… | |
… | |
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) |
… | |
… | |
155 | const_iv (KCMP_SIGHAND) |
165 | const_iv (KCMP_SIGHAND) |
156 | const_iv (KCMP_IO) |
166 | const_iv (KCMP_IO) |
157 | const_iv (KCMP_SYSVSEM) |
167 | const_iv (KCMP_SYSVSEM) |
158 | const_iv (KCMP_FILE) |
168 | const_iv (KCMP_FILE) |
159 | # 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 |
160 | }; |
182 | }; |
161 | |
183 | |
162 | 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--) |
163 | newCONSTSUB (stash, (char *)civ[-1].name, newSViv (civ[-1].iv)); |
185 | newCONSTSUB (stash, (char *)civ[-1].name, newSViv (civ[-1].iv)); |
164 | |
186 | |
… | |
… | |
191 | munmap (stack_ptr, stacksize); |
213 | munmap (stack_ptr, stacksize); |
192 | errno = old_errno; |
214 | errno = old_errno; |
193 | } |
215 | } |
194 | } |
216 | } |
195 | } |
217 | } |
196 | OUTPUT: |
218 | OUTPUT: RETVAL |
197 | RETVAL |
|
|
198 | |
219 | |
199 | int |
220 | int |
200 | unshare (int flags) |
221 | unshare (int flags) |
201 | |
222 | |
202 | int |
223 | int |
… | |
… | |
207 | pivot_root (SV *new_root, SV *old_root) |
228 | pivot_root (SV *new_root, SV *old_root) |
208 | CODE: |
229 | CODE: |
209 | RETVAL = syscall (SYS_pivot_root, |
230 | RETVAL = syscall (SYS_pivot_root, |
210 | (const char *)SvPVbyte_nolen (new_root), |
231 | (const char *)SvPVbyte_nolen (new_root), |
211 | (const char *)SvPVbyte_nolen (old_root)); |
232 | (const char *)SvPVbyte_nolen (old_root)); |
212 | OUTPUT: |
233 | OUTPUT: RETVAL |
213 | RETVAL |
|
|
214 | |
234 | |
215 | int |
235 | int |
216 | kcmp (IV pid1, IV pid2, IV type, UV idx1 = 0, UV idx2 = 0) |
236 | kcmp (IV pid1, IV pid2, IV type, UV idx1 = 0, UV idx2 = 0) |
217 | |
237 | |
|
|
238 | int |
|
|
239 | siocsifflags (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 | |