bug-coreutils
[Top][All Lists]
Advanced

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

question on d_ino semantics


From: Eric Blake
Subject: question on d_ino semantics
Date: Fri, 20 Jan 2006 07:31:54 -0700
User-agent: Mozilla Thunderbird 1.0.2 (Windows/20050317)

-----BEGIN PGP SIGNED MESSAGE-----
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             address@hidden
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (Cygwin)
Comment: Public key at home.comcast.net/~ericblake/eblake.gpg
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org

iD8DBQFD0PRZ84KuGfSFAYARAtx4AKC01vVf9eYLnSKSApZFJ8PYhEMGeACfRauv
/KMFpDyxM2/CBT1vL+iKr/o=
=3N63
-----END PGP SIGNATURE-----




reply via email to

[Prev in Thread] Current Thread [Next in Thread]