* 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.
This commit is contained in:
Corinna Vinschen 2001-09-03 16:36:54 +00:00
parent 6d47f33adb
commit a71aee46c4
4 changed files with 30 additions and 1 deletions

View File

@ -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.

View File

@ -130,6 +130,8 @@ difftime
_difftime = difftime
div
_div = div
dirfd
_dirfd = dirfd
_dll_crt0@0
dll_crt0__FP11per_process
cygwin_dll_init

View File

@ -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;

View File

@ -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