On 22 Jan 2012, at 3:36pm, David Henry wrote: > According to the posix definition of "ftruncate" , a file is made larger by > writing zeroes up to the size desired. > > My implementation of Fat File System can quickly extend a file by allocating > more sectors, but will take a long time to write all those new sectors with > zeroes. > > So, is zero filling absolutely necessary?
Filling new space with something (doesn't have to be zeros) is considered necessary in modern operating systems. Suppose you were using an application which stored valuable data in a temporary file -- perhaps passwords, or financial records. You quit this application and it deletes its temporary file, reallocating the disk space to the 'unused' pool. You then run another sneaky application which grabs all the free disk space available and looks through it for valuable information. The only way to defeat to fill disk space with something before inserting it into the new file. You can do this when the space is released, or when the space is reused and ftruncate does the latter. > Also, is ftruncate ever called to shorten a file? Often code calls ftruncate to set the file size, without even knowing whether it will expand or truncate the file. It just knows what the new size of the file should be. ftruncate does the right thing in both cases. Simon. _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users