blob: 52e3302854575cda9f521de858d9e95b2f3d365f [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
51
52static inline void fscrypt_restore_control_page(struct page *page)
53{
54 return;
55}
56
57static inline void fscrypt_set_d_op(struct dentry *dentry)
58{
59 return;
60}
61
62static inline void fscrypt_set_encrypted_dentry(struct dentry *dentry)
63{
64 return;
65}
66
67/* policy.c */
68static inline int fscrypt_ioctl_set_policy(struct file *filp,
69 const void __user *arg)
70{
71 return -EOPNOTSUPP;
72}
73
74static inline int fscrypt_ioctl_get_policy(struct file *filp, void __user *arg)
75{
76 return -EOPNOTSUPP;
77}
78
79static inline int fscrypt_has_permitted_context(struct inode *parent,
80 struct inode *child)
81{
82 return 0;
83}
84
85static inline int fscrypt_inherit_context(struct inode *parent,
86 struct inode *child,
87 void *fs_data, bool preload)
88{
89 return -EOPNOTSUPP;
90}
91
92/* keyinfo.c */
93static inline int fscrypt_get_encryption_info(struct inode *inode)
94{
95 return -EOPNOTSUPP;
96}
97
98static inline void fscrypt_put_encryption_info(struct inode *inode,
99 struct fscrypt_info *ci)
100{
101 return;
102}
103
104 /* fname.c */
105static inline int fscrypt_setup_filename(struct inode *dir,
106 const struct qstr *iname,
107 int lookup, struct fscrypt_name *fname)
108{
Eric Biggerse0428a22017-10-09 12:15:36 -0700109 if (IS_ENCRYPTED(dir))
Eric Biggers46f47e42017-01-24 10:58:06 -0800110 return -EOPNOTSUPP;
111
112 memset(fname, 0, sizeof(struct fscrypt_name));
113 fname->usr_fname = iname;
114 fname->disk_name.name = (unsigned char *)iname->name;
115 fname->disk_name.len = iname->len;
116 return 0;
117}
118
119static inline void fscrypt_free_filename(struct fscrypt_name *fname)
120{
121 return;
122}
123
124static inline u32 fscrypt_fname_encrypted_size(const struct inode *inode,
125 u32 ilen)
126{
127 /* never happens */
128 WARN_ON(1);
129 return 0;
130}
131
132static inline int fscrypt_fname_alloc_buffer(const struct inode *inode,
133 u32 ilen,
134 struct fscrypt_str *crypto_str)
135{
136 return -EOPNOTSUPP;
137}
138
139static inline void fscrypt_fname_free_buffer(struct fscrypt_str *crypto_str)
140{
141 return;
142}
143
144static inline int fscrypt_fname_disk_to_usr(struct inode *inode,
145 u32 hash, u32 minor_hash,
146 const struct fscrypt_str *iname,
147 struct fscrypt_str *oname)
148{
149 return -EOPNOTSUPP;
150}
151
152static inline int fscrypt_fname_usr_to_disk(struct inode *inode,
153 const struct qstr *iname,
154 struct fscrypt_str *oname)
155{
156 return -EOPNOTSUPP;
157}
158
Eric Biggers17159422017-04-24 10:00:10 -0700159static inline bool fscrypt_match_name(const struct fscrypt_name *fname,
160 const u8 *de_name, u32 de_name_len)
161{
162 /* Encryption support disabled; use standard comparison */
163 if (de_name_len != fname->disk_name.len)
164 return false;
165 return !memcmp(de_name, fname->disk_name.name, fname->disk_name.len);
166}
167
Eric Biggers46f47e42017-01-24 10:58:06 -0800168/* bio.c */
169static inline void fscrypt_decrypt_bio_pages(struct fscrypt_ctx *ctx,
170 struct bio *bio)
171{
172 return;
173}
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
Eric Biggersefcc7ae2017-10-09 12:15: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
Eric Biggers0ea87a92017-10-09 12:15:41 -0700195static inline int __fscrypt_prepare_link(struct inode *inode,
196 struct inode *dir)
197{
198 return -EOPNOTSUPP;
199}
200
Eric Biggers94b26f32017-10-09 12:15:42 -0700201static 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
Eric Biggers32c3cf02017-10-09 12:15:43 -0700210static inline int __fscrypt_prepare_lookup(struct inode *dir,
211 struct dentry *dentry)
212{
213 return -EOPNOTSUPP;
214}
215
Eric Biggers46f47e42017-01-24 10:58:06 -0800216#endif /* _LINUX_FSCRYPT_NOTSUPP_H */