Re: cygwin <sys/dirent.h> has changed during dec. 2005

Greg Troxel <gdt-2FjktZCtrC/[email protected]> Wed, 08 Feb 2006 08:44:18 -0500
Newsgroups gmane.comp.gnome.apps.gqview.devel
Message-ID <[email protected]>
  > ui_tabcomp.c:                if (dir->d_ino > 0)
  > 
  > the statement 'dir->d_ino' should be changed to 'dir->__invalid_d_ino' to
  > reflect the change in <sys/dirent.h>
  > 
  > (At least that makes gqview compile again. )

The NetBSD man page for readdir says:

STANDARDS
     The opendir(), readdir(), rewinddir() and closedir() functions conform to
     ISO/IEC 9945-1:1990 (``POSIX.1'').

So, the code should probably comply with POSIX, which is hard to
obtain, and thus recent Open Group #6 is probably a good thing to examine:

http://www.opengroup.org/onlinepubs/009695399/functions/readdir.html

readdir is not allowed to return empty names.
The value of d_ino is unspecified for symlinks.

struct dirent does not necessairly contain d_ino:

http://www.opengroup.org/onlinepubs/009695399/basedefs/dirent.h.html

so gqview shouldn't (if conforming to TOG #6) read it.

  My guess is that the test for a valid (non-zero) inode is not really needed 
  at all, and is only a holdover from the past when readdir did not filter 
  out invalid (unlinked) files. Can anyone confirm this?

Do you a bug in early Linux kernels or glibc?  That sounds very
plausible.  The standard is quite clear that readdir only returns
names of files in the directory.  Also, there's nothing in the
standard that says 0 is an invalid inode number.  So I'd say that test
should be removed, and a Linux-specific workaround added if it turns
out to be necessary.


-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=103432&bid=230486&dat=121642