aboutsummaryrefslogtreecommitdiffstats
path: root/fs/proc
diff options
context:
space:
mode:
authorDavid Howells <dhowells@redhat.com>2018-11-01 19:07:25 -0400
committerAl Viro <viro@zeniv.linux.org.uk>2019-02-28 03:29:27 -0500
commit60a3c3a58e2e01e19ed2b68b415adb12118ac349 (patch)
tree2535e20323f20f42922f8c87c782771aa2746313 /fs/proc
parent0b52075ee62301dd150c9f2c3ddd0035ed894cde (diff)
procfs: Move proc_fill_super() to fs/proc/root.c
Move proc_fill_super() to fs/proc/root.c as that's where the other superblock stuff is. Signed-off-by: David Howells <dhowells@redhat.com> Reviewed-by: Alexey Dobriyan <adobriyan@gmail.com> cc: Alexey Dobriyan <adobriyan@gmail.com> Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'fs/proc')
-rw-r--r--fs/proc/inode.c51
-rw-r--r--fs/proc/internal.h4
-rw-r--r--fs/proc/root.c51
3 files changed, 52 insertions, 54 deletions
diff --git a/fs/proc/inode.c b/fs/proc/inode.c
index da649ccd6804..17b5261206dd 100644
--- a/fs/proc/inode.c
+++ b/fs/proc/inode.c
@@ -24,7 +24,6 @@
24#include <linux/seq_file.h> 24#include <linux/seq_file.h>
25#include <linux/slab.h> 25#include <linux/slab.h>
26#include <linux/mount.h> 26#include <linux/mount.h>
27#include <linux/magic.h>
28 27
29#include <linux/uaccess.h> 28#include <linux/uaccess.h>
30 29
@@ -122,7 +121,7 @@ static int proc_show_options(struct seq_file *seq, struct dentry *root)
122 return 0; 121 return 0;
123} 122}
124 123
125static const struct super_operations proc_sops = { 124const struct super_operations proc_sops = {
126 .alloc_inode = proc_alloc_inode, 125 .alloc_inode = proc_alloc_inode,
127 .destroy_inode = proc_destroy_inode, 126 .destroy_inode = proc_destroy_inode,
128 .drop_inode = generic_delete_inode, 127 .drop_inode = generic_delete_inode,
@@ -488,51 +487,3 @@ struct inode *proc_get_inode(struct super_block *sb, struct proc_dir_entry *de)
488 pde_put(de); 487 pde_put(de);
489 return inode; 488 return inode;
490} 489}
491
492int proc_fill_super(struct super_block *s, void *data, int silent)
493{
494 struct pid_namespace *ns = get_pid_ns(s->s_fs_info);
495 struct inode *root_inode;
496 int ret;
497
498 if (!proc_parse_options(data, ns))
499 return -EINVAL;
500
501 /* User space would break if executables or devices appear on proc */
502 s->s_iflags |= SB_I_USERNS_VISIBLE | SB_I_NOEXEC | SB_I_NODEV;
503 s->s_flags |= SB_NODIRATIME | SB_NOSUID | SB_NOEXEC;
504 s->s_blocksize = 1024;
505 s->s_blocksize_bits = 10;
506 s->s_magic = PROC_SUPER_MAGIC;
507 s->s_op = &proc_sops;
508 s->s_time_gran = 1;
509
510 /*
511 * procfs isn't actually a stacking filesystem; however, there is
512 * too much magic going on inside it to permit stacking things on
513 * top of it
514 */
515 s->s_stack_depth = FILESYSTEM_MAX_STACK_DEPTH;
516
517 /* procfs dentries and inodes don't require IO to create */
518 s->s_shrink.seeks = 0;
519
520 pde_get(&proc_root);
521 root_inode = proc_get_inode(s, &proc_root);
522 if (!root_inode) {
523 pr_err("proc_fill_super: get root inode failed\n");
524 return -ENOMEM;
525 }
526
527 s->s_root = d_make_root(root_inode);
528 if (!s->s_root) {
529 pr_err("proc_fill_super: allocate dentry failed\n");
530 return -ENOMEM;
531 }
532
533 ret = proc_setup_self(s);
534 if (ret) {
535 return ret;
536 }
537 return proc_setup_thread_self(s);
538}
diff --git a/fs/proc/internal.h b/fs/proc/internal.h
index 5185d7f6a51e..97157c0410a2 100644
--- a/fs/proc/internal.h
+++ b/fs/proc/internal.h
@@ -205,13 +205,12 @@ struct pde_opener {
205 struct completion *c; 205 struct completion *c;
206} __randomize_layout; 206} __randomize_layout;
207extern const struct inode_operations proc_link_inode_operations; 207extern const struct inode_operations proc_link_inode_operations;
208
209extern const struct inode_operations proc_pid_link_inode_operations; 208extern const struct inode_operations proc_pid_link_inode_operations;
209extern const struct super_operations proc_sops;
210 210
211void proc_init_kmemcache(void); 211void proc_init_kmemcache(void);
212void set_proc_pid_nlink(void); 212void set_proc_pid_nlink(void);
213extern struct inode *proc_get_inode(struct super_block *, struct proc_dir_entry *); 213extern struct inode *proc_get_inode(struct super_block *, struct proc_dir_entry *);
214extern int proc_fill_super(struct super_block *, void *data, int flags);
215extern void proc_entry_rundown(struct proc_dir_entry *); 214extern void proc_entry_rundown(struct proc_dir_entry *);
216 215
217/* 216/*
@@ -269,7 +268,6 @@ static inline void proc_tty_init(void) {}
269 * root.c 268 * root.c
270 */ 269 */
271extern struct proc_dir_entry proc_root; 270extern struct proc_dir_entry proc_root;
272extern int proc_parse_options(char *options, struct pid_namespace *pid);
273 271
274extern void proc_self_init(void); 272extern void proc_self_init(void);
275extern int proc_remount(struct super_block *, int *, char *); 273extern int proc_remount(struct super_block *, int *, char *);
diff --git a/fs/proc/root.c b/fs/proc/root.c
index f4b1a9d2eca6..fe4f64b3250b 100644
--- a/fs/proc/root.c
+++ b/fs/proc/root.c
@@ -23,6 +23,7 @@
23#include <linux/pid_namespace.h> 23#include <linux/pid_namespace.h>
24#include <linux/parser.h> 24#include <linux/parser.h>
25#include <linux/cred.h> 25#include <linux/cred.h>
26#include <linux/magic.h>
26 27
27#include "internal.h" 28#include "internal.h"
28 29
@@ -36,7 +37,7 @@ static const match_table_t tokens = {
36 {Opt_err, NULL}, 37 {Opt_err, NULL},
37}; 38};
38 39
39int proc_parse_options(char *options, struct pid_namespace *pid) 40static int proc_parse_options(char *options, struct pid_namespace *pid)
40{ 41{
41 char *p; 42 char *p;
42 substring_t args[MAX_OPT_ARGS]; 43 substring_t args[MAX_OPT_ARGS];
@@ -78,6 +79,54 @@ int proc_parse_options(char *options, struct pid_namespace *pid)
78 return 1; 79 return 1;
79} 80}
80 81
82static int proc_fill_super(struct super_block *s, void *data, int silent)
83{
84 struct pid_namespace *ns = get_pid_ns(s->s_fs_info);
85 struct inode *root_inode;
86 int ret;
87
88 if (!proc_parse_options(data, ns))
89 return -EINVAL;
90
91 /* User space would break if executables or devices appear on proc */
92 s->s_iflags |= SB_I_USERNS_VISIBLE | SB_I_NOEXEC | SB_I_NODEV;
93 s->s_flags |= SB_NODIRATIME | SB_NOSUID | SB_NOEXEC;
94 s->s_blocksize = 1024;
95 s->s_blocksize_bits = 10;
96 s->s_magic = PROC_SUPER_MAGIC;
97 s->s_op = &proc_sops;
98 s->s_time_gran = 1;
99
100 /*
101 * procfs isn't actually a stacking filesystem; however, there is
102 * too much magic going on inside it to permit stacking things on
103 * top of it
104 */
105 s->s_stack_depth = FILESYSTEM_MAX_STACK_DEPTH;
106
107 /* procfs dentries and inodes don't require IO to create */
108 s->s_shrink.seeks = 0;
109
110 pde_get(&proc_root);
111 root_inode = proc_get_inode(s, &proc_root);
112 if (!root_inode) {
113 pr_err("proc_fill_super: get root inode failed\n");
114 return -ENOMEM;
115 }
116
117 s->s_root = d_make_root(root_inode);
118 if (!s->s_root) {
119 pr_err("proc_fill_super: allocate dentry failed\n");
120 return -ENOMEM;
121 }
122
123 ret = proc_setup_self(s);
124 if (ret) {
125 return ret;
126 }
127 return proc_setup_thread_self(s);
128}
129
81int proc_remount(struct super_block *sb, int *flags, char *data) 130int proc_remount(struct super_block *sb, int *flags, char *data)
82{ 131{
83 struct pid_namespace *pid = sb->s_fs_info; 132 struct pid_namespace *pid = sb->s_fs_info;