* cygwin.din: Export fdopendir.

* dir.cc (opendir): Call fhandler's opendir with fd set to -1.
	(fdopendir): New function.
	(seekdir64): Use dirent_info_mask.
	(rewinddir): Ditto.
	(closedir): Only release underlying file descriptor if it has been
	reserved by opendir itself.
	* fhandler.cc (fhandler_base::opendir): Accommodate new parameter.
	* fhandler.h (dirent_states): Add dirent_valid_fd and dirent_info_mask.
	(fhander_XXX::opendir): Add file descriptor parameter.  Use regparms.
	(fhandler_procnet::opendir): Drop declaration.
	* fhandler_disk_file.cc (fhandler_disk_file::opendir): Ditto.
	If called from fdopendir, use existing handle to re-open directory
	with valid flags.  Rename fd to cfd.  Use only if no valid incoming fd.
	(fhandler_cygdrive::opendir): Accommodate new parameter.
	* fhandler_process.cc (fhandler_process::opendir): Ditto.
	* fhandler_procnet.cc (fhandler_procnet::opendir): Drop definition.
	* fhandler_virtual.cc (fhandler_virtual::opendir): Accommodate new
	parameter.  Only create new file descriptor entry if called from
	opendir.  Remove duplicated setting of dir->__flags.
	* posix.sgml: Add fdopendir to list of implemented Solaris functions.
	* include/cygwin/version.h: Bump API minor number.
	* include/sys/dirent.h: Declare fdopendir.
This commit is contained in:
Corinna Vinschen
2007-06-29 15:13:01 +00:00
parent 8931495a14
commit 40570a828e
11 changed files with 128 additions and 62 deletions

View File

@@ -46,7 +46,7 @@ fhandler_virtual::fixup_after_exec ()
}
DIR *
fhandler_virtual::opendir ()
fhandler_virtual::opendir (int fd)
{
DIR *dir;
DIR *res = NULL;
@@ -73,20 +73,30 @@ fhandler_virtual::opendir ()
{
strcpy (dir->__d_dirname, get_name ());
dir->__d_dirent->__d_version = __DIRENT_VERSION;
cygheap_fdnew fd;
dir->__d_cookie = __DIRENT_COOKIE;
dir->__handle = INVALID_HANDLE_VALUE;
dir->__d_position = 0;
dir->__flags = 0;
if (fd >= 0)
{
fd = this;
fd->nohandle (true);
{
dir->__flags |= dirent_valid_fd;
dir->__d_fd = fd;
dir->__fh = this;
dir->__d_cookie = __DIRENT_COOKIE;
dir->__handle = INVALID_HANDLE_VALUE;
dir->__d_position = 0;
// dir->__d_dirhash = get_namehash ();
dir->__flags = dirent_saw_dot | dirent_saw_dot_dot;
res = dir;
res->__flags = 0;
dir->__fh = this;
res = dir;
}
else
{
cygheap_fdnew cfd;
if (cfd >= 0)
{
cfd = this;
cfd->nohandle (true);
dir->__d_fd = cfd;
dir->__fh = this;
res = dir;
}
}
}