Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0
0002 /*
0003   File: fs/ext4/acl.h
0004 
0005   (C) 2001 Andreas Gruenbacher, <a.gruenbacher@computer.org>
0006 */
0007 
0008 #include <linux/posix_acl_xattr.h>
0009 
0010 #define EXT4_ACL_VERSION    0x0001
0011 
0012 typedef struct {
0013     __le16      e_tag;
0014     __le16      e_perm;
0015     __le32      e_id;
0016 } ext4_acl_entry;
0017 
0018 typedef struct {
0019     __le16      e_tag;
0020     __le16      e_perm;
0021 } ext4_acl_entry_short;
0022 
0023 typedef struct {
0024     __le32      a_version;
0025 } ext4_acl_header;
0026 
0027 static inline size_t ext4_acl_size(int count)
0028 {
0029     if (count <= 4) {
0030         return sizeof(ext4_acl_header) +
0031                count * sizeof(ext4_acl_entry_short);
0032     } else {
0033         return sizeof(ext4_acl_header) +
0034                4 * sizeof(ext4_acl_entry_short) +
0035                (count - 4) * sizeof(ext4_acl_entry);
0036     }
0037 }
0038 
0039 static inline int ext4_acl_count(size_t size)
0040 {
0041     ssize_t s;
0042     size -= sizeof(ext4_acl_header);
0043     s = size - 4 * sizeof(ext4_acl_entry_short);
0044     if (s < 0) {
0045         if (size % sizeof(ext4_acl_entry_short))
0046             return -1;
0047         return size / sizeof(ext4_acl_entry_short);
0048     } else {
0049         if (s % sizeof(ext4_acl_entry))
0050             return -1;
0051         return s / sizeof(ext4_acl_entry) + 4;
0052     }
0053 }
0054 
0055 #ifdef CONFIG_EXT4_FS_POSIX_ACL
0056 
0057 /* acl.c */
0058 struct posix_acl *ext4_get_acl(struct inode *inode, int type, bool rcu);
0059 int ext4_set_acl(struct user_namespace *mnt_userns, struct inode *inode,
0060          struct posix_acl *acl, int type);
0061 extern int ext4_init_acl(handle_t *, struct inode *, struct inode *);
0062 
0063 #else  /* CONFIG_EXT4_FS_POSIX_ACL */
0064 #include <linux/sched.h>
0065 #define ext4_get_acl NULL
0066 #define ext4_set_acl NULL
0067 
0068 static inline int
0069 ext4_init_acl(handle_t *handle, struct inode *inode, struct inode *dir)
0070 {
0071     return 0;
0072 }
0073 #endif  /* CONFIG_EXT4_FS_POSIX_ACL */
0074