diff options
-rw-r--r-- | fs/dcache.c | 12 | ||||
-rw-r--r-- | include/linux/dcache.h | 21 |
2 files changed, 24 insertions, 9 deletions
diff --git a/fs/dcache.c b/fs/dcache.c index 2a4ce7dc2306..5699d4c027cb 100644 --- a/fs/dcache.c +++ b/fs/dcache.c | |||
@@ -1454,9 +1454,7 @@ static struct dentry *__d_instantiate_unique(struct dentry *entry, | |||
1454 | continue; | 1454 | continue; |
1455 | if (alias->d_parent != entry->d_parent) | 1455 | if (alias->d_parent != entry->d_parent) |
1456 | continue; | 1456 | continue; |
1457 | if (qstr->len != len) | 1457 | if (dentry_cmp(qstr->name, qstr->len, name, len)) |
1458 | continue; | ||
1459 | if (memcmp(qstr->name, name, len)) | ||
1460 | continue; | 1458 | continue; |
1461 | __dget(alias); | 1459 | __dget(alias); |
1462 | return alias; | 1460 | return alias; |
@@ -1810,9 +1808,7 @@ seqretry: | |||
1810 | tlen, tname, name)) | 1808 | tlen, tname, name)) |
1811 | continue; | 1809 | continue; |
1812 | } else { | 1810 | } else { |
1813 | if (tlen != len) | 1811 | if (dentry_cmp(tname, tlen, str, len)) |
1814 | continue; | ||
1815 | if (memcmp(tname, str, tlen)) | ||
1816 | continue; | 1812 | continue; |
1817 | } | 1813 | } |
1818 | /* | 1814 | /* |
@@ -1925,9 +1921,7 @@ struct dentry *__d_lookup(struct dentry *parent, struct qstr *name) | |||
1925 | tlen, tname, name)) | 1921 | tlen, tname, name)) |
1926 | goto next; | 1922 | goto next; |
1927 | } else { | 1923 | } else { |
1928 | if (tlen != len) | 1924 | if (dentry_cmp(tname, tlen, str, len)) |
1929 | goto next; | ||
1930 | if (memcmp(tname, str, tlen)) | ||
1931 | goto next; | 1925 | goto next; |
1932 | } | 1926 | } |
1933 | 1927 | ||
diff --git a/include/linux/dcache.h b/include/linux/dcache.h index c0a2ca97c72f..bd07758943e0 100644 --- a/include/linux/dcache.h +++ b/include/linux/dcache.h | |||
@@ -47,6 +47,27 @@ struct dentry_stat_t { | |||
47 | }; | 47 | }; |
48 | extern struct dentry_stat_t dentry_stat; | 48 | extern struct dentry_stat_t dentry_stat; |
49 | 49 | ||
50 | /* | ||
51 | * Compare 2 name strings, return 0 if they match, otherwise non-zero. | ||
52 | * The strings are both count bytes long, and count is non-zero. | ||
53 | */ | ||
54 | static inline int dentry_cmp(const unsigned char *cs, size_t scount, | ||
55 | const unsigned char *ct, size_t tcount) | ||
56 | { | ||
57 | int ret; | ||
58 | if (scount != tcount) | ||
59 | return 1; | ||
60 | do { | ||
61 | ret = (*cs != *ct); | ||
62 | if (ret) | ||
63 | break; | ||
64 | cs++; | ||
65 | ct++; | ||
66 | tcount--; | ||
67 | } while (tcount); | ||
68 | return ret; | ||
69 | } | ||
70 | |||
50 | /* Name hashing routines. Initial hash value */ | 71 | /* Name hashing routines. Initial hash value */ |
51 | /* Hash courtesy of the R5 hash in reiserfs modulo sign bits */ | 72 | /* Hash courtesy of the R5 hash in reiserfs modulo sign bits */ |
52 | #define init_name_hash() 0 | 73 | #define init_name_hash() 0 |