]>
Commit | Line | Data |
---|---|---|
b2441318 | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
1da177e4 LT |
2 | #include <linux/init.h> |
3 | #include <linux/posix_acl.h> | |
1da177e4 LT |
4 | |
5 | #define REISERFS_ACL_VERSION 0x0001 | |
6 | ||
7 | typedef struct { | |
bd4c625c LT |
8 | __le16 e_tag; |
9 | __le16 e_perm; | |
10 | __le32 e_id; | |
1da177e4 LT |
11 | } reiserfs_acl_entry; |
12 | ||
13 | typedef struct { | |
bd4c625c LT |
14 | __le16 e_tag; |
15 | __le16 e_perm; | |
1da177e4 LT |
16 | } reiserfs_acl_entry_short; |
17 | ||
18 | typedef struct { | |
bd4c625c | 19 | __le32 a_version; |
1da177e4 LT |
20 | } reiserfs_acl_header; |
21 | ||
22 | static inline size_t reiserfs_acl_size(int count) | |
23 | { | |
24 | if (count <= 4) { | |
25 | return sizeof(reiserfs_acl_header) + | |
bd4c625c | 26 | count * sizeof(reiserfs_acl_entry_short); |
1da177e4 LT |
27 | } else { |
28 | return sizeof(reiserfs_acl_header) + | |
bd4c625c LT |
29 | 4 * sizeof(reiserfs_acl_entry_short) + |
30 | (count - 4) * sizeof(reiserfs_acl_entry); | |
1da177e4 LT |
31 | } |
32 | } | |
33 | ||
34 | static inline int reiserfs_acl_count(size_t size) | |
35 | { | |
36 | ssize_t s; | |
37 | size -= sizeof(reiserfs_acl_header); | |
38 | s = size - 4 * sizeof(reiserfs_acl_entry_short); | |
39 | if (s < 0) { | |
40 | if (size % sizeof(reiserfs_acl_entry_short)) | |
41 | return -1; | |
42 | return size / sizeof(reiserfs_acl_entry_short); | |
43 | } else { | |
44 | if (s % sizeof(reiserfs_acl_entry)) | |
45 | return -1; | |
46 | return s / sizeof(reiserfs_acl_entry) + 4; | |
47 | } | |
48 | } | |
49 | ||
1da177e4 | 50 | #ifdef CONFIG_REISERFS_FS_POSIX_ACL |
bd4c625c | 51 | struct posix_acl *reiserfs_get_acl(struct inode *inode, int type); |
47f70d08 | 52 | int reiserfs_set_acl(struct inode *inode, struct posix_acl *acl, int type); |
bd4c625c | 53 | int reiserfs_acl_chmod(struct inode *inode); |
0ab2621e JM |
54 | int reiserfs_inherit_default_acl(struct reiserfs_transaction_handle *th, |
55 | struct inode *dir, struct dentry *dentry, | |
bd4c625c LT |
56 | struct inode *inode); |
57 | int reiserfs_cache_default_acl(struct inode *dir); | |
cfe14677 | 58 | |
1da177e4 LT |
59 | #else |
60 | ||
1da177e4 | 61 | #define reiserfs_cache_default_acl(inode) 0 |
4e34e719 | 62 | #define reiserfs_get_acl NULL |
47f70d08 | 63 | #define reiserfs_set_acl NULL |
bc5e483d | 64 | |
bd4c625c | 65 | static inline int reiserfs_acl_chmod(struct inode *inode) |
1da177e4 | 66 | { |
bd4c625c | 67 | return 0; |
1da177e4 LT |
68 | } |
69 | ||
70 | static inline int | |
77e46586 AB |
71 | reiserfs_inherit_default_acl(struct reiserfs_transaction_handle *th, |
72 | const struct inode *dir, struct dentry *dentry, | |
bd4c625c | 73 | struct inode *inode) |
1da177e4 | 74 | { |
bd4c625c | 75 | return 0; |
1da177e4 | 76 | } |
1da177e4 | 77 | #endif |