This is the mail archive of the cygwin-patches@cygwin.com mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Patch]: setting errno to ENOTDIR rather than ENOENT


This patch should take care of the error reported by 
Eric Blake on the list, at least for disk files.

It also removes code under the condition
(opt & PC_SYM_IGNORE) && pcheck_case == PCHECK_RELAXED
which is never true, AFAICS.

It also gets rid of an obsolete function.

While testing, the assert (!i); on line 259 of pinfo.cc
kicks in. That's a feature because when flag & PID_EXECED
the code just loops, keeping the same h0 and mapname!
Am I the only one to see that?

Pierre


2005-01-25  Pierre Humblet <pierre.humblet@ieee.org>

	* path.cc (path_conv::check): Return ENOTDIR rather than ENOENT
	when a component is not a directory. Remove unreachable code.
	(digits): Delete.

Index: path.cc
===================================================================
RCS file: /cvs/src/src/winsup/cygwin/path.cc,v
retrieving revision 1.338
diff -u -p -r1.338 path.cc
--- path.cc     18 Jan 2005 13:00:18 -0000      1.338
+++ path.cc     25 Jan 2005 20:08:53 -0000
@@ -655,12 +655,6 @@ path_conv::check (const char *src, unsig
              full_path[3] = '\0';
            }
 
-         if ((opt & PC_SYM_IGNORE) && pcheck_case == PCHECK_RELAXED)
-           {
-             fileattr = GetFileAttributes (this->path);
-             goto out;
-           }
-
          symlen = sym.check (full_path, suff, opt | fs.has_ea ());
 
          if (sym.minor || sym.major)
@@ -680,7 +674,7 @@ path_conv::check (const char *src, unsig
              if (pcheck_case == PCHECK_STRICT)
                {
                  case_clash = true;
-                 error = ENOENT;
+                 error = component?ENOTDIR:ENOENT;
                  goto out;
                }
              /* If pcheck_case==PCHECK_ADJUST the case_clash is remembered
@@ -706,6 +700,11 @@ path_conv::check (const char *src, unsig
                  error = sym.error;
                  if (component == 0)
                    add_ext_from_sym (sym);
+                  else if (!(sym.fileattr & FILE_ATTRIBUTE_DIRECTORY))
+                    {
+                      error = ENOTDIR;
+                     goto out;
+                    }  
                  if (pcheck_case == PCHECK_RELAXED)
                    goto out;   // file found
                  /* Avoid further symlink evaluation. Only case checks are
@@ -939,15 +938,6 @@ path_conv::~path_conv ()
     }
 }
 
-static __inline int
-digits (const char *name)
-{
-  char *p;
-  int n = strtol (name, &p, 10);
-
-  return p > name && !*p ? n : -1;
-}
-
 /* Return true if src_path is a valid, internally supported device name.
    In that case, win32_path gets the corresponding NT device name and
    dev is appropriately filled with device information. */


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]