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]

Re: findutils still broken


> Nevertheless, Cygwin does try only to set errno when there is an error.
> There are some cases where that isn't true but I didn't see any that
> referred to EISDIR.
> 

While I didn't find any EISDIR on success (yet), I did find the following in 1.5.15: [l]stat() on /proc/registry/HKEY_CLASSES_ROOT sets EBADF on success, and lstat() on /proc/registry/HKEY_CLASSES_ROOT/\*/InfoTip sets ENOENT on success.  I originally wrote this program to discover that inode reporting in readdir() is broken (to which you replied that fixing it would cause too much of a slowdown), and to expose the closedir() bug on /cygdrive that was patched for 1.5.13.

$ cat mydir.c
#include <unistd.h>
#include <stdio.h>
#include <errno.h>
#include <string.h>
#include <fcntl.h>
#include <dirent.h>
#include <sys/stat.h>

int main(int argc, char** argv)
{
   DIR* dirp;
   struct dirent* d;
   struct stat s;
   dev_t dev;

   if (argc < 2)
      argv[1] = "/cygdrive";
   if (chdir(argv[1]) < 0)
   {
      puts("Usage: mydir [<dirname>], <dirname> defaults to /cygdrive");
      return 1;
   }
   if (stat(".", &s) < 0)
      return 2;
   if (errno)
   {
      fprintf(stderr, "stat succeeded, but with errno set %d:%s\n", errno,
              strerror(errno));
      errno = 0;
   }
   dev = s.st_dev;
   if (!(dirp = opendir(".")))
      return 3;
   if (errno)
   {
      fprintf(stderr, "opendir succeeded, but with errno set %d:%s\n", errno,
              strerror(errno));
      errno = 0;
   }
   while ((d = readdir(dirp)))
   {
      if (errno)
      {
         fprintf(stderr, "readdir succeeded, but with errno set %d:%s\n", errno,
                 strerror(errno));
         errno = 0;
      }
      if (lstat(d->d_name, &s) < 0)
         return 4;
      if (errno)
      {
         fprintf(stderr, "lstat succeeded, but with errno set %d:%s\n", errno,
                 strerror(errno));
         errno = 0;
      }
      printf("name %s readdir %lld:%lld lstat %lld:%lld\n",
             d->d_name, (long long) dev, (long long) d->d_ino,
             (long long) s.st_dev, (long long) s.st_ino);
   }
   if (errno)
   {
      fprintf(stderr, "readdir died with error %d:%s\n", errno,
              strerror(errno));
      errno = 0;
   }
   if (closedir(dirp))
   {
      fprintf(stderr, "closedir died with error %d:%s\n", errno,
              strerror(errno));
      return 7;
   }
   return 0;
}

$ ./mydir /proc/registry
name . readdir 249:62955137485954567 lstat 249:62955137485954567
name .. readdir 249:1290187932582212885 lstat 250:3370216573438707685
lstat succeeded, but with errno set 9:Bad file descriptor
name HKEY_CLASSES_ROOT readdir 249:2918072127280940078 lstat 249:-5725779783608089317
lstat succeeded, but with errno set 9:Bad file descriptor
name HKEY_CURRENT_CONFIG readdir 249:1858416338210701691 lstat 249:-4922755561972704280
lstat succeeded, but with errno set 9:Bad file descriptor
name HKEY_CURRENT_USER readdir 249:-5314180556948332796 lstat 249:4488711605872189425
lstat succeeded, but with errno set 9:Bad file descriptor
name HKEY_LOCAL_MACHINE readdir 249:8931300086272188864 lstat 249:-3090864638969521133
lstat succeeded, but with errno set 9:Bad file descriptor
name HKEY_USERS readdir 249:-617872841864433419 lstat 249:5152742094727745864
name HKEY_DYN_DATA readdir 249:-3036519385171394589 lstat 249:-2412852278496113200
lstat succeeded, but with errno set 9:Bad file descriptor
name HKEY_PERFORMANCE_DATA readdir 249:2001697819424303980 lstat 249:-153357268691558567

$ ./mydir /proc/registry/HKEY_CLASSES_ROOT/\*                         
name . readdir 249:-8709620034263747754 lstat 249:-8709620034263747754
lstat succeeded, but with errno set 9:Bad file descriptor
name .. readdir 249:-5346420323644962042 lstat 249:-5725779783608089317
name shellex readdir 249:2608058107958852925 lstat 249:3945857567889735338
lstat succeeded, but with errno set 2:No such file or directory
name InfoTip readdir 249:2752982411951817191 lstat 249:4090781871882699604
lstat succeeded, but with errno set 2:No such file or directory
name AlwaysShowExt readdir 249:-8169035040402285905 lstat 249:-7545367933727004516

--
Eric Blake



--
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/


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