Currently cygwin has a problem with errno code set by opendir()
function. It always sets errno to ENOENT.
After applying the path opendir() sets errno to 'ENAMETOOLONG' when path
or a path component is too long,
'ELOOP' when a loop of symbolic links exits in the path.
Best regards,
Oleg
2014-02-18 Oleg Kravtsov <oleg.kravt...@oktetlabs.ru>
* dir.cc (opendir): Set errno code depending on the type of an error
instead of always setting it to ENOENT.
Index: cygwin/dir.cc
===================================================================
RCS file: /cvs/src/src/winsup/cygwin/dir.cc,v
retrieving revision 1.136
diff -u -p -r1.136 dir.cc
--- cygwin/dir.cc 31 Jan 2014 19:27:26 -0000 1.136
+++ cygwin/dir.cc 3 Mar 2014 18:33:55 -0000
@@ -57,7 +57,16 @@ opendir (const char *name)
fh = build_fh_name (name, PC_SYM_FOLLOW);
if (!fh)
- res = NULL;
+ {
+ res = NULL;
+ goto done;
+ }
+
+ if (fh->error ())
+ {
+ debug_printf ("got %d error from build_fh_name", fh->error ());
+ set_errno (fh->error ());
+ }
else if (fh->exists ())
res = fh->opendir (-1);
else
@@ -71,6 +80,8 @@ opendir (const char *name)
/* Applications calling flock(2) on dirfd(fd) need this... */
if (res && !fh->nohandle ())
fh->set_unique_id ();
+
+done:
return res;
}