acl.h 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. #include <linux/init.h>
  3. #include <linux/posix_acl.h>
  4. #define REISERFS_ACL_VERSION 0x0001
  5. typedef struct {
  6. __le16 e_tag;
  7. __le16 e_perm;
  8. __le32 e_id;
  9. } reiserfs_acl_entry;
  10. typedef struct {
  11. __le16 e_tag;
  12. __le16 e_perm;
  13. } reiserfs_acl_entry_short;
  14. typedef struct {
  15. __le32 a_version;
  16. } reiserfs_acl_header;
  17. static inline size_t reiserfs_acl_size(int count)
  18. {
  19. if (count <= 4) {
  20. return sizeof(reiserfs_acl_header) +
  21. count * sizeof(reiserfs_acl_entry_short);
  22. } else {
  23. return sizeof(reiserfs_acl_header) +
  24. 4 * sizeof(reiserfs_acl_entry_short) +
  25. (count - 4) * sizeof(reiserfs_acl_entry);
  26. }
  27. }
  28. static inline int reiserfs_acl_count(size_t size)
  29. {
  30. ssize_t s;
  31. size -= sizeof(reiserfs_acl_header);
  32. s = size - 4 * sizeof(reiserfs_acl_entry_short);
  33. if (s < 0) {
  34. if (size % sizeof(reiserfs_acl_entry_short))
  35. return -1;
  36. return size / sizeof(reiserfs_acl_entry_short);
  37. } else {
  38. if (s % sizeof(reiserfs_acl_entry))
  39. return -1;
  40. return s / sizeof(reiserfs_acl_entry) + 4;
  41. }
  42. }
  43. #ifdef CONFIG_REISERFS_FS_POSIX_ACL
  44. struct posix_acl *reiserfs_get_acl(struct inode *inode, int type);
  45. int reiserfs_set_acl(struct inode *inode, struct posix_acl *acl, int type);
  46. int reiserfs_acl_chmod(struct inode *inode);
  47. int reiserfs_inherit_default_acl(struct reiserfs_transaction_handle *th,
  48. struct inode *dir, struct dentry *dentry,
  49. struct inode *inode);
  50. int reiserfs_cache_default_acl(struct inode *dir);
  51. #else
  52. #define reiserfs_cache_default_acl(inode) 0
  53. #define reiserfs_get_acl NULL
  54. #define reiserfs_set_acl NULL
  55. static inline int reiserfs_acl_chmod(struct inode *inode)
  56. {
  57. return 0;
  58. }
  59. static inline int
  60. reiserfs_inherit_default_acl(struct reiserfs_transaction_handle *th,
  61. const struct inode *dir, struct dentry *dentry,
  62. struct inode *inode)
  63. {
  64. return 0;
  65. }
  66. #endif