+ return run_as_unlinkat(AT_FDCWD, path, uid, gid);
+}
+
+LTTNG_HIDDEN
+int run_as_unlinkat(int dirfd, const char *path, uid_t uid, gid_t gid)
+{
+ struct run_as_data data;
+ struct run_as_ret ret;
+
+ memset(&data, 0, sizeof(data));
+ memset(&ret, 0, sizeof(ret));
+
+ DBG3("unlinkat() fd = %d%s, path = %s, uid = %d, gid = %d",
+ dirfd, dirfd == AT_FDCWD ? " (AT_FDCWD)" : "",
+ path, (int) uid, (int) gid);
+ strncpy(data.u.unlink.path, path, PATH_MAX - 1);
+ data.u.unlink.path[PATH_MAX - 1] = '\0';
+ data.fd = dirfd;
+ run_as(RUN_AS_UNLINK, &data, &ret, uid, gid);
+ errno = ret._errno;
+ return ret.u.unlink.ret;
+}
+
+LTTNG_HIDDEN
+int run_as_rmdir_recursive(const char *path, uid_t uid, gid_t gid)
+{
+ struct run_as_data data;
+ struct run_as_ret ret;
+
+ memset(&data, 0, sizeof(data));
+ memset(&ret, 0, sizeof(ret));
+
+ DBG3("rmdir_recursive() %s with for uid %d and gid %d",
+ path, (int) uid, (int) gid);
+ strncpy(data.u.rmdir_recursive.path, path, PATH_MAX - 1);
+ data.u.rmdir_recursive.path[PATH_MAX - 1] = '\0';
+ run_as(RUN_AS_RMDIR_RECURSIVE, &data, &ret, uid, gid);
+ errno = ret._errno;
+ return ret.u.rmdir_recursive.ret;
+}
+
+LTTNG_HIDDEN
+int run_as_extract_elf_symbol_offset(int fd, const char* function,
+ uid_t uid, gid_t gid, uint64_t *offset)
+{
+ struct run_as_data data;
+ struct run_as_ret ret;
+
+ memset(&data, 0, sizeof(data));
+ memset(&ret, 0, sizeof(ret));
+
+ DBG3("extract_elf_symbol_offset() on fd=%d and function=%s "
+ "with for uid %d and gid %d", fd, function, (int) uid, (int) gid);
+
+ data.fd = fd;
+
+ strncpy(data.u.extract_elf_symbol_offset.function, function, LTTNG_SYMBOL_NAME_LEN - 1);
+
+ data.u.extract_elf_symbol_offset.function[LTTNG_SYMBOL_NAME_LEN - 1] = '\0';
+
+ run_as(RUN_AS_EXTRACT_ELF_SYMBOL_OFFSET, &data, &ret, uid, gid);
+
+ errno = ret._errno;
+
+ if (ret._error) {
+ return -1;
+ }
+
+ *offset = ret.u.extract_elf_symbol_offset.offset;
+ return 0;
+}
+
+LTTNG_HIDDEN
+int run_as_extract_sdt_probe_offsets(int fd, const char* provider_name,
+ const char* probe_name, uid_t uid, gid_t gid,
+ uint64_t **offsets, uint32_t *num_offset)
+{
+ struct run_as_data data;
+ struct run_as_ret ret;
+
+ memset(&data, 0, sizeof(data));
+ memset(&ret, 0, sizeof(ret));
+
+ DBG3("extract_sdt_probe_offsets() on fd=%d, probe_name=%s and "
+ "provider_name=%s with for uid %d and gid %d", fd, probe_name,
+ provider_name, (int) uid, (int) gid);
+
+ data.fd = fd;
+
+ strncpy(data.u.extract_sdt_probe_offsets.probe_name, probe_name, LTTNG_SYMBOL_NAME_LEN - 1);
+ strncpy(data.u.extract_sdt_probe_offsets.provider_name, provider_name, LTTNG_SYMBOL_NAME_LEN - 1);
+
+ data.u.extract_sdt_probe_offsets.probe_name[LTTNG_SYMBOL_NAME_LEN - 1] = '\0';
+ data.u.extract_sdt_probe_offsets.provider_name[LTTNG_SYMBOL_NAME_LEN - 1] = '\0';