Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | #include <linux/init.h> |
| 2 | #include <linux/posix_acl.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3 | |
| 4 | #define REISERFS_ACL_VERSION 0x0001 |
| 5 | |
| 6 | typedef struct { |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 7 | __le16 e_tag; |
| 8 | __le16 e_perm; |
| 9 | __le32 e_id; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 10 | } reiserfs_acl_entry; |
| 11 | |
| 12 | typedef struct { |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 13 | __le16 e_tag; |
| 14 | __le16 e_perm; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 15 | } reiserfs_acl_entry_short; |
| 16 | |
| 17 | typedef struct { |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 18 | __le32 a_version; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 19 | } reiserfs_acl_header; |
| 20 | |
| 21 | static inline size_t reiserfs_acl_size(int count) |
| 22 | { |
| 23 | if (count <= 4) { |
| 24 | return sizeof(reiserfs_acl_header) + |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 25 | count * sizeof(reiserfs_acl_entry_short); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 26 | } else { |
| 27 | return sizeof(reiserfs_acl_header) + |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 28 | 4 * sizeof(reiserfs_acl_entry_short) + |
| 29 | (count - 4) * sizeof(reiserfs_acl_entry); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 30 | } |
| 31 | } |
| 32 | |
| 33 | static 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 Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 49 | #ifdef CONFIG_REISERFS_FS_POSIX_ACL |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 50 | struct posix_acl *reiserfs_get_acl(struct inode *inode, int type); |
Christoph Hellwig | 47f70d0 | 2013-12-20 05:16:49 -0800 | [diff] [blame] | 51 | int reiserfs_set_acl(struct inode *inode, struct posix_acl *acl, int type); |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 52 | int reiserfs_acl_chmod(struct inode *inode); |
Jeff Mahoney | 0ab2621 | 2009-03-30 14:02:39 -0400 | [diff] [blame] | 53 | int reiserfs_inherit_default_acl(struct reiserfs_transaction_handle *th, |
| 54 | struct inode *dir, struct dentry *dentry, |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 55 | struct inode *inode); |
| 56 | int reiserfs_cache_default_acl(struct inode *dir); |
Alexey Dobriyan | cfe1467 | 2006-09-29 02:00:00 -0700 | [diff] [blame] | 57 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 58 | #else |
| 59 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 60 | #define reiserfs_cache_default_acl(inode) 0 |
Christoph Hellwig | 4e34e71 | 2011-07-23 17:37:31 +0200 | [diff] [blame] | 61 | #define reiserfs_get_acl NULL |
Christoph Hellwig | 47f70d0 | 2013-12-20 05:16:49 -0800 | [diff] [blame] | 62 | #define reiserfs_set_acl NULL |
Andrew Morton | bc5e483 | 2006-02-04 23:27:51 -0800 | [diff] [blame] | 63 | |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 64 | static inline int reiserfs_acl_chmod(struct inode *inode) |
| 65 | { |
| 66 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 67 | } |
| 68 | |
| 69 | static inline int |
Alexander Beregalov | 77e4658 | 2009-03-31 00:32:40 +0400 | [diff] [blame] | 70 | reiserfs_inherit_default_acl(struct reiserfs_transaction_handle *th, |
| 71 | const struct inode *dir, struct dentry *dentry, |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 72 | struct inode *inode) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 73 | { |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 74 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 75 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 76 | #endif |