Subject: Re: Cygnus Win32 B17.1 'unlink': Failure to return error code.
From: [email-masked] (Jim Balter)

22 Feb 1997 04:43:18 -0800
Approved: [email-masked]
Distribution: cygnus
Message-ID: <[email-masked]>
References: <199702211657.LAA18195@telxon>
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
X-Mailer: Mozilla 3.01Gold (WinNT; I)
Original-To: "Griswold, Victor" <[email-masked]>
Original-CC: "'Cygnus":"GNU-WIN32'" <[email-masked]>
Original-Sender: [email-masked]

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
"[email-masked]" with one line of text: "help".