[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[MiNT] Hash filename for index



Hi,

in another thread it has been discussed how to find out if two filenames
refer to the same file if the filesystem/kernel doesn't support Fxattr and
file index records.

The MiNTLib (and I think the MiNT kernel too) simply increment a counter
and return the counter as a fake index. Drawback: subsequent stat calls on
the same file will return different (increasing) values on each
call. Furthermore, communicating the index to another process (or
storing and re-reading it in a subsequent invocation) will result
in chaos.

Provided we find a decent algorithm (which will also work with
potentially short strings) that hashes the filename (the "real" filename,
i. e. with the correct case on case-preserving filesystems) into a 32-bit
value we could avoid these problems at the risk of reporting a hard link
with the merely theoretical chance of 1:2^32 (*).  An application could
even circumvent this problem by additionally checking the link count.  If
it is zero, the identical indices were reported erroneously.

Comments? Which hash algorithm would be a good choice?

Ciao

Guido

P.S.: Of course, the new Fstat64 call should hash the name into 64
bits and Fxattr should mask out the upper 32 bits.

(*) If you delete a file and immediately create a new one, most
filesystems will assign the index of the deleted file to the new
one.  The chances for this race-condition are probably a lot higher than
the risk of duplicate hash values.
-- 
http://www.stud.uni-saarland.de/
Send your spam to president@whitehouse.gov and your replies to
mailto:guido at freemint dot de