X-Git-Url: https://git.lttng.org/?a=blobdiff_plain;f=src%2Fcommon%2Fcompat%2Fdirectory-handle.c;h=562a7928719031856164f5a7fb2333fe30bcfc75;hb=578e21bdc951a54e34fe539b64e446557b703206;hp=781f2574b0ea652cadd2d8b8bb0e9e487d891d91;hpb=69e3a560d3063497c161ae00a9875dad1d546818;p=lttng-tools.git diff --git a/src/common/compat/directory-handle.c b/src/common/compat/directory-handle.c index 781f2574b..562a79287 100644 --- a/src/common/compat/directory-handle.c +++ b/src/common/compat/directory-handle.c @@ -88,6 +88,24 @@ void lttng_directory_handle_fini(struct lttng_directory_handle *handle) } } +LTTNG_HIDDEN +int lttng_directory_handle_copy(const struct lttng_directory_handle *handle, + struct lttng_directory_handle *new_copy) +{ + int ret = 0; + + if (handle->dirfd == AT_FDCWD) { + new_copy->dirfd = handle->dirfd; + } else { + new_copy->dirfd = dup(handle->dirfd); + if (new_copy->dirfd == -1) { + PERROR("Failed to duplicate directory fd of directory handle"); + ret = -1; + } + } + return ret; +} + static int lttng_directory_handle_stat(const struct lttng_directory_handle *handle, const char *path, struct stat *st) @@ -225,6 +243,14 @@ void lttng_directory_handle_fini(struct lttng_directory_handle *handle) free(handle->base_path); } +LTTNG_HIDDEN +int lttng_directory_handle_copy(const struct lttng_directory_handle *handle, + struct lttng_directory_handle *new_copy) +{ + new_copy->base_path = strdup(handle->base_path); + return new_copy->base_path ? 0 : -1; +} + static int get_full_path(const struct lttng_directory_handle *handle, const char *subdirectory, char *fullpath, size_t size)