aboutsummaryrefslogtreecommitdiff
path: root/winsup/cygwin
diff options
context:
space:
mode:
Diffstat (limited to 'winsup/cygwin')
-rw-r--r--winsup/cygwin/dir.cc11
-rw-r--r--winsup/cygwin/fhandler/disk_file.cc4
-rw-r--r--winsup/cygwin/fhandler/virtual.cc4
3 files changed, 10 insertions, 9 deletions
diff --git a/winsup/cygwin/dir.cc b/winsup/cygwin/dir.cc
index c30ed74..df07491 100644
--- a/winsup/cygwin/dir.cc
+++ b/winsup/cygwin/dir.cc
@@ -61,13 +61,18 @@ opendir (const char *name)
set_errno (fh->error ());
res = NULL;
}
- else if (fh->exists ())
- res = fh->opendir (-1);
- else
+ else if (!fh->exists ())
{
set_errno (ENOENT);
res = NULL;
}
+ else if (!fh->pc.isdir ())
+ {
+ set_errno (ENOTDIR);
+ res = NULL;
+ }
+ else
+ res = fh->opendir (-1);
if (!res && fh)
delete fh;
diff --git a/winsup/cygwin/fhandler/disk_file.cc b/winsup/cygwin/fhandler/disk_file.cc
index c5b7898..f1ac29d 100644
--- a/winsup/cygwin/fhandler/disk_file.cc
+++ b/winsup/cygwin/fhandler/disk_file.cc
@@ -2156,9 +2156,7 @@ fhandler_disk_file::opendir (int fd)
DIR *dir;
DIR *res = NULL;
- if (!pc.isdir ())
- set_errno (ENOTDIR);
- else if ((dir = (DIR *) malloc (sizeof (DIR))) == NULL)
+ if ((dir = (DIR *) malloc (sizeof (DIR))) == NULL)
set_errno (ENOMEM);
else if ((dir->__d_dirname = (char *) malloc ( sizeof (struct __DIR_cache)))
== NULL)
diff --git a/winsup/cygwin/fhandler/virtual.cc b/winsup/cygwin/fhandler/virtual.cc
index 21ff4f3..4a0d294 100644
--- a/winsup/cygwin/fhandler/virtual.cc
+++ b/winsup/cygwin/fhandler/virtual.cc
@@ -45,9 +45,7 @@ fhandler_virtual::opendir (int fd)
DIR *res = NULL;
size_t len;
- if (!virt_ftype_isdir (exists ()))
- set_errno (ENOTDIR);
- else if ((len = strlen (get_name ())) > PATH_MAX - 3)
+ if ((len = strlen (get_name ())) > PATH_MAX - 3)
set_errno (ENAMETOOLONG);
else if ((dir = (DIR *) malloc (sizeof (DIR))) == NULL)
set_errno (ENOMEM);