From 11f35d5f2444a6dff8d008f65852b7922a8bb043 Mon Sep 17 00:00:00 2001 From: ed Date: Sun, 21 Mar 2010 20:45:06 +0000 Subject: 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. --- lib/libc/gen/opendir.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'lib/libc') diff --git a/lib/libc/gen/opendir.c b/lib/libc/gen/opendir.c index b312c89..0c08735 100644 --- a/lib/libc/gen/opendir.c +++ b/lib/libc/gen/opendir.c @@ -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); -- cgit v1.1