History

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().

Al Viro committed 12 years ago

Commit e149ed21 parent f77c80110 files · +208 −161Browse files

Showing the changes to include (3 of 10 files). Show all

Unified · Split

3 files
  1. include/linux/ns_common.h +1 −0
  2. include/linux/proc_ns.h +18 −13
  3. include/uapi/linux/magic.h +1 −0
include/linux/ns_common.h+1−0
@@ -4,6 +4,7 @@ · 3 unmodified lines
44 struct proc_ns_operations;
55
66 struct ns_common {
7+ atomic_long_t stashed;
78 const struct proc_ns_operations *ops;
89 unsigned int inum;
910 };
include/linux/proc_ns.h+18−13
@@ -4,9 +4,11 @@ · 3 unmodified lines
44 #ifndef _LINUX_PROC_NS_H
55 #define _LINUX_PROC_NS_H
66
7+#include <linux/ns_common.h>
8+
79 struct pid_namespace;
810 struct nsproxy;
9−struct ns_common;
11+struct path;
1012
1113 struct proc_ns_operations {
1214 const char *name;
@@ -38,35 +40,38 @@ enum { · 25 unmodified lines
3840
3941 extern int pid_ns_prepare_proc(struct pid_namespace *ns);
4042 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 *);
4343 extern int proc_alloc_inum(unsigned int *pino);
4444 extern void proc_free_inum(unsigned int inum);
45−extern bool proc_ns_inode(struct inode *inode);
4645
4746 #else /* CONFIG_PROC_FS */
4847
4948 static inline int pid_ns_prepare_proc(struct pid_namespace *ns) { return 0; }
5049 static inline void pid_ns_release_proc(struct pid_namespace *ns) {}
5150
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−
5951 static inline int proc_alloc_inum(unsigned int *inum)
6052 {
6153 *inum = 1;
6254 return 0;
6355 }
6456 static inline void proc_free_inum(unsigned int inum) {}
65−static inline bool proc_ns_inode(struct inode *inode) { return false; }
6657
6758 #endif /* CONFIG_PROC_FS */
6859
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+
7066 #define ns_free_inum(ns) proc_free_inum((ns)->inum)
7167
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+
7277 #endif /* _LINUX_PROC_NS_H */
include/uapi/linux/magic.h+1−0
@@ -72,5 +72,6 @@ · 71 unmodified lines
7272 #define MTD_INODE_FS_MAGIC 0x11307854
7373 #define ANON_INODE_FS_MAGIC 0x09041934
7474 #define BTRFS_TEST_MAGIC 0x73727279
75+#define NSFS_MAGIC 0x6e736673
7576
7677 #endif /* __LINUX_MAGIC_H__ */

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t