Add a method to create a directory handle relative to another one
[lttng-tools.git] / src / common / utils.c
index aada37fe707d156bc0a22425e2c0ad04a291b81e..a91ede65c84af5d5c1d01797dc5766ee7e16057b 100644 (file)
@@ -679,16 +679,20 @@ int utils_mkdir(const char *path, mode_t mode, int uid, int gid)
 {
        int ret;
        struct lttng_directory_handle handle;
-       struct lttng_credentials creds = {
+       const struct lttng_credentials creds = {
                .uid = (uid_t) uid,
                .gid = (gid_t) gid,
        };
 
-       (void) lttng_directory_handle_init(&handle, NULL);
+       ret = lttng_directory_handle_init(&handle, NULL);
+       if (ret) {
+               goto end;
+       }
        ret = lttng_directory_handle_create_subdirectory_as_user(
                        &handle, path, mode,
                        (uid >= 0 || gid >= 0) ? &creds : NULL);
        lttng_directory_handle_fini(&handle);
+end:
        return ret;
 }
 
@@ -703,16 +707,20 @@ int utils_mkdir_recursive(const char *path, mode_t mode, int uid, int gid)
 {
        int ret;
        struct lttng_directory_handle handle;
-       struct lttng_credentials creds = {
+       const struct lttng_credentials creds = {
                .uid = (uid_t) uid,
                .gid = (gid_t) gid,
        };
 
-       (void) lttng_directory_handle_init(&handle, NULL);
+       ret = lttng_directory_handle_init(&handle, NULL);
+       if (ret) {
+               goto end;
+       }
        ret = lttng_directory_handle_create_subdirectory_recursive_as_user(
                        &handle, path, mode,
                        (uid >= 0 || gid >= 0) ? &creds : NULL);
        lttng_directory_handle_fini(&handle);
+end:
        return ret;
 }
 
This page took 0.025532 seconds and 5 git commands to generate.