coreutils
[Top][All Lists]
Advanced

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

Re: feature request du/find


From: Kaz Kylheku (Coreutils)
Subject: Re: feature request du/find
Date: Wed, 30 Oct 2019 23:27:19 -0700
User-agent: Roundcube Webmail/0.9.2

On 2019-10-30 13:14, Benjamin Arnold wrote:
Hi,

thanks a lot for your quick response.

Sorry, i must have missed the -links option, that's exactly what i am
looking for.

Unfortunately, it's a component in an incorrect solution.
A file tree being backed up can contain hard links (e.g. two
executables in /usr/bin being the same file).

The general condition we must look for is that if the tree has
N directory entries pointing to the same object O, then O is entirely
contained in that tree if its link count is N.
Otherwise the count must be > N, and there are links to it
elsewhere.

A static -links predicate in find will not do it.

In my case du would have counted "twice", because the other hard link is
not in the directory du is searching in.

I think this should be a feature of do; and likely du has most
of the pieces in place to make this easy.

It already identifies multiply linked objects. All it needs is
a flag which will cause it to disregard the size of any
any object which has more links than the number of times
du has encountered that object.

The obvious algorithm will have an effect on the order in which du
reports objects. When the option is in effect, du will show the
path which references the *last* occurrence of the object (in the
traversal order). E.g. if some object with link count = 3 is
processed, the first two appearances of it won't be reported and
counted, but when the third one is seen, du can be sure that there
are no other references and can then tally the object's size
and report on it.

This algorithm will naturally cull the objects with excessive link
counts: the condition for reporting them and adding them to the
total simply isn't reached.



reply via email to

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