Merge tag 'for-linus-5.11-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/rw...
[linux-2.6-microblaze.git] / fs / ubifs / dir.c
index 3c432f0..9a6b866 100644 (file)
@@ -203,6 +203,7 @@ static struct dentry *ubifs_lookup(struct inode *dir, struct dentry *dentry,
        dbg_gen("'%pd' in dir ino %lu", dentry, dir->i_ino);
 
        err = fscrypt_prepare_lookup(dir, dentry, &nm);
+       generic_set_encrypted_ci_d_ops(dentry);
        if (err == -ENOENT)
                return d_splice_alias(NULL, dentry);
        if (err)
@@ -270,6 +271,15 @@ done:
        return d_splice_alias(inode, dentry);
 }
 
+static int ubifs_prepare_create(struct inode *dir, struct dentry *dentry,
+                               struct fscrypt_name *nm)
+{
+       if (fscrypt_is_nokey_name(dentry))
+               return -ENOKEY;
+
+       return fscrypt_setup_filename(dir, &dentry->d_name, 0, nm);
+}
+
 static int ubifs_create(struct inode *dir, struct dentry *dentry, umode_t mode,
                        bool excl)
 {
@@ -293,7 +303,7 @@ static int ubifs_create(struct inode *dir, struct dentry *dentry, umode_t mode,
        if (err)
                return err;
 
-       err = fscrypt_setup_filename(dir, &dentry->d_name, 0, &nm);
+       err = ubifs_prepare_create(dir, dentry, &nm);
        if (err)
                goto out_budg;
 
@@ -505,7 +515,7 @@ static int ubifs_readdir(struct file *file, struct dir_context *ctx)
                return 0;
 
        if (encrypted) {
-               err = fscrypt_get_encryption_info(dir);
+               err = fscrypt_prepare_readdir(dir);
                if (err)
                        return err;
 
@@ -953,7 +963,7 @@ static int ubifs_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode)
        if (err)
                return err;
 
-       err = fscrypt_setup_filename(dir, &dentry->d_name, 0, &nm);
+       err = ubifs_prepare_create(dir, dentry, &nm);
        if (err)
                goto out_budg;
 
@@ -1038,7 +1048,7 @@ static int ubifs_mknod(struct inode *dir, struct dentry *dentry,
                return err;
        }
 
-       err = fscrypt_setup_filename(dir, &dentry->d_name, 0, &nm);
+       err = ubifs_prepare_create(dir, dentry, &nm);
        if (err) {
                kfree(dev);
                goto out_budg;
@@ -1122,7 +1132,7 @@ static int ubifs_symlink(struct inode *dir, struct dentry *dentry,
        if (err)
                return err;
 
-       err = fscrypt_setup_filename(dir, &dentry->d_name, 0, &nm);
+       err = ubifs_prepare_create(dir, dentry, &nm);
        if (err)
                goto out_budg;
 
@@ -1610,14 +1620,6 @@ int ubifs_getattr(const struct path *path, struct kstat *stat,
        return 0;
 }
 
-static int ubifs_dir_open(struct inode *dir, struct file *file)
-{
-       if (IS_ENCRYPTED(dir))
-               return fscrypt_get_encryption_info(dir) ? -EACCES : 0;
-
-       return 0;
-}
-
 const struct inode_operations ubifs_dir_inode_operations = {
        .lookup      = ubifs_lookup,
        .create      = ubifs_create,
@@ -1642,7 +1644,6 @@ const struct file_operations ubifs_dir_operations = {
        .iterate_shared = ubifs_readdir,
        .fsync          = ubifs_fsync,
        .unlocked_ioctl = ubifs_ioctl,
-       .open           = ubifs_dir_open,
 #ifdef CONFIG_COMPAT
        .compat_ioctl   = ubifs_compat_ioctl,
 #endif