Greg Kroah-Hartman | b244131 | 2017-11-01 15:07:57 +0100 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
Eric Biggers | 46f47e4 | 2017-01-24 10:58:06 -0800 | [diff] [blame] | 2 | /* |
| 3 | * fscrypt_notsupp.h |
| 4 | * |
| 5 | * This stubs out the fscrypt functions for filesystems configured without |
| 6 | * encryption support. |
Dave Chinner | 734f0d2 | 2017-10-09 12:15:34 -0700 | [diff] [blame] | 7 | * |
| 8 | * Do not include this file directly. Use fscrypt.h instead! |
Eric Biggers | 46f47e4 | 2017-01-24 10:58:06 -0800 | [diff] [blame] | 9 | */ |
Dave Chinner | 734f0d2 | 2017-10-09 12:15:34 -0700 | [diff] [blame] | 10 | #ifndef _LINUX_FSCRYPT_H |
| 11 | #error "Incorrect include of linux/fscrypt_notsupp.h!" |
| 12 | #endif |
Eric Biggers | 46f47e4 | 2017-01-24 10:58:06 -0800 | [diff] [blame] | 13 | |
| 14 | #ifndef _LINUX_FSCRYPT_NOTSUPP_H |
| 15 | #define _LINUX_FSCRYPT_NOTSUPP_H |
| 16 | |
Eric Biggers | 3d463f2 | 2018-01-05 10:44:52 -0800 | [diff] [blame] | 17 | static inline bool fscrypt_has_encryption_key(const struct inode *inode) |
| 18 | { |
| 19 | return false; |
| 20 | } |
| 21 | |
Eric Biggers | 1493651 | 2018-01-05 10:44:56 -0800 | [diff] [blame] | 22 | static inline bool fscrypt_dummy_context_enabled(struct inode *inode) |
| 23 | { |
| 24 | return false; |
| 25 | } |
| 26 | |
Eric Biggers | 46f47e4 | 2017-01-24 10:58:06 -0800 | [diff] [blame] | 27 | /* crypto.c */ |
| 28 | static inline struct fscrypt_ctx *fscrypt_get_ctx(const struct inode *inode, |
| 29 | gfp_t gfp_flags) |
| 30 | { |
| 31 | return ERR_PTR(-EOPNOTSUPP); |
| 32 | } |
| 33 | |
| 34 | static inline void fscrypt_release_ctx(struct fscrypt_ctx *ctx) |
| 35 | { |
| 36 | return; |
| 37 | } |
| 38 | |
| 39 | static inline struct page *fscrypt_encrypt_page(const struct inode *inode, |
| 40 | struct page *page, |
| 41 | unsigned int len, |
| 42 | unsigned int offs, |
| 43 | u64 lblk_num, gfp_t gfp_flags) |
| 44 | { |
| 45 | return ERR_PTR(-EOPNOTSUPP); |
| 46 | } |
| 47 | |
| 48 | static inline int fscrypt_decrypt_page(const struct inode *inode, |
| 49 | struct page *page, |
| 50 | unsigned int len, unsigned int offs, |
| 51 | u64 lblk_num) |
| 52 | { |
| 53 | return -EOPNOTSUPP; |
| 54 | } |
| 55 | |
Eric Biggers | 4fd4b15 | 2018-01-05 10:44:53 -0800 | [diff] [blame] | 56 | static inline struct page *fscrypt_control_page(struct page *page) |
| 57 | { |
| 58 | WARN_ON_ONCE(1); |
| 59 | return ERR_PTR(-EINVAL); |
| 60 | } |
Eric Biggers | 46f47e4 | 2017-01-24 10:58:06 -0800 | [diff] [blame] | 61 | |
| 62 | static inline void fscrypt_restore_control_page(struct page *page) |
| 63 | { |
| 64 | return; |
| 65 | } |
| 66 | |
| 67 | static inline void fscrypt_set_d_op(struct dentry *dentry) |
| 68 | { |
| 69 | return; |
| 70 | } |
| 71 | |
| 72 | static inline void fscrypt_set_encrypted_dentry(struct dentry *dentry) |
| 73 | { |
| 74 | return; |
| 75 | } |
| 76 | |
| 77 | /* policy.c */ |
| 78 | static inline int fscrypt_ioctl_set_policy(struct file *filp, |
| 79 | const void __user *arg) |
| 80 | { |
| 81 | return -EOPNOTSUPP; |
| 82 | } |
| 83 | |
| 84 | static inline int fscrypt_ioctl_get_policy(struct file *filp, void __user *arg) |
| 85 | { |
| 86 | return -EOPNOTSUPP; |
| 87 | } |
| 88 | |
| 89 | static inline int fscrypt_has_permitted_context(struct inode *parent, |
| 90 | struct inode *child) |
| 91 | { |
| 92 | return 0; |
| 93 | } |
| 94 | |
| 95 | static inline int fscrypt_inherit_context(struct inode *parent, |
| 96 | struct inode *child, |
| 97 | void *fs_data, bool preload) |
| 98 | { |
| 99 | return -EOPNOTSUPP; |
| 100 | } |
| 101 | |
| 102 | /* keyinfo.c */ |
| 103 | static inline int fscrypt_get_encryption_info(struct inode *inode) |
| 104 | { |
| 105 | return -EOPNOTSUPP; |
| 106 | } |
| 107 | |
| 108 | static inline void fscrypt_put_encryption_info(struct inode *inode, |
| 109 | struct fscrypt_info *ci) |
| 110 | { |
| 111 | return; |
| 112 | } |
| 113 | |
| 114 | /* fname.c */ |
| 115 | static inline int fscrypt_setup_filename(struct inode *dir, |
| 116 | const struct qstr *iname, |
| 117 | int lookup, struct fscrypt_name *fname) |
| 118 | { |
Eric Biggers | e0428a2 | 2017-10-09 12:15:36 -0700 | [diff] [blame] | 119 | if (IS_ENCRYPTED(dir)) |
Eric Biggers | 46f47e4 | 2017-01-24 10:58:06 -0800 | [diff] [blame] | 120 | return -EOPNOTSUPP; |
| 121 | |
| 122 | memset(fname, 0, sizeof(struct fscrypt_name)); |
| 123 | fname->usr_fname = iname; |
| 124 | fname->disk_name.name = (unsigned char *)iname->name; |
| 125 | fname->disk_name.len = iname->len; |
| 126 | return 0; |
| 127 | } |
| 128 | |
| 129 | static inline void fscrypt_free_filename(struct fscrypt_name *fname) |
| 130 | { |
| 131 | return; |
| 132 | } |
| 133 | |
| 134 | static inline u32 fscrypt_fname_encrypted_size(const struct inode *inode, |
| 135 | u32 ilen) |
| 136 | { |
| 137 | /* never happens */ |
| 138 | WARN_ON(1); |
| 139 | return 0; |
| 140 | } |
| 141 | |
| 142 | static inline int fscrypt_fname_alloc_buffer(const struct inode *inode, |
| 143 | u32 ilen, |
| 144 | struct fscrypt_str *crypto_str) |
| 145 | { |
| 146 | return -EOPNOTSUPP; |
| 147 | } |
| 148 | |
| 149 | static inline void fscrypt_fname_free_buffer(struct fscrypt_str *crypto_str) |
| 150 | { |
| 151 | return; |
| 152 | } |
| 153 | |
| 154 | static inline int fscrypt_fname_disk_to_usr(struct inode *inode, |
| 155 | u32 hash, u32 minor_hash, |
| 156 | const struct fscrypt_str *iname, |
| 157 | struct fscrypt_str *oname) |
| 158 | { |
| 159 | return -EOPNOTSUPP; |
| 160 | } |
| 161 | |
| 162 | static inline int fscrypt_fname_usr_to_disk(struct inode *inode, |
| 163 | const struct qstr *iname, |
| 164 | struct fscrypt_str *oname) |
| 165 | { |
| 166 | return -EOPNOTSUPP; |
| 167 | } |
| 168 | |
Eric Biggers | 1715942 | 2017-04-24 10:00:10 -0700 | [diff] [blame] | 169 | static inline bool fscrypt_match_name(const struct fscrypt_name *fname, |
| 170 | const u8 *de_name, u32 de_name_len) |
| 171 | { |
| 172 | /* Encryption support disabled; use standard comparison */ |
| 173 | if (de_name_len != fname->disk_name.len) |
| 174 | return false; |
| 175 | return !memcmp(de_name, fname->disk_name.name, fname->disk_name.len); |
| 176 | } |
| 177 | |
Eric Biggers | 46f47e4 | 2017-01-24 10:58:06 -0800 | [diff] [blame] | 178 | /* bio.c */ |
| 179 | static inline void fscrypt_decrypt_bio_pages(struct fscrypt_ctx *ctx, |
| 180 | struct bio *bio) |
| 181 | { |
| 182 | return; |
| 183 | } |
| 184 | |
| 185 | static inline void fscrypt_pullback_bio_page(struct page **page, bool restore) |
| 186 | { |
| 187 | return; |
| 188 | } |
| 189 | |
| 190 | static inline int fscrypt_zeroout_range(const struct inode *inode, pgoff_t lblk, |
| 191 | sector_t pblk, unsigned int len) |
| 192 | { |
| 193 | return -EOPNOTSUPP; |
| 194 | } |
| 195 | |
Eric Biggers | efcc7ae | 2017-10-09 12:15:40 -0700 | [diff] [blame] | 196 | /* hooks.c */ |
| 197 | |
| 198 | static inline int fscrypt_file_open(struct inode *inode, struct file *filp) |
| 199 | { |
| 200 | if (IS_ENCRYPTED(inode)) |
| 201 | return -EOPNOTSUPP; |
| 202 | return 0; |
| 203 | } |
| 204 | |
Eric Biggers | 0ea87a9 | 2017-10-09 12:15:41 -0700 | [diff] [blame] | 205 | static inline int __fscrypt_prepare_link(struct inode *inode, |
| 206 | struct inode *dir) |
| 207 | { |
| 208 | return -EOPNOTSUPP; |
| 209 | } |
| 210 | |
Eric Biggers | 94b26f3 | 2017-10-09 12:15:42 -0700 | [diff] [blame] | 211 | static inline int __fscrypt_prepare_rename(struct inode *old_dir, |
| 212 | struct dentry *old_dentry, |
| 213 | struct inode *new_dir, |
| 214 | struct dentry *new_dentry, |
| 215 | unsigned int flags) |
| 216 | { |
| 217 | return -EOPNOTSUPP; |
| 218 | } |
| 219 | |
Eric Biggers | 32c3cf0 | 2017-10-09 12:15:43 -0700 | [diff] [blame] | 220 | static inline int __fscrypt_prepare_lookup(struct inode *dir, |
| 221 | struct dentry *dentry) |
| 222 | { |
| 223 | return -EOPNOTSUPP; |
| 224 | } |
| 225 | |
Eric Biggers | 46f47e4 | 2017-01-24 10:58:06 -0800 | [diff] [blame] | 226 | #endif /* _LINUX_FSCRYPT_NOTSUPP_H */ |