On 24 Jan 2012, at 6:51pm, David Garfield wrote:

> From the ftruncate page: "If the file size is increased, the extended
> area shall appear as if it were zero-filled".
> It doesn't have to write zeros, just act like it did.

That's a bit of handwaving.  What happens is that the file system doesn't 
itself write zeros to the disk surface.  It puts zeros into the cache of the 
sector in memory and marks that sector as dirty (i.e. needing to eventually be 
written back to disk).  So if the program doesn't write to that sector and just 
releases it, those zeros do eventually get written to disk.  But if the program 
does write to that sector the disk surface only gets touched once, not twice, 
which is faster.

So it doesn't write zeros to disk, but it does write zeros to the bit of memory 
that represents that bit of disk, and arrange that (unless the program 
overwrites them) they'll be written to disk eventually.

Simon.
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to