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
4struct proc_ns_operations;4struct proc_ns_operations;
5 5
6struct ns_common {6struct 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};
include/linux/proc_ns.h+18−13
@@ -4,9 +4,11 @@ · 3 unmodified lines
4#ifndef _LINUX_PROC_NS_H4#ifndef _LINUX_PROC_NS_H
5#define _LINUX_PROC_NS_H5#define _LINUX_PROC_NS_H
6 6
7#include <linux/ns_common.h>
8
7struct pid_namespace;9struct pid_namespace;
8struct nsproxy;10struct nsproxy;
9struct ns_common;11struct path;
10 12
11struct proc_ns_operations {13struct proc_ns_operations {
12 const char *name;14 const char *name;
@@ -38,35 +40,38 @@ enum { · 25 unmodified lines
38 40
39extern int pid_ns_prepare_proc(struct pid_namespace *ns);41extern int pid_ns_prepare_proc(struct pid_namespace *ns);
40extern void pid_ns_release_proc(struct pid_namespace *ns);42extern void pid_ns_release_proc(struct pid_namespace *ns);
41extern struct file *proc_ns_fget(int fd);
42extern struct ns_common *get_proc_ns(struct inode *);
43extern int proc_alloc_inum(unsigned int *pino);43extern int proc_alloc_inum(unsigned int *pino);
44extern void proc_free_inum(unsigned int inum);44extern void proc_free_inum(unsigned int inum);
45extern bool proc_ns_inode(struct inode *inode);
46 45
47#else /* CONFIG_PROC_FS */46#else /* CONFIG_PROC_FS */
48 47
49static inline int pid_ns_prepare_proc(struct pid_namespace *ns) { return 0; }48static inline int pid_ns_prepare_proc(struct pid_namespace *ns) { return 0; }
50static inline void pid_ns_release_proc(struct pid_namespace *ns) {}49static inline void pid_ns_release_proc(struct pid_namespace *ns) {}
51 50
52static inline struct file *proc_ns_fget(int fd)
53{
54 return ERR_PTR(-EINVAL);
55}
56
57static inline struct ns_common *get_proc_ns(struct inode *inode) { return NULL; }
58
59static inline int proc_alloc_inum(unsigned int *inum)51static inline int proc_alloc_inum(unsigned int *inum)
60{52{
61 *inum = 1;53 *inum = 1;
62 return 0;54 return 0;
63}55}
64static inline void proc_free_inum(unsigned int inum) {}56static inline void proc_free_inum(unsigned int inum) {}
65static 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)60static 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
68extern struct file *proc_ns_fget(int fd);
69#define get_proc_ns(inode) ((struct ns_common *)(inode)->i_private)
70extern void *ns_get_path(struct path *path, struct task_struct *task,
71 const struct proc_ns_operations *ns_ops);
72
73extern int ns_get_name(char *buf, size_t size, struct task_struct *task,
74 const struct proc_ns_operations *ns_ops);
75extern void nsfs_init(void);
76
72#endif /* _LINUX_PROC_NS_H */77#endif /* _LINUX_PROC_NS_H */
include/uapi/linux/magic.h+1−0
@@ -72,5 +72,6 @@ · 71 unmodified lines
72#define MTD_INODE_FS_MAGIC 0x1130785472#define MTD_INODE_FS_MAGIC 0x11307854
73#define ANON_INODE_FS_MAGIC 0x0904193473#define ANON_INODE_FS_MAGIC 0x09041934
74#define BTRFS_TEST_MAGIC 0x7372727974#define BTRFS_TEST_MAGIC 0x73727279
75#define NSFS_MAGIC 0x6e736673
75 76
76#endif /* __LINUX_MAGIC_H__ */77#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