X-Git-Url: http://git.liburcu.org/?p=lttng-ust.git;a=blobdiff_plain;f=liblttng-ust-fork%2Fustfork.c;h=25f9d4cc04c31d2589e36d148684bf61d846c5aa;hp=71c4b86c1189ff7f89e1f7edba541c5d69d98df5;hb=735bef4705cc42f25d26f25be09ba98f1efb8511;hpb=20142124a2e34c287a277bbd7ef5b28697735d10 diff --git a/liblttng-ust-fork/ustfork.c b/liblttng-ust-fork/ustfork.c index 71c4b86c..25f9d4cc 100644 --- a/liblttng-ust-fork/ustfork.c +++ b/liblttng-ust-fork/ustfork.c @@ -160,6 +160,56 @@ int clone(int (*fn)(void *), void *child_stack, int flags, void *arg, ...) 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; + + 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; + + ust_after_unshare(); + + errno = saved_errno; + return retval; +} + #elif defined (__FreeBSD__) pid_t rfork(int flags)