X-Git-Url: https://git.lttng.org/?p=lttng-tools.git;a=blobdiff_plain;f=src%2Fcommon%2Futils.c;h=17a313ee16f66efe8c574ddfddc8f94f156b9e11;hp=664ba3e8e82abbdcf3a0c15614ba9b5858fbea93;hb=cec6b2a556f6880230c326b07facbc3f673ee0c7;hpb=c35f9726a22f1d93e14589688d830efccda196f3 diff --git a/src/common/utils.c b/src/common/utils.c index 664ba3e8e..17a313ee1 100644 --- a/src/common/utils.c +++ b/src/common/utils.c @@ -379,6 +379,9 @@ char *_utils_expand_path(const char *path, bool keep_symlink) /* Resolve partially our path */ absolute_path = utils_partial_realpath(absolute_path, absolute_path, LTTNG_PATH_MAX); + if (!absolute_path) { + goto error; + } } ret = expand_double_slashes_dot_and_dotdot(absolute_path); @@ -765,74 +768,6 @@ int utils_stream_file_path(const char *path_name, const char *file_name, return ret; } -/* - * Create the stream file on disk. - * - * Return 0 on success or else a negative value. - */ -LTTNG_HIDDEN -int utils_create_stream_file(const char *path_name, char *file_name, uint64_t size, - uint64_t count, int uid, int gid, char *suffix) -{ - int ret, flags, mode; - char path[LTTNG_PATH_MAX]; - - ret = utils_stream_file_path(path_name, file_name, - size, count, suffix, path, sizeof(path)); - if (ret < 0) { - goto error; - } - - /* - * With the session rotation feature on the relay, we might need to seek - * and truncate a tracefile, so we need read and write access. - */ - flags = O_RDWR | O_CREAT | O_TRUNC; - /* Open with 660 mode */ - mode = S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP; - - if (uid < 0 || gid < 0) { - ret = open(path, flags, mode); - } else { - ret = run_as_open(path, flags, mode, uid, gid); - } - if (ret < 0) { - PERROR("open stream path %s", path); - } -error: - return ret; -} - -/* - * Unlink the stream tracefile from disk. - * - * Return 0 on success or else a negative value. - */ -LTTNG_HIDDEN -int utils_unlink_stream_file(const char *path_name, char *file_name, uint64_t size, - uint64_t count, int uid, int gid, char *suffix) -{ - int ret; - char path[LTTNG_PATH_MAX]; - - ret = utils_stream_file_path(path_name, file_name, size, count, suffix, - path, sizeof(path)); - if (ret < 0) { - goto error; - } - if (uid < 0 || gid < 0) { - ret = unlink(path); - } else { - ret = run_as_unlink(path, uid, gid); - } - if (ret < 0) { - goto error; - } -error: - DBG("utils_unlink_stream_file %s returns %d", path, ret); - return ret; -} - /** * Parse a string that represents a size in human readable format. It * supports decimal integers suffixed by 'k', 'K', 'M' or 'G'. @@ -1197,7 +1132,7 @@ int utils_get_count_order_u64(uint64_t x) * Otherwise returns the value of HOME. */ LTTNG_HIDDEN -char *utils_get_home_dir(void) +const char *utils_get_home_dir(void) { char *val = NULL; struct passwd *pwd;