Merge tag 'rtc-4.18' of git://git.kernel.org/pub/scm/linux/kernel/git/abelloni/linux
[linux-2.6-microblaze.git] / include / linux / fscrypt_notsupp.h
1 /* SPDX-License-Identifier: GPL-2.0 */
2 /*
3  * fscrypt_notsupp.h
4  *
5  * This stubs out the fscrypt functions for filesystems configured without
6  * encryption support.
7  *
8  * Do not include this file directly. Use fscrypt.h instead!
9  */
10 #ifndef _LINUX_FSCRYPT_H
11 #error "Incorrect include of linux/fscrypt_notsupp.h!"
12 #endif
13
14 #ifndef _LINUX_FSCRYPT_NOTSUPP_H
15 #define _LINUX_FSCRYPT_NOTSUPP_H
16
17 static inline bool fscrypt_has_encryption_key(const struct inode *inode)
18 {
19         return false;
20 }
21
22 static inline bool fscrypt_dummy_context_enabled(struct inode *inode)
23 {
24         return false;
25 }
26
27 /* crypto.c */
28 static inline struct fscrypt_ctx *fscrypt_get_ctx(const struct inode *inode,
29                                                   gfp_t gfp_flags)
30 {
31         return ERR_PTR(-EOPNOTSUPP);
32 }
33
34 static inline void fscrypt_release_ctx(struct fscrypt_ctx *ctx)
35 {
36         return;
37 }
38
39 static 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
48 static 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
56 static inline struct page *fscrypt_control_page(struct page *page)
57 {
58         WARN_ON_ONCE(1);
59         return ERR_PTR(-EINVAL);
60 }
61
62 static inline void fscrypt_restore_control_page(struct page *page)
63 {
64         return;
65 }
66
67 /* policy.c */
68 static inline int fscrypt_ioctl_set_policy(struct file *filp,
69                                            const void __user *arg)
70 {
71         return -EOPNOTSUPP;
72 }
73
74 static inline int fscrypt_ioctl_get_policy(struct file *filp, void __user *arg)
75 {
76         return -EOPNOTSUPP;
77 }
78
79 static inline int fscrypt_has_permitted_context(struct inode *parent,
80                                                 struct inode *child)
81 {
82         return 0;
83 }
84
85 static 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 */
93 static inline int fscrypt_get_encryption_info(struct inode *inode)
94 {
95         return -EOPNOTSUPP;
96 }
97
98 static inline void fscrypt_put_encryption_info(struct inode *inode)
99 {
100         return;
101 }
102
103  /* fname.c */
104 static inline int fscrypt_setup_filename(struct inode *dir,
105                                          const struct qstr *iname,
106                                          int lookup, struct fscrypt_name *fname)
107 {
108         if (IS_ENCRYPTED(dir))
109                 return -EOPNOTSUPP;
110
111         memset(fname, 0, sizeof(struct fscrypt_name));
112         fname->usr_fname = iname;
113         fname->disk_name.name = (unsigned char *)iname->name;
114         fname->disk_name.len = iname->len;
115         return 0;
116 }
117
118 static inline void fscrypt_free_filename(struct fscrypt_name *fname)
119 {
120         return;
121 }
122
123 static inline int fscrypt_fname_alloc_buffer(const struct inode *inode,
124                                              u32 max_encrypted_len,
125                                              struct fscrypt_str *crypto_str)
126 {
127         return -EOPNOTSUPP;
128 }
129
130 static inline void fscrypt_fname_free_buffer(struct fscrypt_str *crypto_str)
131 {
132         return;
133 }
134
135 static inline int fscrypt_fname_disk_to_usr(struct inode *inode,
136                                             u32 hash, u32 minor_hash,
137                                             const struct fscrypt_str *iname,
138                                             struct fscrypt_str *oname)
139 {
140         return -EOPNOTSUPP;
141 }
142
143 static inline bool fscrypt_match_name(const struct fscrypt_name *fname,
144                                       const u8 *de_name, u32 de_name_len)
145 {
146         /* Encryption support disabled; use standard comparison */
147         if (de_name_len != fname->disk_name.len)
148                 return false;
149         return !memcmp(de_name, fname->disk_name.name, fname->disk_name.len);
150 }
151
152 /* bio.c */
153 static inline void fscrypt_decrypt_bio_pages(struct fscrypt_ctx *ctx,
154                                              struct bio *bio)
155 {
156         return;
157 }
158
159 static inline void fscrypt_pullback_bio_page(struct page **page, bool restore)
160 {
161         return;
162 }
163
164 static inline int fscrypt_zeroout_range(const struct inode *inode, pgoff_t lblk,
165                                         sector_t pblk, unsigned int len)
166 {
167         return -EOPNOTSUPP;
168 }
169
170 /* hooks.c */
171
172 static inline int fscrypt_file_open(struct inode *inode, struct file *filp)
173 {
174         if (IS_ENCRYPTED(inode))
175                 return -EOPNOTSUPP;
176         return 0;
177 }
178
179 static inline int __fscrypt_prepare_link(struct inode *inode,
180                                          struct inode *dir)
181 {
182         return -EOPNOTSUPP;
183 }
184
185 static inline int __fscrypt_prepare_rename(struct inode *old_dir,
186                                            struct dentry *old_dentry,
187                                            struct inode *new_dir,
188                                            struct dentry *new_dentry,
189                                            unsigned int flags)
190 {
191         return -EOPNOTSUPP;
192 }
193
194 static inline int __fscrypt_prepare_lookup(struct inode *dir,
195                                            struct dentry *dentry)
196 {
197         return -EOPNOTSUPP;
198 }
199
200 static inline int __fscrypt_prepare_symlink(struct inode *dir,
201                                             unsigned int len,
202                                             unsigned int max_len,
203                                             struct fscrypt_str *disk_link)
204 {
205         return -EOPNOTSUPP;
206 }
207
208 static inline int __fscrypt_encrypt_symlink(struct inode *inode,
209                                             const char *target,
210                                             unsigned int len,
211                                             struct fscrypt_str *disk_link)
212 {
213         return -EOPNOTSUPP;
214 }
215
216 static inline const char *fscrypt_get_symlink(struct inode *inode,
217                                               const void *caddr,
218                                               unsigned int max_size,
219                                               struct delayed_call *done)
220 {
221         return ERR_PTR(-EOPNOTSUPP);
222 }
223
224 #endif  /* _LINUX_FSCRYPT_NOTSUPP_H */