lkml.org 
[lkml]   [2007]   [Jun]   [26]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [patch 2/2] HFS+: Add custom dentry hash and comparison operations
On Mon, 25 Jun 2007 14:17:19 +0200 (CEST) Roman Zippel <zippel@linux-m68k.org> wrote:

> +/*
> + * Hash a string to an integer as appropriate for the HFS+ filesystem.
> + * Composed unicode characters are decomposed and case-folding is performed
> + * if the appropriate bits are (un)set on the superblock.
> + */
> +int hfsplus_hash_dentry(struct dentry *dentry, struct qstr *str)
> +{
> + struct super_block *sb = dentry->d_sb;
> + const char *astr;
> + const u16 *dstr;
> + int casefold, decompose, size, dsize, len;
> + unsigned long hash;
> + wchar_t c;
> + u16 c2;
> +
> + casefold = (HFSPLUS_SB(sb).flags & HFSPLUS_SB_CASEFOLD);
> + decompose = !(HFSPLUS_SB(sb).flags & HFSPLUS_SB_NODECOMPOSE);
> + hash = init_name_hash();
> + astr = str->name;
> + len = str->len;
> + while (len > 0) {
> + size = asc2unichar(sb, astr, len, &c);
> + astr += size;
> + len -= size;
> +
> + if (decompose && (dstr = decompose_unichar(c, &dsize))) {
> + do {
> + c2 = *dstr++;
> + if (!casefold || (c2 = case_fold(c2)))
> + hash = partial_name_hash(c2, hash);
> + } while (--dsize > 0);

Are you really sure that we cannot start this loop with dsize==0? This isn't
obviously true to these bleary eyes.

> + } else {
> + c2 = c;
> + if (!casefold || (c2 = case_fold(c2)))
> + hash = partial_name_hash(c2, hash);
> + }
> + }
> + str->hash = end_name_hash(hash);
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2007-06-26 07:05    [W:0.076 / U:0.100 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site