mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] SYSV fs: test in sysv_hash() is backwards
@ 2003-05-24 11:32 René Scharfe
  2003-05-24 12:06 ` René Scharfe
  0 siblings, 1 reply; 2+ messages in thread
From: René Scharfe @ 2003-05-24 11:32 UTC (permalink / raw)
  To: linux-kernel; +Cc: trivial

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

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] SYSV fs: test in sysv_hash() is backwards
  2003-05-24 11:32 [PATCH] SYSV fs: test in sysv_hash() is backwards René Scharfe
@ 2003-05-24 12:06 ` René Scharfe
  0 siblings, 0 replies; 2+ messages in thread
From: René Scharfe @ 2003-05-24 12:06 UTC (permalink / raw)
  To: linux-kernel; +Cc: trivial

On Sat, 24 May 2003 13:32:13 +0200
René Scharfe <l.s.r@web.de> wrote:

> it seems sysvfs will compute a filename hash only in the case where
> that name is too long.

... and that is just fine. On second glance, that is _exactly_ what
it should do. The common case is handled in fs/namei.c. D'oh!

There's opportunity for cleanup, though. Updated patch below.

René



--- fs/sysv/namei.c.orig	2003-05-24 12:49:57.000000000 +0200
+++ fs/sysv/namei.c	2003-05-24 13:59:09.000000000 +0200
@@ -42,21 +42,12 @@
 
 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;
 }
 

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2003-05-24 11:37 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-05-24 11:32 [PATCH] SYSV fs: test in sysv_hash() is backwards René Scharfe
2003-05-24 12:06 ` René Scharfe

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®