bug-tar
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Bug-tar] BUG: incorrectly creates hard links in archive


From: Toby Peterson
Subject: [Bug-tar] BUG: incorrectly creates hard links in archive
Date: Fri, 9 Jul 2004 17:43:18 -0700

address@hidden ~]$ uname -a
FreeBSD ensemble.isc.org 4.10-RELEASE FreeBSD 4.10-RELEASE #0: Tue May 25 22:47:12 GMT 2004 address@hidden:/usr/obj/usr/src/sys/GENERIC i386
address@hidden ~]$ tar --version
tar (GNU tar) 1.13.25
Copyright (C) 2001 Free Software Foundation, Inc.
This program comes with NO WARRANTY, to the extent permitted by law.
You may redistribute it under the terms of the GNU General Public License;
see the file named COPYING for details.
Written by John Gilmore and Jay Fenlason.
address@hidden ~]$ cat tarbug.sh
#!/bin/sh

rm -rf tartest
rm -f tartest.tar

mkdir tartest
mkdir tartest/test1
mkdir tartest/test2

echo TEST > tartest/test1/test.txt
ln tartest/test1/test.txt tartest/test2/test.txt

tar cf tartest.tar tartest/test1/test.txt tartest/test1/test.txt

rm -r tartest
tar tvf tartest.tar
tar xf tartest.tar
address@hidden ~]$ sh tarbug.sh
-rw-r--r-- toby/toby         5 Jul  9 17:30 2004 tartest/test1/test.txt
-rw-r--r-- toby/toby 0 Jul 9 17:30 2004 tartest/test1/test.txt link to tartest/test1/test.txt tar: tartest/test1/test.txt: Cannot hard link to `tartest/test1/test.txt': No such file or directory
tar: Error exit delayed from previous errors


This also occurs with tar 1.14. I've been able to reproduce the problem in FreeBSD 4.10, FreeBSD 5.2, Mac OS X 10.3, and Mac OS X 10.4. My main complaint is that it does not untar the test.txt file at all.

Anyway, what I'm guessing is going on (I haven't examined the source too closely) is that tar is trying to store only one copy of any hardlinked file. What seems to be happening here is that tar sees that test1/test.txt has a link counter > 1 (because of test2/test.txt). So, it stores one copy. The second time the file appears on the command line, tar recognizes that it already has that file stored, and stores the second copy as a hardlink. Unfortunately, tar doesn't seem be checking whether it has the same *name* as another file in the archive.

I'm not sure what the best solution is (create a hard link in the archive vs. store the same file twice vs. ignore it completely), but the result of untarring should *not* be that you end up with no files. Let me know; I'd like to be able to resolve this problem immediately.

Thanks!

Toby Peterson
Core OS
Apple Computer, Inc.





reply via email to

[Prev in Thread] Current Thread [Next in Thread]