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 | 46f47e4 | 2017-01-24 10:58:06 -0800 | [diff] [blame] | 17 | /* crypto.c */ |
| 18 | static inline struct fscrypt_ctx *fscrypt_get_ctx(const struct inode *inode, |
| 19 | gfp_t gfp_flags) |
| 20 | { |
| 21 | return ERR_PTR(-EOPNOTSUPP); |
| 22 | } |
| 23 | |
| 24 | static inline void fscrypt_release_ctx(struct fscrypt_ctx *ctx) |
| 25 | { |
| 26 | return; |
| 27 | } |
| 28 | |
| 29 | static 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 | |
| 38 | static 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 | |
| 47 | static inline void fscrypt_restore_control_page(struct page *page) |
| 48 | { |
| 49 | return; |
| 50 | } |
| 51 | |
| 52 | static inline void fscrypt_set_d_op(struct dentry *dentry) |
| 53 | { |
| 54 | return; |
| 55 | } |
| 56 | |
| 57 | static inline void fscrypt_set_encrypted_dentry(struct dentry *dentry) |
| 58 | { |
| 59 | return; |
| 60 | } |
| 61 | |
| 62 | /* policy.c */ |
| 63 | static inline int fscrypt_ioctl_set_policy(struct file *filp, |
| 64 | const void __user *arg) |
| 65 | { |
| 66 | return -EOPNOTSUPP; |
| 67 | } |
| 68 | |
| 69 | static inline int fscrypt_ioctl_get_policy(struct file *filp, void __user *arg) |
| 70 | { |
| 71 | return -EOPNOTSUPP; |
| 72 | } |
| 73 | |
| 74 | static inline int fscrypt_has_permitted_context(struct inode *parent, |
| 75 | struct inode *child) |
| 76 | { |
| 77 | return 0; |
| 78 | } |
| 79 | |
| 80 | static 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 */ |
| 88 | static inline int fscrypt_get_encryption_info(struct inode *inode) |
| 89 | { |
| 90 | return -EOPNOTSUPP; |
| 91 | } |
| 92 | |
| 93 | static inline void fscrypt_put_encryption_info(struct inode *inode, |
| 94 | struct fscrypt_info *ci) |
| 95 | { |
| 96 | return; |
| 97 | } |
| 98 | |
| 99 | /* fname.c */ |
| 100 | static inline int fscrypt_setup_filename(struct inode *dir, |
| 101 | const struct qstr *iname, |
| 102 | int lookup, struct fscrypt_name *fname) |
| 103 | { |
Eric Biggers | e0428a2 | 2017-10-09 12:15:36 -0700 | [diff] [blame] | 104 | if (IS_ENCRYPTED(dir)) |
Eric Biggers | 46f47e4 | 2017-01-24 10:58:06 -0800 | [diff] [blame] | 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 | |
| 114 | static inline void fscrypt_free_filename(struct fscrypt_name *fname) |
| 115 | { |
| 116 | return; |
| 117 | } |
| 118 | |
| 119 | static 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 | |
| 127 | static 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 | |
| 134 | static inline void fscrypt_fname_free_buffer(struct fscrypt_str *crypto_str) |
| 135 | { |
| 136 | return; |
| 137 | } |
| 138 | |
| 139 | static 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 | |
| 147 | static 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 | |
Eric Biggers | 1715942 | 2017-04-24 10:00:10 -0700 | [diff] [blame] | 154 | static 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 | |
Eric Biggers | 46f47e4 | 2017-01-24 10:58:06 -0800 | [diff] [blame] | 163 | /* bio.c */ |
| 164 | static inline void fscrypt_decrypt_bio_pages(struct fscrypt_ctx *ctx, |
| 165 | struct bio *bio) |
| 166 | { |
| 167 | return; |
| 168 | } |
| 169 | |
| 170 | static inline void fscrypt_pullback_bio_page(struct page **page, bool restore) |
| 171 | { |
| 172 | return; |
| 173 | } |
| 174 | |
| 175 | static 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 | |
Eric Biggers | efcc7ae | 2017-10-09 12:15:40 -0700 | [diff] [blame] | 181 | /* hooks.c */ |
| 182 | |
| 183 | static 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 | |
Eric Biggers | 0ea87a9 | 2017-10-09 12:15:41 -0700 | [diff] [blame] | 190 | static inline int __fscrypt_prepare_link(struct inode *inode, |
| 191 | struct inode *dir) |
| 192 | { |
| 193 | return -EOPNOTSUPP; |
| 194 | } |
| 195 | |
Eric Biggers | 94b26f3 | 2017-10-09 12:15:42 -0700 | [diff] [blame] | 196 | static 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 | |
Eric Biggers | 32c3cf0 | 2017-10-09 12:15:43 -0700 | [diff] [blame] | 205 | static inline int __fscrypt_prepare_lookup(struct inode *dir, |
| 206 | struct dentry *dentry) |
| 207 | { |
| 208 | return -EOPNOTSUPP; |
| 209 | } |
| 210 | |
Eric Biggers | 46f47e4 | 2017-01-24 10:58:06 -0800 | [diff] [blame] | 211 | #endif /* _LINUX_FSCRYPT_NOTSUPP_H */ |