mirror of
https://sourceware.org/git/glibc.git
synced 2025-07-29 11:41:21 +03:00
* sysdeps/unix/readdir.c: If getdents fails with ENOENT, restore errno
and treat it as an EOF return. * sysdeps/unix/readdir_r.c: Likewise.
This commit is contained in:
@ -1,5 +1,9 @@
|
|||||||
2002-08-27 Roland McGrath <roland@redhat.com>
|
2002-08-27 Roland McGrath <roland@redhat.com>
|
||||||
|
|
||||||
|
* sysdeps/unix/readdir.c: If getdents fails with ENOENT, restore errno
|
||||||
|
and treat it as an EOF return.
|
||||||
|
* sysdeps/unix/readdir_r.c: Likewise.
|
||||||
|
|
||||||
* sysdeps/gnu/errlist-compat.awk: Include <bits/wordsize.h> in output.
|
* sysdeps/gnu/errlist-compat.awk: Include <bits/wordsize.h> in output.
|
||||||
From Alexandre Oliva <aoliva@redhat.com>.
|
From Alexandre Oliva <aoliva@redhat.com>.
|
||||||
* sysdeps/gnu/errlist-compat.c: Regenerated.
|
* sysdeps/gnu/errlist-compat.c: Regenerated.
|
||||||
|
@ -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.
|
This file is part of the GNU C Library.
|
||||||
|
|
||||||
The GNU C Library is free software; you can redistribute it and/or
|
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);
|
bytes = __GETDENTS (dirp->fd, dirp->data, maxread);
|
||||||
if (bytes <= 0)
|
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. */
|
/* Don't modifiy errno when reaching EOF. */
|
||||||
if (bytes == 0)
|
if (bytes == 0)
|
||||||
__set_errno (saved_errno);
|
__set_errno (saved_errno);
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
/* Copyright (C) 1991,92,93,94,95,96,97,98,99,2000 Free Software Foundation, Inc.
|
/* Copyright (C) 1991,92,93,94,95,96,97,98,99,2000,02
|
||||||
|
Free Software Foundation, Inc.
|
||||||
This file is part of the GNU C Library.
|
This file is part of the GNU C Library.
|
||||||
|
|
||||||
The GNU C Library is free software; you can redistribute it and/or
|
The GNU C Library is free software; you can redistribute it and/or
|
||||||
@ -40,6 +41,7 @@ __READDIR_R (DIR *dirp, DIRENT_TYPE *entry, DIRENT_TYPE **result)
|
|||||||
{
|
{
|
||||||
DIRENT_TYPE *dp;
|
DIRENT_TYPE *dp;
|
||||||
size_t reclen;
|
size_t reclen;
|
||||||
|
const int saved_errno = errno;
|
||||||
|
|
||||||
__libc_lock_lock (dirp->lock);
|
__libc_lock_lock (dirp->lock);
|
||||||
|
|
||||||
@ -62,6 +64,15 @@ __READDIR_R (DIR *dirp, DIRENT_TYPE *entry, DIRENT_TYPE **result)
|
|||||||
bytes = __GETDENTS (dirp->fd, dirp->data, maxread);
|
bytes = __GETDENTS (dirp->fd, dirp->data, maxread);
|
||||||
if (bytes <= 0)
|
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;
|
||||||
|
__set_errno (saved_errno);
|
||||||
|
}
|
||||||
|
|
||||||
dp = NULL;
|
dp = NULL;
|
||||||
/* Reclen != 0 signals that an error occurred. */
|
/* Reclen != 0 signals that an error occurred. */
|
||||||
reclen = bytes != 0;
|
reclen = bytes != 0;
|
||||||
|
Reference in New Issue
Block a user