blob: c4c6bf2c390e0550198e58040ae6c9918571adb0 [file] [log] [blame]
Hyojun Kim63da4202017-10-06 17:10:08 -07001/*
2 * fscrypt_notsupp.h
3 *
4 * This stubs out the fscrypt functions for filesystems configured without
5 * encryption support.
Jaegeuk Kim8dec0742017-06-22 12:14:40 -07006 *
7 * Do not include this file directly. Use fscrypt.h instead!
Hyojun Kim63da4202017-10-06 17:10:08 -07008 */
Jaegeuk Kim8dec0742017-06-22 12:14:40 -07009#ifndef _LINUX_FSCRYPT_H
10#error "Incorrect include of linux/fscrypt_notsupp.h!"
11#endif
Hyojun Kim63da4202017-10-06 17:10:08 -070012
13#ifndef _LINUX_FSCRYPT_NOTSUPP_H
14#define _LINUX_FSCRYPT_NOTSUPP_H
15
Hyojun Kim63da4202017-10-06 17:10:08 -070016/* crypto.c */
17static inline struct fscrypt_ctx *fscrypt_get_ctx(const struct inode *inode,
18 gfp_t gfp_flags)
19{
20 return ERR_PTR(-EOPNOTSUPP);
21}
22
23static inline void fscrypt_release_ctx(struct fscrypt_ctx *ctx)
24{
25 return;
26}
27
28static inline struct page *fscrypt_encrypt_page(const struct inode *inode,
29 struct page *page,
30 unsigned int len,
31 unsigned int offs,
32 u64 lblk_num, gfp_t gfp_flags)
33{
34 return ERR_PTR(-EOPNOTSUPP);
35}
36
37static inline int fscrypt_decrypt_page(const struct inode *inode,
38 struct page *page,
39 unsigned int len, unsigned int offs,
40 u64 lblk_num)
41{
42 return -EOPNOTSUPP;
43}
44
45
46static inline void fscrypt_restore_control_page(struct page *page)
47{
48 return;
49}
50
51static inline void fscrypt_set_d_op(struct dentry *dentry)
52{
53 return;
54}
55
56static inline void fscrypt_set_encrypted_dentry(struct dentry *dentry)
57{
58 return;
59}
60
61/* policy.c */
62static inline int fscrypt_ioctl_set_policy(struct file *filp,
63 const void __user *arg)
64{
65 return -EOPNOTSUPP;
66}
67
68static inline int fscrypt_ioctl_get_policy(struct file *filp, void __user *arg)
69{
70 return -EOPNOTSUPP;
71}
72
73static inline int fscrypt_has_permitted_context(struct inode *parent,
74 struct inode *child)
75{
76 return 0;
77}
78
79static inline int fscrypt_inherit_context(struct inode *parent,
80 struct inode *child,
81 void *fs_data, bool preload)
82{
83 return -EOPNOTSUPP;
84}
85
86/* keyinfo.c */
87static inline int fscrypt_get_encryption_info(struct inode *inode)
88{
89 return -EOPNOTSUPP;
90}
91
92static inline void fscrypt_put_encryption_info(struct inode *inode,
93 struct fscrypt_info *ci)
94{
95 return;
96}
97
98 /* fname.c */
99static inline int fscrypt_setup_filename(struct inode *dir,
100 const struct qstr *iname,
101 int lookup, struct fscrypt_name *fname)
102{
Jaegeuk Kim8dec0742017-06-22 12:14:40 -0700103 if (IS_ENCRYPTED(dir))
Hyojun Kim63da4202017-10-06 17:10:08 -0700104 return -EOPNOTSUPP;
105
106 memset(fname, 0, sizeof(struct fscrypt_name));
107 fname->usr_fname = iname;
108 fname->disk_name.name = (unsigned char *)iname->name;
109 fname->disk_name.len = iname->len;
110 return 0;
111}
112
113static inline void fscrypt_free_filename(struct fscrypt_name *fname)
114{
115 return;
116}
117
118static inline u32 fscrypt_fname_encrypted_size(const struct inode *inode,
119 u32 ilen)
120{
121 /* never happens */
122 WARN_ON(1);
123 return 0;
124}
125
126static inline int fscrypt_fname_alloc_buffer(const struct inode *inode,
127 u32 ilen,
128 struct fscrypt_str *crypto_str)
129{
130 return -EOPNOTSUPP;
131}
132
133static inline void fscrypt_fname_free_buffer(struct fscrypt_str *crypto_str)
134{
135 return;
136}
137
138static inline int fscrypt_fname_disk_to_usr(struct inode *inode,
139 u32 hash, u32 minor_hash,
140 const struct fscrypt_str *iname,
141 struct fscrypt_str *oname)
142{
143 return -EOPNOTSUPP;
144}
145
146static inline int fscrypt_fname_usr_to_disk(struct inode *inode,
147 const struct qstr *iname,
148 struct fscrypt_str *oname)
149{
150 return -EOPNOTSUPP;
151}
152
153static inline bool fscrypt_match_name(const struct fscrypt_name *fname,
154 const u8 *de_name, u32 de_name_len)
155{
156 /* Encryption support disabled; use standard comparison */
157 if (de_name_len != fname->disk_name.len)
158 return false;
159 return !memcmp(de_name, fname->disk_name.name, fname->disk_name.len);
160}
161
162/* bio.c */
163static inline void fscrypt_decrypt_bio_pages(struct fscrypt_ctx *ctx,
164 struct bio *bio)
165{
166 return;
167}
168
169static inline void fscrypt_pullback_bio_page(struct page **page, bool restore)
170{
171 return;
172}
173
174static inline int fscrypt_zeroout_range(const struct inode *inode, pgoff_t lblk,
175 sector_t pblk, unsigned int len)
176{
177 return -EOPNOTSUPP;
178}
179
Jaegeuk Kim8dec0742017-06-22 12:14:40 -0700180/* hooks.c */
181
182static inline int fscrypt_file_open(struct inode *inode, struct file *filp)
183{
184 if (IS_ENCRYPTED(inode))
185 return -EOPNOTSUPP;
186 return 0;
187}
188
189static inline int __fscrypt_prepare_link(struct inode *inode,
190 struct inode *dir)
191{
192 return -EOPNOTSUPP;
193}
194
195static inline int __fscrypt_prepare_rename(struct inode *old_dir,
196 struct dentry *old_dentry,
197 struct inode *new_dir,
198 struct dentry *new_dentry,
199 unsigned int flags)
200{
201 return -EOPNOTSUPP;
202}
203
204static inline int __fscrypt_prepare_lookup(struct inode *dir,
205 struct dentry *dentry)
206{
207 return -EOPNOTSUPP;
208}
209
Hyojun Kim63da4202017-10-06 17:10:08 -0700210#endif /* _LINUX_FSCRYPT_NOTSUPP_H */