+static
+int get_full_path(const struct lttng_directory_handle *handle,
+ const char *subdirectory, char *fullpath, size_t size)
+{
+ int ret;
+
+ subdirectory = subdirectory ? : "";
+ /*
+ * Don't include the base path if subdirectory is absolute.
+ * This is the same behaviour than mkdirat.
+ */
+ ret = snprintf(fullpath, size, "%s%s",
+ *subdirectory != '/' ? handle->base_path : "",
+ subdirectory);
+ if (ret == -1 || ret >= size) {
+ ERR("Failed to format subdirectory from directory handle");
+ ret = -1;
+ }
+ ret = 0;
+ return ret;
+}
+