home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / std_unix / volume.11 / text0008.txt < prev    next >
Encoding:
Internet Message Format  |  1987-07-18  |  5.7 KB

  1. From: guy@sun.com (Guy Harris)
  2.  
  3. > As the moderator of this newsgroup, I solicit comments about what should
  4. > be done with section 10.
  5.  
  6. One thing that should not be done, under any circumstances, is to
  7. replace "tar" with "cpio" - *especially* if it includes the old
  8. non-"-c" form.  The non-portable form is completely useless for
  9. moving data between systems with different byte orders unless you
  10. have a clever "cpio" that figures out that the byte order is
  11. backwards and undoes the damage.
  12.  
  13. I discovered this when trying to read a "cpio" tape made on a VAX in
  14. the old format; no combination of "cpio" byte-swapping options and
  15. "dd conv=swab" would help.  I finally ended up fixing our "cpio" to
  16. do the aforementioned look-at-the-header-and-undo-the-damage stuff.
  17.  
  18. The X/OPEN standard uses "cpio".  The rationale given exhibits a
  19. distressing degree of incompetence:
  20.  
  21.     If an exchange mdeium is to be read on a target machine that
  22.     is architecturally different from the source machine,
  23.     problems may arise concerning the ordering of bytes within a
  24.     word and words within a long word (see the portability guides
  25.     in Part III).  These can easily be handled when using "cpio"
  26.     as an exchange utility, while with "tar" it may be a little
  27.     more difficult.
  28.  
  29. Now, I will first note here that the *only* time I had a problem
  30. moving "tar" tapes between machines was when I had to move things to
  31. a Plexus.  The problem was *not* that the machines had different byte
  32. orders; the problem was that the Plexus had a typical brain-damaged
  33. Multibus tape controller that swapped bytes when it transferred data
  34. to and from memory.
  35.  
  36. "cpio" would not have made this any easier; the System III
  37. byte-swapping option did not swap the bytes on *all* blocks read, but
  38. just swapped the bytes on data blocks and in file names.  The intent
  39. here was clearly that you would read a tape written on a machine with
  40. a different byte order by doing something like
  41.  
  42.     dd if=/dev/rmt0 conv=swab | cpio -ids
  43.  
  44. "dd" would swap everything; "cpio -s" would un-swap everything but
  45. the binary data in the header.  (We pause to note that merely
  46. swapping the binary data in the header would be much more efficient,
  47. especially given that "dd" is somewhat of a pig.)  This works, but is
  48. less than wonderful.  (And it doesn't solve the problem with the
  49. Plexus; to solve that you just stick the "dd" in front of "cpio" and
  50. don't bother with "-s" at all.)
  51.  
  52. The System V "cpio" byte-swapping and word-swapping options work
  53. *only* on data blocks; they have no effect whatsoever on binary data
  54. in the header or on file names.  This means that the trick that
  55. worked with the System III "cpio" wouldn't work at all - and the
  56. problem with the Plexus still isn't fixed, if that was the intent.
  57. The S5 options are useless for old-style non-"-c" tapes.  They are of
  58. some use with "-c" tapes - but only if all the files on the tape
  59. consist solely of "short"s or "long"s, since the data in the data
  60. blocks are all byte-swapped or word-swapped in the same fashion.
  61. Most files I tend to put on or extract from "cpio" tapes are text
  62. files, which obviously need no swapping.
  63.  
  64. In short, the arguments offered by X/OPEN in favor of "cpio" are
  65. completely bogus.
  66.  
  67. Now for the arguments against "cpio" format:
  68.  
  69.     1) It is somewhat more UNIX-specific, in that the "mode"
  70.        field of the "stat" structure is written out numerically.
  71.        POSIX does not specify required numeric values for this
  72.        field.  "tar" indicates the file type with a standard
  73.        symbolic code, so you can read "tar" tapes even if the
  74.        machine on which the tape was written and the machine on
  75.        which it is being read do not have the same values for
  76.        this field.
  77.  
  78.     2) It does not handle hard links particularly elegantly.
  79.        "cpio" knows nothing of files with multiple hard links
  80.        when it writes a tape; if it is told to write "foo" and
  81.        "bar" to the tape, and they are both hard links to the
  82.        same file, it writes two copies of this file to the tape.
  83.        The hard links are established when the tape is read.
  84.        If the files appear on the tape in the order "foo" and
  85.        then "bar", "foo" will be read in first.  Once "bar" has
  86.        been read in, "cpio" will check to see if it has already
  87.        read in a file with the same dev/inumber value.  If so, it
  88.        will delete "bar" and make a hard link to "foo" called
  89.        "bar".
  90.  
  91.     3) It is less common.  Almost all UNIX systems that support
  92.        "cpio" also support "tar"; many UNIX systems that support
  93.        "tar" do not support "cpio".
  94.  
  95.     4) POSIX has already chosen "tar" format; why should it
  96.        change horses in midstream, especially given that the new
  97.        horse is lame and, despite the claims made by the person
  98.        selling the horse, is not capable of pulling any heavier
  99.        loads than the existing one?
  100.  
  101. Anyway, I'll have to dig up the proposal made to POSIX that "cpio"
  102. supplement or replace "tar" and cast a very strong "no" vote citing
  103. the above.
  104.  
  105. Now, as for the proposal for handing the whole thing off to P1003.2 -
  106. I have some inclination to support this.  It could, in some ways, be
  107. considered neither part of the scope of P1003.1 nor of P1003.2, but
  108. to be a separate standardization topic entirely.  However, if I had
  109. to choose which of the two items - C-language binding to OS
  110. system call and library functions, or command-language functions -
  111. the data interchange standard belonged to, I'd vote in favor of the
  112. latter.  There is no library of functions for reading or writing
  113. "tar" tapes, but there is a command (namely, "tar") for reading and
  114. writing them, so I think it belongs in that category - especially
  115. given that Section 10 currently says "A conforming system shall
  116. implement a user utility..." which really sounds a lot more like
  117. a P1003.2 requirement than a P1003.1 requirement.
  118.  
  119. Volume-Number: Volume 11, Number 9
  120.  
  121.