acl.h 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. /*
  2. File: fs/ext4/acl.h
  3. (C) 2001 Andreas Gruenbacher, <a.gruenbacher@computer.org>
  4. */
  5. #include <linux/posix_acl_xattr.h>
  6. #define EXT4_ACL_VERSION 0x0001
  7. typedef struct {
  8. __le16 e_tag;
  9. __le16 e_perm;
  10. __le32 e_id;
  11. } ext4_acl_entry;
  12. typedef struct {
  13. __le16 e_tag;
  14. __le16 e_perm;
  15. } ext4_acl_entry_short;
  16. typedef struct {
  17. __le32 a_version;
  18. } ext4_acl_header;
  19. static inline size_t ext4_acl_size(int count)
  20. {
  21. if (count <= 4) {
  22. return sizeof(ext4_acl_header) +
  23. count * sizeof(ext4_acl_entry_short);
  24. } else {
  25. return sizeof(ext4_acl_header) +
  26. 4 * sizeof(ext4_acl_entry_short) +
  27. (count - 4) * sizeof(ext4_acl_entry);
  28. }
  29. }
  30. static inline int ext4_acl_count(size_t size)
  31. {
  32. ssize_t s;
  33. size -= sizeof(ext4_acl_header);
  34. s = size - 4 * sizeof(ext4_acl_entry_short);
  35. if (s < 0) {
  36. if (size % sizeof(ext4_acl_entry_short))
  37. return -1;
  38. return size / sizeof(ext4_acl_entry_short);
  39. } else {
  40. if (s % sizeof(ext4_acl_entry))
  41. return -1;
  42. return s / sizeof(ext4_acl_entry) + 4;
  43. }
  44. }
  45. #ifdef CONFIG_EXT4DEV_FS_POSIX_ACL
  46. /* Value for inode->u.ext4_i.i_acl and inode->u.ext4_i.i_default_acl
  47. if the ACL has not been cached */
  48. #define EXT4_ACL_NOT_CACHED ((void *)-1)
  49. /* acl.c */
  50. extern int ext4_permission (struct inode *, int, struct nameidata *);
  51. extern int ext4_acl_chmod (struct inode *);
  52. extern int ext4_init_acl (handle_t *, struct inode *, struct inode *);
  53. #else /* CONFIG_EXT4DEV_FS_POSIX_ACL */
  54. #include <linux/sched.h>
  55. #define ext4_permission NULL
  56. static inline int
  57. ext4_acl_chmod(struct inode *inode)
  58. {
  59. return 0;
  60. }
  61. static inline int
  62. ext4_init_acl(handle_t *handle, struct inode *inode, struct inode *dir)
  63. {
  64. return 0;
  65. }
  66. #endif /* CONFIG_EXT4DEV_FS_POSIX_ACL */