Merge pull request #7469 from kinvolk/dongsu/nspawn-netns
nspawn: introduce an option for specifying network namespace path
This commit is contained in:
@@ -1271,4 +1271,12 @@ struct fib_rule_uid_range {
|
||||
# define EXT4_IOC_RESIZE_FS _IOW('f', 16, __u64)
|
||||
#endif
|
||||
|
||||
#ifndef NSFS_MAGIC
|
||||
#define NSFS_MAGIC 0x6e736673
|
||||
#endif
|
||||
|
||||
#ifndef NS_GET_NSTYPE
|
||||
#define NS_GET_NSTYPE _IO(0xb7, 0x3)
|
||||
#endif
|
||||
|
||||
#include "missing_syscall.h"
|
||||
|
||||
@@ -226,6 +226,18 @@ int fd_is_temporary_fs(int fd) {
|
||||
return is_temporary_fs(&s);
|
||||
}
|
||||
|
||||
int fd_is_network_ns(int fd) {
|
||||
int r;
|
||||
|
||||
r = fd_is_fs_type(fd, NSFS_MAGIC);
|
||||
if (r <= 0)
|
||||
return r;
|
||||
r = ioctl(fd, NS_GET_NSTYPE);
|
||||
if (r < 0)
|
||||
return -errno;
|
||||
return r == CLONE_NEWNET;
|
||||
}
|
||||
|
||||
int path_is_temporary_fs(const char *path) {
|
||||
_cleanup_close_ int fd = -1;
|
||||
|
||||
|
||||
@@ -62,6 +62,7 @@ int path_is_fs_type(const char *path, statfs_f_type_t magic_value);
|
||||
|
||||
bool is_temporary_fs(const struct statfs *s) _pure_;
|
||||
int fd_is_temporary_fs(int fd);
|
||||
int fd_is_network_ns(int fd);
|
||||
int path_is_temporary_fs(const char *path);
|
||||
|
||||
/* Because statfs.t_type can be int on some architectures, we have to cast
|
||||
|
||||
Reference in New Issue
Block a user