Re: [patch 2/2] HFS+: Add custom dentry hash and comparison operations

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

 



On Mon, 25 Jun 2007 14:17:19 +0200 (CEST) Roman Zippel <[email protected]> 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 [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Stuff]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]     [Linux Resources]
  Powered by Linux