+ errno = saved_errno;
+ return retval;
+}
+
+int setns(int fd, int nstype)
+{
+ static int (*plibc_func)(int fd, int nstype) = NULL;
+ int retval;
+ int saved_errno;
+
+ if (plibc_func == NULL) {
+ plibc_func = dlsym(RTLD_NEXT, "setns");
+ if (plibc_func == NULL) {
+ fprintf(stderr, "libustfork: unable to find \"setns\" symbol\n");
+ errno = ENOSYS;
+ return -1;
+ }
+ }
+
+ /* Do the real setns */
+ retval = plibc_func(fd, nstype);
+ saved_errno = errno;
+
+ lttng_ust_after_setns();
+
+ errno = saved_errno;
+ return retval;
+}
+
+int unshare(int flags)
+{
+ static int (*plibc_func)(int flags) = NULL;
+ int retval;
+ int saved_errno;
+
+ if (plibc_func == NULL) {
+ plibc_func = dlsym(RTLD_NEXT, "unshare");
+ if (plibc_func == NULL) {
+ fprintf(stderr, "libustfork: unable to find \"unshare\" symbol\n");
+ errno = ENOSYS;
+ return -1;
+ }
+ }
+
+ /* Do the real setns */
+ retval = plibc_func(flags);
+ saved_errno = errno;
+
+ lttng_ust_after_unshare();
+
+ errno = saved_errno;
+ return retval;
+}
+
+int setresuid(uid_t ruid, uid_t euid, uid_t suid)
+{
+ static int (*plibc_func)(uid_t ruid, uid_t euid, uid_t suid) = NULL;
+ int retval;
+ int saved_errno;
+
+ if (plibc_func == NULL) {
+ plibc_func = dlsym(RTLD_NEXT, "setresuid");
+ if (plibc_func == NULL) {
+ fprintf(stderr, "libustfork: unable to find \"setresuid\" symbol\n");
+ errno = ENOSYS;
+ return -1;
+ }
+ }
+
+ /* Do the real setresuid */
+ retval = plibc_func(ruid, euid, suid);
+ saved_errno = errno;
+
+ lttng_ust_after_setresuid();
+
+ errno = saved_errno;
+ return retval;
+}
+
+int setresgid(gid_t rgid, gid_t egid, gid_t sgid)
+{
+ static int (*plibc_func)(gid_t rgid, gid_t egid, gid_t sgid) = NULL;
+ int retval;
+ int saved_errno;
+
+ if (plibc_func == NULL) {
+ plibc_func = dlsym(RTLD_NEXT, "setresgid");
+ if (plibc_func == NULL) {
+ fprintf(stderr, "libustfork: unable to find \"setresgid\" symbol\n");
+ errno = ENOSYS;
+ return -1;
+ }
+ }
+
+ /* Do the real setresgid */
+ retval = plibc_func(rgid, egid, sgid);
+ saved_errno = errno;
+
+ lttng_ust_after_setresgid();
+
+ errno = saved_errno;