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 | 46f47e4 | 2017-01-24 10:58:06 -0800 | [diff] [blame] | 22 | /* crypto.c */ |
| 23 | static inline struct fscrypt_ctx *fscrypt_get_ctx(const struct inode *inode, |
| 24 | gfp_t gfp_flags) |
| 25 | { |
| 26 | return ERR_PTR(-EOPNOTSUPP); |
| 27 | } |
| 28 | |
| 29 | static inline void fscrypt_release_ctx(struct fscrypt_ctx *ctx) |
| 30 | { |
| 31 | return; |
| 32 | } |
| 33 | |
| 34 | static inline struct page *fscrypt_encrypt_page(const struct inode *inode, |
| 35 | struct page *page, |
| 36 | unsigned int len, |
| 37 | unsigned int offs, |
| 38 | u64 lblk_num, gfp_t gfp_flags) |
| 39 | { |
| 40 | return ERR_PTR(-EOPNOTSUPP); |
| 41 | } |
| 42 | |
| 43 | static inline int fscrypt_decrypt_page(const struct inode *inode, |
| 44 | struct page *page, |
| 45 | unsigned int len, unsigned int offs, |
| 46 | u64 lblk_num) |
| 47 | { |
| 48 | return -EOPNOTSUPP; |
| 49 | } |
| 50 | |
| 51 | |
| 52 | static inline void fscrypt_restore_control_page(struct page *page) |
| 53 | { |
| 54 | return; |
| 55 | } |
| 56 | |
| 57 | static inline void fscrypt_set_d_op(struct dentry *dentry) |
| 58 | { |
| 59 | return; |
| 60 | } |
| 61 | |
| 62 | static inline void fscrypt_set_encrypted_dentry(struct dentry *dentry) |
| 63 | { |
| 64 | return; |
| 65 | } |
| 66 | |
| 67 | /* policy.c */ |
| 68 | static inline int fscrypt_ioctl_set_policy(struct file *filp, |
| 69 | const void __user *arg) |
| 70 | { |
| 71 | return -EOPNOTSUPP; |
| 72 | } |
| 73 | |
| 74 | static inline int fscrypt_ioctl_get_policy(struct file *filp, void __user *arg) |
| 75 | { |
| 76 | return -EOPNOTSUPP; |
| 77 | } |
| 78 | |
| 79 | static inline int fscrypt_has_permitted_context(struct inode *parent, |
| 80 | struct inode *child) |
| 81 | { |
| 82 | return 0; |
| 83 | } |
| 84 | |
| 85 | static inline int fscrypt_inherit_context(struct inode *parent, |
| 86 | struct inode *child, |
| 87 | void *fs_data, bool preload) |
| 88 | { |
| 89 | return -EOPNOTSUPP; |
| 90 | } |
| 91 | |
| 92 | /* keyinfo.c */ |
| 93 | static inline int fscrypt_get_encryption_info(struct inode *inode) |
| 94 | { |
| 95 | return -EOPNOTSUPP; |
| 96 | } |
| 97 | |
| 98 | static inline void fscrypt_put_encryption_info(struct inode *inode, |
| 99 | struct fscrypt_info *ci) |
| 100 | { |
| 101 | return; |
| 102 | } |
| 103 | |
| 104 | /* fname.c */ |
| 105 | static inline int fscrypt_setup_filename(struct inode *dir, |
| 106 | const struct qstr *iname, |
| 107 | int lookup, struct fscrypt_name *fname) |
| 108 | { |
Eric Biggers | e0428a2 | 2017-10-09 12:15:36 -0700 | [diff] [blame] | 109 | if (IS_ENCRYPTED(dir)) |
Eric Biggers | 46f47e4 | 2017-01-24 10:58:06 -0800 | [diff] [blame] | 110 | return -EOPNOTSUPP; |
| 111 | |
| 112 | memset(fname, 0, sizeof(struct fscrypt_name)); |
| 113 | fname->usr_fname = iname; |
| 114 | fname->disk_name.name = (unsigned char *)iname->name; |
| 115 | fname->disk_name.len = iname->len; |
| 116 | return 0; |
| 117 | } |
| 118 | |
| 119 | static inline void fscrypt_free_filename(struct fscrypt_name *fname) |
| 120 | { |
| 121 | return; |
| 122 | } |
| 123 | |
| 124 | static inline u32 fscrypt_fname_encrypted_size(const struct inode *inode, |
| 125 | u32 ilen) |
| 126 | { |
| 127 | /* never happens */ |
| 128 | WARN_ON(1); |
| 129 | return 0; |
| 130 | } |
| 131 | |
| 132 | static inline int fscrypt_fname_alloc_buffer(const struct inode *inode, |
| 133 | u32 ilen, |
| 134 | struct fscrypt_str *crypto_str) |
| 135 | { |
| 136 | return -EOPNOTSUPP; |
| 137 | } |
| 138 | |
| 139 | static inline void fscrypt_fname_free_buffer(struct fscrypt_str *crypto_str) |
| 140 | { |
| 141 | return; |
| 142 | } |
| 143 | |
| 144 | static inline int fscrypt_fname_disk_to_usr(struct inode *inode, |
| 145 | u32 hash, u32 minor_hash, |
| 146 | const struct fscrypt_str *iname, |
| 147 | struct fscrypt_str *oname) |
| 148 | { |
| 149 | return -EOPNOTSUPP; |
| 150 | } |
| 151 | |
| 152 | static inline int fscrypt_fname_usr_to_disk(struct inode *inode, |
| 153 | const struct qstr *iname, |
| 154 | struct fscrypt_str *oname) |
| 155 | { |
| 156 | return -EOPNOTSUPP; |
| 157 | } |
| 158 | |
Eric Biggers | 1715942 | 2017-04-24 10:00:10 -0700 | [diff] [blame] | 159 | static inline bool fscrypt_match_name(const struct fscrypt_name *fname, |
| 160 | const u8 *de_name, u32 de_name_len) |
| 161 | { |
| 162 | /* Encryption support disabled; use standard comparison */ |
| 163 | if (de_name_len != fname->disk_name.len) |
| 164 | return false; |
| 165 | return !memcmp(de_name, fname->disk_name.name, fname->disk_name.len); |
| 166 | } |
| 167 | |
Eric Biggers | 46f47e4 | 2017-01-24 10:58:06 -0800 | [diff] [blame] | 168 | /* bio.c */ |
| 169 | static inline void fscrypt_decrypt_bio_pages(struct fscrypt_ctx *ctx, |
| 170 | struct bio *bio) |
| 171 | { |
| 172 | return; |
| 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 | |
Eric Biggers | efcc7ae | 2017-10-09 12:15: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 | |
Eric Biggers | 0ea87a9 | 2017-10-09 12:15:41 -0700 | [diff] [blame] | 195 | static inline int __fscrypt_prepare_link(struct inode *inode, |
| 196 | struct inode *dir) |
| 197 | { |
| 198 | return -EOPNOTSUPP; |
| 199 | } |
| 200 | |
Eric Biggers | 94b26f3 | 2017-10-09 12:15:42 -0700 | [diff] [blame] | 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 | |
Eric Biggers | 32c3cf0 | 2017-10-09 12:15:43 -0700 | [diff] [blame] | 210 | static inline int __fscrypt_prepare_lookup(struct inode *dir, |
| 211 | struct dentry *dentry) |
| 212 | { |
| 213 | return -EOPNOTSUPP; |
| 214 | } |
| 215 | |
Eric Biggers | 46f47e4 | 2017-01-24 10:58:06 -0800 | [diff] [blame] | 216 | #endif /* _LINUX_FSCRYPT_NOTSUPP_H */ |