X-Git-Url: https://git.lttng.org/?p=lttng-tools.git;a=blobdiff_plain;f=lttng-sessiond%2Futils.c;h=22a07ffaefd4174d7e2bb2cad1878eefd78d66b4;hp=0da5642109fcc5ddf7eeced026a0d441cb685594;hb=0857097f7cd49f503c966eb42716415dd5540352;hpb=322585731ced1adba36cddcb8bdd5d997d1b2e3e diff --git a/lttng-sessiond/utils.c b/lttng-sessiond/utils.c index 0da564210..22a07ffae 100644 --- a/lttng-sessiond/utils.c +++ b/lttng-sessiond/utils.c @@ -22,8 +22,6 @@ #include #include #include -#include -#include #include #include @@ -54,78 +52,3 @@ const char *get_home_dir(void) { return ((const char *) getenv("HOME")); } - -/* - * Create recursively directory using the FULL path. - */ -int mkdir_recursive(const char *path, mode_t mode, uid_t uid, gid_t gid) -{ - int ret; - char *p, tmp[PATH_MAX]; - size_t len; - mode_t old_umask; - - ret = snprintf(tmp, sizeof(tmp), "%s", path); - if (ret < 0) { - PERROR("snprintf mkdir"); - goto error; - } - - len = ret; - if (tmp[len - 1] == '/') { - tmp[len - 1] = 0; - } - - old_umask = umask(0); - for (p = tmp + 1; *p; p++) { - if (*p == '/') { - *p = 0; - ret = mkdir(tmp, mode); - if (ret < 0) { - if (!(errno == EEXIST)) { - PERROR("mkdir recursive"); - ret = -errno; - goto umask_error; - } - } else if (ret == 0) { - /* - * We created the directory. Set its ownership to the - * user/group specified. - */ - ret = chown(tmp, uid, gid); - if (ret < 0) { - PERROR("chown in mkdir recursive"); - ret = -errno; - goto umask_error; - } - } - *p = '/'; - } - } - - ret = mkdir(tmp, mode); - if (ret < 0) { - if (!(errno == EEXIST)) { - PERROR("mkdir recursive last piece"); - ret = -errno; - } else { - ret = 0; - } - } else if (ret == 0) { - /* - * We created the directory. Set its ownership to the user/group - * specified. - */ - ret = chown(tmp, uid, gid); - if (ret < 0) { - PERROR("chown in mkdir recursive"); - ret = -errno; - goto umask_error; - } - } - -umask_error: - umask(old_umask); -error: - return ret; -}