2001-07-08 17:02:59

by Pavel Machek

[permalink] [raw]
Subject: Re: Q: sparse file creation in existing data?

Hi!

> It could be used as a replacement for the truncate code, because then
> truncate is simply a special case of punch, namely punch(0, end).

I do not think so. Truncate leaves you with filesize 0, while punch schould
leave you with filesize of original file.
Pavel
--
Philips Velo 1: 1"x4"x8", 300gram, 60, 12MB, 40bogomips, linux, mutt,
details at http://atrey.karlin.mff.cuni.cz/~pavel/velo/index.html.


2001-07-09 06:44:33

by Andreas Dilger

[permalink] [raw]
Subject: Re: Q: sparse file creation in existing data?

Pavel writes:
> > It could be used as a replacement for the truncate code, because then
> > truncate is simply a special case of punch, namely punch(0, end).
>
> I do not think so. Truncate leaves you with filesize 0, while punch schould
> leave you with filesize of original file.

I can't recall the exact details (it's been a year since I looked at the
code), but I believe that the VFS sets the file size before the call to
truncate, so it didn't matter on the exact semantics of the punch call.
Truncate still existed, but it was just a wrapper calling the punch code
to punch out all of the existing blocks.

Cheers, Andreas
--
Andreas Dilger \ "If a man ate a pound of pasta and a pound of antipasto,
\ would they cancel out, leaving him still hungry?"
http://www-mddsp.enel.ucalgary.ca/People/adilger/ -- Dogbert