diff options
Diffstat (limited to 'fs/f2fs/hash.c')
-rw-r--r-- | fs/f2fs/hash.c | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/fs/f2fs/hash.c b/fs/f2fs/hash.c index a60f04200f8b..6eb8d269b53b 100644 --- a/fs/f2fs/hash.c +++ b/fs/f2fs/hash.c | |||
@@ -42,7 +42,7 @@ static void TEA_transform(unsigned int buf[4], unsigned int const in[]) | |||
42 | buf[1] += b1; | 42 | buf[1] += b1; |
43 | } | 43 | } |
44 | 44 | ||
45 | static void str2hashbuf(const char *msg, int len, unsigned int *buf, int num) | 45 | static void str2hashbuf(const char *msg, size_t len, unsigned int *buf, int num) |
46 | { | 46 | { |
47 | unsigned pad, val; | 47 | unsigned pad, val; |
48 | int i; | 48 | int i; |
@@ -69,13 +69,17 @@ static void str2hashbuf(const char *msg, int len, unsigned int *buf, int num) | |||
69 | *buf++ = pad; | 69 | *buf++ = pad; |
70 | } | 70 | } |
71 | 71 | ||
72 | f2fs_hash_t f2fs_dentry_hash(const char *name, int len) | 72 | f2fs_hash_t f2fs_dentry_hash(const char *name, size_t len) |
73 | { | 73 | { |
74 | __u32 hash, minor_hash; | 74 | __u32 hash; |
75 | f2fs_hash_t f2fs_hash; | 75 | f2fs_hash_t f2fs_hash; |
76 | const char *p; | 76 | const char *p; |
77 | __u32 in[8], buf[4]; | 77 | __u32 in[8], buf[4]; |
78 | 78 | ||
79 | if ((len <= 2) && (name[0] == '.') && | ||
80 | (name[1] == '.' || name[1] == '\0')) | ||
81 | return 0; | ||
82 | |||
79 | /* Initialize the default seed for the hash checksum functions */ | 83 | /* Initialize the default seed for the hash checksum functions */ |
80 | buf[0] = 0x67452301; | 84 | buf[0] = 0x67452301; |
81 | buf[1] = 0xefcdab89; | 85 | buf[1] = 0xefcdab89; |
@@ -83,15 +87,15 @@ f2fs_hash_t f2fs_dentry_hash(const char *name, int len) | |||
83 | buf[3] = 0x10325476; | 87 | buf[3] = 0x10325476; |
84 | 88 | ||
85 | p = name; | 89 | p = name; |
86 | while (len > 0) { | 90 | while (1) { |
87 | str2hashbuf(p, len, in, 4); | 91 | str2hashbuf(p, len, in, 4); |
88 | TEA_transform(buf, in); | 92 | TEA_transform(buf, in); |
89 | len -= 16; | ||
90 | p += 16; | 93 | p += 16; |
94 | if (len <= 16) | ||
95 | break; | ||
96 | len -= 16; | ||
91 | } | 97 | } |
92 | hash = buf[0]; | 98 | hash = buf[0]; |
93 | minor_hash = buf[1]; | ||
94 | |||
95 | f2fs_hash = cpu_to_le32(hash & ~F2FS_HASH_COL_BIT); | 99 | f2fs_hash = cpu_to_le32(hash & ~F2FS_HASH_COL_BIT); |
96 | return f2fs_hash; | 100 | return f2fs_hash; |
97 | } | 101 | } |