blob: 81e02201b215af57db201e2477fd712c90f3f1a8 [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 */
28static inline struct fscrypt_ctx *fscrypt_get_ctx(const struct inode *inode,
29 gfp_t gfp_flags)
30{
31 return ERR_PTR(-EOPNOTSUPP);
32}
33
34static inline void fscrypt_release_ctx(struct fscrypt_ctx *ctx)
35{
36 return;
37}
38
39static inline struct page *fscrypt_encrypt_page(const struct inode *inode,
40 struct page *page,
41 unsigned int len,
42 unsigned int offs,
43 u64 lblk_num, gfp_t gfp_flags)
44{
45 return ERR_PTR(-EOPNOTSUPP);
46}
47
48static inline int fscrypt_decrypt_page(const struct inode *inode,
49 struct page *page,
50 unsigned int len, unsigned int offs,
51 u64 lblk_num)
52{
53 return -EOPNOTSUPP;
54}
55
Eric Biggers4fd4b152018-01-05 10:44:53 -080056static inline struct page *fscrypt_control_page(struct page *page)
57{
58 WARN_ON_ONCE(1);
59 return ERR_PTR(-EINVAL);
60}
Eric Biggers46f47e42017-01-24 10:58:06 -080061
62static inline void fscrypt_restore_control_page(struct page *page)
63{
64 return;
65}
66
67static inline void fscrypt_set_d_op(struct dentry *dentry)
68{
69 return;
70}
71
72static inline void fscrypt_set_encrypted_dentry(struct dentry *dentry)
73{
74 return;
75}
76
77/* policy.c */
78static inline int fscrypt_ioctl_set_policy(struct file *filp,
79 const void __user *arg)
80{
81 return -EOPNOTSUPP;
82}
83
84static inline int fscrypt_ioctl_get_policy(struct file *filp, void __user *arg)
85{
86 return -EOPNOTSUPP;
87}
88
89static inline int fscrypt_has_permitted_context(struct inode *parent,
90 struct inode *child)
91{
92 return 0;
93}
94
95static inline int fscrypt_inherit_context(struct inode *parent,
96 struct inode *child,
97 void *fs_data, bool preload)
98{
99 return -EOPNOTSUPP;
100}
101
102/* keyinfo.c */
103static inline int fscrypt_get_encryption_info(struct inode *inode)
104{
105 return -EOPNOTSUPP;
106}
107
108static inline void fscrypt_put_encryption_info(struct inode *inode,
109 struct fscrypt_info *ci)
110{
111 return;
112}
113
114 /* fname.c */
115static inline int fscrypt_setup_filename(struct inode *dir,
116 const struct qstr *iname,
117 int lookup, struct fscrypt_name *fname)
118{
Eric Biggerse0428a22017-10-09 12:15:36 -0700119 if (IS_ENCRYPTED(dir))
Eric Biggers46f47e42017-01-24 10:58:06 -0800120 return -EOPNOTSUPP;
121
122 memset(fname, 0, sizeof(struct fscrypt_name));
123 fname->usr_fname = iname;
124 fname->disk_name.name = (unsigned char *)iname->name;
125 fname->disk_name.len = iname->len;
126 return 0;
127}
128
129static inline void fscrypt_free_filename(struct fscrypt_name *fname)
130{
131 return;
132}
133
134static inline u32 fscrypt_fname_encrypted_size(const struct inode *inode,
135 u32 ilen)
136{
137 /* never happens */
138 WARN_ON(1);
139 return 0;
140}
141
142static inline int fscrypt_fname_alloc_buffer(const struct inode *inode,
143 u32 ilen,
144 struct fscrypt_str *crypto_str)
145{
146 return -EOPNOTSUPP;
147}
148
149static inline void fscrypt_fname_free_buffer(struct fscrypt_str *crypto_str)
150{
151 return;
152}
153
154static inline int fscrypt_fname_disk_to_usr(struct inode *inode,
155 u32 hash, u32 minor_hash,
156 const struct fscrypt_str *iname,
157 struct fscrypt_str *oname)
158{
159 return -EOPNOTSUPP;
160}
161
162static inline int fscrypt_fname_usr_to_disk(struct inode *inode,
163 const struct qstr *iname,
164 struct fscrypt_str *oname)
165{
166 return -EOPNOTSUPP;
167}
168
Eric Biggers17159422017-04-24 10:00:10 -0700169static inline bool fscrypt_match_name(const struct fscrypt_name *fname,
170 const u8 *de_name, u32 de_name_len)
171{
172 /* Encryption support disabled; use standard comparison */
173 if (de_name_len != fname->disk_name.len)
174 return false;
175 return !memcmp(de_name, fname->disk_name.name, fname->disk_name.len);
176}
177
Eric Biggers46f47e42017-01-24 10:58:06 -0800178/* bio.c */
179static inline void fscrypt_decrypt_bio_pages(struct fscrypt_ctx *ctx,
180 struct bio *bio)
181{
182 return;
183}
184
185static inline void fscrypt_pullback_bio_page(struct page **page, bool restore)
186{
187 return;
188}
189
190static inline int fscrypt_zeroout_range(const struct inode *inode, pgoff_t lblk,
191 sector_t pblk, unsigned int len)
192{
193 return -EOPNOTSUPP;
194}
195
Eric Biggersefcc7ae2017-10-09 12:15:40 -0700196/* hooks.c */
197
198static inline int fscrypt_file_open(struct inode *inode, struct file *filp)
199{
200 if (IS_ENCRYPTED(inode))
201 return -EOPNOTSUPP;
202 return 0;
203}
204
Eric Biggers0ea87a92017-10-09 12:15:41 -0700205static inline int __fscrypt_prepare_link(struct inode *inode,
206 struct inode *dir)
207{
208 return -EOPNOTSUPP;
209}
210
Eric Biggers94b26f32017-10-09 12:15:42 -0700211static inline int __fscrypt_prepare_rename(struct inode *old_dir,
212 struct dentry *old_dentry,
213 struct inode *new_dir,
214 struct dentry *new_dentry,
215 unsigned int flags)
216{
217 return -EOPNOTSUPP;
218}
219
Eric Biggers32c3cf02017-10-09 12:15:43 -0700220static inline int __fscrypt_prepare_lookup(struct inode *dir,
221 struct dentry *dentry)
222{
223 return -EOPNOTSUPP;
224}
225
Eric Biggers46f47e42017-01-24 10:58:06 -0800226#endif /* _LINUX_FSCRYPT_NOTSUPP_H */