Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 2 | File: linux/posix_acl_xattr.h |
| 3 | |
| 4 | Extended attribute system call representation of Access Control Lists. |
| 5 | |
| 6 | Copyright (C) 2000 by Andreas Gruenbacher <a.gruenbacher@computer.org> |
| 7 | Copyright (C) 2002 SGI - Silicon Graphics, Inc <linux-xfs@oss.sgi.com> |
| 8 | */ |
| 9 | #ifndef _POSIX_ACL_XATTR_H |
| 10 | #define _POSIX_ACL_XATTR_H |
| 11 | |
Andreas Gruenbacher | 97d7929 | 2015-12-02 14:44:35 +0100 | [diff] [blame] | 12 | #include <uapi/linux/xattr.h> |
Andreas Gruenbacher | bc8bcf3 | 2016-09-27 13:03:23 +0200 | [diff] [blame] | 13 | #include <uapi/linux/posix_acl_xattr.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 14 | #include <linux/posix_acl.h> |
| 15 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 16 | static inline size_t |
| 17 | posix_acl_xattr_size(int count) |
| 18 | { |
Andreas Gruenbacher | 2211d5b | 2016-09-27 13:03:22 +0200 | [diff] [blame] | 19 | return (sizeof(struct posix_acl_xattr_header) + |
| 20 | (count * sizeof(struct posix_acl_xattr_entry))); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 21 | } |
| 22 | |
| 23 | static inline int |
| 24 | posix_acl_xattr_count(size_t size) |
| 25 | { |
Andreas Gruenbacher | 2211d5b | 2016-09-27 13:03:22 +0200 | [diff] [blame] | 26 | if (size < sizeof(struct posix_acl_xattr_header)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 27 | return -1; |
Andreas Gruenbacher | 2211d5b | 2016-09-27 13:03:22 +0200 | [diff] [blame] | 28 | size -= sizeof(struct posix_acl_xattr_header); |
| 29 | if (size % sizeof(struct posix_acl_xattr_entry)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 30 | return -1; |
Andreas Gruenbacher | 2211d5b | 2016-09-27 13:03:22 +0200 | [diff] [blame] | 31 | return size / sizeof(struct posix_acl_xattr_entry); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 32 | } |
| 33 | |
Eric W. Biederman | 2f6f065 | 2012-02-07 18:52:57 -0800 | [diff] [blame] | 34 | #ifdef CONFIG_FS_POSIX_ACL |
| 35 | void posix_acl_fix_xattr_from_user(void *value, size_t size); |
| 36 | void posix_acl_fix_xattr_to_user(void *value, size_t size); |
| 37 | #else |
| 38 | static inline void posix_acl_fix_xattr_from_user(void *value, size_t size) |
| 39 | { |
| 40 | } |
| 41 | static inline void posix_acl_fix_xattr_to_user(void *value, size_t size) |
| 42 | { |
| 43 | } |
| 44 | #endif |
| 45 | |
Eric W. Biederman | 5f3a4a2 | 2012-09-10 20:17:44 -0700 | [diff] [blame] | 46 | struct posix_acl *posix_acl_from_xattr(struct user_namespace *user_ns, |
| 47 | const void *value, size_t size); |
| 48 | int posix_acl_to_xattr(struct user_namespace *user_ns, |
| 49 | const struct posix_acl *acl, void *buffer, size_t size); |
Christoph Hellwig | 9a59f45 | 2005-06-23 00:10:19 -0700 | [diff] [blame] | 50 | |
Christoph Hellwig | 2aeccbe | 2013-12-20 05:16:40 -0800 | [diff] [blame] | 51 | extern const struct xattr_handler posix_acl_access_xattr_handler; |
| 52 | extern const struct xattr_handler posix_acl_default_xattr_handler; |
| 53 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 54 | #endif /* _POSIX_ACL_XATTR_H */ |