home *** CD-ROM | disk | FTP | other *** search
- Submitted-by: fred@mindcraft.com (Fred Zlotnick)
-
- In article <1992Apr3.101844.23646@uunet.uu.net> ast@cs.vu.nl (Andy Tanenbaum) writes:
- >Does anyone know what the following program is supposed to do according
- >to P1003.1 and why? If the rmdir works, how can things like this be
- >implemented in general?
- >
- > main()
- > {
- > #include <unistd.h>
- >
- > mkdir ("D", 0777);
- > rmdir("D/.");
- > }
-
- First, my personal opinion: The directory "D" in the current directory
- (the one just created by the mkdir() call) should be removed. The relevant
- clause in 1003.1-1990 is 2.3.6, "pathname resolution", which says in part:
-
- Pathname resolution is performed for a process to resolve a
- pathname to a particular file in a file hierarchy...
-
- Each filename in the pathname is located in the directory
- specified by its predecessor.... If the pathname does not
- begin with a slash, the predecessor of the first filename
- of the pathname is taken to be the current working directory
- of the process...
-
- The special filename, dot, refers to the directory specified
- by its predecessor.
-
- Collective these imply (IMHO) that the pathname "D/." resolves to "D" in
- the current directory. However, as Bob Lenk once said in this newsgroup,
- "It is worth pointing out that official interpretations of an IEEE
- standard can only be issued by the IEEE."
-
- Having said all that, I tried this on six different systems, at least three
- of which claim to be POSIX.1 conforming. It failed on all of them, with
- errno = EINVAL on five of the six. EINVAL is not given as one of the errno
- values for any error specified by POSIX.1.
-
- The P1003.3.1 Draft 13 test assertions for clause 2.3.6 specify behavior
- for rmdir (among other functions) for pathnames that have a "." as an
- initial component or an intermediate component, but not as a final component.
- That's no help. I think it's time for an official interpretation.
-
- Incidentally, the 0777 in the mkdir call is not POSIX-portable. It will,
- of course, work on all known systems (known to me, anyway) but the ugly
- construct (mode_t)(S_IRWXU | S_IRWXG | S_IRWXO) is its POSIX-portable
- replacement.
- ----
- Fred Zlotnick | POSIX is coming! POSIX is coming!
- fred@mindcraft.com | -- Stephen Walli
- ...!{uupsi,ames}!mindcrf!fred |
- #include <std/disclaimer> |
-
-
- Volume-Number: Volume 27, Number 71
-
-