blob: 0abc588b10c917a0a7187ed4a4c12af5136be303 [file] [log] [blame]
Greg Kroah-Hartmanb2441312017-11-01 15:07:57 +01001/* SPDX-License-Identifier: GPL-2.0 */
Eric Biggers46f47e42017-01-24 10:58:06 -08002/*
3 * fscrypt_notsupp.h
4 *
5 * This stubs out the fscrypt functions for filesystems configured without
6 * encryption support.
Dave Chinner734f0d22017-10-09 12:15:34 -07007 *
8 * Do not include this file directly. Use fscrypt.h instead!
Eric Biggers46f47e42017-01-24 10:58:06 -08009 */
Dave Chinner734f0d22017-10-09 12:15:34 -070010#ifndef _LINUX_FSCRYPT_H
11#error "Incorrect include of linux/fscrypt_notsupp.h!"
12#endif
Eric Biggers46f47e42017-01-24 10:58:06 -080013
14#ifndef _LINUX_FSCRYPT_NOTSUPP_H
15#define _LINUX_FSCRYPT_NOTSUPP_H
16
Eric Biggers3d463f22018-01-05 10:44:52 -080017static inline bool fscrypt_has_encryption_key(const struct inode *inode)
18{
19 return false;
20}
21
Eric Biggers14936512018-01-05 10:44:56 -080022static inline bool fscrypt_dummy_context_enabled(struct inode *inode)
23{
24 return false;
25}
26
Eric Biggers46f47e42017-01-24 10:58:06 -080027/* crypto.c */
Eric Biggers0cb8dae2018-04-18 11:09:47 -070028static inline void fscrypt_enqueue_decrypt_work(struct work_struct *work)
29{
30}
31
Eric Biggers46f47e42017-01-24 10:58:06 -080032static inline struct fscrypt_ctx *fscrypt_get_ctx(const struct inode *inode,
33 gfp_t gfp_flags)
34{
35 return ERR_PTR(-EOPNOTSUPP);
36}
37
38static inline void fscrypt_release_ctx(struct fscrypt_ctx *ctx)
39{
40 return;
41}
42
43static inline struct page *fscrypt_encrypt_page(const struct inode *inode,
44 struct page *page,
45 unsigned int len,
46 unsigned int offs,
47 u64 lblk_num, gfp_t gfp_flags)
48{
49 return ERR_PTR(-EOPNOTSUPP);
50}
51
52static inline int fscrypt_decrypt_page(const struct inode *inode,
53 struct page *page,
54 unsigned int len, unsigned int offs,
55 u64 lblk_num)
56{
57 return -EOPNOTSUPP;
58}
59
Eric Biggers4fd4b152018-01-05 10:44:53 -080060static inline struct page *fscrypt_control_page(struct page *page)
61{
62 WARN_ON_ONCE(1);
63 return ERR_PTR(-EINVAL);
64}
Eric Biggers46f47e42017-01-24 10:58:06 -080065
66static inline void fscrypt_restore_control_page(struct page *page)
67{
68 return;
69}
70
Eric Biggers46f47e42017-01-24 10:58:06 -080071/* policy.c */
72static inline int fscrypt_ioctl_set_policy(struct file *filp,
73 const void __user *arg)
74{
75 return -EOPNOTSUPP;
76}
77
78static inline int fscrypt_ioctl_get_policy(struct file *filp, void __user *arg)
79{
80 return -EOPNOTSUPP;
81}
82
83static inline int fscrypt_has_permitted_context(struct inode *parent,
84 struct inode *child)
85{
86 return 0;
87}
88
89static inline int fscrypt_inherit_context(struct inode *parent,
90 struct inode *child,
91 void *fs_data, bool preload)
92{
93 return -EOPNOTSUPP;
94}
95
96/* keyinfo.c */
97static inline int fscrypt_get_encryption_info(struct inode *inode)
98{
99 return -EOPNOTSUPP;
100}
101
Eric Biggers3d204e22018-01-11 23:30:13 -0500102static inline void fscrypt_put_encryption_info(struct inode *inode)
Eric Biggers46f47e42017-01-24 10:58:06 -0800103{
104 return;
105}
106
107 /* fname.c */
108static inline int fscrypt_setup_filename(struct inode *dir,
109 const struct qstr *iname,
110 int lookup, struct fscrypt_name *fname)
111{
Eric Biggerse0428a22017-10-09 12:15:36 -0700112 if (IS_ENCRYPTED(dir))
Eric Biggers46f47e42017-01-24 10:58:06 -0800113 return -EOPNOTSUPP;
114
115 memset(fname, 0, sizeof(struct fscrypt_name));
116 fname->usr_fname = iname;
117 fname->disk_name.name = (unsigned char *)iname->name;
118 fname->disk_name.len = iname->len;
119 return 0;
120}
121
122static inline void fscrypt_free_filename(struct fscrypt_name *fname)
123{
124 return;
125}
126
Eric Biggers46f47e42017-01-24 10:58:06 -0800127static inline int fscrypt_fname_alloc_buffer(const struct inode *inode,
Eric Biggers2cbadad2018-01-11 23:30:08 -0500128 u32 max_encrypted_len,
Eric Biggers46f47e42017-01-24 10:58:06 -0800129 struct fscrypt_str *crypto_str)
130{
131 return -EOPNOTSUPP;
132}
133
134static inline void fscrypt_fname_free_buffer(struct fscrypt_str *crypto_str)
135{
136 return;
137}
138
139static inline int fscrypt_fname_disk_to_usr(struct inode *inode,
140 u32 hash, u32 minor_hash,
141 const struct fscrypt_str *iname,
142 struct fscrypt_str *oname)
143{
144 return -EOPNOTSUPP;
145}
146
Eric Biggers17159422017-04-24 10:00:10 -0700147static inline bool fscrypt_match_name(const struct fscrypt_name *fname,
148 const u8 *de_name, u32 de_name_len)
149{
150 /* Encryption support disabled; use standard comparison */
151 if (de_name_len != fname->disk_name.len)
152 return false;
153 return !memcmp(de_name, fname->disk_name.name, fname->disk_name.len);
154}
155
Eric Biggers46f47e42017-01-24 10:58:06 -0800156/* bio.c */
Eric Biggers0cb8dae2018-04-18 11:09:47 -0700157static inline void fscrypt_decrypt_bio(struct bio *bio)
Eric Biggers46f47e42017-01-24 10:58:06 -0800158{
Eric Biggers0cb8dae2018-04-18 11:09:47 -0700159}
160
161static inline void fscrypt_enqueue_decrypt_bio(struct fscrypt_ctx *ctx,
162 struct bio *bio)
163{
Eric Biggers46f47e42017-01-24 10:58:06 -0800164}
165
166static inline void fscrypt_pullback_bio_page(struct page **page, bool restore)
167{
168 return;
169}
170
171static inline int fscrypt_zeroout_range(const struct inode *inode, pgoff_t lblk,
172 sector_t pblk, unsigned int len)
173{
174 return -EOPNOTSUPP;
175}
176
Zhen Kongee7bdc62019-03-14 10:55:19 -0700177/* fscrypt_ice.c */
178static inline int fscrypt_using_hardware_encryption(const struct inode *inode)
179{
180 return 0;
181}
182
183static inline void fscrypt_set_ice_dun(const struct inode *inode,
184 struct bio *bio, u64 dun) {}
185
186static inline bool fscrypt_mergeable_bio(struct bio *bio,
187 sector_t iv_block, bool bio_encrypted)
188{
189 return true;
190}
191
Eric Biggersefcc7ae2017-10-09 12:15:40 -0700192/* hooks.c */
193
194static inline int fscrypt_file_open(struct inode *inode, struct file *filp)
195{
196 if (IS_ENCRYPTED(inode))
197 return -EOPNOTSUPP;
198 return 0;
199}
200
Eric Biggers0ea87a92017-10-09 12:15:41 -0700201static inline int __fscrypt_prepare_link(struct inode *inode,
202 struct inode *dir)
203{
204 return -EOPNOTSUPP;
205}
206
Eric Biggers94b26f32017-10-09 12:15:42 -0700207static inline int __fscrypt_prepare_rename(struct inode *old_dir,
208 struct dentry *old_dentry,
209 struct inode *new_dir,
210 struct dentry *new_dentry,
211 unsigned int flags)
212{
213 return -EOPNOTSUPP;
214}
215
Eric Biggers32c3cf02017-10-09 12:15:43 -0700216static inline int __fscrypt_prepare_lookup(struct inode *dir,
217 struct dentry *dentry)
218{
219 return -EOPNOTSUPP;
220}
221
Eric Biggers76e81d62018-01-05 10:45:01 -0800222static inline int __fscrypt_prepare_symlink(struct inode *dir,
223 unsigned int len,
224 unsigned int max_len,
225 struct fscrypt_str *disk_link)
226{
227 return -EOPNOTSUPP;
228}
229
230static inline int __fscrypt_encrypt_symlink(struct inode *inode,
231 const char *target,
232 unsigned int len,
233 struct fscrypt_str *disk_link)
234{
235 return -EOPNOTSUPP;
236}
237
Eric Biggers3b0d8832018-01-05 10:45:02 -0800238static inline const char *fscrypt_get_symlink(struct inode *inode,
239 const void *caddr,
240 unsigned int max_size,
241 struct delayed_call *done)
242{
243 return ERR_PTR(-EOPNOTSUPP);
244}
245
Eric Biggers46f47e42017-01-24 10:58:06 -0800246#endif /* _LINUX_FSCRYPT_NOTSUPP_H */