about summary refs log tree commit diff
path: root/sysdeps/unix/readdir_r.c
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>1998-03-10 11:10:51 +0000
committerUlrich Drepper <drepper@redhat.com>1998-03-10 11:10:51 +0000
commitc063ba610a6058cacddf2e3d156f478c7b969f87 (patch)
tree817fe899699e8c9ffa5e0e308a41e687430acfba /sysdeps/unix/readdir_r.c
parent54fce91d605e1ef51303508b7adc22e01c092757 (diff)
downloadglibc-c063ba610a6058cacddf2e3d156f478c7b969f87.tar.gz
glibc-c063ba610a6058cacddf2e3d156f478c7b969f87.tar.xz
glibc-c063ba610a6058cacddf2e3d156f478c7b969f87.zip
Update.
1998-03-10 19:43  Matthias Urlichs <urlichs@noris.de>

	* sysdeps/unix/readdir_r.c: zero out *result on EOF.
	* sysdeps/unix/sysv/linux/readdir64_r.c: Likewise.
	* manual/filesys/texi: document this.
Diffstat (limited to 'sysdeps/unix/readdir_r.c')
-rw-r--r--sysdeps/unix/readdir_r.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/sysdeps/unix/readdir_r.c b/sysdeps/unix/readdir_r.c
index 6d70233e6e..15a4c3775c 100644
--- a/sysdeps/unix/readdir_r.c
+++ b/sysdeps/unix/readdir_r.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991, 92, 93, 94, 95, 96, 97 Free Software Foundation, Inc.
+/* Copyright (C) 1991,92,93,94,95,96,97,98 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
@@ -59,7 +59,8 @@ __readdir_r (DIR *dirp, struct dirent *entry, struct dirent **result)
 	  if (bytes <= 0)
 	    {
 	      dp = NULL;
-	      reclen = 0;
+	      /* Reclen != 0 signals that an error occurred.  */
+	      reclen = bytes != 0;
 	      break;
 	    }
 	  dirp->size = (size_t) bytes;
@@ -93,13 +94,16 @@ __readdir_r (DIR *dirp, struct dirent *entry, struct dirent **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;
 }
 weak_alias (__readdir_r, readdir_r)