Subject: Cygnus Win32 B17.1 'unlink': Failure to return error code.
From: [email-masked] ("Griswold, Victor")

21 Feb 1997 10:11:17 -0800
Approved: [email-masked]
Distribution: cygnus
Message-ID: <199702211657.LAA18195.cygnus.gnu-win32@telxon>
Mime-Version: 1.0
Content-Type: text/plain
Original-To: "'Cygnus:GNU-WIN32'" <[email-masked]>
X-Priority: 3
X-Mailer: Internet Mail Service (5.0.1389.3)
Original-Sender: [email-masked]

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.

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.

Test code is as follows:

====start unlink_bug.c=============================================
#include <stdio.h>
#include <errno.h>

int main(int argc, char* argv[]) {
	int status;

	if (argc != 2) {
		fprintf(stderr, "usage:  %s <dir>\n", argv[0]);
		return 1;
	}

	status = unlink(argv[1]);

	printf("unlink(%s) == %d   errno == %d\n",argv[1], status,
errno);

	return status;
}
====end unlink_bug.c=============================================

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

Victor J. Griswold, D.Sc.
Aironet Wireless Communications, Inc.
voice:	330-664-7987
fax:	330-664-7301
email:	(MS-Mail) [email-masked]
	(MIME) [email-masked]

-
For help on using this list, send a message to
"[email-masked]" with one line of text: "help".