Question about inodes returned by stat() and readdir()

Robb, Sam
Thu Jan 16 18:56:00 GMT 2003


  As far as I can tell, it appears that the inode number
returned by calling stat() on a directory differs from
the inode number returned by calling readdir() for the
same directory:

    path         : /tmp
    path->st_ino : 1772102

    parent       : /
    child        : tmp
    child->d_ino : 635407883

  (In case this is pilot error on my part, I've attached the
source used to generate the above results.)

  In trying to figure out if this is by design or not, I came
across the following:

  "The inode number for a file is calculated by hashing its full
   Win32 path. The inode number generated by the stat call always
   matches the one returned in d_ino of the dirent structure."

  On the other hand, in Cygwin's sys/dirent.h, there is the
following comment attached to the dirent d_ino member:

    ino_t d_ino; /* Just for compatibility, it's junk */

  What's the expected behvaior in this case - should readdir()
return the same inode as stat()?  Looking at the cygwin1.dll
source, it looks like the intent is to return the same inode
number from readdir().

-------------- next part --------------
A non-text attachment was scrubbed...
Name: check_tmp_inode.c
Type: application/octet-stream
Size: 805 bytes
Desc: check_tmp_inode.c
URL: <>

More information about the Cygwin-apps mailing list