blob: 6f97714fbd8838edfc5a663b360b80d0a23d3d19 [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
Jaegeuk Kimd9197652018-01-05 10:44:52 -080016static inline bool fscrypt_has_encryption_key(const struct inode *inode)
17{
18 return false;
19}
20
21static inline bool fscrypt_dummy_context_enabled(struct inode *inode)
22{
23 return false;
24}
25
Hyojun Kim63da4202017-10-06 17:10:08 -070026/* crypto.c */
Eric Biggers823fd562018-04-18 11:09:47 -070027static inline void fscrypt_enqueue_decrypt_work(struct work_struct *work)
28{
29}
30
Hyojun Kim63da4202017-10-06 17:10:08 -070031static inline struct fscrypt_ctx *fscrypt_get_ctx(const struct inode *inode,
32 gfp_t gfp_flags)
33{
34 return ERR_PTR(-EOPNOTSUPP);
35}
36
37static inline void fscrypt_release_ctx(struct fscrypt_ctx *ctx)
38{
39 return;
40}
41
42static inline struct page *fscrypt_encrypt_page(const struct inode *inode,
43 struct page *page,
44 unsigned int len,
45 unsigned int offs,
46 u64 lblk_num, gfp_t gfp_flags)
47{
48 return ERR_PTR(-EOPNOTSUPP);
49}
50
51static inline int fscrypt_decrypt_page(const struct inode *inode,
52 struct page *page,
53 unsigned int len, unsigned int offs,
54 u64 lblk_num)
55{
56 return -EOPNOTSUPP;
57}
58
Jaegeuk Kimd9197652018-01-05 10:44:52 -080059static inline struct page *fscrypt_control_page(struct page *page)
60{
61 WARN_ON_ONCE(1);
62 return ERR_PTR(-EINVAL);
63}
Hyojun Kim63da4202017-10-06 17:10:08 -070064
65static inline void fscrypt_restore_control_page(struct page *page)
66{
67 return;
68}
69
70static inline void fscrypt_set_d_op(struct dentry *dentry)
71{
72 return;
73}
74
75static inline void fscrypt_set_encrypted_dentry(struct dentry *dentry)
76{
77 return;
78}
79
80/* policy.c */
81static inline int fscrypt_ioctl_set_policy(struct file *filp,
82 const void __user *arg)
83{
84 return -EOPNOTSUPP;
85}
86
87static inline int fscrypt_ioctl_get_policy(struct file *filp, void __user *arg)
88{
89 return -EOPNOTSUPP;
90}
91
92static inline int fscrypt_has_permitted_context(struct inode *parent,
93 struct inode *child)
94{
95 return 0;
96}
97
98static inline int fscrypt_inherit_context(struct inode *parent,
99 struct inode *child,
100 void *fs_data, bool preload)
101{
102 return -EOPNOTSUPP;
103}
104
105/* keyinfo.c */
106static inline int fscrypt_get_encryption_info(struct inode *inode)
107{
108 return -EOPNOTSUPP;
109}
110
Jaegeuk Kimd9197652018-01-05 10:44:52 -0800111static inline void fscrypt_put_encryption_info(struct inode *inode)
Hyojun Kim63da4202017-10-06 17:10:08 -0700112{
113 return;
114}
115
116 /* fname.c */
117static inline int fscrypt_setup_filename(struct inode *dir,
118 const struct qstr *iname,
119 int lookup, struct fscrypt_name *fname)
120{
Jaegeuk Kim8dec0742017-06-22 12:14:40 -0700121 if (IS_ENCRYPTED(dir))
Hyojun Kim63da4202017-10-06 17:10:08 -0700122 return -EOPNOTSUPP;
123
124 memset(fname, 0, sizeof(struct fscrypt_name));
125 fname->usr_fname = iname;
126 fname->disk_name.name = (unsigned char *)iname->name;
127 fname->disk_name.len = iname->len;
128 return 0;
129}
130
131static inline void fscrypt_free_filename(struct fscrypt_name *fname)
132{
133 return;
134}
135
Hyojun Kim63da4202017-10-06 17:10:08 -0700136static inline int fscrypt_fname_alloc_buffer(const struct inode *inode,
Jaegeuk Kimd9197652018-01-05 10:44:52 -0800137 u32 max_encrypted_len,
Hyojun Kim63da4202017-10-06 17:10:08 -0700138 struct fscrypt_str *crypto_str)
139{
140 return -EOPNOTSUPP;
141}
142
143static inline void fscrypt_fname_free_buffer(struct fscrypt_str *crypto_str)
144{
145 return;
146}
147
148static inline int fscrypt_fname_disk_to_usr(struct inode *inode,
149 u32 hash, u32 minor_hash,
150 const struct fscrypt_str *iname,
151 struct fscrypt_str *oname)
152{
153 return -EOPNOTSUPP;
154}
155
Hyojun Kim63da4202017-10-06 17:10:08 -0700156static inline bool fscrypt_match_name(const struct fscrypt_name *fname,
157 const u8 *de_name, u32 de_name_len)
158{
159 /* Encryption support disabled; use standard comparison */
160 if (de_name_len != fname->disk_name.len)
161 return false;
162 return !memcmp(de_name, fname->disk_name.name, fname->disk_name.len);
163}
164
165/* bio.c */
Eric Biggers823fd562018-04-18 11:09:47 -0700166static inline void fscrypt_decrypt_bio(struct bio *bio)
Hyojun Kim63da4202017-10-06 17:10:08 -0700167{
Eric Biggers823fd562018-04-18 11:09:47 -0700168}
169
170static inline void fscrypt_enqueue_decrypt_bio(struct fscrypt_ctx *ctx,
171 struct bio *bio)
172{
Hyojun Kim63da4202017-10-06 17:10:08 -0700173}
174
175static inline void fscrypt_pullback_bio_page(struct page **page, bool restore)
176{
177 return;
178}
179
180static inline int fscrypt_zeroout_range(const struct inode *inode, pgoff_t lblk,
181 sector_t pblk, unsigned int len)
182{
183 return -EOPNOTSUPP;
184}
185
Jaegeuk Kim8dec0742017-06-22 12:14:40 -0700186/* hooks.c */
187
188static inline int fscrypt_file_open(struct inode *inode, struct file *filp)
189{
190 if (IS_ENCRYPTED(inode))
191 return -EOPNOTSUPP;
192 return 0;
193}
194
195static inline int __fscrypt_prepare_link(struct inode *inode,
196 struct inode *dir)
197{
198 return -EOPNOTSUPP;
199}
200
201static inline int __fscrypt_prepare_rename(struct inode *old_dir,
202 struct dentry *old_dentry,
203 struct inode *new_dir,
204 struct dentry *new_dentry,
205 unsigned int flags)
206{
207 return -EOPNOTSUPP;
208}
209
210static inline int __fscrypt_prepare_lookup(struct inode *dir,
211 struct dentry *dentry)
212{
213 return -EOPNOTSUPP;
214}
215
Jaegeuk Kimd9197652018-01-05 10:44:52 -0800216static inline int __fscrypt_prepare_symlink(struct inode *dir,
217 unsigned int len,
218 unsigned int max_len,
219 struct fscrypt_str *disk_link)
220{
221 return -EOPNOTSUPP;
222}
223
224static inline int __fscrypt_encrypt_symlink(struct inode *inode,
225 const char *target,
226 unsigned int len,
227 struct fscrypt_str *disk_link)
228{
229 return -EOPNOTSUPP;
230}
231
232static inline const char *fscrypt_get_symlink(struct inode *inode,
233 const void *caddr,
234 unsigned int max_size,
235 struct delayed_call *done)
236{
237 return ERR_PTR(-EOPNOTSUPP);
238}
239
Hyojun Kim63da4202017-10-06 17:10:08 -0700240#endif /* _LINUX_FSCRYPT_NOTSUPP_H */