summaryrefslogtreecommitdiffstats
path: root/winsup/cygwin/fhandler_virtual.cc
diff options
context:
space:
mode:
Diffstat (limited to 'winsup/cygwin/fhandler_virtual.cc')
-rw-r--r--winsup/cygwin/fhandler_virtual.cc32
1 files changed, 21 insertions, 11 deletions
diff --git a/winsup/cygwin/fhandler_virtual.cc b/winsup/cygwin/fhandler_virtual.cc
index 13f8e1fd4..4045c2d5e 100644
--- a/winsup/cygwin/fhandler_virtual.cc
+++ b/winsup/cygwin/fhandler_virtual.cc
@@ -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;
+ res = dir;
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;
+ }
+ else
+ {
+ cygheap_fdnew cfd;
+ if (cfd >= 0)
+ {
+ cfd = this;
+ cfd->nohandle (true);
+ dir->__d_fd = cfd;
+ dir->__fh = this;
+ res = dir;
+ }
}
}