www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1995/08/18/16:14:50

From: Marc Singer <nbn.nbn.com!sapien!elf>
Subject: mkdir and errno in V2
To: nbn.nbn.com!sapien!sun.soe.clarkson.edu!djgpp (DJGPP List Alias)
Date: Thu, 17 Aug 1995 18:02:11 -0700 (PDT)

It appears that the mkdir call does not clear errno on success.  My
code is creating a new path by starting at the full length trying to
create the directory.  On failure, it removes the last path element
and tries again until it succeeds.  As soon as it does so, it replaces
the path elements one at a time and creates the path one directory at
a time.

Since it fails once, errno is ENOTDIR.  The successful mkdir calls do
not clear this value so errno on exit from my procedure is still
ENOTDIR.  I patch my procedure by clearing errno before each call to
mkdir.

I'm porting this code fragment as part of CVS.  I notice that the
procedure assumes that mkdir returns ENOENT when the directory cannot
be created.  Is the ENOTDIR an incorrect return value?  ENOENT is what
the Linux libc returns.

----------------------------------------------------------------------
          Marc Singer       | "... but when you eat this ... pear, you
       elf AT netcom DOT com       |  are rarely aware of the fact that it was
   or  elf AT sapien DOT com       |  ... plucked from the branch of this ... 
< My comments are my own. > |  pear tree." -- Charlie V.

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019