]> asedeno.scripts.mit.edu Git - linux.git/blobdiff - fs/f2fs/dir.c
Merge tag 'fscrypt_for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tytso...
[linux.git] / fs / f2fs / dir.c
index 8d5c62b07b283f53e90ded2366c8bb9375409fa2..e640870528349ecd67dae9bd4688bedc4fa84333 100644 (file)
@@ -111,8 +111,6 @@ struct f2fs_dir_entry *find_target_dentry(struct fscrypt_name *fname,
        struct f2fs_dir_entry *de;
        unsigned long bit_pos = 0;
        int max_len = 0;
-       struct fscrypt_str de_name = FSTR_INIT(NULL, 0);
-       struct fscrypt_str *name = &fname->disk_name;
 
        if (max_slots)
                *max_slots = 0;
@@ -130,17 +128,9 @@ struct f2fs_dir_entry *find_target_dentry(struct fscrypt_name *fname,
                        continue;
                }
 
-               /* encrypted case */
-               de_name.name = d->filename[bit_pos];
-               de_name.len = le16_to_cpu(de->name_len);
-
-               /* show encrypted name */
-               if (fname->hash) {
-                       if (de->hash_code == cpu_to_le32(fname->hash))
-                               goto found;
-               } else if (de_name.len == name->len &&
-                       de->hash_code == namehash &&
-                       !memcmp(de_name.name, name->name, name->len))
+               if (de->hash_code == namehash &&
+                   fscrypt_match_name(fname, d->filename[bit_pos],
+                                      le16_to_cpu(de->name_len)))
                        goto found;
 
                if (max_slots && max_len > *max_slots)
@@ -170,12 +160,7 @@ static struct f2fs_dir_entry *find_in_level(struct inode *dir,
        struct f2fs_dir_entry *de = NULL;
        bool room = false;
        int max_slots;
-       f2fs_hash_t namehash;
-
-       if(fname->hash)
-               namehash = cpu_to_le32(fname->hash);
-       else
-               namehash = f2fs_dentry_hash(&name);
+       f2fs_hash_t namehash = f2fs_dentry_hash(&name, fname);
 
        nbucket = dir_buckets(level, F2FS_I(dir)->i_dir_level);
        nblock = bucket_blocks(level);
@@ -542,7 +527,7 @@ int f2fs_add_regular_entry(struct inode *dir, const struct qstr *new_name,
 
        level = 0;
        slots = GET_DENTRY_SLOTS(new_name->len);
-       dentry_hash = f2fs_dentry_hash(new_name);
+       dentry_hash = f2fs_dentry_hash(new_name, NULL);
 
        current_depth = F2FS_I(dir)->i_current_depth;
        if (F2FS_I(dir)->chash == dentry_hash) {