This is the mail archive of the
mailing list for the Cygwin project.
Re: cygwin's unlink
- To: cygwin at sourceware dot cygnus dot com
- Subject: Re: cygwin's unlink
- From: "J. J. Farrell" <jjf at bcs dot org dot uk>
- Date: Tue, 26 Oct 1999 16:47:59 -0700 (PDT)
> From: Chris Faylor <email@example.com>
> On Tue, Oct 26, 1999 at 02:01:10PM -0600, Steve Jorgensen wrote:
> >Anyway, in the case where the file is truely a directory, under all
> >unix systems we've tried, unlink returns and error, and we proceed with
> >the recursive directory removal, but under cygwin it returns success
> >(even though nothing is removed), and our code returns success without
> >removing the directory. Is this a limitation in the underlying windows
> >unlink, or a bug in cygwin?
> When I try this I get a "Permission denied" error. It should be a
> "Is a directory error" though. I've changed the sources here so
> this should be fixed in the next snapshot.
Before you fix that (he says, probably too late) ...
This one's a bit complex. First off: under POSIX.1 it is
implementation-defined whether or not unlink() works on
directories. This means that Steve's algorithm is wrong,
since what he saw as a bug in cygwin's unlink() is perfectly
valid behaviour for a POSIX.1 system. The fact that POSIX
allows it suggests that at least one UNIX implementation
behaved that way when POSIX.1 was drawn up, and future ones
are allowed to if they wish (though rmdir() is the preferred
Secondly: in the case where the implementation does not
support unlink() on directories, the required error value
is EPERM which would result in a "Permission denied" error.
From the XPG3 documentation (which is aligned with POSIX.1):
[EPERM] The file named by path is a directory, and either
the calling process does not have appropriate
privileges, or the implementation prohibits using
unlink() on directories.
I can't comment on why Steve and Chris saw different results,
but both were equally valid (assuming in Steve's case that the
directory entry would have disappeared once everything below
it had been unlinked). The implementation may support unlink()
of directories, and if it doesn't it should give EPERM.
Want to unsubscribe from this list?
Send a message to firstname.lastname@example.org