X-Git-Url: https://git.lttng.org/?p=lttng-tools.git;a=blobdiff_plain;f=src%2Fcommon%2Findex%2Findex.c;h=89b4fd769eab98a49137fb08087388caec4469e4;hp=3d22ca61cc1ad720e7e50270137053c6d5f5a787;hb=1c20f0e29cbf8627bfb1ff444572d52d6655c4e2;hpb=3c4599b9a5c12ceff19368c6cd51e01d81824726 diff --git a/src/common/index/index.c b/src/common/index/index.c index 3d22ca61c..89b4fd769 100644 --- a/src/common/index/index.c +++ b/src/common/index/index.c @@ -18,6 +18,7 @@ #define _GNU_SOURCE #include +#include #include #include @@ -35,8 +36,25 @@ int index_create_file(char *path_name, char *stream_name, int uid, int gid, { int ret, fd = -1; struct lttng_packet_index_file_hdr hdr; + char fullpath[PATH_MAX]; - ret = utils_create_stream_file(path_name, stream_name, size, count, uid, + ret = snprintf(fullpath, sizeof(fullpath), "%s/" DEFAULT_INDEX_DIR, + path_name); + if (ret < 0) { + PERROR("snprintf index path"); + goto error; + } + + /* Create index directory if necessary. */ + ret = run_as_mkdir(fullpath, S_IRWXU | S_IRWXG, uid, gid); + if (ret < 0) { + if (ret != -EEXIST) { + ERR("Index trace directory creation error"); + goto error; + } + } + + ret = utils_create_stream_file(fullpath, stream_name, size, count, uid, gid, DEFAULT_INDEX_FILE_SUFFIX); if (ret < 0) { goto error;