Hello,

Attached is a patch + a testcase. The testcase can be executed with any of
the
following directories:

  /cygdrive
  /proc
  /proc/<PID>
  /proc/registry/HKEY_WHATEVER

2003-08-05  Pavel Tsekov  <[EMAIL PROTECTED]>

        * fhandler_disk_file.cc (fhandler_cygdrive::readdir): Do not change 'errno'
if
        end of directory condition is encountered as per SUSv2.
        * fhandler_proc.cc (fhandler_proc::readdir): Ditto.
        * fhandler_process (fhandler_process::readdir): Ditto.
        * fhandler_registry (fhandler_registry::readdir): Ditto.

Pavel

-- 
COMPUTERBILD 15/03: Premium-e-mail-Dienste im Test
--------------------------------------------------
1. GMX TopMail - Platz 1 und Testsieger!
2. GMX ProMail - Platz 2 und Preis-Qualitätssieger!
3. Arcor - 4. web.de - 5. T-Online - 6. freenet.de - 7. daybyday - 8. e-Post

Attachment: scandir.c
Description: Binary data

Index: fhandler_disk_file.cc
===================================================================
RCS file: /cvs/src/src/winsup/cygwin/fhandler_disk_file.cc,v
retrieving revision 1.58
diff -u -p -r1.58 fhandler_disk_file.cc
--- fhandler_disk_file.cc       26 Jul 2003 04:53:59 -0000      1.58
+++ fhandler_disk_file.cc       5 Aug 2003 02:38:36 -0000
@@ -769,10 +769,7 @@ fhandler_cygdrive::readdir (DIR *dir)
   if (!iscygdrive_root ())
     return fhandler_disk_file::readdir (dir);
   if (!pdrive || !*pdrive)
-    {
-      set_errno (ENMFILE);
-      return NULL;
-    }
+    return NULL;
   else if (dir->__d_position > 1
           && GetFileAttributes (pdrive) == INVALID_FILE_ATTRIBUTES)
     {
Index: fhandler_proc.cc
===================================================================
RCS file: /cvs/src/src/winsup/cygwin/fhandler_proc.cc,v
retrieving revision 1.34
diff -u -p -r1.34 fhandler_proc.cc
--- fhandler_proc.cc    26 Jul 2003 04:53:59 -0000      1.34
+++ fhandler_proc.cc    5 Aug 2003 02:38:39 -0000
@@ -206,7 +206,6 @@ fhandler_proc::readdir (DIR * dir)
            dir->__d_position++;
            return dir->__d_dirent;
          }
-      set_errno (ENMFILE);
       return NULL;
     }
 
Index: fhandler_process.cc
===================================================================
RCS file: /cvs/src/src/winsup/cygwin/fhandler_process.cc,v
retrieving revision 1.35
diff -u -p -r1.35 fhandler_process.cc
--- fhandler_process.cc 9 Jul 2003 01:33:06 -0000       1.35
+++ fhandler_process.cc 5 Aug 2003 02:38:42 -0000
@@ -147,10 +147,7 @@ struct dirent *
 fhandler_process::readdir (DIR * dir)
 {
   if (dir->__d_position >= PROCESS_LINK_COUNT)
-    {
-      set_errno (ENMFILE);
-      return NULL;
-    }
+    return NULL;
   strcpy (dir->__d_dirent->d_name, process_listing[dir->__d_position++]);
   syscall_printf ("%p = readdir (%p) (%s)", &dir->__d_dirent, dir,
                  dir->__d_dirent->d_name);
Index: fhandler_registry.cc
===================================================================
RCS file: /cvs/src/src/winsup/cygwin/fhandler_registry.cc,v
retrieving revision 1.19
diff -u -p -r1.19 fhandler_registry.cc
--- fhandler_registry.cc        16 Jun 2003 03:24:10 -0000      1.19
+++ fhandler_registry.cc        5 Aug 2003 02:38:45 -0000
@@ -331,7 +331,8 @@ retry:
     {
       RegCloseKey ((HKEY) dir->__d_u.__d_data.__handle);
       dir->__d_u.__d_data.__handle = INVALID_HANDLE_VALUE;
-      seterrno_from_win_error (__FILE__, __LINE__, error);
+      if (error != ERROR_NO_MORE_ITEMS)
+       seterrno_from_win_error (__FILE__, __LINE__, error);
       goto out;
     }
 

Reply via email to