fscrypt_notsupp.h 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /*
  3. * fscrypt_notsupp.h
  4. *
  5. * This stubs out the fscrypt functions for filesystems configured without
  6. * encryption support.
  7. *
  8. * Do not include this file directly. Use fscrypt.h instead!
  9. */
  10. #ifndef _LINUX_FSCRYPT_H
  11. #error "Incorrect include of linux/fscrypt_notsupp.h!"
  12. #endif
  13. #ifndef _LINUX_FSCRYPT_NOTSUPP_H
  14. #define _LINUX_FSCRYPT_NOTSUPP_H
  15. static inline bool fscrypt_has_encryption_key(const struct inode *inode)
  16. {
  17. return false;
  18. }
  19. static inline bool fscrypt_dummy_context_enabled(struct inode *inode)
  20. {
  21. return false;
  22. }
  23. /* crypto.c */
  24. static inline void fscrypt_enqueue_decrypt_work(struct work_struct *work)
  25. {
  26. }
  27. static inline struct fscrypt_ctx *fscrypt_get_ctx(const struct inode *inode,
  28. gfp_t gfp_flags)
  29. {
  30. return ERR_PTR(-EOPNOTSUPP);
  31. }
  32. static inline void fscrypt_release_ctx(struct fscrypt_ctx *ctx)
  33. {
  34. return;
  35. }
  36. static inline struct page *fscrypt_encrypt_page(const struct inode *inode,
  37. struct page *page,
  38. unsigned int len,
  39. unsigned int offs,
  40. u64 lblk_num, gfp_t gfp_flags)
  41. {
  42. return ERR_PTR(-EOPNOTSUPP);
  43. }
  44. static inline int fscrypt_decrypt_page(const struct inode *inode,
  45. struct page *page,
  46. unsigned int len, unsigned int offs,
  47. u64 lblk_num)
  48. {
  49. return -EOPNOTSUPP;
  50. }
  51. static inline struct page *fscrypt_control_page(struct page *page)
  52. {
  53. WARN_ON_ONCE(1);
  54. return ERR_PTR(-EINVAL);
  55. }
  56. static inline void fscrypt_restore_control_page(struct page *page)
  57. {
  58. return;
  59. }
  60. /* policy.c */
  61. static inline int fscrypt_ioctl_set_policy(struct file *filp,
  62. const void __user *arg)
  63. {
  64. return -EOPNOTSUPP;
  65. }
  66. static inline int fscrypt_ioctl_get_policy(struct file *filp, void __user *arg)
  67. {
  68. return -EOPNOTSUPP;
  69. }
  70. static inline int fscrypt_has_permitted_context(struct inode *parent,
  71. struct inode *child)
  72. {
  73. return 0;
  74. }
  75. static inline int fscrypt_inherit_context(struct inode *parent,
  76. struct inode *child,
  77. void *fs_data, bool preload)
  78. {
  79. return -EOPNOTSUPP;
  80. }
  81. /* keyinfo.c */
  82. static inline int fscrypt_get_encryption_info(struct inode *inode)
  83. {
  84. return -EOPNOTSUPP;
  85. }
  86. static inline void fscrypt_put_encryption_info(struct inode *inode)
  87. {
  88. return;
  89. }
  90. /* fname.c */
  91. static inline int fscrypt_setup_filename(struct inode *dir,
  92. const struct qstr *iname,
  93. int lookup, struct fscrypt_name *fname)
  94. {
  95. if (IS_ENCRYPTED(dir))
  96. return -EOPNOTSUPP;
  97. memset(fname, 0, sizeof(struct fscrypt_name));
  98. fname->usr_fname = iname;
  99. fname->disk_name.name = (unsigned char *)iname->name;
  100. fname->disk_name.len = iname->len;
  101. return 0;
  102. }
  103. static inline void fscrypt_free_filename(struct fscrypt_name *fname)
  104. {
  105. return;
  106. }
  107. static inline int fscrypt_fname_alloc_buffer(const struct inode *inode,
  108. u32 max_encrypted_len,
  109. struct fscrypt_str *crypto_str)
  110. {
  111. return -EOPNOTSUPP;
  112. }
  113. static inline void fscrypt_fname_free_buffer(struct fscrypt_str *crypto_str)
  114. {
  115. return;
  116. }
  117. static inline int fscrypt_fname_disk_to_usr(struct inode *inode,
  118. u32 hash, u32 minor_hash,
  119. const struct fscrypt_str *iname,
  120. struct fscrypt_str *oname)
  121. {
  122. return -EOPNOTSUPP;
  123. }
  124. static inline bool fscrypt_match_name(const struct fscrypt_name *fname,
  125. const u8 *de_name, u32 de_name_len)
  126. {
  127. /* Encryption support disabled; use standard comparison */
  128. if (de_name_len != fname->disk_name.len)
  129. return false;
  130. return !memcmp(de_name, fname->disk_name.name, fname->disk_name.len);
  131. }
  132. /* bio.c */
  133. static inline void fscrypt_decrypt_bio(struct bio *bio)
  134. {
  135. }
  136. static inline void fscrypt_enqueue_decrypt_bio(struct fscrypt_ctx *ctx,
  137. struct bio *bio)
  138. {
  139. }
  140. static inline void fscrypt_pullback_bio_page(struct page **page, bool restore)
  141. {
  142. return;
  143. }
  144. static inline int fscrypt_zeroout_range(const struct inode *inode, pgoff_t lblk,
  145. sector_t pblk, unsigned int len)
  146. {
  147. return -EOPNOTSUPP;
  148. }
  149. /* hooks.c */
  150. static inline int fscrypt_file_open(struct inode *inode, struct file *filp)
  151. {
  152. if (IS_ENCRYPTED(inode))
  153. return -EOPNOTSUPP;
  154. return 0;
  155. }
  156. static inline int __fscrypt_prepare_link(struct inode *inode,
  157. struct inode *dir)
  158. {
  159. return -EOPNOTSUPP;
  160. }
  161. static inline int __fscrypt_prepare_rename(struct inode *old_dir,
  162. struct dentry *old_dentry,
  163. struct inode *new_dir,
  164. struct dentry *new_dentry,
  165. unsigned int flags)
  166. {
  167. return -EOPNOTSUPP;
  168. }
  169. static inline int __fscrypt_prepare_lookup(struct inode *dir,
  170. struct dentry *dentry)
  171. {
  172. return -EOPNOTSUPP;
  173. }
  174. static inline int __fscrypt_prepare_symlink(struct inode *dir,
  175. unsigned int len,
  176. unsigned int max_len,
  177. struct fscrypt_str *disk_link)
  178. {
  179. return -EOPNOTSUPP;
  180. }
  181. static inline int __fscrypt_encrypt_symlink(struct inode *inode,
  182. const char *target,
  183. unsigned int len,
  184. struct fscrypt_str *disk_link)
  185. {
  186. return -EOPNOTSUPP;
  187. }
  188. static inline const char *fscrypt_get_symlink(struct inode *inode,
  189. const void *caddr,
  190. unsigned int max_size,
  191. struct delayed_call *done)
  192. {
  193. return ERR_PTR(-EOPNOTSUPP);
  194. }
  195. #endif /* _LINUX_FSCRYPT_NOTSUPP_H */