Skip to contentSkip to conversation

procfs: parse mount options

RFC In review Vasiliy Kulikov 2 participants 3 messages Nov 15, 2011 Proc filesystem

lore
Share & tools
lore
#0 lore raw

RFC 1/3 procfs: parse mount options

This patch adds support of procfs mount options. Actual mount options are coming in the next patches.

--

 fs/proc/inode.c    |   10 +++++++++
 fs/proc/internal.h |    1 +
 fs/proc/root.c     |   56 ++++++++++++++++++++++++++++++++++++++++++++++++++-
 3 files changed, 65 insertions(+), 2 deletions(-)
fs/proc/inode.c +10 -0
index 7737c54..9b9f92a 100644
@@ -7,6 +7,7 @@
 #include <linux/time.h>
 #include <linux/proc_fs.h>
 #include <linux/kernel.h>
+#include <linux/pid_namespace.h>
 #include <linux/mm.h>
 #include <linux/string.h>
 #include <linux/stat.h>
@@ -17,7 +18,9 @@
 #include <linux/init.h>
 #include <linux/module.h>
 #include <linux/sysctl.h>
+#include <linux/seq_file.h>
 #include <linux/slab.h>
+#include <linux/mount.h>
 
 #include <asm/system.h>
 #include <asm/uaccess.h>
@@ -102,12 +105,19 @@ void __init proc_init_inodecache(void)
 					     init_once);
 }
 
+static int proc_show_options(struct seq_file *seq, struct vfsmount *vfs)
+{
+	return 0;
+}
+
 static const struct super_operations proc_sops = {
 	.alloc_inode	= proc_alloc_inode,
 	.destroy_inode	= proc_destroy_inode,
 	.drop_inode	= generic_delete_inode,
 	.evict_inode	= proc_evict_inode,
 	.statfs		= simple_statfs,
+	.remount_fs	= proc_remount,
+	.show_options	= proc_show_options,
 };
 
 static void __pde_users_dec(struct proc_dir_entry *pde)
fs/proc/internal.h +1 -0
index 7838e5c..2925775 100644
@@ -117,6 +117,7 @@ void pde_put(struct proc_dir_entry *pde);
 
 int proc_fill_super(struct super_block *);
 struct inode *proc_get_inode(struct super_block *, struct proc_dir_entry *);
+int proc_remount(struct super_block *sb, int *flags, char *data);
 
 /*
  * These are generic /proc routines that use the internal
fs/proc/root.c +54 -2

83 lines not on this page · raw message

--

#1 lore raw

fs/proc/root.c static int proc_set_super(struct super_block *sb, void *data) · line 52

Quoted 6 lines · Vasiliy Kulikov
fs/proc/root.c +6 -0
+
+static int proc_parse_options(char *options, struct pid_namespace *pid)
+{
+       char *p;
+       substring_t args[MAX_OPT_ARGS];
+       int option;

'option' is unused?

Quoted 5 lines
fs/proc/root.c +5 -0
+
+       pr_debug("proc: options = %s\n", options);
+
+       if (!options)
+               return 1;

fs/proc/root.c static int proc_set_super(struct super_block *sb, void *data) · line 67

Quoted 10 lines
fs/proc/root.c +10 -0
+
+       while ((p = strsep(&options, ",")) != NULL) {
+               int token;
+               if (!*p)
+                       continue;
+
+               args[0].to = args[0].from = 0;
+               token = match_token(p, tokens, args);
+               switch (token) {
+               default:

This switch block reads odd...

Quoted 2 lines

+                       pr_err("proc: unrecognized mount option \"%s\" "
+                              "or missing value", p);

"\n" is needed.

fs/proc/root.c static int proc_set_super(struct super_block *sb, void *data) · line 71

Quoted 6 lines

+                       return 0;
+               }
+       }

fs/proc/root.c +3 -0
+
+       return 1;
+}

Regards.

#2 lore raw

Hi Américo,

Quoted 10 lines · Américo Wang

fs/proc/root.c static int proc_set_super(struct super_block *sb, void *data) · line 52

Quoted 6 lines · Vasiliy Kulikov
fs/proc/root.c +6 -0
+
+static int proc_parse_options(char *options, struct pid_namespace *pid)
+{
+       char *p;
+       substring_t args[MAX_OPT_ARGS];
+       int option;

'option' is unused?

Right.

Quoted 5 lines
Quoted 2 lines

+               switch (token) {
+               default:

This switch block reads odd...

It will be used in 2/3 patch.

Quoted 4 lines
Quoted 2 lines

+                       pr_err("proc: unrecognized mount option \"%s\" "
+                              "or missing value", p);

"\n" is needed.

Correct. Thank you!

Quoted 6 lines
Quoted 6 lines

+                       return 0;
+               }
+       }

fs/proc/root.c +3 -0
+
+       return 1;
+}
Signature · 2 lines
Vasiliy Kulikov
http://www.openwall.com - bringing security into open computing environments