mirror of git://sourceware.org/git/glibc.git
This commit is contained in:
parent
a4f1763067
commit
2f15699349
|
|
@ -1,8 +1,5 @@
|
||||||
2006-01-20 Ulrich Drepper <drepper@redhat.com>
|
2006-01-20 Ulrich Drepper <drepper@redhat.com>
|
||||||
|
|
||||||
* sysdeps/unix/fdopendir.c (fdopendir): If O_DIRECTORY is
|
|
||||||
available, avoid stat call, use fcntl result to determine whether
|
|
||||||
descriptor is for a directory or not.
|
|
||||||
* dirent/Makefile (tests): Add tst-fdopendir2.
|
* dirent/Makefile (tests): Add tst-fdopendir2.
|
||||||
* dirent/tst-fdopendir2.c: New file.
|
* dirent/tst-fdopendir2.c: New file.
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,6 @@ fdopendir (int fd)
|
||||||
{
|
{
|
||||||
struct stat64 statbuf;
|
struct stat64 statbuf;
|
||||||
|
|
||||||
#ifndef O_DIRECTORY
|
|
||||||
if (__builtin_expect (__fxstat64 (_STAT_VER, fd, &statbuf), 0) < 0)
|
if (__builtin_expect (__fxstat64 (_STAT_VER, fd, &statbuf), 0) < 0)
|
||||||
return NULL;
|
return NULL;
|
||||||
if (__builtin_expect (! S_ISDIR (statbuf.st_mode), 0))
|
if (__builtin_expect (! S_ISDIR (statbuf.st_mode), 0))
|
||||||
|
|
@ -37,20 +36,11 @@ fdopendir (int fd)
|
||||||
__set_errno (ENOTDIR);
|
__set_errno (ENOTDIR);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Make sure the descriptor allows for reading (and eventually that
|
/* Make sure the descriptor allows for reading. */
|
||||||
the descriptor is for a directory). */
|
|
||||||
int flags = __fcntl (fd, F_GETFL);
|
int flags = __fcntl (fd, F_GETFL);
|
||||||
if (__builtin_expect (flags == -1, 0))
|
if (__builtin_expect (flags == -1, 0))
|
||||||
return NULL;
|
return NULL;
|
||||||
#ifdef O_DIRECTORY
|
|
||||||
if (__builtin_expect ((flags & O_DIRECTORY) == 0, 0))
|
|
||||||
{
|
|
||||||
__set_errno (ENOTDIR);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
if (__builtin_expect ((flags & O_ACCMODE) == O_WRONLY, 0))
|
if (__builtin_expect ((flags & O_ACCMODE) == O_WRONLY, 0))
|
||||||
{
|
{
|
||||||
__set_errno (EINVAL);
|
__set_errno (EINVAL);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue