From: "René Scharfe" <l.s.r@web.de>
To: linux-kernel@vger.kernel.org
Cc: trivial@rustcorp.com.au
Subject: [PATCH] SYSV fs: test in sysv_hash() is backwards
Date: Sat, 24 May 2003 13:32:13 +0200 [thread overview]
Message-ID: <20030524133213.04a53581.l.s.r@web.de> (raw)
Hi all,
it seems sysvfs will compute a filename hash only in the case where
that name is too long.
After applying the patch below it will always update the hash, and
truncate too-long filenames beforehand. Also use full_name_hash() to
simplify the code.
René
--- linux/fs/sysv/namei.c.orig 2003-05-24 12:49:57.000000000 +0200
+++ linux/fs/sysv/namei.c 2003-05-24 13:08:45.000000000 +0200
@@ -42,21 +42,11 @@
static int sysv_hash(struct dentry *dentry, struct qstr *qstr)
{
- unsigned long hash;
- int i;
- const unsigned char *name;
-
- i = SYSV_NAMELEN;
- if (i >= qstr->len)
- return 0;
/* Truncate the name in place, avoids having to define a compare
function. */
- qstr->len = i;
- name = qstr->name;
- hash = init_name_hash();
- while (i--)
- hash = partial_name_hash(*name++, hash);
- qstr->hash = end_name_hash(hash);
+ if (qstr->len > SYSV_NAMELEN)
+ qstr->len = SYSV_NAMELEN;
+ qstr->hash = full_name_hash(qstr->name, qstr->len);
return 0;
}
next reply other threads:[~2003-05-24 11:03 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-05-24 11:32 René Scharfe [this message]
2003-05-24 12:06 ` René Scharfe
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=20030524133213.04a53581.l.s.r@web.de \
--to=l.s.r@web.de \
--cc=linux-kernel@vger.kernel.org \
--cc=trivial@rustcorp.com.au \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®