2006-10-11 16:20:50 +08:00
|
|
|
/*
|
2006-10-11 16:20:53 +08:00
|
|
|
File: fs/ext4/acl.h
|
2006-10-11 16:20:50 +08:00
|
|
|
|
|
|
|
(C) 2001 Andreas Gruenbacher, <a.gruenbacher@computer.org>
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/posix_acl_xattr.h>
|
|
|
|
|
2006-10-11 16:20:53 +08:00
|
|
|
#define EXT4_ACL_VERSION 0x0001
|
2006-10-11 16:20:50 +08:00
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
__le16 e_tag;
|
|
|
|
__le16 e_perm;
|
|
|
|
__le32 e_id;
|
2006-10-11 16:20:53 +08:00
|
|
|
} ext4_acl_entry;
|
2006-10-11 16:20:50 +08:00
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
__le16 e_tag;
|
|
|
|
__le16 e_perm;
|
2006-10-11 16:20:53 +08:00
|
|
|
} ext4_acl_entry_short;
|
2006-10-11 16:20:50 +08:00
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
__le32 a_version;
|
2006-10-11 16:20:53 +08:00
|
|
|
} ext4_acl_header;
|
2006-10-11 16:20:50 +08:00
|
|
|
|
2006-10-11 16:20:53 +08:00
|
|
|
static inline size_t ext4_acl_size(int count)
|
2006-10-11 16:20:50 +08:00
|
|
|
{
|
|
|
|
if (count <= 4) {
|
2006-10-11 16:20:53 +08:00
|
|
|
return sizeof(ext4_acl_header) +
|
|
|
|
count * sizeof(ext4_acl_entry_short);
|
2006-10-11 16:20:50 +08:00
|
|
|
} else {
|
2006-10-11 16:20:53 +08:00
|
|
|
return sizeof(ext4_acl_header) +
|
|
|
|
4 * sizeof(ext4_acl_entry_short) +
|
|
|
|
(count - 4) * sizeof(ext4_acl_entry);
|
2006-10-11 16:20:50 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-10-11 16:20:53 +08:00
|
|
|
static inline int ext4_acl_count(size_t size)
|
2006-10-11 16:20:50 +08:00
|
|
|
{
|
|
|
|
ssize_t s;
|
2006-10-11 16:20:53 +08:00
|
|
|
size -= sizeof(ext4_acl_header);
|
|
|
|
s = size - 4 * sizeof(ext4_acl_entry_short);
|
2006-10-11 16:20:50 +08:00
|
|
|
if (s < 0) {
|
2006-10-11 16:20:53 +08:00
|
|
|
if (size % sizeof(ext4_acl_entry_short))
|
2006-10-11 16:20:50 +08:00
|
|
|
return -1;
|
2006-10-11 16:20:53 +08:00
|
|
|
return size / sizeof(ext4_acl_entry_short);
|
2006-10-11 16:20:50 +08:00
|
|
|
} else {
|
2006-10-11 16:20:53 +08:00
|
|
|
if (s % sizeof(ext4_acl_entry))
|
2006-10-11 16:20:50 +08:00
|
|
|
return -1;
|
2006-10-11 16:20:53 +08:00
|
|
|
return s / sizeof(ext4_acl_entry) + 4;
|
2006-10-11 16:20:50 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-10-11 08:02:48 +08:00
|
|
|
#ifdef CONFIG_EXT4_FS_POSIX_ACL
|
2006-10-11 16:20:50 +08:00
|
|
|
|
2006-10-11 16:20:53 +08:00
|
|
|
/* Value for inode->u.ext4_i.i_acl and inode->u.ext4_i.i_default_acl
|
2006-10-11 16:20:50 +08:00
|
|
|
if the ACL has not been cached */
|
2006-10-11 16:20:53 +08:00
|
|
|
#define EXT4_ACL_NOT_CACHED ((void *)-1)
|
2006-10-11 16:20:50 +08:00
|
|
|
|
|
|
|
/* acl.c */
|
2008-09-09 10:25:24 +08:00
|
|
|
extern int ext4_permission(struct inode *, int);
|
|
|
|
extern int ext4_acl_chmod(struct inode *);
|
|
|
|
extern int ext4_init_acl(handle_t *, struct inode *, struct inode *);
|
2006-10-11 16:20:50 +08:00
|
|
|
|
2008-10-11 08:02:48 +08:00
|
|
|
#else /* CONFIG_EXT4_FS_POSIX_ACL */
|
2006-10-11 16:20:50 +08:00
|
|
|
#include <linux/sched.h>
|
2006-10-11 16:20:53 +08:00
|
|
|
#define ext4_permission NULL
|
2006-10-11 16:20:50 +08:00
|
|
|
|
|
|
|
static inline int
|
2006-10-11 16:20:53 +08:00
|
|
|
ext4_acl_chmod(struct inode *inode)
|
2006-10-11 16:20:50 +08:00
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline int
|
2006-10-11 16:20:53 +08:00
|
|
|
ext4_init_acl(handle_t *handle, struct inode *inode, struct inode *dir)
|
2006-10-11 16:20:50 +08:00
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
2008-10-11 08:02:48 +08:00
|
|
|
#endif /* CONFIG_EXT4_FS_POSIX_ACL */
|
2006-10-11 16:20:50 +08:00
|
|
|
|