blob: 4a211f5b34b81f00dc123c251a3adc7aff9dcf93 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001#include <linux/init.h>
2#include <linux/posix_acl.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -07003
4#define REISERFS_ACL_VERSION 0x0001
5
6typedef struct {
Linus Torvaldsbd4c6252005-07-12 20:21:28 -07007 __le16 e_tag;
8 __le16 e_perm;
9 __le32 e_id;
Linus Torvalds1da177e2005-04-16 15:20:36 -070010} reiserfs_acl_entry;
11
12typedef struct {
Linus Torvaldsbd4c6252005-07-12 20:21:28 -070013 __le16 e_tag;
14 __le16 e_perm;
Linus Torvalds1da177e2005-04-16 15:20:36 -070015} reiserfs_acl_entry_short;
16
17typedef struct {
Linus Torvaldsbd4c6252005-07-12 20:21:28 -070018 __le32 a_version;
Linus Torvalds1da177e2005-04-16 15:20:36 -070019} reiserfs_acl_header;
20
21static inline size_t reiserfs_acl_size(int count)
22{
23 if (count <= 4) {
24 return sizeof(reiserfs_acl_header) +
Linus Torvaldsbd4c6252005-07-12 20:21:28 -070025 count * sizeof(reiserfs_acl_entry_short);
Linus Torvalds1da177e2005-04-16 15:20:36 -070026 } else {
27 return sizeof(reiserfs_acl_header) +
Linus Torvaldsbd4c6252005-07-12 20:21:28 -070028 4 * sizeof(reiserfs_acl_entry_short) +
29 (count - 4) * sizeof(reiserfs_acl_entry);
Linus Torvalds1da177e2005-04-16 15:20:36 -070030 }
31}
32
33static inline int reiserfs_acl_count(size_t size)
34{
35 ssize_t s;
36 size -= sizeof(reiserfs_acl_header);
37 s = size - 4 * sizeof(reiserfs_acl_entry_short);
38 if (s < 0) {
39 if (size % sizeof(reiserfs_acl_entry_short))
40 return -1;
41 return size / sizeof(reiserfs_acl_entry_short);
42 } else {
43 if (s % sizeof(reiserfs_acl_entry))
44 return -1;
45 return s / sizeof(reiserfs_acl_entry) + 4;
46 }
47}
48
Linus Torvalds1da177e2005-04-16 15:20:36 -070049#ifdef CONFIG_REISERFS_FS_POSIX_ACL
Linus Torvaldsbd4c6252005-07-12 20:21:28 -070050struct posix_acl *reiserfs_get_acl(struct inode *inode, int type);
Christoph Hellwig47f70d02013-12-20 05:16:49 -080051int reiserfs_set_acl(struct inode *inode, struct posix_acl *acl, int type);
Linus Torvaldsbd4c6252005-07-12 20:21:28 -070052int reiserfs_acl_chmod(struct inode *inode);
Jeff Mahoney0ab26212009-03-30 14:02:39 -040053int reiserfs_inherit_default_acl(struct reiserfs_transaction_handle *th,
54 struct inode *dir, struct dentry *dentry,
Linus Torvaldsbd4c6252005-07-12 20:21:28 -070055 struct inode *inode);
56int reiserfs_cache_default_acl(struct inode *dir);
Alexey Dobriyancfe14672006-09-29 02:00:00 -070057
Linus Torvalds1da177e2005-04-16 15:20:36 -070058#else
59
Linus Torvalds1da177e2005-04-16 15:20:36 -070060#define reiserfs_cache_default_acl(inode) 0
Christoph Hellwig4e34e712011-07-23 17:37:31 +020061#define reiserfs_get_acl NULL
Christoph Hellwig47f70d02013-12-20 05:16:49 -080062#define reiserfs_set_acl NULL
Andrew Mortonbc5e4832006-02-04 23:27:51 -080063
Linus Torvaldsbd4c6252005-07-12 20:21:28 -070064static inline int reiserfs_acl_chmod(struct inode *inode)
65{
66 return 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -070067}
68
69static inline int
Alexander Beregalov77e46582009-03-31 00:32:40 +040070reiserfs_inherit_default_acl(struct reiserfs_transaction_handle *th,
71 const struct inode *dir, struct dentry *dentry,
Linus Torvaldsbd4c6252005-07-12 20:21:28 -070072 struct inode *inode)
Linus Torvalds1da177e2005-04-16 15:20:36 -070073{
Linus Torvaldsbd4c6252005-07-12 20:21:28 -070074 return 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -070075}
Linus Torvalds1da177e2005-04-16 15:20:36 -070076#endif