svn commit: r205424 - head/lib/libc/gen

Ed Schouten ed at FreeBSD.org
Sun Mar 21 20:45:06 UTC 2010


Author: ed
Date: Sun Mar 21 20:45:06 2010
New Revision: 205424
URL: http://svn.freebsd.org/changeset/base/205424

Log:
  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.

Modified:
  head/lib/libc/gen/opendir.c

Modified: head/lib/libc/gen/opendir.c
==============================================================================
--- head/lib/libc/gen/opendir.c	Sun Mar 21 20:43:23 2010	(r205423)
+++ head/lib/libc/gen/opendir.c	Sun Mar 21 20:45:06 2010	(r205424)
@@ -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 *nam
 		 */
 		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);


More information about the svn-src-head mailing list