]> pilppa.org Git - linux-2.6-omap-h63xx.git/commitdiff
[PATCH] fix handling of st_nlink on procfs root
authorAl Viro <viro@zeniv.linux.org.uk>
Wed, 8 Feb 2006 19:37:40 +0000 (14:37 -0500)
committerAl Viro <viro@zeniv.linux.org.uk>
Sat, 18 Feb 2006 20:54:36 +0000 (15:54 -0500)
1) it should use nr_processes(), not nr_threads; otherwise we are getting
very confused find(1) and friends, among other things.
2) better do that at stat() time than at every damn lookup in procfs root.

Patch had been sitting in FC4 kernels for many months now...

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
fs/proc/inode.c
fs/proc/root.c

index 6573f31f1fd9a1efa1747a1f97a768738c88c07f..075d3e945602c92ab22122944727311301ff2491 100644 (file)
@@ -204,10 +204,6 @@ int proc_fill_super(struct super_block *s, void *data, int silent)
        root_inode = proc_get_inode(s, PROC_ROOT_INO, &proc_root);
        if (!root_inode)
                goto out_no_root;
-       /*
-        * 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);
index 68896283c8ae54d79f1e87277322aa2ce83846bc..c3fd3611112f27f0b9379e35d00887d5f89f90d1 100644 (file)
@@ -80,16 +80,16 @@ void __init proc_root_init(void)
        proc_bus = proc_mkdir("bus", NULL);
 }
 
-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;
        }
@@ -134,6 +134,7 @@ static struct file_operations proc_root_operations = {
  */
 static struct inode_operations proc_root_inode_operations = {
        .lookup         = proc_root_lookup,
+       .getattr        = proc_root_getattr,
 };
 
 /*