Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 */
0002 /*
0003   File: linux/posix_acl_xattr.h
0004 
0005   Extended attribute system call representation of Access Control Lists.
0006 
0007   Copyright (C) 2000 by Andreas Gruenbacher <a.gruenbacher@computer.org>
0008   Copyright (C) 2002 SGI - Silicon Graphics, Inc <linux-xfs@oss.sgi.com>
0009  */
0010 #ifndef _POSIX_ACL_XATTR_H
0011 #define _POSIX_ACL_XATTR_H
0012 
0013 #include <uapi/linux/xattr.h>
0014 #include <uapi/linux/posix_acl_xattr.h>
0015 #include <linux/posix_acl.h>
0016 
0017 static inline size_t
0018 posix_acl_xattr_size(int count)
0019 {
0020     return (sizeof(struct posix_acl_xattr_header) +
0021         (count * sizeof(struct posix_acl_xattr_entry)));
0022 }
0023 
0024 static inline int
0025 posix_acl_xattr_count(size_t size)
0026 {
0027     if (size < sizeof(struct posix_acl_xattr_header))
0028         return -1;
0029     size -= sizeof(struct posix_acl_xattr_header);
0030     if (size % sizeof(struct posix_acl_xattr_entry))
0031         return -1;
0032     return size / sizeof(struct posix_acl_xattr_entry);
0033 }
0034 
0035 #ifdef CONFIG_FS_POSIX_ACL
0036 void posix_acl_fix_xattr_from_user(void *value, size_t size);
0037 void posix_acl_fix_xattr_to_user(void *value, size_t size);
0038 void posix_acl_getxattr_idmapped_mnt(struct user_namespace *mnt_userns,
0039                      const struct inode *inode,
0040                      void *value, size_t size);
0041 void posix_acl_setxattr_idmapped_mnt(struct user_namespace *mnt_userns,
0042                      const struct inode *inode,
0043                      void *value, size_t size);
0044 #else
0045 static inline void posix_acl_fix_xattr_from_user(void *value, size_t size)
0046 {
0047 }
0048 static inline void posix_acl_fix_xattr_to_user(void *value, size_t size)
0049 {
0050 }
0051 static inline void
0052 posix_acl_getxattr_idmapped_mnt(struct user_namespace *mnt_userns,
0053                 const struct inode *inode, void *value,
0054                 size_t size)
0055 {
0056 }
0057 static inline void
0058 posix_acl_setxattr_idmapped_mnt(struct user_namespace *mnt_userns,
0059                 const struct inode *inode, void *value,
0060                 size_t size)
0061 {
0062 }
0063 #endif
0064 
0065 struct posix_acl *posix_acl_from_xattr(struct user_namespace *user_ns, 
0066                        const void *value, size_t size);
0067 int posix_acl_to_xattr(struct user_namespace *user_ns,
0068                const struct posix_acl *acl, void *buffer, size_t size);
0069 
0070 extern const struct xattr_handler posix_acl_access_xattr_handler;
0071 extern const struct xattr_handler posix_acl_default_xattr_handler;
0072 
0073 #endif  /* _POSIX_ACL_XATTR_H */