lkml.org 
[lkml]   [2003]   [May]   [24]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
Subject[PATCH] SYSV fs: test in sysv_hash() is backwards
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;
}

-
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: 2005-03-22 13:35    [W:0.020 / U:0.480 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site