aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAl Viro <viro@zeniv.linux.org.uk>2014-11-01 00:37:32 -0400
committerAl Viro <viro@zeniv.linux.org.uk>2014-12-04 14:34:17 -0500
commit64964528b24ea390824f0e5ce9d34b8d39b28cde (patch)
tree2de66d75468ad4ddecc7e175f86f1dbaae47ea9a
parent3c0411846118a578de3a979faf2da3ab5fb81179 (diff)
make proc_ns_operations work with struct ns_common * instead of void *
We can do that now. And kill ->inum(), while we are at it - all instances are identical. Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
-rw-r--r--fs/namespace.c13
-rw-r--r--fs/proc/inode.c2
-rw-r--r--fs/proc/namespaces.c8
-rw-r--r--include/linux/proc_ns.h10
-rw-r--r--ipc/namespace.c12
-rw-r--r--kernel/pid_namespace.c12
-rw-r--r--kernel/user_namespace.c12
-rw-r--r--kernel/utsname.c12
-rw-r--r--net/core/net_namespace.c12
9 files changed, 28 insertions, 65 deletions
diff --git a/fs/namespace.c b/fs/namespace.c
index 5c21fdadabe4..b9c16c3f63f5 100644
--- a/fs/namespace.c
+++ b/fs/namespace.c
@@ -3149,7 +3149,7 @@ found:
3149 return visible; 3149 return visible;
3150} 3150}
3151 3151
3152static void *mntns_get(struct task_struct *task) 3152static struct ns_common *mntns_get(struct task_struct *task)
3153{ 3153{
3154 struct ns_common *ns = NULL; 3154 struct ns_common *ns = NULL;
3155 struct nsproxy *nsproxy; 3155 struct nsproxy *nsproxy;
@@ -3165,12 +3165,12 @@ static void *mntns_get(struct task_struct *task)
3165 return ns; 3165 return ns;
3166} 3166}
3167 3167
3168static void mntns_put(void *ns) 3168static void mntns_put(struct ns_common *ns)
3169{ 3169{
3170 put_mnt_ns(to_mnt_ns(ns)); 3170 put_mnt_ns(to_mnt_ns(ns));
3171} 3171}
3172 3172
3173static int mntns_install(struct nsproxy *nsproxy, void *ns) 3173static int mntns_install(struct nsproxy *nsproxy, struct ns_common *ns)
3174{ 3174{
3175 struct fs_struct *fs = current->fs; 3175 struct fs_struct *fs = current->fs;
3176 struct mnt_namespace *mnt_ns = to_mnt_ns(ns); 3176 struct mnt_namespace *mnt_ns = to_mnt_ns(ns);
@@ -3203,17 +3203,10 @@ static int mntns_install(struct nsproxy *nsproxy, void *ns)
3203 return 0; 3203 return 0;
3204} 3204}
3205 3205
3206static unsigned int mntns_inum(void *ns)
3207{
3208 struct ns_common *p = ns;
3209 return p->inum;
3210}
3211
3212const struct proc_ns_operations mntns_operations = { 3206const struct proc_ns_operations mntns_operations = {
3213 .name = "mnt", 3207 .name = "mnt",
3214 .type = CLONE_NEWNS, 3208 .type = CLONE_NEWNS,
3215 .get = mntns_get, 3209 .get = mntns_get,
3216 .put = mntns_put, 3210 .put = mntns_put,
3217 .install = mntns_install, 3211 .install = mntns_install,
3218 .inum = mntns_inum,
3219}; 3212};
diff --git a/fs/proc/inode.c b/fs/proc/inode.c
index 333080d7a671..43b703c6cd3b 100644
--- a/fs/proc/inode.c
+++ b/fs/proc/inode.c
@@ -33,7 +33,7 @@ static void proc_evict_inode(struct inode *inode)
33 struct proc_dir_entry *de; 33 struct proc_dir_entry *de;
34 struct ctl_table_header *head; 34 struct ctl_table_header *head;
35 const struct proc_ns_operations *ns_ops; 35 const struct proc_ns_operations *ns_ops;
36 void *ns; 36 struct ns_common *ns;
37 37
38 truncate_inode_pages_final(&inode->i_data); 38 truncate_inode_pages_final(&inode->i_data);
39 clear_inode(inode); 39 clear_inode(inode);
diff --git a/fs/proc/namespaces.c b/fs/proc/namespaces.c
index 89026095f2b5..995e8e98237d 100644
--- a/fs/proc/namespaces.c
+++ b/fs/proc/namespaces.c
@@ -64,7 +64,7 @@ static struct dentry *proc_ns_get_dentry(struct super_block *sb,
64 struct inode *inode; 64 struct inode *inode;
65 struct proc_inode *ei; 65 struct proc_inode *ei;
66 struct qstr qname = { .name = "", }; 66 struct qstr qname = { .name = "", };
67 void *ns; 67 struct ns_common *ns;
68 68
69 ns = ns_ops->get(task); 69 ns = ns_ops->get(task);
70 if (!ns) 70 if (!ns)
@@ -76,7 +76,7 @@ static struct dentry *proc_ns_get_dentry(struct super_block *sb,
76 return ERR_PTR(-ENOMEM); 76 return ERR_PTR(-ENOMEM);
77 } 77 }
78 78
79 inode = iget_locked(sb, ns_ops->inum(ns)); 79 inode = iget_locked(sb, ns->inum);
80 if (!inode) { 80 if (!inode) {
81 dput(dentry); 81 dput(dentry);
82 ns_ops->put(ns); 82 ns_ops->put(ns);
@@ -144,7 +144,7 @@ static int proc_ns_readlink(struct dentry *dentry, char __user *buffer, int bufl
144 struct proc_inode *ei = PROC_I(inode); 144 struct proc_inode *ei = PROC_I(inode);
145 const struct proc_ns_operations *ns_ops = ei->ns.ns_ops; 145 const struct proc_ns_operations *ns_ops = ei->ns.ns_ops;
146 struct task_struct *task; 146 struct task_struct *task;
147 void *ns; 147 struct ns_common *ns;
148 char name[50]; 148 char name[50];
149 int res = -EACCES; 149 int res = -EACCES;
150 150
@@ -160,7 +160,7 @@ static int proc_ns_readlink(struct dentry *dentry, char __user *buffer, int bufl
160 if (!ns) 160 if (!ns)
161 goto out_put_task; 161 goto out_put_task;
162 162
163 snprintf(name, sizeof(name), "%s:[%u]", ns_ops->name, ns_ops->inum(ns)); 163 snprintf(name, sizeof(name), "%s:[%u]", ns_ops->name, ns->inum);
164 res = readlink_copy(buffer, buflen, name); 164 res = readlink_copy(buffer, buflen, name);
165 ns_ops->put(ns); 165 ns_ops->put(ns);
166out_put_task: 166out_put_task:
diff --git a/include/linux/proc_ns.h b/include/linux/proc_ns.h
index 34a1e105bef4..f284959391fd 100644
--- a/include/linux/proc_ns.h
+++ b/include/linux/proc_ns.h
@@ -6,18 +6,18 @@
6 6
7struct pid_namespace; 7struct pid_namespace;
8struct nsproxy; 8struct nsproxy;
9struct ns_common;
9 10
10struct proc_ns_operations { 11struct proc_ns_operations {
11 const char *name; 12 const char *name;
12 int type; 13 int type;
13 void *(*get)(struct task_struct *task); 14 struct ns_common *(*get)(struct task_struct *task);
14 void (*put)(void *ns); 15 void (*put)(struct ns_common *ns);
15 int (*install)(struct nsproxy *nsproxy, void *ns); 16 int (*install)(struct nsproxy *nsproxy, struct ns_common *ns);
16 unsigned int (*inum)(void *ns);
17}; 17};
18 18
19struct proc_ns { 19struct proc_ns {
20 void *ns; 20 struct ns_common *ns;
21 const struct proc_ns_operations *ns_ops; 21 const struct proc_ns_operations *ns_ops;
22}; 22};
23 23
diff --git a/ipc/namespace.c b/ipc/namespace.c
index 3c1e8d3bd7d3..531029a67fef 100644
--- a/ipc/namespace.c
+++ b/ipc/namespace.c
@@ -154,7 +154,7 @@ static inline struct ipc_namespace *to_ipc_ns(struct ns_common *ns)
154 return container_of(ns, struct ipc_namespace, ns); 154 return container_of(ns, struct ipc_namespace, ns);
155} 155}
156 156
157static void *ipcns_get(struct task_struct *task) 157static struct ns_common *ipcns_get(struct task_struct *task)
158{ 158{
159 struct ipc_namespace *ns = NULL; 159 struct ipc_namespace *ns = NULL;
160 struct nsproxy *nsproxy; 160 struct nsproxy *nsproxy;
@@ -168,12 +168,12 @@ static void *ipcns_get(struct task_struct *task)
168 return ns ? &ns->ns : NULL; 168 return ns ? &ns->ns : NULL;
169} 169}
170 170
171static void ipcns_put(void *ns) 171static void ipcns_put(struct ns_common *ns)
172{ 172{
173 return put_ipc_ns(to_ipc_ns(ns)); 173 return put_ipc_ns(to_ipc_ns(ns));
174} 174}
175 175
176static int ipcns_install(struct nsproxy *nsproxy, void *new) 176static int ipcns_install(struct nsproxy *nsproxy, struct ns_common *new)
177{ 177{
178 struct ipc_namespace *ns = to_ipc_ns(new); 178 struct ipc_namespace *ns = to_ipc_ns(new);
179 if (!ns_capable(ns->user_ns, CAP_SYS_ADMIN) || 179 if (!ns_capable(ns->user_ns, CAP_SYS_ADMIN) ||
@@ -187,16 +187,10 @@ static int ipcns_install(struct nsproxy *nsproxy, void *new)
187 return 0; 187 return 0;
188} 188}
189 189
190static unsigned int ipcns_inum(void *vp)
191{
192 return ((struct ns_common *)vp)->inum;
193}
194
195const struct proc_ns_operations ipcns_operations = { 190const struct proc_ns_operations ipcns_operations = {
196 .name = "ipc", 191 .name = "ipc",
197 .type = CLONE_NEWIPC, 192 .type = CLONE_NEWIPC,
198 .get = ipcns_get, 193 .get = ipcns_get,
199 .put = ipcns_put, 194 .put = ipcns_put,
200 .install = ipcns_install, 195 .install = ipcns_install,
201 .inum = ipcns_inum,
202}; 196};
diff --git a/kernel/pid_namespace.c b/kernel/pid_namespace.c
index dd961ad86fbd..79aabce49a85 100644
--- a/kernel/pid_namespace.c
+++ b/kernel/pid_namespace.c
@@ -318,7 +318,7 @@ static inline struct pid_namespace *to_pid_ns(struct ns_common *ns)
318 return container_of(ns, struct pid_namespace, ns); 318 return container_of(ns, struct pid_namespace, ns);
319} 319}
320 320
321static void *pidns_get(struct task_struct *task) 321static struct ns_common *pidns_get(struct task_struct *task)
322{ 322{
323 struct pid_namespace *ns; 323 struct pid_namespace *ns;
324 324
@@ -331,12 +331,12 @@ static void *pidns_get(struct task_struct *task)
331 return ns ? &ns->ns : NULL; 331 return ns ? &ns->ns : NULL;
332} 332}
333 333
334static void pidns_put(void *ns) 334static void pidns_put(struct ns_common *ns)
335{ 335{
336 put_pid_ns(to_pid_ns(ns)); 336 put_pid_ns(to_pid_ns(ns));
337} 337}
338 338
339static int pidns_install(struct nsproxy *nsproxy, void *ns) 339static int pidns_install(struct nsproxy *nsproxy, struct ns_common *ns)
340{ 340{
341 struct pid_namespace *active = task_active_pid_ns(current); 341 struct pid_namespace *active = task_active_pid_ns(current);
342 struct pid_namespace *ancestor, *new = to_pid_ns(ns); 342 struct pid_namespace *ancestor, *new = to_pid_ns(ns);
@@ -367,18 +367,12 @@ static int pidns_install(struct nsproxy *nsproxy, void *ns)
367 return 0; 367 return 0;
368} 368}
369 369
370static unsigned int pidns_inum(void *ns)
371{
372 return ((struct ns_common *)ns)->inum;
373}
374
375const struct proc_ns_operations pidns_operations = { 370const struct proc_ns_operations pidns_operations = {
376 .name = "pid", 371 .name = "pid",
377 .type = CLONE_NEWPID, 372 .type = CLONE_NEWPID,
378 .get = pidns_get, 373 .get = pidns_get,
379 .put = pidns_put, 374 .put = pidns_put,
380 .install = pidns_install, 375 .install = pidns_install,
381 .inum = pidns_inum,
382}; 376};
383 377
384static __init int pid_namespaces_init(void) 378static __init int pid_namespaces_init(void)
diff --git a/kernel/user_namespace.c b/kernel/user_namespace.c
index 1ab2209228ff..29cd5ccfc37a 100644
--- a/kernel/user_namespace.c
+++ b/kernel/user_namespace.c
@@ -846,7 +846,7 @@ static inline struct user_namespace *to_user_ns(struct ns_common *ns)
846 return container_of(ns, struct user_namespace, ns); 846 return container_of(ns, struct user_namespace, ns);
847} 847}
848 848
849static void *userns_get(struct task_struct *task) 849static struct ns_common *userns_get(struct task_struct *task)
850{ 850{
851 struct user_namespace *user_ns; 851 struct user_namespace *user_ns;
852 852
@@ -857,12 +857,12 @@ static void *userns_get(struct task_struct *task)
857 return user_ns ? &user_ns->ns : NULL; 857 return user_ns ? &user_ns->ns : NULL;
858} 858}
859 859
860static void userns_put(void *ns) 860static void userns_put(struct ns_common *ns)
861{ 861{
862 put_user_ns(to_user_ns(ns)); 862 put_user_ns(to_user_ns(ns));
863} 863}
864 864
865static int userns_install(struct nsproxy *nsproxy, void *ns) 865static int userns_install(struct nsproxy *nsproxy, struct ns_common *ns)
866{ 866{
867 struct user_namespace *user_ns = to_user_ns(ns); 867 struct user_namespace *user_ns = to_user_ns(ns);
868 struct cred *cred; 868 struct cred *cred;
@@ -893,18 +893,12 @@ static int userns_install(struct nsproxy *nsproxy, void *ns)
893 return commit_creds(cred); 893 return commit_creds(cred);
894} 894}
895 895
896static unsigned int userns_inum(void *ns)
897{
898 return ((struct ns_common *)ns)->inum;
899}
900
901const struct proc_ns_operations userns_operations = { 896const struct proc_ns_operations userns_operations = {
902 .name = "user", 897 .name = "user",
903 .type = CLONE_NEWUSER, 898 .type = CLONE_NEWUSER,
904 .get = userns_get, 899 .get = userns_get,
905 .put = userns_put, 900 .put = userns_put,
906 .install = userns_install, 901 .install = userns_install,
907 .inum = userns_inum,
908}; 902};
909 903
910static __init int user_namespaces_init(void) 904static __init int user_namespaces_init(void)
diff --git a/kernel/utsname.c b/kernel/utsname.c
index 1917f74be8ec..20697befe466 100644
--- a/kernel/utsname.c
+++ b/kernel/utsname.c
@@ -93,7 +93,7 @@ static inline struct uts_namespace *to_uts_ns(struct ns_common *ns)
93 return container_of(ns, struct uts_namespace, ns); 93 return container_of(ns, struct uts_namespace, ns);
94} 94}
95 95
96static void *utsns_get(struct task_struct *task) 96static struct ns_common *utsns_get(struct task_struct *task)
97{ 97{
98 struct uts_namespace *ns = NULL; 98 struct uts_namespace *ns = NULL;
99 struct nsproxy *nsproxy; 99 struct nsproxy *nsproxy;
@@ -109,12 +109,12 @@ static void *utsns_get(struct task_struct *task)
109 return ns ? &ns->ns : NULL; 109 return ns ? &ns->ns : NULL;
110} 110}
111 111
112static void utsns_put(void *ns) 112static void utsns_put(struct ns_common *ns)
113{ 113{
114 put_uts_ns(to_uts_ns(ns)); 114 put_uts_ns(to_uts_ns(ns));
115} 115}
116 116
117static int utsns_install(struct nsproxy *nsproxy, void *new) 117static int utsns_install(struct nsproxy *nsproxy, struct ns_common *new)
118{ 118{
119 struct uts_namespace *ns = to_uts_ns(new); 119 struct uts_namespace *ns = to_uts_ns(new);
120 120
@@ -128,16 +128,10 @@ static int utsns_install(struct nsproxy *nsproxy, void *new)
128 return 0; 128 return 0;
129} 129}
130 130
131static unsigned int utsns_inum(void *vp)
132{
133 return ((struct ns_common *)vp)->inum;
134}
135
136const struct proc_ns_operations utsns_operations = { 131const struct proc_ns_operations utsns_operations = {
137 .name = "uts", 132 .name = "uts",
138 .type = CLONE_NEWUTS, 133 .type = CLONE_NEWUTS,
139 .get = utsns_get, 134 .get = utsns_get,
140 .put = utsns_put, 135 .put = utsns_put,
141 .install = utsns_install, 136 .install = utsns_install,
142 .inum = utsns_inum,
143}; 137};
diff --git a/net/core/net_namespace.c b/net/core/net_namespace.c
index 97f4dc2132ad..2161f0979fce 100644
--- a/net/core/net_namespace.c
+++ b/net/core/net_namespace.c
@@ -629,7 +629,7 @@ void unregister_pernet_device(struct pernet_operations *ops)
629EXPORT_SYMBOL_GPL(unregister_pernet_device); 629EXPORT_SYMBOL_GPL(unregister_pernet_device);
630 630
631#ifdef CONFIG_NET_NS 631#ifdef CONFIG_NET_NS
632static void *netns_get(struct task_struct *task) 632static struct ns_common *netns_get(struct task_struct *task)
633{ 633{
634 struct net *net = NULL; 634 struct net *net = NULL;
635 struct nsproxy *nsproxy; 635 struct nsproxy *nsproxy;
@@ -648,12 +648,12 @@ static inline struct net *to_net_ns(struct ns_common *ns)
648 return container_of(ns, struct net, ns); 648 return container_of(ns, struct net, ns);
649} 649}
650 650
651static void netns_put(void *ns) 651static void netns_put(struct ns_common *ns)
652{ 652{
653 put_net(to_net_ns(ns)); 653 put_net(to_net_ns(ns));
654} 654}
655 655
656static int netns_install(struct nsproxy *nsproxy, void *ns) 656static int netns_install(struct nsproxy *nsproxy, struct ns_common *ns)
657{ 657{
658 struct net *net = to_net_ns(ns); 658 struct net *net = to_net_ns(ns);
659 659
@@ -666,17 +666,11 @@ static int netns_install(struct nsproxy *nsproxy, void *ns)
666 return 0; 666 return 0;
667} 667}
668 668
669static unsigned int netns_inum(void *ns)
670{
671 return ((struct ns_common *)ns)->inum;
672}
673
674const struct proc_ns_operations netns_operations = { 669const struct proc_ns_operations netns_operations = {
675 .name = "net", 670 .name = "net",
676 .type = CLONE_NEWNET, 671 .type = CLONE_NEWNET,
677 .get = netns_get, 672 .get = netns_get,
678 .put = netns_put, 673 .put = netns_put,
679 .install = netns_install, 674 .install = netns_install,
680 .inum = netns_inum,
681}; 675};
682#endif 676#endif