posix_acl_xattr.h 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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. #ifdef CONFIG_FS_POSIX_ACL
  43. void posix_acl_fix_xattr_from_user(void *value, size_t size);
  44. void posix_acl_fix_xattr_to_user(void *value, size_t size);
  45. #else
  46. static inline void posix_acl_fix_xattr_from_user(void *value, size_t size)
  47. {
  48. }
  49. static inline void posix_acl_fix_xattr_to_user(void *value, size_t size)
  50. {
  51. }
  52. #endif
  53. struct posix_acl *posix_acl_from_xattr(struct user_namespace *user_ns,
  54. const void *value, size_t size);
  55. int posix_acl_to_xattr(struct user_namespace *user_ns,
  56. const struct posix_acl *acl, void *buffer, size_t size);
  57. extern const struct xattr_handler posix_acl_access_xattr_handler;
  58. extern const struct xattr_handler posix_acl_default_xattr_handler;
  59. #endif /* _POSIX_ACL_XATTR_H */