summaryrefslogtreecommitdiff
path: root/fs/btrfs/acl.c
diff options
context:
space:
mode:
authorYan <yanzheng@21cn.com>2008-01-14 13:26:08 -0500
committerChris Mason <chris.mason@oracle.com>2008-09-25 11:03:59 -0400
commit744f52f997b21de2a01931f79cf6c198bf688120 (patch)
tree903f0d91560b139bc7167f424e34664ddb7c0b72 /fs/btrfs/acl.c
parentb3a0d8d28c607cb2531a68742afc2b967b1f6083 (diff)
Btrfs: Implement ACLs setting and getting
ACLs are stored but not used for permission checks (yet) Signed-off-by: Chris Mason <chris.mason@oracle.com>
Diffstat (limited to 'fs/btrfs/acl.c')
-rw-r--r--fs/btrfs/acl.c73
1 files changed, 44 insertions, 29 deletions
diff --git a/fs/btrfs/acl.c b/fs/btrfs/acl.c
index 889ba89d3f9..b4f85ebe1bd 100644
--- a/fs/btrfs/acl.c
+++ b/fs/btrfs/acl.c
@@ -22,53 +22,68 @@
#include <linux/posix_acl_xattr.h>
#include "ctree.h"
#include "xattr.h"
+static int btrfs_xattr_set_acl(struct inode *inode, int type,
+ const void *value, size_t size)
+{
+ int ret = 0;
+ struct posix_acl *acl;
-/*
- * FIXME: At this point this is all place holder stuff, we just return
- * -EOPNOTSUPP so cp won't complain when it tries to copy over a file with an
- * acl on it.
- */
+ if (!is_owner_or_cap(inode))
+ return -EPERM;
+ if (value) {
+ acl = posix_acl_from_xattr(value, size);
+ if (acl == NULL) {
+ value = NULL;
+ size = 0;
+ } else if (IS_ERR(acl)) {
+ ret = PTR_ERR(acl);
+ } else {
+ ret = posix_acl_valid(acl);
+ posix_acl_release(acl);
+ }
+ if (ret)
+ return ret;
+ }
+ return btrfs_xattr_set(inode, type, "", value, size, 0);
+}
+static int btrfs_xattr_get_acl(struct inode *inode, int type,
+ void *value, size_t size)
+{
+ return btrfs_xattr_get(inode, type, "", value, size);
+}
static int btrfs_xattr_acl_access_get(struct inode *inode, const char *name,
void *value, size_t size)
{
- /*
- return btrfs_xattr_get(inode, BTRFS_XATTR_INDEX_POSIX_ACL_ACCESS, name,
- value, size);
- */
- return -EOPNOTSUPP;
+ if (*name != '\0')
+ return -EINVAL;
+ return btrfs_xattr_get_acl(inode, BTRFS_XATTR_INDEX_POSIX_ACL_ACCESS,
+ value, size);
}
-
static int btrfs_xattr_acl_access_set(struct inode *inode, const char *name,
const void *value, size_t size, int flags)
{
- /*
- return btrfs_xattr_set(inode, BTRFS_XATTR_INDEX_POSIX_ACL_ACCESS, name,
- value, size, flags);
- */
- return -EOPNOTSUPP;
+ if (*name != '\0')
+ return -EINVAL;
+ return btrfs_xattr_set_acl(inode, BTRFS_XATTR_INDEX_POSIX_ACL_ACCESS,
+ value, size);
}
-
static int btrfs_xattr_acl_default_get(struct inode *inode, const char *name,
void *value, size_t size)
{
- /*
- return btrfs_xattr_get(inode, BTRFS_XATTR_INDEX_POSIX_ACL_DEFAULT,
- name, value, size);
- */
- return -EOPNOTSUPP;
+ if (*name != '\0')
+ return -EINVAL;
+ return btrfs_xattr_get_acl(inode, BTRFS_XATTR_INDEX_POSIX_ACL_DEFAULT,
+ value, size);
}
-
static int btrfs_xattr_acl_default_set(struct inode *inode, const char *name,
const void *value, size_t size, int flags)
{
- /*
- return btrfs_xattr_set(inode, BTRFS_XATTR_INDEX_POSIX_ACL_DEFAULT,
- name, value, size, flags);
- */
- return -EOPNOTSUPP;
+ if (*name != '\0')
+ return -EINVAL;
+ return btrfs_xattr_set_acl(inode, BTRFS_XATTR_INDEX_POSIX_ACL_DEFAULT,
+ value, size);
}
-
struct xattr_handler btrfs_xattr_acl_default_handler = {
.prefix = POSIX_ACL_XATTR_DEFAULT,
.list = btrfs_xattr_generic_list,