Subject: Re: [vserver] Requirements for file to be hashified
From: "Daniel Hokka Zakrisson" <daniel@hozac.com>
Date: Sat, 1 Nov 2008 16:08:03 +0100 (CET)

Jim Wight wrote:
> On Fri, 2008-10-31 at 18:39 +0100, Herbert Poetzl wrote:
>> On Thu, Oct 30, 2008 at 03:49:22PM +0000, Jim Wight wrote:
>> > What are the requirements for files to be hashified? I thought it was
>> > simply identical content. If so, what might be the reason for the
>> > following behaviour?

Content, and basic properties. Hashifying a file owned by root and one
owned by a user would be rather bad...

The struct stat fields used are mode, uid, gid, rdev, size and mtime.

>> > # cp /tmp/testfile leave/usr/local
>> > # cp /tmp/testfile bscw2/usr/local
>> > # vserver leave hashify; vserver bscw2 hashify
>> > # ls -l */usr/local/testfile
>> > -rwxr-xr-x 2 root root 227 Oct 30 15:14 bscw2/usr/local/testfile
>> > -rwxr-xr-x 2 root root 227 Oct 30 15:14 leave/usr/local/testfile
>> > # find */usr/local -name testfile -printf "%p %i\n"
>> > bscw2/usr/local/testfile 1150163
>> > leave/usr/local/testfile 1200007
>>
>> > I would have expected 3 links and same inode. testfile is an ASCII file.
>>
>> yep, that I would expect too, but what does the
>> following give you?
>>
>> stat leave/usr/local/testfile
>> stat bscw2/usr/local/testfile
>
> # stat leave/usr/local/testfile
>   File: `leave/usr/local/testfile'
>   Size: 227             Blocks: 8          IO Block: 4096   regular file
> Device: fe00h/65024d    Inode: 1200007     Links: 2
> Access: (0755/-rwxr-xr-x)  Uid: (    0/    root)   Gid: (    0/    root)
> Access: 2008-10-30 15:14:38.000000000 +0000
> Modify: 2008-10-30 15:14:38.000000000 +0000
> Change: 2008-10-30 15:15:31.000000000 +0000
> # stat bscw2/usr/local/testfile
>   File: `bscw2/usr/local/testfile'
>   Size: 227             Blocks: 8          IO Block: 4096   regular file
> Device: fe00h/65024d    Inode: 1150163     Links: 2
> Access: (0755/-rwxr-xr-x)  Uid: (    0/    root)   Gid: (    0/    root)
> Access: 2008-10-30 15:14:44.000000000 +0000
> Modify: 2008-10-30 15:14:44.000000000 +0000
> Change: 2008-10-30 15:16:01.000000000 +0000

The timestamps are different.

> The ed package was recently updated in the two vservers. After
> rehashification the new binaries were linked as expected.
>
> However, if I
>
> # cp leave/bin/ed leave/bin/anothered

Use cp -a and it'd do what you expect.

> # vserver leave hashify
>
> should the link count for leave/bin/ed not incease by 1? The outcome is
> the same as with testfile:
>
> # ls -l leave/bin/anothered
> -rwxr-xr-x 2 root root 40636 Nov  1 10:06 leave/bin/anothered

-- 
Daniel Hokka Zakrisson