delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/1997/02/21/10:11:17

From: VGris AT aironet DOT com ("Griswold, Victor")
Subject: Cygnus Win32 B17.1 'unlink': Failure to return error code.
21 Feb 1997 10:11:17 -0800 :
Approved: cygnus DOT gnu-win32 AT cygnus DOT com
Distribution: cygnus
Message-ID: <199702211657.LAA18195.cygnus.gnu-win32@telxon>
Mime-Version: 1.0
Original-To: "'Cygnus:GNU-WIN32'" <gnu-win32 AT cygnus DOT com>
X-Priority: 3
X-Mailer: Internet Mail Service (5.0.1389.3)
Original-Sender: owner-gnu-win32 AT cygnus DOT com

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) vgris AT aironet DOT com
	(MIME) Victor DOT Griswold AT pobox DOT com


-
For help on using this list, send a message to
"gnu-win32-request AT cygnus DOT com" with one line of text: "help".

- Raw text -


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