diff options
Diffstat (limited to 'include/linux/fscrypt_supp.h')
-rw-r--r-- | include/linux/fscrypt_supp.h | 68 |
1 files changed, 63 insertions, 5 deletions
diff --git a/include/linux/fscrypt_supp.h b/include/linux/fscrypt_supp.h index cf9e9fc02f0a..477a7a6504d2 100644 --- a/include/linux/fscrypt_supp.h +++ b/include/linux/fscrypt_supp.h | |||
@@ -11,8 +11,54 @@ | |||
11 | #ifndef _LINUX_FSCRYPT_SUPP_H | 11 | #ifndef _LINUX_FSCRYPT_SUPP_H |
12 | #define _LINUX_FSCRYPT_SUPP_H | 12 | #define _LINUX_FSCRYPT_SUPP_H |
13 | 13 | ||
14 | #include <linux/mm.h> | ||
15 | #include <linux/slab.h> | ||
16 | |||
17 | /* | ||
18 | * fscrypt superblock flags | ||
19 | */ | ||
20 | #define FS_CFLG_OWN_PAGES (1U << 1) | ||
21 | |||
22 | /* | ||
23 | * crypto operations for filesystems | ||
24 | */ | ||
25 | struct fscrypt_operations { | ||
26 | unsigned int flags; | ||
27 | const char *key_prefix; | ||
28 | int (*get_context)(struct inode *, void *, size_t); | ||
29 | int (*set_context)(struct inode *, const void *, size_t, void *); | ||
30 | bool (*dummy_context)(struct inode *); | ||
31 | bool (*empty_dir)(struct inode *); | ||
32 | unsigned (*max_namelen)(struct inode *); | ||
33 | }; | ||
34 | |||
35 | struct fscrypt_ctx { | ||
36 | union { | ||
37 | struct { | ||
38 | struct page *bounce_page; /* Ciphertext page */ | ||
39 | struct page *control_page; /* Original page */ | ||
40 | } w; | ||
41 | struct { | ||
42 | struct bio *bio; | ||
43 | struct work_struct work; | ||
44 | } r; | ||
45 | struct list_head free_list; /* Free list */ | ||
46 | }; | ||
47 | u8 flags; /* Flags */ | ||
48 | }; | ||
49 | |||
50 | static inline bool fscrypt_has_encryption_key(const struct inode *inode) | ||
51 | { | ||
52 | return (inode->i_crypt_info != NULL); | ||
53 | } | ||
54 | |||
55 | static inline bool fscrypt_dummy_context_enabled(struct inode *inode) | ||
56 | { | ||
57 | return inode->i_sb->s_cop->dummy_context && | ||
58 | inode->i_sb->s_cop->dummy_context(inode); | ||
59 | } | ||
60 | |||
14 | /* crypto.c */ | 61 | /* crypto.c */ |
15 | extern struct kmem_cache *fscrypt_info_cachep; | ||
16 | extern struct fscrypt_ctx *fscrypt_get_ctx(const struct inode *, gfp_t); | 62 | extern struct fscrypt_ctx *fscrypt_get_ctx(const struct inode *, gfp_t); |
17 | extern void fscrypt_release_ctx(struct fscrypt_ctx *); | 63 | extern void fscrypt_release_ctx(struct fscrypt_ctx *); |
18 | extern struct page *fscrypt_encrypt_page(const struct inode *, struct page *, | 64 | extern struct page *fscrypt_encrypt_page(const struct inode *, struct page *, |
@@ -20,6 +66,12 @@ extern struct page *fscrypt_encrypt_page(const struct inode *, struct page *, | |||
20 | u64, gfp_t); | 66 | u64, gfp_t); |
21 | extern int fscrypt_decrypt_page(const struct inode *, struct page *, unsigned int, | 67 | extern int fscrypt_decrypt_page(const struct inode *, struct page *, unsigned int, |
22 | unsigned int, u64); | 68 | unsigned int, u64); |
69 | |||
70 | static inline struct page *fscrypt_control_page(struct page *page) | ||
71 | { | ||
72 | return ((struct fscrypt_ctx *)page_private(page))->w.control_page; | ||
73 | } | ||
74 | |||
23 | extern void fscrypt_restore_control_page(struct page *); | 75 | extern void fscrypt_restore_control_page(struct page *); |
24 | 76 | ||
25 | extern const struct dentry_operations fscrypt_d_ops; | 77 | extern const struct dentry_operations fscrypt_d_ops; |
@@ -44,7 +96,7 @@ extern int fscrypt_inherit_context(struct inode *, struct inode *, | |||
44 | void *, bool); | 96 | void *, bool); |
45 | /* keyinfo.c */ | 97 | /* keyinfo.c */ |
46 | extern int fscrypt_get_encryption_info(struct inode *); | 98 | extern int fscrypt_get_encryption_info(struct inode *); |
47 | extern void fscrypt_put_encryption_info(struct inode *, struct fscrypt_info *); | 99 | extern void fscrypt_put_encryption_info(struct inode *); |
48 | 100 | ||
49 | /* fname.c */ | 101 | /* fname.c */ |
50 | extern int fscrypt_setup_filename(struct inode *, const struct qstr *, | 102 | extern int fscrypt_setup_filename(struct inode *, const struct qstr *, |
@@ -55,14 +107,11 @@ static inline void fscrypt_free_filename(struct fscrypt_name *fname) | |||
55 | kfree(fname->crypto_buf.name); | 107 | kfree(fname->crypto_buf.name); |
56 | } | 108 | } |
57 | 109 | ||
58 | extern u32 fscrypt_fname_encrypted_size(const struct inode *, u32); | ||
59 | extern int fscrypt_fname_alloc_buffer(const struct inode *, u32, | 110 | extern int fscrypt_fname_alloc_buffer(const struct inode *, u32, |
60 | struct fscrypt_str *); | 111 | struct fscrypt_str *); |
61 | extern void fscrypt_fname_free_buffer(struct fscrypt_str *); | 112 | extern void fscrypt_fname_free_buffer(struct fscrypt_str *); |
62 | extern int fscrypt_fname_disk_to_usr(struct inode *, u32, u32, | 113 | extern int fscrypt_fname_disk_to_usr(struct inode *, u32, u32, |
63 | const struct fscrypt_str *, struct fscrypt_str *); | 114 | const struct fscrypt_str *, struct fscrypt_str *); |
64 | extern int fscrypt_fname_usr_to_disk(struct inode *, const struct qstr *, | ||
65 | struct fscrypt_str *); | ||
66 | 115 | ||
67 | #define FSCRYPT_FNAME_MAX_UNDIGESTED_SIZE 32 | 116 | #define FSCRYPT_FNAME_MAX_UNDIGESTED_SIZE 32 |
68 | 117 | ||
@@ -153,5 +202,14 @@ extern int __fscrypt_prepare_rename(struct inode *old_dir, | |||
153 | struct dentry *new_dentry, | 202 | struct dentry *new_dentry, |
154 | unsigned int flags); | 203 | unsigned int flags); |
155 | extern int __fscrypt_prepare_lookup(struct inode *dir, struct dentry *dentry); | 204 | extern int __fscrypt_prepare_lookup(struct inode *dir, struct dentry *dentry); |
205 | extern int __fscrypt_prepare_symlink(struct inode *dir, unsigned int len, | ||
206 | unsigned int max_len, | ||
207 | struct fscrypt_str *disk_link); | ||
208 | extern int __fscrypt_encrypt_symlink(struct inode *inode, const char *target, | ||
209 | unsigned int len, | ||
210 | struct fscrypt_str *disk_link); | ||
211 | extern const char *fscrypt_get_symlink(struct inode *inode, const void *caddr, | ||
212 | unsigned int max_size, | ||
213 | struct delayed_call *done); | ||
156 | 214 | ||
157 | #endif /* _LINUX_FSCRYPT_SUPP_H */ | 215 | #endif /* _LINUX_FSCRYPT_SUPP_H */ |