fs/9p: Add xattr callbacks for POSIX ACL
authorAneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
Mon, 27 Sep 2010 18:57:39 +0000 (00:27 +0530)
committerEric Van Hensbergen <ericvh@gmail.com>
Thu, 28 Oct 2010 14:08:46 +0000 (09:08 -0500)
This patch implement fetching POSIX ACL from the server

Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
Signed-off-by: Venkateswararao Jujjuri <jvrao@linux.vnet.ibm.com>
Signed-off-by: Eric Van Hensbergen <ericvh@gmail.com>
fs/9p/acl.c
fs/9p/xattr.c
fs/9p/xattr.h

index a8c013615a22b6b2e7232018077ff4562f100150..4293b4599ff645e8da821cc09bf68577eb65052b 100644 (file)
@@ -94,3 +94,44 @@ int v9fs_check_acl(struct inode *inode, int mask)
        }
        return -EAGAIN;
 }
+
+static int v9fs_xattr_get_acl(struct dentry *dentry, const char *name,
+                             void *buffer, size_t size, int type)
+{
+       struct posix_acl *acl;
+       int error;
+
+       if (strcmp(name, "") != 0)
+               return -EINVAL;
+
+       acl = v9fs_get_cached_acl(dentry->d_inode, type);
+       if (IS_ERR(acl))
+               return PTR_ERR(acl);
+       if (acl == NULL)
+               return -ENODATA;
+       error = posix_acl_to_xattr(acl, buffer, size);
+       posix_acl_release(acl);
+
+       return error;
+}
+
+static int v9fs_xattr_set_acl(struct dentry *dentry, const char *name,
+                             const void *value, size_t size,
+                             int flags, int type)
+{
+       return 0;
+}
+
+const struct xattr_handler v9fs_xattr_acl_access_handler = {
+       .prefix = POSIX_ACL_XATTR_ACCESS,
+       .flags  = ACL_TYPE_ACCESS,
+       .get    = v9fs_xattr_get_acl,
+       .set    = v9fs_xattr_set_acl,
+};
+
+const struct xattr_handler v9fs_xattr_acl_default_handler = {
+       .prefix = POSIX_ACL_XATTR_DEFAULT,
+       .flags  = ACL_TYPE_DEFAULT,
+       .get    = v9fs_xattr_get_acl,
+       .set    = v9fs_xattr_set_acl,
+};
index 67ac6cfc1a0778d3346b663fc1138c161d8afd9f..43ec7df84336f7f3e824b9c801abafebe1dd07e8 100644 (file)
@@ -164,5 +164,9 @@ ssize_t v9fs_listxattr(struct dentry *dentry, char *buffer, size_t buffer_size)
 
 const struct xattr_handler *v9fs_xattr_handlers[] = {
        &v9fs_xattr_user_handler,
+#ifdef CONFIG_9P_FS_POSIX_ACL
+       &v9fs_xattr_acl_access_handler,
+       &v9fs_xattr_acl_default_handler,
+#endif
        NULL
 };
index ec908c693342cfa0d2baa66acde9411ef60ec025..eaa837c53bd5bd29e81ec2757f54ac746a974aac 100644 (file)
@@ -20,6 +20,8 @@
 
 extern const struct xattr_handler *v9fs_xattr_handlers[];
 extern struct xattr_handler v9fs_xattr_user_handler;
+extern const struct xattr_handler v9fs_xattr_acl_access_handler;
+extern const struct xattr_handler v9fs_xattr_acl_default_handler;
 
 extern ssize_t v9fs_fid_xattr_get(struct p9_fid *, const char *,
                                  void *, size_t);