* SOFTWARE.
*/
-#define BT_LOG_TAG "WRITER"
+#define BT_LOG_TAG "CTF-WRITER"
#include <babeltrace/lib-logging-internal.h>
#include <babeltrace/ctf-writer/clock-internal.h>
int ret;
struct bt_ctf_writer *writer = NULL;
unsigned char uuid[16];
+ char *metadata_path = NULL;
if (!path) {
goto error;
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) {
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;
}
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");