This is the mail archive of the cygwin mailing list for the Cygwin project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

question on d_ino semantics

Hash: SHA1

There are currently two competing uses of d_ino semantics in coreutils:

lib/backupfile.c assumes that if d_ino is ever 0, (captured by the macro
REAL_DIR_ENTRY, which is always non-zero on platforms without d_ino), that
readdir() returned an invalid entry and no attempt to dereference that
name should be attempted.

src/pwd.c assumes that if d_ino is ever 0, (captured by the macro D_INO,
which is hardcoded to 0 on platforms without d_ino), that an lstat()
should be attempted and the entry skipped if the stat failed, otherwise
use st_ino.

Cygwin currently has no d_ino member, because it is prohibitively
expensive to provide it on WinNT and Win2K machines (the only way to make
d_ino match st_ino on those two platforms is to perform the equivalent of
a stat during readdir, but this penalizes the many apps which do not
follow readdir with stat).  But it is relatively trivial to provide d_ino
that matches st_ino on Win9x and WinXP machines.  If cygwin were to
provide a sentinel value for d_ino in cases where making d_ino match
st_ino is too expensive, would it be better to make the sentinel be 0 (in
which case, pwd.c still works but backupfile.c would need to be taught to
do the lstat before giving up on the entry), or would it be better to make
the sentinel be -1 (in which case backupfile.c would still work, as it
does not care what the value of d_ino is so long as it is not 0; but pwd.c
would need to be taught that -1 also implies that lstat must be used to
get the real st_ino)?

Which other Unix platforms use 0 as the sentinel for a non-existent entry
returned by readdir()?  Does anyone know of a standard that describes
whether d_ino being 0 has special meaning?  POSIX only states that d_ino
is an optional member (but required in XSI implementations), without any
details as to whether d_ino must be non-zero.

- --
Life is short - so eat dessert first!

Eric Blake   
Version: GnuPG v1.4.1 (Cygwin)
Comment: Public key at
Comment: Using GnuPG with Thunderbird -


Unsubscribe info:
Problem reports:

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]