OSDN Git Service

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