[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Bug-tar] tar fails to preserve hard links with --remove-files
From: |
Carl Worth |
Subject: |
[Bug-tar] tar fails to preserve hard links with --remove-files |
Date: |
Thu, 30 Jul 2009 04:57:04 -0700 |
A user of Debian noticed that tar (1.22) does not always preserve hard
links when creating an archive with the --remove-files option. Ted Ts'o
provided the following analysis:
On Sun, 13 Apr 2003 15:45:27 -0400, Theodore Ts'o <address@hidden> wrote:
> I'm pretty sure, by the way, that the problem is that tar is keying
> off of the st_nlink to decide whether or not to do hard link
> processing as an optimization. When --remove-files is present, then
> st_nlink of the hard-linked inode is dropping, and when st_nlink is
> one, tar can't tell that it was previously a hard-linked file. The
> fix would require that tar check every single file's inode number
> against previously written files to see if it was a hard linked file
> (instead of just checking files where st_nlink > 1), in the case when
> --remove-file option is in use.
I've attached two patches to fix this bug. The first implements Ted's
suggestion, (using the hard links hash table for all files when the
--remove-files option is in effect, regardless of the value of
st_nlink). The second patch adds a test case for the bug, (failing
before the first patch is added and passing afterwards).
Please let me know if you need anything else,
-Carl
PS. If you could preserve the CC list in any replies that would be
appreciated.
0001-Preserve-hard-links-with-remove-files.patch
Description: Text Data
0002-Add-hardlinks-test-to-ensure-they-are-preserved-with.patch
Description: Text Data
signature.asc
Description: This is a digitally signed message part
- [Bug-tar] tar fails to preserve hard links with --remove-files,
Carl Worth <=