This is the mail archive of the cygwin@sourceware.cygnus.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]

Re: Cygnus Win32 B17.1 'unlink': Failure to return error code.


Griswold, Victor wrote:
> 
> Gentlemen:
> 
>         The 'unlink' call in b17.1, when applied to a directory, neither
> performs an implicit 'rmdir' (which it is theoretically allowed to do if
> the calling user is "root" -- perhaps that means "Administrator" under
> WinNT?), nor returns an error code nor sets 'errno' in such a situation.
> Some code (the generic port of CVS to WinNT, in particular), relies on
> the error return of 'unlink' as an implicit 'isdir' call when told to
> unlink a generic filespec.

> I understand that such code is poor practice, and I have corrected the
> situation in my version of the CVS source, but such practice does exist
> and will be encountered when porting software to GNU-Win32.

unlink by root in those unix systems that allow it does *not* do an
rmdir; it removes the link to the directory from its parent, but does
not remove the . and .. links to the directory, thus leaving your
filesystem in an improper state.  Using this as an isdir is a lot worse
than just bad.

> In any case, an error should be returned if the call to 'unlink' did
> nothing to a directory.  Under WinNT, such a call on "native" compilers
> generally returns EACCES; under Win95 it returns ENOENT.  I would agree
> that this difference in behavior should be removed and standardized on
> whatever error code various flavors of Unix would return.

The correct errno is defined by POSIX as EPERM.
But this is only one of dozens of incorrect errnos produced by cygwin.
POSIX certification is a long way off.

> Thank you for an excellent tool which shows much promise to keep
> improving.

Not to mention opportunity.

--
<J Q B>
-
For help on using this list, send a message to
"gnu-win32-request@cygnus.com" with one line of text: "help".


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