posix_acl_xattr.h 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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 <[email protected]>
  6. Copyright (C) 2002 SGI - Silicon Graphics, Inc <[email protected]>
  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. void posix_acl_getxattr_idmapped_mnt(struct user_namespace *mnt_userns,
  33. const struct inode *inode,
  34. void *value, size_t size);
  35. #else
  36. static inline void posix_acl_fix_xattr_from_user(void *value, size_t size)
  37. {
  38. }
  39. static inline void posix_acl_fix_xattr_to_user(void *value, size_t size)
  40. {
  41. }
  42. static inline void
  43. posix_acl_getxattr_idmapped_mnt(struct user_namespace *mnt_userns,
  44. const struct inode *inode, void *value,
  45. size_t size)
  46. {
  47. }
  48. #endif
  49. struct posix_acl *posix_acl_from_xattr(struct user_namespace *user_ns,
  50. const void *value, size_t size);
  51. int posix_acl_to_xattr(struct user_namespace *user_ns,
  52. const struct posix_acl *acl, void *buffer, size_t size);
  53. struct posix_acl *vfs_set_acl_prepare(struct user_namespace *mnt_userns,
  54. struct user_namespace *fs_userns,
  55. const void *value, size_t size);
  56. extern const struct xattr_handler posix_acl_access_xattr_handler;
  57. extern const struct xattr_handler posix_acl_default_xattr_handler;
  58. #endif /* _POSIX_ACL_XATTR_H */