NWFS mangled name algorithm.

Jeremy Allison jeremy at valinux.com
Mon Mar 27 22:57:44 GMT 2000


Hi all,

	Timpanogas just released a netware filesystem module
for Linux under the GPL.

They use the following hash functions to generate mangled
names :

ULONG HornerStringHash(BYTE *v, ULONG len, ULONG M)
{
   register ULONG h = 0, a = 127, i;

   if (!M)
   {
      NWFSPrint("nwfs:  horner hash limit error [%s] lim-%u\n",
         v, (unsigned int)M);
      return -1;
   }

   for (i = 0; i < len && *v; v++, i++)
      h = ((a * h) + *v) % M;

   return h;

}

//
//  very good universal string hash function with a built-in random
//  number genrator, but has more computational overhead.
//

ULONG UniversalStringHash(BYTE *v, ULONG len, ULONG M)
{
   register ULONG h, a = 31415, b = 27163, i;

   if (!M)
   {
      NWFSPrint("nwfs:  universal hash limit error [%s] lim-%u\n",
          v, (unsigned int)M);
      return -1;
   }

   for (i = 0, h = 0; i < len && *v; i++, v++, a = (a * b) % (M - 1))
      h = ((a * h) + *v) % M;

   return h;

}

Andrew, any comments on changing to one of these in Samba
instead of the (rather crappy:-) str_checksum() function ?

Jeremy.

-- 
--------------------------------------------------------
Buying an operating system without source is like buying
a self-assembly Space Shuttle with no instructions.
--------------------------------------------------------


More information about the samba-technical mailing list