]> sourceware.org Git - glibc.git/commitdiff
Update.
authorUlrich Drepper <drepper@redhat.com>
Tue, 10 Mar 1998 11:10:51 +0000 (11:10 +0000)
committerUlrich Drepper <drepper@redhat.com>
Tue, 10 Mar 1998 11:10:51 +0000 (11:10 +0000)
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.

ChangeLog
manual/filesys.texi
sysdeps/unix/readdir_r.c
sysdeps/unix/sysv/linux/readdir64_r.c

index 6824fa21f74107a9bb534372ab8eec246f1a4a2e..181c33bc3557d3597c7a2f99e9fdbf7840ae828c 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+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.
+
 1998-03-10 10:49  Ulrich Drepper  <drepper@cygnus.com>
 
        * manual/filesys.texi: Document the change below.
index 3b125cd3f0b97175b19e6273848d47993c149827..951ae7956ce8df7be9b30aff6d790e5a0fe40fa0 100644 (file)
@@ -354,6 +354,9 @@ successfully.  In this case a pointer to the result is returned in
 the function returns a value indicating the error (as described for
 @code{readdir}).
 
+If there are no more directory entries, @code{readdir_r}'s return value is
+@code{0}, and *@var{result} is set to @code{NULL}.
+
 @strong{Portability Note:} On some systems, @code{readdir_r} may not
 return a terminated string as the file name even if no @code{d_reclen}
 element is available in @code{struct dirent} and the file name as the
index 6d70233e6eb1a73aa77be4165f66d08a18020601..15a4c3775c9a70e8111171eadc60fa5860369683 100644 (file)
@@ -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)
index 57ae4c786ef4711aae5856f6e036f6cf8814ce66..5e711c4787a749e56446e86c608f1de446227476 100644 (file)
@@ -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;
 }
This page took 0.054506 seconds and 5 git commands to generate.