fallocate

what's the difference between fallocate and ftruncate

江枫思渺然 提交于 2020-06-16 02:10:05
问题 They can all change file size according to my test. why can they all change file to larger and to shorter? what's the difference between fallocate and ftruncate? 回答1: ftruncate is a simple, single-purpose function. Per the POSIX documentation, it simply sets the file to the requested length: If fildes refers to a regular file, the ftruncate() function shall cause the size of the file to be truncated to length . ... ftruncate() is also a standard POSIX function and is portable. Note that POSIX