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

Re: dpkg and hardlinks



On 2009-03-24, Mike Hommey <mh@glandium.org> wrote:
> On Tue, Mar 24, 2009 at 02:09:25PM +0100, Raphael Hertzog <hertzog@debian.org> wrote:
>> On Tue, 24 Mar 2009, Jerome Warnier wrote:
>> > For files from packages, though, deduplication might be a good idea, as
>> > dpkg is supposedly the only one to ever modify the files (under /usr for
>> > example).
>> > I don't know however how dpkg treats hardlinks. Does it "break" the
>> > hardlink before replacing a file or does it replace the file whatever
>> > its real nature is?
>> 
>> IIRC dpkg preserves hardlinks inside a binary package but I don't see how
>> it could do the same across multiple binary packages.
>
> I think the question is more something like:
> Package foo has file a
> Package bar had file b
> They are actually the same content, so the user hardlinks a and b.
> What happens when bar is updated with a different b file ?
>
> The answer, AFAIK, is that dpkg will do the right thing, namely, to
> replace the content of b, but not of a, because it actually doesn't put
> the content in b but rather in another file that it renames, eventually,
> to b.

iirc, dpkg starts with chmod'ing 0600 a file and then replacing it.

But let us test:

sune@gladstone:/var/tmp/user$ ln /usr/bin/sudo
sune@gladstone:/var/tmp/user$ ls -l
-rwsr-xr-x 3 root root 113916 2009-01-27 19:57 sudo
sune@gladstone:/var/tmp/user$ sudo apt-get --reinstall install sudo
[many lines of apt]
sune@gladstone:/var/tmp/user$ ls -l
-rw------- 1 root root 113916 2009-01-27 19:57 sudo


for non-suid files, it is a bit different:

sune@gladstone:/var/tmp/user$ ln /bin/ls
sune@gladstone:/var/tmp/user$ ls -l ls
-rwxr-xr-x 2 root root 100564 2009-02-22 23:40 ls
sune@gladstone:/var/tmp/user$ sudo apt-get --reinstall install coreutils
sune@gladstone:/var/tmp/user$ ls -l ls
-rwxr-xr-x 1 root root 100564 2009-02-22 23:40 ls

/Sune


Reply to: