[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Bug in handling hard links in bind-mounted directories
From: |
Sergey Poznyakoff |
Subject: |
Re: Bug in handling hard links in bind-mounted directories |
Date: |
Tue, 11 Jan 2022 07:19:23 +0100 |
User-agent: |
MH (GNU Mailutils 3.13.90) |
Hi Derec,
> It appears that tar doesn't always recognize (and treat as hard links) files
> that are the same file, but appear in two different directories from bind
> mounts.
>
> $ sudo mount -o bind /tmp/foo/bar /tmp/foo/baz
> $ echo "test data" >/tmp/foo/bar/bleh
> $ stat --printf "%d %i %n\n" /tmp/foo/bar/bleh /tmp/foo/baz/bleh
> 51 97105 /tmp/foo/bar/bleh
> 51 97105 /tmp/foo/baz/bleh
Tar uses link count to decide whether a file might be a hard link to
another file. In this test case, link count of bleh is 1, so it skips
hardlink detection phase. To force hardlink detection, use the -h
(--dereference) option:
tar -hcf /tmp/testing.tar /tmp/foo
Regards,
Sergey
- Re: Bug in handling hard links in bind-mounted directories,
Sergey Poznyakoff <=