From owner-svn-src-all@FreeBSD.ORG Sun Aug 18 20:11:36 2013 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id 463BC411; Sun, 18 Aug 2013 20:11:36 +0000 (UTC) (envelope-from pjd@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 237652A6B; Sun, 18 Aug 2013 20:11:36 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r7IKBZ6r002429; Sun, 18 Aug 2013 20:11:35 GMT (envelope-from pjd@svn.freebsd.org) Received: (from pjd@localhost) by svn.freebsd.org (8.14.7/8.14.5/Submit) id r7IKBZM3002425; Sun, 18 Aug 2013 20:11:35 GMT (envelope-from pjd@svn.freebsd.org) Message-Id: <201308182011.r7IKBZM3002425@svn.freebsd.org> From: Pawel Jakub Dawidek Date: Sun, 18 Aug 2013 20:11:35 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r254499 - in head: include lib/libc/gen X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 18 Aug 2013 20:11:36 -0000 Author: pjd Date: Sun Aug 18 20:11:34 2013 New Revision: 254499 URL: http://svnweb.freebsd.org/changeset/base/254499 Log: Implement fdclosedir(3) function, which is equivalent to the closedir(3) function, but returns directory file descriptor instead of closing it. Submitted by: Mariusz Zaborski Sponsored by: Google Summer of Code 2013 Modified: head/include/dirent.h head/lib/libc/gen/Symbol.map head/lib/libc/gen/closedir.c head/lib/libc/gen/directory.3 Modified: head/include/dirent.h ============================================================================== --- head/include/dirent.h Sun Aug 18 20:06:35 2013 (r254498) +++ head/include/dirent.h Sun Aug 18 20:11:34 2013 (r254499) @@ -79,6 +79,7 @@ int dirfd(DIR *); #endif #if __BSD_VISIBLE DIR *__opendir2(const char *, int); +int fdclosedir(DIR *); int getdents(int, char *, int); int getdirentries(int, char *, int, long *); #endif Modified: head/lib/libc/gen/Symbol.map ============================================================================== --- head/lib/libc/gen/Symbol.map Sun Aug 18 20:06:35 2013 (r254498) +++ head/lib/libc/gen/Symbol.map Sun Aug 18 20:11:34 2013 (r254499) @@ -384,6 +384,7 @@ FBSD_1.3 { clock_getcpuclockid; dirfd; dup3; + fdclosedir; fdlopen; __FreeBSD_libc_enter_restricted_mode; getcontextx; Modified: head/lib/libc/gen/closedir.c ============================================================================== --- head/lib/libc/gen/closedir.c Sun Aug 18 20:06:35 2013 (r254498) +++ head/lib/libc/gen/closedir.c Sun Aug 18 20:11:34 2013 (r254499) @@ -49,7 +49,7 @@ __FBSDID("$FreeBSD$"); * close a directory. */ int -closedir(DIR *dirp) +fdclosedir(DIR *dirp) { int fd; @@ -65,5 +65,12 @@ closedir(DIR *dirp) _pthread_mutex_destroy(&dirp->dd_lock); } free((void *)dirp); - return(_close(fd)); + return (fd); +} + +int +closedir(DIR *dirp) +{ + + return (_close(fdclosedir(dirp))); } Modified: head/lib/libc/gen/directory.3 ============================================================================== --- head/lib/libc/gen/directory.3 Sun Aug 18 20:06:35 2013 (r254498) +++ head/lib/libc/gen/directory.3 Sun Aug 18 20:11:34 2013 (r254499) @@ -28,7 +28,7 @@ .\" @(#)directory.3 8.1 (Berkeley) 6/4/93 .\" $FreeBSD$ .\" -.Dd July 5, 2012 +.Dd August 18, 2013 .Dt DIRECTORY 3 .Os .Sh NAME @@ -40,6 +40,7 @@ .Nm seekdir , .Nm rewinddir , .Nm closedir , +.Nm fdclosedir , .Nm dirfd .Nd directory operations .Sh LIBRARY @@ -64,6 +65,8 @@ .Ft int .Fn closedir "DIR *dirp" .Ft int +.Fn fdclosedir "DIR *dirp" +.Ft int .Fn dirfd "DIR *dirp" .Sh DESCRIPTION The @@ -208,6 +211,13 @@ On failure, \-1 is returned and the glob is set to indicate the error. .Pp The +.Fn fdclosedir +function is equivalent to the +.Fn closedir +function except that this function returns directory file descriptor instead of +closing it. +.Pp +The .Fn dirfd function returns the integer file descriptor associated with the named @@ -252,6 +262,9 @@ The .Fn fdopendir function appeared in .Fx 8.0 . +.Fn fdclosedir +function appeared in +.Fx 10.0 . .Sh BUGS The invalidation of .Fn telldir