Path: utzoo!mnetor!uunet!husc6!psuvax1!vu-vlsi!dsinc!syd From: syd@dsinc.UUCP (Syd Weinstein) Newsgroups: comp.unix.questions Subject: Re: tar or cpio? Message-ID: <325@dsinc.UUCP> Date: 18 Feb 88 00:42:01 GMT References: <246@mancol.UUCP> <1629@cuuxb.ATT.COM> <2506@mibte.UUCP> <41499@sun.uucp> <2071@bsu-cs.UUCP> <699@mcdsun.UUCP> Reply-To: syd@dsinc.UUCP (Syd Weinstein) Organization: Datacomp Systems, Inc., Huntingdon Valley, PA 19006 Lines: 40 In article <699@mcdsun.UUCP> fnf@mcdsun.UUCP (Fred Fish) writes: :In article <2071@bsu-cs.UUCP> dhesi@bsu-cs.UUCP (Rahul Dhesi) writes: :>An even more correct thing to do is for cpio to always write archive headers :>in a canonical format that is not dependent on the byte-ordering of the :>hardware. E.g., all header data written least significant byte first. :> [ stuff deleted for brevity ] : :Unfortunately this will not work for one not-so-obvious reason, and that :is because there are systems that when reading the exact same media, :will return bytes ordered differently. [again deleted] :Several years ago after I got my first Unix system, I was so disgusted :with tar and cpio that I wrote my own backup/archiver type program (bru) :which has always handled this problem completely transparently to the :user by writing ASCII formatted archives and doing whatever byte swapping :was necessary. The basic algorithm is: : : 1. Examine block's magic number, if correct, no swapping. : 2. Swap all bytes and try again. If correct, note byte swap : needed for all blocks. : 3. Swap all shorts and try again. If correct, note short swap : also needed for all blocks. : 4. Swap all bytes and try again. If correct, reset byte swapping : flag (swap shorts only). : :I have never encountered a machine where one of these four combinations of :byte/short swapping didn't result in a readable archive, but I've seen :each combination needed at least once for at least one machine. I had to write a backup system also a while back, and I can add another step to your algorithm that will force it to 8 steps. There are some machines out there that invert the bits on tapes. IE, you need to NOT(~) it to make it work. Adding this makes one repeat all four steps again for bit inverted tapes. Boy was that a pain to figure out. -- ===================================================================== Sydney S. Weinstein, CDP, CCP Datacomp Systems, Inc. Voice: (215) 947-9900 {allegra,bellcore,bpa,vu-vlsi}!dsinc!syd FAX: (215) 938-0235