+ for (i = 0; i < ctf_fs_trace->ds_file_groups->len; i++) {
+ struct ctf_fs_ds_file_group *ds_file_group =
+ g_ptr_array_index(ctf_fs_trace->ds_file_groups, i);
+ name = get_stream_instance_unique_name(ds_file_group);
+
+ if (!name) {
+ goto error;
+ }
+
+ if (ds_file_group->sc->ir_sc) {
+ BT_ASSERT(ctf_fs_trace->trace);
+
+ if (ds_file_group->stream_id == UINT64_C(-1)) {
+ /* No stream ID: use 0 */
+ ds_file_group->stream = bt_stream_create_with_id(
+ ds_file_group->sc->ir_sc,
+ ctf_fs_trace->trace,
+ ctf_fs_trace->next_stream_id);
+ ctf_fs_trace->next_stream_id++;
+ } else {
+ /* Specific stream ID */
+ ds_file_group->stream = bt_stream_create_with_id(
+ ds_file_group->sc->ir_sc,
+ ctf_fs_trace->trace,
+ (uint64_t) ds_file_group->stream_id);
+ }
+ } else {
+ ds_file_group->stream = NULL;
+ }
+
+ if (!ds_file_group->stream) {
+ BT_LOGE("Cannot create stream for DS file group: "
+ "addr=%p, stream-name=\"%s\"",
+ ds_file_group, name->str);
+ goto error;
+ }
+
+ ret = bt_stream_set_name(ds_file_group->stream,
+ name->str);
+ if (ret) {
+ BT_LOGE("Cannot set stream's name: "
+ "addr=%p, stream-name=\"%s\"",
+ ds_file_group->stream, name->str);
+ goto error;
+ }
+
+ g_string_free(name, TRUE);
+ name = NULL;
+ }
+
+ ret = 0;
+ goto end;
+
+error:
+ ret = -1;
+
+end:
+
+ if (name) {
+ g_string_free(name, TRUE);
+ }
+ return ret;
+}
+
+bool validate_paths_parameter(const bt_value *paths)
+{
+ bool ret;
+ bt_value_type type;
+ uint64_t i;
+
+ if (!paths) {
+ BT_LOGE("missing \"paths\" parameter");
+ goto error;
+ }
+
+ type = bt_value_get_type(paths);
+ if (type != BT_VALUE_TYPE_ARRAY) {
+ BT_LOGE("`paths` parameter: expecting array value: type=%s",
+ bt_common_value_type_string(type));
+ goto error;
+ }
+
+ for (i = 0; i < bt_value_array_get_size(paths); i++) {
+ const bt_value *elem;
+
+ elem = bt_value_array_borrow_element_by_index_const(paths, i);
+ type = bt_value_get_type(elem);
+ if (type != BT_VALUE_TYPE_STRING) {
+ BT_LOGE("`paths` parameter: expecting string value: index=%" PRIu64 ", type=%s",
+ i, bt_common_value_type_string(type));
+ goto error;
+ }
+ }
+
+ ret = true;
+ goto end;
+
+error:
+ ret = false;
+
+end:
+ return ret;
+}
+
+static
+struct ctf_fs_component *ctf_fs_create(
+ bt_self_component_source *self_comp,
+ const bt_value *params)
+{
+ struct ctf_fs_component *ctf_fs = NULL;
+ const bt_value *value = NULL;
+ guint i;
+ const bt_value *paths_value;
+
+ paths_value = bt_value_map_borrow_entry_value_const(params, "paths");
+ if (!validate_paths_parameter(paths_value)) {
+ goto error;
+ }
+
+ ctf_fs = ctf_fs_component_create();