]> git.proxmox.com Git - mirror_ubuntu-eoan-kernel.git/blame - include/linux/fscrypt_notsupp.h
fscrypt: new helper function - fscrypt_file_open()
[mirror_ubuntu-eoan-kernel.git] / include / linux / fscrypt_notsupp.h
CommitLineData
46f47e48
EB
1/*
2 * fscrypt_notsupp.h
3 *
4 * This stubs out the fscrypt functions for filesystems configured without
5 * encryption support.
734f0d24
DC
6 *
7 * Do not include this file directly. Use fscrypt.h instead!
46f47e48 8 */
734f0d24
DC
9#ifndef _LINUX_FSCRYPT_H
10#error "Incorrect include of linux/fscrypt_notsupp.h!"
11#endif
46f47e48
EB
12
13#ifndef _LINUX_FSCRYPT_NOTSUPP_H
14#define _LINUX_FSCRYPT_NOTSUPP_H
15
46f47e48
EB
16/* crypto.c */
17static inline struct fscrypt_ctx *fscrypt_get_ctx(const struct inode *inode,
18 gfp_t gfp_flags)
19{
20 return ERR_PTR(-EOPNOTSUPP);
21}
22
23static inline void fscrypt_release_ctx(struct fscrypt_ctx *ctx)
24{
25 return;
26}
27
28static inline struct page *fscrypt_encrypt_page(const struct inode *inode,
29 struct page *page,
30 unsigned int len,
31 unsigned int offs,
32 u64 lblk_num, gfp_t gfp_flags)
33{
34 return ERR_PTR(-EOPNOTSUPP);
35}
36
37static inline int fscrypt_decrypt_page(const struct inode *inode,
38 struct page *page,
39 unsigned int len, unsigned int offs,
40 u64 lblk_num)
41{
42 return -EOPNOTSUPP;
43}
44
45
46static inline void fscrypt_restore_control_page(struct page *page)
47{
48 return;
49}
50
51static inline void fscrypt_set_d_op(struct dentry *dentry)
52{
53 return;
54}
55
56static inline void fscrypt_set_encrypted_dentry(struct dentry *dentry)
57{
58 return;
59}
60
61/* policy.c */
62static inline int fscrypt_ioctl_set_policy(struct file *filp,
63 const void __user *arg)
64{
65 return -EOPNOTSUPP;
66}
67
68static inline int fscrypt_ioctl_get_policy(struct file *filp, void __user *arg)
69{
70 return -EOPNOTSUPP;
71}
72
73static inline int fscrypt_has_permitted_context(struct inode *parent,
74 struct inode *child)
75{
76 return 0;
77}
78
79static inline int fscrypt_inherit_context(struct inode *parent,
80 struct inode *child,
81 void *fs_data, bool preload)
82{
83 return -EOPNOTSUPP;
84}
85
86/* keyinfo.c */
87static inline int fscrypt_get_encryption_info(struct inode *inode)
88{
89 return -EOPNOTSUPP;
90}
91
92static inline void fscrypt_put_encryption_info(struct inode *inode,
93 struct fscrypt_info *ci)
94{
95 return;
96}
97
98 /* fname.c */
99static inline int fscrypt_setup_filename(struct inode *dir,
100 const struct qstr *iname,
101 int lookup, struct fscrypt_name *fname)
102{
e0428a26 103 if (IS_ENCRYPTED(dir))
46f47e48
EB
104 return -EOPNOTSUPP;
105
106 memset(fname, 0, sizeof(struct fscrypt_name));
107 fname->usr_fname = iname;
108 fname->disk_name.name = (unsigned char *)iname->name;
109 fname->disk_name.len = iname->len;
110 return 0;
111}
112
113static inline void fscrypt_free_filename(struct fscrypt_name *fname)
114{
115 return;
116}
117
118static inline u32 fscrypt_fname_encrypted_size(const struct inode *inode,
119 u32 ilen)
120{
121 /* never happens */
122 WARN_ON(1);
123 return 0;
124}
125
126static inline int fscrypt_fname_alloc_buffer(const struct inode *inode,
127 u32 ilen,
128 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
146static inline int fscrypt_fname_usr_to_disk(struct inode *inode,
147 const struct qstr *iname,
148 struct fscrypt_str *oname)
149{
150 return -EOPNOTSUPP;
151}
152
17159420
EB
153static inline bool fscrypt_match_name(const struct fscrypt_name *fname,
154 const u8 *de_name, u32 de_name_len)
155{
156 /* Encryption support disabled; use standard comparison */
157 if (de_name_len != fname->disk_name.len)
158 return false;
159 return !memcmp(de_name, fname->disk_name.name, fname->disk_name.len);
160}
161
46f47e48
EB
162/* bio.c */
163static inline void fscrypt_decrypt_bio_pages(struct fscrypt_ctx *ctx,
164 struct bio *bio)
165{
166 return;
167}
168
169static inline void fscrypt_pullback_bio_page(struct page **page, bool restore)
170{
171 return;
172}
173
174static inline int fscrypt_zeroout_range(const struct inode *inode, pgoff_t lblk,
175 sector_t pblk, unsigned int len)
176{
177 return -EOPNOTSUPP;
178}
179
efcc7ae2
EB
180/* hooks.c */
181
182static inline int fscrypt_file_open(struct inode *inode, struct file *filp)
183{
184 if (IS_ENCRYPTED(inode))
185 return -EOPNOTSUPP;
186 return 0;
187}
188
46f47e48 189#endif /* _LINUX_FSCRYPT_NOTSUPP_H */