diff options
| author | Al Viro <viro@zeniv.linux.org.uk> | 2014-11-01 10:57:28 -0400 |
|---|---|---|
| committer | Al Viro <viro@zeniv.linux.org.uk> | 2014-12-10 21:30:20 -0500 |
| commit | e149ed2b805fefdccf7ccdfc19eca22fdd4514ac (patch) | |
| tree | 8c9cd88deff8c7309ca2acb8d4cb475aaca47b14 /include | |
| parent | f77c80142e1afe6d5c16975ca5d7d1fc324b16f9 (diff) | |
take the targets of /proc/*/ns/* symlinks to separate fs
New pseudo-filesystem: nsfs. Targets of /proc/*/ns/* live there now.
It's not mountable (not even registered, so it's not in /proc/filesystems,
etc.). Files on it *are* bindable - we explicitly permit that in do_loopback().
This stuff lives in fs/nsfs.c now; proc_ns_fget() moved there as well.
get_proc_ns() is a macro now (it's simply returning ->i_private; would
have been an inline, if not for header ordering headache).
proc_ns_inode() is an ex-parrot. The interface used in procfs is
ns_get_path(path, task, ops) and ns_get_name(buf, size, task, ops).
Dentries and inodes are never hashed; a non-counting reference to dentry
is stashed in ns_common (removed by ->d_prune()) and reused by ns_get_path()
if present. See ns_get_path()/ns_prune_dentry/nsfs_evict() for details
of that mechanism.
As the result, proc_ns_follow_link() has stopped poking in nd->path.mnt;
it does nd_jump_link() on a consistent <vfsmount,dentry> pair it gets
from ns_get_path().
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'include')
| -rw-r--r-- | include/linux/ns_common.h | 1 | ||||
| -rw-r--r-- | include/linux/proc_ns.h | 31 | ||||
| -rw-r--r-- | include/uapi/linux/magic.h | 1 |
3 files changed, 20 insertions, 13 deletions
diff --git a/include/linux/ns_common.h b/include/linux/ns_common.h index ce23cf4bbe69..85a5c8c16be9 100644 --- a/include/linux/ns_common.h +++ b/include/linux/ns_common.h | |||
| @@ -4,6 +4,7 @@ | |||
| 4 | struct proc_ns_operations; | 4 | struct proc_ns_operations; |
| 5 | 5 | ||
| 6 | struct ns_common { | 6 | struct ns_common { |
| 7 | atomic_long_t stashed; | ||
| 7 | const struct proc_ns_operations *ops; | 8 | const struct proc_ns_operations *ops; |
| 8 | unsigned int inum; | 9 | unsigned int inum; |
| 9 | }; | 10 | }; |
diff --git a/include/linux/proc_ns.h b/include/linux/proc_ns.h index 2837ff41cfe3..42dfc615dbf8 100644 --- a/include/linux/proc_ns.h +++ b/include/linux/proc_ns.h | |||
| @@ -4,9 +4,11 @@ | |||
| 4 | #ifndef _LINUX_PROC_NS_H | 4 | #ifndef _LINUX_PROC_NS_H |
| 5 | #define _LINUX_PROC_NS_H | 5 | #define _LINUX_PROC_NS_H |
| 6 | 6 | ||
| 7 | #include <linux/ns_common.h> | ||
| 8 | |||
| 7 | struct pid_namespace; | 9 | struct pid_namespace; |
| 8 | struct nsproxy; | 10 | struct nsproxy; |
| 9 | struct ns_common; | 11 | struct path; |
| 10 | 12 | ||
| 11 | struct proc_ns_operations { | 13 | struct proc_ns_operations { |
| 12 | const char *name; | 14 | const char *name; |
| @@ -38,35 +40,38 @@ enum { | |||
| 38 | 40 | ||
| 39 | extern int pid_ns_prepare_proc(struct pid_namespace *ns); | 41 | extern int pid_ns_prepare_proc(struct pid_namespace *ns); |
| 40 | extern void pid_ns_release_proc(struct pid_namespace *ns); | 42 | extern void pid_ns_release_proc(struct pid_namespace *ns); |
| 41 | extern struct file *proc_ns_fget(int fd); | ||
| 42 | extern struct ns_common *get_proc_ns(struct inode *); | ||
| 43 | extern int proc_alloc_inum(unsigned int *pino); | 43 | extern int proc_alloc_inum(unsigned int *pino); |
| 44 | extern void proc_free_inum(unsigned int inum); | 44 | extern void proc_free_inum(unsigned int inum); |
| 45 | extern bool proc_ns_inode(struct inode *inode); | ||
| 46 | 45 | ||
| 47 | #else /* CONFIG_PROC_FS */ | 46 | #else /* CONFIG_PROC_FS */ |
| 48 | 47 | ||
| 49 | static inline int pid_ns_prepare_proc(struct pid_namespace *ns) { return 0; } | 48 | static inline int pid_ns_prepare_proc(struct pid_namespace *ns) { return 0; } |
| 50 | static inline void pid_ns_release_proc(struct pid_namespace *ns) {} | 49 | static inline void pid_ns_release_proc(struct pid_namespace *ns) {} |
| 51 | 50 | ||
| 52 | static inline struct file *proc_ns_fget(int fd) | ||
| 53 | { | ||
| 54 | return ERR_PTR(-EINVAL); | ||
| 55 | } | ||
| 56 | |||
| 57 | static inline struct ns_common *get_proc_ns(struct inode *inode) { return NULL; } | ||
| 58 | |||
| 59 | static inline int proc_alloc_inum(unsigned int *inum) | 51 | static inline int proc_alloc_inum(unsigned int *inum) |
| 60 | { | 52 | { |
| 61 | *inum = 1; | 53 | *inum = 1; |
| 62 | return 0; | 54 | return 0; |
| 63 | } | 55 | } |
| 64 | static inline void proc_free_inum(unsigned int inum) {} | 56 | static inline void proc_free_inum(unsigned int inum) {} |
| 65 | static inline bool proc_ns_inode(struct inode *inode) { return false; } | ||
| 66 | 57 | ||
| 67 | #endif /* CONFIG_PROC_FS */ | 58 | #endif /* CONFIG_PROC_FS */ |
| 68 | 59 | ||
| 69 | #define ns_alloc_inum(ns) proc_alloc_inum(&(ns)->inum) | 60 | static inline int ns_alloc_inum(struct ns_common *ns) |
| 61 | { | ||
| 62 | atomic_long_set(&ns->stashed, 0); | ||
| 63 | return proc_alloc_inum(&ns->inum); | ||
| 64 | } | ||
| 65 | |||
| 70 | #define ns_free_inum(ns) proc_free_inum((ns)->inum) | 66 | #define ns_free_inum(ns) proc_free_inum((ns)->inum) |
| 71 | 67 | ||
| 68 | extern struct file *proc_ns_fget(int fd); | ||
| 69 | #define get_proc_ns(inode) ((struct ns_common *)(inode)->i_private) | ||
| 70 | extern void *ns_get_path(struct path *path, struct task_struct *task, | ||
| 71 | const struct proc_ns_operations *ns_ops); | ||
| 72 | |||
| 73 | extern int ns_get_name(char *buf, size_t size, struct task_struct *task, | ||
| 74 | const struct proc_ns_operations *ns_ops); | ||
| 75 | extern void nsfs_init(void); | ||
| 76 | |||
| 72 | #endif /* _LINUX_PROC_NS_H */ | 77 | #endif /* _LINUX_PROC_NS_H */ |
diff --git a/include/uapi/linux/magic.h b/include/uapi/linux/magic.h index 77c60311a6c6..7d664ea85ebd 100644 --- a/include/uapi/linux/magic.h +++ b/include/uapi/linux/magic.h | |||
| @@ -72,5 +72,6 @@ | |||
| 72 | #define MTD_INODE_FS_MAGIC 0x11307854 | 72 | #define MTD_INODE_FS_MAGIC 0x11307854 |
| 73 | #define ANON_INODE_FS_MAGIC 0x09041934 | 73 | #define ANON_INODE_FS_MAGIC 0x09041934 |
| 74 | #define BTRFS_TEST_MAGIC 0x73727279 | 74 | #define BTRFS_TEST_MAGIC 0x73727279 |
| 75 | #define NSFS_MAGIC 0x6e736673 | ||
| 75 | 76 | ||
| 76 | #endif /* __LINUX_MAGIC_H__ */ | 77 | #endif /* __LINUX_MAGIC_H__ */ |
