From: Russ Cox <russcox@gmail.com>
To: Fans of the OS Plan 9 from Bell Labs <9fans@cse.psu.edu>
Subject: Re: [9fans] truncation via wstat on ken's fs
Date: Sun, 17 Oct 2004 13:01:40 -0400 [thread overview]
Message-ID: <ee9e417a04101710012bdf8410@mail.gmail.com> (raw)
In-Reply-To: <f5bbaa3d61cddff0ebce8441ed44744f@collyer.net>
> Changing the length is easy, but giving back the no-longer-needed
> blocks is messy, involving a recursive walk of the indirect blocks.
> I'm tempted to just change the length, which gives the desired
> user-visible effect, unless the side-effect of freeing the
> unneeded storage is important to someone.
I thought about this too, but it's not actually true.
It's important to free or zero the blocks:
fd = create("foo", ORDWR);
write(fd, "hello world", 12);
ftruncate(fd, 0);
pwrite(fd, "", 1, 11);
should result in a file with 12 zero bytes,
not the string "hello world\0".
It's not that hard to do the recursive walk.
Remove does it already. In fossil we just pulled
that code out of remove and made it a separate
function that can be passed a length instead
of assuming 0.
Russ
next prev parent reply other threads:[~2004-10-17 17:01 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-10-17 11:05 geoff
2004-10-17 11:18 ` Brantley Coile
2004-10-17 17:01 ` Russ Cox [this message]
2004-10-18 0:43 ` geoff
2004-10-18 8:03 ` Charles Forsyth
2004-10-18 8:24 ` geoff
2004-10-18 8:36 ` Charles Forsyth
2004-10-18 8:38 ` geoff
2004-10-17 17:35 ` boyd, rounin
2004-10-17 13:19 Aharon Robbins
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=ee9e417a04101710012bdf8410@mail.gmail.com \
--to=russcox@gmail.com \
--cc=9fans@cse.psu.edu \
/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).