public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Albert Cahalan <albert@users.sf.net>
To: linux-kernel mailing list <linux-kernel@vger.kernel.org>,
	Andrew Morton OSDL <akpm@osdl.org>,
	Linus Torvalds <torvalds@osdl.org>
Subject: fake_ino fixes
Date: 13 Sep 2004 11:52:19 -0400	[thread overview]
Message-ID: <1095090739.2191.1465.camel@cube> (raw)

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 <albert@users.sf.net>

diff -Naurd ol/fs/proc/base.c nl/fs/proc/base.c
--- ol/fs/proc/base.c	2004-09-13 11:13:54.000000000 -0400
+++ nl/fs/proc/base.c	2004-09-13 11:47:29.000000000 -0400
@@ -34,14 +34,16 @@
 #include <linux/ptrace.h>
 
 /*
- * 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,
@@ -779,7 +781,8 @@
 {
 	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;




             reply	other threads:[~2004-09-13 16:02 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-09-13 15:52 Albert Cahalan [this message]
2004-09-14  2:03 ` fake_ino fixes William Lee Irwin III

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1095090739.2191.1465.camel@cube \
    --to=albert@users.sf.net \
    --cc=akpm@osdl.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=torvalds@osdl.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox