0001
0002
0003
0004
0005
0006
0007
0008 #include <linux/posix_acl_xattr.h>
0009
0010 #define EXT2_ACL_VERSION 0x0001
0011
0012 typedef struct {
0013 __le16 e_tag;
0014 __le16 e_perm;
0015 __le32 e_id;
0016 } ext2_acl_entry;
0017
0018 typedef struct {
0019 __le16 e_tag;
0020 __le16 e_perm;
0021 } ext2_acl_entry_short;
0022
0023 typedef struct {
0024 __le32 a_version;
0025 } ext2_acl_header;
0026
0027 static inline size_t ext2_acl_size(int count)
0028 {
0029 if (count <= 4) {
0030 return sizeof(ext2_acl_header) +
0031 count * sizeof(ext2_acl_entry_short);
0032 } else {
0033 return sizeof(ext2_acl_header) +
0034 4 * sizeof(ext2_acl_entry_short) +
0035 (count - 4) * sizeof(ext2_acl_entry);
0036 }
0037 }
0038
0039 static inline int ext2_acl_count(size_t size)
0040 {
0041 ssize_t s;
0042 size -= sizeof(ext2_acl_header);
0043 s = size - 4 * sizeof(ext2_acl_entry_short);
0044 if (s < 0) {
0045 if (size % sizeof(ext2_acl_entry_short))
0046 return -1;
0047 return size / sizeof(ext2_acl_entry_short);
0048 } else {
0049 if (s % sizeof(ext2_acl_entry))
0050 return -1;
0051 return s / sizeof(ext2_acl_entry) + 4;
0052 }
0053 }
0054
0055 #ifdef CONFIG_EXT2_FS_POSIX_ACL
0056
0057
0058 extern struct posix_acl *ext2_get_acl(struct inode *inode, int type, bool rcu);
0059 extern int ext2_set_acl(struct user_namespace *mnt_userns, struct inode *inode,
0060 struct posix_acl *acl, int type);
0061 extern int ext2_init_acl (struct inode *, struct inode *);
0062
0063 #else
0064 #include <linux/sched.h>
0065 #define ext2_get_acl NULL
0066 #define ext2_set_acl NULL
0067
0068 static inline int ext2_init_acl (struct inode *inode, struct inode *dir)
0069 {
0070 return 0;
0071 }
0072 #endif
0073