]> git.sesse.net Git - bcachefs-tools-debian/blob - libbcachefs/acl.h
Update bcachefs sources to 0906b1fb49 bcachefs: fixes for 32 bit/big endian machines
[bcachefs-tools-debian] / libbcachefs / acl.h
1 #ifndef _BCACHEFS_ACL_H
2 #define _BCACHEFS_ACL_H
3
4 #ifdef CONFIG_BCACHEFS_POSIX_ACL
5
6 #define BCH_ACL_VERSION 0x0001
7
8 typedef struct {
9         __le16          e_tag;
10         __le16          e_perm;
11         __le32          e_id;
12 } bch_acl_entry;
13
14 typedef struct {
15         __le16          e_tag;
16         __le16          e_perm;
17 } bch_acl_entry_short;
18
19 typedef struct {
20         __le32          a_version;
21 } bch_acl_header;
22
23 static inline size_t bch2_acl_size(int count)
24 {
25         if (count <= 4) {
26                 return sizeof(bch_acl_header) +
27                        count * sizeof(bch_acl_entry_short);
28         } else {
29                 return sizeof(bch_acl_header) +
30                        4 * sizeof(bch_acl_entry_short) +
31                        (count - 4) * sizeof(bch_acl_entry);
32         }
33 }
34
35 static inline int bch2_acl_count(size_t size)
36 {
37         ssize_t s;
38
39         size -= sizeof(bch_acl_header);
40         s = size - 4 * sizeof(bch_acl_entry_short);
41         if (s < 0) {
42                 if (size % sizeof(bch_acl_entry_short))
43                         return -1;
44                 return size / sizeof(bch_acl_entry_short);
45         } else {
46                 if (s % sizeof(bch_acl_entry))
47                         return -1;
48                 return s / sizeof(bch_acl_entry) + 4;
49         }
50 }
51
52 struct posix_acl;
53
54 extern struct posix_acl *bch2_get_acl(struct inode *, int);
55 extern int bch2_set_acl(struct inode *, struct posix_acl *, int);
56
57 #else
58
59 static inline int bch2_set_acl(struct inode *inode, struct posix_acl *acl, int type)
60 {
61         return 0;
62 }
63
64 #endif /* CONFIG_BCACHEFS_POSIX_ACL */
65
66 #endif /* _BCACHEFS_ACL_H */