acl.h 1.8 KB

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