- trace_ids = g_array_new(FALSE, TRUE, sizeof(int));
-
- while ((node = fts_read(tree))) {
- int dirfd, metafd;
-
- if (!(node->fts_info & FTS_D))
- continue;
-
- dirfd = open(node->fts_accpath, 0);
- if (dirfd < 0) {
- fprintf(stdout, "[warning] unable to open trace "
- "directory file descriptor.\n");
- continue;
- }
- metafd = openat(dirfd, "metadata", O_RDONLY);
- if (metafd < 0) {
- ret = close(dirfd);
- if (ret < 0) {
- perror("close");
- goto error;
- }
- } else {
- int trace_id;
-
- ret = close(metafd);
- if (ret < 0) {
- perror("close");
- goto error;
- }
- ret = close(dirfd);
- if (ret < 0) {
- perror("close");
- goto error;
- }
-
- trace_id = bt_context_add_trace(ctx,
- node->fts_accpath, format_str);
- if (trace_id < 0) {
- fprintf(stdout, "[warning] CTX opening trace \"%s\"from %s "
- "for reading.\n\n", node->fts_accpath, path);
- continue;
- }
- g_array_append_val(trace_ids, trace_id);
- }
- }
-
- g_array_free(trace_ids, TRUE);
- return 0;