aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'fs/f2fs/dir.c')
-rw-r--r--fs/f2fs/dir.c32
1 files changed, 21 insertions, 11 deletions
diff --git a/fs/f2fs/dir.c b/fs/f2fs/dir.c
index 7c1678ba8f92..60972a559685 100644
--- a/fs/f2fs/dir.c
+++ b/fs/f2fs/dir.c
@@ -124,19 +124,29 @@ struct f2fs_dir_entry *find_target_dentry(struct f2fs_filename *fname,
124 124
125 de = &d->dentry[bit_pos]; 125 de = &d->dentry[bit_pos];
126 126
127 /* encrypted case */ 127 if (de->hash_code != namehash)
128 goto not_match;
129
128 de_name.name = d->filename[bit_pos]; 130 de_name.name = d->filename[bit_pos];
129 de_name.len = le16_to_cpu(de->name_len); 131 de_name.len = le16_to_cpu(de->name_len);
130 132
131 /* show encrypted name */ 133#ifdef CONFIG_F2FS_FS_ENCRYPTION
132 if (fname->hash) { 134 if (unlikely(!name->name)) {
133 if (de->hash_code == fname->hash) 135 if (fname->usr_fname->name[0] == '_') {
134 goto found; 136 if (de_name.len > 32 &&
135 } else if (de_name.len == name->len && 137 !memcmp(de_name.name + ((de_name.len - 17) & ~15),
136 de->hash_code == namehash && 138 fname->crypto_buf.name + 8, 16))
137 !memcmp(de_name.name, name->name, name->len)) 139 goto found;
140 goto not_match;
141 }
142 name->name = fname->crypto_buf.name;
143 name->len = fname->crypto_buf.len;
144 }
145#endif
146 if (de_name.len == name->len &&
147 !memcmp(de_name.name, name->name, name->len))
138 goto found; 148 goto found;
139 149not_match:
140 if (max_slots && max_len > *max_slots) 150 if (max_slots && max_len > *max_slots)
141 *max_slots = max_len; 151 *max_slots = max_len;
142 max_len = 0; 152 max_len = 0;
@@ -170,7 +180,7 @@ static struct f2fs_dir_entry *find_in_level(struct inode *dir,
170 int max_slots; 180 int max_slots;
171 f2fs_hash_t namehash; 181 f2fs_hash_t namehash;
172 182
173 namehash = f2fs_dentry_hash(&name); 183 namehash = f2fs_dentry_hash(&name, fname);
174 184
175 f2fs_bug_on(F2FS_I_SB(dir), level > MAX_DIR_HASH_DEPTH); 185 f2fs_bug_on(F2FS_I_SB(dir), level > MAX_DIR_HASH_DEPTH);
176 186
@@ -547,7 +557,7 @@ int __f2fs_add_link(struct inode *dir, const struct qstr *name,
547 557
548 level = 0; 558 level = 0;
549 slots = GET_DENTRY_SLOTS(new_name.len); 559 slots = GET_DENTRY_SLOTS(new_name.len);
550 dentry_hash = f2fs_dentry_hash(&new_name); 560 dentry_hash = f2fs_dentry_hash(&new_name, NULL);
551 561
552 current_depth = F2FS_I(dir)->i_current_depth; 562 current_depth = F2FS_I(dir)->i_current_depth;
553 if (F2FS_I(dir)->chash == dentry_hash) { 563 if (F2FS_I(dir)->chash == dentry_hash) {