This is the mail archive of the
mailing list for the Cygwin project.
Re: [PATCH] Fix errno codes set by opendir() in case of problems with the path argument
- From: Christopher Faylor <cgf-use-the-mailinglist-please at cygwin dot com>
- To: cygwin-patches at cygwin dot com
- Date: Mon, 3 Mar 2014 14:32:01 -0500
- Subject: Re: [PATCH] Fix errno codes set by opendir() in case of problems with the path argument
- Authentication-results: sourceware.org; auth=none
- References: <5314CB53 dot 4070300 at oktetlabs dot ru>
- Reply-to: cygwin-patches at cygwin dot com
On Mon, Mar 03, 2014 at 10:34:59PM +0400, Oleg Kravtsov wrote:
>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.
>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.
Thanks for the patch but I don't see any reason for a goto here. Also
you seem to be skipping over a free which could result in a memory leak.
I think the below should do the same thing without those limitations.
Does it work for you?
RCS file: /cvs/src/src/winsup/cygwin/dir.cc,v
retrieving revision 1.136
diff -d -u -p -r1.136 dir.cc
--- dir.cc 31 Jan 2014 19:27:26 -0000 1.136
+++ dir.cc 3 Mar 2014 19:31:30 -0000
@@ -58,6 +58,11 @@ opendir (const char *name)
fh = build_fh_name (name, PC_SYM_FOLLOW);
res = NULL;
+ else if (fh->error ())
+ set_errno (fh->error ());
+ res = NULL;
else if (fh->exists ())
res = fh->opendir (-1);