#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
-#include <sys/mman.h>
-#include <babeltrace/compat/dirent.h>
+#include <babeltrace/compat/mman-internal.h>
+#include <dirent.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <babeltrace/babeltrace-internal.h>
#include <babeltrace/ctf/types.h>
-#include <babeltrace/compat/uuid.h>
-#include <babeltrace/compat/utc.h>
-#include <babeltrace/compat/stdio.h>
-#include <babeltrace/endian.h>
+#include <babeltrace/compat/uuid-internal.h>
+#include <babeltrace/compat/utc-internal.h>
+#include <babeltrace/compat/stdio-internal.h>
+#include <babeltrace/endian-internal.h>
#define NSEC_PER_USEC 1000UL
#define NSEC_PER_MSEC 1000000UL
{
int fd, metadata_fd, ret;
DIR *dir;
- int dir_fd;
FILE *metadata_fp;
+ char *file_path;
ret = parse_args(argc, argv);
if (ret) {
perror("opendir");
goto error_rmdir;
}
- dir_fd = bt_dirfd(dir);
- if (dir_fd < 0) {
- perror("dirfd");
+
+ file_path = g_build_filename(s_outputname, "datastream", NULL);
+ if (file_path == NULL) {
+ perror("g_build_filename");
goto error_closedir;
}
-
- fd = openat(dir_fd, "datastream", O_RDWR|O_CREAT,
+ fd = open(file_path, O_RDWR|O_CREAT,
S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP);
+ g_free(file_path);
if (fd < 0) {
- perror("openat");
- goto error_closedirfd;
+ perror("open");
+ goto error_closedir;
}
- metadata_fd = openat(dir_fd, "metadata", O_RDWR|O_CREAT,
+ file_path = g_build_filename(s_outputname, "metadata", NULL);
+ if (file_path == NULL) {
+ perror("g_build_filename");
+ goto error_closedatastream;
+ }
+ metadata_fd = open(file_path, O_RDWR|O_CREAT,
S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP);
+ g_free(file_path);
if (metadata_fd < 0) {
- perror("openat");
+ perror("open");
goto error_closedatastream;
}
metadata_fp = fdopen(metadata_fd, "w");
ret = close(fd);
if (ret)
perror("close");
-error_closedirfd:
- ret = close(dir_fd);
- if (ret)
- perror("close");
error_closedir:
ret = closedir(dir);
if (ret)