nfsd: use get_acl and ->set_acl
Remove the boilerplate code to marshall and unmarhall ACL objects into xattrs and operate on the posix_acl objects directly. Also move all the ACL handling code into nfs?acl.c where it belongs. Signed-off-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
This commit is contained in:

committed by
Al Viro

parent
feda821e76
commit
4ac7249ea5
@@ -29,8 +29,9 @@ nfsd3_proc_null(struct svc_rqst *rqstp, void *argp, void *resp)
|
||||
static __be32 nfsd3_proc_getacl(struct svc_rqst * rqstp,
|
||||
struct nfsd3_getaclargs *argp, struct nfsd3_getaclres *resp)
|
||||
{
|
||||
svc_fh *fh;
|
||||
struct posix_acl *acl;
|
||||
struct inode *inode;
|
||||
svc_fh *fh;
|
||||
__be32 nfserr = 0;
|
||||
|
||||
fh = fh_copy(&resp->fh, &argp->fh);
|
||||
@@ -38,26 +39,20 @@ static __be32 nfsd3_proc_getacl(struct svc_rqst * rqstp,
|
||||
if (nfserr)
|
||||
RETURN_STATUS(nfserr);
|
||||
|
||||
inode = fh->fh_dentry->d_inode;
|
||||
|
||||
if (argp->mask & ~(NFS_ACL|NFS_ACLCNT|NFS_DFACL|NFS_DFACLCNT))
|
||||
RETURN_STATUS(nfserr_inval);
|
||||
resp->mask = argp->mask;
|
||||
|
||||
if (resp->mask & (NFS_ACL|NFS_ACLCNT)) {
|
||||
acl = nfsd_get_posix_acl(fh, ACL_TYPE_ACCESS);
|
||||
acl = get_acl(inode, ACL_TYPE_ACCESS);
|
||||
if (IS_ERR(acl)) {
|
||||
int err = PTR_ERR(acl);
|
||||
|
||||
if (err == -ENODATA || err == -EOPNOTSUPP)
|
||||
acl = NULL;
|
||||
else {
|
||||
nfserr = nfserrno(err);
|
||||
goto fail;
|
||||
}
|
||||
nfserr = nfserrno(PTR_ERR(acl));
|
||||
goto fail;
|
||||
}
|
||||
if (acl == NULL) {
|
||||
/* Solaris returns the inode's minimum ACL. */
|
||||
|
||||
struct inode *inode = fh->fh_dentry->d_inode;
|
||||
acl = posix_acl_from_mode(inode->i_mode, GFP_KERNEL);
|
||||
}
|
||||
resp->acl_access = acl;
|
||||
@@ -65,17 +60,10 @@ static __be32 nfsd3_proc_getacl(struct svc_rqst * rqstp,
|
||||
if (resp->mask & (NFS_DFACL|NFS_DFACLCNT)) {
|
||||
/* Check how Solaris handles requests for the Default ACL
|
||||
of a non-directory! */
|
||||
|
||||
acl = nfsd_get_posix_acl(fh, ACL_TYPE_DEFAULT);
|
||||
acl = get_acl(inode, ACL_TYPE_DEFAULT);
|
||||
if (IS_ERR(acl)) {
|
||||
int err = PTR_ERR(acl);
|
||||
|
||||
if (err == -ENODATA || err == -EOPNOTSUPP)
|
||||
acl = NULL;
|
||||
else {
|
||||
nfserr = nfserrno(err);
|
||||
goto fail;
|
||||
}
|
||||
nfserr = nfserrno(PTR_ERR(acl));
|
||||
goto fail;
|
||||
}
|
||||
resp->acl_default = acl;
|
||||
}
|
||||
@@ -96,21 +84,37 @@ static __be32 nfsd3_proc_setacl(struct svc_rqst * rqstp,
|
||||
struct nfsd3_setaclargs *argp,
|
||||
struct nfsd3_attrstat *resp)
|
||||
{
|
||||
struct inode *inode;
|
||||
svc_fh *fh;
|
||||
__be32 nfserr = 0;
|
||||
int error;
|
||||
|
||||
fh = fh_copy(&resp->fh, &argp->fh);
|
||||
nfserr = fh_verify(rqstp, &resp->fh, 0, NFSD_MAY_SATTR);
|
||||
if (nfserr)
|
||||
goto out;
|
||||
|
||||
if (!nfserr) {
|
||||
nfserr = nfserrno( nfsd_set_posix_acl(
|
||||
fh, ACL_TYPE_ACCESS, argp->acl_access) );
|
||||
}
|
||||
if (!nfserr) {
|
||||
nfserr = nfserrno( nfsd_set_posix_acl(
|
||||
fh, ACL_TYPE_DEFAULT, argp->acl_default) );
|
||||
inode = fh->fh_dentry->d_inode;
|
||||
if (!IS_POSIXACL(inode) || !inode->i_op->set_acl) {
|
||||
error = -EOPNOTSUPP;
|
||||
goto out_errno;
|
||||
}
|
||||
|
||||
error = fh_want_write(fh);
|
||||
if (error)
|
||||
goto out_errno;
|
||||
|
||||
error = inode->i_op->set_acl(inode, argp->acl_access, ACL_TYPE_ACCESS);
|
||||
if (error)
|
||||
goto out_drop_write;
|
||||
error = inode->i_op->set_acl(inode, argp->acl_default,
|
||||
ACL_TYPE_DEFAULT);
|
||||
|
||||
out_drop_write:
|
||||
fh_drop_write(fh);
|
||||
out_errno:
|
||||
nfserr = nfserrno(error);
|
||||
out:
|
||||
/* argp->acl_{access,default} may have been allocated in
|
||||
nfs3svc_decode_setaclargs. */
|
||||
posix_acl_release(argp->acl_access);
|
||||
|
Reference in New Issue
Block a user