diff options
author | Christoph Hellwig <hch@infradead.org> | 2013-12-20 08:16:55 -0500 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2014-01-26 08:26:41 -0500 |
commit | 4ac7249ea5a0ceef9f8269f63f33cc873c3fac61 (patch) | |
tree | f12c9d14720d981270c45b207748e215f7a3dca3 /fs/nfsd/nfs3acl.c | |
parent | feda821e76f3bbbba4bd54d30b4d4005a7848aa5 (diff) |
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>
Diffstat (limited to 'fs/nfsd/nfs3acl.c')
-rw-r--r-- | fs/nfsd/nfs3acl.c | 62 |
1 files changed, 33 insertions, 29 deletions
diff --git a/fs/nfsd/nfs3acl.c b/fs/nfsd/nfs3acl.c index 9cbc1a841f87..adc5f1b1dc26 100644 --- a/fs/nfsd/nfs3acl.c +++ b/fs/nfsd/nfs3acl.c | |||
@@ -29,8 +29,9 @@ nfsd3_proc_null(struct svc_rqst *rqstp, void *argp, void *resp) | |||
29 | static __be32 nfsd3_proc_getacl(struct svc_rqst * rqstp, | 29 | static __be32 nfsd3_proc_getacl(struct svc_rqst * rqstp, |
30 | struct nfsd3_getaclargs *argp, struct nfsd3_getaclres *resp) | 30 | struct nfsd3_getaclargs *argp, struct nfsd3_getaclres *resp) |
31 | { | 31 | { |
32 | svc_fh *fh; | ||
33 | struct posix_acl *acl; | 32 | struct posix_acl *acl; |
33 | struct inode *inode; | ||
34 | svc_fh *fh; | ||
34 | __be32 nfserr = 0; | 35 | __be32 nfserr = 0; |
35 | 36 | ||
36 | fh = fh_copy(&resp->fh, &argp->fh); | 37 | fh = fh_copy(&resp->fh, &argp->fh); |
@@ -38,26 +39,20 @@ static __be32 nfsd3_proc_getacl(struct svc_rqst * rqstp, | |||
38 | if (nfserr) | 39 | if (nfserr) |
39 | RETURN_STATUS(nfserr); | 40 | RETURN_STATUS(nfserr); |
40 | 41 | ||
42 | inode = fh->fh_dentry->d_inode; | ||
43 | |||
41 | if (argp->mask & ~(NFS_ACL|NFS_ACLCNT|NFS_DFACL|NFS_DFACLCNT)) | 44 | if (argp->mask & ~(NFS_ACL|NFS_ACLCNT|NFS_DFACL|NFS_DFACLCNT)) |
42 | RETURN_STATUS(nfserr_inval); | 45 | RETURN_STATUS(nfserr_inval); |
43 | resp->mask = argp->mask; | 46 | resp->mask = argp->mask; |
44 | 47 | ||
45 | if (resp->mask & (NFS_ACL|NFS_ACLCNT)) { | 48 | if (resp->mask & (NFS_ACL|NFS_ACLCNT)) { |
46 | acl = nfsd_get_posix_acl(fh, ACL_TYPE_ACCESS); | 49 | acl = get_acl(inode, ACL_TYPE_ACCESS); |
47 | if (IS_ERR(acl)) { | 50 | if (IS_ERR(acl)) { |
48 | int err = PTR_ERR(acl); | 51 | nfserr = nfserrno(PTR_ERR(acl)); |
49 | 52 | goto fail; | |
50 | if (err == -ENODATA || err == -EOPNOTSUPP) | ||
51 | acl = NULL; | ||
52 | else { | ||
53 | nfserr = nfserrno(err); | ||
54 | goto fail; | ||
55 | } | ||
56 | } | 53 | } |
57 | if (acl == NULL) { | 54 | if (acl == NULL) { |
58 | /* Solaris returns the inode's minimum ACL. */ | 55 | /* Solaris returns the inode's minimum ACL. */ |
59 | |||
60 | struct inode *inode = fh->fh_dentry->d_inode; | ||
61 | acl = posix_acl_from_mode(inode->i_mode, GFP_KERNEL); | 56 | acl = posix_acl_from_mode(inode->i_mode, GFP_KERNEL); |
62 | } | 57 | } |
63 | resp->acl_access = acl; | 58 | resp->acl_access = acl; |
@@ -65,17 +60,10 @@ static __be32 nfsd3_proc_getacl(struct svc_rqst * rqstp, | |||
65 | if (resp->mask & (NFS_DFACL|NFS_DFACLCNT)) { | 60 | if (resp->mask & (NFS_DFACL|NFS_DFACLCNT)) { |
66 | /* Check how Solaris handles requests for the Default ACL | 61 | /* Check how Solaris handles requests for the Default ACL |
67 | of a non-directory! */ | 62 | of a non-directory! */ |
68 | 63 | acl = get_acl(inode, ACL_TYPE_DEFAULT); | |
69 | acl = nfsd_get_posix_acl(fh, ACL_TYPE_DEFAULT); | ||
70 | if (IS_ERR(acl)) { | 64 | if (IS_ERR(acl)) { |
71 | int err = PTR_ERR(acl); | 65 | nfserr = nfserrno(PTR_ERR(acl)); |
72 | 66 | goto fail; | |
73 | if (err == -ENODATA || err == -EOPNOTSUPP) | ||
74 | acl = NULL; | ||
75 | else { | ||
76 | nfserr = nfserrno(err); | ||
77 | goto fail; | ||
78 | } | ||
79 | } | 67 | } |
80 | resp->acl_default = acl; | 68 | resp->acl_default = acl; |
81 | } | 69 | } |
@@ -96,21 +84,37 @@ static __be32 nfsd3_proc_setacl(struct svc_rqst * rqstp, | |||
96 | struct nfsd3_setaclargs *argp, | 84 | struct nfsd3_setaclargs *argp, |
97 | struct nfsd3_attrstat *resp) | 85 | struct nfsd3_attrstat *resp) |
98 | { | 86 | { |
87 | struct inode *inode; | ||
99 | svc_fh *fh; | 88 | svc_fh *fh; |
100 | __be32 nfserr = 0; | 89 | __be32 nfserr = 0; |
90 | int error; | ||
101 | 91 | ||
102 | fh = fh_copy(&resp->fh, &argp->fh); | 92 | fh = fh_copy(&resp->fh, &argp->fh); |
103 | nfserr = fh_verify(rqstp, &resp->fh, 0, NFSD_MAY_SATTR); | 93 | nfserr = fh_verify(rqstp, &resp->fh, 0, NFSD_MAY_SATTR); |
94 | if (nfserr) | ||
95 | goto out; | ||
104 | 96 | ||
105 | if (!nfserr) { | 97 | inode = fh->fh_dentry->d_inode; |
106 | nfserr = nfserrno( nfsd_set_posix_acl( | 98 | if (!IS_POSIXACL(inode) || !inode->i_op->set_acl) { |
107 | fh, ACL_TYPE_ACCESS, argp->acl_access) ); | 99 | error = -EOPNOTSUPP; |
108 | } | 100 | goto out_errno; |
109 | if (!nfserr) { | ||
110 | nfserr = nfserrno( nfsd_set_posix_acl( | ||
111 | fh, ACL_TYPE_DEFAULT, argp->acl_default) ); | ||
112 | } | 101 | } |
113 | 102 | ||
103 | error = fh_want_write(fh); | ||
104 | if (error) | ||
105 | goto out_errno; | ||
106 | |||
107 | error = inode->i_op->set_acl(inode, argp->acl_access, ACL_TYPE_ACCESS); | ||
108 | if (error) | ||
109 | goto out_drop_write; | ||
110 | error = inode->i_op->set_acl(inode, argp->acl_default, | ||
111 | ACL_TYPE_DEFAULT); | ||
112 | |||
113 | out_drop_write: | ||
114 | fh_drop_write(fh); | ||
115 | out_errno: | ||
116 | nfserr = nfserrno(error); | ||
117 | out: | ||
114 | /* argp->acl_{access,default} may have been allocated in | 118 | /* argp->acl_{access,default} may have been allocated in |
115 | nfs3svc_decode_setaclargs. */ | 119 | nfs3svc_decode_setaclargs. */ |
116 | posix_acl_release(argp->acl_access); | 120 | posix_acl_release(argp->acl_access); |