• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 /* crypto.c */
fscrypt_get_ctx(const struct inode * inode,gfp_t gfp_flags)17 static inline struct fscrypt_ctx *fscrypt_get_ctx(const struct inode *inode,
18 						  gfp_t gfp_flags)
19 {
20 	return ERR_PTR(-EOPNOTSUPP);
21 }
22 
fscrypt_release_ctx(struct fscrypt_ctx * ctx)23 static inline void fscrypt_release_ctx(struct fscrypt_ctx *ctx)
24 {
25 	return;
26 }
27 
fscrypt_encrypt_page(const struct inode * inode,struct page * page,unsigned int len,unsigned int offs,u64 lblk_num,gfp_t gfp_flags)28 static 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 
fscrypt_decrypt_page(const struct inode * inode,struct page * page,unsigned int len,unsigned int offs,u64 lblk_num)37 static 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 
fscrypt_restore_control_page(struct page * page)46 static inline void fscrypt_restore_control_page(struct page *page)
47 {
48 	return;
49 }
50 
fscrypt_set_d_op(struct dentry * dentry)51 static inline void fscrypt_set_d_op(struct dentry *dentry)
52 {
53 	return;
54 }
55 
fscrypt_set_encrypted_dentry(struct dentry * dentry)56 static inline void fscrypt_set_encrypted_dentry(struct dentry *dentry)
57 {
58 	return;
59 }
60 
61 /* policy.c */
fscrypt_ioctl_set_policy(struct file * filp,const void __user * arg)62 static inline int fscrypt_ioctl_set_policy(struct file *filp,
63 					   const void __user *arg)
64 {
65 	return -EOPNOTSUPP;
66 }
67 
fscrypt_ioctl_get_policy(struct file * filp,void __user * arg)68 static inline int fscrypt_ioctl_get_policy(struct file *filp, void __user *arg)
69 {
70 	return -EOPNOTSUPP;
71 }
72 
fscrypt_has_permitted_context(struct inode * parent,struct inode * child)73 static inline int fscrypt_has_permitted_context(struct inode *parent,
74 						struct inode *child)
75 {
76 	return 0;
77 }
78 
fscrypt_inherit_context(struct inode * parent,struct inode * child,void * fs_data,bool preload)79 static 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 */
fscrypt_get_encryption_info(struct inode * inode)87 static inline int fscrypt_get_encryption_info(struct inode *inode)
88 {
89 	return -EOPNOTSUPP;
90 }
91 
fscrypt_put_encryption_info(struct inode * inode,struct fscrypt_info * ci)92 static inline void fscrypt_put_encryption_info(struct inode *inode,
93 					       struct fscrypt_info *ci)
94 {
95 	return;
96 }
97 
98  /* fname.c */
fscrypt_setup_filename(struct inode * dir,const struct qstr * iname,int lookup,struct fscrypt_name * fname)99 static inline int fscrypt_setup_filename(struct inode *dir,
100 					 const struct qstr *iname,
101 					 int lookup, struct fscrypt_name *fname)
102 {
103 	if (IS_ENCRYPTED(dir))
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 
fscrypt_free_filename(struct fscrypt_name * fname)113 static inline void fscrypt_free_filename(struct fscrypt_name *fname)
114 {
115 	return;
116 }
117 
fscrypt_fname_encrypted_size(const struct inode * inode,u32 ilen)118 static 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 
fscrypt_fname_alloc_buffer(const struct inode * inode,u32 ilen,struct fscrypt_str * crypto_str)126 static 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 
fscrypt_fname_free_buffer(struct fscrypt_str * crypto_str)133 static inline void fscrypt_fname_free_buffer(struct fscrypt_str *crypto_str)
134 {
135 	return;
136 }
137 
fscrypt_fname_disk_to_usr(struct inode * inode,u32 hash,u32 minor_hash,const struct fscrypt_str * iname,struct fscrypt_str * oname)138 static 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 
fscrypt_fname_usr_to_disk(struct inode * inode,const struct qstr * iname,struct fscrypt_str * oname)146 static 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 
fscrypt_match_name(const struct fscrypt_name * fname,const u8 * de_name,u32 de_name_len)153 static 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 
162 /* bio.c */
fscrypt_decrypt_bio_pages(struct fscrypt_ctx * ctx,struct bio * bio)163 static inline void fscrypt_decrypt_bio_pages(struct fscrypt_ctx *ctx,
164 					     struct bio *bio)
165 {
166 	return;
167 }
168 
fscrypt_pullback_bio_page(struct page ** page,bool restore)169 static inline void fscrypt_pullback_bio_page(struct page **page, bool restore)
170 {
171 	return;
172 }
173 
fscrypt_zeroout_range(const struct inode * inode,pgoff_t lblk,sector_t pblk,unsigned int len)174 static 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 
180 /* hooks.c */
181 
fscrypt_file_open(struct inode * inode,struct file * filp)182 static 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 
__fscrypt_prepare_link(struct inode * inode,struct inode * dir)189 static inline int __fscrypt_prepare_link(struct inode *inode,
190 					 struct inode *dir)
191 {
192 	return -EOPNOTSUPP;
193 }
194 
__fscrypt_prepare_rename(struct inode * old_dir,struct dentry * old_dentry,struct inode * new_dir,struct dentry * new_dentry,unsigned int flags)195 static inline int __fscrypt_prepare_rename(struct inode *old_dir,
196 					   struct dentry *old_dentry,
197 					   struct inode *new_dir,
198 					   struct dentry *new_dentry,
199 					   unsigned int flags)
200 {
201 	return -EOPNOTSUPP;
202 }
203 
__fscrypt_prepare_lookup(struct inode * dir,struct dentry * dentry)204 static inline int __fscrypt_prepare_lookup(struct inode *dir,
205 					   struct dentry *dentry)
206 {
207 	return -EOPNOTSUPP;
208 }
209 
210 #endif	/* _LINUX_FSCRYPT_NOTSUPP_H */
211