[lkml]   [2004]   [Jan]   [4]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
    SubjectRe: udev and devfs - The final word
    Date writes:

    > On Sun, 04 Jan 2004 23:01:04 +0100, Andries Brouwer said:
    >> A common Unix idiom is testing for the identity
    >> of two files by comparing st_ino and st_dev.
    >> A broken idiom?

    > Comparing two of these obtained at the same time is *usually* a good
    > test, although racy even on current systems. (Consider the case of an
    > unlink()/creat() pair between the two stat() calls - there's been more than
    > one race condition resulting in a security hole based on THIS one). It's
    > only safe if you actually have an open reference to both files before you
    > fstat() either one. And yes, it has to be fstat(), as you can't guarantee
    > that the file referenced by path in stat() is the one you did an
    > open() on.

    Unfortunately, programs such as tar depend on inode numbers of distinct
    files being distinct even when the file is not open over a period of
    several minutes/seconds. This is needed to avoid dumping hard links
    more than once. Furthermore, there is no efficient way to write
    programs such as tar without depending on this capability. Thus, if
    st_ino cannot be used reliably for this purpose, it would be useful for
    there to be a system call for retrieving a true
    unique-within-the-filesystem identifier for the file.

    Jeremy Maitin-Shepard
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to
    More majordomo info at
    Please read the FAQ at

     \ /
      Last update: 2005-03-22 13:59    [W:0.019 / U:3.288 seconds]
    ©2003-2017 Jasper Spaans. hosted at Digital OceanAdvertise on this site