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.5 by root, Mon Jul 25 10:59:29 2022 UTC vs.
Revision 1.9 by root, Tue Sep 6 10:57:01 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>
20#include <linux/kcmp.h>
21
22/* kcmp.h does not define symbols, so there is no way to detect preesence of enum */
23/* members, so we just hardcode new symbols here. */
24#ifndef KCMP_EPOLL_TFD
25 #define KCMP_EPOLL_TFD 7
26#endif
13 27
14#ifdef __has_include 28#ifdef __has_include
15 #if !__has_include("linux/kcmp.h") // use "" as GCC wrongly expands macros 29 #if !__has_include("linux/kcmp.h") // use "" as GCC wrongly expands macros
16 #undef SYS_kcmp 30 #undef SYS_kcmp
17 #endif 31 #endif
76 const char *name; 90 const char *name;
77 IV iv; 91 IV iv;
78 } *civ, const_iv[] = { 92 } *civ, const_iv[] = {
79# define const_iv(name) { # name, (IV)name }, 93# define const_iv(name) { # name, (IV)name },
80# define const_iv_clone(name) { # name, (IV) CLONE_ ## name }, 94# define const_iv_clone(name) { # name, (IV) CLONE_ ## name },
95# ifdef CSIGNAL
96 const_iv (CSIGNAL)
97# endif
81# ifdef CLONE_FILES 98# ifdef CLONE_FILES
82 const_iv_clone (FILES) 99 const_iv_clone (FILES)
83# endif 100# endif
84# ifdef CLONE_FS 101# ifdef CLONE_FS
85 const_iv_clone (FS) 102 const_iv_clone (FS)
105# ifdef CLONE_NEWIPC 122# ifdef CLONE_NEWIPC
106 const_iv_clone (NEWIPC) 123 const_iv_clone (NEWIPC)
107# endif 124# endif
108# ifdef CLONE_NEWNET 125# ifdef CLONE_NEWNET
109 const_iv_clone (NEWNET) 126 const_iv_clone (NEWNET)
127# endif
128# ifdef CLONE_NEWTIME
129 x
130 const_iv_clone (NEWTIME)
110# endif 131# endif
111# ifdef CLONE_PTRACE 132# ifdef CLONE_PTRACE
112 const_iv_clone (PTRACE) 133 const_iv_clone (PTRACE)
113# endif 134# endif
114# ifdef CLONE_VFORK 135# ifdef CLONE_VFORK
153 const_iv (KCMP_FILES) 174 const_iv (KCMP_FILES)
154 const_iv (KCMP_FS) 175 const_iv (KCMP_FS)
155 const_iv (KCMP_SIGHAND) 176 const_iv (KCMP_SIGHAND)
156 const_iv (KCMP_IO) 177 const_iv (KCMP_IO)
157 const_iv (KCMP_SYSVSEM) 178 const_iv (KCMP_SYSVSEM)
158 const_iv (KCMP_FILE) 179 const_iv (KCMP_EPOLL_TFD)
180# endif
181# ifdef NS_GET_USERNS
182 const_iv (NS_GET_USERNS)
183# endif
184# ifdef NS_GET_PARENT
185 const_iv (NS_GET_PARENT)
186# endif
187# ifdef NS_GET_NSTYPE
188 const_iv (NS_GET_NSTYPE)
189# endif
190# ifdef NS_OWNER_UID
191 const_iv (NS_OWNER_UID
159# endif 192# endif
160 }; 193 };
161 194
162 for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); civ > const_iv; civ--) 195 for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); civ > const_iv; civ--)
163 newCONSTSUB (stash, (char *)civ[-1].name, newSViv (civ[-1].iv)); 196 newCONSTSUB (stash, (char *)civ[-1].name, newSViv (civ[-1].iv));
191 munmap (stack_ptr, stacksize); 224 munmap (stack_ptr, stacksize);
192 errno = old_errno; 225 errno = old_errno;
193 } 226 }
194 } 227 }
195} 228}
196 OUTPUT: 229 OUTPUT: RETVAL
197 RETVAL
198 230
199int 231int
200unshare (int flags) 232unshare (int flags)
233 PROTOTYPE: @
201 234
202int 235int
203setns (SV *fh_or_fd, int nstype = 0) 236setns (SV *fh_or_fd, int nstype = 0)
204 C_ARGS: s_fileno (fh_or_fd, 0), nstype 237 C_ARGS: s_fileno (fh_or_fd, 0), nstype
205 238
207pivot_root (SV *new_root, SV *old_root) 240pivot_root (SV *new_root, SV *old_root)
208 CODE: 241 CODE:
209 RETVAL = syscall (SYS_pivot_root, 242 RETVAL = syscall (SYS_pivot_root,
210 (const char *)SvPVbyte_nolen (new_root), 243 (const char *)SvPVbyte_nolen (new_root),
211 (const char *)SvPVbyte_nolen (old_root)); 244 (const char *)SvPVbyte_nolen (old_root));
212 OUTPUT: 245 OUTPUT: RETVAL
213 RETVAL
214 246
215int 247int
216kcmp (IV pid1, IV pid2, IV type, UV idx1 = 0, UV idx2 = 0) 248kcmp (IV pid1, IV pid2, IV type, UV idx1 = 0, UV idx2 = 0)
217 249
250int
251siocsifflags (char *ifname, U32 flags = IFF_UP)
252 CODE:
253{
254 int saved_errno;
255 struct ifreq ifr;
256 int fd = socket (AF_INET, SOCK_DGRAM, 0);
257 strncpy (ifr.ifr_name, ifname, sizeof (ifr.ifr_name));
258 RETVAL = ioctl (fd, SIOCSIFFLAGS, &ifr);
259 saved_errno = errno;
260 close (fd);
261 errno = saved_errno;
262}
263 OUTPUT: RETVAL
264

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines