Merge tag 'trace-tracefs-v6.10' of git://git.kernel.org/pub/scm/linux/kernel/git...
[linux-2.6-block.git] / fs / ext4 / acl.h
CommitLineData
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, <a.gruenbacher@computer.org>
6*/
7
8#include <linux/posix_acl_xattr.h>
9
617ba13b 10#define EXT4_ACL_VERSION 0x0001
ac27a0ec
DK
11
12typedef struct {
13 __le16 e_tag;
14 __le16 e_perm;
15 __le32 e_id;
617ba13b 16} ext4_acl_entry;
ac27a0ec
DK
17
18typedef struct {
19 __le16 e_tag;
20 __le16 e_perm;
617ba13b 21} ext4_acl_entry_short;
ac27a0ec
DK
22
23typedef struct {
24 __le32 a_version;
617ba13b 25} ext4_acl_header;
ac27a0ec 26
617ba13b 27static 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 39static 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 */
0cad6246 58struct posix_acl *ext4_get_acl(struct inode *inode, int type, bool rcu);
13e83a49 59int ext4_set_acl(struct mnt_idmap *idmap, struct dentry *dentry,
549c7297 60 struct posix_acl *acl, int type);
af5bc92d 61extern int ext4_init_acl(handle_t *, struct inode *, struct inode *);
ac27a0ec 62
03010a33 63#else /* CONFIG_EXT4_FS_POSIX_ACL */
ac27a0ec 64#include <linux/sched.h>
4e34e719 65#define ext4_get_acl NULL
64e178a7 66#define ext4_set_acl NULL
ac27a0ec
DK
67
68static inline int
617ba13b 69ext4_init_acl(handle_t *handle, struct inode *inode, struct inode *dir)
ac27a0ec
DK
70{
71 return 0;
72}
03010a33 73#endif /* CONFIG_EXT4_FS_POSIX_ACL */
ac27a0ec 74