small procfs bug & fix

Bruno Haible (haible@ilog.fr)
Thu, 3 Sep 1998 23:03:14 +0200 (MET DST)


Hi,

In 2.1.119, when you cd into some /proc/<pid>/ directory and call /bin/pwd,
it reports "cannot get current directory". This is because readdir() of
/proc/ returns ino=2 for all of these /proc/<pid>/ directories. Here is a fix:

*** linux-2.1.119/fs/proc/root.c.orig Mon Aug 31 00:43:25 1998
--- linux-2.1.119/fs/proc/root.c Tue Sep 1 00:05:55 1998
***************
*** 945,950 ****
--- 945,951 ----

for (i = 0; i < nr_pids; i++) {
int pid = pid_array[i];
+ ino_t ino = (pid << 16) + PROC_PID_INO;
unsigned long j = PROC_NUMBUF;

do {
***************
*** 953,959 ****
pid /= 10;
} while (pid);

! if (filldir(dirent, buf+j, PROC_NUMBUF-j, filp->f_pos, (pid << 16) + PROC_PID_INO) < 0)
break;
filp->f_pos++;
}
--- 954,960 ----
pid /= 10;
} while (pid);

! if (filldir(dirent, buf+j, PROC_NUMBUF-j, filp->f_pos, ino) < 0)
break;
filp->f_pos++;
}

Bruno

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.altern.org/andrebalsa/doc/lkml-faq.html