blob: 2aef9c3f5ce8161fd77a47a9c297b1f127bfbb21 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001#include <linux/init.h>
2#include <linux/posix_acl.h>
3#include <linux/xattr_acl.h>
4
5#define REISERFS_ACL_VERSION 0x0001
6
7typedef struct {
Al Viro3e8962b2005-05-01 08:59:18 -07008 __le16 e_tag;
9 __le16 e_perm;
10 __le32 e_id;
Linus Torvalds1da177e2005-04-16 15:20:36 -070011} reiserfs_acl_entry;
12
13typedef struct {
Al Viro3e8962b2005-05-01 08:59:18 -070014 __le16 e_tag;
15 __le16 e_perm;
Linus Torvalds1da177e2005-04-16 15:20:36 -070016} reiserfs_acl_entry_short;
17
18typedef struct {
Al Viro3e8962b2005-05-01 08:59:18 -070019 __le32 a_version;
Linus Torvalds1da177e2005-04-16 15:20:36 -070020} reiserfs_acl_header;
21
22static inline size_t reiserfs_acl_size(int count)
23{
24 if (count <= 4) {
25 return sizeof(reiserfs_acl_header) +
26 count * sizeof(reiserfs_acl_entry_short);
27 } else {
28 return sizeof(reiserfs_acl_header) +
29 4 * sizeof(reiserfs_acl_entry_short) +
30 (count - 4) * sizeof(reiserfs_acl_entry);
31 }
32}
33
34static inline int reiserfs_acl_count(size_t size)
35{
36 ssize_t s;
37 size -= sizeof(reiserfs_acl_header);
38 s = size - 4 * sizeof(reiserfs_acl_entry_short);
39 if (s < 0) {
40 if (size % sizeof(reiserfs_acl_entry_short))
41 return -1;
42 return size / sizeof(reiserfs_acl_entry_short);
43 } else {
44 if (s % sizeof(reiserfs_acl_entry))
45 return -1;
46 return s / sizeof(reiserfs_acl_entry) + 4;
47 }
48}
49
50
51#ifdef CONFIG_REISERFS_FS_POSIX_ACL
52struct posix_acl * reiserfs_get_acl(struct inode *inode, int type);
53int reiserfs_acl_chmod (struct inode *inode);
54int reiserfs_inherit_default_acl (struct inode *dir, struct dentry *dentry, struct inode *inode);
55int reiserfs_cache_default_acl (struct inode *dir);
56extern int reiserfs_xattr_posix_acl_init (void) __init;
57extern int reiserfs_xattr_posix_acl_exit (void);
58extern struct reiserfs_xattr_handler posix_acl_default_handler;
59extern struct reiserfs_xattr_handler posix_acl_access_handler;
60#else
61
62#define reiserfs_get_acl NULL
63#define reiserfs_cache_default_acl(inode) 0
64
65static inline int
66reiserfs_xattr_posix_acl_init (void)
67{
68 return 0;
69}
70
71static inline int
72reiserfs_xattr_posix_acl_exit (void)
73{
74 return 0;
75}
76
77static inline int
78reiserfs_acl_chmod (struct inode *inode)
79{
80 return 0;
81}
82
83static inline int
84reiserfs_inherit_default_acl (const struct inode *dir, struct dentry *dentry, struct inode *inode)
85{
86 return 0;
87}
88
89#endif