]>
Commit | Line | Data |
---|---|---|
f5166768 | 1 | // SPDX-License-Identifier: GPL-2.0 |
ac27a0ec | 2 | /* |
617ba13b | 3 | File: fs/ext4/acl.h |
ac27a0ec DK |
4 | |
5 | (C) 2001 Andreas Gruenbacher, <[email protected]> | |
6 | */ | |
7 | ||
8 | #include <linux/posix_acl_xattr.h> | |
9 | ||
617ba13b | 10 | #define EXT4_ACL_VERSION 0x0001 |
ac27a0ec DK |
11 | |
12 | typedef struct { | |
13 | __le16 e_tag; | |
14 | __le16 e_perm; | |
15 | __le32 e_id; | |
617ba13b | 16 | } ext4_acl_entry; |
ac27a0ec DK |
17 | |
18 | typedef struct { | |
19 | __le16 e_tag; | |
20 | __le16 e_perm; | |
617ba13b | 21 | } ext4_acl_entry_short; |
ac27a0ec DK |
22 | |
23 | typedef struct { | |
24 | __le32 a_version; | |
617ba13b | 25 | } ext4_acl_header; |
ac27a0ec | 26 | |
617ba13b | 27 | static inline size_t ext4_acl_size(int count) |
ac27a0ec DK |
28 | { |
29 | if (count <= 4) { | |
617ba13b MC |
30 | return sizeof(ext4_acl_header) + |
31 | count * sizeof(ext4_acl_entry_short); | |
ac27a0ec | 32 | } else { |
617ba13b MC |
33 | return sizeof(ext4_acl_header) + |
34 | 4 * sizeof(ext4_acl_entry_short) + | |
35 | (count - 4) * sizeof(ext4_acl_entry); | |
ac27a0ec DK |
36 | } |
37 | } | |
38 | ||
617ba13b | 39 | static inline int ext4_acl_count(size_t size) |
ac27a0ec DK |
40 | { |
41 | ssize_t s; | |
617ba13b MC |
42 | size -= sizeof(ext4_acl_header); |
43 | s = size - 4 * sizeof(ext4_acl_entry_short); | |
ac27a0ec | 44 | if (s < 0) { |
617ba13b | 45 | if (size % sizeof(ext4_acl_entry_short)) |
ac27a0ec | 46 | return -1; |
617ba13b | 47 | return size / sizeof(ext4_acl_entry_short); |
ac27a0ec | 48 | } else { |
617ba13b | 49 | if (s % sizeof(ext4_acl_entry)) |
ac27a0ec | 50 | return -1; |
617ba13b | 51 | return s / sizeof(ext4_acl_entry) + 4; |
ac27a0ec DK |
52 | } |
53 | } | |
54 | ||
03010a33 | 55 | #ifdef CONFIG_EXT4_FS_POSIX_ACL |
ac27a0ec | 56 | |
ac27a0ec | 57 | /* acl.c */ |
4e34e719 | 58 | struct posix_acl *ext4_get_acl(struct inode *inode, int type); |
64e178a7 | 59 | int ext4_set_acl(struct inode *inode, struct posix_acl *acl, int type); |
af5bc92d | 60 | extern int ext4_init_acl(handle_t *, struct inode *, struct inode *); |
ac27a0ec | 61 | |
03010a33 | 62 | #else /* CONFIG_EXT4_FS_POSIX_ACL */ |
ac27a0ec | 63 | #include <linux/sched.h> |
4e34e719 | 64 | #define ext4_get_acl NULL |
64e178a7 | 65 | #define ext4_set_acl NULL |
ac27a0ec DK |
66 | |
67 | static inline int | |
617ba13b | 68 | ext4_init_acl(handle_t *handle, struct inode *inode, struct inode *dir) |
ac27a0ec DK |
69 | { |
70 | return 0; | |
71 | } | |
03010a33 | 72 | #endif /* CONFIG_EXT4_FS_POSIX_ACL */ |
ac27a0ec | 73 |