diff options
author | Jaegeuk Kim <jaegeuk@kernel.org> | 2015-04-22 02:23:47 +0300 |
---|---|---|
committer | Jaegeuk Kim <jaegeuk@kernel.org> | 2015-05-29 01:41:49 +0300 |
commit | 0adda907f23df2e19355b58a20f0a7ff76587c6a (patch) | |
tree | 1ab172e639f055eddf80b6e679ba07445625e8c9 /fs/f2fs/f2fs.h | |
parent | 57e5055b0a5e33267b8be366ee52ce5cdc239bc7 (diff) | |
download | linux-0adda907f23df2e19355b58a20f0a7ff76587c6a.tar.xz |
f2fs crypto: add encryption key management facilities
This patch copies from encrypt_key.c in ext4, and modifies for f2fs.
Use GFP_NOFS, since _f2fs_get_encryption_info is called under f2fs_lock_op.
Signed-off-by: Michael Halcrow <mhalcrow@google.com>
Signed-off-by: Ildar Muslukhov <muslukhovi@gmail.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Diffstat (limited to 'fs/f2fs/f2fs.h')
-rw-r--r-- | fs/f2fs/f2fs.h | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h index b0490cb58b97..eb6440960964 100644 --- a/fs/f2fs/f2fs.h +++ b/fs/f2fs/f2fs.h @@ -1974,17 +1974,39 @@ int f2fs_decrypt(struct f2fs_crypto_ctx *, struct page *); int f2fs_decrypt_one(struct inode *, struct page *); void f2fs_end_io_crypto_work(struct f2fs_crypto_ctx *, struct bio *); +/* crypto_key.c */ +void f2fs_free_encryption_info(struct inode *); +int _f2fs_get_encryption_info(struct inode *inode); + #ifdef CONFIG_F2FS_FS_ENCRYPTION void f2fs_restore_and_release_control_page(struct page **); void f2fs_restore_control_page(struct page *); int f2fs_init_crypto(void); void f2fs_exit_crypto(void); + +int f2fs_has_encryption_key(struct inode *); + +static inline int f2fs_get_encryption_info(struct inode *inode) +{ + struct f2fs_crypt_info *ci = F2FS_I(inode)->i_crypt_info; + + if (!ci || + (ci->ci_keyring_key && + (ci->ci_keyring_key->flags & ((1 << KEY_FLAG_INVALIDATED) | + (1 << KEY_FLAG_REVOKED) | + (1 << KEY_FLAG_DEAD))))) + return _f2fs_get_encryption_info(inode); + return 0; +} #else static inline void f2fs_restore_and_release_control_page(struct page **p) { } static inline void f2fs_restore_control_page(struct page *p) { } static inline int f2fs_init_crypto(void) { return 0; } static inline void f2fs_exit_crypto(void) { } + +static inline int f2fs_has_encryption_key(struct inode *i) { return 0; } +static inline int f2fs_get_encryption_info(struct inode *i) { return 0; } #endif #endif |