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