cpio(1) under Sun 3.0; or, does System V write filenames backwards?
Greg Earle
earle at smeagol.UUCP
Fri Sep 5 07:18:18 AEST 1986
In article <760 at smeagol.UUCP>, earle at smeagol.UUCP I wrote:
> I have implemented a `fix', based on this source version:
> >#ifndef lint
> >static char sccsid[] = "@(#)cpio.c 1.1 86/02/03 SMI"; /* from S5R2 1.17 */
> >#endif
>
> --------------
> diff -l -cb /usr/src/sun/usr.bin/cpio.c /tmp/cpio.c
> *** /usr/src/sun/usr.bin/cpio.c Mon Feb 3 23:58:42 1986
> --- /tmp/cpio.c Wed Sep 3 20:10:23 1986
> ***************
> *** 602,609
> }
> if(Cflag)
> readhdr(Hdr.h_name, Hdr.h_namesize);
> ! else
> ! bread(Hdr.h_name, Hdr.h_namesize);
> if(EQ(Hdr.h_name, "TRAILER!!!"))
> return 0;
> ftype = Hdr.h_mode & Filetype;
>
> --- 602,611 -----
> }
> if(Cflag)
> readhdr(Hdr.h_name, Hdr.h_namesize);
> ! else {
> ! bread(Name, Hdr.h_namesize);
> ! swab(Name, Hdr.h_name, (Hdr.h_namesize + 1) & ~001);
> ! }
> if(EQ(Hdr.h_name, "TRAILER!!!"))
> return 0;
> ftype = Hdr.h_mode & Filetype;
> --------------
This should probably read:
diff -l -cb /usr/src/sun/usr.bin/cpio.c /tmp/cpio.c
*** /usr/src/sun/usr.bin/cpio.c Mon Feb 3 23:58:42 1986
--- /tmp/cpio.c Wed Sep 3 20:10:23 1986
***************
*** 602,609
}
if(Cflag)
readhdr(Hdr.h_name, Hdr.h_namesize);
! else
! bread(Hdr.h_name, Hdr.h_namesize);
if(EQ(Hdr.h_name, "TRAILER!!!"))
return 0;
ftype = Hdr.h_mode & Filetype;
--- 602,612 -----
}
if(Cflag)
readhdr(Hdr.h_name, Hdr.h_namesize);
! else {
! bread(Name, Hdr.h_namesize);
! if (Swap)
! swap(Hdr.h_name, (Hdr.h_namesize + 1) & ~001);
! }
if(EQ(Hdr.h_name, "TRAILER!!!"))
return 0;
ftype = Hdr.h_mode & Filetype;
----------------
since you don't want to swap unless you are converting from a machine that
needs the data bytes swapped (`-s' option).
Further question:
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 at csvax.caltech.edu
AT&T: +1 818 354 0876
Here I am in the POSTERIOR OLFACTORY LOBULE but I don't see CARL SAGAN
anywhere!!
More information about the Comp.unix.wizards
mailing list