Mail Archives: djgpp-workers/1998/03/20/08:49:45
> > 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 -