Fix: return EINVAL if agent registration fails
[lttng-tools.git] / src / lib / lttng-ctl / lttng-ctl.c
index c5aada5bec9b46af9e26ce74c606f1a74553a2bf..ff57a0d1a7a70237e396274b8a4847f1194beb3d 100644 (file)
@@ -919,10 +919,10 @@ int lttng_enable_event_with_exclusions(struct lttng_handle *handle,
                                sizeof(lsm.u.enable.channel_name));
        }
 
-       if (ev->name[0] != '\0') {
-               lsm.cmd_type = LTTNG_ENABLE_EVENT;
-       } else {
-               lsm.cmd_type = LTTNG_ENABLE_ALL_EVENT;
+       lsm.cmd_type = LTTNG_ENABLE_EVENT;
+       if (ev->name[0] == '\0') {
+               /* Enable all events */
+               lttng_ctl_copy_string(ev->name, "*", sizeof(ev->name));
        }
 
        lttng_ctl_copy_lttng_domain(&lsm.domain, &handle->domain);
@@ -1081,10 +1081,10 @@ int lttng_disable_event_ext(struct lttng_handle *handle,
                                sizeof(lsm.u.disable.channel_name));
        }
 
-       if (ev->name[0] != '\0') {
-               lsm.cmd_type = LTTNG_DISABLE_EVENT;
-       } else {
-               lsm.cmd_type = LTTNG_DISABLE_ALL_EVENT;
+       lsm.cmd_type = LTTNG_DISABLE_EVENT;
+       if (ev->name[0] == '\0') {
+               /* Disable all events */
+               lttng_ctl_copy_string(ev->name, "*", sizeof(ev->name));
        }
 
        lttng_ctl_copy_lttng_domain(&lsm.domain, &handle->domain);
@@ -1323,6 +1323,35 @@ int lttng_list_tracepoint_fields(struct lttng_handle *handle,
        return ret / sizeof(struct lttng_event_field);
 }
 
+/*
+ *  Lists all available kernel system calls. Allocates and sets the contents of
+ *  the events array.
+ *
+ *  Returns the number of lttng_event entries in events; on error, returns a
+ *  negative value.
+ */
+int lttng_list_syscalls(struct lttng_event **events)
+{
+       int ret;
+       struct lttcomm_session_msg lsm;
+
+       if (!events) {
+               return -LTTNG_ERR_INVALID;
+       }
+
+       memset(&lsm, 0, sizeof(lsm));
+       lsm.cmd_type = LTTNG_LIST_SYSCALLS;
+       /* Force kernel domain for system calls. */
+       lsm.domain.type = LTTNG_DOMAIN_KERNEL;
+
+       ret = lttng_ctl_ask_sessiond(&lsm, (void **) events);
+       if (ret < 0) {
+               return ret;
+       }
+
+       return ret / sizeof(struct lttng_event);
+}
+
 /*
  *  Returns a human readable string describing
  *  the error code (a negative value).
This page took 0.027636 seconds and 5 git commands to generate.