blob: 2387709991b54a39a2726268b08185c9b50f9a6d [file] [log] [blame]
Greg Kroah-Hartmanb2441312017-11-01 15:07:57 +01001/* SPDX-License-Identifier: GPL-2.0 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002/*
3 File: linux/posix_acl_xattr.h
4
5 Extended attribute system call representation of Access Control Lists.
6
7 Copyright (C) 2000 by Andreas Gruenbacher <a.gruenbacher@computer.org>
8 Copyright (C) 2002 SGI - Silicon Graphics, Inc <linux-xfs@oss.sgi.com>
9 */
10#ifndef _POSIX_ACL_XATTR_H
11#define _POSIX_ACL_XATTR_H
12
Andreas Gruenbacher97d79292015-12-02 14:44:35 +010013#include <uapi/linux/xattr.h>
Andreas Gruenbacherbc8bcf32016-09-27 13:03:23 +020014#include <uapi/linux/posix_acl_xattr.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070015#include <linux/posix_acl.h>
16
Linus Torvalds1da177e2005-04-16 15:20:36 -070017static inline size_t
18posix_acl_xattr_size(int count)
19{
Andreas Gruenbacher2211d5b2016-09-27 13:03:22 +020020 return (sizeof(struct posix_acl_xattr_header) +
21 (count * sizeof(struct posix_acl_xattr_entry)));
Linus Torvalds1da177e2005-04-16 15:20:36 -070022}
23
24static inline int
25posix_acl_xattr_count(size_t size)
26{
Andreas Gruenbacher2211d5b2016-09-27 13:03:22 +020027 if (size < sizeof(struct posix_acl_xattr_header))
Linus Torvalds1da177e2005-04-16 15:20:36 -070028 return -1;
Andreas Gruenbacher2211d5b2016-09-27 13:03:22 +020029 size -= sizeof(struct posix_acl_xattr_header);
30 if (size % sizeof(struct posix_acl_xattr_entry))
Linus Torvalds1da177e2005-04-16 15:20:36 -070031 return -1;
Andreas Gruenbacher2211d5b2016-09-27 13:03:22 +020032 return size / sizeof(struct posix_acl_xattr_entry);
Linus Torvalds1da177e2005-04-16 15:20:36 -070033}
34
Eric W. Biederman2f6f0652012-02-07 18:52:57 -080035#ifdef CONFIG_FS_POSIX_ACL
36void posix_acl_fix_xattr_from_user(void *value, size_t size);
37void posix_acl_fix_xattr_to_user(void *value, size_t size);
38#else
39static inline void posix_acl_fix_xattr_from_user(void *value, size_t size)
40{
41}
42static inline void posix_acl_fix_xattr_to_user(void *value, size_t size)
43{
44}
45#endif
46
Eric W. Biederman5f3a4a282012-09-10 20:17:44 -070047struct posix_acl *posix_acl_from_xattr(struct user_namespace *user_ns,
48 const void *value, size_t size);
49int posix_acl_to_xattr(struct user_namespace *user_ns,
50 const struct posix_acl *acl, void *buffer, size_t size);
Christoph Hellwig9a59f452005-06-23 00:10:19 -070051
Christoph Hellwig2aeccbe2013-12-20 05:16:40 -080052extern const struct xattr_handler posix_acl_access_xattr_handler;
53extern const struct xattr_handler posix_acl_default_xattr_handler;
54
Linus Torvalds1da177e2005-04-16 15:20:36 -070055#endif /* _POSIX_ACL_XATTR_H */