acl.h 1.5 KB

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