lkml.org 
[lkml]   [1997]   [Aug]   [5]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: rmdir(".") works, and causes havoc
torvalds@transmeta.com (Linus Torvalds)  wrote on 04.08.97 in <Pine.LNX.3.95.970804085343.3690H-100000@penguin.transmeta.com>:
> For the new dcache, 'rmdir(".")' is trivially easy to do, and involves no
> special cases at all. I personally think that is a very cool thing, but at
> the same time I'm afraid we have to add the silly limits imposed to us by
> standards.

Are you _sure_ POSIX needs this?

I've currently only access to The Single UNIX Specification, Version 2
(aka "Unix98"), and it indicates that all these cases are perfectly ok:

The Single UNIX « Specification, Version 2
Copyright + 1997 The Open Group


NAME

rmdir - remove a directory

SYNOPSIS

#include <unistd.h>

int rmdir(const char *path);


DESCRIPTION

The rmdir() function removes a directory whose name is given by path.
The directory is removed only if it is an empty directory.

If the directory is the root directory or the current working
directory of any process, it is unspecified whether the function succeeds,
or whether it fails and sets errno to [EBUSY].

If path names a symbolic link, then rmdir() fails and sets errno to
[ENOTDIR].

If the directory's link count becomes 0 and no process has the
directory open, the space occupied by the directory will be freed and the
directory will no longer be accessible. If one or more processes have the
directory open when the last link is removed, the dot and dot-dot entries,
if present, are removed before rmdir() returns and no new entries may be
created in the directory, but the directory is not removed until all
references to the directory are closed.

Upon successful completion, the rmdir() function marks for update the
st_ctime and st_mtime fields of the parent directory.

RETURN VALUE

Upon successful completion, the function rmdir() returns 0. Otherwise,
-1 is returned, and errno is set to indicate the error. If -1 is returned,
the named directory is not changed.

ERRORS

The rmdir() function will fail if:

[EACCES]
Search permission is denied on a component of the path prefix, or
write permission is denied on the parent directory of the directory to be
removed.

[EBUSY]
The directory to be removed is currently in use by the system or
another process and the implementation considers this to be an error.

[EEXIST] or [ENOTEMPTY]

The path argument names a directory that is not an empty directory.

[EIO]
A physical I/O error has occurred.

[ELOOP]
Too many symbolic links were encountered in resolving path.

[ENAMETOOLONG]

The length of the path argument exceeds {PATH_MAX} or a pathname
component is longer than {NAME_MAX}.
[ENOENT]
A component of path does not name an existing file, or the path
argument names a non-existent directory or points to an empty string.

[ENOTDIR]
A component of the path is not a directory.

[EPERM] or [EACCES]

The S_ISVTX flag is set on the parent directory of the directory to
be removed and the caller is not the owner of the directory to be removed,
nor is the caller the owner of the parent directory, nor does the caller
have the appropriate privileges.

[EROFS]
The directory entry to be removed resides on a read-only file
system.

The rmdir() function may fail if:

[ENAMETOOLONG]

Pathname resolution of a symbolic link produced an intermediate
result whose length exceeds {PATH_MAX}.
EXAMPLES

None.

APPLICATION USAGE

None.

FUTURE DIRECTIONS

None.

SEE ALSO

mkdir(), remove(), unlink(), <unistd.h>.


UNIX « is a registered Trademark of The Open
Group.
Copyright + 1997 The Open Group
[ Main Index | XSH | XCU | XBD | XCURSES | XNS ]

MfG Kai

\
 
 \ /
  Last update: 2005-03-22 13:40    [from the cache]
©2003-2014 Jasper Spaans. Advertise on this site