X-Git-Url: http://git.efficios.com/?p=babeltrace.git;a=blobdiff_plain;f=lib%2Fcontext.c;h=3cbafa07c5ba6b09e6af94653d480accda2038f2;hp=507e90abb92d0abb7d94a06d1fe8d863b0a10f79;hb=02dc4610b1dccefaf545ba77378857ee6188ea33;hpb=08c22d055e49b0f6ba55a1a8a2684372a62902cd diff --git a/lib/context.c b/lib/context.c index 507e90ab..3cbafa07 100644 --- a/lib/context.c +++ b/lib/context.c @@ -67,17 +67,17 @@ int bt_context_add_trace(struct bt_context *ctx, const char *path, td = fmt->open_trace(path, O_RDONLY, ctf_move_pos_slow, NULL); if (!td) { - fprintf(stdout, "[error] [Context] Cannot Open_trace of the format %s .\n\n", + fprintf(stderr, "[error] [Context] Cannot open_trace of the format %s .\n\n", path); - return 0; + return -1; } /* Create an handle for the trace */ handle = bt_trace_handle_create(ctx); if (handle < 0) { - fprintf(stdout, "[error] [Context] Creating trace handle %s .\n\n", + fprintf(stderr, "[error] [Context] Creating trace handle %s .\n\n", path); - return 0; + return -1; } handle->format = fmt; handle->td = td; @@ -88,15 +88,14 @@ int bt_context_add_trace(struct bt_context *ctx, const char *path, g_hash_table_insert(ctx->trace_handles, (gpointer) (unsigned long) handle->id, handle); - trace_collection_add(ctx->tc, td); - return handle->id; + return trace_collection_add(ctx->tc, td); } /* * Unable to open toplevel: failure. * Unable to open some subdirectory or file: warn and continue; */ -int bt_context_add_traces(struct bt_context *ctx, const char *path, +int bt_context_add_traces_recursive(struct bt_context *ctx, const char *path, const char *format_str) { FTS *tree; @@ -115,7 +114,7 @@ int bt_context_add_traces(struct bt_context *ctx, const char *path, tree = fts_open(paths, FTS_NOCHDIR | FTS_LOGICAL, 0); if (tree == NULL) { - fprintf(stdout, "[error] Cannot traverse \"%s\" for reading.\n\n", + fprintf(stderr, "[error] [Context] Cannot traverse \"%s\" for reading.\n", path); return -EINVAL; } @@ -130,9 +129,10 @@ int bt_context_add_traces(struct bt_context *ctx, const char *path, dirfd = open(node->fts_accpath, 0); if (dirfd < 0) { - fprintf(stdout, "[warning] unable to open trace " + fprintf(stderr, "[error] [Context] Unable to open trace " "directory file descriptor.\n"); - continue; + ret = dirfd; + goto error; } metafd = openat(dirfd, "metadata", O_RDONLY); if (metafd < 0) { @@ -158,9 +158,10 @@ int bt_context_add_traces(struct bt_context *ctx, const char *path, 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; + fprintf(stderr, "[error] [Context] opening trace \"%s\" from %s " + "for reading.\n", node->fts_accpath, path); + ret = trace_id; + goto error; } g_array_append_val(trace_ids, trace_id); }