procfs: add hidepid= and gid= mount options
[GitHub/mt8127/android_kernel_alcatel_ttab.git] / fs / proc / inode.c
index 7737c5468a4088f507165230884ba30b605713ea..84fd3235a5902b73eb59dbc9d18d42be4969b3a3 100644 (file)
@@ -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>
@@ -77,7 +80,6 @@ static struct inode *proc_alloc_inode(struct super_block *sb)
 static void proc_i_callback(struct rcu_head *head)
 {
        struct inode *inode = container_of(head, struct inode, i_rcu);
-       INIT_LIST_HEAD(&inode->i_dentry);
        kmem_cache_free(proc_inode_cachep, PROC_I(inode));
 }
 
@@ -102,12 +104,27 @@ void __init proc_init_inodecache(void)
                                             init_once);
 }
 
+static int proc_show_options(struct seq_file *seq, struct dentry *root)
+{
+       struct super_block *sb = root->d_sb;
+       struct pid_namespace *pid = sb->s_fs_info;
+
+       if (pid->pid_gid)
+               seq_printf(seq, ",gid=%lu", (unsigned long)pid->pid_gid);
+       if (pid->hide_pid != 0)
+               seq_printf(seq, ",hidepid=%u", pid->hide_pid);
+
+       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)