Highly efficient filesystem APIs for certain kinds of operations
Posted
by romkyns
on Stack Overflow
See other posts from Stack Overflow
or by romkyns
Published on 2010-05-24T10:35:02Z
Indexed on
2010/05/24
10:41 UTC
Read the original article
Hit count: 177
I occasionally find myself needing certain filesystem APIs which could be implemented very efficiently if supported by the filesystem, but I've never heard of them. For example:
- Truncate file from the beginning, on an allocation unit boundary
- Split file into two on an allocation unit boundary
- Insert or remove a chunk from the middle of the file, again, on an allocation unit boundary
The only way that I know of to do things like these is to rewrite the data into a new file. This has the benefit that the allocation unit is no longer relevant, but is extremely slow in comparison to some low-level filesystem magic.
I understand that the alignment requirements mean that the methods aren't always applicable, but I think they can still be useful. For example, a file archiver may be able to trim down the archive very efficiently after the user deletes a file from the archive, even if that leaves a small amount of garbage either side for alignment reasons.
Is it really the case that such APIs don't exist, or am I simply not aware of them? I am mostly interested in NTFS, but hearing about other filesystems will be interesting too.
© Stack Overflow or respective owner