This is the mail archive of the
cygwin-patches
mailing list for the Cygwin project.
[PATCH] Fix errno codes set by opendir() in case of problems with the path argument
- From: Oleg Kravtsov <Oleg dot Kravtsov at oktetlabs dot ru>
- To: cygwin-patches <cygwin-patches at cygwin dot com>
- Date: Mon, 03 Mar 2014 22:34:59 +0400
- Subject: [PATCH] Fix errno codes set by opendir() in case of problems with the path argument
- Authentication-results: sourceware.org; auth=none
- Authentication-results: shelob.oktetlabs.ru/69DA67F4DF; dkim=none (no signature) header.i=unknown; dkim-adsp=none
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.Kravtsov@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;
}