blob: cbec0864d37f1f35e2a9817a4a29bdc5c68fce05 [file] [log] [blame]
Jaegeuk Kime6b120d2017-07-10 12:55:09 -07001/*
2 * fscrypt_notsupp.h
3 *
4 * This stubs out the fscrypt functions for filesystems configured without
5 * encryption support.
Dave Chinner16179292017-10-09 12:15:34 -07006 *
7 * Do not include this file directly. Use fscrypt.h instead!
Jaegeuk Kime6b120d2017-07-10 12:55:09 -07008 */
Dave Chinner16179292017-10-09 12:15:34 -07009#ifndef _LINUX_FSCRYPT_H
10#error "Incorrect include of linux/fscrypt_notsupp.h!"
11#endif
Jaegeuk Kime6b120d2017-07-10 12:55:09 -070012
13#ifndef _LINUX_FSCRYPT_NOTSUPP_H
14#define _LINUX_FSCRYPT_NOTSUPP_H
15
Eric Biggersd8dfb892018-01-05 10:44:52 -080016static inline bool fscrypt_has_encryption_key(const struct inode *inode)
17{
18 return false;
19}
20
Eric Biggers616dbd22018-01-05 10:44:56 -080021static inline bool fscrypt_dummy_context_enabled(struct inode *inode)
22{
23 return false;
24}
25
Jaegeuk Kime6b120d2017-07-10 12:55:09 -070026/* crypto.c */
Eric Biggers05099232018-04-18 11:09:47 -070027static inline void fscrypt_enqueue_decrypt_work(struct work_struct *work)
28{
29}
30
Jaegeuk Kime6b120d2017-07-10 12:55:09 -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
Eric Biggersb67b07e2018-01-05 10:44:53 -080059static inline struct page *fscrypt_control_page(struct page *page)
60{
61 WARN_ON_ONCE(1);
62 return ERR_PTR(-EINVAL);
63}
Jaegeuk Kime6b120d2017-07-10 12:55:09 -070064
65static inline void fscrypt_restore_control_page(struct page *page)
66{
67 return;
68}
69
Jaegeuk Kime6b120d2017-07-10 12:55:09 -070070/* policy.c */
71static inline int fscrypt_ioctl_set_policy(struct file *filp,
72 const void __user *arg)
73{
74 return -EOPNOTSUPP;
75}
76
77static inline int fscrypt_ioctl_get_policy(struct file *filp, void __user *arg)
78{
79 return -EOPNOTSUPP;
80}
81
82static inline int fscrypt_has_permitted_context(struct inode *parent,
83 struct inode *child)
84{
85 return 0;
86}
87
88static inline int fscrypt_inherit_context(struct inode *parent,
89 struct inode *child,
90 void *fs_data, bool preload)
91{
92 return -EOPNOTSUPP;
93}
94
95/* keyinfo.c */
96static inline int fscrypt_get_encryption_info(struct inode *inode)
97{
98 return -EOPNOTSUPP;
99}
100
Eric Biggers401052f2018-01-11 23:30:13 -0500101static inline void fscrypt_put_encryption_info(struct inode *inode)
Jaegeuk Kime6b120d2017-07-10 12:55:09 -0700102{
103 return;
104}
105
106 /* fname.c */
107static inline int fscrypt_setup_filename(struct inode *dir,
108 const struct qstr *iname,
109 int lookup, struct fscrypt_name *fname)
110{
Eric Biggersd750ec72017-10-09 12:15:36 -0700111 if (IS_ENCRYPTED(dir))
Jaegeuk Kime6b120d2017-07-10 12:55:09 -0700112 return -EOPNOTSUPP;
113
114 memset(fname, 0, sizeof(struct fscrypt_name));
115 fname->usr_fname = iname;
116 fname->disk_name.name = (unsigned char *)iname->name;
117 fname->disk_name.len = iname->len;
118 return 0;
119}
120
121static inline void fscrypt_free_filename(struct fscrypt_name *fname)
122{
123 return;
124}
125
Jaegeuk Kime6b120d2017-07-10 12:55:09 -0700126static inline int fscrypt_fname_alloc_buffer(const struct inode *inode,
Eric Biggersc440b5092018-01-11 23:30:08 -0500127 u32 max_encrypted_len,
Jaegeuk Kime6b120d2017-07-10 12:55:09 -0700128 struct fscrypt_str *crypto_str)
129{
130 return -EOPNOTSUPP;
131}
132
133static inline void fscrypt_fname_free_buffer(struct fscrypt_str *crypto_str)
134{
135 return;
136}
137
138static inline int fscrypt_fname_disk_to_usr(struct inode *inode,
139 u32 hash, u32 minor_hash,
140 const struct fscrypt_str *iname,
141 struct fscrypt_str *oname)
142{
143 return -EOPNOTSUPP;
144}
145
Jaegeuk Kime6b120d2017-07-10 12:55:09 -0700146static inline bool fscrypt_match_name(const struct fscrypt_name *fname,
147 const u8 *de_name, u32 de_name_len)
148{
149 /* Encryption support disabled; use standard comparison */
150 if (de_name_len != fname->disk_name.len)
151 return false;
152 return !memcmp(de_name, fname->disk_name.name, fname->disk_name.len);
153}
154
155/* bio.c */
Eric Biggers05099232018-04-18 11:09:47 -0700156static inline void fscrypt_decrypt_bio(struct bio *bio)
Jaegeuk Kime6b120d2017-07-10 12:55:09 -0700157{
Eric Biggers05099232018-04-18 11:09:47 -0700158}
159
160static inline void fscrypt_enqueue_decrypt_bio(struct fscrypt_ctx *ctx,
161 struct bio *bio)
162{
Jaegeuk Kime6b120d2017-07-10 12:55:09 -0700163}
164
165static inline void fscrypt_pullback_bio_page(struct page **page, bool restore)
166{
167 return;
168}
169
170static inline int fscrypt_zeroout_range(const struct inode *inode, pgoff_t lblk,
171 sector_t pblk, unsigned int len)
172{
173 return -EOPNOTSUPP;
174}
175
Eric Biggersd61dffb2017-10-09 12:15:40 -0700176/* hooks.c */
177
178static inline int fscrypt_file_open(struct inode *inode, struct file *filp)
179{
180 if (IS_ENCRYPTED(inode))
181 return -EOPNOTSUPP;
182 return 0;
183}
184
Eric Biggersf5218702017-10-09 12:15:41 -0700185static inline int __fscrypt_prepare_link(struct inode *inode,
186 struct inode *dir)
187{
188 return -EOPNOTSUPP;
189}
190
Eric Biggers98fe83a2017-10-09 12:15:42 -0700191static inline int __fscrypt_prepare_rename(struct inode *old_dir,
192 struct dentry *old_dentry,
193 struct inode *new_dir,
194 struct dentry *new_dentry,
195 unsigned int flags)
196{
197 return -EOPNOTSUPP;
198}
199
Eric Biggersec822ff2017-10-09 12:15:43 -0700200static inline int __fscrypt_prepare_lookup(struct inode *dir,
201 struct dentry *dentry)
202{
203 return -EOPNOTSUPP;
204}
205
Eric Biggersa7e05c72018-01-05 10:45:01 -0800206static inline int __fscrypt_prepare_symlink(struct inode *dir,
207 unsigned int len,
208 unsigned int max_len,
209 struct fscrypt_str *disk_link)
210{
211 return -EOPNOTSUPP;
212}
213
214static inline int __fscrypt_encrypt_symlink(struct inode *inode,
215 const char *target,
216 unsigned int len,
217 struct fscrypt_str *disk_link)
218{
219 return -EOPNOTSUPP;
220}
221
Eric Biggersda32a162018-01-05 10:45:02 -0800222static inline const char *fscrypt_get_symlink(struct inode *inode,
223 const void *caddr,
224 unsigned int max_size,
225 struct delayed_call *done)
226{
227 return ERR_PTR(-EOPNOTSUPP);
228}
229
Jaegeuk Kime6b120d2017-07-10 12:55:09 -0700230#endif /* _LINUX_FSCRYPT_NOTSUPP_H */