Subject: Re: cache_*() case-insensitive searching
To: Bill Sommerfeld <>
From: Jaromir Dolecek <>
List: tech-kern
Date: 08/09/1999 12:05:22
Bill Sommerfeld wrote:
> No.
> The hash bucket is selected via:
> 	ncpp = &nchashtbl[(cnp->cn_hash ^ dvp->v_id) & nchash];
> (see vfs_cache.c)
> cnp->cn_hash is computed in vfs_lookup.c from the pathname component:
> 	cnp->cn_hash = 0;
> 	for (cp = cnp->cn_nameptr; *cp != '\0' && *cp != '/'; cp++)
> 		cnp->cn_hash += (unsigned char)*cp;

Hmm, I though cnp->cn_hash just magically comes from the air, 
which is not true, obviously :)

Anyway, with the change I've sent in the previous message, this could be
changed to: 
	for (cp = cnp->cn_cnameptr; *cp != '\0' && *cp != '/'; cp++)
		cnp->cn_hash += (unsigned char)*cp;

and it would "just work". sys_getcwd() should be okay too, as
the cache_revlookup() would be left to use ncp->nc_name and not
the "canonified" name.

Is there anything other I don't see ?

Regarding the NCHNAMLEN: I counted it incorrectly the first time
it seems, the actual length of the struct namecache is
(10*4) + 1 + 31 == 72 bytes for 32 bit arch, (10*8) + 1 + 31 == 112
for 64 bit ones (assuming u_long is 8 bytes wide as well as a pointer is).
So, for 32bit archs the NCHNAMLEN could be safely changed to
to 87 with no bigger memory overhead (or shorten to 23 to safe
the 64 bytes). For 64bit archs, NCHNAMLEN can safely be 43.

> > Monocase fs in tree is filecorefs only, right ?
> Not the only one; for example, the MS-DOS filesystem without the win95
> extensions for long filenames is case-insensitive..

Hmm, so actually this is the only case where any our fs is monocase (i.e.
it's case-independant and not -preserving). Maybe even cd9660
with rockridge extensions off ?
As David pointed out, filecorefs is -independant, but -preserving.

To sum it up: the case-indendant, but -preserving fs'es in tree
seem to be adosfs, filecorefs, msdosfs with w95 extensions, ntfs
(when mounted with -i).

The case-independant and not -preserving are msdosfs without w95 extensions,
cd9660 without RockRidge.

Jaromir Dolecek <>
"The only way how to get rid temptation is to yield to it." -- Oscar Wilde