All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@linux-foundation.org>
To: Roman Zippel <zippel@linux-m68k.org>
Cc: Duane Griffin <duaneg@dghda.com>,
	linux-kernel@vger.kernel.org, didier <did447@gmail.com>,
	Solra Bizna <sbizna@tejat.net>, Daniel Drake <dsd@gentoo.org>
Subject: Re: [patch 2/2] HFS+: Add custom dentry hash and comparison operations
Date: Mon, 25 Jun 2007 22:01:18 -0700	[thread overview]
Message-ID: <20070625220118.199f86a8.akpm@linux-foundation.org> (raw)
In-Reply-To: <Pine.LNX.4.64.0706251412030.1817@scrub.home>

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);

      reply	other threads:[~2007-06-26  5:02 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-06-20  0:06 [patch 0/2] HFS+: custom dentry hash and comparison operations Duane Griffin
2007-06-20  0:06 ` [patch 1/2] HFS+: Refactor ASCII to unicode conversion routine for later reuse Duane Griffin
2007-06-25 12:11   ` Roman Zippel
2007-06-26 10:03     ` Duane Griffin
2007-06-20  0:06 ` [patch 2/2] HFS+: Add custom dentry hash and comparison operations Duane Griffin
2007-06-25 12:17   ` Roman Zippel
2007-06-26  5:01     ` Andrew Morton [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20070625220118.199f86a8.akpm@linux-foundation.org \
    --to=akpm@linux-foundation.org \
    --cc=did447@gmail.com \
    --cc=dsd@gentoo.org \
    --cc=duaneg@dghda.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=sbizna@tejat.net \
    --cc=zippel@linux-m68k.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.