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