From: Albert Cahalan This improves /proc inode numbering a bit. If ino_t is 32-bit: just fix task 0 handling If ino_t is 64-bit: fix large fd numbers too Handling PID 0xffff on 32-bit was dropped in favor of handling PID 0 correctly, since PID 0 can be seen with the default pid_max value. Signed-off-by: Albert Cahalan Signed-off-by: Andrew Morton --- 25-akpm/fs/proc/base.c | 13 ++++++++----- 1 files changed, 8 insertions(+), 5 deletions(-) diff -puN fs/proc/base.c~fake_ino-fixes fs/proc/base.c --- 25/fs/proc/base.c~fake_ino-fixes Tue Sep 14 16:12:15 2004 +++ 25-akpm/fs/proc/base.c Tue Sep 14 16:12:15 2004 @@ -35,14 +35,16 @@ #include /* - * For hysterical raisins we keep the same inumbers as in the old procfs. - * Feel free to change the macro below - just keep the range distinct from - * inumbers of the rest of procfs (currently those are in 0x0000--0xffff). + * This range should be distinct from inumbers of the rest of procfs. + * (currently those are in 0x0000--0xffff) Remember that PID 0 can + * be seen. Don't go above PID 0xfffe on any port with a 32-bit ino_t! + * (currently: Alpha, zSeries, and all 32-bit ports) Also, you'd best + * avoid using over 0x8000 file descriptors per task on such ports. * As soon as we'll get a separate superblock we will be able to forget * about magical ranges too. */ -#define fake_ino(pid,ino) (((pid)<<16)|(ino)) +#define fake_ino(pid,ino) ((((ino_t)pid+1)<<(sizeof(ino_t)*4))|(ino)) enum pid_directory_inos { PROC_TGID_INO = 2, @@ -804,7 +806,8 @@ static int proc_readfd(struct file * fil { struct inode *inode = filp->f_dentry->d_inode; struct task_struct *p = proc_task(inode); - unsigned int fd, tid, ino; + unsigned int fd, tid; + ino_t ino; int retval; char buf[NUMBUF]; struct files_struct * files; _