Distinguish UST return codes from transport return codes
[lttng-ust.git] / liblttng-ust / lttng-ust-abi.c
index fded1e3a806072c0fe8716a5c13d2ee654a54a8f..bbbcd062e1bd19026820f20ed64046009d021a14 100644 (file)
@@ -38,6 +38,7 @@
  */
 
 #include <lttng/ust-abi.h>
+#include <lttng/ust-error.h>
 #include <urcu/compiler.h>
 #include <urcu/list.h>
 #include <lttng/ust-events.h>
@@ -263,9 +264,9 @@ static
 long lttng_abi_tracer_version(int objd,
        struct lttng_ust_tracer_version *v)
 {
-       v->major = LTTNG_UST_MAJOR_VERSION;
-       v->minor = LTTNG_UST_MINOR_VERSION;
-       v->patchlevel = LTTNG_UST_PATCHLEVEL_VERSION;
+       v->major = LTTNG_UST_INTERNAL_MAJOR_VERSION;
+       v->minor = LTTNG_UST_INTERNAL_MINOR_VERSION;
+       v->patchlevel = LTTNG_UST_INTERNAL_PATCHLEVEL_VERSION;
        return 0;
 }
 
@@ -361,7 +362,7 @@ void lttng_metadata_create_events(int channel_objd)
         * We tolerate no failure path after event creation. It will stay
         * invariant for the rest of the session.
         */
-       ret = ltt_event_create(channel, &metadata_params, NULL, NULL, &event);
+       ret = ltt_event_create(channel, &metadata_params, &event);
        if (ret < 0) {
                goto create_error;
        }
@@ -541,7 +542,7 @@ long lttng_tracepoint_list_cmd(int objd, unsigned int cmd, unsigned long arg,
        retry:
                iter = lttng_ust_tracepoint_list_get_iter_next(list);
                if (!iter)
-                       return -ENOENT;
+                       return -LTTNG_UST_ERR_NOENT;
                if (!strcmp(iter->name, "lttng_ust:metadata"))
                        goto retry;
                memcpy(tp, iter, sizeof(*tp));
@@ -623,7 +624,7 @@ long lttng_tracepoint_field_list_cmd(int objd, unsigned int cmd,
        retry:
                iter = lttng_ust_field_list_get_iter_next(list);
                if (!iter)
-                       return -ENOENT;
+                       return -LTTNG_UST_ERR_NOENT;
                if (!strcmp(iter->event_name, "lttng_ust:metadata"))
                        goto retry;
                memcpy(tp, iter, sizeof(*tp));
@@ -753,7 +754,7 @@ int lttng_abi_create_event(int channel_objd,
         * We tolerate no failure path after event creation. It will stay
         * invariant for the rest of the session.
         */
-       ret = ltt_event_create(channel, event_param, NULL, NULL, &event);
+       ret = ltt_event_create(channel, event_param, &event);
        if (ret < 0) {
                goto event_error;
        }
@@ -1035,6 +1036,8 @@ static const struct lttng_ust_objd_ops lib_ring_buffer_objd_ops = {
  *             Enable recording for this event (weak enable)
  *     LTTNG_UST_DISABLE
  *             Disable recording for this event (strong disable)
+ *     LTTNG_UST_FILTER
+ *             Attach a filter to an event.
  */
 static
 long lttng_event_cmd(int objd, unsigned int cmd, unsigned long arg,
@@ -1051,6 +1054,17 @@ long lttng_event_cmd(int objd, unsigned int cmd, unsigned long arg,
                return ltt_event_enable(event);
        case LTTNG_UST_DISABLE:
                return ltt_event_disable(event);
+       case LTTNG_UST_FILTER:
+       {
+               int ret;
+               ret = lttng_filter_event_attach_bytecode(event,
+                               (struct lttng_ust_filter_bytecode *) arg);
+               if (ret)
+                       return ret;
+               lttng_filter_event_link_bytecode(event,
+                               event->filter_bytecode);
+               return 0;
+       }
        default:
                return -EINVAL;
        }
@@ -1088,6 +1102,8 @@ static const struct lttng_ust_objd_ops lttng_event_ops = {
  *             Enable recording for these wildcard events (weak enable)
  *     LTTNG_UST_DISABLE
  *             Disable recording for these wildcard events (strong disable)
+ *     LTTNG_UST_FILTER
+ *             Attach a filter to a wildcard.
  */
 static
 long lttng_wildcard_cmd(int objd, unsigned int cmd, unsigned long arg,
@@ -1107,6 +1123,17 @@ long lttng_wildcard_cmd(int objd, unsigned int cmd, unsigned long arg,
                return ltt_wildcard_enable(wildcard);
        case LTTNG_UST_DISABLE:
                return ltt_wildcard_disable(wildcard);
+       case LTTNG_UST_FILTER:
+       {
+               int ret;
+
+               ret = lttng_filter_wildcard_attach_bytecode(wildcard,
+                               (struct lttng_ust_filter_bytecode *) arg);
+               if (ret)
+                       return ret;
+               lttng_filter_wildcard_link_bytecode(wildcard);
+               return 0;
+       }
        default:
                return -EINVAL;
        }
This page took 0.024631 seconds and 4 git commands to generate.