1
0
mirror of https://git.FreeBSD.org/src.git synced 2024-12-14 10:09:48 +00:00

Let opendir() use O_DIRECTORY.

I am not removing the fstat() calls here, since we cannot yet assume
people will always run kernels that respect O_DIRECTORY.
This commit is contained in:
Ed Schouten 2010-03-21 20:45:06 +00:00
parent 0fef797f4a
commit 070f2a9831
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=205424

View File

@ -86,7 +86,7 @@ __opendir2(const char *name, int flags)
errno = ENOTDIR;
return (NULL);
}
if ((fd = _open(name, O_RDONLY | O_NONBLOCK)) == -1)
if ((fd = _open(name, O_RDONLY | O_NONBLOCK | O_DIRECTORY)) == -1)
return (NULL);
return __opendir_common(fd, name, flags);
@ -200,7 +200,7 @@ __opendir_common(int fd, const char *name, int flags)
*/
if (flags & DTF_REWIND) {
(void)_close(fd);
if ((fd = _open(name, O_RDONLY)) == -1) {
if ((fd = _open(name, O_RDONLY | O_DIRECTORY)) == -1) {
saved_errno = errno;
free(buf);
free(dirp);