Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!seismo!ut-sally!std-unix From: mwm@cuuxb.att.com (Marc W. Mengel) Newsgroups: comp.std.unix Subject: Re: tar vs. cpio Message-ID: <8360@ut-sally.UUCP> Date: Tue, 23-Jun-87 14:32:18 EDT Article-I.D.: ut-sally.8360 Posted: Tue Jun 23 14:32:18 1987 Date-Received: Tue, 30-Jun-87 06:46:41 EDT References: <8188@ut-sally.UUCP> <8208@ut-sally.UUCP> <8249@ut-sally.UUCP> <8276@ut-sally.UUCP> Sender: std-unix@ut-sally.UUCP Reply-To: moss!cuuxb!mwm@RUTGERS.EDU (Marc W. Mengel) Organization: AT&T-DSD, Software Support, Lisle IL Lines: 41 Approved: jsq@sally.utexas.edu (Moderator, John Quarterman) From: mwm@cuuxb.att.com (Marc W. Mengel) In article <8276@ut-sally.UUCP> ka@hropus.UUCP (Kenneth Almquist) writes: :Several people have suggested that tar's method of handling links is :better than cpio's. After looking at the tar format, I wondered how :tar could possibly handle links correctly. A quick experiment showed :that it doesn't. Try the following: : : > file1 : ln file1 file2 : tar -cf archive file1 file2 : rm file1 file2 : tar -xf archive file2 : :The second tar command will fail because tar will simply try to create :a link from file1 to file2, but since I only requested that file2 be :extracted file1 does not exist. : :I claim that this is a bug in the tar archive format rather than just :the tar program. Consider what tar must do to function correctly. Tar :could remember the location of file1 and lseek to it in this particular :example, but in general the input to tar is not a regular file and thus :may not be seekable. : Kenneth Almquist Actually this is easily solved using the current format, you need merely ensure that when a file has multiple links, that the file's data is put on the archive only the last time that it is referenced. This guarantees that the location of file1 in your example is always further along the archive than file2, and therefore no "rewinding" is ever needed to find the file after discovering that a link to it has been requested. This does require the program to make two traversals over the directory tree ( 1 to determine where the last reference to each file in the subtree occurs, 1 to actually write out the files), but the format itself is *not* inherently broken. -- Marc Mengel ...!{moss|lll-crg|mtune|ihnp4}!cuuxb!mwm Volume-Number: Volume 11, Number 78