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

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

 



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.
http://www.opengroup.org/onlinepubs/9699919799/functions/ftruncate.html
"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.

Dave

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list

[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]