PERFORCE change 122934 for review
Roman Divacky
rdivacky at FreeBSD.org
Thu Jul 5 10:06:59 UTC 2007
http://perforce.freebsd.org/chv.cgi?CH=122934
Change 122934 by rdivacky at rdivacky_witten on 2007/07/05 10:06:17
Naive implementation of fdopendir.
Affected files ...
.. //depot/projects/soc2007/rdivacky/linux_at/lib/libc/gen/fdopendir.c#2 edit
Differences ...
==== //depot/projects/soc2007/rdivacky/linux_at/lib/libc/gen/fdopendir.c#2 (text+ko) ====
@@ -31,7 +31,7 @@
static char sccsid[] = "@(#)opendir.c 8.8 (Berkeley) 5/1/95";
#endif /* LIBC_SCCS and not lint */
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/lib/libc/gen/opendir.c,v 1.23 2007/01/09 00:27:54 imp Exp $");
+__FBSDID("$FreeBSD$");
#include "namespace.h"
#include <sys/param.h>
@@ -51,37 +51,24 @@
* Open a directory.
*/
DIR *
-opendir(name)
- const char *name;
+fdopendir(fd)
+ const int fd;
{
- return (__opendir2(name, DTF_HIDEW|DTF_NODUP));
+ return (__fdopendir2(fd, DTF_HIDEW|DTF_NODUP));
}
DIR *
-__opendir2(name, flags)
- const char *name;
+__fdopendir2(fd, flags)
+ const int fd;
int flags;
{
DIR *dirp;
- int fd;
int incr;
int saved_errno;
int unionstack;
struct stat statb;
- /*
- * stat() before _open() because opening of special files may be
- * harmful. _fstat() after open because the file may have changed.
- */
- if (stat(name, &statb) != 0)
- return (NULL);
- if (!S_ISDIR(statb.st_mode)) {
- errno = ENOTDIR;
- return (NULL);
- }
- if ((fd = _open(name, O_RDONLY | O_NONBLOCK)) == -1)
- return (NULL);
dirp = NULL;
if (_fstat(fd, &statb) != 0)
goto fail;
@@ -168,14 +155,7 @@
* which has also been read -- see fts.c.
*/
if (flags & DTF_REWIND) {
- (void)_close(fd);
- if ((fd = _open(name, O_RDONLY)) == -1) {
- saved_errno = errno;
- free(buf);
- free(dirp);
- errno = saved_errno;
- return (NULL);
- }
+ /* XXX: what here? */
}
/*
More information about the p4-projects
mailing list