From owner-mint@fishpool.com Thu Jun 22 12:16:56 2000 From: "Guido Flohr" Date: Thu, 8 Jun 2000 00:42:17 +0200 To: MiNT mailing list Subject: [MiNT] Hash filename for index Message-ID: <20000608004217.D5738@zowee.kosmos.all> Reply-To: guido@freemint.de Mail-Followup-To: MiNT mailing list Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Mailer: Mutt 1.0.1i X-Hello-To-Secret-Service: Bombs Terror Ghaddafi PGP Marx Engels Lenin Che Guevara Fidel Castro Anarchy Porno Punk Saddam Password Mafia Peter Graf X-Operating-System: Linux zowee 2.2.14 Sender: owner-mint@fishpool.com Precedence: bulk X-Loop: mint@fishpool.com 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