blob: 9d843d5deac402593b8b557e27c6ed25aafe401d [file] [log] [blame]
Dave Kleikampac27a0e2006-10-11 01:20:50 -07001/*
Mingming Cao617ba132006-10-11 01:20:53 -07002 File: fs/ext4/acl.h
Dave Kleikampac27a0e2006-10-11 01:20:50 -07003
4 (C) 2001 Andreas Gruenbacher, <a.gruenbacher@computer.org>
5*/
6
7#include <linux/posix_acl_xattr.h>
8
Mingming Cao617ba132006-10-11 01:20:53 -07009#define EXT4_ACL_VERSION 0x0001
Dave Kleikampac27a0e2006-10-11 01:20:50 -070010
11typedef struct {
12 __le16 e_tag;
13 __le16 e_perm;
14 __le32 e_id;
Mingming Cao617ba132006-10-11 01:20:53 -070015} ext4_acl_entry;
Dave Kleikampac27a0e2006-10-11 01:20:50 -070016
17typedef struct {
18 __le16 e_tag;
19 __le16 e_perm;
Mingming Cao617ba132006-10-11 01:20:53 -070020} ext4_acl_entry_short;
Dave Kleikampac27a0e2006-10-11 01:20:50 -070021
22typedef struct {
23 __le32 a_version;
Mingming Cao617ba132006-10-11 01:20:53 -070024} ext4_acl_header;
Dave Kleikampac27a0e2006-10-11 01:20:50 -070025
Mingming Cao617ba132006-10-11 01:20:53 -070026static inline size_t ext4_acl_size(int count)
Dave Kleikampac27a0e2006-10-11 01:20:50 -070027{
28 if (count <= 4) {
Mingming Cao617ba132006-10-11 01:20:53 -070029 return sizeof(ext4_acl_header) +
30 count * sizeof(ext4_acl_entry_short);
Dave Kleikampac27a0e2006-10-11 01:20:50 -070031 } else {
Mingming Cao617ba132006-10-11 01:20:53 -070032 return sizeof(ext4_acl_header) +
33 4 * sizeof(ext4_acl_entry_short) +
34 (count - 4) * sizeof(ext4_acl_entry);
Dave Kleikampac27a0e2006-10-11 01:20:50 -070035 }
36}
37
Mingming Cao617ba132006-10-11 01:20:53 -070038static inline int ext4_acl_count(size_t size)
Dave Kleikampac27a0e2006-10-11 01:20:50 -070039{
40 ssize_t s;
Mingming Cao617ba132006-10-11 01:20:53 -070041 size -= sizeof(ext4_acl_header);
42 s = size - 4 * sizeof(ext4_acl_entry_short);
Dave Kleikampac27a0e2006-10-11 01:20:50 -070043 if (s < 0) {
Mingming Cao617ba132006-10-11 01:20:53 -070044 if (size % sizeof(ext4_acl_entry_short))
Dave Kleikampac27a0e2006-10-11 01:20:50 -070045 return -1;
Mingming Cao617ba132006-10-11 01:20:53 -070046 return size / sizeof(ext4_acl_entry_short);
Dave Kleikampac27a0e2006-10-11 01:20:50 -070047 } else {
Mingming Cao617ba132006-10-11 01:20:53 -070048 if (s % sizeof(ext4_acl_entry))
Dave Kleikampac27a0e2006-10-11 01:20:50 -070049 return -1;
Mingming Cao617ba132006-10-11 01:20:53 -070050 return s / sizeof(ext4_acl_entry) + 4;
Dave Kleikampac27a0e2006-10-11 01:20:50 -070051 }
52}
53
Theodore Ts'o03010a32008-10-10 20:02:48 -040054#ifdef CONFIG_EXT4_FS_POSIX_ACL
Dave Kleikampac27a0e2006-10-11 01:20:50 -070055
Dave Kleikampac27a0e2006-10-11 01:20:50 -070056/* acl.c */
Linus Torvalds1d5ccd12009-08-28 12:12:24 -070057extern int ext4_check_acl(struct inode *, int);
Theodore Ts'oaf5bc922008-09-08 22:25:24 -040058extern int ext4_acl_chmod(struct inode *);
59extern int ext4_init_acl(handle_t *, struct inode *, struct inode *);
Dave Kleikampac27a0e2006-10-11 01:20:50 -070060
Theodore Ts'o03010a32008-10-10 20:02:48 -040061#else /* CONFIG_EXT4_FS_POSIX_ACL */
Dave Kleikampac27a0e2006-10-11 01:20:50 -070062#include <linux/sched.h>
Linus Torvalds1d5ccd12009-08-28 12:12:24 -070063#define ext4_check_acl NULL
Dave Kleikampac27a0e2006-10-11 01:20:50 -070064
65static inline int
Mingming Cao617ba132006-10-11 01:20:53 -070066ext4_acl_chmod(struct inode *inode)
Dave Kleikampac27a0e2006-10-11 01:20:50 -070067{
68 return 0;
69}
70
71static inline int
Mingming Cao617ba132006-10-11 01:20:53 -070072ext4_init_acl(handle_t *handle, struct inode *inode, struct inode *dir)
Dave Kleikampac27a0e2006-10-11 01:20:50 -070073{
74 return 0;
75}
Theodore Ts'o03010a32008-10-10 20:02:48 -040076#endif /* CONFIG_EXT4_FS_POSIX_ACL */
Dave Kleikampac27a0e2006-10-11 01:20:50 -070077