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.2 by root, Wed Aug 24 03:34:24 2016 UTC vs.
Revision 1.3 by root, Thu Nov 2 07:31:16 2017 UTC

6#include <sys/mman.h> 6#include <sys/mman.h>
7 7
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>
12#include <sys/syscall.h>
13
14#ifdef SYS_kcmp
15 #include <linux/kcmp.h>
16 #define kcmp(pid1,pid2,type,idx1,idx2) \
17 syscall (SYS_kcmp, (pid_t)pid1, (pid_t)pid2, \
18 (int)type, (unsigned long)idx1, (unsigned long)idx2)
19#else
20 #define kcmp(pid1,pid2,type,idx1,idx2) \
21 (errno = ENOSYS, -1)
22#endif
11 23
12/* from schmorp.h */ 24/* from schmorp.h */
13static int 25static int
14s_fileno (SV *fh, int wr) 26s_fileno (SV *fh, int wr)
15{ 27{
56 68
57 static const struct { 69 static const struct {
58 const char *name; 70 const char *name;
59 IV iv; 71 IV iv;
60 } *civ, const_iv[] = { 72 } *civ, const_iv[] = {
61# define const_iv(name) { # name, (IV) CLONE_ ## name }, 73# define const_iv(name) { # name, (IV)name },
62# ifdef CLONE_FILES 74# ifdef CLONE_FILES
63 const_iv (FILES) 75 const_iv (CLONE_FILES)
64# endif 76# endif
65# ifdef CLONE_FS 77# ifdef CLONE_FS
66 const_iv (FS) 78 const_iv (CLONE_FS)
67# endif 79# endif
68# ifdef CLONE_NEWNS 80# ifdef CLONE_NEWNS
69 const_iv (NEWNS) 81 const_iv (CLONE_NEWNS)
70# endif 82# endif
71# ifdef CLONE_VM 83# ifdef CLONE_VM
72 const_iv (VM) 84 const_iv (CLONE_VM)
73# endif 85# endif
74# ifdef CLONE_THREAD 86# ifdef CLONE_THREAD
75 const_iv (THREAD) 87 const_iv (CLONE_THREAD)
76# endif 88# endif
77# ifdef CLONE_SIGHAND 89# ifdef CLONE_SIGHAND
78 const_iv (SIGHAND) 90 const_iv (CLONE_SIGHAND)
79# endif 91# endif
80# ifdef CLONE_SYSVSEM 92# ifdef CLONE_SYSVSEM
81 const_iv (SYSVSEM) 93 const_iv (CLONE_SYSVSEM)
82# endif 94# endif
83# ifdef CLONE_NEWUTS 95# ifdef CLONE_NEWUTS
84 const_iv (NEWUTS) 96 const_iv (CLONE_NEWUTS)
85# endif 97# endif
86# ifdef CLONE_NEWIPC 98# ifdef CLONE_NEWIPC
87 const_iv (NEWIPC) 99 const_iv (CLONE_NEWIPC)
88# endif 100# endif
89# ifdef CLONE_NEWNET 101# ifdef CLONE_NEWNET
90 const_iv (NEWNET) 102 const_iv (CLONE_NEWNET)
91# endif 103# endif
92# ifdef CLONE_PTRACE 104# ifdef CLONE_PTRACE
93 const_iv (PTRACE) 105 const_iv (CLONE_PTRACE)
94# endif 106# endif
95# ifdef CLONE_VFORK 107# ifdef CLONE_VFORK
96 const_iv (VFORK) 108 const_iv (CLONE_VFORK)
97# endif 109# endif
98# ifdef CLONE_SETTLS 110# ifdef CLONE_SETTLS
99 const_iv (SETTLS) 111 const_iv (CLONE_SETTLS)
100# endif 112# endif
101# ifdef CLONE_PARENT_SETTID 113# ifdef CLONE_PARENT_SETTID
102 const_iv (PARENT_SETTID) 114 const_iv (CLONE_PARENT_SETTID)
103# endif 115# endif
104# ifdef CLONE_CHILD_CLEARTID 116# ifdef CLONE_CHILD_CLEARTID
105 const_iv (CHILD_CLEARTID) 117 const_iv (CLONE_CHILD_CLEARTID)
106# endif 118# endif
107# ifdef CLONE_DETACHED 119# ifdef CLONE_DETACHED
108 const_iv (DETACHED) 120 const_iv (CLONE_DETACHED)
109# endif 121# endif
110# ifdef CLONE_UNTRACED 122# ifdef CLONE_UNTRACED
111 const_iv (UNTRACED) 123 const_iv (CLONE_UNTRACED)
112# endif 124# endif
113# ifdef CLONE_CHILD_SETTID 125# ifdef CLONE_CHILD_SETTID
114 const_iv (CHILD_SETTID) 126 const_iv (CLONE_CHILD_SETTID)
115# endif 127# endif
116# ifdef CLONE_NEWUSER 128# ifdef CLONE_NEWUSER
117 const_iv (NEWUSER) 129 const_iv (CLONE_NEWUSER)
118# endif 130# endif
119# ifdef CLONE_NEWPID 131# ifdef CLONE_NEWPID
120 const_iv (NEWPID) 132 const_iv (CLONE_NEWPID)
121# endif 133# endif
122# ifdef CLONE_IO 134# ifdef CLONE_IO
123 const_iv (IO) 135 const_iv (CLONE_IO)
124# endif 136# endif
125# ifdef CLONE_NEWCGROUP 137# ifdef CLONE_NEWCGROUP
126 const_iv (NEWCGROUP) 138 const_iv (CLONE_NEWCGROUP)
139# endif
140# ifdef SYS_kcmp
141 const_iv (KCMP_FILE)
142 const_iv (KCMP_VM)
143 const_iv (KCMP_FILES)
144 const_iv (KCMP_FS)
145 const_iv (KCMP_SIGHAND)
146 const_iv (KCMP_IO)
147 const_iv (KCMP_SYSVSEM)
148 const_iv (KCMP_FILE)
127# endif 149# endif
128 }; 150 };
129 151
130 for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); civ > const_iv; civ--) 152 for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); civ > const_iv; civ--)
131 newCONSTSUB (stash, (char *)civ[-1].name, newSViv (civ[-1].iv)); 153 newCONSTSUB (stash, (char *)civ[-1].name, newSViv (civ[-1].iv));
168unshare (int flags) 190unshare (int flags)
169 191
170int 192int
171setns (SV *fh_or_fd, int nstype = 0) 193setns (SV *fh_or_fd, int nstype = 0)
172 C_ARGS: s_fileno (fh_or_fd, 0), nstype 194 C_ARGS: s_fileno (fh_or_fd, 0), nstype
195
196int
197pivot_root (SV *new_root, SV *old_root)
198 CODE:
199 RETVAL = syscall (SYS_pivot_root,
200 (const char *)SvPVbyte_nolen (new_root),
201 (const char *)SvPVbyte_nolen (old_root));
202 OUTPUT:
203 RETVAL
204
205int
206kcmp (IV pid1, IV pid2, IV type, UV idx1 = 0, UV idx2 = 0)
207

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines