]> git.sesse.net Git - bcachefs-tools-debian/blob - libbcachefs/acl.h
Faster crc32c
[bcachefs-tools-debian] / libbcachefs / acl.h
1 /*
2   File: fs/bch/acl.h
3
4   (C) 2001 Andreas Gruenbacher, <a.gruenbacher@computer.org>
5 */
6
7 #include <linux/posix_acl_xattr.h>
8
9 #define BCH_ACL_VERSION 0x0001
10
11 typedef struct {
12         __le16          e_tag;
13         __le16          e_perm;
14         __le32          e_id;
15 } bch_acl_entry;
16
17 typedef struct {
18         __le16          e_tag;
19         __le16          e_perm;
20 } bch_acl_entry_short;
21
22 typedef struct {
23         __le32          a_version;
24 } bch_acl_header;
25
26 static inline size_t bch2_acl_size(int count)
27 {
28         if (count <= 4) {
29                 return sizeof(bch_acl_header) +
30                        count * sizeof(bch_acl_entry_short);
31         } else {
32                 return sizeof(bch_acl_header) +
33                        4 * sizeof(bch_acl_entry_short) +
34                        (count - 4) * sizeof(bch_acl_entry);
35         }
36 }
37
38 static inline int bch2_acl_count(size_t size)
39 {
40         ssize_t s;
41
42         size -= sizeof(bch_acl_header);
43         s = size - 4 * sizeof(bch_acl_entry_short);
44         if (s < 0) {
45                 if (size % sizeof(bch_acl_entry_short))
46                         return -1;
47                 return size / sizeof(bch_acl_entry_short);
48         } else {
49                 if (s % sizeof(bch_acl_entry))
50                         return -1;
51                 return s / sizeof(bch_acl_entry) + 4;
52         }
53 }
54
55 extern struct posix_acl *bch2_get_acl(struct inode *, int);
56 extern int bch2_set_acl(struct inode *, struct posix_acl *, int);