ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/Linux-Clone/Clone.xs
(Generate patch)

Comparing Linux-Clone/Clone.xs (file contents):
Revision 1.4 by root, Tue Nov 7 18:15:29 2017 UTC vs.
Revision 1.6 by root, Sat Sep 3 23:47:02 2022 UTC

8#undef _GNU_SOURCE 8#undef _GNU_SOURCE
9#define _GNU_SOURCE 9#define _GNU_SOURCE
10#include <sched.h> 10#include <sched.h>
11#include <unistd.h> 11#include <unistd.h>
12#include <sys/syscall.h> 12#include <sys/syscall.h>
13
14#include <sched.h>
15
16#include <sys/ioctl.h>
17#include <net/if.h>
13 18
14#ifdef __has_include 19#ifdef __has_include
15 #if !__has_include("linux/kcmp.h") // use "" as GCC wrongly expands macros 20 #if !__has_include("linux/kcmp.h") // use "" as GCC wrongly expands macros
16 #undef SYS_kcmp 21 #undef SYS_kcmp
17 #endif 22 #endif
76 const char *name; 81 const char *name;
77 IV iv; 82 IV iv;
78 } *civ, const_iv[] = { 83 } *civ, const_iv[] = {
79# define const_iv(name) { # name, (IV)name }, 84# define const_iv(name) { # name, (IV)name },
80# define const_iv_clone(name) { # name, (IV) CLONE_ ## name }, 85# define const_iv_clone(name) { # name, (IV) CLONE_ ## name },
86# ifdef CSIGNAL
87 const_iv (CSIGNAL)
88# endif
81# ifdef CLONE_FILES 89# ifdef CLONE_FILES
82 const_iv_clone (FILES) 90 const_iv_clone (FILES)
83# endif 91# endif
84# ifdef CLONE_FS 92# ifdef CLONE_FS
85 const_iv_clone (FS) 93 const_iv_clone (FS)
141# ifdef CLONE_IO 149# ifdef CLONE_IO
142 const_iv_clone (IO) 150 const_iv_clone (IO)
143# endif 151# endif
144# ifdef CLONE_NEWCGROUP 152# ifdef CLONE_NEWCGROUP
145 const_iv_clone (NEWCGROUP) 153 const_iv_clone (NEWCGROUP)
154# endif
155# ifdef CLONE_PIDFD
156 const_iv_clone (PIDFD)
146# endif 157# endif
147# ifdef SYS_kcmp 158# ifdef SYS_kcmp
148 const_iv (KCMP_FILE) 159 const_iv (KCMP_FILE)
149 const_iv (KCMP_VM) 160 const_iv (KCMP_VM)
150 const_iv (KCMP_FILES) 161 const_iv (KCMP_FILES)
188 munmap (stack_ptr, stacksize); 199 munmap (stack_ptr, stacksize);
189 errno = old_errno; 200 errno = old_errno;
190 } 201 }
191 } 202 }
192} 203}
193 OUTPUT: 204 OUTPUT: RETVAL
194 RETVAL
195 205
196int 206int
197unshare (int flags) 207unshare (int flags)
198 208
199int 209int
204pivot_root (SV *new_root, SV *old_root) 214pivot_root (SV *new_root, SV *old_root)
205 CODE: 215 CODE:
206 RETVAL = syscall (SYS_pivot_root, 216 RETVAL = syscall (SYS_pivot_root,
207 (const char *)SvPVbyte_nolen (new_root), 217 (const char *)SvPVbyte_nolen (new_root),
208 (const char *)SvPVbyte_nolen (old_root)); 218 (const char *)SvPVbyte_nolen (old_root));
209 OUTPUT: 219 OUTPUT: RETVAL
210 RETVAL
211 220
212int 221int
213kcmp (IV pid1, IV pid2, IV type, UV idx1 = 0, UV idx2 = 0) 222kcmp (IV pid1, IV pid2, IV type, UV idx1 = 0, UV idx2 = 0)
214 223
224int
225siocsifflags (char *ifname, U32 flags = IFF_UP)
226 CODE:
227{
228 int saved_errno;
229 struct ifreq ifr;
230 int fd = socket (AF_INET, SOCK_DGRAM, 0);
231 strncpy (ifr.ifr_name, ifname, sizeof (ifr.ifr_name));
232 RETVAL = ioctl (fd, SIOCSIFFLAGS, &ifr);
233 saved_errno = errno;
234 close (fd);
235 errno = saved_errno;
236}
237 OUTPUT: RETVAL
238

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines