Unique /proc/<pid>/fd/ inode numbers?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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>
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Stuff]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]     [Linux Resources]
  Powered by Linux