posix_acl_xattr.h 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. /*
  2. File: linux/posix_acl_xattr.h
  3. Extended attribute system call representation of Access Control Lists.
  4. Copyright (C) 2000 by Andreas Gruenbacher <a.gruenbacher@computer.org>
  5. Copyright (C) 2002 SGI - Silicon Graphics, Inc <linux-xfs@oss.sgi.com>
  6. */
  7. #ifndef _POSIX_ACL_XATTR_H
  8. #define _POSIX_ACL_XATTR_H
  9. #include <linux/posix_acl.h>
  10. /* Extended attribute names */
  11. #define POSIX_ACL_XATTR_ACCESS "system.posix_acl_access"
  12. #define POSIX_ACL_XATTR_DEFAULT "system.posix_acl_default"
  13. /* Supported ACL a_version fields */
  14. #define POSIX_ACL_XATTR_VERSION 0x0002
  15. /* An undefined entry e_id value */
  16. #define ACL_UNDEFINED_ID (-1)
  17. typedef struct {
  18. __le16 e_tag;
  19. __le16 e_perm;
  20. __le32 e_id;
  21. } posix_acl_xattr_entry;
  22. typedef struct {
  23. __le32 a_version;
  24. posix_acl_xattr_entry a_entries[0];
  25. } posix_acl_xattr_header;
  26. static inline size_t
  27. posix_acl_xattr_size(int count)
  28. {
  29. return (sizeof(posix_acl_xattr_header) +
  30. (count * sizeof(posix_acl_xattr_entry)));
  31. }
  32. static inline int
  33. posix_acl_xattr_count(size_t size)
  34. {
  35. if (size < sizeof(posix_acl_xattr_header))
  36. return -1;
  37. size -= sizeof(posix_acl_xattr_header);
  38. if (size % sizeof(posix_acl_xattr_entry))
  39. return -1;
  40. return size / sizeof(posix_acl_xattr_entry);
  41. }
  42. struct posix_acl *posix_acl_from_xattr(const void *value, size_t size);
  43. int posix_acl_to_xattr(const struct posix_acl *acl, void *buffer, size_t size);
  44. #endif /* _POSIX_ACL_XATTR_H */