aboutsummaryrefslogtreecommitdiff
path: root/winsup
diff options
context:
space:
mode:
authorCorinna Vinschen <corinna@vinschen.de>2001-09-03 16:36:54 +0000
committerCorinna Vinschen <corinna@vinschen.de>2001-09-03 16:36:54 +0000
commita71aee46c41636e75325df62d9027bfc66b3c4dc (patch)
treebd56f67cc5db2a52e6d2cb1068a400be79085e53 /winsup
parent6d47f33adbbab01dc8b10327874eca5132520235 (diff)
downloadnewlib-a71aee46c41636e75325df62d9027bfc66b3c4dc.zip
newlib-a71aee46c41636e75325df62d9027bfc66b3c4dc.tar.gz
newlib-a71aee46c41636e75325df62d9027bfc66b3c4dc.tar.bz2
* cygwin.din: Add `dirfd'.
* dir.cc (dirfd): New function. (opendir): Open a directory file descriptor and save it in __d_dirent->d_fd. (closedir): Close directory file descriptor. * include/cygwin/version.h: Bump API minor version to 44.
Diffstat (limited to 'winsup')
-rw-r--r--winsup/cygwin/ChangeLog9
-rw-r--r--winsup/cygwin/cygwin.din2
-rw-r--r--winsup/cygwin/dir.cc17
-rw-r--r--winsup/cygwin/include/cygwin/version.h3
4 files changed, 30 insertions, 1 deletions
diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog
index 167457d..809f49a 100644
--- a/winsup/cygwin/ChangeLog
+++ b/winsup/cygwin/ChangeLog
@@ -1,3 +1,12 @@
+Mon Sep 3 18:34:00 2001 Corinna Vinschen <corinna@vinschen.de>
+
+ * cygwin.din: Add `dirfd'.
+ * dir.cc (dirfd): New function.
+ (opendir): Open a directory file descriptor and save it in
+ __d_dirent->d_fd.
+ (closedir): Close directory file descriptor.
+ * include/cygwin/version.h: Bump API minor version to 44.
+
Sun Sep 2 22:09:31 2001 Christopher Faylor <cgf@cygnus.com>
* child_info.h: Modify magic number.
diff --git a/winsup/cygwin/cygwin.din b/winsup/cygwin/cygwin.din
index 10ddbbf..693b16b 100644
--- a/winsup/cygwin/cygwin.din
+++ b/winsup/cygwin/cygwin.din
@@ -130,6 +130,8 @@ difftime
_difftime = difftime
div
_div = div
+dirfd
+_dirfd = dirfd
_dll_crt0@0
dll_crt0__FP11per_process
cygwin_dll_init
diff --git a/winsup/cygwin/dir.cc b/winsup/cygwin/dir.cc
index 83e38de..d44615e 100644
--- a/winsup/cygwin/dir.cc
+++ b/winsup/cygwin/dir.cc
@@ -9,6 +9,7 @@ Cygwin license. Please consult the file "CYGWIN_LICENSE" for
details. */
#include "winsup.h"
+#include <sys/fcntl.h>
#include <unistd.h>
#include <stdlib.h>
#include <sys/stat.h>
@@ -61,6 +62,18 @@ writable_directory (const char *file)
#endif
}
+extern "C" int
+dirfd (DIR *dir)
+{
+ if (dir->__d_cookie != __DIRENT_COOKIE)
+ {
+ set_errno (EBADF);
+ syscall_printf ("-1 = dirfd (%p)", dir);
+ return -1;
+ }
+ return dir->__d_dirent->d_fd;
+}
+
/* opendir: POSIX 5.1.2.1 */
extern "C" DIR *
opendir (const char *dirname)
@@ -114,6 +127,7 @@ opendir (const char *dirname)
goto failed;
}
strcpy (dir->__d_dirname, real_dirname.get_win32 ());
+ dir->__d_dirent->d_fd = open (dir->__d_dirname, O_RDONLY | O_DIROPEN);
/* FindFirstFile doesn't seem to like duplicate /'s. */
len = strlen (dir->__d_dirname);
if (len == 0 || SLASH_P (dir->__d_dirname[len - 1]))
@@ -290,6 +304,9 @@ closedir (DIR * dir)
return -1;
}
+ if (dir->__d_dirent->d_fd >= 0)
+ close (dir->__d_dirent->d_fd);
+
/* Reset the marker in case the caller tries to use `dir' again. */
dir->__d_cookie = 0;
diff --git a/winsup/cygwin/include/cygwin/version.h b/winsup/cygwin/include/cygwin/version.h
index db9a97b..f270a82 100644
--- a/winsup/cygwin/include/cygwin/version.h
+++ b/winsup/cygwin/include/cygwin/version.h
@@ -141,10 +141,11 @@ details. */
41: __signgam
42: sys_errlist, sys_nerr
43: sigsetjmp, siglongjmp fixed
+ 44: Export dirfd
*/
#define CYGWIN_VERSION_API_MAJOR 0
-#define CYGWIN_VERSION_API_MINOR 43
+#define CYGWIN_VERSION_API_MINOR 44
/* There is also a compatibity version number associated with the
shared memory regions. It is incremented when incompatible