index common code: introduce lttng_index_file_unlink
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Wed, 3 Apr 2019 20:29:44 +0000 (16:29 -0400)
committerJonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Wed, 10 Apr 2019 23:36:37 +0000 (19:36 -0400)
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
src/common/index/index.c
src/common/index/index.h

index 9bfb56fa0b7a6a3c9c475e028473c297a9e5779a..07d2cf3c01ed9bd9c2798fd16be595e9a14f1675 100644 (file)
@@ -78,11 +78,15 @@ struct lttng_index_file *lttng_index_file_create(char *path_name,
         */
        ret = utils_unlink_stream_file(fullpath, stream_name, size, count, uid,
                        gid, DEFAULT_INDEX_FILE_SUFFIX);
+       DBG("utils_unlink_stream_file %s %s ret %d errno %d",
+                       fullpath, stream_name, ret, errno);
        if (ret < 0 && errno != ENOENT) {
                goto error;
        }
        ret = utils_create_stream_file(fullpath, stream_name, size, count, uid,
                        gid, DEFAULT_INDEX_FILE_SUFFIX);
+       DBG("utils_create_stream_file %s %s ret %d errno %d",
+                       fullpath, stream_name, ret, errno);
        if (ret < 0) {
                goto error;
        }
@@ -119,6 +123,34 @@ error:
        return NULL;
 }
 
+int lttng_index_file_unlink(char *path_name,
+               char *stream_name, int uid, int gid,
+               uint64_t tracefile_size,
+               uint64_t tracefile_count_current)
+{
+       int ret;
+       char fullpath[PATH_MAX];
+
+       ret = snprintf(fullpath, sizeof(fullpath), "%s/" DEFAULT_INDEX_DIR,
+                       path_name);
+       if (ret < 0) {
+               PERROR("snprintf index path");
+               goto error;
+       }
+
+       ret = utils_unlink_stream_file(fullpath, stream_name,
+                       tracefile_size, tracefile_count_current, uid,
+                       gid, DEFAULT_INDEX_FILE_SUFFIX);
+       if (ret < 0 && errno != ENOENT) {
+               goto error;
+       }
+
+       return 0;
+
+error:
+       return -1;
+}
+
 /*
  * Write index values to the given index file.
  *
index 7020936b646b33142f3d2021d5f540bac08f29dd..b240969e228173668fc9ed539a0401b67c0e0940 100644 (file)
@@ -40,6 +40,9 @@ struct lttng_index_file {
 struct lttng_index_file *lttng_index_file_create(char *path_name,
                char *stream_name, int uid, int gid, uint64_t size,
                uint64_t count, uint32_t major, uint32_t minor);
+int lttng_index_file_unlink(char *path_name,
+               char *stream_name, int uid, int gid,
+               uint64_t tracefile_size, uint64_t tracefile_count_current);
 struct lttng_index_file *lttng_index_file_open(const char *path_name,
                const char *channel_name, uint64_t tracefile_count,
                uint64_t tracefile_count_current);
This page took 0.028116 seconds and 5 git commands to generate.