From owner-p4-projects@FreeBSD.ORG Thu Jul 5 10:06:59 2007 Return-Path: X-Original-To: p4-projects@freebsd.org Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id DA48116A46B; Thu, 5 Jul 2007 10:06:58 +0000 (UTC) X-Original-To: perforce@FreeBSD.org Delivered-To: perforce@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id AB19416A41F for ; Thu, 5 Jul 2007 10:06:58 +0000 (UTC) (envelope-from rdivacky@FreeBSD.org) Received: from repoman.freebsd.org (repoman.freebsd.org [69.147.83.41]) by mx1.freebsd.org (Postfix) with ESMTP id 9BC7713C44C for ; Thu, 5 Jul 2007 10:06:58 +0000 (UTC) (envelope-from rdivacky@FreeBSD.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.13.8/8.13.8) with ESMTP id l65A6wSD043089 for ; Thu, 5 Jul 2007 10:06:58 GMT (envelope-from rdivacky@FreeBSD.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.13.8/8.13.8/Submit) id l65A6w3O043086 for perforce@freebsd.org; Thu, 5 Jul 2007 10:06:58 GMT (envelope-from rdivacky@FreeBSD.org) Date: Thu, 5 Jul 2007 10:06:58 GMT Message-Id: <200707051006.l65A6w3O043086@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to rdivacky@FreeBSD.org using -f From: Roman Divacky To: Perforce Change Reviews Cc: Subject: PERFORCE change 122934 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 05 Jul 2007 10:06:59 -0000 http://perforce.freebsd.org/chv.cgi?CH=122934 Change 122934 by rdivacky@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 -__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 @@ -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? */ } /*