diff options
-rw-r--r-- | fs/btrfs/acl.c | 73 | ||||
-rw-r--r-- | fs/btrfs/dir-item.c | 3 | ||||
-rw-r--r-- | fs/btrfs/xattr.c | 16 |
3 files changed, 51 insertions, 41 deletions
diff --git a/fs/btrfs/acl.c b/fs/btrfs/acl.c index 889ba89d3f9f..b4f85ebe1bd6 100644 --- a/fs/btrfs/acl.c +++ b/fs/btrfs/acl.c | |||
@@ -22,53 +22,68 @@ | |||
22 | #include <linux/posix_acl_xattr.h> | 22 | #include <linux/posix_acl_xattr.h> |
23 | #include "ctree.h" | 23 | #include "ctree.h" |
24 | #include "xattr.h" | 24 | #include "xattr.h" |
25 | static int btrfs_xattr_set_acl(struct inode *inode, int type, | ||
26 | const void *value, size_t size) | ||
27 | { | ||
28 | int ret = 0; | ||
29 | struct posix_acl *acl; | ||
25 | 30 | ||
26 | /* | 31 | if (!is_owner_or_cap(inode)) |
27 | * FIXME: At this point this is all place holder stuff, we just return | 32 | return -EPERM; |
28 | * -EOPNOTSUPP so cp won't complain when it tries to copy over a file with an | 33 | if (value) { |
29 | * acl on it. | 34 | acl = posix_acl_from_xattr(value, size); |
30 | */ | 35 | if (acl == NULL) { |
36 | value = NULL; | ||
37 | size = 0; | ||
38 | } else if (IS_ERR(acl)) { | ||
39 | ret = PTR_ERR(acl); | ||
40 | } else { | ||
41 | ret = posix_acl_valid(acl); | ||
42 | posix_acl_release(acl); | ||
43 | } | ||
44 | if (ret) | ||
45 | return ret; | ||
46 | } | ||
47 | return btrfs_xattr_set(inode, type, "", value, size, 0); | ||
48 | } | ||
31 | 49 | ||
50 | static int btrfs_xattr_get_acl(struct inode *inode, int type, | ||
51 | void *value, size_t size) | ||
52 | { | ||
53 | return btrfs_xattr_get(inode, type, "", value, size); | ||
54 | } | ||
32 | static int btrfs_xattr_acl_access_get(struct inode *inode, const char *name, | 55 | static int btrfs_xattr_acl_access_get(struct inode *inode, const char *name, |
33 | void *value, size_t size) | 56 | void *value, size_t size) |
34 | { | 57 | { |
35 | /* | 58 | if (*name != '\0') |
36 | return btrfs_xattr_get(inode, BTRFS_XATTR_INDEX_POSIX_ACL_ACCESS, name, | 59 | return -EINVAL; |
37 | value, size); | 60 | return btrfs_xattr_get_acl(inode, BTRFS_XATTR_INDEX_POSIX_ACL_ACCESS, |
38 | */ | 61 | value, size); |
39 | return -EOPNOTSUPP; | ||
40 | } | 62 | } |
41 | |||
42 | static int btrfs_xattr_acl_access_set(struct inode *inode, const char *name, | 63 | static int btrfs_xattr_acl_access_set(struct inode *inode, const char *name, |
43 | const void *value, size_t size, int flags) | 64 | const void *value, size_t size, int flags) |
44 | { | 65 | { |
45 | /* | 66 | if (*name != '\0') |
46 | return btrfs_xattr_set(inode, BTRFS_XATTR_INDEX_POSIX_ACL_ACCESS, name, | 67 | return -EINVAL; |
47 | value, size, flags); | 68 | return btrfs_xattr_set_acl(inode, BTRFS_XATTR_INDEX_POSIX_ACL_ACCESS, |
48 | */ | 69 | value, size); |
49 | return -EOPNOTSUPP; | ||
50 | } | 70 | } |
51 | |||
52 | static int btrfs_xattr_acl_default_get(struct inode *inode, const char *name, | 71 | static int btrfs_xattr_acl_default_get(struct inode *inode, const char *name, |
53 | void *value, size_t size) | 72 | void *value, size_t size) |
54 | { | 73 | { |
55 | /* | 74 | if (*name != '\0') |
56 | return btrfs_xattr_get(inode, BTRFS_XATTR_INDEX_POSIX_ACL_DEFAULT, | 75 | return -EINVAL; |
57 | name, value, size); | 76 | return btrfs_xattr_get_acl(inode, BTRFS_XATTR_INDEX_POSIX_ACL_DEFAULT, |
58 | */ | 77 | value, size); |
59 | return -EOPNOTSUPP; | ||
60 | } | 78 | } |
61 | |||
62 | static int btrfs_xattr_acl_default_set(struct inode *inode, const char *name, | 79 | static int btrfs_xattr_acl_default_set(struct inode *inode, const char *name, |
63 | const void *value, size_t size, int flags) | 80 | const void *value, size_t size, int flags) |
64 | { | 81 | { |
65 | /* | 82 | if (*name != '\0') |
66 | return btrfs_xattr_set(inode, BTRFS_XATTR_INDEX_POSIX_ACL_DEFAULT, | 83 | return -EINVAL; |
67 | name, value, size, flags); | 84 | return btrfs_xattr_set_acl(inode, BTRFS_XATTR_INDEX_POSIX_ACL_DEFAULT, |
68 | */ | 85 | value, size); |
69 | return -EOPNOTSUPP; | ||
70 | } | 86 | } |
71 | |||
72 | struct xattr_handler btrfs_xattr_acl_default_handler = { | 87 | struct xattr_handler btrfs_xattr_acl_default_handler = { |
73 | .prefix = POSIX_ACL_XATTR_DEFAULT, | 88 | .prefix = POSIX_ACL_XATTR_DEFAULT, |
74 | .list = btrfs_xattr_generic_list, | 89 | .list = btrfs_xattr_generic_list, |
diff --git a/fs/btrfs/dir-item.c b/fs/btrfs/dir-item.c index ddbe12ae0d63..5247a9a41f08 100644 --- a/fs/btrfs/dir-item.c +++ b/fs/btrfs/dir-item.c | |||
@@ -76,6 +76,9 @@ int btrfs_insert_xattr_item(struct btrfs_trans_handle *trans, | |||
76 | path = btrfs_alloc_path(); | 76 | path = btrfs_alloc_path(); |
77 | if (!path) | 77 | if (!path) |
78 | return -ENOMEM; | 78 | return -ENOMEM; |
79 | if (name_len + data_len + sizeof(struct btrfs_dir_item) > | ||
80 | BTRFS_LEAF_DATA_SIZE(root) - sizeof(struct btrfs_item)) | ||
81 | return -ENOSPC; | ||
79 | 82 | ||
80 | data_size = sizeof(*dir_item) + name_len + data_len; | 83 | data_size = sizeof(*dir_item) + name_len + data_len; |
81 | dir_item = insert_with_overflow(trans, root, path, &key, data_size, | 84 | dir_item = insert_with_overflow(trans, root, path, &key, data_size, |
diff --git a/fs/btrfs/xattr.c b/fs/btrfs/xattr.c index 33caaf5b4b0c..85ac42605f8d 100644 --- a/fs/btrfs/xattr.c +++ b/fs/btrfs/xattr.c | |||
@@ -141,11 +141,6 @@ ssize_t btrfs_xattr_get(struct inode *inode, int name_index, | |||
141 | 141 | ||
142 | if (!handler) | 142 | if (!handler) |
143 | return -EOPNOTSUPP; | 143 | return -EOPNOTSUPP; |
144 | |||
145 | /* just in case... */ | ||
146 | if (*attr_name == '\0') | ||
147 | return -EINVAL; | ||
148 | |||
149 | name = get_name(attr_name, name_index); | 144 | name = get_name(attr_name, name_index); |
150 | if (!name) | 145 | if (!name) |
151 | return -ENOMEM; | 146 | return -ENOMEM; |
@@ -201,14 +196,8 @@ int btrfs_xattr_set(struct inode *inode, int name_index, | |||
201 | struct xattr_handler *handler = btrfs_xattr_handler(name_index); | 196 | struct xattr_handler *handler = btrfs_xattr_handler(name_index); |
202 | char *name; | 197 | char *name; |
203 | int ret = 0, mod = 0; | 198 | int ret = 0, mod = 0; |
204 | |||
205 | if (!handler) | 199 | if (!handler) |
206 | return -EOPNOTSUPP; | 200 | return -EOPNOTSUPP; |
207 | |||
208 | /* just in case... */ | ||
209 | if (*attr_name == '\0') | ||
210 | return -EINVAL; | ||
211 | |||
212 | name = get_name(attr_name, name_index); | 201 | name = get_name(attr_name, name_index); |
213 | if (!name) | 202 | if (!name) |
214 | return -ENOMEM; | 203 | return -ENOMEM; |
@@ -454,15 +443,18 @@ static int btrfs_xattr_##name##_get(struct inode *inode, \ | |||
454 | const char *name, void *value, \ | 443 | const char *name, void *value, \ |
455 | size_t size) \ | 444 | size_t size) \ |
456 | { \ | 445 | { \ |
446 | if (*name == '\0') \ | ||
447 | return -EINVAL; \ | ||
457 | return btrfs_xattr_get(inode, index, name, value, size); \ | 448 | return btrfs_xattr_get(inode, index, name, value, size); \ |
458 | } \ | 449 | } \ |
459 | static int btrfs_xattr_##name##_set(struct inode *inode, \ | 450 | static int btrfs_xattr_##name##_set(struct inode *inode, \ |
460 | const char *name, const void *value,\ | 451 | const char *name, const void *value,\ |
461 | size_t size, int flags) \ | 452 | size_t size, int flags) \ |
462 | { \ | 453 | { \ |
454 | if (*name == '\0') \ | ||
455 | return -EINVAL; \ | ||
463 | return btrfs_xattr_set(inode, index, name, value, size, flags); \ | 456 | return btrfs_xattr_set(inode, index, name, value, size, flags); \ |
464 | } \ | 457 | } \ |
465 | |||
466 | BTRFS_XATTR_SETGET_FUNCS(security, BTRFS_XATTR_INDEX_SECURITY); | 458 | BTRFS_XATTR_SETGET_FUNCS(security, BTRFS_XATTR_INDEX_SECURITY); |
467 | BTRFS_XATTR_SETGET_FUNCS(system, BTRFS_XATTR_INDEX_SYSTEM); | 459 | BTRFS_XATTR_SETGET_FUNCS(system, BTRFS_XATTR_INDEX_SYSTEM); |
468 | BTRFS_XATTR_SETGET_FUNCS(user, BTRFS_XATTR_INDEX_USER); | 460 | BTRFS_XATTR_SETGET_FUNCS(user, BTRFS_XATTR_INDEX_USER); |