1 /* SPDX-License-Identifier: GPL-2.0 */
5 * This stubs out the fscrypt functions for filesystems configured without
8 * Do not include this file directly. Use fscrypt.h instead!
10 #ifndef _LINUX_FSCRYPT_H
11 #error "Incorrect include of linux/fscrypt_notsupp.h!"
14 #ifndef _LINUX_FSCRYPT_NOTSUPP_H
15 #define _LINUX_FSCRYPT_NOTSUPP_H
18 static inline struct fscrypt_ctx *fscrypt_get_ctx(const struct inode *inode,
21 return ERR_PTR(-EOPNOTSUPP);
24 static inline void fscrypt_release_ctx(struct fscrypt_ctx *ctx)
29 static inline struct page *fscrypt_encrypt_page(const struct inode *inode,
33 u64 lblk_num, gfp_t gfp_flags)
35 return ERR_PTR(-EOPNOTSUPP);
38 static inline int fscrypt_decrypt_page(const struct inode *inode,
40 unsigned int len, unsigned int offs,
47 static inline void fscrypt_restore_control_page(struct page *page)
52 static inline void fscrypt_set_d_op(struct dentry *dentry)
57 static inline void fscrypt_set_encrypted_dentry(struct dentry *dentry)
63 static inline int fscrypt_ioctl_set_policy(struct file *filp,
64 const void __user *arg)
69 static inline int fscrypt_ioctl_get_policy(struct file *filp, void __user *arg)
74 static inline int fscrypt_has_permitted_context(struct inode *parent,
80 static inline int fscrypt_inherit_context(struct inode *parent,
82 void *fs_data, bool preload)
88 static inline int fscrypt_get_encryption_info(struct inode *inode)
93 static inline void fscrypt_put_encryption_info(struct inode *inode,
94 struct fscrypt_info *ci)
100 static inline int fscrypt_setup_filename(struct inode *dir,
101 const struct qstr *iname,
102 int lookup, struct fscrypt_name *fname)
104 if (IS_ENCRYPTED(dir))
107 memset(fname, 0, sizeof(struct fscrypt_name));
108 fname->usr_fname = iname;
109 fname->disk_name.name = (unsigned char *)iname->name;
110 fname->disk_name.len = iname->len;
114 static inline void fscrypt_free_filename(struct fscrypt_name *fname)
119 static inline u32 fscrypt_fname_encrypted_size(const struct inode *inode,
127 static inline int fscrypt_fname_alloc_buffer(const struct inode *inode,
129 struct fscrypt_str *crypto_str)
134 static inline void fscrypt_fname_free_buffer(struct fscrypt_str *crypto_str)
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)
147 static inline int fscrypt_fname_usr_to_disk(struct inode *inode,
148 const struct qstr *iname,
149 struct fscrypt_str *oname)
154 static inline bool fscrypt_match_name(const struct fscrypt_name *fname,
155 const u8 *de_name, u32 de_name_len)
157 /* Encryption support disabled; use standard comparison */
158 if (de_name_len != fname->disk_name.len)
160 return !memcmp(de_name, fname->disk_name.name, fname->disk_name.len);
164 static inline void fscrypt_decrypt_bio_pages(struct fscrypt_ctx *ctx,
170 static inline void fscrypt_pullback_bio_page(struct page **page, bool restore)
175 static inline int fscrypt_zeroout_range(const struct inode *inode, pgoff_t lblk,
176 sector_t pblk, unsigned int len)
183 static inline int fscrypt_file_open(struct inode *inode, struct file *filp)
185 if (IS_ENCRYPTED(inode))
190 static inline int __fscrypt_prepare_link(struct inode *inode,
196 static inline int __fscrypt_prepare_rename(struct inode *old_dir,
197 struct dentry *old_dentry,
198 struct inode *new_dir,
199 struct dentry *new_dentry,
205 static inline int __fscrypt_prepare_lookup(struct inode *dir,
206 struct dentry *dentry)
211 #endif /* _LINUX_FSCRYPT_NOTSUPP_H */