Return to BSD News archive
Xref: sserve comp.os.386bsd.bugs:1255 comp.os.386bsd.misc:731 comp.os.386bsd.questions:4557 Path: sserve!newshost.anu.edu.au!munnari.oz.au!constellation!osuunx.ucc.okstate.edu!moe.ksu.ksu.edu!vixen.cso.uiuc.edu!howland.reston.ans.net!xlink.net!math.fu-berlin.de!irz401!uriah!not-for-mail From: j@bonnie.tcd-dresden.de (J Wunsch) Newsgroups: comp.os.386bsd.bugs,comp.os.386bsd.misc,comp.os.386bsd.questions Subject: Re: Problem with CPIO? Date: 22 Aug 1993 20:39:50 +0200 Organization: Textil Computer Design GmbH Dresden, Germany Lines: 155 Message-ID: <258ehmINNl9j@bonnie.tcd-dresden.de> References: <251oub$csf@manuel.anu.edu.au> NNTP-Posting-Host: bonnie.tcd-dresden.de In <251oub$csf@manuel.anu.edu.au> mbl900@anusf.anu.edu.au (Mathew BM LIM) writes: >IS there a know bug in cpio an Archive Viper QIC 150 drives? I ALWAYS >get the following problem when using cpio on this drive. >I can write to the drive without any apparent problems using > find / -print | cpio -ovBc > /dev/rst0 >All seems ok, the write finishes, but when I go to read the tape again, I get : > cpio -ivBct < /dev/rst0 [...] > 100755 root 496498 Aug 15 18:07:33 1993 > cpio: Out of phase--get help It's a known bug, with a known fix (by me:-). cpio is from AT&T, and AT&T didn't have symlinks. So the cpio support for symlinks is buggy. The original cpio, as delivered with 386BSD is able to dump symlinks only in binary mode, i.e. without the -c option. If you use compatibility mode (-c), the archive header for the symlink will still be written binary:-((, so the cpio -i cannot restore it. Similiar considerations apply to archives containing unix domain sockets. (Though it's never usefull to restore them, cpio should at least conti- nue instead of aborting.) Here's my patch, in patchkit style: #! /bin/sh # This is a shell archive. Remove anything before this line, then feed it # into a shell via "sh file" or similar. To overwrite existing files, # type "sh file -c". # The tool that generated this appeared in the comp.sources.unix newsgroup; # send mail to comp-sources-unix@uunet.uu.net if you want that tool. # If this archive is complete, you will see the following message at the end: # "End of shell archive." # Contents: patchjw004 patchjw004/PATCH patchjw004/part.1 # Wrapped by j@bonnie on Sun Aug 22 20:37:23 1993 PATH=/bin:/usr/bin:/usr/ucb ; export PATH if test ! -d 'patchjw004' ; then echo shar: Creating directory \"'patchjw004'\" mkdir 'patchjw004' fi if test -f 'patchjw004/PATCH' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'patchjw004/PATCH'\" else echo shar: Extracting \"'patchjw004/PATCH'\" \(888 characters\) sed "s/^X//" >'patchjw004/PATCH' <<'END_OF_FILE' X%%DESC Help information per file for Patches program XPATCH: FIX SYMLINK AND SOCKET NODE BUG IN CPIO XAUTHOR: J"org Wunsch <joerg_wunsch@uriah.sax.de> XDESCRIPTION: XWhen creating ``portable'' archives with cpio (option -oc), symbolic links Xcause cpio to create the wrong (binary) headers, so the cpio -i fails to Xread them (out of phase). The fix corrects this. XAnother problem is that, if there's a socket node in the archive, it's Xgetting displayed correctly with cpio -ivt, but an empty directory will Xbe created when extracting the archive. This is fixed, so a complaint Xfrom mknod(2) is printed (there's no sense creating sockets this way). X%%REQ Patches for files to be correct patch level for this patch XPATCHTO 1 00048 /usr/src/usr.bin/cpio/cpio.c.pl1 X%%FILES New and Patch files for this patch XPATCH 2 part.1 /usr/src/usr.bin/cpio/cpio.c X%%EOF -- This file has not been truncated END_OF_FILE echo shar: NEWLINE appended to \"'patchjw004/PATCH'\" if test 889 -ne `wc -c <'patchjw004/PATCH'`; then echo shar: \"'patchjw004/PATCH'\" unpacked with wrong size! fi # end of 'patchjw004/PATCH' fi if test -f 'patchjw004/part.1' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'patchjw004/part.1'\" else echo shar: Extracting \"'patchjw004/part.1'\" \(2012 characters\) sed "s/^X//" >'patchjw004/part.1' <<'END_OF_FILE' X*** /usr/src/usr.bin/cpio/cpio.c.pl2 Tue Oct 13 12:10:18 1992 X--- /usr/src/usr.bin/cpio/cpio.c Wed Jan 27 05:29:27 1993 X*************** X*** 14,23 **** X * X * PATCHES MAGIC LEVEL PATCH THAT GOT US HERE X * -------------------- ----- ---------------------- X! * CURRENT PATCH LEVEL: 1 00048 X * -------------------- ----- ---------------------- X * X * 16 Aug 92 Guy Harris Symbolic link fix X */ X X /* cpio COMPILE: cc -O cpio.c -s -i -o cpio -lgen -lerr X--- 14,26 ---- X * X * PATCHES MAGIC LEVEL PATCH THAT GOT US HERE X * -------------------- ----- ---------------------- X! * CURRENT PATCH LEVEL: 2 jw004 X * -------------------- ----- ---------------------- X * X * 16 Aug 92 Guy Harris Symbolic link fix X+ * X+ * 27 Jan 93 J"org Wunsch Another symlink fix, X+ * fixed socket handling on cpio -i X */ X X /* cpio COMPILE: cc -O cpio.c -s -i -o cpio -lgen -lerr X*************** X*** 363,369 **** X continue; X } X Symlbuf[symlsz] = '\0'; X! bwrite(&Hdr, HDRSIZE+Hdr.h_namesize); X bwrite(Symlbuf, symlsz); X if(Verbose) X (void) fprintf(stderr, "%s\n", X--- 366,376 ---- X continue; X } X Symlbuf[symlsz] = '\0'; X! /* 27 Jan 93 -- symlinks should get ascii headers, too, if requested so */ X! if( Cflag ) X! bwrite(Chdr,CHARS+Hdr.h_namesize); X! else X! bwrite(&Hdr, HDRSIZE+Hdr.h_namesize); X bwrite(Symlbuf, symlsz); X if(Verbose) X (void) fprintf(stderr, "%s\n", X*************** X*** 748,753 **** X--- 755,766 ---- X A_directory = (ftype == S_IFDIR); X A_special = (ftype == S_IFBLK) X || (ftype == S_IFCHR) X+ /* 27 Jan 93 */ X+ #ifdef S_IFSOCK X+ /* handle socket nodes; though we cannot mknod them (no sense), we thus X+ avoid empty dir's from being created */ X+ || (ftype == S_IFSOCK) X+ #endif X || (ftype == S_IFIFO); X A_symlink = (ftype == S_IFLNK); X return 1; END_OF_FILE echo shar: NEWLINE appended to \"'patchjw004/part.1'\" if test 2013 -ne `wc -c <'patchjw004/part.1'`; then echo shar: \"'patchjw004/part.1'\" unpacked with wrong size! fi # end of 'patchjw004/part.1' fi echo shar: End of shell archive. exit 0 -- in real life: J"org Wunsch | ) o o | primary: joerg_wunsch@tcd-dresden.de above 1.8 MHz: DL 8 DTL | ) | | private: joerg_wunsch@uriah.sax.de | . * ) == | ``An elephant is a mouse with an operating system.''