On Mon, Jun 20, 2011 at 6:37 AM, Fam Zheng <famc...@gmail.com> wrote:
> Is there any difference between bdrv_getlength and
> bdrv_get_allocated_file_size for bs-file? If not, I can simplify it by
> reusing it in two raw devices.

Yes, the two functions are different:

POSIX sparse files (files with holes) take up less space on disk than
their file size.  For example a 1 GB file where you've only written
the last byte and never touched any other blocks will only take up one
block - the rest will be unallocated.  So bdrv_getlength() == 1 GB and
bdrv_get_allocated_file_size() == 4 KB (or whatever the file system
block size is).

You can look at this using the stat(1) command and dd(1) to only write
the last byte of a file.

Stefan

Reply via email to