+ ret = create_argv(wa, " \t\n", &argv);
+ if (ret < 0)
+ goto fail;
+ argc = ret;
+ ret = lls(lls_lookup_subcmd(argv[0], write_cmd_suite, &errctx));
+ if (ret < 0)
+ goto free_argv;
+ writer_num = ret;
+ cmd = WRITE_CMD(writer_num);
+ if (!writer_supported(writer_num)) {
+ ret = -ERRNO_TO_PARA_ERROR(EINVAL);
+ errctx = make_message("%s writer is not supported",
+ lls_command_name(cmd));
+ goto free_argv;
+ }
+parse:
+ ret = lls(lls_parse(argc, argv, cmd, lprp, &errctx));
+ if (ret >= 0)
+ ret = writer_num;
+free_argv:
+ free_argv(argv);
+ if (ret >= 0)
+ return ret;
+fail:
+ if (errctx)
+ PARA_ERROR_LOG("%s\n", errctx);
+ free(errctx);
+ PARA_EMERG_LOG("%s\n", para_strerror(-ret));
+ exit(EXIT_FAILURE);
+}
+
+/**
+ * Open a writer node and register the corresponding task.
+ *
+ * \param wn The writer node to open.
+ * \param parent The parent btr node (the source for the writer node).
+ * \param s The scheduler instance to register the task to.
+ */
+void register_writer_node(struct writer_node *wn, struct btr_node *parent,
+ struct sched *s)
+{
+ const struct writer *w = writer_get(wn->wid);
+
+ wn->btrn = btr_new_node(&(struct btr_node_description)
+ EMBRACE(.name = writer_name(wn->wid), .parent = parent,
+ .handler = w->execute, .context = wn));
+ wn->task = task_register(&(struct task_info) {
+ .name = writer_name(wn->wid),
+ .pre_select = w->pre_select,
+ .post_select = w->post_select,
+ .context = wn,
+ }, s);