pft.h 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. /* Copyright (c) 2014, The Linux Foundation. All rights reserved.
  2. *
  3. * This program is free software; you can redistribute it and/or modify
  4. * it under the terms of the GNU General Public License version 2 and
  5. * only version 2 as published by the Free Software Foundation.
  6. *
  7. * This program is distributed in the hope that it will be useful,
  8. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. * GNU General Public License for more details.
  11. */
  12. #ifndef PFT_H_
  13. #define PFT_H_
  14. #include <linux/types.h>
  15. #include <linux/fs.h>
  16. #include <linux/bio.h>
  17. #ifdef CONFIG_PFT
  18. /* dm-req-crypt API */
  19. int pft_get_key_index(struct bio *bio, u32 *key_index,
  20. bool *is_encrypted, bool *is_inplace);
  21. /* block layer API */
  22. bool pft_allow_merge_bio(struct bio *bio1, struct bio *bio2);
  23. /* --- security hooks , called from selinux --- */
  24. int pft_inode_create(struct inode *dir, struct dentry *dentry, umode_t mode);
  25. int pft_inode_post_create(struct inode *dir, struct dentry *dentry,
  26. umode_t mode);
  27. int pft_file_open(struct file *filp, const struct cred *cred);
  28. int pft_file_permission(struct file *file, int mask);
  29. int pft_file_close(struct file *filp);
  30. int pft_inode_unlink(struct inode *dir, struct dentry *dentry);
  31. int pft_inode_mknod(struct inode *dir, struct dentry *dentry, umode_t mode,
  32. dev_t dev);
  33. int pft_inode_rename(struct inode *inode, struct dentry *dentry,
  34. struct inode *new_inode, struct dentry *new_dentry);
  35. int pft_inode_set_xattr(struct dentry *dentry, const char *name);
  36. #else
  37. static inline int pft_get_key_index(struct inode *inode, u32 *key_index,
  38. bool *is_encrypted, bool *is_inplace)
  39. { return -ENODEV; }
  40. static inline bool pft_allow_merge_bio(struct bio *bio1, struct bio *bio2)
  41. { return true; }
  42. static inline int pft_file_permission(struct file *file, int mask)
  43. { return 0; }
  44. static inline int pft_inode_create(
  45. struct inode *dir, struct dentry *dentry, umode_t mode)
  46. { return 0; }
  47. static inline int pft_inode_post_create(
  48. struct inode *dir, struct dentry *dentry, umode_t mode)
  49. { return 0; }
  50. static inline int pft_file_open(struct file *filp, const struct cred *cred)
  51. { return 0; }
  52. static inline int pft_file_close(struct file *filp)
  53. { return 0; }
  54. static inline int pft_inode_unlink(struct inode *dir, struct dentry *dentry)
  55. { return 0; }
  56. static inline int pft_inode_mknod(struct inode *dir, struct dentry *dentry,
  57. umode_t mode, dev_t dev)
  58. { return 0; }
  59. static inline int pft_inode_rename(struct inode *inode, struct dentry *dentry,
  60. struct inode *new_inode, struct dentry *new_dentry)
  61. { return 0; }
  62. static inline int pft_inode_set_xattr(struct dentry *dentry, const char *name)
  63. { return 0; }
  64. #endif /* CONFIG_PFT */
  65. #endif /* PFT_H */