aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2014-12-16 18:53:03 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2014-12-16 18:53:03 -0500
commit603ba7e41bf5d405aba22294af5d075d8898176d (patch)
treefb9cf0b7c4912b5105f7da5efdd204cd0e66c8db /include
parent31f48fc8f226f968d6e6b9b9718abe8e16c51fe8 (diff)
parent93fe74b2e2b5d266d630f0c3f8287efcbe6ecd10 (diff)
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs
Pull vfs pile #2 from Al Viro: "Next pile (and there'll be one or two more). The large piece in this one is getting rid of /proc/*/ns/* weirdness; among other things, it allows to (finally) make nameidata completely opaque outside of fs/namei.c, making for easier further cleanups in there" * 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs: coda_venus_readdir(): use file_inode() fs/namei.c: fold link_path_walk() call into path_init() path_init(): don't bother with LOOKUP_PARENT in argument fs/namei.c: new helper (path_cleanup()) path_init(): store the "base" pointer to file in nameidata itself make default ->i_fop have ->open() fail with ENXIO make nameidata completely opaque outside of fs/namei.c kill proc_ns completely take the targets of /proc/*/ns/* symlinks to separate fs bury struct proc_ns in fs/proc copy address of proc_ns_ops into ns_common new helpers: ns_alloc_inum/ns_free_inum make proc_ns_operations work with struct ns_common * instead of void * switch the rest of proc_ns_operations to working with &...->ns netns: switch ->get()/->put()/->install()/->inum() to working with &net->ns make mntns ->get()/->put()/->install()/->inum() work with &mnt_ns->ns common object embedded into various struct ....ns
Diffstat (limited to 'include')
-rw-r--r--include/linux/fs.h1
-rw-r--r--include/linux/ipc_namespace.h3
-rw-r--r--include/linux/namei.h25
-rw-r--r--include/linux/ns_common.h12
-rw-r--r--include/linux/pid_namespace.h3
-rw-r--r--include/linux/proc_ns.h43
-rw-r--r--include/linux/user_namespace.h3
-rw-r--r--include/linux/utsname.h3
-rw-r--r--include/net/net_namespace.h3
-rw-r--r--include/uapi/linux/magic.h1
10 files changed, 49 insertions, 48 deletions
diff --git a/include/linux/fs.h b/include/linux/fs.h
index eeaccd37184f..f90c0282c114 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -2176,7 +2176,6 @@ static inline int sb_is_blkdev_sb(struct super_block *sb)
2176extern int sync_filesystem(struct super_block *); 2176extern int sync_filesystem(struct super_block *);
2177extern const struct file_operations def_blk_fops; 2177extern const struct file_operations def_blk_fops;
2178extern const struct file_operations def_chr_fops; 2178extern const struct file_operations def_chr_fops;
2179extern const struct file_operations bad_sock_fops;
2180#ifdef CONFIG_BLOCK 2179#ifdef CONFIG_BLOCK
2181extern int ioctl_by_bdev(struct block_device *, unsigned, unsigned long); 2180extern int ioctl_by_bdev(struct block_device *, unsigned, unsigned long);
2182extern int blkdev_ioctl(struct block_device *, fmode_t, unsigned, unsigned long); 2181extern int blkdev_ioctl(struct block_device *, fmode_t, unsigned, unsigned long);
diff --git a/include/linux/ipc_namespace.h b/include/linux/ipc_namespace.h
index e365d5ec69cb..1eee6bcfcf76 100644
--- a/include/linux/ipc_namespace.h
+++ b/include/linux/ipc_namespace.h
@@ -6,6 +6,7 @@
6#include <linux/rwsem.h> 6#include <linux/rwsem.h>
7#include <linux/notifier.h> 7#include <linux/notifier.h>
8#include <linux/nsproxy.h> 8#include <linux/nsproxy.h>
9#include <linux/ns_common.h>
9 10
10struct user_namespace; 11struct user_namespace;
11 12
@@ -58,7 +59,7 @@ struct ipc_namespace {
58 /* user_ns which owns the ipc ns */ 59 /* user_ns which owns the ipc ns */
59 struct user_namespace *user_ns; 60 struct user_namespace *user_ns;
60 61
61 unsigned int proc_inum; 62 struct ns_common ns;
62}; 63};
63 64
64extern struct ipc_namespace init_ipc_ns; 65extern struct ipc_namespace init_ipc_ns;
diff --git a/include/linux/namei.h b/include/linux/namei.h
index 492de72560fa..c8990779f0c3 100644
--- a/include/linux/namei.h
+++ b/include/linux/namei.h
@@ -7,21 +7,10 @@
7#include <linux/path.h> 7#include <linux/path.h>
8 8
9struct vfsmount; 9struct vfsmount;
10struct nameidata;
10 11
11enum { MAX_NESTED_LINKS = 8 }; 12enum { MAX_NESTED_LINKS = 8 };
12 13
13struct nameidata {
14 struct path path;
15 struct qstr last;
16 struct path root;
17 struct inode *inode; /* path.dentry.d_inode */
18 unsigned int flags;
19 unsigned seq, m_seq;
20 int last_type;
21 unsigned depth;
22 char *saved_names[MAX_NESTED_LINKS + 1];
23};
24
25/* 14/*
26 * Type of the last component on LOOKUP_PARENT 15 * Type of the last component on LOOKUP_PARENT
27 */ 16 */
@@ -82,16 +71,8 @@ extern struct dentry *lock_rename(struct dentry *, struct dentry *);
82extern void unlock_rename(struct dentry *, struct dentry *); 71extern void unlock_rename(struct dentry *, struct dentry *);
83 72
84extern void nd_jump_link(struct nameidata *nd, struct path *path); 73extern void nd_jump_link(struct nameidata *nd, struct path *path);
85 74extern void nd_set_link(struct nameidata *nd, char *path);
86static inline void nd_set_link(struct nameidata *nd, char *path) 75extern char *nd_get_link(struct nameidata *nd);
87{
88 nd->saved_names[nd->depth] = path;
89}
90
91static inline char *nd_get_link(struct nameidata *nd)
92{
93 return nd->saved_names[nd->depth];
94}
95 76
96static inline void nd_terminate_link(void *name, size_t len, size_t maxlen) 77static inline void nd_terminate_link(void *name, size_t len, size_t maxlen)
97{ 78{
diff --git a/include/linux/ns_common.h b/include/linux/ns_common.h
new file mode 100644
index 000000000000..85a5c8c16be9
--- /dev/null
+++ b/include/linux/ns_common.h
@@ -0,0 +1,12 @@
1#ifndef _LINUX_NS_COMMON_H
2#define _LINUX_NS_COMMON_H
3
4struct proc_ns_operations;
5
6struct ns_common {
7 atomic_long_t stashed;
8 const struct proc_ns_operations *ops;
9 unsigned int inum;
10};
11
12#endif
diff --git a/include/linux/pid_namespace.h b/include/linux/pid_namespace.h
index 1997ffc295a7..b9cf6c51b181 100644
--- a/include/linux/pid_namespace.h
+++ b/include/linux/pid_namespace.h
@@ -8,6 +8,7 @@
8#include <linux/threads.h> 8#include <linux/threads.h>
9#include <linux/nsproxy.h> 9#include <linux/nsproxy.h>
10#include <linux/kref.h> 10#include <linux/kref.h>
11#include <linux/ns_common.h>
11 12
12struct pidmap { 13struct pidmap {
13 atomic_t nr_free; 14 atomic_t nr_free;
@@ -43,7 +44,7 @@ struct pid_namespace {
43 kgid_t pid_gid; 44 kgid_t pid_gid;
44 int hide_pid; 45 int hide_pid;
45 int reboot; /* group exit code if this pidns was rebooted */ 46 int reboot; /* group exit code if this pidns was rebooted */
46 unsigned int proc_inum; 47 struct ns_common ns;
47}; 48};
48 49
49extern struct pid_namespace init_pid_ns; 50extern struct pid_namespace init_pid_ns;
diff --git a/include/linux/proc_ns.h b/include/linux/proc_ns.h
index 34a1e105bef4..42dfc615dbf8 100644
--- a/include/linux/proc_ns.h
+++ b/include/linux/proc_ns.h
@@ -4,21 +4,18 @@
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
7struct pid_namespace; 9struct pid_namespace;
8struct nsproxy; 10struct nsproxy;
11struct path;
9 12
10struct proc_ns_operations { 13struct proc_ns_operations {
11 const char *name; 14 const char *name;
12 int type; 15 int type;
13 void *(*get)(struct task_struct *task); 16 struct ns_common *(*get)(struct task_struct *task);
14 void (*put)(void *ns); 17 void (*put)(struct ns_common *ns);
15 int (*install)(struct nsproxy *nsproxy, void *ns); 18 int (*install)(struct nsproxy *nsproxy, struct ns_common *ns);
16 unsigned int (*inum)(void *ns);
17};
18
19struct proc_ns {
20 void *ns;
21 const struct proc_ns_operations *ns_ops;
22}; 19};
23 20
24extern const struct proc_ns_operations netns_operations; 21extern const struct proc_ns_operations netns_operations;
@@ -43,32 +40,38 @@ enum {
43 40
44extern int pid_ns_prepare_proc(struct pid_namespace *ns); 41extern int pid_ns_prepare_proc(struct pid_namespace *ns);
45extern void pid_ns_release_proc(struct pid_namespace *ns); 42extern void pid_ns_release_proc(struct pid_namespace *ns);
46extern struct file *proc_ns_fget(int fd);
47extern struct proc_ns *get_proc_ns(struct inode *);
48extern int proc_alloc_inum(unsigned int *pino); 43extern int proc_alloc_inum(unsigned int *pino);
49extern void proc_free_inum(unsigned int inum); 44extern void proc_free_inum(unsigned int inum);
50extern bool proc_ns_inode(struct inode *inode);
51 45
52#else /* CONFIG_PROC_FS */ 46#else /* CONFIG_PROC_FS */
53 47
54static 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; }
55static inline void pid_ns_release_proc(struct pid_namespace *ns) {} 49static inline void pid_ns_release_proc(struct pid_namespace *ns) {}
56 50
57static inline struct file *proc_ns_fget(int fd)
58{
59 return ERR_PTR(-EINVAL);
60}
61
62static inline struct proc_ns *get_proc_ns(struct inode *inode) { return NULL; }
63
64static inline int proc_alloc_inum(unsigned int *inum) 51static inline int proc_alloc_inum(unsigned int *inum)
65{ 52{
66 *inum = 1; 53 *inum = 1;
67 return 0; 54 return 0;
68} 55}
69static inline void proc_free_inum(unsigned int inum) {} 56static inline void proc_free_inum(unsigned int inum) {}
70static inline bool proc_ns_inode(struct inode *inode) { return false; }
71 57
72#endif /* CONFIG_PROC_FS */ 58#endif /* CONFIG_PROC_FS */
73 59
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
66#define ns_free_inum(ns) proc_free_inum((ns)->inum)
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
74#endif /* _LINUX_PROC_NS_H */ 77#endif /* _LINUX_PROC_NS_H */
diff --git a/include/linux/user_namespace.h b/include/linux/user_namespace.h
index e95372654f09..4cf06c140e21 100644
--- a/include/linux/user_namespace.h
+++ b/include/linux/user_namespace.h
@@ -3,6 +3,7 @@
3 3
4#include <linux/kref.h> 4#include <linux/kref.h>
5#include <linux/nsproxy.h> 5#include <linux/nsproxy.h>
6#include <linux/ns_common.h>
6#include <linux/sched.h> 7#include <linux/sched.h>
7#include <linux/err.h> 8#include <linux/err.h>
8 9
@@ -26,7 +27,7 @@ struct user_namespace {
26 int level; 27 int level;
27 kuid_t owner; 28 kuid_t owner;
28 kgid_t group; 29 kgid_t group;
29 unsigned int proc_inum; 30 struct ns_common ns;
30 31
31 /* Register of per-UID persistent keyrings for this namespace */ 32 /* Register of per-UID persistent keyrings for this namespace */
32#ifdef CONFIG_PERSISTENT_KEYRINGS 33#ifdef CONFIG_PERSISTENT_KEYRINGS
diff --git a/include/linux/utsname.h b/include/linux/utsname.h
index 239e27733d6c..5093f58ae192 100644
--- a/include/linux/utsname.h
+++ b/include/linux/utsname.h
@@ -5,6 +5,7 @@
5#include <linux/sched.h> 5#include <linux/sched.h>
6#include <linux/kref.h> 6#include <linux/kref.h>
7#include <linux/nsproxy.h> 7#include <linux/nsproxy.h>
8#include <linux/ns_common.h>
8#include <linux/err.h> 9#include <linux/err.h>
9#include <uapi/linux/utsname.h> 10#include <uapi/linux/utsname.h>
10 11
@@ -23,7 +24,7 @@ struct uts_namespace {
23 struct kref kref; 24 struct kref kref;
24 struct new_utsname name; 25 struct new_utsname name;
25 struct user_namespace *user_ns; 26 struct user_namespace *user_ns;
26 unsigned int proc_inum; 27 struct ns_common ns;
27}; 28};
28extern struct uts_namespace init_uts_ns; 29extern struct uts_namespace init_uts_ns;
29 30
diff --git a/include/net/net_namespace.h b/include/net/net_namespace.h
index e0d64667a4b3..2e8756b8c775 100644
--- a/include/net/net_namespace.h
+++ b/include/net/net_namespace.h
@@ -26,6 +26,7 @@
26#endif 26#endif
27#include <net/netns/nftables.h> 27#include <net/netns/nftables.h>
28#include <net/netns/xfrm.h> 28#include <net/netns/xfrm.h>
29#include <linux/ns_common.h>
29 30
30struct user_namespace; 31struct user_namespace;
31struct proc_dir_entry; 32struct proc_dir_entry;
@@ -60,7 +61,7 @@ struct net {
60 61
61 struct user_namespace *user_ns; /* Owning user namespace */ 62 struct user_namespace *user_ns; /* Owning user namespace */
62 63
63 unsigned int proc_inum; 64 struct ns_common ns;
64 65
65 struct proc_dir_entry *proc_net; 66 struct proc_dir_entry *proc_net;
66 struct proc_dir_entry *proc_net_stat; 67 struct proc_dir_entry *proc_net_stat;
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__ */