[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: [libvirt] [PATCH 3/3] Add volume zeroing

According to Dave Allan on 2/15/2010 9:08 PM:
>> ftruncate (fd, 0);
>> ftruncate (fd, st.st_size);
> That's a good point.  The only thing that makes me hesitate is that I'm
> not certain that the file is guaranteed to contain zeros following the
> second call to ftruncate, and I'm having trouble coming up with the
> relevant spec at the moment.

For regular files, POSIX guarantees that extending a file via ftruncate
will give zeros following the previous length.
"If the file previously was smaller than this size, ftruncate() shall
increase the size of the file. If the file size is increased, the extended
area shall appear as if it were zero-filled."

But for all other file types (such as block devices), the results are
unspecified by POSIX.

Don't work too hard, make some time for fun as well!

Eric Blake             ebb9 byu net

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]