diff options
author | Jeff Mahoney <jeffm@suse.com> | 2009-03-30 14:02:38 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2009-03-30 15:16:38 -0400 |
commit | 48b32a3553a54740d236b79a90f20147a25875e3 (patch) | |
tree | faf6807facb5825608469a9e33c9127f90b974df /fs/reiserfs/xattr_trusted.c | |
parent | 8ecbe550a142fe604874afa477ea68986f89b86c (diff) |
reiserfs: use generic xattr handlers
Christoph Hellwig had asked me quite some time ago to port the reiserfs
xattrs to the generic xattr interface.
This patch replaces the reiserfs-specific xattr handling code with the
generic struct xattr_handler.
However, since reiserfs doesn't split the prefix and name when accessing
xattrs, it can't leverage generic_{set,get,list,remove}xattr without
needlessly reconstructing the name on the back end.
Update 7/26/07: Added missing dput() to deletion path.
Update 8/30/07: Added missing mark_inode_dirty when i_mode is used to
represent an ACL and no previous ACL existed.
Signed-off-by: Jeff Mahoney <jeffm@suse.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'fs/reiserfs/xattr_trusted.c')
-rw-r--r-- | fs/reiserfs/xattr_trusted.c | 45 |
1 files changed, 11 insertions, 34 deletions
diff --git a/fs/reiserfs/xattr_trusted.c b/fs/reiserfs/xattr_trusted.c index 076ad388d489..a865042f75e2 100644 --- a/fs/reiserfs/xattr_trusted.c +++ b/fs/reiserfs/xattr_trusted.c | |||
@@ -13,10 +13,7 @@ trusted_get(struct inode *inode, const char *name, void *buffer, size_t size) | |||
13 | if (strlen(name) < sizeof(XATTR_TRUSTED_PREFIX)) | 13 | if (strlen(name) < sizeof(XATTR_TRUSTED_PREFIX)) |
14 | return -EINVAL; | 14 | return -EINVAL; |
15 | 15 | ||
16 | if (!reiserfs_xattrs(inode->i_sb)) | 16 | if (!capable(CAP_SYS_ADMIN) || IS_PRIVATE(inode)) |
17 | return -EOPNOTSUPP; | ||
18 | |||
19 | if (!(capable(CAP_SYS_ADMIN) || IS_PRIVATE(inode))) | ||
20 | return -EPERM; | 17 | return -EPERM; |
21 | 18 | ||
22 | return reiserfs_xattr_get(inode, name, buffer, size); | 19 | return reiserfs_xattr_get(inode, name, buffer, size); |
@@ -29,50 +26,30 @@ trusted_set(struct inode *inode, const char *name, const void *buffer, | |||
29 | if (strlen(name) < sizeof(XATTR_TRUSTED_PREFIX)) | 26 | if (strlen(name) < sizeof(XATTR_TRUSTED_PREFIX)) |
30 | return -EINVAL; | 27 | return -EINVAL; |
31 | 28 | ||
32 | if (!reiserfs_xattrs(inode->i_sb)) | 29 | if (!capable(CAP_SYS_ADMIN) || IS_PRIVATE(inode)) |
33 | return -EOPNOTSUPP; | ||
34 | |||
35 | if (!(capable(CAP_SYS_ADMIN) || IS_PRIVATE(inode))) | ||
36 | return -EPERM; | 30 | return -EPERM; |
37 | 31 | ||
38 | return reiserfs_xattr_set(inode, name, buffer, size, flags); | 32 | return reiserfs_xattr_set(inode, name, buffer, size, flags); |
39 | } | 33 | } |
40 | 34 | ||
41 | static int trusted_del(struct inode *inode, const char *name) | 35 | static size_t trusted_list(struct inode *inode, char *list, size_t list_size, |
36 | const char *name, size_t name_len) | ||
42 | { | 37 | { |
43 | if (strlen(name) < sizeof(XATTR_TRUSTED_PREFIX)) | 38 | const size_t len = name_len + 1; |
44 | return -EINVAL; | ||
45 | 39 | ||
46 | if (!reiserfs_xattrs(inode->i_sb)) | 40 | if (!capable(CAP_SYS_ADMIN) || IS_PRIVATE(inode)) |
47 | return -EOPNOTSUPP; | ||
48 | |||
49 | if (!(capable(CAP_SYS_ADMIN) || IS_PRIVATE(inode))) | ||
50 | return -EPERM; | ||
51 | |||
52 | return 0; | ||
53 | } | ||
54 | |||
55 | static int | ||
56 | trusted_list(struct inode *inode, const char *name, int namelen, char *out) | ||
57 | { | ||
58 | int len = namelen; | ||
59 | |||
60 | if (!reiserfs_xattrs(inode->i_sb)) | ||
61 | return 0; | 41 | return 0; |
62 | 42 | ||
63 | if (!(capable(CAP_SYS_ADMIN) || IS_PRIVATE(inode))) | 43 | if (list && len <= list_size) { |
64 | return 0; | 44 | memcpy(list, name, name_len); |
65 | 45 | list[name_len] = '\0'; | |
66 | if (out) | 46 | } |
67 | memcpy(out, name, len); | ||
68 | |||
69 | return len; | 47 | return len; |
70 | } | 48 | } |
71 | 49 | ||
72 | struct reiserfs_xattr_handler trusted_handler = { | 50 | struct xattr_handler reiserfs_xattr_trusted_handler = { |
73 | .prefix = XATTR_TRUSTED_PREFIX, | 51 | .prefix = XATTR_TRUSTED_PREFIX, |
74 | .get = trusted_get, | 52 | .get = trusted_get, |
75 | .set = trusted_set, | 53 | .set = trusted_set, |
76 | .del = trusted_del, | ||
77 | .list = trusted_list, | 54 | .list = trusted_list, |
78 | }; | 55 | }; |