+ struct lttng_directory_handle handle;
+
+ path = data->u.mkdirat.path;
+ mode = data->u.mkdirat.mode;
+
+ (void) lttng_directory_handle_init_from_dirfd(&handle, data->fd);
+ /* Ownership of dirfd is transferred to the handle. */
+ data->fd = -1;
+ /* Safe to call as we have transitioned to the requested uid/gid. */
+ ret_value->u.mkdirat.ret =
+ lttng_directory_handle_create_subdirectory_recursive(
+ &handle, path, mode);
+ ret_value->_errno = errno;
+ ret_value->_error = (ret_value->u.mkdirat.ret) ? true : false;
+ lttng_directory_handle_fini(&handle);
+ return ret_value->u.mkdirat.ret;
+}
+
+static
+int _mkdirat(struct run_as_data *data, struct run_as_ret *ret_value)
+{
+ const char *path;
+ mode_t mode;
+ struct lttng_directory_handle handle;
+
+ path = data->u.mkdirat.path;
+ mode = data->u.mkdirat.mode;
+
+ (void) lttng_directory_handle_init_from_dirfd(&handle, data->fd);
+ /* Ownership of dirfd is transferred to the handle. */
+ data->fd = -1;
+ /* Safe to call as we have transitioned to the requested uid/gid. */
+ ret_value->u.mkdirat.ret =
+ lttng_directory_handle_create_subdirectory(
+ &handle, path, mode);
+ ret_value->_errno = errno;
+ ret_value->_error = (ret_value->u.mkdirat.ret) ? true : false;
+ lttng_directory_handle_fini(&handle);
+ return ret_value->u.mkdirat.ret;
+}
+
+static
+int _open(struct run_as_data *data, struct run_as_ret *ret_value)
+{
+ ret_value->u.open.ret = openat(data->fd, data->u.open.path,
+ data->u.open.flags, data->u.open.mode);
+ ret_value->fd = ret_value->u.open.ret;
+ ret_value->_errno = errno;
+ ret_value->_error = ret_value->u.open.ret < 0;
+ return ret_value->u.open.ret;
+}
+
+static
+int _unlink(struct run_as_data *data, struct run_as_ret *ret_value)
+{
+ ret_value->u.unlink.ret = unlinkat(data->fd, data->u.unlink.path, 0);
+ ret_value->_errno = errno;
+ ret_value->_error = (ret_value->u.unlink.ret) ? true : false;
+ return ret_value->u.unlink.ret;
+}
+
+static
+int _rmdir_recursive(struct run_as_data *data, struct run_as_ret *ret_value)
+{
+ ret_value->u.rmdir_recursive.ret = utils_recursive_rmdir(data->u.rmdir_recursive.path);
+ ret_value->_errno = errno;
+ ret_value->_error = (ret_value->u.rmdir_recursive.ret) ? true : false;
+ return ret_value->u.rmdir_recursive.ret;
+}
+
+#ifdef HAVE_ELF_H
+static
+int _extract_elf_symbol_offset(struct run_as_data *data,
+ struct run_as_ret *ret_value)
+{
+ int ret = 0;
+ ret_value->_error = false;
+
+ ret = lttng_elf_get_symbol_offset(data->fd,
+ data->u.extract_elf_symbol_offset.function,
+ &ret_value->u.extract_elf_symbol_offset.offset);
+ if (ret) {
+ DBG("Failed to extract ELF function offset");
+ ret_value->_error = true;
+ }