X-Spam-Check-By: sourceware.org Message-ID: <43D0F45A.9060408@byu.net> Date: Fri, 20 Jan 2006 07:31:54 -0700 From: Eric Blake User-Agent: Mozilla Thunderbird 1.0.2 (Windows/20050317) MIME-Version: 1.0 To: bug-coreutils AT gnu DOT org CC: cygwin AT cygwin DOT com Subject: question on d_ino semantics Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-IsSubscribed: yes Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com -----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 ebb9 AT byu DOT net -----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----- -- Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple Problem reports: http://cygwin.com/problems.html Documentation: http://cygwin.com/docs.html FAQ: http://cygwin.com/faq/