Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
.
  • Loading branch information
Ulrich Drepper committed Jan 20, 2006
1 parent a4f1763 commit 2f15699
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 14 deletions.
3 changes: 0 additions & 3 deletions ChangeLog
@@ -1,8 +1,5 @@
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/tst-fdopendir2.c: New file.

Expand Down
12 changes: 1 addition & 11 deletions sysdeps/unix/fdopendir.c
Expand Up @@ -29,28 +29,18 @@ fdopendir (int fd)
{
struct stat64 statbuf;

#ifndef O_DIRECTORY
if (__builtin_expect (__fxstat64 (_STAT_VER, fd, &statbuf), 0) < 0)
return NULL;
if (__builtin_expect (! S_ISDIR (statbuf.st_mode), 0))
{
__set_errno (ENOTDIR);
return NULL;
}
#endif

/* Make sure the descriptor allows for reading (and eventually that
the descriptor is for a directory). */
/* Make sure the descriptor allows for reading. */
int flags = __fcntl (fd, F_GETFL);
if (__builtin_expect (flags == -1, 0))
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))
{
__set_errno (EINVAL);
Expand Down

0 comments on commit 2f15699

Please sign in to comment.