aboutsummaryrefslogtreecommitdiff
path: root/sysdeps/unix/readdir.c
diff options
context:
space:
mode:
authorRoland McGrath <roland@gnu.org>2002-08-28 03:26:52 +0000
committerRoland McGrath <roland@gnu.org>2002-08-28 03:26:52 +0000
commit90341544e5ddea1402a7f188800d2381d07a1602 (patch)
tree61f94afa1a176cbff16b2d599068d752fcf565d4 /sysdeps/unix/readdir.c
parenta7b8a17b063179d23e185eee655a308ae91873d7 (diff)
downloadglibc-90341544e5ddea1402a7f188800d2381d07a1602.tar
glibc-90341544e5ddea1402a7f188800d2381d07a1602.tar.gz
glibc-90341544e5ddea1402a7f188800d2381d07a1602.tar.bz2
glibc-90341544e5ddea1402a7f188800d2381d07a1602.zip
* sysdeps/unix/readdir.c: If getdents fails with ENOENT, restore errno
and treat it as an EOF return. * sysdeps/unix/readdir_r.c: Likewise.
Diffstat (limited to 'sysdeps/unix/readdir.c')
-rw-r--r--sysdeps/unix/readdir.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/sysdeps/unix/readdir.c b/sysdeps/unix/readdir.c
index dc015d2802..4a0f0890e9 100644
--- a/sysdeps/unix/readdir.c
+++ b/sysdeps/unix/readdir.c
@@ -1,4 +1,5 @@
-/* Copyright (C) 1991,92,93,94,95,96,97,99,2000 Free Software Foundation, Inc.
+/* Copyright (C) 1991,92,93,94,95,96,97,99,2000,02
+ 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
@@ -64,6 +65,12 @@ __READDIR (DIR *dirp)
bytes = __GETDENTS (dirp->fd, dirp->data, maxread);
if (bytes <= 0)
{
+ /* On some systems getdents fails with ENOENT when the
+ open directory has been rmdir'd already. POSIX.1
+ requires that we treat this condition like normal EOF. */
+ if (bytes < 0 && errno == ENOENT)
+ bytes = 0;
+
/* Don't modifiy errno when reaching EOF. */
if (bytes == 0)
__set_errno (saved_errno);