bug-coreutils
[Top][All Lists]
Advanced

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

Re: RFC: How du counts size of hardlinked files


From: Johannes Niess
Subject: Re: RFC: How du counts size of hardlinked files
Date: Fri, 13 Jan 2006 22:11:30 +0100
User-agent: KMail/1.9

Hi Phillip,

Hard links and file sizes are concepts that don't fit each other well. The 
best fit depends on what you are asking for.

bash-2.05b$ cp -al a/ b
bash-2.05b$ du -s a b .
34540   a
34540   b
34556   .
bash-2.05b$ du -sc a b .
34540   a
12      b
4       .
34556   total
bash-2.05b$ du -scl a b .
34540   a
34540   b
69084   .
138164  total
bash-2.05b$     

Am Freitag, 13. Januar 2006 19:56 schrieb Phillip Susi:
> Maybe I misunderstood you but you seem to think that each hard link to
> the same file can have different ownerships.  This is not the case.
> Hard links are just additional names for the same inode, and permissions
> and ownership is associated with the inode, not the name(s).

I know that. So I made the distinction between physical (customer) and logical 
(file system) owner. A file hardlinked between 2 customers belongs to both of 
them. It is quite unpredictable which directory entry (i.e one of the links 
to the inode) du finds first. This directory has the inode size added to its 
sum.

>
> Also I just tested it and du doesn't report the size used by duplicate
> hard links in the tree twice.  I did a cp -al foo bar, then a du -sh, du
> -sh foo, and they were both the same size.

That's correct without -l. The sizes do not add up: 'du ./foo' + 
'du ./bar'  (my two customers point of view) != 'du .' (disk space I need in 
the server).

'du -l' counts the links multiple times. 'du ./foo' = 'du ./bar' = 0.5 'du .';  
The overall size is from a customer perspective.

My approximate mode would count two halves. 0.5 'du ./foo' + 0.5 'du ./bar' = 
'du .'; That's the admins size perspective. In reality there is no fixed 
factor to du -l.

Johannes




reply via email to

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