WG15 Defect Report Ref: 9945-1-70
Topic: rmdir


This is an approved interpretation of 9945-1:1990.

.

Last update: 1997-05-20


                                                                9945-1-90 #70

 _____________________________________________________________________________

	Topic:			rmdir
	Relevant Sections:	5.5.2.2

Defect Report:
-----------------------

From: jfh@rpp386.cactus.org (John F. Haugh II)
Date: Thu, 14 Jul 94 19:21:17 CDT

I have a question concerning permissible error returns.  5.5.2.2 states
"The directory shall be removed only if it is an empty directory."

Reading the standard it seems ambiguous how a comforming implementation
might behave if the "empty directory" did not contain the implementation's
nominal collection of dot and dot-dot entries.  2.4 seems to suggest that
a directory must contain dot and dot-dot (or at least pretend as though
those entries existed).  It seems that an implementation may then return
ENOTDIR if rmdir() is called with an "empty directory" that was missing
either dot or dot-dot since that directory does not conform to the abstract
notion of that implementations "directory".

In short, here are the questions --

Does 5.5.2.2 permit rmdir() to fail when path refers to an empty directory
and the empty directory is missing either the dot or dot-dot entries?  If
the implementation considers this entry to not be a valid directory, may
it permit the dot and/or dot-dot entries to be removed with unlink() prior
to removal of the directory itself with unlink()?  If the implementation
returns EPERM when unlink() is used to remove directories, and the
implementation returns ENOTDIR (or perhaps EINVAL) when rmdir() is invoked
with such a mal-formed directory, how does one remove the directory using
only the mechanisms specified in 9945-1?



WG15 response for 9945-1:1990 (9945-1-90 #70)
-----------------------------------
rmdir() may fail when an empty directory is considered by the
implementation to be malformed.

The standard clearly states (5.5.1.2) that unlink() may only
remove directories if the process has appropriate privileges and
the implementation supports unlink on directories.

The standard does not speak to the issue of recovering from such
a malformed directory and such an issue is beyond the scope of
POSIX.1.

Rationale:
The standard clearly states that implementations may return error
values for reasons other than those described in the standard if
those conditions can be treated identically to the error conditions
described, or may return additional error values. 

Resolution forwarded for review: Oct 18 1995
Finalised: Nov 21 1995