]> git.proxmox.com Git - mirror_iproute2.git/blob - include/namespace.h
netns: Rename & move get_netns_fd to lib
[mirror_iproute2.git] / include / namespace.h
1 #ifndef __NAMESPACE_H__
2 #define __NAMESPACE_H__ 1
3
4 #include <sched.h>
5 #include <sys/mount.h>
6 #include <errno.h>
7
8 #define NETNS_RUN_DIR "/var/run/netns"
9 #define NETNS_ETC_DIR "/etc/netns"
10
11 #ifndef CLONE_NEWNET
12 #define CLONE_NEWNET 0x40000000 /* New network namespace (lo, device, names sockets, etc) */
13 #endif
14
15 #ifndef MNT_DETACH
16 #define MNT_DETACH 0x00000002 /* Just detach from the tree */
17 #endif /* MNT_DETACH */
18
19 /* sys/mount.h may be out too old to have these */
20 #ifndef MS_REC
21 #define MS_REC 16384
22 #endif
23
24 #ifndef MS_SLAVE
25 #define MS_SLAVE (1 << 19)
26 #endif
27
28 #ifndef MS_SHARED
29 #define MS_SHARED (1 << 20)
30 #endif
31
32 #ifndef HAVE_SETNS
33 static int setns(int fd, int nstype)
34 {
35 #ifdef __NR_setns
36 return syscall(__NR_setns, fd, nstype);
37 #else
38 errno = ENOSYS;
39 return -1;
40 #endif
41 }
42 #endif /* HAVE_SETNS */
43
44 extern int netns_switch(char *netns);
45 extern int netns_get_fd(const char *netns);
46
47 #endif /* __NAMESPACE_H__ */