summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpjd <pjd@FreeBSD.org>2013-08-18 20:11:34 +0000
committerpjd <pjd@FreeBSD.org>2013-08-18 20:11:34 +0000
commitb717fb9f083afdfbc50a14ced6ddc971ca583f02 (patch)
tree37987e56c42c803d239a91e0492707926feb0d7a
parentab20de7f07aa70c9e4f011a7080d656e3bbc7397 (diff)
downloadFreeBSD-src-b717fb9f083afdfbc50a14ced6ddc971ca583f02.zip
FreeBSD-src-b717fb9f083afdfbc50a14ced6ddc971ca583f02.tar.gz
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 <oshogbo@FreeBSD.org> Sponsored by: Google Summer of Code 2013
-rw-r--r--include/dirent.h1
-rw-r--r--lib/libc/gen/Symbol.map1
-rw-r--r--lib/libc/gen/closedir.c11
-rw-r--r--lib/libc/gen/directory.315
4 files changed, 25 insertions, 3 deletions
diff --git a/include/dirent.h b/include/dirent.h
index 941a977..d0b0a9a 100644
--- a/include/dirent.h
+++ b/include/dirent.h
@@ -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
diff --git a/lib/libc/gen/Symbol.map b/lib/libc/gen/Symbol.map
index e9e645e..5885420 100644
--- a/lib/libc/gen/Symbol.map
+++ b/lib/libc/gen/Symbol.map
@@ -384,6 +384,7 @@ FBSD_1.3 {
clock_getcpuclockid;
dirfd;
dup3;
+ fdclosedir;
fdlopen;
__FreeBSD_libc_enter_restricted_mode;
getcontextx;
diff --git a/lib/libc/gen/closedir.c b/lib/libc/gen/closedir.c
index 4b520cc..88ded37 100644
--- a/lib/libc/gen/closedir.c
+++ b/lib/libc/gen/closedir.c
@@ -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)));
}
diff --git a/lib/libc/gen/directory.3 b/lib/libc/gen/directory.3
index 0fd5bba..4573d45 100644
--- a/lib/libc/gen/directory.3
+++ b/lib/libc/gen/directory.3
@@ -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 global variable
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
OpenPOWER on IntegriCloud