svn commit: trunk/uClibc/libc/misc/dirent
vapier at uclibc.org
vapier at uclibc.org
Sat Feb 4 02:19:24 UTC 2006
Author: vapier
Date: 2006-02-03 18:19:23 -0800 (Fri, 03 Feb 2006)
New Revision: 13826
Log:
use O_DIRECTORY when possible, saves us from having to use stat() thus cutting codesize/race condition
Modified:
trunk/uClibc/libc/misc/dirent/opendir.c
Changeset:
Modified: trunk/uClibc/libc/misc/dirent/opendir.c
===================================================================
--- trunk/uClibc/libc/misc/dirent/opendir.c 2006-02-04 02:18:41 UTC (rev 13825)
+++ trunk/uClibc/libc/misc/dirent/opendir.c 2006-02-04 02:19:23 UTC (rev 13826)
@@ -7,6 +7,7 @@
#include <errno.h>
#include <stdlib.h>
#include <string.h>
+#include <sys/types.h>
#include <fcntl.h>
#include <unistd.h>
#include <sys/dir.h>
@@ -29,13 +30,17 @@
char *buf;
DIR *ptr;
+#ifndef O_DIRECTORY
+ /* O_DIRECTORY is linux specific and has been around since like 2.1.x */
if (stat(name, &statbuf))
return NULL;
if (!S_ISDIR(statbuf.st_mode)) {
__set_errno(ENOTDIR);
return NULL;
}
- if ((fd = open(name, O_RDONLY)) < 0)
+# define O_DIRECTORY 0
+#endif
+ if ((fd = open(name, O_RDONLY|O_NDELAY|O_DIRECTORY)) < 0)
return NULL;
/* According to POSIX, directory streams should be closed when
* exec. From "Anna Pluzhnikov" <besp at midway.uchicago.edu>.
More information about the uClibc-cvs
mailing list