blob: 8b867e3bf3aa84e553e2c02fa0e6244284abcc51 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
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 Gruenbacher97d79292015-12-02 14:44:35 +010012#include <uapi/linux/xattr.h>
Andreas Gruenbacherbc8bcf32016-09-27 13:03:23 +020013#include <uapi/linux/posix_acl_xattr.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070014#include <linux/posix_acl.h>
15
Linus Torvalds1da177e2005-04-16 15:20:36 -070016static inline size_t
17posix_acl_xattr_size(int count)
18{
Andreas Gruenbacher2211d5b2016-09-27 13:03:22 +020019 return (sizeof(struct posix_acl_xattr_header) +
20 (count * sizeof(struct posix_acl_xattr_entry)));
Linus Torvalds1da177e2005-04-16 15:20:36 -070021}
22
23static inline int
24posix_acl_xattr_count(size_t size)
25{
Andreas Gruenbacher2211d5b2016-09-27 13:03:22 +020026 if (size < sizeof(struct posix_acl_xattr_header))
Linus Torvalds1da177e2005-04-16 15:20:36 -070027 return -1;
Andreas Gruenbacher2211d5b2016-09-27 13:03:22 +020028 size -= sizeof(struct posix_acl_xattr_header);
29 if (size % sizeof(struct posix_acl_xattr_entry))
Linus Torvalds1da177e2005-04-16 15:20:36 -070030 return -1;
Andreas Gruenbacher2211d5b2016-09-27 13:03:22 +020031 return size / sizeof(struct posix_acl_xattr_entry);
Linus Torvalds1da177e2005-04-16 15:20:36 -070032}
33
Eric W. Biederman2f6f0652012-02-07 18:52:57 -080034#ifdef CONFIG_FS_POSIX_ACL
35void posix_acl_fix_xattr_from_user(void *value, size_t size);
36void posix_acl_fix_xattr_to_user(void *value, size_t size);
37#else
38static inline void posix_acl_fix_xattr_from_user(void *value, size_t size)
39{
40}
41static inline void posix_acl_fix_xattr_to_user(void *value, size_t size)
42{
43}
44#endif
45
Eric W. Biederman5f3a4a22012-09-10 20:17:44 -070046struct posix_acl *posix_acl_from_xattr(struct user_namespace *user_ns,
47 const void *value, size_t size);
48int posix_acl_to_xattr(struct user_namespace *user_ns,
49 const struct posix_acl *acl, void *buffer, size_t size);
Christoph Hellwig9a59f452005-06-23 00:10:19 -070050
Christoph Hellwig2aeccbe2013-12-20 05:16:40 -080051extern const struct xattr_handler posix_acl_access_xattr_handler;
52extern const struct xattr_handler posix_acl_default_xattr_handler;
53
Linus Torvalds1da177e2005-04-16 15:20:36 -070054#endif /* _POSIX_ACL_XATTR_H */