2017-12-18 10:00:59 +07:00
|
|
|
// SPDX-License-Identifier: GPL-2.0
|
2006-10-11 15:20:50 +07:00
|
|
|
/*
|
2006-10-11 15:20:53 +07:00
|
|
|
File: fs/ext4/acl.h
|
2006-10-11 15:20:50 +07:00
|
|
|
|
|
|
|
(C) 2001 Andreas Gruenbacher, <a.gruenbacher@computer.org>
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/posix_acl_xattr.h>
|
|
|
|
|
2006-10-11 15:20:53 +07:00
|
|
|
#define EXT4_ACL_VERSION 0x0001
|
2006-10-11 15:20:50 +07:00
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
__le16 e_tag;
|
|
|
|
__le16 e_perm;
|
|
|
|
__le32 e_id;
|
2006-10-11 15:20:53 +07:00
|
|
|
} ext4_acl_entry;
|
2006-10-11 15:20:50 +07:00
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
__le16 e_tag;
|
|
|
|
__le16 e_perm;
|
2006-10-11 15:20:53 +07:00
|
|
|
} ext4_acl_entry_short;
|
2006-10-11 15:20:50 +07:00
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
__le32 a_version;
|
2006-10-11 15:20:53 +07:00
|
|
|
} ext4_acl_header;
|
2006-10-11 15:20:50 +07:00
|
|
|
|
2006-10-11 15:20:53 +07:00
|
|
|
static inline size_t ext4_acl_size(int count)
|
2006-10-11 15:20:50 +07:00
|
|
|
{
|
|
|
|
if (count <= 4) {
|
2006-10-11 15:20:53 +07:00
|
|
|
return sizeof(ext4_acl_header) +
|
|
|
|
count * sizeof(ext4_acl_entry_short);
|
2006-10-11 15:20:50 +07:00
|
|
|
} else {
|
2006-10-11 15:20:53 +07:00
|
|
|
return sizeof(ext4_acl_header) +
|
|
|
|
4 * sizeof(ext4_acl_entry_short) +
|
|
|
|
(count - 4) * sizeof(ext4_acl_entry);
|
2006-10-11 15:20:50 +07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-10-11 15:20:53 +07:00
|
|
|
static inline int ext4_acl_count(size_t size)
|
2006-10-11 15:20:50 +07:00
|
|
|
{
|
|
|
|
ssize_t s;
|
2006-10-11 15:20:53 +07:00
|
|
|
size -= sizeof(ext4_acl_header);
|
|
|
|
s = size - 4 * sizeof(ext4_acl_entry_short);
|
2006-10-11 15:20:50 +07:00
|
|
|
if (s < 0) {
|
2006-10-11 15:20:53 +07:00
|
|
|
if (size % sizeof(ext4_acl_entry_short))
|
2006-10-11 15:20:50 +07:00
|
|
|
return -1;
|
2006-10-11 15:20:53 +07:00
|
|
|
return size / sizeof(ext4_acl_entry_short);
|
2006-10-11 15:20:50 +07:00
|
|
|
} else {
|
2006-10-11 15:20:53 +07:00
|
|
|
if (s % sizeof(ext4_acl_entry))
|
2006-10-11 15:20:50 +07:00
|
|
|
return -1;
|
2006-10-11 15:20:53 +07:00
|
|
|
return s / sizeof(ext4_acl_entry) + 4;
|
2006-10-11 15:20:50 +07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-10-11 07:02:48 +07:00
|
|
|
#ifdef CONFIG_EXT4_FS_POSIX_ACL
|
2006-10-11 15:20:50 +07:00
|
|
|
|
|
|
|
/* acl.c */
|
2011-07-23 22:37:31 +07:00
|
|
|
struct posix_acl *ext4_get_acl(struct inode *inode, int type);
|
2013-12-20 20:16:44 +07:00
|
|
|
int ext4_set_acl(struct inode *inode, struct posix_acl *acl, int type);
|
2008-09-09 09:25:24 +07:00
|
|
|
extern int ext4_init_acl(handle_t *, struct inode *, struct inode *);
|
2006-10-11 15:20:50 +07:00
|
|
|
|
2008-10-11 07:02:48 +07:00
|
|
|
#else /* CONFIG_EXT4_FS_POSIX_ACL */
|
2006-10-11 15:20:50 +07:00
|
|
|
#include <linux/sched.h>
|
2011-07-23 22:37:31 +07:00
|
|
|
#define ext4_get_acl NULL
|
2013-12-20 20:16:44 +07:00
|
|
|
#define ext4_set_acl NULL
|
2006-10-11 15:20:50 +07:00
|
|
|
|
|
|
|
static inline int
|
2006-10-11 15:20:53 +07:00
|
|
|
ext4_init_acl(handle_t *handle, struct inode *inode, struct inode *dir)
|
2006-10-11 15:20:50 +07:00
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
2008-10-11 07:02:48 +07:00
|
|
|
#endif /* CONFIG_EXT4_FS_POSIX_ACL */
|
2006-10-11 15:20:50 +07:00
|
|
|
|