9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
From: arnold@skeeve.com
To: 9fans@9fans.net
Subject: Re: [9fans] du vs. ls: duplication or not?
Date: Sun, 15 Jan 2012 23:39:13 -0800	[thread overview]
Message-ID: <201201160739.q0G7dDXS024165@freefriends.org> (raw)

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



             reply	other threads:[~2012-01-16  7:39 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-01-16  7:39 arnold [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=201201160739.q0G7dDXS024165@freefriends.org \
    --to=arnold@skeeve.com \
    --cc=9fans@9fans.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).