Wierd File Sizes....

Dave Wolfe dwolfe at risc.sps.mot.com
Fri Jun 11 03:23:24 EST 1999


[ Packer, Dave writes: ]
> 
> This is peculiar behavior I've never noticed before and was wondering if
> anyone else has experienced this.  I've created a file using mmap, set its
> size to the appropriate bytes, and then written it. As you can see in the
> listing below the file size is 156K, but du -k only sees 7K.  What's not
> below is if I use df -k it sees 7K less than before the file was created.

This is a feature. Unix file systems support sparse files. The
uninitialized blocks aren't allocated on disk, so du is reporting the
true file size, i.e. the disk space used to contain the file, vs the
offset of the EOF, which is what ls reports.

> As you can see below by using gzip / ungzip the file gets noticed properly.

Ungzip actually wrote the intervening blocks which didn't exist in the
original file, so now disk space is required to hold those blocks.
I believe tar has an option to accurately preserve sparse files, so
gzipping a tar of such files would be one way of compressing them if you
felt you really needed to do that.

-- 
 Dave Wolfe

[[ This message was sent via the linuxppc-dev mailing list.  Replies are ]]
[[ not  forced  back  to the list, so be sure to Cc linuxppc-dev if your ]]
[[ reply is of general interest. Please check http://lists.linuxppc.org/ ]]
[[ and http://www.linuxppc.org/ for useful information before posting.   ]]





More information about the Linuxppc-dev mailing list