On Wed, 11 Jun 2008 03:20:00 +1000, Andi Kleen <andi@xxxxxxxxxxxxxx> wrote:
dizzy <dizzy@xxxxxxxxx> writes:
Can someone tell me (in English or C :) ) the algorithm of the sorting
order
of the entries in an XFS directory as I would get them with a readdir()
(or
shell "find" command)?
I am trying to figure it out by reading linux/fs/xfs/xfs_dir2*.c code
but I
don't seem to be doing much progress and I was hoping maybe someone that
knows these details can help.
I believe it computes a hash over the name and then sorts by the hash
numerical value. At least the b*tree large directories do, small inline
directories might be different (XFS uses different algorithms for
different directory sizes)
readdir order is not dependant on the hashes. The order depends on the
order of files being created, unlinked and the length of the filenames
being unlinked/created.
The hash function is in xfs_da_btree.c:xfs_da_hashname()
With the recent case insensitive support there are also differences
on the file systems which have that enabled.
Also better don't rely on it never changing.
Yes :)
Barry.
|