diff options
author | Jaegeuk Kim <jaegeuk@kernel.org> | 2015-04-26 00:12:50 -0700 |
---|---|---|
committer | Jaegeuk Kim <jaegeuk@kernel.org> | 2015-05-28 15:41:50 -0700 |
commit | 6b3bd08f93a849edd56595391a54100d607ad7e4 (patch) | |
tree | 2f6f67598ee7731fe489b47194b370e4e935a418 /fs/f2fs/f2fs.h | |
parent | 0adda907f23df2e19355b58a20f0a7ff76587c6a (diff) | |
download | linux-6b3bd08f93a849edd56595391a54100d607ad7e4.tar.bz2 |
f2fs crypto: filename encryption facilities
This patch adds filename encryption infra.
Most of codes are copied from ext4 part, but changed to adjust f2fs
directory structure.
Signed-off-by: Uday Savagaonkar <savagaon@google.com>
Signed-off-by: Ildar Muslukhov <ildarm@google.com>
Signed-off-by: Michael Halcrow <mhalcrow@google.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 | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h index eb6440960964..98ce1ddf7186 100644 --- a/fs/f2fs/f2fs.h +++ b/fs/f2fs/f2fs.h @@ -257,6 +257,25 @@ static inline bool __has_cursum_space(struct f2fs_summary_block *sum, int size, * For INODE and NODE manager */ /* for directory operations */ +struct f2fs_str { + unsigned char *name; + u32 len; +}; + +struct f2fs_filename { + const struct qstr *usr_fname; + struct f2fs_str disk_name; + f2fs_hash_t hash; +#ifdef CONFIG_F2FS_FS_ENCRYPTION + struct f2fs_str crypto_buf; +#endif +}; + +#define FSTR_INIT(n, l) { .name = n, .len = l } +#define FSTR_TO_QSTR(f) QSTR_INIT((f)->name, (f)->len) +#define fname_name(p) ((p)->disk_name.name) +#define fname_len(p) ((p)->disk_name.len) + struct f2fs_dentry_ptr { const void *bitmap; struct f2fs_dir_entry *dentry; @@ -1978,6 +1997,15 @@ void f2fs_end_io_crypto_work(struct f2fs_crypto_ctx *, struct bio *); void f2fs_free_encryption_info(struct inode *); int _f2fs_get_encryption_info(struct inode *inode); +/* crypto_fname.c */ +bool f2fs_valid_filenames_enc_mode(uint32_t); +u32 f2fs_fname_crypto_round_up(u32, u32); +int f2fs_fname_crypto_alloc_buffer(struct inode *, u32, struct f2fs_str *); +int f2fs_fname_disk_to_usr(struct inode *, f2fs_hash_t *, + const struct f2fs_str *, struct f2fs_str *); +int f2fs_fname_usr_to_disk(struct inode *, const struct qstr *, + struct f2fs_str *); + #ifdef CONFIG_F2FS_FS_ENCRYPTION void f2fs_restore_and_release_control_page(struct page **); void f2fs_restore_control_page(struct page *); @@ -1999,6 +2027,12 @@ static inline int f2fs_get_encryption_info(struct inode *inode) return _f2fs_get_encryption_info(inode); return 0; } + +int f2fs_setup_fname_crypto(struct inode *); +void f2fs_fname_crypto_free_buffer(struct f2fs_str *); +int f2fs_fname_setup_filename(struct inode *, const struct qstr *, + int lookup, struct f2fs_filename *); +void f2fs_fname_free_filename(struct f2fs_filename *); #else static inline void f2fs_restore_and_release_control_page(struct page **p) { } static inline void f2fs_restore_control_page(struct page *p) { } @@ -2008,5 +2042,21 @@ 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; } + +static inline int f2fs_setup_fname_crypto(struct inode *i) { return 0; } +static inline void f2fs_fname_crypto_free_buffer(struct f2fs_str *p) { } + +static inline int f2fs_fname_setup_filename(struct inode *dir, + const struct qstr *iname, + int lookup, struct f2fs_filename *fname) +{ + memset(fname, 0, sizeof(struct f2fs_filename)); + fname->usr_fname = iname; + fname->disk_name.name = (unsigned char *)iname->name; + fname->disk_name.len = iname->len; + return 0; +} + +static inline void f2fs_fname_free_filename(struct f2fs_filename *fname) { } #endif #endif |