cpio -S -b flags

guy at sun.UUCP guy at sun.UUCP
Mon Sep 8 08:47:55 AEST 1986


> > 	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 at sun.com (or guy at sun.arpa)



More information about the Comp.bugs.4bsd.ucb-fixes mailing list