+static int lttng_ust_event_notifier_enabler_create(int event_notifier_group_obj,
+ void *owner, struct lttng_ust_abi_event_notifier *event_notifier_param,
+ enum lttng_enabler_format_type type)
+{
+ struct lttng_event_notifier_group *event_notifier_group =
+ objd_private(event_notifier_group_obj);
+ struct lttng_event_notifier_enabler *event_notifier_enabler;
+ int event_notifier_objd, ret;
+
+ event_notifier_param->event.name[LTTNG_UST_ABI_SYM_NAME_LEN - 1] = '\0';
+ event_notifier_objd = objd_alloc(NULL, <tng_event_notifier_enabler_ops, owner,
+ "event_notifier enabler");
+ if (event_notifier_objd < 0) {
+ ret = event_notifier_objd;
+ goto objd_error;
+ }
+
+ event_notifier_enabler = lttng_event_notifier_enabler_create(
+ event_notifier_group, type, event_notifier_param);
+ if (!event_notifier_enabler) {
+ ret = -ENOMEM;
+ goto event_notifier_error;
+ }
+
+ objd_set_private(event_notifier_objd, event_notifier_enabler);
+ /* The event_notifier holds a reference on the event_notifier group. */
+ objd_ref(event_notifier_enabler->group->objd);
+
+ return event_notifier_objd;
+
+event_notifier_error:
+ {
+ int err;
+
+ err = lttng_ust_abi_objd_unref(event_notifier_objd, 1);
+ assert(!err);
+ }
+objd_error:
+ return ret;
+}
+
+static
+long lttng_event_notifier_enabler_cmd(int objd, unsigned int cmd, unsigned long arg,
+ union lttng_ust_abi_args *uargs, void *owner)
+{
+ struct lttng_event_notifier_enabler *event_notifier_enabler = objd_private(objd);
+ switch (cmd) {
+ case LTTNG_UST_ABI_FILTER:
+ return lttng_event_notifier_enabler_attach_filter_bytecode(
+ event_notifier_enabler,
+ (struct lttng_ust_bytecode_node **) arg);
+ case LTTNG_UST_ABI_EXCLUSION:
+ return lttng_event_notifier_enabler_attach_exclusion(event_notifier_enabler,
+ (struct lttng_ust_excluder_node **) arg);
+ case LTTNG_UST_ABI_CAPTURE:
+ return lttng_event_notifier_enabler_attach_capture_bytecode(
+ event_notifier_enabler,
+ (struct lttng_ust_bytecode_node **) arg);
+ case LTTNG_UST_ABI_ENABLE:
+ return lttng_event_notifier_enabler_enable(event_notifier_enabler);
+ case LTTNG_UST_ABI_DISABLE:
+ return lttng_event_notifier_enabler_disable(event_notifier_enabler);
+ default:
+ return -EINVAL;
+ }
+}
+
+/**
+ * lttng_event_notifier_group_error_counter_cmd - lttng event_notifier group error counter object command
+ *
+ * @obj: the object
+ * @cmd: the command
+ * @arg: command arg
+ * @uargs: UST arguments (internal)
+ * @owner: objd owner
+ *
+ * This descriptor implements lttng commands:
+ * LTTNG_UST_ABI_COUNTER_GLOBAL
+ * Return negative error code on error, 0 on success.
+ * LTTNG_UST_ABI_COUNTER_CPU
+ * Return negative error code on error, 0 on success.
+ */
+static
+long lttng_event_notifier_group_error_counter_cmd(int objd, unsigned int cmd, unsigned long arg,
+ union lttng_ust_abi_args *uargs, void *owner)
+{
+ int ret;
+ struct lttng_counter *counter = objd_private(objd);
+
+ switch (cmd) {
+ case LTTNG_UST_ABI_COUNTER_GLOBAL:
+ ret = -EINVAL; /* Unimplemented. */
+ break;
+ case LTTNG_UST_ABI_COUNTER_CPU:
+ {
+ struct lttng_ust_abi_counter_cpu *counter_cpu =
+ (struct lttng_ust_abi_counter_cpu *)arg;
+
+ ret = lttng_counter_set_cpu_shm(counter->counter,
+ counter_cpu->cpu_nr, uargs->counter_shm.shm_fd);
+ if (!ret) {
+ /* Take ownership of the shm_fd. */
+ uargs->counter_shm.shm_fd = -1;
+ }
+ break;
+ }
+ default:
+ ret = -EINVAL;
+ break;
+ }
+
+ return ret;
+}
+
+__attribute__((visibility("hidden")))
+int lttng_release_event_notifier_group_error_counter(int objd)
+{
+ struct lttng_counter *counter = objd_private(objd);
+
+ if (counter) {
+ return lttng_ust_abi_objd_unref(counter->event_notifier_group->objd, 0);
+ } else {
+ return -EINVAL;
+ }
+}
+
+static const struct lttng_ust_abi_objd_ops lttng_event_notifier_group_error_counter_ops = {
+ .release = lttng_release_event_notifier_group_error_counter,
+ .cmd = lttng_event_notifier_group_error_counter_cmd,