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