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

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

On 02/15/2010 11:29 PM, Eric Blake wrote:
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.

That's ok, I was only asking about behavior with regular files here. Thanks for the pointer--that's exactly what I was looking for.


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