acl.h 1.5 KB

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