diff options
Diffstat (limited to 'fs/hfsplus/xattr.c')
-rw-r--r-- | fs/hfsplus/xattr.c | 62 |
1 files changed, 56 insertions, 6 deletions
diff --git a/fs/hfsplus/xattr.c b/fs/hfsplus/xattr.c index f66346155df5..bd8471fb9a6a 100644 --- a/fs/hfsplus/xattr.c +++ b/fs/hfsplus/xattr.c | |||
@@ -8,11 +8,16 @@ | |||
8 | 8 | ||
9 | #include "hfsplus_fs.h" | 9 | #include "hfsplus_fs.h" |
10 | #include "xattr.h" | 10 | #include "xattr.h" |
11 | #include "acl.h" | ||
11 | 12 | ||
12 | const struct xattr_handler *hfsplus_xattr_handlers[] = { | 13 | const struct xattr_handler *hfsplus_xattr_handlers[] = { |
13 | &hfsplus_xattr_osx_handler, | 14 | &hfsplus_xattr_osx_handler, |
14 | &hfsplus_xattr_user_handler, | 15 | &hfsplus_xattr_user_handler, |
15 | &hfsplus_xattr_trusted_handler, | 16 | &hfsplus_xattr_trusted_handler, |
17 | #ifdef CONFIG_HFSPLUS_FS_POSIX_ACL | ||
18 | &hfsplus_xattr_acl_access_handler, | ||
19 | &hfsplus_xattr_acl_default_handler, | ||
20 | #endif | ||
16 | &hfsplus_xattr_security_handler, | 21 | &hfsplus_xattr_security_handler, |
17 | NULL | 22 | NULL |
18 | }; | 23 | }; |
@@ -46,11 +51,58 @@ static inline int is_known_namespace(const char *name) | |||
46 | return true; | 51 | return true; |
47 | } | 52 | } |
48 | 53 | ||
54 | static int can_set_system_xattr(struct inode *inode, const char *name, | ||
55 | const void *value, size_t size) | ||
56 | { | ||
57 | #ifdef CONFIG_HFSPLUS_FS_POSIX_ACL | ||
58 | struct posix_acl *acl; | ||
59 | int err; | ||
60 | |||
61 | if (!inode_owner_or_capable(inode)) | ||
62 | return -EPERM; | ||
63 | |||
64 | /* | ||
65 | * POSIX_ACL_XATTR_ACCESS is tied to i_mode | ||
66 | */ | ||
67 | if (strcmp(name, POSIX_ACL_XATTR_ACCESS) == 0) { | ||
68 | acl = posix_acl_from_xattr(&init_user_ns, value, size); | ||
69 | if (IS_ERR(acl)) | ||
70 | return PTR_ERR(acl); | ||
71 | if (acl) { | ||
72 | err = posix_acl_equiv_mode(acl, &inode->i_mode); | ||
73 | posix_acl_release(acl); | ||
74 | if (err < 0) | ||
75 | return err; | ||
76 | mark_inode_dirty(inode); | ||
77 | } | ||
78 | /* | ||
79 | * We're changing the ACL. Get rid of the cached one | ||
80 | */ | ||
81 | forget_cached_acl(inode, ACL_TYPE_ACCESS); | ||
82 | |||
83 | return 0; | ||
84 | } else if (strcmp(name, POSIX_ACL_XATTR_DEFAULT) == 0) { | ||
85 | acl = posix_acl_from_xattr(&init_user_ns, value, size); | ||
86 | if (IS_ERR(acl)) | ||
87 | return PTR_ERR(acl); | ||
88 | posix_acl_release(acl); | ||
89 | |||
90 | /* | ||
91 | * We're changing the default ACL. Get rid of the cached one | ||
92 | */ | ||
93 | forget_cached_acl(inode, ACL_TYPE_DEFAULT); | ||
94 | |||
95 | return 0; | ||
96 | } | ||
97 | #endif /* CONFIG_HFSPLUS_FS_POSIX_ACL */ | ||
98 | return -EOPNOTSUPP; | ||
99 | } | ||
100 | |||
49 | static int can_set_xattr(struct inode *inode, const char *name, | 101 | static int can_set_xattr(struct inode *inode, const char *name, |
50 | const void *value, size_t value_len) | 102 | const void *value, size_t value_len) |
51 | { | 103 | { |
52 | if (!strncmp(name, XATTR_SYSTEM_PREFIX, XATTR_SYSTEM_PREFIX_LEN)) | 104 | if (!strncmp(name, XATTR_SYSTEM_PREFIX, XATTR_SYSTEM_PREFIX_LEN)) |
53 | return -EOPNOTSUPP; /* TODO: implement ACL support */ | 105 | return can_set_system_xattr(inode, name, value, value_len); |
54 | 106 | ||
55 | if (!strncmp(name, XATTR_MAC_OSX_PREFIX, XATTR_MAC_OSX_PREFIX_LEN)) { | 107 | if (!strncmp(name, XATTR_MAC_OSX_PREFIX, XATTR_MAC_OSX_PREFIX_LEN)) { |
56 | /* | 108 | /* |
@@ -253,11 +305,10 @@ static int copy_name(char *buffer, const char *xattr_name, int name_len) | |||
253 | return len; | 305 | return len; |
254 | } | 306 | } |
255 | 307 | ||
256 | static ssize_t hfsplus_getxattr_finder_info(struct dentry *dentry, | 308 | static ssize_t hfsplus_getxattr_finder_info(struct inode *inode, |
257 | void *value, size_t size) | 309 | void *value, size_t size) |
258 | { | 310 | { |
259 | ssize_t res = 0; | 311 | ssize_t res = 0; |
260 | struct inode *inode = dentry->d_inode; | ||
261 | struct hfs_find_data fd; | 312 | struct hfs_find_data fd; |
262 | u16 entry_type; | 313 | u16 entry_type; |
263 | u16 folder_rec_len = sizeof(struct DInfo) + sizeof(struct DXInfo); | 314 | u16 folder_rec_len = sizeof(struct DInfo) + sizeof(struct DXInfo); |
@@ -304,10 +355,9 @@ end_getxattr_finder_info: | |||
304 | return res; | 355 | return res; |
305 | } | 356 | } |
306 | 357 | ||
307 | ssize_t hfsplus_getxattr(struct dentry *dentry, const char *name, | 358 | ssize_t __hfsplus_getxattr(struct inode *inode, const char *name, |
308 | void *value, size_t size) | 359 | void *value, size_t size) |
309 | { | 360 | { |
310 | struct inode *inode = dentry->d_inode; | ||
311 | struct hfs_find_data fd; | 361 | struct hfs_find_data fd; |
312 | hfsplus_attr_entry *entry; | 362 | hfsplus_attr_entry *entry; |
313 | __be32 xattr_record_type; | 363 | __be32 xattr_record_type; |
@@ -333,7 +383,7 @@ ssize_t hfsplus_getxattr(struct dentry *dentry, const char *name, | |||
333 | } | 383 | } |
334 | 384 | ||
335 | if (!strcmp_xattr_finder_info(name)) | 385 | if (!strcmp_xattr_finder_info(name)) |
336 | return hfsplus_getxattr_finder_info(dentry, value, size); | 386 | return hfsplus_getxattr_finder_info(inode, value, size); |
337 | 387 | ||
338 | if (!HFSPLUS_SB(inode->i_sb)->attr_tree) | 388 | if (!HFSPLUS_SB(inode->i_sb)->attr_tree) |
339 | return -EOPNOTSUPP; | 389 | return -EOPNOTSUPP; |