2013-01-16 16:36:32 -08:00
|
|
|
/* Compat code so unshare and setns can be used with older libcs */
|
|
|
|
#ifndef UTIL_LINUX_NAMESPACE_H
|
2013-01-20 18:04:56 +00:00
|
|
|
# define UTIL_LINUX_NAMESPACE_H
|
2013-01-16 16:36:32 -08:00
|
|
|
|
2013-01-20 18:04:56 +00:00
|
|
|
# include <sched.h>
|
2013-01-16 16:36:32 -08:00
|
|
|
|
2013-03-08 11:43:17 -08:00
|
|
|
# ifndef CLONE_NEWNS
|
2013-01-20 18:04:56 +00:00
|
|
|
# define CLONE_NEWNS 0x00020000
|
|
|
|
# endif
|
|
|
|
# ifndef CLONE_NEWUTS
|
|
|
|
# define CLONE_NEWUTS 0x04000000
|
|
|
|
# endif
|
|
|
|
# ifndef CLONE_NEWIPC
|
|
|
|
# define CLONE_NEWIPC 0x08000000
|
|
|
|
# endif
|
|
|
|
# ifndef CLONE_NEWNET
|
|
|
|
# define CLONE_NEWNET 0x40000000
|
|
|
|
# endif
|
|
|
|
# ifndef CLONE_NEWUSER
|
|
|
|
# define CLONE_NEWUSER 0x10000000
|
|
|
|
# endif
|
|
|
|
# ifndef CLONE_NEWPID
|
|
|
|
# define CLONE_NEWPID 0x20000000
|
|
|
|
# endif
|
2013-01-16 16:36:32 -08:00
|
|
|
|
2013-03-20 14:40:19 +01:00
|
|
|
# if !defined(HAVE_UNSHARE) || !defined(HAVE_SETNS)
|
2013-01-20 18:04:56 +00:00
|
|
|
# include <sys/syscall.h>
|
2013-03-20 14:40:19 +01:00
|
|
|
# endif
|
|
|
|
|
|
|
|
# ifndef HAVE_UNSHARE
|
2013-01-16 16:36:32 -08:00
|
|
|
static inline int unshare(int flags)
|
|
|
|
{
|
|
|
|
return syscall(SYS_unshare, flags);
|
|
|
|
}
|
2013-01-20 18:04:56 +00:00
|
|
|
# endif
|
2013-01-16 16:36:32 -08:00
|
|
|
|
2013-01-20 18:04:56 +00:00
|
|
|
# ifndef HAVE_SETNS
|
2013-01-16 16:36:32 -08:00
|
|
|
static inline int setns(int fd, int nstype)
|
|
|
|
{
|
|
|
|
return syscall(SYS_setns, fd, nstype);
|
|
|
|
}
|
2013-01-20 18:04:56 +00:00
|
|
|
# endif
|
2013-01-16 16:36:32 -08:00
|
|
|
|
2013-01-20 18:04:56 +00:00
|
|
|
#endif /* UTIL_LINUX_NAMESPACE_H */
|