/*
* Copyright (C) 2011 - David Goulet <david.goulet@polymtl.ca>
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the Free
- * Software Foundation; only version 2 of the License.
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License, version 2 only,
+ * as published by the Free Software Foundation.
*
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
*
- * You should have received a copy of the GNU General Public License along with
- * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
- * Place - Suite 330, Boston, MA 02111-1307, USA.
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#define _GNU_SOURCE
if (kevent == NULL) {
ret = kernel_create_event(event, kchan);
if (ret < 0) {
- if (ret == -EEXIST) {
+ switch (-ret) {
+ case EEXIST:
ret = LTTCOMM_KERN_EVENT_EXIST;
- } else {
+ break;
+ case ENOSYS:
+ ret = LTTCOMM_KERN_EVENT_ENOSYS;
+ break;
+ default:
ret = LTTCOMM_KERN_ENABLE_FAIL;
+ break;
}
goto end;
}
ret = LTTCOMM_KERN_ENABLE_FAIL;
goto end;
}
+ } else {
+ /* At this point, the event is considered enabled */
+ ret = LTTCOMM_KERN_EVENT_EXIST;
+ goto end;
}
+
ret = LTTCOMM_OK;
end:
return ret;
int event_kernel_enable_all(struct ltt_kernel_session *ksession,
struct ltt_kernel_channel *kchan, int kernel_tracer_fd)
{
- int ret;
+ int tp_ret;
- ret = event_kernel_enable_all_tracepoints(ksession, kchan, kernel_tracer_fd);
- if (ret != LTTCOMM_OK) {
+ tp_ret = event_kernel_enable_all_tracepoints(ksession, kchan, kernel_tracer_fd);
+ if (tp_ret != LTTCOMM_OK) {
goto end;
}
- ret = event_kernel_enable_all_syscalls(ksession, kchan, kernel_tracer_fd);
+
+ /*
+ * Reaching this code path means that all tracepoints were enabled without
+ * errors so we ignore the error value of syscalls.
+ *
+ * At the moment, failing to enable syscalls on "lttng enable-event -a -k"
+ * is not considered an error that need to be returned to the client since
+ * tracepoints did not fail. Future work will allow us to send back
+ * multiple errors to the client in one API call.
+ */
+ (void) event_kernel_enable_all_syscalls(ksession, kchan, kernel_tracer_fd);
+
end:
- return ret;
+ return tp_ret;
}
/*
int event_ust_enable_all_tracepoints(struct ltt_ust_session *usess, int domain,
struct ltt_ust_channel *uchan)
{
- int ret, i;
- size_t size;
+ int ret, i, size;
struct lttng_ht_iter iter;
struct ltt_ust_event *uevent = NULL;
struct lttng_event *events = NULL;
case LTTNG_DOMAIN_UST_PID_FOLLOW_CHILDREN:
#endif
default:
- ret = LTTCOMM_NOT_IMPLEMENTED;
+ ret = LTTCOMM_UND;
goto error;
}
case LTTNG_DOMAIN_UST_PID_FOLLOW_CHILDREN:
#endif
default:
- ret = LTTCOMM_NOT_IMPLEMENTED;
+ ret = LTTCOMM_UND;
goto end;
}
case LTTNG_DOMAIN_UST_PID_FOLLOW_CHILDREN:
#endif
default:
- ret = LTTCOMM_NOT_IMPLEMENTED;
+ ret = LTTCOMM_UND;
goto error;
}
int event_ust_disable_all_tracepoints(struct ltt_ust_session *usess, int domain,
struct ltt_ust_channel *uchan)
{
- int ret, i;
- size_t size;
+ int ret, i, size;
struct lttng_ht_iter iter;
struct ltt_ust_event *uevent = NULL;
struct lttng_event *events = NULL;
case LTTNG_DOMAIN_UST_PID_FOLLOW_CHILDREN:
#endif
default:
- ret = LTTCOMM_NOT_IMPLEMENTED;
+ ret = LTTCOMM_UND;
goto error;
}