bigbiff bigbiff | e60683a | 2013-02-22 20:55:50 -0500 | [diff] [blame] | 1 | /* Compat code so unshare and setns can be used with older libcs */ |
| 2 | #ifndef UTIL_LINUX_NAMESPACE_H |
| 3 | # define UTIL_LINUX_NAMESPACE_H |
| 4 | |
| 5 | # include <sched.h> |
| 6 | |
bigbiff | 7b4c7a6 | 2015-01-01 19:44:14 -0500 | [diff] [blame] | 7 | # ifndef CLONE_NEWNS |
bigbiff bigbiff | e60683a | 2013-02-22 20:55:50 -0500 | [diff] [blame] | 8 | # define CLONE_NEWNS 0x00020000 |
| 9 | # endif |
| 10 | # ifndef CLONE_NEWUTS |
| 11 | # define CLONE_NEWUTS 0x04000000 |
| 12 | # endif |
| 13 | # ifndef CLONE_NEWIPC |
| 14 | # define CLONE_NEWIPC 0x08000000 |
| 15 | # endif |
| 16 | # ifndef CLONE_NEWNET |
| 17 | # define CLONE_NEWNET 0x40000000 |
| 18 | # endif |
| 19 | # ifndef CLONE_NEWUSER |
| 20 | # define CLONE_NEWUSER 0x10000000 |
| 21 | # endif |
| 22 | # ifndef CLONE_NEWPID |
| 23 | # define CLONE_NEWPID 0x20000000 |
| 24 | # endif |
| 25 | |
bigbiff | 7b4c7a6 | 2015-01-01 19:44:14 -0500 | [diff] [blame] | 26 | # if !defined(HAVE_UNSHARE) || !defined(HAVE_SETNS) |
bigbiff bigbiff | e60683a | 2013-02-22 20:55:50 -0500 | [diff] [blame] | 27 | # include <sys/syscall.h> |
bigbiff | 7b4c7a6 | 2015-01-01 19:44:14 -0500 | [diff] [blame] | 28 | # endif |
| 29 | |
| 30 | # if !defined(HAVE_UNSHARE) && defined(SYS_unshare) |
bigbiff bigbiff | e60683a | 2013-02-22 20:55:50 -0500 | [diff] [blame] | 31 | static inline int unshare(int flags) |
| 32 | { |
| 33 | return syscall(SYS_unshare, flags); |
| 34 | } |
| 35 | # endif |
| 36 | |
bigbiff | 7b4c7a6 | 2015-01-01 19:44:14 -0500 | [diff] [blame] | 37 | # if !defined(HAVE_SETNS) && defined(SYS_setns) |
bigbiff bigbiff | e60683a | 2013-02-22 20:55:50 -0500 | [diff] [blame] | 38 | static inline int setns(int fd, int nstype) |
| 39 | { |
| 40 | return syscall(SYS_setns, fd, nstype); |
| 41 | } |
| 42 | # endif |
| 43 | |
| 44 | #endif /* UTIL_LINUX_NAMESPACE_H */ |