[patch] wrong nlink counts in procfs

Roderich Schupp (rsch@ExperTeam.de)
Sun, 28 Jun 1998 19:38:00 +0200


Hi,
the nlink counts on most directories below /proc are wrong:
/proc/<pid>/fd has nlink=1 (should be 2); every directory
below /proc/sysctl has nlink=<number of sub directories>
(should be nlink=2+<number of subs>). I think if identified
the problem. Patch against 2.1.107 follows.

Cheers, Roderich

--- linux/fs/proc/base.c.~1~ Thu Jun 25 21:30:23 1998
+++ linux/fs/proc/base.c Sun Jun 28 18:49:27 1998
@@ -120,7 +120,7 @@
};
static struct proc_dir_entry proc_pid_fd = {
PROC_PID_FD, 2, "fd",
- S_IFDIR | S_IRUSR | S_IXUSR, 1, 0, 0,
+ S_IFDIR | S_IRUSR | S_IXUSR, 2, 0, 0,
0, &proc_fd_inode_operations,
NULL, proc_pid_fill_inode,
};
--- linux/fs/proc/generic.c.~1~ Wed Jun 3 23:27:26 1998
+++ linux/fs/proc/generic.c Sun Jun 28 19:28:52 1998
@@ -260,13 +260,15 @@
ent->name = ((char *) ent) + sizeof(*ent);
ent->namelen = len;

- if (mode == S_IFDIR) {
+ if (S_ISDIR(mode)) {
+ if ((mode & S_IALLUGO) == 0)
mode |= S_IRUGO | S_IXUGO;
ent->ops = &proc_dyna_dir_inode_operations;
ent->nlink = 2;
}
- else if (mode == 0) {
- mode = S_IFREG | S_IRUGO;
+ else {
+ if ((mode & S_IALLUGO) == 0)
+ mode |= S_IFREG | S_IRUGO;
ent->nlink = 1;
}
ent->mode = mode;

--
         Franz jagt im komplett verwahrlosten Taxi quer durch Bayern.
Roderich Schupp                 mailto:rsch@ExperTeam.de
ExperTeam GmbH                  http://www.experteam.de/
Munich, Germany                 linux:2.1.107

- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu