This is the mail archive of the
cygwin@sourceware.cygnus.com
mailing list for the Cygwin project.
Cygnus Win32 B17.1 'unlink': Failure to return error code.
- To: "'Cygnus:GNU-WIN32'" <gnu-win32 at cygnus dot com>
- Subject: Cygnus Win32 B17.1 'unlink': Failure to return error code.
- From: "Griswold, Victor" <VGris at aironet dot com>
- Date: Fri, 21 Feb 1997 12:08:41 -0500
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@aironet.com
(MIME) Victor.Griswold@pobox.com
-
For help on using this list, send a message to
"gnu-win32-request@cygnus.com" with one line of text: "help".