diff options
Diffstat (limited to 'fs/xfs/linux-2.6')
-rw-r--r-- | fs/xfs/linux-2.6/xfs_acl.c | 57 | ||||
-rw-r--r-- | fs/xfs/linux-2.6/xfs_xattr.c | 71 |
2 files changed, 35 insertions, 93 deletions
diff --git a/fs/xfs/linux-2.6/xfs_acl.c b/fs/xfs/linux-2.6/xfs_acl.c index 69e598b6986f..2512125dfa7c 100644 --- a/fs/xfs/linux-2.6/xfs_acl.c +++ b/fs/xfs/linux-2.6/xfs_acl.c | |||
@@ -354,37 +354,14 @@ xfs_acl_chmod(struct inode *inode) | |||
354 | return error; | 354 | return error; |
355 | } | 355 | } |
356 | 356 | ||
357 | /* | ||
358 | * System xattr handlers. | ||
359 | * | ||
360 | * Currently Posix ACLs are the only system namespace extended attribute | ||
361 | * handlers supported by XFS, so we just implement the handlers here. | ||
362 | * If we ever support other system extended attributes this will need | ||
363 | * some refactoring. | ||
364 | */ | ||
365 | |||
366 | static int | 357 | static int |
367 | xfs_decode_acl(const char *name) | 358 | xfs_xattr_acl_get(struct dentry *dentry, const char *name, |
368 | { | 359 | void *value, size_t size, int type) |
369 | if (strcmp(name, "posix_acl_access") == 0) | ||
370 | return ACL_TYPE_ACCESS; | ||
371 | else if (strcmp(name, "posix_acl_default") == 0) | ||
372 | return ACL_TYPE_DEFAULT; | ||
373 | return -EINVAL; | ||
374 | } | ||
375 | |||
376 | static int | ||
377 | xfs_xattr_system_get(struct inode *inode, const char *name, | ||
378 | void *value, size_t size) | ||
379 | { | 360 | { |
380 | struct posix_acl *acl; | 361 | struct posix_acl *acl; |
381 | int type, error; | 362 | int error; |
382 | |||
383 | type = xfs_decode_acl(name); | ||
384 | if (type < 0) | ||
385 | return type; | ||
386 | 363 | ||
387 | acl = xfs_get_acl(inode, type); | 364 | acl = xfs_get_acl(dentry->d_inode, type); |
388 | if (IS_ERR(acl)) | 365 | if (IS_ERR(acl)) |
389 | return PTR_ERR(acl); | 366 | return PTR_ERR(acl); |
390 | if (acl == NULL) | 367 | if (acl == NULL) |
@@ -397,15 +374,13 @@ xfs_xattr_system_get(struct inode *inode, const char *name, | |||
397 | } | 374 | } |
398 | 375 | ||
399 | static int | 376 | static int |
400 | xfs_xattr_system_set(struct inode *inode, const char *name, | 377 | xfs_xattr_acl_set(struct dentry *dentry, const char *name, |
401 | const void *value, size_t size, int flags) | 378 | const void *value, size_t size, int flags, int type) |
402 | { | 379 | { |
380 | struct inode *inode = dentry->d_inode; | ||
403 | struct posix_acl *acl = NULL; | 381 | struct posix_acl *acl = NULL; |
404 | int error = 0, type; | 382 | int error = 0; |
405 | 383 | ||
406 | type = xfs_decode_acl(name); | ||
407 | if (type < 0) | ||
408 | return type; | ||
409 | if (flags & XATTR_CREATE) | 384 | if (flags & XATTR_CREATE) |
410 | return -EINVAL; | 385 | return -EINVAL; |
411 | if (type == ACL_TYPE_DEFAULT && !S_ISDIR(inode->i_mode)) | 386 | if (type == ACL_TYPE_DEFAULT && !S_ISDIR(inode->i_mode)) |
@@ -462,8 +437,16 @@ xfs_xattr_system_set(struct inode *inode, const char *name, | |||
462 | return error; | 437 | return error; |
463 | } | 438 | } |
464 | 439 | ||
465 | struct xattr_handler xfs_xattr_system_handler = { | 440 | struct xattr_handler xfs_xattr_acl_access_handler = { |
466 | .prefix = XATTR_SYSTEM_PREFIX, | 441 | .prefix = POSIX_ACL_XATTR_ACCESS, |
467 | .get = xfs_xattr_system_get, | 442 | .flags = ACL_TYPE_ACCESS, |
468 | .set = xfs_xattr_system_set, | 443 | .get = xfs_xattr_acl_get, |
444 | .set = xfs_xattr_acl_set, | ||
445 | }; | ||
446 | |||
447 | struct xattr_handler xfs_xattr_acl_default_handler = { | ||
448 | .prefix = POSIX_ACL_XATTR_DEFAULT, | ||
449 | .flags = ACL_TYPE_DEFAULT, | ||
450 | .get = xfs_xattr_acl_get, | ||
451 | .set = xfs_xattr_acl_set, | ||
469 | }; | 452 | }; |
diff --git a/fs/xfs/linux-2.6/xfs_xattr.c b/fs/xfs/linux-2.6/xfs_xattr.c index 497c7fb75cc1..0b1878857fc3 100644 --- a/fs/xfs/linux-2.6/xfs_xattr.c +++ b/fs/xfs/linux-2.6/xfs_xattr.c | |||
@@ -30,10 +30,10 @@ | |||
30 | 30 | ||
31 | 31 | ||
32 | static int | 32 | static int |
33 | __xfs_xattr_get(struct inode *inode, const char *name, | 33 | xfs_xattr_get(struct dentry *dentry, const char *name, |
34 | void *value, size_t size, int xflags) | 34 | void *value, size_t size, int xflags) |
35 | { | 35 | { |
36 | struct xfs_inode *ip = XFS_I(inode); | 36 | struct xfs_inode *ip = XFS_I(dentry->d_inode); |
37 | int error, asize = size; | 37 | int error, asize = size; |
38 | 38 | ||
39 | if (strcmp(name, "") == 0) | 39 | if (strcmp(name, "") == 0) |
@@ -52,10 +52,10 @@ __xfs_xattr_get(struct inode *inode, const char *name, | |||
52 | } | 52 | } |
53 | 53 | ||
54 | static int | 54 | static int |
55 | __xfs_xattr_set(struct inode *inode, const char *name, const void *value, | 55 | xfs_xattr_set(struct dentry *dentry, const char *name, const void *value, |
56 | size_t size, int flags, int xflags) | 56 | size_t size, int flags, int xflags) |
57 | { | 57 | { |
58 | struct xfs_inode *ip = XFS_I(inode); | 58 | struct xfs_inode *ip = XFS_I(dentry->d_inode); |
59 | 59 | ||
60 | if (strcmp(name, "") == 0) | 60 | if (strcmp(name, "") == 0) |
61 | return -EINVAL; | 61 | return -EINVAL; |
@@ -71,75 +71,34 @@ __xfs_xattr_set(struct inode *inode, const char *name, const void *value, | |||
71 | return -xfs_attr_set(ip, name, (void *)value, size, xflags); | 71 | return -xfs_attr_set(ip, name, (void *)value, size, xflags); |
72 | } | 72 | } |
73 | 73 | ||
74 | static int | ||
75 | xfs_xattr_user_get(struct inode *inode, const char *name, | ||
76 | void *value, size_t size) | ||
77 | { | ||
78 | return __xfs_xattr_get(inode, name, value, size, 0); | ||
79 | } | ||
80 | |||
81 | static int | ||
82 | xfs_xattr_user_set(struct inode *inode, const char *name, | ||
83 | const void *value, size_t size, int flags) | ||
84 | { | ||
85 | return __xfs_xattr_set(inode, name, value, size, flags, 0); | ||
86 | } | ||
87 | |||
88 | static struct xattr_handler xfs_xattr_user_handler = { | 74 | static struct xattr_handler xfs_xattr_user_handler = { |
89 | .prefix = XATTR_USER_PREFIX, | 75 | .prefix = XATTR_USER_PREFIX, |
90 | .get = xfs_xattr_user_get, | 76 | .flags = 0, /* no flags implies user namespace */ |
91 | .set = xfs_xattr_user_set, | 77 | .get = xfs_xattr_get, |
78 | .set = xfs_xattr_set, | ||
92 | }; | 79 | }; |
93 | 80 | ||
94 | |||
95 | static int | ||
96 | xfs_xattr_trusted_get(struct inode *inode, const char *name, | ||
97 | void *value, size_t size) | ||
98 | { | ||
99 | return __xfs_xattr_get(inode, name, value, size, ATTR_ROOT); | ||
100 | } | ||
101 | |||
102 | static int | ||
103 | xfs_xattr_trusted_set(struct inode *inode, const char *name, | ||
104 | const void *value, size_t size, int flags) | ||
105 | { | ||
106 | return __xfs_xattr_set(inode, name, value, size, flags, ATTR_ROOT); | ||
107 | } | ||
108 | |||
109 | static struct xattr_handler xfs_xattr_trusted_handler = { | 81 | static struct xattr_handler xfs_xattr_trusted_handler = { |
110 | .prefix = XATTR_TRUSTED_PREFIX, | 82 | .prefix = XATTR_TRUSTED_PREFIX, |
111 | .get = xfs_xattr_trusted_get, | 83 | .flags = ATTR_ROOT, |
112 | .set = xfs_xattr_trusted_set, | 84 | .get = xfs_xattr_get, |
85 | .set = xfs_xattr_set, | ||
113 | }; | 86 | }; |
114 | 87 | ||
115 | |||
116 | static int | ||
117 | xfs_xattr_secure_get(struct inode *inode, const char *name, | ||
118 | void *value, size_t size) | ||
119 | { | ||
120 | return __xfs_xattr_get(inode, name, value, size, ATTR_SECURE); | ||
121 | } | ||
122 | |||
123 | static int | ||
124 | xfs_xattr_secure_set(struct inode *inode, const char *name, | ||
125 | const void *value, size_t size, int flags) | ||
126 | { | ||
127 | return __xfs_xattr_set(inode, name, value, size, flags, ATTR_SECURE); | ||
128 | } | ||
129 | |||
130 | static struct xattr_handler xfs_xattr_security_handler = { | 88 | static struct xattr_handler xfs_xattr_security_handler = { |
131 | .prefix = XATTR_SECURITY_PREFIX, | 89 | .prefix = XATTR_SECURITY_PREFIX, |
132 | .get = xfs_xattr_secure_get, | 90 | .flags = ATTR_SECURE, |
133 | .set = xfs_xattr_secure_set, | 91 | .get = xfs_xattr_get, |
92 | .set = xfs_xattr_set, | ||
134 | }; | 93 | }; |
135 | 94 | ||
136 | |||
137 | struct xattr_handler *xfs_xattr_handlers[] = { | 95 | struct xattr_handler *xfs_xattr_handlers[] = { |
138 | &xfs_xattr_user_handler, | 96 | &xfs_xattr_user_handler, |
139 | &xfs_xattr_trusted_handler, | 97 | &xfs_xattr_trusted_handler, |
140 | &xfs_xattr_security_handler, | 98 | &xfs_xattr_security_handler, |
141 | #ifdef CONFIG_XFS_POSIX_ACL | 99 | #ifdef CONFIG_XFS_POSIX_ACL |
142 | &xfs_xattr_system_handler, | 100 | &xfs_xattr_acl_access_handler, |
101 | &xfs_xattr_acl_default_handler, | ||
143 | #endif | 102 | #endif |
144 | NULL | 103 | NULL |
145 | }; | 104 | }; |