[PATCH 23/23] nfsd: Add support for saving richacl

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



With this patch nfsd will check whether the exported filesystem
use richacl format. If yes nfsd will map NFSv4 acl to richacl
and save the acl in richacl format ondisk. NFSv4 acl can be
better mapped to richacl format without loosing information.

Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@xxxxxxxxxxxxxxxxxx>
---
 fs/nfsd/vfs.c |   46 ++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 46 insertions(+), 0 deletions(-)

diff --git a/fs/nfsd/vfs.c b/fs/nfsd/vfs.c
index ce727a5..a1e5895 100644
--- a/fs/nfsd/vfs.c
+++ b/fs/nfsd/vfs.c
@@ -508,6 +508,50 @@ out_nfserr:
 		return nfserrno(host_error);
 }
 
+static int
+__set_richacl(struct dentry *dentry, struct richacl *racl)
+{
+	size_t buflen;
+	char *buf = NULL;
+	int error = 0;
+
+	buflen = richacl_xattr_size(racl);
+	buf = kmalloc(buflen, GFP_KERNEL);
+	error = -ENOMEM;
+	if (buf == NULL)
+		goto out;
+
+	richacl_to_xattr(racl, buf);
+	error = vfs_setxattr(dentry, RICHACL_XATTR, buf, buflen, 0);
+out:
+	kfree(buf);
+	return error;
+}
+
+static __be32
+nfsd4_set_richacl(struct dentry *dentry, struct nfs4_acl *acl)
+{
+	int host_error;
+	struct richacl *racl;
+
+	host_error = nfs4_acl_nfsv4_to_richacl(acl, &racl);
+	if (host_error == -EINVAL)
+		return nfserr_attrnotsupp;
+	else if (host_error < 0)
+		goto out_nfserr;
+
+	host_error = __set_richacl(dentry, racl);
+	if (host_error < 0)
+		goto out_release;
+out_release:
+	richacl_put(racl);
+out_nfserr:
+	if (host_error == -EOPNOTSUPP)
+		return nfserr_attrnotsupp;
+	else
+		return nfserrno(host_error);
+}
+
 __be32
 nfsd4_set_nfs4_acl(struct svc_rqst *rqstp, struct svc_fh *fhp,
     struct nfs4_acl *acl)
@@ -529,6 +573,8 @@ nfsd4_set_nfs4_acl(struct svc_rqst *rqstp, struct svc_fh *fhp,
 
 	if (IS_POSIXACL(inode))
 		error = nfsd4_set_posix_acl(dentry, acl, flags);
+	else if (IS_RICHACL(inode))
+		error = nfsd4_set_richacl(dentry, acl);
 	else
 		error = nfserr_attrnotsupp;
 
-- 
1.7.0.rc0.48.gdace5

--
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [Samba]     [Device Mapper]     [CEPH Development]
  Powered by Linux