acl.h 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. // SPDX-License-Identifier: GPL-2.0
  2. /*
  3. File: fs/ext4/acl.h
  4. (C) 2001 Andreas Gruenbacher, <a.gruenbacher@computer.org>
  5. */
  6. #include <linux/posix_acl_xattr.h>
  7. #define EXT4_ACL_VERSION 0x0001
  8. typedef struct {
  9. __le16 e_tag;
  10. __le16 e_perm;
  11. __le32 e_id;
  12. } ext4_acl_entry;
  13. typedef struct {
  14. __le16 e_tag;
  15. __le16 e_perm;
  16. } ext4_acl_entry_short;
  17. typedef struct {
  18. __le32 a_version;
  19. } ext4_acl_header;
  20. static inline size_t ext4_acl_size(int count)
  21. {
  22. if (count <= 4) {
  23. return sizeof(ext4_acl_header) +
  24. count * sizeof(ext4_acl_entry_short);
  25. } else {
  26. return sizeof(ext4_acl_header) +
  27. 4 * sizeof(ext4_acl_entry_short) +
  28. (count - 4) * sizeof(ext4_acl_entry);
  29. }
  30. }
  31. static inline int ext4_acl_count(size_t size)
  32. {
  33. ssize_t s;
  34. size -= sizeof(ext4_acl_header);
  35. s = size - 4 * sizeof(ext4_acl_entry_short);
  36. if (s < 0) {
  37. if (size % sizeof(ext4_acl_entry_short))
  38. return -1;
  39. return size / sizeof(ext4_acl_entry_short);
  40. } else {
  41. if (s % sizeof(ext4_acl_entry))
  42. return -1;
  43. return s / sizeof(ext4_acl_entry) + 4;
  44. }
  45. }
  46. #ifdef CONFIG_EXT4_FS_POSIX_ACL
  47. /* acl.c */
  48. struct posix_acl *ext4_get_acl(struct inode *inode, int type);
  49. int ext4_set_acl(struct inode *inode, struct posix_acl *acl, int type);
  50. extern int ext4_init_acl(handle_t *, struct inode *, struct inode *);
  51. #else /* CONFIG_EXT4_FS_POSIX_ACL */
  52. #include <linux/sched.h>
  53. #define ext4_get_acl NULL
  54. #define ext4_set_acl NULL
  55. static inline int
  56. ext4_init_acl(handle_t *handle, struct inode *inode, struct inode *dir)
  57. {
  58. return 0;
  59. }
  60. #endif /* CONFIG_EXT4_FS_POSIX_ACL */