9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
* Re: [9fans] du vs. ls: duplication or not?
@ 2012-01-16  7:39 arnold
  2012-01-16 11:55 ` tlaronde
  2012-01-16 13:24 ` erik quanstrom
  0 siblings, 2 replies; 14+ messages in thread
From: arnold @ 2012-01-16  7:39 UTC (permalink / raw)
  To: 9fans

Hi.

> What I meant was the size of the file is already given via ls(1). So
> a recursive output that make sense and fit a manipulation via join(1)
> (to combine a srv/qid) and sort and uniq etc. could do the trick.

Not quite. On Unix (don't remember 'bout Plan 9 but I assume it's the
same) files can have holes.  All you have to do is lseek pass the end of
the file and then write something.  Bingo - size (or better, length of
the byte stream) no longer has a direct relationship to the number of
disk blocks occupied.

On Unix systems, du looks in the stat structure at the count of
blocks occupied (st_blocks IIRC) and does the computation from that.
Similaly, many Unix du implementations will track hard links based
on device+inode to only count a file's blocks once.

> Since ls(1) gives the size of the file; since du(1) can not really or at
> least not always in an arbitrary context tells the "real" occupation of
> disk size, is not ls(1) enough?

For the two above reasons, I think not.  Again, at least on Unix. :-)

(I suppose ls could print device+inode, and sort+join on that to remove
duplicates, but the holes problems is still there.  Hmmm. I bet ls can
print the number of blocks instead of or in addition to the size. So
maybe I'm wrong after all. :-)

Arnold



^ permalink raw reply	[flat|nested] 14+ messages in thread
* [9fans] du vs. ls: duplication or not?
@ 2012-01-14  8:01 tlaronde
  2012-01-14  9:20 ` Charles Forsyth
                   ` (2 more replies)
  0 siblings, 3 replies; 14+ messages in thread
From: tlaronde @ 2012-01-14  8:01 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

This is a slightly different point of view from the thread my blunders
have started.

du(1) stands for Disk Usage. But does this, with the "historical" use,
has any real sense now, with a namespace that can be, not only built by
presenting a same file via different paths, but a combination of local
storage (including memory one...) and remote storage?

Furthermore, even for an Unix du(1), if the underlying filesystem shares
common blocks, the count will be wrong. So Unix du(1) seems more
accurate only when it is used on "old" technology.

So if du(1) should stand for Disk Usage, it should tell what disk place
would be needed to _store_ "locally" the files. And this depends
on a lot of things: deduplication of blocks? If one uses a FAT, it
will need the total amount displayed etc.

So, in fact, since there is no real and immediate answer, and keeping in
mind the principle: don't duplicate fonctionnality, wouldn't it be
better to have a 'ls -R' (récursive listing) and no du(1) at all on
Plan9?

This is not a proposal or whatever. But, say, a semantical and
engineering question. And BTW, this is not a critic of what has been and
is done on Plan9. (I finally consider that du(1) does what it promises
in the man page; the "lack" is just a one line caveat that du(1) can not
answer a fuzzy question.)
-- 
        Thierry Laronde <tlaronde +AT+ polynum +dot+ com>
                      http://www.kergis.com/
Key fingerprint = 0FF7 E906 FBAF FE95 FD89  250D 52B1 AE95 6006 F40C



^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2012-01-16 18:06 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-01-16  7:39 [9fans] du vs. ls: duplication or not? arnold
2012-01-16 11:55 ` tlaronde
2012-01-16 13:21   ` erik quanstrom
2012-01-16 13:24 ` erik quanstrom
  -- strict thread matches above, loose matches on Subject: below --
2012-01-14  8:01 tlaronde
2012-01-14  9:20 ` Charles Forsyth
2012-01-15 16:18   ` tlaronde
2012-01-15 21:17     ` erik quanstrom
2012-01-16 11:46       ` tlaronde
2012-01-16 16:13         ` Joel C. Salomon
2012-01-16 17:43           ` tlaronde
2012-01-16 18:06             ` erik quanstrom
2012-01-14  9:45 ` David du Colombier
2012-01-14 13:23 ` erik quanstrom

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).