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