]> git.ipfire.org Git - thirdparty/util-linux.git/blame - include/namespace.h
Merge branch 'lsfd--bpf-name#in-flight' of https://github.com/masatake/util-linux
[thirdparty/util-linux.git] / include / namespace.h
CommitLineData
40f8c5e4
KZ
1
2/*
3 * No copyright is claimed. This code is in the public domain; do with
4 * it what you wish.
5 *
6 * Compat code so unshare and setns can be used with older libcs
7 */
c91280a4 8#ifndef UTIL_LINUX_NAMESPACE_H
a167328a 9# define UTIL_LINUX_NAMESPACE_H
c91280a4 10
a167328a 11# include <sched.h>
c91280a4 12
b00456d2 13# ifndef CLONE_NEWNS
a167328a
SK
14# define CLONE_NEWNS 0x00020000
15# endif
f9e7b66d
SH
16# ifndef CLONE_NEWCGROUP
17# define CLONE_NEWCGROUP 0x02000000
18# endif
a167328a
SK
19# ifndef CLONE_NEWUTS
20# define CLONE_NEWUTS 0x04000000
21# endif
22# ifndef CLONE_NEWIPC
23# define CLONE_NEWIPC 0x08000000
24# endif
25# ifndef CLONE_NEWNET
26# define CLONE_NEWNET 0x40000000
27# endif
28# ifndef CLONE_NEWUSER
29# define CLONE_NEWUSER 0x10000000
30# endif
31# ifndef CLONE_NEWPID
32# define CLONE_NEWPID 0x20000000
33# endif
be7df01a
AR
34# ifndef CLONE_NEWTIME
35# define CLONE_NEWTIME 0x00000080
36# endif
c91280a4 37
5ad09239 38# if !defined(HAVE_UNSHARE) || !defined(HAVE_SETNS)
a167328a 39# include <sys/syscall.h>
5ad09239
KZ
40# endif
41
6d791b4c 42# if !defined(HAVE_UNSHARE) && defined(SYS_unshare)
c91280a4
EB
43static inline int unshare(int flags)
44{
45 return syscall(SYS_unshare, flags);
46}
a167328a 47# endif
c91280a4 48
6d791b4c 49# if !defined(HAVE_SETNS) && defined(SYS_setns)
c91280a4
EB
50static inline int setns(int fd, int nstype)
51{
52 return syscall(SYS_setns, fd, nstype);
53}
a167328a 54# endif
c91280a4 55
a167328a 56#endif /* UTIL_LINUX_NAMESPACE_H */