X-Git-Url: http://git.efficios.com/?a=blobdiff_plain;f=lib%2Fctf-writer%2Fwriter.c;h=2978cdfb78a02affa2f7b0e32193eb44225d10cd;hb=ebd0404825a8b8b7d5701933f0acfcd3a8b534a7;hp=a5efe4775c37468b296dfb990f78e39fb6f46834;hpb=04394229f0daeeb36a09ea64f3208fe051fd9ca0;p=babeltrace.git diff --git a/lib/ctf-writer/writer.c b/lib/ctf-writer/writer.c index a5efe477..2978cdfb 100644 --- a/lib/ctf-writer/writer.c +++ b/lib/ctf-writer/writer.c @@ -109,6 +109,7 @@ struct bt_ctf_writer *bt_ctf_writer_create(const char *path) int ret; struct bt_ctf_writer *writer = NULL; unsigned char uuid[16]; + char *metadata_path = NULL; if (!path) { goto error; @@ -119,6 +120,8 @@ struct bt_ctf_writer *bt_ctf_writer_create(const char *path) goto error; } + metadata_path = g_build_filename(path, "metadata", NULL); + bt_object_init(writer, bt_ctf_writer_destroy); writer->path = g_string_new(path); if (!writer->path) { @@ -161,22 +164,21 @@ struct bt_ctf_writer *bt_ctf_writer_create(const char *path) goto error_destroy; } - writer->trace_dir_fd = open(path, O_RDONLY, S_IRWXU | S_IRWXG); - if (writer->trace_dir_fd < 0) { + writer->metadata_fd = open(metadata_path, + O_WRONLY | O_CREAT | O_TRUNC, + S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP); + if (writer->metadata_fd < 0) { perror("open"); goto error_destroy; } - writer->metadata_fd = openat(writer->trace_dir_fd, "metadata", - O_WRONLY | O_CREAT | O_TRUNC, - S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP); - + g_free(metadata_path); return writer; error_destroy: - unlinkat(writer->trace_dir_fd, "metadata", 0); BT_PUT(writer); error: + g_free(metadata_path); return writer; } @@ -190,12 +192,6 @@ void bt_ctf_writer_destroy(struct bt_object *obj) g_string_free(writer->path, TRUE); } - if (writer->trace_dir_fd > 0) { - if (close(writer->trace_dir_fd)) { - perror("close"); - } - } - if (writer->metadata_fd > 0) { if (close(writer->metadata_fd)) { perror("close");