[net.bugs.4bsd] cpio -S -b flags

andy@icom.UUCP (Andrew H. Marrinson) (09/06/86)

> 	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 (swap halfwords only when 
> 1/2 word != byte?  Swap both when in `pass' mode?).  Any explanation?
> -- 
> 	Greg Earle		UUCP: sdcrdcf!smeagol!earle; attmail!earle
> 	JPL			ARPA: elroy!smeagol!earle@csvax.caltech.edu

Assuming these are the same as in sysV, I believe halfwords refers
(ambiguously) to 16-bit quantites.  The -b option does both byte-swapping
and halfword (word) swapping.  To summarize then:

byte:		0	1	2	3	4	5	6	7
contents:	A	B	C	D	E	F	G	H
-s:		B	A	D	C	F	E	H	G
-S:		C	D	A	B	G	H	E	F
-b:		D	C	B	A	H	G	F	E

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.

I wonder if vn adds the .signature?  Just to be safe here it is, possibly
twice:

	andy@icom.UUCP
	Or for those of		Andrew H. Marrinson
	you who wish to		ICOM Systems, Inc.
	play it the hard	Arlington Heights, IL 60005
	way: ihnp4!icom!andy

-- 

	andy@icom.UUCP
	Or for those of		Andrew H. Marrinson
	you who wish to		ICOM Systems, Inc.
	play it the hard	Arlington Heights, IL 60005
	way: ihnp4!icom!andy

guy@sun.UUCP (09/08/86)

> > 	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)