Blame include/namespace.h

Packit Service 3880ab
/* SPDX-License-Identifier: GPL-2.0 */
Packit Service 3880ab
#ifndef __NAMESPACE_H__
Packit Service 3880ab
#define __NAMESPACE_H__ 1
Packit Service 3880ab
Packit Service 3880ab
#include <sched.h>
Packit Service 3880ab
#include <sys/mount.h>
Packit Service 3880ab
#include <unistd.h>
Packit Service 3880ab
#include <sys/syscall.h>
Packit Service 3880ab
#include <errno.h>
Packit Service 3880ab
Packit Service 3880ab
#ifndef NETNS_RUN_DIR
Packit Service 3880ab
#define NETNS_RUN_DIR "/var/run/netns"
Packit Service 3880ab
#endif
Packit Service 3880ab
Packit Service 3880ab
#ifndef NETNS_ETC_DIR
Packit Service 3880ab
#define NETNS_ETC_DIR "/etc/netns"
Packit Service 3880ab
#endif
Packit Service 3880ab
Packit Service 3880ab
#ifndef CLONE_NEWNET
Packit Service 3880ab
#define CLONE_NEWNET 0x40000000	/* New network namespace (lo, device, names sockets, etc) */
Packit Service 3880ab
#endif
Packit Service 3880ab
Packit Service 3880ab
#ifndef MNT_DETACH
Packit Service 3880ab
#define MNT_DETACH	0x00000002	/* Just detach from the tree */
Packit Service 3880ab
#endif /* MNT_DETACH */
Packit Service 3880ab
Packit Service 3880ab
/* sys/mount.h may be out too old to have these */
Packit Service 3880ab
#ifndef MS_REC
Packit Service 3880ab
#define MS_REC		16384
Packit Service 3880ab
#endif
Packit Service 3880ab
Packit Service 3880ab
#ifndef MS_SLAVE
Packit Service 3880ab
#define MS_SLAVE	(1 << 19)
Packit Service 3880ab
#endif
Packit Service 3880ab
Packit Service 3880ab
#ifndef MS_SHARED
Packit Service 3880ab
#define MS_SHARED	(1 << 20)
Packit Service 3880ab
#endif
Packit Service 3880ab
Packit Service 3880ab
#ifndef HAVE_SETNS
Packit Service 3880ab
static inline int setns(int fd, int nstype)
Packit Service 3880ab
{
Packit Service 3880ab
#ifdef __NR_setns
Packit Service 3880ab
	return syscall(__NR_setns, fd, nstype);
Packit Service 3880ab
#else
Packit Service 3880ab
	errno = ENOSYS;
Packit Service 3880ab
	return -1;
Packit Service 3880ab
#endif
Packit Service 3880ab
}
Packit Service 3880ab
#endif /* HAVE_SETNS */
Packit Service 3880ab
Packit Service 3880ab
int netns_switch(char *netns);
Packit Service 3880ab
int netns_get_fd(const char *netns);
Packit Service 3880ab
int netns_foreach(int (*func)(char *nsname, void *arg), void *arg);
Packit Service 3880ab
Packit Service 3880ab
struct netns_func {
Packit Service 3880ab
	int (*func)(char *nsname, void *arg);
Packit Service 3880ab
	void *arg;
Packit Service 3880ab
};
Packit Service 3880ab
Packit Service 3880ab
#endif /* __NAMESPACE_H__ */