| 1 |
|
| #ifndef __linux |
| 2 |
|
| #error "No linux. Compile aborted." |
| 3 |
|
| #endif |
| 4 |
|
| |
| 5 |
|
| #include "EXTERN.h" |
| 6 |
|
| #include "perl.h" |
| 7 |
|
| #include "XSUB.h" |
| 8 |
|
| #include "ppport.h" |
| 9 |
|
| #include <sys/syscall.h> |
| 10 |
|
| |
| 11 |
|
| #define CLONE_ALL 0 |
| 12 |
|
| |
| 13 |
|
| #ifndef setns |
| 14 |
0 |
| int setns(int fd, int nstype) { |
| 15 |
0 |
| return syscall(SYS_setns, fd, nstype); |
| 16 |
|
| } |
| 17 |
|
| #endif |
| 18 |
|
| |
| 19 |
|
| MODULE = Linux::Setns PACKAGE = Linux::Setns |
| 20 |
|
| |
| 21 |
|
| SV * setns_wrapper(path,nstype) |
| 22 |
|
| SV * path; |
| 23 |
|
| int nstype; |
| 24 |
|
| CODE: |
| 25 |
2 |
| int fd = -1; |
| 26 |
2 |
| int err = 2; |
| 27 |
2 |
| fd = open(SvPV_nolen(path), O_RDONLY); |
| 28 |
2 |
▶ | if (fd == -1) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (fd == -1) { |
1 |
1 |
2 |
|
| 29 |
1 |
| err = 2; |
| 30 |
|
| } else { |
| 31 |
1 |
| err = setns(fd, nstype); |
| 32 |
|
| } |
| 33 |
2 |
| RETVAL = newSVnv(err); |
| 34 |
|
| OUTPUT: |
| 35 |
|
| RETVAL |