summaryrefslogtreecommitdiff
path: root/sysdeps/unix/opendir.c
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2005-10-20 06:59:57 +0000
committerJakub Jelinek <jakub@redhat.com>2005-10-20 06:59:57 +0000
commitb7071f6fc41f4c20510de3683f39e5c8ea8a2e1e (patch)
tree852f4f1992a3c9ecbb44b822df6702c7e635fc5a /sysdeps/unix/opendir.c
parentacfebba27b162b3064c616142883541eaef3f725 (diff)
Updated to fedora-glibc-20051020T0651
Diffstat (limited to 'sysdeps/unix/opendir.c')
-rw-r--r--sysdeps/unix/opendir.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/sysdeps/unix/opendir.c b/sysdeps/unix/opendir.c
index 366670b79c..98fb4ca5c8 100644
--- a/sysdeps/unix/opendir.c
+++ b/sysdeps/unix/opendir.c
@@ -132,14 +132,14 @@ __opendir (const char *name)
}
}
- return __alloc_dir (fd, &statbuf);
+ return __alloc_dir (fd, true, &statbuf);
}
weak_alias (__opendir, opendir)
DIR *
internal_function
-__alloc_dir (int fd, struct stat64 *statp)
+__alloc_dir (int fd, bool close_fd, struct stat64 *statp)
{
if (__builtin_expect (__fcntl (fd, F_SETFD, FD_CLOEXEC), 0) < 0)
goto lose;
@@ -160,9 +160,12 @@ __alloc_dir (int fd, struct stat64 *statp)
if (dirp == NULL)
lose:
{
- int save_errno = errno;
- close_not_cancel_no_status (fd);
- __set_errno (save_errno);
+ if (close_fd)
+ {
+ int save_errno = errno;
+ close_not_cancel_no_status (fd);
+ __set_errno (save_errno);
+ }
return NULL;
}
memset (dirp, '\0', sizeof (DIR));