Messages in this thread | | | Date | Wed, 20 Mar 1996 20:53:53 -0500 | From | "Theodore Ts'o" <> | Subject | Re: rmdir system call |
| |
Date: Thu, 21 Mar 1996 01:08:13 +0100 From: Andries.Brouwer@cwi.nl
: I have some code which is calling rmdir and passing the directory name : is with a trailing '/'.
: eg rmdir("/tmp/nick/")
: The system call is returning with 'ENOENT'.
: The same code works ok on other operating systems. (HPUX, IRIX, AIX ...)
: Like my last posting, which is right?
: If Linux is wrong, what can I do about it?
Linux is wrong.
The last question is easy: remove this trailing slash. Which is right is more tricky, since POSIX.1 contradicts itself. The classical interpretation is that an empty pathname refers to the current directory, so that "/dir/" is equivalent to "/dir/.". But POSIX explicitly forbids this use of empty names. Nevertheless, the definition of `pathname' says: If the pathname refers to a directory, it may also have one or more trailing slashes. Probably Linux should accept such filenames, and probably you should not use them.
This is the POSIX.1 definition of pathname (2.2.2.57):
A pathname consists of, at most, {PATH_MAX} bytes, including the terminating null character. It has an optional beginning slash, followed by zero or more filenames separated by slashes. If the pathname refers to a directory, it may also have one or more trailing slashes. Multiple successive slashes are considered to be the same as one slash. A pathname that begins with two successive slashes may be interpreted in an implementation-defined manner, although more than two leading slashes shall be treated as a single slash. The interpretation of the pathname is described in 2.3.6
Section 2.3.6 is rather long, so I won't quote it here. It is in this section that statement "A null pathname is invalid". However, it's clear that this is referring to the entire pathname, and not a pathname component. In any case, in the POSIX.1 definition, multiple separator characters '/' do not create null pathname components which are the same as '.' (although many traditional Unix systems implement things this way). Instead, POSIX.1 states that "multiple slashes are to be considered the same as one slash."
So I don't think POSIX.1 is self-contradictory. It is true that Linux isn't strictly POSIX.1 compliant right now, because of we don't support the trailing slash requirements. However, if the Linux-FT distribution has achieved official POSIX.1 certification, then presumably they've fixed this in their 1.2 kernel. Perhaps someone from the Linux-FT team can get this (and any other changes which they had to make) integrated into the 1.3 development kernels?
- Ted
| |