J
J.A. Hacker
Hello,
There's a fixed directory, mydir. This directory contains many files;
frequently, files are removed (in a random order) and new files added.
Now I have some code that reads the directory entries periodically with
readdir(3) or scandir(3) or equivalent. It would be nice if the order the
files came out was essentially in order of their creation, without
needing to sort. Instead, new files' inodes seem to "fill in the gaps" in
the directory's structure.
What I envisage is a sort of "compactification" of the directory that
rearranges the inodes in the B-tree(?) making up the directory, so that
the next file created in the directory will get its inode added at the end
of the tree. Then after removing a file in mydir, this compactifier would
be called to keep the entries in order.
Would that be easy to achieve? Is there a utility function or program that
already does it?
Cheers!
There's a fixed directory, mydir. This directory contains many files;
frequently, files are removed (in a random order) and new files added.
Now I have some code that reads the directory entries periodically with
readdir(3) or scandir(3) or equivalent. It would be nice if the order the
files came out was essentially in order of their creation, without
needing to sort. Instead, new files' inodes seem to "fill in the gaps" in
the directory's structure.
What I envisage is a sort of "compactification" of the directory that
rearranges the inodes in the B-tree(?) making up the directory, so that
the next file created in the directory will get its inode added at the end
of the tree. Then after removing a file in mydir, this compactifier would
be called to keep the entries in order.
Would that be easy to achieve? Is there a utility function or program that
already does it?
Cheers!