aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/fscrypt_supp.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/linux/fscrypt_supp.h')
-rw-r--r--include/linux/fscrypt_supp.h68
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 */
25struct 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
35struct 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
50static inline bool fscrypt_has_encryption_key(const struct inode *inode)
51{
52 return (inode->i_crypt_info != NULL);
53}
54
55static 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 */
15extern struct kmem_cache *fscrypt_info_cachep;
16extern struct fscrypt_ctx *fscrypt_get_ctx(const struct inode *, gfp_t); 62extern struct fscrypt_ctx *fscrypt_get_ctx(const struct inode *, gfp_t);
17extern void fscrypt_release_ctx(struct fscrypt_ctx *); 63extern void fscrypt_release_ctx(struct fscrypt_ctx *);
18extern struct page *fscrypt_encrypt_page(const struct inode *, struct page *, 64extern 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);
21extern int fscrypt_decrypt_page(const struct inode *, struct page *, unsigned int, 67extern int fscrypt_decrypt_page(const struct inode *, struct page *, unsigned int,
22 unsigned int, u64); 68 unsigned int, u64);
69
70static inline struct page *fscrypt_control_page(struct page *page)
71{
72 return ((struct fscrypt_ctx *)page_private(page))->w.control_page;
73}
74
23extern void fscrypt_restore_control_page(struct page *); 75extern void fscrypt_restore_control_page(struct page *);
24 76
25extern const struct dentry_operations fscrypt_d_ops; 77extern 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 */
46extern int fscrypt_get_encryption_info(struct inode *); 98extern int fscrypt_get_encryption_info(struct inode *);
47extern void fscrypt_put_encryption_info(struct inode *, struct fscrypt_info *); 99extern void fscrypt_put_encryption_info(struct inode *);
48 100
49/* fname.c */ 101/* fname.c */
50extern int fscrypt_setup_filename(struct inode *, const struct qstr *, 102extern 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
58extern u32 fscrypt_fname_encrypted_size(const struct inode *, u32);
59extern int fscrypt_fname_alloc_buffer(const struct inode *, u32, 110extern int fscrypt_fname_alloc_buffer(const struct inode *, u32,
60 struct fscrypt_str *); 111 struct fscrypt_str *);
61extern void fscrypt_fname_free_buffer(struct fscrypt_str *); 112extern void fscrypt_fname_free_buffer(struct fscrypt_str *);
62extern int fscrypt_fname_disk_to_usr(struct inode *, u32, u32, 113extern 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 *);
64extern 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);
155extern int __fscrypt_prepare_lookup(struct inode *dir, struct dentry *dentry); 204extern int __fscrypt_prepare_lookup(struct inode *dir, struct dentry *dentry);
205extern int __fscrypt_prepare_symlink(struct inode *dir, unsigned int len,
206 unsigned int max_len,
207 struct fscrypt_str *disk_link);
208extern int __fscrypt_encrypt_symlink(struct inode *inode, const char *target,
209 unsigned int len,
210 struct fscrypt_str *disk_link);
211extern 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 */