[PATCH] proc filesystem (3/3): add proc_show_options()

2005-02-01 Thread rene . scharfe
This patch adds a show_options function to the proc filesystem.

diff -pur l2/fs/proc/inode.c l3/fs/proc/inode.c
--- l2/fs/proc/inode.c  2005-02-01 04:51:23.0 +0100
+++ l3/fs/proc/inode.c  2005-02-01 04:51:07.0 +0100
@@ -16,6 +16,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 
@@ -23,6 +24,9 @@
 extern umode_t proc_umask;
 extern void free_proc_entry(struct proc_dir_entry *);
 
+static int proc_root_inode_uid;
+static int proc_root_inode_gid;
+
 static inline struct proc_dir_entry * de_get(struct proc_dir_entry *de)
 {
if (de)
@@ -134,6 +138,17 @@ static int proc_remount(struct super_blo
return 0;
 }
 
+static int proc_show_options(struct seq_file *m, struct vfsmount *mnt)
+{
+   if (proc_root_inode_uid != 0)
+   seq_printf(m, ",uid=%i", proc_root_inode_uid);
+   if (proc_root_inode_gid != 0)
+   seq_printf(m, ",gid=%i", proc_root_inode_gid);
+   if (proc_umask != 0)
+   seq_printf(m, ",umask=%04o", proc_umask);
+   return 0;
+}
+
 static struct super_operations proc_sops = { 
.alloc_inode= proc_alloc_inode,
.destroy_inode  = proc_destroy_inode,
@@ -142,6 +157,7 @@ static struct super_operations proc_sops
.delete_inode   = proc_delete_inode,
.statfs = simple_statfs,
.remount_fs = proc_remount,
+   .show_options   = proc_show_options,
 };
 
 enum {
@@ -248,6 +264,8 @@ int proc_fill_super(struct super_block *
struct inode * root_inode;
 
proc_umask = 0;
+   proc_root_inode_uid = 0;
+   proc_root_inode_gid = 0;
s->s_flags |= MS_NODIRATIME;
s->s_blocksize = 1024;
s->s_blocksize_bits = 10;
@@ -262,12 +280,12 @@ int proc_fill_super(struct super_block *
 * Fixup the root inode's nlink value
 */
root_inode->i_nlink += nr_processes();
-   root_inode->i_uid = 0;
-   root_inode->i_gid = 0;
s->s_root = d_alloc_root(root_inode);
if (!s->s_root)
goto out_no_root;
-   parse_options(data, _inode->i_uid, _inode->i_gid);
+   parse_options(data, _root_inode_uid, _root_inode_gid);
+   root_inode->i_uid = proc_root_inode_uid;
+   root_inode->i_gid = proc_root_inode_gid;
return 0;
 
 out_no_root:
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] proc filesystem (3/3): add proc_show_options()

2005-02-01 Thread rene . scharfe
This patch adds a show_options function to the proc filesystem.

diff -pur l2/fs/proc/inode.c l3/fs/proc/inode.c
--- l2/fs/proc/inode.c  2005-02-01 04:51:23.0 +0100
+++ l3/fs/proc/inode.c  2005-02-01 04:51:07.0 +0100
@@ -16,6 +16,7 @@
 #include linux/module.h
 #include linux/parser.h
 #include linux/smp_lock.h
+#include linux/seq_file.h
 
 #include asm/system.h
 #include asm/uaccess.h
@@ -23,6 +24,9 @@
 extern umode_t proc_umask;
 extern void free_proc_entry(struct proc_dir_entry *);
 
+static int proc_root_inode_uid;
+static int proc_root_inode_gid;
+
 static inline struct proc_dir_entry * de_get(struct proc_dir_entry *de)
 {
if (de)
@@ -134,6 +138,17 @@ static int proc_remount(struct super_blo
return 0;
 }
 
+static int proc_show_options(struct seq_file *m, struct vfsmount *mnt)
+{
+   if (proc_root_inode_uid != 0)
+   seq_printf(m, ,uid=%i, proc_root_inode_uid);
+   if (proc_root_inode_gid != 0)
+   seq_printf(m, ,gid=%i, proc_root_inode_gid);
+   if (proc_umask != 0)
+   seq_printf(m, ,umask=%04o, proc_umask);
+   return 0;
+}
+
 static struct super_operations proc_sops = { 
.alloc_inode= proc_alloc_inode,
.destroy_inode  = proc_destroy_inode,
@@ -142,6 +157,7 @@ static struct super_operations proc_sops
.delete_inode   = proc_delete_inode,
.statfs = simple_statfs,
.remount_fs = proc_remount,
+   .show_options   = proc_show_options,
 };
 
 enum {
@@ -248,6 +264,8 @@ int proc_fill_super(struct super_block *
struct inode * root_inode;
 
proc_umask = 0;
+   proc_root_inode_uid = 0;
+   proc_root_inode_gid = 0;
s-s_flags |= MS_NODIRATIME;
s-s_blocksize = 1024;
s-s_blocksize_bits = 10;
@@ -262,12 +280,12 @@ int proc_fill_super(struct super_block *
 * Fixup the root inode's nlink value
 */
root_inode-i_nlink += nr_processes();
-   root_inode-i_uid = 0;
-   root_inode-i_gid = 0;
s-s_root = d_alloc_root(root_inode);
if (!s-s_root)
goto out_no_root;
-   parse_options(data, root_inode-i_uid, root_inode-i_gid);
+   parse_options(data, proc_root_inode_uid, proc_root_inode_gid);
+   root_inode-i_uid = proc_root_inode_uid;
+   root_inode-i_gid = proc_root_inode_gid;
return 0;
 
 out_no_root:
-
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/