diff options
author | Andrea Bastoni <bastoni@cs.unc.edu> | 2010-05-30 19:16:45 -0400 |
---|---|---|
committer | Andrea Bastoni <bastoni@cs.unc.edu> | 2010-05-30 19:16:45 -0400 |
commit | ada47b5fe13d89735805b566185f4885f5a3f750 (patch) | |
tree | 644b88f8a71896307d71438e9b3af49126ffb22b /fs/xfs/linux-2.6/xfs_acl.c | |
parent | 43e98717ad40a4ae64545b5ba047c7b86aa44f4f (diff) | |
parent | 3280f21d43ee541f97f8cda5792150d2dbec20d5 (diff) |
Merge branch 'wip-2.6.34' into old-private-masterarchived-private-master
Diffstat (limited to 'fs/xfs/linux-2.6/xfs_acl.c')
-rw-r--r-- | fs/xfs/linux-2.6/xfs_acl.c | 73 |
1 files changed, 30 insertions, 43 deletions
diff --git a/fs/xfs/linux-2.6/xfs_acl.c b/fs/xfs/linux-2.6/xfs_acl.c index b23a54506446..a7bc925c4d60 100644 --- a/fs/xfs/linux-2.6/xfs_acl.c +++ b/fs/xfs/linux-2.6/xfs_acl.c | |||
@@ -21,6 +21,8 @@ | |||
21 | #include "xfs_bmap_btree.h" | 21 | #include "xfs_bmap_btree.h" |
22 | #include "xfs_inode.h" | 22 | #include "xfs_inode.h" |
23 | #include "xfs_vnodeops.h" | 23 | #include "xfs_vnodeops.h" |
24 | #include "xfs_trace.h" | ||
25 | #include <linux/slab.h> | ||
24 | #include <linux/xattr.h> | 26 | #include <linux/xattr.h> |
25 | #include <linux/posix_acl_xattr.h> | 27 | #include <linux/posix_acl_xattr.h> |
26 | 28 | ||
@@ -105,7 +107,7 @@ xfs_get_acl(struct inode *inode, int type) | |||
105 | struct posix_acl *acl; | 107 | struct posix_acl *acl; |
106 | struct xfs_acl *xfs_acl; | 108 | struct xfs_acl *xfs_acl; |
107 | int len = sizeof(struct xfs_acl); | 109 | int len = sizeof(struct xfs_acl); |
108 | char *ea_name; | 110 | unsigned char *ea_name; |
109 | int error; | 111 | int error; |
110 | 112 | ||
111 | acl = get_cached_acl(inode, type); | 113 | acl = get_cached_acl(inode, type); |
@@ -132,7 +134,8 @@ xfs_get_acl(struct inode *inode, int type) | |||
132 | if (!xfs_acl) | 134 | if (!xfs_acl) |
133 | return ERR_PTR(-ENOMEM); | 135 | return ERR_PTR(-ENOMEM); |
134 | 136 | ||
135 | error = -xfs_attr_get(ip, ea_name, (char *)xfs_acl, &len, ATTR_ROOT); | 137 | error = -xfs_attr_get(ip, ea_name, (unsigned char *)xfs_acl, |
138 | &len, ATTR_ROOT); | ||
136 | if (error) { | 139 | if (error) { |
137 | /* | 140 | /* |
138 | * If the attribute doesn't exist make sure we have a negative | 141 | * If the attribute doesn't exist make sure we have a negative |
@@ -161,7 +164,7 @@ STATIC int | |||
161 | xfs_set_acl(struct inode *inode, int type, struct posix_acl *acl) | 164 | xfs_set_acl(struct inode *inode, int type, struct posix_acl *acl) |
162 | { | 165 | { |
163 | struct xfs_inode *ip = XFS_I(inode); | 166 | struct xfs_inode *ip = XFS_I(inode); |
164 | char *ea_name; | 167 | unsigned char *ea_name; |
165 | int error; | 168 | int error; |
166 | 169 | ||
167 | if (S_ISLNK(inode->i_mode)) | 170 | if (S_ISLNK(inode->i_mode)) |
@@ -193,7 +196,7 @@ xfs_set_acl(struct inode *inode, int type, struct posix_acl *acl) | |||
193 | (sizeof(struct xfs_acl_entry) * | 196 | (sizeof(struct xfs_acl_entry) * |
194 | (XFS_ACL_MAX_ENTRIES - acl->a_count)); | 197 | (XFS_ACL_MAX_ENTRIES - acl->a_count)); |
195 | 198 | ||
196 | error = -xfs_attr_set(ip, ea_name, (char *)xfs_acl, | 199 | error = -xfs_attr_set(ip, ea_name, (unsigned char *)xfs_acl, |
197 | len, ATTR_ROOT); | 200 | len, ATTR_ROOT); |
198 | 201 | ||
199 | kfree(xfs_acl); | 202 | kfree(xfs_acl); |
@@ -250,8 +253,9 @@ xfs_set_mode(struct inode *inode, mode_t mode) | |||
250 | if (mode != inode->i_mode) { | 253 | if (mode != inode->i_mode) { |
251 | struct iattr iattr; | 254 | struct iattr iattr; |
252 | 255 | ||
253 | iattr.ia_valid = ATTR_MODE; | 256 | iattr.ia_valid = ATTR_MODE | ATTR_CTIME; |
254 | iattr.ia_mode = mode; | 257 | iattr.ia_mode = mode; |
258 | iattr.ia_ctime = current_fs_time(inode->i_sb); | ||
255 | 259 | ||
256 | error = -xfs_setattr(XFS_I(inode), &iattr, XFS_ATTR_NOACL); | 260 | error = -xfs_setattr(XFS_I(inode), &iattr, XFS_ATTR_NOACL); |
257 | } | 261 | } |
@@ -260,7 +264,7 @@ xfs_set_mode(struct inode *inode, mode_t mode) | |||
260 | } | 264 | } |
261 | 265 | ||
262 | static int | 266 | static int |
263 | xfs_acl_exists(struct inode *inode, char *name) | 267 | xfs_acl_exists(struct inode *inode, unsigned char *name) |
264 | { | 268 | { |
265 | int len = sizeof(struct xfs_acl); | 269 | int len = sizeof(struct xfs_acl); |
266 | 270 | ||
@@ -353,37 +357,14 @@ xfs_acl_chmod(struct inode *inode) | |||
353 | return error; | 357 | return error; |
354 | } | 358 | } |
355 | 359 | ||
356 | /* | ||
357 | * System xattr handlers. | ||
358 | * | ||
359 | * Currently Posix ACLs are the only system namespace extended attribute | ||
360 | * handlers supported by XFS, so we just implement the handlers here. | ||
361 | * If we ever support other system extended attributes this will need | ||
362 | * some refactoring. | ||
363 | */ | ||
364 | |||
365 | static int | 360 | static int |
366 | xfs_decode_acl(const char *name) | 361 | xfs_xattr_acl_get(struct dentry *dentry, const char *name, |
367 | { | 362 | void *value, size_t size, int type) |
368 | if (strcmp(name, "posix_acl_access") == 0) | ||
369 | return ACL_TYPE_ACCESS; | ||
370 | else if (strcmp(name, "posix_acl_default") == 0) | ||
371 | return ACL_TYPE_DEFAULT; | ||
372 | return -EINVAL; | ||
373 | } | ||
374 | |||
375 | static int | ||
376 | xfs_xattr_system_get(struct inode *inode, const char *name, | ||
377 | void *value, size_t size) | ||
378 | { | 363 | { |
379 | struct posix_acl *acl; | 364 | struct posix_acl *acl; |
380 | int type, error; | 365 | int error; |
381 | |||
382 | type = xfs_decode_acl(name); | ||
383 | if (type < 0) | ||
384 | return type; | ||
385 | 366 | ||
386 | acl = xfs_get_acl(inode, type); | 367 | acl = xfs_get_acl(dentry->d_inode, type); |
387 | if (IS_ERR(acl)) | 368 | if (IS_ERR(acl)) |
388 | return PTR_ERR(acl); | 369 | return PTR_ERR(acl); |
389 | if (acl == NULL) | 370 | if (acl == NULL) |
@@ -396,15 +377,13 @@ xfs_xattr_system_get(struct inode *inode, const char *name, | |||
396 | } | 377 | } |
397 | 378 | ||
398 | static int | 379 | static int |
399 | xfs_xattr_system_set(struct inode *inode, const char *name, | 380 | xfs_xattr_acl_set(struct dentry *dentry, const char *name, |
400 | const void *value, size_t size, int flags) | 381 | const void *value, size_t size, int flags, int type) |
401 | { | 382 | { |
383 | struct inode *inode = dentry->d_inode; | ||
402 | struct posix_acl *acl = NULL; | 384 | struct posix_acl *acl = NULL; |
403 | int error = 0, type; | 385 | int error = 0; |
404 | 386 | ||
405 | type = xfs_decode_acl(name); | ||
406 | if (type < 0) | ||
407 | return type; | ||
408 | if (flags & XATTR_CREATE) | 387 | if (flags & XATTR_CREATE) |
409 | return -EINVAL; | 388 | return -EINVAL; |
410 | if (type == ACL_TYPE_DEFAULT && !S_ISDIR(inode->i_mode)) | 389 | if (type == ACL_TYPE_DEFAULT && !S_ISDIR(inode->i_mode)) |
@@ -461,8 +440,16 @@ xfs_xattr_system_set(struct inode *inode, const char *name, | |||
461 | return error; | 440 | return error; |
462 | } | 441 | } |
463 | 442 | ||
464 | struct xattr_handler xfs_xattr_system_handler = { | 443 | struct xattr_handler xfs_xattr_acl_access_handler = { |
465 | .prefix = XATTR_SYSTEM_PREFIX, | 444 | .prefix = POSIX_ACL_XATTR_ACCESS, |
466 | .get = xfs_xattr_system_get, | 445 | .flags = ACL_TYPE_ACCESS, |
467 | .set = xfs_xattr_system_set, | 446 | .get = xfs_xattr_acl_get, |
447 | .set = xfs_xattr_acl_set, | ||
448 | }; | ||
449 | |||
450 | struct xattr_handler xfs_xattr_acl_default_handler = { | ||
451 | .prefix = POSIX_ACL_XATTR_DEFAULT, | ||
452 | .flags = ACL_TYPE_DEFAULT, | ||
453 | .get = xfs_xattr_acl_get, | ||
454 | .set = xfs_xattr_acl_set, | ||
468 | }; | 455 | }; |