about summary refs log tree commit diff
path: root/sysdeps/unix/sysv/linux/readdir64_r.c
diff options
context:
space:
mode:
Diffstat (limited to 'sysdeps/unix/sysv/linux/readdir64_r.c')
-rw-r--r--sysdeps/unix/sysv/linux/readdir64_r.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/sysdeps/unix/sysv/linux/readdir64_r.c b/sysdeps/unix/sysv/linux/readdir64_r.c
index 57ae4c786e..5e711c4787 100644
--- a/sysdeps/unix/sysv/linux/readdir64_r.c
+++ b/sysdeps/unix/sysv/linux/readdir64_r.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1997 Free Software Foundation, Inc.
+/* Copyright (C) 1997, 1998 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
    The GNU C Library is free software; you can redistribute it and/or
@@ -62,7 +62,8 @@ readdir64_r (DIR *dirp, struct dirent64 *entry, struct dirent64 **result)
 	  if (bytes <= 0)
 	    {
 	      dp = NULL;
-	      reclen = 0;
+	      /* Reclen != 0 signals that an error occurred.  */
+	      reclen = bytes != 0;
 	      break;
 	    }
 	  dirp->size = (size_t) bytes;
@@ -96,12 +97,15 @@ readdir64_r (DIR *dirp, struct dirent64 *entry, struct dirent64 **result)
 #endif
 
       /* Skip deleted files.  */
-    } while (dp->d_ino == 0);
+    }
+  while (dp->d_ino == 0);
 
   if (dp != NULL)
     *result = memcpy (entry, dp, reclen);
+  else
+    *result = NULL;
 
   __libc_lock_unlock (dirp->lock);
 
-  return dp != NULL ? 0 : errno;
+  return dp != NULL ? 0 : reclen ? errno : 0;
 }