All of lore.kernel.org
 help / color / mirror / Atom feed
From: Bernard Blackham <bernard@blackham.com.au>
To: linux-kernel@vger.kernel.org
Subject: Unique /proc/<pid>/fd/ inode numbers?
Date: Tue, 31 Jan 2006 00:37:49 +0800	[thread overview]
Message-ID: <20060130163748.GC8154@blackham.com.au> (raw)

A useful thing to be able to determine when checkpointing a process
from userspace is whether two file descriptors that point to the
same file are
   (a) two independently open()'d instances of the file; or
   (b) one open() and one dup().
(the latter case meaning the FDs share locks & seek offsets).

I haven't yet found a clean way to do this from userspace. What did
cross my mind is to look at the inode number of the symlink in
/proc/<pid>/fd/.

Currently, the inode number amounts to ((pid<<16) | 0x8000 + fd_num)
(from fs/proc/base.c), which appears rather arbitrary, but
sufficient not to cause conflicts. I was thinking it would be
convenient if dup()'d files had identical inode numbers (think of
them as hard links :)

There is a comment at the top of base.c:
/*
 * 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).
 * As soon as we'll get a separate superblock we will be able to forget
 * about magical ranges too.
 */

Where should I be looking for the status on this separate
superblock? 

Would it be potentially possible to make the inode number some
unique hash of the struct file pointer relevant to the FD?

Or alternately, is there another way to solve the original problem
at the start of this email?

I'd be happy to prepare and send a patch when I'm certain things
won't collide, but I'd appreciate any guidance.

Thanks in advance,

Bernard.

-- 
 Bernard Blackham <bernard at blackham dot com dot au>

             reply	other threads:[~2006-01-30 16:38 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-01-30 16:37 Bernard Blackham [this message]
2006-01-30 20:32 ` Unique /proc/<pid>/fd/ inode numbers? Ram Gupta

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=20060130163748.GC8154@blackham.com.au \
    --to=bernard@blackham.com.au \
    --cc=linux-kernel@vger.kernel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.