Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!seismo!uwvax!husc6!panda!genrad!decvax!decwrl!sun!guy From: guy@sun.UUCP Newsgroups: net.bugs.4bsd,net.unix-wizards Subject: Re: cpio -S -b flags Message-ID: <6991@sun.uucp> Date: Sun, 7-Sep-86 18:47:55 EDT Article-I.D.: sun.6991 Posted: Sun Sep 7 18:47:55 1986 Date-Received: Mon, 8-Sep-86 20:56:39 EDT References: <761@smeagol.UUCP> <685@icom.UUCP> Organization: Sun Microsystems, Inc. Lines: 44 Xref: mnetor net.bugs.4bsd:923 net.unix-wizards:7820 > > There are two undocumented options, `-S' and `-b', that are supposed > > to be for "swap half words" and "swap both words". I'm not sure under > > what circumstance these switches would be used... The only circumstances in which *any* of the swapping options to the System V "cpio" are used are those where you're reading in a file written either 1) on a machine with the same byte order as yours or 2) written with the "-c" flag, and you want to swap *every* pair of bytes, words, or bytes and words in the data file - i.e., the file is a binary data file consisting solely of "short"s or "long"s with the wrong byte or word. > Assuming these are the same as in sysV, Since the Sun 3.0 "cpio" is the same as in System V, so are the "-S" and "-b" options. The options were omitted from the documentation (perhaps because they are next to useless); fixed in 3.2. > I seem to recall that when DEC introduced the VAX, longwords (32-bit) were > stored "word-swapped" from the order implied by the multiply/divide > instructions on the PDP-11, or at least from the order used in the PDP-11 C > compiler, thus requiring the -S flag. The multiply/divide instructions on the PDP-11 don't imply any word order, as they don't work on 32-bit quantities in memory. The PDP-11 floating point coprocessors *did* imply an order for words within a longword that was swapped from the order that the VAX used. The PDP-11 FORTRAN compiler used an order that was swapped from the order used by the PDP-11 floating point coprocessors, and the PDP-11 FORTRAN order was what was used by the VAX. The PDP-11 UNIX C compiler used the floating point coprocessors' word order. What is *really* amusing is that some data structure in DEC's Files-11 file system, as used by RSX and VMS, also used the floating point coprocessors' byte order, so that VAX/VMS has to swap words when dealing with this data structure! The "-S" flag is NOT, however, required by "cpio"; the only binary data stored in the file headers on a "cpio" tape are "short"s, and the byte order is the same on the PDP-11 as on the VAX. The data might require this swapping, but that would only be the case if, as was pointed out, *every single datum in the file* was a "long"! -- Guy Harris {ihnp4, decvax, seismo, decwrl, ...}!sun!guy guy@sun.com (or guy@sun.arpa)