summaryrefslogtreecommitdiff
path: root/fs/proc/base.c
diff options
context:
space:
mode:
authorDaniel Drake <dsd@gentoo.org>2005-05-01 19:59:03 +0400
committerLinus Torvalds <torvalds@ppc970.osdl.org>2005-05-01 19:59:03 +0400
commitf246315e1ab96c40978777d1e159820ecca45aa8 (patch)
tree32ed8f99da48313838d5aa863f5d3e7ed984213f /fs/proc/base.c
parentbcf88e1163623e8e8ef2ba7feface9c826a890c9 (diff)
downloadlinux-f246315e1ab96c40978777d1e159820ecca45aa8.tar.xz
[PATCH] procfs: Fix hardlink counts for /proc/<PID>/task
The current logic assumes that a /proc/<PID>/task directory should have a hardlink count of 3, probably counting ".", "..", and a directory for a single child task. It's fairly obvious that this doesn't work out correctly when a PID has more than one child task, which is quite often the case. Signed-off-by: Daniel Drake <dsd@gentoo.org> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'fs/proc/base.c')
-rw-r--r--fs/proc/base.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/fs/proc/base.c b/fs/proc/base.c
index 4718173af2c8..2eac86d46c51 100644
--- a/fs/proc/base.c
+++ b/fs/proc/base.c
@@ -1419,6 +1419,8 @@ static struct file_operations proc_tgid_attr_operations;
static struct inode_operations proc_tgid_attr_inode_operations;
#endif
+static int get_tid_list(int index, unsigned int *tids, struct inode *dir);
+
/* SMP-safe */
static struct dentry *proc_pident_lookup(struct inode *dir,
struct dentry *dentry,
@@ -1458,7 +1460,7 @@ static struct dentry *proc_pident_lookup(struct inode *dir,
*/
switch(p->type) {
case PROC_TGID_TASK:
- inode->i_nlink = 3;
+ inode->i_nlink = 2 + get_tid_list(2, NULL, dir);
inode->i_op = &proc_task_inode_operations;
inode->i_fop = &proc_task_operations;
break;
@@ -1943,7 +1945,8 @@ static int get_tid_list(int index, unsigned int *tids, struct inode *dir)
if (--index >= 0)
continue;
- tids[nr_tids] = tid;
+ if (tids != NULL)
+ tids[nr_tids] = tid;
nr_tids++;
if (nr_tids >= PROC_MAXPIDS)
break;
@@ -2043,6 +2046,7 @@ static int proc_task_readdir(struct file * filp, void * dirent, filldir_t filldi
}
nr_tids = get_tid_list(pos, tid_array, inode);
+ inode->i_nlink = pos + nr_tids;
for (i = 0; i < nr_tids; i++) {
unsigned long j = PROC_NUMBUF;