fedora core 6 1.2949 + vserver 2.2.0
[linux-2.6.git] / fs / proc / root.c
index bf4b5d2..15e1599 100644 (file)
 #include <linux/time.h>
 #include <linux/proc_fs.h>
 #include <linux/stat.h>
-#include <linux/config.h>
 #include <linux/init.h>
+#include <linux/sched.h>
 #include <linux/module.h>
-#include <asm/bitops.h>
+#include <linux/bitops.h>
 #include <linux/smp_lock.h>
+#include <linux/mount.h>
 
-struct proc_dir_entry *proc_net, *proc_bus, *proc_root_fs, *proc_root_driver;
+#include "internal.h"
+
+struct proc_dir_entry *proc_net, *proc_net_stat, *proc_bus, *proc_root_fs, *proc_root_driver;
 
 #ifdef CONFIG_SYSCTL
 struct proc_dir_entry *proc_sys_root;
 #endif
+struct proc_dir_entry *proc_virtual;
+
+extern void proc_vx_init(void);
 
-static struct super_block *proc_get_sb(struct file_system_type *fs_type,
-       int flags, const char *dev_name, void *data)
+static int proc_get_sb(struct file_system_type *fs_type,
+       int flags, const char *dev_name, void *data, struct vfsmount *mnt)
 {
-       return get_sb_single(fs_type, flags, data, proc_fill_super);
+       if (proc_mnt) {
+               /* Seed the root directory with a pid so it doesn't need
+                * to be special in base.c.  I would do this earlier but
+                * the only task alive when /proc is mounted the first time
+                * is the init_task and it doesn't have any pids.
+                */
+               struct proc_inode *ei;
+               ei = PROC_I(proc_mnt->mnt_sb->s_root->d_inode);
+               if (!ei->pid)
+                       ei->pid = find_get_pid(1);
+       }
+       return get_sb_single(fs_type, flags, data, proc_fill_super, mnt);
 }
 
 static struct file_system_type proc_fs_type = {
@@ -36,7 +53,6 @@ static struct file_system_type proc_fs_type = {
        .kill_sb        = kill_anon_super,
 };
 
-extern int __init proc_init_inodecache(void);
 void __init proc_root_init(void)
 {
        int err = proc_init_inodecache();
@@ -52,41 +68,44 @@ void __init proc_root_init(void)
                return;
        }
        proc_misc_init();
-       proc_net = proc_mkdir("net", 0);
+       proc_net = proc_mkdir("net", NULL);
+       proc_net_stat = proc_mkdir("net/stat", NULL);
+
 #ifdef CONFIG_SYSVIPC
-       proc_mkdir("sysvipc", 0);
+       proc_mkdir("sysvipc", NULL);
 #endif
 #ifdef CONFIG_SYSCTL
-       proc_sys_root = proc_mkdir("sys", 0);
+       proc_sys_root = proc_mkdir("sys", NULL);
 #endif
 #if defined(CONFIG_BINFMT_MISC) || defined(CONFIG_BINFMT_MISC_MODULE)
-       proc_mkdir("sys/fs", 0);
-       proc_mkdir("sys/fs/binfmt_misc", 0);
+       proc_mkdir("sys/fs", NULL);
+       proc_mkdir("sys/fs/binfmt_misc", NULL);
 #endif
-       proc_root_fs = proc_mkdir("fs", 0);
-       proc_root_driver = proc_mkdir("driver", 0);
-       proc_mkdir("fs/nfsd", 0); /* somewhere for the nfsd filesystem to be mounted */
+       proc_root_fs = proc_mkdir("fs", NULL);
+       proc_root_driver = proc_mkdir("driver", NULL);
+       proc_mkdir("fs/nfsd", NULL); /* somewhere for the nfsd filesystem to be mounted */
 #if defined(CONFIG_SUN_OPENPROMFS) || defined(CONFIG_SUN_OPENPROMFS_MODULE)
        /* just give it a mountpoint */
-       proc_mkdir("openprom", 0);
+       proc_mkdir("openprom", NULL);
 #endif
        proc_tty_init();
 #ifdef CONFIG_PROC_DEVICETREE
        proc_device_tree_init();
 #endif
-       proc_bus = proc_mkdir("bus", 0);
+       proc_bus = proc_mkdir("bus", NULL);
+       proc_vx_init();
 }
 
-static struct dentry *proc_root_lookup(struct inode * dir, struct dentry * dentry, struct nameidata *nd)
+static int proc_root_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat
+)
 {
-       /*
-        * nr_threads is actually protected by the tasklist_lock;
-        * however, it's conventional to do reads, especially for
-        * reporting, without any locking whatsoever.
-        */
-       if (dir->i_ino == PROC_ROOT_INO) /* check for safety... */
-               dir->i_nlink = proc_root.nlink + nr_threads;
+       generic_fillattr(dentry->d_inode, stat);
+       stat->nlink = proc_root.nlink + nr_processes();
+       return 0;
+}
 
+static struct dentry *proc_root_lookup(struct inode * dir, struct dentry * dentry, struct nameidata *nd)
+{
        if (!proc_lookup(dir, dentry, nd)) {
                return NULL;
        }
@@ -131,6 +150,7 @@ static struct file_operations proc_root_operations = {
  */
 static struct inode_operations proc_root_inode_operations = {
        .lookup         = proc_root_lookup,
+       .getattr        = proc_root_getattr,
 };
 
 /*
@@ -147,9 +167,6 @@ struct proc_dir_entry proc_root = {
        .parent         = &proc_root,
 };
 
-#ifdef CONFIG_SYSCTL
-EXPORT_SYMBOL(proc_sys_root);
-#endif
 EXPORT_SYMBOL(proc_symlink);
 EXPORT_SYMBOL(proc_mkdir);
 EXPORT_SYMBOL(create_proc_entry);
@@ -157,5 +174,6 @@ EXPORT_SYMBOL(remove_proc_entry);
 EXPORT_SYMBOL(proc_root);
 EXPORT_SYMBOL(proc_root_fs);
 EXPORT_SYMBOL(proc_net);
+EXPORT_SYMBOL(proc_net_stat);
 EXPORT_SYMBOL(proc_bus);
 EXPORT_SYMBOL(proc_root_driver);