aboutsummaryrefslogtreecommitdiffstats
path: root/fs/xfs/linux-2.6/xfs_acl.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/xfs/linux-2.6/xfs_acl.c')
-rw-r--r--fs/xfs/linux-2.6/xfs_acl.c58
1 files changed, 21 insertions, 37 deletions
diff --git a/fs/xfs/linux-2.6/xfs_acl.c b/fs/xfs/linux-2.6/xfs_acl.c
index b23a54506446..2512125dfa7c 100644
--- a/fs/xfs/linux-2.6/xfs_acl.c
+++ b/fs/xfs/linux-2.6/xfs_acl.c
@@ -21,6 +21,7 @@
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"
24#include <linux/xattr.h> 25#include <linux/xattr.h>
25#include <linux/posix_acl_xattr.h> 26#include <linux/posix_acl_xattr.h>
26 27
@@ -353,37 +354,14 @@ xfs_acl_chmod(struct inode *inode)
353 return error; 354 return error;
354} 355}
355 356
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
365static int 357static int
366xfs_decode_acl(const char *name) 358xfs_xattr_acl_get(struct dentry *dentry, const char *name,
367{ 359 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
375static int
376xfs_xattr_system_get(struct inode *inode, const char *name,
377 void *value, size_t size)
378{ 360{
379 struct posix_acl *acl; 361 struct posix_acl *acl;
380 int type, error; 362 int error;
381
382 type = xfs_decode_acl(name);
383 if (type < 0)
384 return type;
385 363
386 acl = xfs_get_acl(inode, type); 364 acl = xfs_get_acl(dentry->d_inode, type);
387 if (IS_ERR(acl)) 365 if (IS_ERR(acl))
388 return PTR_ERR(acl); 366 return PTR_ERR(acl);
389 if (acl == NULL) 367 if (acl == NULL)
@@ -396,15 +374,13 @@ xfs_xattr_system_get(struct inode *inode, const char *name,
396} 374}
397 375
398static int 376static int
399xfs_xattr_system_set(struct inode *inode, const char *name, 377xfs_xattr_acl_set(struct dentry *dentry, const char *name,
400 const void *value, size_t size, int flags) 378 const void *value, size_t size, int flags, int type)
401{ 379{
380 struct inode *inode = dentry->d_inode;
402 struct posix_acl *acl = NULL; 381 struct posix_acl *acl = NULL;
403 int error = 0, type; 382 int error = 0;
404 383
405 type = xfs_decode_acl(name);
406 if (type < 0)
407 return type;
408 if (flags & XATTR_CREATE) 384 if (flags & XATTR_CREATE)
409 return -EINVAL; 385 return -EINVAL;
410 if (type == ACL_TYPE_DEFAULT && !S_ISDIR(inode->i_mode)) 386 if (type == ACL_TYPE_DEFAULT && !S_ISDIR(inode->i_mode))
@@ -461,8 +437,16 @@ xfs_xattr_system_set(struct inode *inode, const char *name,
461 return error; 437 return error;
462} 438}
463 439
464struct xattr_handler xfs_xattr_system_handler = { 440struct xattr_handler xfs_xattr_acl_access_handler = {
465 .prefix = XATTR_SYSTEM_PREFIX, 441 .prefix = POSIX_ACL_XATTR_ACCESS,
466 .get = xfs_xattr_system_get, 442 .flags = ACL_TYPE_ACCESS,
467 .set = xfs_xattr_system_set, 443 .get = xfs_xattr_acl_get,
444 .set = xfs_xattr_acl_set,
445};
446
447struct 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,
468}; 452};