cvs.gedasymbols.org/archives/browse.cgi   search  
Mail Archives: djgpp-workers/1998/03/20/08:49:45

From: Martin Stromberg <Martin DOT Stromberg AT lu DOT erisoft DOT se>
Message-Id: <199803201348.OAA23352@propus.lu.erisoft.se>
Subject: Re: mkdir and errno
To: dj AT delorie DOT com (DJ Delorie)
Date: Fri, 20 Mar 1998 14:48:30 +0100 (MET)
Cc: djgpp-workers AT delorie DOT com (DJGPP-WORKERS)
In-Reply-To: <199803200131.UAA10178@delorie.com> from "DJ Delorie" at Mar 19, 98 08:31:43 pm
MIME-Version: 1.0

> > I didn't get any feedback on whether it is bug or feature that the call
> > to access() clobbers errno. So is it a bug or feature?
> 
> Any library function may change errno at any time for any reason.
> This is not a bug or a feature, but a rule.

Of course! But I think you misunderstood me. This is an excerp from libc's 
mkdir.c:

  if (r.x.flags & 1)
  {
    errno = __doserr_to_errno(r.x.ax);				(1)
    if (errno == EACCES)
    {
      /* see if the directory existed, in which case
	 we should return EEXIST - DJ */
      if (access(dirname, D_OK) == 0)				(2)
	errno = EEXIST;
    }
    return -1;
  }

Suppose errno get set to EACCES at (1). access() is called at (2), 
which perhaps modifies errno, and returns zero or non-zero. If
zero is returned all is fine. But if non-zero is returned, what is
returned from mkdir() is access()'s settting of errno, not EACCES.

Again this might be a feature, but it sure looks like a bug to me.


Right,

							MartinS
 

- Raw text -


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