]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph-client.git/commitdiff
fscrypt: uninline and export fscrypt_require_key
authorJeff Layton <jlayton@kernel.org>
Fri, 27 Aug 2021 13:06:06 +0000 (09:06 -0400)
committerJeff Layton <jlayton@kernel.org>
Tue, 7 Dec 2021 15:32:46 +0000 (10:32 -0500)
ceph_atomic_open needs to be able to call this.

Signed-off-by: Jeff Layton <jlayton@kernel.org>
fs/crypto/fscrypt_private.h
fs/crypto/keysetup.c
include/linux/fscrypt.h

index 51e42767dbd6d5a1d6d6066aeeebbffd38afd500..89d5d85afdd5138492c548fc615465d01b57607f 100644 (file)
@@ -579,32 +579,6 @@ void fscrypt_hash_inode_number(struct fscrypt_info *ci,
 
 int fscrypt_get_encryption_info(struct inode *inode, bool allow_unsupported);
 
-/**
- * fscrypt_require_key() - require an inode's encryption key
- * @inode: the inode we need the key for
- *
- * If the inode is encrypted, set up its encryption key if not already done.
- * Then require that the key be present and return -ENOKEY otherwise.
- *
- * No locks are needed, and the key will live as long as the struct inode --- so
- * it won't go away from under you.
- *
- * Return: 0 on success, -ENOKEY if the key is missing, or another -errno code
- * if a problem occurred while setting up the encryption key.
- */
-static inline int fscrypt_require_key(struct inode *inode)
-{
-       if (IS_ENCRYPTED(inode)) {
-               int err = fscrypt_get_encryption_info(inode, false);
-
-               if (err)
-                       return err;
-               if (!fscrypt_has_encryption_key(inode))
-                       return -ENOKEY;
-       }
-       return 0;
-}
-
 /* keysetup_v1.c */
 
 void fscrypt_put_direct_key(struct fscrypt_direct_key *dk);
index eede186b04ce3b274b8cb7b9d9afdf8e1e45c7cc..7aeb0047d03d714a65f6c5ddf00bc864bca1c939 100644 (file)
@@ -792,3 +792,30 @@ int fscrypt_drop_inode(struct inode *inode)
        return !is_master_key_secret_present(&mk->mk_secret);
 }
 EXPORT_SYMBOL_GPL(fscrypt_drop_inode);
+
+/**
+ * fscrypt_require_key() - require an inode's encryption key
+ * @inode: the inode we need the key for
+ *
+ * If the inode is encrypted, set up its encryption key if not already done.
+ * Then require that the key be present and return -ENOKEY otherwise.
+ *
+ * No locks are needed, and the key will live as long as the struct inode --- so
+ * it won't go away from under you.
+ *
+ * Return: 0 on success, -ENOKEY if the key is missing, or another -errno code
+ * if a problem occurred while setting up the encryption key.
+ */
+int fscrypt_require_key(struct inode *inode)
+{
+       if (IS_ENCRYPTED(inode)) {
+               int err = fscrypt_get_encryption_info(inode, false);
+
+               if (err)
+                       return err;
+               if (!fscrypt_has_encryption_key(inode))
+                       return -ENOKEY;
+       }
+       return 0;
+}
+EXPORT_SYMBOL_GPL(fscrypt_require_key);
index 530433098f82bbd9c9482028eeae3d1d089f4b9f..7d3c670d0c6d40d4811fb1215fef4b75639cf8fc 100644 (file)
@@ -334,6 +334,7 @@ bool fscrypt_match_name(const struct fscrypt_name *fname,
                        const u8 *de_name, u32 de_name_len);
 u64 fscrypt_fname_siphash(const struct inode *dir, const struct qstr *name);
 int fscrypt_d_revalidate(struct dentry *dentry, unsigned int flags);
+int fscrypt_require_key(struct inode *inode);
 
 /* bio.c */
 void fscrypt_decrypt_bio(struct bio *bio);
@@ -601,6 +602,10 @@ static inline int fscrypt_d_revalidate(struct dentry *dentry,
        return 1;
 }
 
+static inline int fscrypt_require_key(struct inode *inode)
+{
+       return 0;
+}
 /* bio.c */
 static inline void fscrypt_decrypt_bio(struct bio *bio)
 {