home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / std_unix / volume.27 / text0071.txt < prev    next >
Encoding:
Text File  |  1992-05-20  |  2.3 KB  |  60 lines

  1. Submitted-by: fred@mindcraft.com (Fred Zlotnick)
  2.  
  3. In article <1992Apr3.101844.23646@uunet.uu.net> ast@cs.vu.nl (Andy Tanenbaum) writes:
  4. >Does anyone know what the following program is supposed to do according
  5. >to P1003.1 and why? If the rmdir works, how can things like this be
  6. >implemented in general?
  7. >
  8. >  main()
  9. >  {
  10. >  #include <unistd.h>
  11. >  
  12. >    mkdir ("D", 0777);
  13. >    rmdir("D/.");
  14. >  }
  15.  
  16. First, my personal opinion:  The directory "D" in the current directory
  17. (the one just created by the mkdir() call) should be removed.  The relevant
  18. clause in 1003.1-1990 is 2.3.6, "pathname resolution", which says in part:
  19.  
  20.     Pathname resolution is performed for a process to resolve a
  21.     pathname to a particular file in a file hierarchy...
  22.  
  23.     Each filename in the pathname is located in the directory
  24.     specified by its predecessor.... If the pathname does not
  25.     begin with a slash, the predecessor of the first filename
  26.     of the pathname is taken to be the current working directory
  27.     of the process...
  28.  
  29.     The special filename, dot, refers to the directory specified
  30.     by its predecessor.
  31.  
  32. Collective these imply (IMHO) that the pathname "D/." resolves to "D" in
  33. the current directory.  However, as Bob Lenk once said in this newsgroup,
  34. "It is worth pointing out that official interpretations of an IEEE
  35. standard can only be issued by the IEEE."
  36.  
  37. Having said all that, I tried this on six different systems, at least three
  38. of which claim to be POSIX.1 conforming.  It failed on all of them, with
  39. errno = EINVAL on five of the six.  EINVAL is not given as one of the errno
  40. values for any error specified by POSIX.1.
  41.  
  42. The P1003.3.1 Draft 13 test assertions for clause 2.3.6 specify behavior
  43. for rmdir (among other functions) for pathnames that have a "." as an
  44. initial component or an intermediate component, but not as a final component.
  45. That's no help.  I think it's time for an official interpretation.
  46.  
  47. Incidentally, the 0777 in the mkdir call is not POSIX-portable.  It will,
  48. of course, work on all known systems (known to me, anyway) but the ugly
  49. construct (mode_t)(S_IRWXU | S_IRWXG | S_IRWXO) is its POSIX-portable
  50. replacement.
  51. ----
  52. Fred Zlotnick            |  POSIX is coming! POSIX is coming!
  53. fred@mindcraft.com        |          -- Stephen Walli
  54. ...!{uupsi,ames}!mindcrf!fred    |
  55. #include <std/disclaimer>    |
  56.  
  57.  
  58. Volume-Number: Volume 27, Number 71
  59.  
  60.