Results 1 to 4 of 4
The blocks allocation is decided by the kernel. When writing new data to a file, if the block is not enough, the kernel will select a new block from the ...
- 08-21-2009 #1Just Joined!
- Join Date
- Aug 2009
- Posts
- 2
how to create a file that the device blocks are non-contiguous?
The blocks allocation is decided by the kernel. When writing new data to a file, if the block is not enough, the kernel will select a new block from the device that is contiguous with file's last block.
If the selected block has been used by other file. The kernel can only select a non-contiguous block.
My questions is that:How can we create a file, the device block are non-contguous?
- 08-21-2009 #2Linux Guru
- Join Date
- Apr 2009
- Location
- I can be found either 40 miles west of Chicago, or in a galaxy far, far away.
- Posts
- 8,961
Please clarify. Are you asking how to create a file that consists totally (or mostly) of non-contiguous blocks?
Sometimes, real fast is almost as good as real time.
Just remember, Semper Gumbi - always be flexible!
- 08-21-2009 #3
- 08-21-2009 #4Linux Guru
- Join Date
- Apr 2009
- Location
- I can be found either 40 miles west of Chicago, or in a galaxy far, far away.
- Posts
- 8,961
I don't think there is a way to guarantee this. The only reliable (sort of) way to do this is to create 2 files on the same device, and then delete the one you don't want. The algorithm, in pseudo-code, goes something like this:
Code:while not done open file 1 to append write 1 block to file close file sync file systems open file 2 to append write 1 block to file close file sync file systems if total size written >= requested size unlink file 2 set done flag endif endwhile # at this point, file 1 (target file) should consist of non-contiguous blocks # however, there is no guarantee of thatSometimes, real fast is almost as good as real time.
Just remember, Semper Gumbi - always be flexible!


Reply With Quote

