posix_acl_xattr.h 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /*
  3. File: linux/posix_acl_xattr.h
  4. Extended attribute system call representation of Access Control Lists.
  5. Copyright (C) 2000 by Andreas Gruenbacher <a.gruenbacher@computer.org>
  6. Copyright (C) 2002 SGI - Silicon Graphics, Inc <linux-xfs@oss.sgi.com>
  7. */
  8. #ifndef _POSIX_ACL_XATTR_H
  9. #define _POSIX_ACL_XATTR_H
  10. #include <uapi/linux/xattr.h>
  11. #include <uapi/linux/posix_acl_xattr.h>
  12. #include <linux/posix_acl.h>
  13. static inline size_t
  14. posix_acl_xattr_size(int count)
  15. {
  16. return (sizeof(struct posix_acl_xattr_header) +
  17. (count * sizeof(struct posix_acl_xattr_entry)));
  18. }
  19. static inline int
  20. posix_acl_xattr_count(size_t size)
  21. {
  22. if (size < sizeof(struct posix_acl_xattr_header))
  23. return -1;
  24. size -= sizeof(struct posix_acl_xattr_header);
  25. if (size % sizeof(struct posix_acl_xattr_entry))
  26. return -1;
  27. return size / sizeof(struct posix_acl_xattr_entry);
  28. }
  29. #ifdef CONFIG_FS_POSIX_ACL
  30. void posix_acl_fix_xattr_from_user(void *value, size_t size);
  31. void posix_acl_fix_xattr_to_user(void *value, size_t size);
  32. #else
  33. static inline void posix_acl_fix_xattr_from_user(void *value, size_t size)
  34. {
  35. }
  36. static inline void posix_acl_fix_xattr_to_user(void *value, size_t size)
  37. {
  38. }
  39. #endif
  40. struct posix_acl *posix_acl_from_xattr(struct user_namespace *user_ns,
  41. const void *value, size_t size);
  42. int posix_acl_to_xattr(struct user_namespace *user_ns,
  43. const struct posix_acl *acl, void *buffer, size_t size);
  44. extern const struct xattr_handler posix_acl_access_xattr_handler;
  45. extern const struct xattr_handler posix_acl_default_xattr_handler;
  46. #endif /* _POSIX_ACL_XATTR_H */