summaryrefslogtreecommitdiff
path: root/fs/proc/root.c
diff options
context:
space:
mode:
authorAl Viro <viro@zeniv.linux.org.uk>2006-02-08 14:37:40 -0500
committerAl Viro <viro@zeniv.linux.org.uk>2006-02-18 15:54:36 -0500
commit76b6159ba094544e003a237cedcf555d82fa3bfe (patch)
tree134d104a2e1568d752a8d509cdeba86815f8f66d /fs/proc/root.c
parente30809fde59d591809f00caa1a4c960cca5916af (diff)
downloadlinux-3.10-76b6159ba094544e003a237cedcf555d82fa3bfe.tar.gz
linux-3.10-76b6159ba094544e003a237cedcf555d82fa3bfe.tar.bz2
linux-3.10-76b6159ba094544e003a237cedcf555d82fa3bfe.zip
[PATCH] fix handling of st_nlink on procfs root
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>
Diffstat (limited to 'fs/proc/root.c')
-rw-r--r--fs/proc/root.c17
1 files changed, 9 insertions, 8 deletions
diff --git a/fs/proc/root.c b/fs/proc/root.c
index 68896283c8a..c3fd3611112 100644
--- a/fs/proc/root.c
+++ b/fs/proc/root.c
@@ -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,
};
/*