David Masover
6/18/2008 5:46:00 PM
On Wednesday 18 June 2008 04:43:50 Robert Klemme wrote:
> This is why tools like "ls" and "du" are
> useful in practice because you can be pretty sure, that only a
> negligible portion of disk usage is counted more than once. But the
> topology of an object graph might look totally different, i.e. more
> interconnected.
Noting that du won't count hardlink'd files more than once, it seems your
point here is that such a tool would be less efficient in Ruby than it is for
filesystems?
> Then there are different types of links - soft links and hard links.
> This gives file system utilities a means to ignore paths. Usually
> soft links are much more often used than hard links (in my personal
> experience anyways) while hard links more closely resemble object
> references in Ruby.
However, filesystem utilities can be made to follow softlinks. Also, I'd argue
that the choice to use softlinks over hardlinks has nothing to do with making
life easier for du, and everything to do with the relative semantics of
actual usage here.
Typical example, if you have /bin/gunzip symlinked to gzip, you can always
replace gzip with a new version, through the old standard method of making a
tempfile, then rename-ing it on top of the original (so as to do an atomic
replace). Then, gunzip, zcat, and friends, will refer to that new version --
whereas with a hardlink, you would have to manually re-link the new version
everywhere it's used.
Or, conversely, if you have something which is meant to be edited in-place --
if you truncate a file which has another hardlink, or do a simple append
(with the shell >>, say), you never know what you'll be changing in the rest
of the filesystem. (That's why we don't often do bang operations on strings,
especially those passed in -- or I don't, anyway.)