fscrypt: trim down fscrypt_common.h
PATCH 1/1 fscrypt: trim down fscrypt_common.h
From: Eric Biggers <[email protected]>
fscrypt_common.h is only meant to include declarations that are exposed to filesystems both with and without encryption enabled. Trim it down a bit by removing stuff that is only needed inside fs/crypto/ itself, instead moving it into fscrypt_private.h or specific .c files.
Signed-off-by Eric Biggers <[email protected]>
--- fs/crypto/bio.c | 1 - fs/crypto/crypto.c | 1 + fs/crypto/fname.c | 12 ++++++++++++ fs/crypto/fscrypt_private.h | 22 +++++++++++++++++++++- fs/crypto/keyinfo.c | 2 ++ fs/crypto/policy.c | 1 + include/linux/fscrypt_common.h | 38 -------------------------------------- include/linux/fscrypt_supp.h | 1 + 8 files changed, 38 insertions(+), 40 deletions(-)
fs/crypto/bio.c +0 -1
@@ -22,7 +22,6 @@#include <linux/pagemap.h> #include <linux/module.h> #include <linux/bio.h> -#include <linux/namei.h> #include "fscrypt_private.h" /*
fs/crypto/crypto.c +1 -0
@@ -27,6 +27,7 @@#include <linux/dcache.h> #include <linux/namei.h> #include <crypto/aes.h> +#include <crypto/skcipher.h> #include "fscrypt_private.h" static unsigned int num_prealloc_crypto_pages =32 ;
fs/crypto/fname.c +12 -0
@@ -12,8 +12,20 @@#include <linux/scatterlist.h> #include <linux/ratelimit.h> +#include <crypto/skcipher.h> #include "fscrypt_private.h" +static inline bool fscrypt_is_dot_dotdot (const struct qstr *str) +{ +if (str->len ==1 && str->name[0 ] =='.' ) +return true; + +if (str->len ==2 && str->name[0 ] =='.' && str->name[1 ] =='.' ) +return true; + +return false; +} +/** * fname_crypt_complete() - completion callback for filename crypto * @req: The asynchronous cipher request context
fs/crypto/fscrypt_private.h +21 -1
@@ -12,7 +12,6 @@#define _FSCRYPT_PRIVATE_H#include <linux/fscrypt_supp.h> -#include <crypto/hash.h> /* Encryption parameters */ #define FS_IV_SIZE 16
@@ -78,6 +77,27 @@ struct fscrypt_completion_result {struct fscrypt_completion_result ecr = { \ COMPLETION_INITIALIZER_ONSTACK((ecr).completion), 0 } +static inline bool fscrypt_dummy_context_enabled (struct inode *inode) +{ +if (inode->i_sb->s_cop->dummy_context && + inode->i_sb->s_cop->dummy_context (inode)) +return true; +return false; +} + +static inline bool fscrypt_valid_enc_modes (u32 contents_mode, +u32 filenames_mode) +{ +if (contents_mode ==FS_ENCRYPTION_MODE_AES_128_CBC && + filenames_mode ==FS_ENCRYPTION_MODE_AES_128_CTS ) +return true; + +if (contents_mode ==FS_ENCRYPTION_MODE_AES_256_XTS && + filenames_mode ==FS_ENCRYPTION_MODE_AES_256_CTS ) +return true; + +return false; +}/* crypto.c */ extern int fscrypt_initialize (unsigned int cop_flags);
fs/crypto/keyinfo.c +2 -0
@@ -12,7 +12,9 @@#include <linux/scatterlist.h> #include <linux/ratelimit.h> #include <crypto/aes.h> +#include <crypto/hash.h> #include <crypto/sha.h> +#include <crypto/skcipher.h> #include "fscrypt_private.h" static struct crypto_shash *essiv_hash_tfm;
fs/crypto/policy.c +1 -0
@@ -11,6 +11,7 @@#include <linux/random.h> #include <linux/string.h> #include <linux/mount.h> +#include <linux/uaccess.h> #include "fscrypt_private.h" /*
include/linux/fscrypt_common.h +0 -38
@@ -10,13 +10,8 @@#ifndef _LINUX_FSCRYPT_COMMON_H#define _LINUX_FSCRYPT_COMMON_H -#include <linux/key.h> #include <linux/fs.h> #include <linux/mm.h> -#include <linux/bio.h> -#include <linux/dcache.h> -#include <crypto/skcipher.h> -#include <uapi/linux/fs.h> #define FS_CRYPTO_BLOCK_SIZE 16
@@ -86,39 +81,6 @@ struct fscrypt_operations {/* Maximum value for the third parameter of fscrypt_operations.set_context(). */ #define FSCRYPT_SET_CONTEXT_MAX_SIZE 28 -static inline bool fscrypt_dummy_context_enabled (struct inode *inode) -{ -if (inode->i_sb->s_cop->dummy_context && - inode->i_sb->s_cop->dummy_context (inode)) -return true; -return false; -} - -static inline bool fscrypt_valid_enc_modes (u32 contents_mode, -u32 filenames_mode) -{ -if (contents_mode ==FS_ENCRYPTION_MODE_AES_128_CBC && - filenames_mode ==FS_ENCRYPTION_MODE_AES_128_CTS ) -return true; - -if (contents_mode ==FS_ENCRYPTION_MODE_AES_256_XTS && - filenames_mode ==FS_ENCRYPTION_MODE_AES_256_CTS ) -return true; - -return false; -} - -static inline bool fscrypt_is_dot_dotdot (const struct qstr *str) -{ -if (str->len ==1 && str->name[0 ] =='.' ) -return true; - -if (str->len ==2 && str->name[0 ] =='.' && str->name[1 ] =='.' ) -return true; - -return false; -} -static inline struct page *fscrypt_control_page (struct page *page) {#if IS_ENABLED (CONFIG_FS_ENCRYPTION )
include/linux/fscrypt_supp.h +1 -0
@@ -8,6 +8,7 @@#define _LINUX_FSCRYPT_SUPP_H#include <linux/fscrypt_common.h> +#include <linux/slab.h> /* crypto.c */ extern struct kmem_cache *fscrypt_info_cachep;
Signature · 1 line
2.13.2.932.g7449e964c-goog