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.7 by root, Sat Sep 3 23:56:10 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>
18
19#include <linux/nsfs.h>
13 20
14#ifdef __has_include 21#ifdef __has_include
15 #if !__has_include("linux/kcmp.h") // use "" as GCC wrongly expands macros 22 #if !__has_include("linux/kcmp.h") // use "" as GCC wrongly expands macros
16 #undef SYS_kcmp 23 #undef SYS_kcmp
17 #endif 24 #endif
76 const char *name; 83 const char *name;
77 IV iv; 84 IV iv;
78 } *civ, const_iv[] = { 85 } *civ, const_iv[] = {
79# define const_iv(name) { # name, (IV)name }, 86# define const_iv(name) { # name, (IV)name },
80# define const_iv_clone(name) { # name, (IV) CLONE_ ## name }, 87# define const_iv_clone(name) { # name, (IV) CLONE_ ## name },
88# ifdef CSIGNAL
89 const_iv (CSIGNAL)
90# endif
81# ifdef CLONE_FILES 91# ifdef CLONE_FILES
82 const_iv_clone (FILES) 92 const_iv_clone (FILES)
83# endif 93# endif
84# ifdef CLONE_FS 94# ifdef CLONE_FS
85 const_iv_clone (FS) 95 const_iv_clone (FS)
141# ifdef CLONE_IO 151# ifdef CLONE_IO
142 const_iv_clone (IO) 152 const_iv_clone (IO)
143# endif 153# endif
144# ifdef CLONE_NEWCGROUP 154# ifdef CLONE_NEWCGROUP
145 const_iv_clone (NEWCGROUP) 155 const_iv_clone (NEWCGROUP)
156# endif
157# ifdef CLONE_PIDFD
158 const_iv_clone (PIDFD)
146# endif 159# endif
147# ifdef SYS_kcmp 160# ifdef SYS_kcmp
148 const_iv (KCMP_FILE) 161 const_iv (KCMP_FILE)
149 const_iv (KCMP_VM) 162 const_iv (KCMP_VM)
150 const_iv (KCMP_FILES) 163 const_iv (KCMP_FILES)
152 const_iv (KCMP_SIGHAND) 165 const_iv (KCMP_SIGHAND)
153 const_iv (KCMP_IO) 166 const_iv (KCMP_IO)
154 const_iv (KCMP_SYSVSEM) 167 const_iv (KCMP_SYSVSEM)
155 const_iv (KCMP_FILE) 168 const_iv (KCMP_FILE)
156# endif 169# endif
170# ifdef NS_GET_USERNS
171 const_iv (NS_GET_USERNS)
172# endif
173# ifdef NS_GET_PARENT
174 const_iv (NS_GET_PARENT)
175# endif
176# ifdef NS_GET_NSTYPE
177 const_iv (NS_GET_NSTYPE)
178# endif
179# ifdef NS_OWNER_UID
180 const_iv (NS_OWNER_UID
181# endif
157 }; 182 };
158 183
159 for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); civ > const_iv; civ--) 184 for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); civ > const_iv; civ--)
160 newCONSTSUB (stash, (char *)civ[-1].name, newSViv (civ[-1].iv)); 185 newCONSTSUB (stash, (char *)civ[-1].name, newSViv (civ[-1].iv));
161 186
188 munmap (stack_ptr, stacksize); 213 munmap (stack_ptr, stacksize);
189 errno = old_errno; 214 errno = old_errno;
190 } 215 }
191 } 216 }
192} 217}
193 OUTPUT: 218 OUTPUT: RETVAL
194 RETVAL
195 219
196int 220int
197unshare (int flags) 221unshare (int flags)
198 222
199int 223int
204pivot_root (SV *new_root, SV *old_root) 228pivot_root (SV *new_root, SV *old_root)
205 CODE: 229 CODE:
206 RETVAL = syscall (SYS_pivot_root, 230 RETVAL = syscall (SYS_pivot_root,
207 (const char *)SvPVbyte_nolen (new_root), 231 (const char *)SvPVbyte_nolen (new_root),
208 (const char *)SvPVbyte_nolen (old_root)); 232 (const char *)SvPVbyte_nolen (old_root));
209 OUTPUT: 233 OUTPUT: RETVAL
210 RETVAL
211 234
212int 235int
213kcmp (IV pid1, IV pid2, IV type, UV idx1 = 0, UV idx2 = 0) 236kcmp (IV pid1, IV pid2, IV type, UV idx1 = 0, UV idx2 = 0)
214 237
238int
239siocsifflags (char *ifname, U32 flags = IFF_UP)
240 CODE:
241{
242 int saved_errno;
243 struct ifreq ifr;
244 int fd = socket (AF_INET, SOCK_DGRAM, 0);
245 strncpy (ifr.ifr_name, ifname, sizeof (ifr.ifr_name));
246 RETVAL = ioctl (fd, SIOCSIFFLAGS, &ifr);
247 saved_errno = errno;
248 close (fd);
249 errno = saved_errno;
250}
251 OUTPUT: RETVAL
252

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines