--- Linux-Clone/Clone.xs 2017/11/07 18:15:29 1.4 +++ Linux-Clone/Clone.xs 2022/09/03 23:56:10 1.7 @@ -11,6 +11,13 @@ #include #include +#include + +#include +#include + +#include + #ifdef __has_include #if !__has_include("linux/kcmp.h") // use "" as GCC wrongly expands macros #undef SYS_kcmp @@ -78,6 +85,9 @@ } *civ, const_iv[] = { # define const_iv(name) { # name, (IV)name }, # define const_iv_clone(name) { # name, (IV) CLONE_ ## name }, +# ifdef CSIGNAL + const_iv (CSIGNAL) +# endif # ifdef CLONE_FILES const_iv_clone (FILES) # endif @@ -144,6 +154,9 @@ # ifdef CLONE_NEWCGROUP const_iv_clone (NEWCGROUP) # endif +# ifdef CLONE_PIDFD + const_iv_clone (PIDFD) +# endif # ifdef SYS_kcmp const_iv (KCMP_FILE) const_iv (KCMP_VM) @@ -154,6 +167,18 @@ const_iv (KCMP_SYSVSEM) const_iv (KCMP_FILE) # endif +# ifdef NS_GET_USERNS + const_iv (NS_GET_USERNS) +# endif +# ifdef NS_GET_PARENT + const_iv (NS_GET_PARENT) +# endif +# ifdef NS_GET_NSTYPE + const_iv (NS_GET_NSTYPE) +# endif +# ifdef NS_OWNER_UID + const_iv (NS_OWNER_UID +# endif }; for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); civ > const_iv; civ--) @@ -190,8 +215,7 @@ } } } - OUTPUT: - RETVAL + OUTPUT: RETVAL int unshare (int flags) @@ -206,9 +230,23 @@ RETVAL = syscall (SYS_pivot_root, (const char *)SvPVbyte_nolen (new_root), (const char *)SvPVbyte_nolen (old_root)); - OUTPUT: - RETVAL + OUTPUT: RETVAL int kcmp (IV pid1, IV pid2, IV type, UV idx1 = 0, UV idx2 = 0) +int +siocsifflags (char *ifname, U32 flags = IFF_UP) + CODE: +{ + int saved_errno; + struct ifreq ifr; + int fd = socket (AF_INET, SOCK_DGRAM, 0); + strncpy (ifr.ifr_name, ifname, sizeof (ifr.ifr_name)); + RETVAL = ioctl (fd, SIOCSIFFLAGS, &ifr); + saved_errno = errno; + close (fd); + errno = saved_errno; +} + OUTPUT: RETVAL +