1 --- opendir.c.orig 2004-11-25 11:38:01.000000000 -0800
2 +++ opendir.c 2006-05-03 23:21:10.000000000 -0700
8 #include "un-namespace.h"
18 - * stat() before _open() because opening of special files may be
19 - * harmful. _fstat() after open because the file may have changed.
20 + * Use O_DIRECTORY to only open directories (because opening of
21 + * special files may be harmful). errno is set to ENOTDIR if
24 - if (stat(name, &statb) != 0)
26 - if (!S_ISDIR(statb.st_mode)) {
30 - if ((fd = _open(name, O_RDONLY | O_NONBLOCK)) == -1)
31 + if ((fd = _open(name, O_RDONLY | O_NONBLOCK | O_DIRECTORY)) == -1)
34 - if (_fstat(fd, &statb) != 0)
36 - if (!S_ISDIR(statb.st_mode)) {
40 if (_fcntl(fd, F_SETFD, FD_CLOEXEC) == -1 ||
41 (dirp = malloc(sizeof(DIR) + sizeof(struct _telldir))) == NULL)
46 dirp->dd_flags = flags;
47 - dirp->dd_lock = NULL;
48 + dirp->dd_lock = (pthread_mutex_t)PTHREAD_MUTEX_INITIALIZER;
51 * Set up seek point for rewinddir.