at v4.15 4.6 kB view raw
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/* crypto.c */ 18static inline struct fscrypt_ctx *fscrypt_get_ctx(const struct inode *inode, 19 gfp_t gfp_flags) 20{ 21 return ERR_PTR(-EOPNOTSUPP); 22} 23 24static inline void fscrypt_release_ctx(struct fscrypt_ctx *ctx) 25{ 26 return; 27} 28 29static inline struct page *fscrypt_encrypt_page(const struct inode *inode, 30 struct page *page, 31 unsigned int len, 32 unsigned int offs, 33 u64 lblk_num, gfp_t gfp_flags) 34{ 35 return ERR_PTR(-EOPNOTSUPP); 36} 37 38static inline int fscrypt_decrypt_page(const struct inode *inode, 39 struct page *page, 40 unsigned int len, unsigned int offs, 41 u64 lblk_num) 42{ 43 return -EOPNOTSUPP; 44} 45 46 47static inline void fscrypt_restore_control_page(struct page *page) 48{ 49 return; 50} 51 52static inline void fscrypt_set_d_op(struct dentry *dentry) 53{ 54 return; 55} 56 57static inline void fscrypt_set_encrypted_dentry(struct dentry *dentry) 58{ 59 return; 60} 61 62/* policy.c */ 63static inline int fscrypt_ioctl_set_policy(struct file *filp, 64 const void __user *arg) 65{ 66 return -EOPNOTSUPP; 67} 68 69static inline int fscrypt_ioctl_get_policy(struct file *filp, void __user *arg) 70{ 71 return -EOPNOTSUPP; 72} 73 74static inline int fscrypt_has_permitted_context(struct inode *parent, 75 struct inode *child) 76{ 77 return 0; 78} 79 80static inline int fscrypt_inherit_context(struct inode *parent, 81 struct inode *child, 82 void *fs_data, bool preload) 83{ 84 return -EOPNOTSUPP; 85} 86 87/* keyinfo.c */ 88static inline int fscrypt_get_encryption_info(struct inode *inode) 89{ 90 return -EOPNOTSUPP; 91} 92 93static inline void fscrypt_put_encryption_info(struct inode *inode, 94 struct fscrypt_info *ci) 95{ 96 return; 97} 98 99 /* fname.c */ 100static inline int fscrypt_setup_filename(struct inode *dir, 101 const struct qstr *iname, 102 int lookup, struct fscrypt_name *fname) 103{ 104 if (IS_ENCRYPTED(dir)) 105 return -EOPNOTSUPP; 106 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; 111 return 0; 112} 113 114static inline void fscrypt_free_filename(struct fscrypt_name *fname) 115{ 116 return; 117} 118 119static inline u32 fscrypt_fname_encrypted_size(const struct inode *inode, 120 u32 ilen) 121{ 122 /* never happens */ 123 WARN_ON(1); 124 return 0; 125} 126 127static inline int fscrypt_fname_alloc_buffer(const struct inode *inode, 128 u32 ilen, 129 struct fscrypt_str *crypto_str) 130{ 131 return -EOPNOTSUPP; 132} 133 134static inline void fscrypt_fname_free_buffer(struct fscrypt_str *crypto_str) 135{ 136 return; 137} 138 139static 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 147static inline int fscrypt_fname_usr_to_disk(struct inode *inode, 148 const struct qstr *iname, 149 struct fscrypt_str *oname) 150{ 151 return -EOPNOTSUPP; 152} 153 154static inline bool fscrypt_match_name(const struct fscrypt_name *fname, 155 const u8 *de_name, u32 de_name_len) 156{ 157 /* Encryption support disabled; use standard comparison */ 158 if (de_name_len != fname->disk_name.len) 159 return false; 160 return !memcmp(de_name, fname->disk_name.name, fname->disk_name.len); 161} 162 163/* bio.c */ 164static inline void fscrypt_decrypt_bio_pages(struct fscrypt_ctx *ctx, 165 struct bio *bio) 166{ 167 return; 168} 169 170static inline void fscrypt_pullback_bio_page(struct page **page, bool restore) 171{ 172 return; 173} 174 175static inline int fscrypt_zeroout_range(const struct inode *inode, pgoff_t lblk, 176 sector_t pblk, unsigned int len) 177{ 178 return -EOPNOTSUPP; 179} 180 181/* hooks.c */ 182 183static inline int fscrypt_file_open(struct inode *inode, struct file *filp) 184{ 185 if (IS_ENCRYPTED(inode)) 186 return -EOPNOTSUPP; 187 return 0; 188} 189 190static inline int __fscrypt_prepare_link(struct inode *inode, 191 struct inode *dir) 192{ 193 return -EOPNOTSUPP; 194} 195 196static inline int __fscrypt_prepare_rename(struct inode *old_dir, 197 struct dentry *old_dentry, 198 struct inode *new_dir, 199 struct dentry *new_dentry, 200 unsigned int flags) 201{ 202 return -EOPNOTSUPP; 203} 204 205static inline int __fscrypt_prepare_lookup(struct inode *dir, 206 struct dentry *dentry) 207{ 208 return -EOPNOTSUPP; 209} 210 211#endif /* _LINUX_FSCRYPT_NOTSUPP_H */