xref: /openbmc/linux/fs/nfsd/nfs2acl.c (revision 4ac7249ea5a0ceef9f8269f63f33cc873c3fac61)
1a257cdd0SAndreas Gruenbacher /*
2a257cdd0SAndreas Gruenbacher  * Process version 2 NFSACL requests.
3a257cdd0SAndreas Gruenbacher  *
4a257cdd0SAndreas Gruenbacher  * Copyright (C) 2002-2003 Andreas Gruenbacher <agruen@suse.de>
5a257cdd0SAndreas Gruenbacher  */
6a257cdd0SAndreas Gruenbacher 
79a74af21SBoaz Harrosh #include "nfsd.h"
89a74af21SBoaz Harrosh /* FIXME: nfsacl.h is a broken header */
9a257cdd0SAndreas Gruenbacher #include <linux/nfsacl.h>
105a0e3ad6STejun Heo #include <linux/gfp.h>
119a74af21SBoaz Harrosh #include "cache.h"
129a74af21SBoaz Harrosh #include "xdr3.h"
130a3adadeSJ. Bruce Fields #include "vfs.h"
14a257cdd0SAndreas Gruenbacher 
15a257cdd0SAndreas Gruenbacher #define NFSDDBG_FACILITY		NFSDDBG_PROC
16a257cdd0SAndreas Gruenbacher #define RETURN_STATUS(st)	{ resp->status = (st); return (st); }
17a257cdd0SAndreas Gruenbacher 
18a257cdd0SAndreas Gruenbacher /*
19a257cdd0SAndreas Gruenbacher  * NULL call.
20a257cdd0SAndreas Gruenbacher  */
217111c66eSAl Viro static __be32
22a257cdd0SAndreas Gruenbacher nfsacld_proc_null(struct svc_rqst *rqstp, void *argp, void *resp)
23a257cdd0SAndreas Gruenbacher {
24a257cdd0SAndreas Gruenbacher 	return nfs_ok;
25a257cdd0SAndreas Gruenbacher }
26a257cdd0SAndreas Gruenbacher 
27a257cdd0SAndreas Gruenbacher /*
28a257cdd0SAndreas Gruenbacher  * Get the Access and/or Default ACL of a file.
29a257cdd0SAndreas Gruenbacher  */
307111c66eSAl Viro static __be32 nfsacld_proc_getacl(struct svc_rqst * rqstp,
31a257cdd0SAndreas Gruenbacher 		struct nfsd3_getaclargs *argp, struct nfsd3_getaclres *resp)
32a257cdd0SAndreas Gruenbacher {
33a257cdd0SAndreas Gruenbacher 	struct posix_acl *acl;
34*4ac7249eSChristoph Hellwig 	struct inode *inode;
35*4ac7249eSChristoph Hellwig 	svc_fh *fh;
36c4d987baSAl Viro 	__be32 nfserr = 0;
37a257cdd0SAndreas Gruenbacher 
38a257cdd0SAndreas Gruenbacher 	dprintk("nfsd: GETACL(2acl)   %s\n", SVCFH_fmt(&argp->fh));
39a257cdd0SAndreas Gruenbacher 
40a257cdd0SAndreas Gruenbacher 	fh = fh_copy(&resp->fh, &argp->fh);
418837abcaSMiklos Szeredi 	nfserr = fh_verify(rqstp, &resp->fh, 0, NFSD_MAY_NOP);
428837abcaSMiklos Szeredi 	if (nfserr)
43ac8587dcSJ. Bruce Fields 		RETURN_STATUS(nfserr);
44a257cdd0SAndreas Gruenbacher 
45*4ac7249eSChristoph Hellwig 	inode = fh->fh_dentry->d_inode;
46*4ac7249eSChristoph Hellwig 
47a257cdd0SAndreas Gruenbacher 	if (argp->mask & ~(NFS_ACL|NFS_ACLCNT|NFS_DFACL|NFS_DFACLCNT))
48a257cdd0SAndreas Gruenbacher 		RETURN_STATUS(nfserr_inval);
49a257cdd0SAndreas Gruenbacher 	resp->mask = argp->mask;
50a257cdd0SAndreas Gruenbacher 
514f4a4fadSJ. Bruce Fields 	nfserr = fh_getattr(fh, &resp->stat);
524f4a4fadSJ. Bruce Fields 	if (nfserr)
534f4a4fadSJ. Bruce Fields 		goto fail;
544f4a4fadSJ. Bruce Fields 
55a257cdd0SAndreas Gruenbacher 	if (resp->mask & (NFS_ACL|NFS_ACLCNT)) {
56*4ac7249eSChristoph Hellwig 		acl = get_acl(inode, ACL_TYPE_ACCESS);
57a257cdd0SAndreas Gruenbacher 		if (IS_ERR(acl)) {
58*4ac7249eSChristoph Hellwig 			nfserr = nfserrno(PTR_ERR(acl));
59a257cdd0SAndreas Gruenbacher 			goto fail;
60a257cdd0SAndreas Gruenbacher 		}
61a257cdd0SAndreas Gruenbacher 		if (acl == NULL) {
62a257cdd0SAndreas Gruenbacher 			/* Solaris returns the inode's minimum ACL. */
63a257cdd0SAndreas Gruenbacher 			acl = posix_acl_from_mode(inode->i_mode, GFP_KERNEL);
64a257cdd0SAndreas Gruenbacher 		}
65a257cdd0SAndreas Gruenbacher 		resp->acl_access = acl;
66a257cdd0SAndreas Gruenbacher 	}
67a257cdd0SAndreas Gruenbacher 	if (resp->mask & (NFS_DFACL|NFS_DFACLCNT)) {
68a257cdd0SAndreas Gruenbacher 		/* Check how Solaris handles requests for the Default ACL
69a257cdd0SAndreas Gruenbacher 		   of a non-directory! */
70*4ac7249eSChristoph Hellwig 		acl = get_acl(inode, ACL_TYPE_DEFAULT);
71a257cdd0SAndreas Gruenbacher 		if (IS_ERR(acl)) {
72*4ac7249eSChristoph Hellwig 			nfserr = nfserrno(PTR_ERR(acl));
73a257cdd0SAndreas Gruenbacher 			goto fail;
74a257cdd0SAndreas Gruenbacher 		}
75a257cdd0SAndreas Gruenbacher 		resp->acl_default = acl;
76a257cdd0SAndreas Gruenbacher 	}
77a257cdd0SAndreas Gruenbacher 
78a257cdd0SAndreas Gruenbacher 	/* resp->acl_{access,default} are released in nfssvc_release_getacl. */
79a257cdd0SAndreas Gruenbacher 	RETURN_STATUS(0);
80a257cdd0SAndreas Gruenbacher 
81a257cdd0SAndreas Gruenbacher fail:
82a257cdd0SAndreas Gruenbacher 	posix_acl_release(resp->acl_access);
83a257cdd0SAndreas Gruenbacher 	posix_acl_release(resp->acl_default);
84a257cdd0SAndreas Gruenbacher 	RETURN_STATUS(nfserr);
85a257cdd0SAndreas Gruenbacher }
86a257cdd0SAndreas Gruenbacher 
87a257cdd0SAndreas Gruenbacher /*
88a257cdd0SAndreas Gruenbacher  * Set the Access and/or Default ACL of a file.
89a257cdd0SAndreas Gruenbacher  */
907111c66eSAl Viro static __be32 nfsacld_proc_setacl(struct svc_rqst * rqstp,
91a257cdd0SAndreas Gruenbacher 		struct nfsd3_setaclargs *argp,
92a257cdd0SAndreas Gruenbacher 		struct nfsd_attrstat *resp)
93a257cdd0SAndreas Gruenbacher {
94*4ac7249eSChristoph Hellwig 	struct inode *inode;
95a257cdd0SAndreas Gruenbacher 	svc_fh *fh;
96c4d987baSAl Viro 	__be32 nfserr = 0;
97*4ac7249eSChristoph Hellwig 	int error;
98a257cdd0SAndreas Gruenbacher 
99a257cdd0SAndreas Gruenbacher 	dprintk("nfsd: SETACL(2acl)   %s\n", SVCFH_fmt(&argp->fh));
100a257cdd0SAndreas Gruenbacher 
101a257cdd0SAndreas Gruenbacher 	fh = fh_copy(&resp->fh, &argp->fh);
1028837abcaSMiklos Szeredi 	nfserr = fh_verify(rqstp, &resp->fh, 0, NFSD_MAY_SATTR);
103*4ac7249eSChristoph Hellwig 	if (nfserr)
104*4ac7249eSChristoph Hellwig 		goto out;
105a257cdd0SAndreas Gruenbacher 
106*4ac7249eSChristoph Hellwig 	inode = fh->fh_dentry->d_inode;
107*4ac7249eSChristoph Hellwig 	if (!IS_POSIXACL(inode) || !inode->i_op->set_acl) {
108*4ac7249eSChristoph Hellwig 		error = -EOPNOTSUPP;
109*4ac7249eSChristoph Hellwig 		goto out_errno;
110a257cdd0SAndreas Gruenbacher 	}
111*4ac7249eSChristoph Hellwig 
112*4ac7249eSChristoph Hellwig 	error = fh_want_write(fh);
113*4ac7249eSChristoph Hellwig 	if (error)
114*4ac7249eSChristoph Hellwig 		goto out_errno;
115*4ac7249eSChristoph Hellwig 
116*4ac7249eSChristoph Hellwig 	error = inode->i_op->set_acl(inode, argp->acl_access, ACL_TYPE_ACCESS);
117*4ac7249eSChristoph Hellwig 	if (error)
118*4ac7249eSChristoph Hellwig 		goto out_drop_write;
119*4ac7249eSChristoph Hellwig 	error = inode->i_op->set_acl(inode, argp->acl_default,
120*4ac7249eSChristoph Hellwig 				     ACL_TYPE_DEFAULT);
121*4ac7249eSChristoph Hellwig 	if (error)
122*4ac7249eSChristoph Hellwig 		goto out_drop_write;
123*4ac7249eSChristoph Hellwig 
124*4ac7249eSChristoph Hellwig 	fh_drop_write(fh);
125*4ac7249eSChristoph Hellwig 
1264f4a4fadSJ. Bruce Fields 	nfserr = fh_getattr(fh, &resp->stat);
127a257cdd0SAndreas Gruenbacher 
128*4ac7249eSChristoph Hellwig out:
129a257cdd0SAndreas Gruenbacher 	/* argp->acl_{access,default} may have been allocated in
130a257cdd0SAndreas Gruenbacher 	   nfssvc_decode_setaclargs. */
131a257cdd0SAndreas Gruenbacher 	posix_acl_release(argp->acl_access);
132a257cdd0SAndreas Gruenbacher 	posix_acl_release(argp->acl_default);
133a257cdd0SAndreas Gruenbacher 	return nfserr;
134*4ac7249eSChristoph Hellwig out_drop_write:
135*4ac7249eSChristoph Hellwig 	fh_drop_write(fh);
136*4ac7249eSChristoph Hellwig out_errno:
137*4ac7249eSChristoph Hellwig 	nfserr = nfserrno(error);
138*4ac7249eSChristoph Hellwig 	goto out;
139a257cdd0SAndreas Gruenbacher }
140a257cdd0SAndreas Gruenbacher 
141a257cdd0SAndreas Gruenbacher /*
142a257cdd0SAndreas Gruenbacher  * Check file attributes
143a257cdd0SAndreas Gruenbacher  */
1447111c66eSAl Viro static __be32 nfsacld_proc_getattr(struct svc_rqst * rqstp,
145a257cdd0SAndreas Gruenbacher 		struct nfsd_fhandle *argp, struct nfsd_attrstat *resp)
146a257cdd0SAndreas Gruenbacher {
1474f4a4fadSJ. Bruce Fields 	__be32 nfserr;
148a257cdd0SAndreas Gruenbacher 	dprintk("nfsd: GETATTR  %s\n", SVCFH_fmt(&argp->fh));
149a257cdd0SAndreas Gruenbacher 
150a257cdd0SAndreas Gruenbacher 	fh_copy(&resp->fh, &argp->fh);
1514f4a4fadSJ. Bruce Fields 	nfserr = fh_verify(rqstp, &resp->fh, 0, NFSD_MAY_NOP);
1524f4a4fadSJ. Bruce Fields 	if (nfserr)
1534f4a4fadSJ. Bruce Fields 		return nfserr;
1544f4a4fadSJ. Bruce Fields 	nfserr = fh_getattr(&resp->fh, &resp->stat);
1554f4a4fadSJ. Bruce Fields 	return nfserr;
156a257cdd0SAndreas Gruenbacher }
157a257cdd0SAndreas Gruenbacher 
158a257cdd0SAndreas Gruenbacher /*
159a257cdd0SAndreas Gruenbacher  * Check file access
160a257cdd0SAndreas Gruenbacher  */
1617111c66eSAl Viro static __be32 nfsacld_proc_access(struct svc_rqst *rqstp, struct nfsd3_accessargs *argp,
162a257cdd0SAndreas Gruenbacher 		struct nfsd3_accessres *resp)
163a257cdd0SAndreas Gruenbacher {
164c4d987baSAl Viro 	__be32 nfserr;
165a257cdd0SAndreas Gruenbacher 
166a257cdd0SAndreas Gruenbacher 	dprintk("nfsd: ACCESS(2acl)   %s 0x%x\n",
167a257cdd0SAndreas Gruenbacher 			SVCFH_fmt(&argp->fh),
168a257cdd0SAndreas Gruenbacher 			argp->access);
169a257cdd0SAndreas Gruenbacher 
170a257cdd0SAndreas Gruenbacher 	fh_copy(&resp->fh, &argp->fh);
171a257cdd0SAndreas Gruenbacher 	resp->access = argp->access;
172a257cdd0SAndreas Gruenbacher 	nfserr = nfsd_access(rqstp, &resp->fh, &resp->access, NULL);
1734f4a4fadSJ. Bruce Fields 	if (nfserr)
1744f4a4fadSJ. Bruce Fields 		return nfserr;
1754f4a4fadSJ. Bruce Fields 	nfserr = fh_getattr(&resp->fh, &resp->stat);
176a257cdd0SAndreas Gruenbacher 	return nfserr;
177a257cdd0SAndreas Gruenbacher }
178a257cdd0SAndreas Gruenbacher 
179a257cdd0SAndreas Gruenbacher /*
180a257cdd0SAndreas Gruenbacher  * XDR decode functions
181a257cdd0SAndreas Gruenbacher  */
182131a21c2SAl Viro static int nfsaclsvc_decode_getaclargs(struct svc_rqst *rqstp, __be32 *p,
183a257cdd0SAndreas Gruenbacher 		struct nfsd3_getaclargs *argp)
184a257cdd0SAndreas Gruenbacher {
185a257cdd0SAndreas Gruenbacher 	if (!(p = nfs2svc_decode_fh(p, &argp->fh)))
186a257cdd0SAndreas Gruenbacher 		return 0;
187a257cdd0SAndreas Gruenbacher 	argp->mask = ntohl(*p); p++;
188a257cdd0SAndreas Gruenbacher 
189a257cdd0SAndreas Gruenbacher 	return xdr_argsize_check(rqstp, p);
190a257cdd0SAndreas Gruenbacher }
191a257cdd0SAndreas Gruenbacher 
192a257cdd0SAndreas Gruenbacher 
193131a21c2SAl Viro static int nfsaclsvc_decode_setaclargs(struct svc_rqst *rqstp, __be32 *p,
194a257cdd0SAndreas Gruenbacher 		struct nfsd3_setaclargs *argp)
195a257cdd0SAndreas Gruenbacher {
196a257cdd0SAndreas Gruenbacher 	struct kvec *head = rqstp->rq_arg.head;
197a257cdd0SAndreas Gruenbacher 	unsigned int base;
198a257cdd0SAndreas Gruenbacher 	int n;
199a257cdd0SAndreas Gruenbacher 
200a257cdd0SAndreas Gruenbacher 	if (!(p = nfs2svc_decode_fh(p, &argp->fh)))
201a257cdd0SAndreas Gruenbacher 		return 0;
202a257cdd0SAndreas Gruenbacher 	argp->mask = ntohl(*p++);
203a257cdd0SAndreas Gruenbacher 	if (argp->mask & ~(NFS_ACL|NFS_ACLCNT|NFS_DFACL|NFS_DFACLCNT) ||
204a257cdd0SAndreas Gruenbacher 	    !xdr_argsize_check(rqstp, p))
205a257cdd0SAndreas Gruenbacher 		return 0;
206a257cdd0SAndreas Gruenbacher 
207a257cdd0SAndreas Gruenbacher 	base = (char *)p - (char *)head->iov_base;
208a257cdd0SAndreas Gruenbacher 	n = nfsacl_decode(&rqstp->rq_arg, base, NULL,
209a257cdd0SAndreas Gruenbacher 			  (argp->mask & NFS_ACL) ?
210a257cdd0SAndreas Gruenbacher 			  &argp->acl_access : NULL);
211a257cdd0SAndreas Gruenbacher 	if (n > 0)
212a257cdd0SAndreas Gruenbacher 		n = nfsacl_decode(&rqstp->rq_arg, base + n, NULL,
213a257cdd0SAndreas Gruenbacher 				  (argp->mask & NFS_DFACL) ?
214a257cdd0SAndreas Gruenbacher 				  &argp->acl_default : NULL);
215a257cdd0SAndreas Gruenbacher 	return (n > 0);
216a257cdd0SAndreas Gruenbacher }
217a257cdd0SAndreas Gruenbacher 
218131a21c2SAl Viro static int nfsaclsvc_decode_fhandleargs(struct svc_rqst *rqstp, __be32 *p,
219a257cdd0SAndreas Gruenbacher 		struct nfsd_fhandle *argp)
220a257cdd0SAndreas Gruenbacher {
221a257cdd0SAndreas Gruenbacher 	if (!(p = nfs2svc_decode_fh(p, &argp->fh)))
222a257cdd0SAndreas Gruenbacher 		return 0;
223a257cdd0SAndreas Gruenbacher 	return xdr_argsize_check(rqstp, p);
224a257cdd0SAndreas Gruenbacher }
225a257cdd0SAndreas Gruenbacher 
226131a21c2SAl Viro static int nfsaclsvc_decode_accessargs(struct svc_rqst *rqstp, __be32 *p,
227a257cdd0SAndreas Gruenbacher 		struct nfsd3_accessargs *argp)
228a257cdd0SAndreas Gruenbacher {
229a257cdd0SAndreas Gruenbacher 	if (!(p = nfs2svc_decode_fh(p, &argp->fh)))
230a257cdd0SAndreas Gruenbacher 		return 0;
231a257cdd0SAndreas Gruenbacher 	argp->access = ntohl(*p++);
232a257cdd0SAndreas Gruenbacher 
233a257cdd0SAndreas Gruenbacher 	return xdr_argsize_check(rqstp, p);
234a257cdd0SAndreas Gruenbacher }
235a257cdd0SAndreas Gruenbacher 
236a257cdd0SAndreas Gruenbacher /*
237a257cdd0SAndreas Gruenbacher  * XDR encode functions
238a257cdd0SAndreas Gruenbacher  */
239a257cdd0SAndreas Gruenbacher 
2401b7e0403SPeter Staubach /*
2411b7e0403SPeter Staubach  * There must be an encoding function for void results so svc_process
2421b7e0403SPeter Staubach  * will work properly.
2431b7e0403SPeter Staubach  */
2449c0b0ff7SJ. Bruce Fields static int nfsaclsvc_encode_voidres(struct svc_rqst *rqstp, __be32 *p, void *dummy)
2451b7e0403SPeter Staubach {
2461b7e0403SPeter Staubach 	return xdr_ressize_check(rqstp, p);
2471b7e0403SPeter Staubach }
2481b7e0403SPeter Staubach 
249a257cdd0SAndreas Gruenbacher /* GETACL */
250131a21c2SAl Viro static int nfsaclsvc_encode_getaclres(struct svc_rqst *rqstp, __be32 *p,
251a257cdd0SAndreas Gruenbacher 		struct nfsd3_getaclres *resp)
252a257cdd0SAndreas Gruenbacher {
253a257cdd0SAndreas Gruenbacher 	struct dentry *dentry = resp->fh.fh_dentry;
254aefa89d1SPrasad P 	struct inode *inode;
255a257cdd0SAndreas Gruenbacher 	struct kvec *head = rqstp->rq_res.head;
256a257cdd0SAndreas Gruenbacher 	unsigned int base;
257a257cdd0SAndreas Gruenbacher 	int n;
258cb65a5baSJesper Juhl 	int w;
259a257cdd0SAndreas Gruenbacher 
260aefa89d1SPrasad P 	/*
261aefa89d1SPrasad P 	 * Since this is version 2, the check for nfserr in
262aefa89d1SPrasad P 	 * nfsd_dispatch actually ensures the following cannot happen.
263aefa89d1SPrasad P 	 * However, it seems fragile to depend on that.
264aefa89d1SPrasad P 	 */
265a257cdd0SAndreas Gruenbacher 	if (dentry == NULL || dentry->d_inode == NULL)
266a257cdd0SAndreas Gruenbacher 		return 0;
267a257cdd0SAndreas Gruenbacher 	inode = dentry->d_inode;
268a257cdd0SAndreas Gruenbacher 
2694f4a4fadSJ. Bruce Fields 	p = nfs2svc_encode_fattr(rqstp, p, &resp->fh, &resp->stat);
270a257cdd0SAndreas Gruenbacher 	*p++ = htonl(resp->mask);
271a257cdd0SAndreas Gruenbacher 	if (!xdr_ressize_check(rqstp, p))
272a257cdd0SAndreas Gruenbacher 		return 0;
273a257cdd0SAndreas Gruenbacher 	base = (char *)p - (char *)head->iov_base;
274a257cdd0SAndreas Gruenbacher 
275cb65a5baSJesper Juhl 	rqstp->rq_res.page_len = w = nfsacl_size(
276cb65a5baSJesper Juhl 		(resp->mask & NFS_ACL)   ? resp->acl_access  : NULL,
277cb65a5baSJesper Juhl 		(resp->mask & NFS_DFACL) ? resp->acl_default : NULL);
278a257cdd0SAndreas Gruenbacher 	while (w > 0) {
279afc59400SJ. Bruce Fields 		if (!*(rqstp->rq_next_page++))
280a257cdd0SAndreas Gruenbacher 			return 0;
281a257cdd0SAndreas Gruenbacher 		w -= PAGE_SIZE;
282a257cdd0SAndreas Gruenbacher 	}
283a257cdd0SAndreas Gruenbacher 
284a257cdd0SAndreas Gruenbacher 	n = nfsacl_encode(&rqstp->rq_res, base, inode,
285a257cdd0SAndreas Gruenbacher 			  resp->acl_access,
286a257cdd0SAndreas Gruenbacher 			  resp->mask & NFS_ACL, 0);
287a257cdd0SAndreas Gruenbacher 	if (n > 0)
288a257cdd0SAndreas Gruenbacher 		n = nfsacl_encode(&rqstp->rq_res, base + n, inode,
289a257cdd0SAndreas Gruenbacher 				  resp->acl_default,
290a257cdd0SAndreas Gruenbacher 				  resp->mask & NFS_DFACL,
291a257cdd0SAndreas Gruenbacher 				  NFS_ACL_DEFAULT);
292a257cdd0SAndreas Gruenbacher 	if (n <= 0)
293a257cdd0SAndreas Gruenbacher 		return 0;
294a257cdd0SAndreas Gruenbacher 	return 1;
295a257cdd0SAndreas Gruenbacher }
296a257cdd0SAndreas Gruenbacher 
297131a21c2SAl Viro static int nfsaclsvc_encode_attrstatres(struct svc_rqst *rqstp, __be32 *p,
298a257cdd0SAndreas Gruenbacher 		struct nfsd_attrstat *resp)
299a257cdd0SAndreas Gruenbacher {
3004f4a4fadSJ. Bruce Fields 	p = nfs2svc_encode_fattr(rqstp, p, &resp->fh, &resp->stat);
301a257cdd0SAndreas Gruenbacher 	return xdr_ressize_check(rqstp, p);
302a257cdd0SAndreas Gruenbacher }
303a257cdd0SAndreas Gruenbacher 
304a257cdd0SAndreas Gruenbacher /* ACCESS */
305131a21c2SAl Viro static int nfsaclsvc_encode_accessres(struct svc_rqst *rqstp, __be32 *p,
306a257cdd0SAndreas Gruenbacher 		struct nfsd3_accessres *resp)
307a257cdd0SAndreas Gruenbacher {
3084f4a4fadSJ. Bruce Fields 	p = nfs2svc_encode_fattr(rqstp, p, &resp->fh, &resp->stat);
309a257cdd0SAndreas Gruenbacher 	*p++ = htonl(resp->access);
310a257cdd0SAndreas Gruenbacher 	return xdr_ressize_check(rqstp, p);
311a257cdd0SAndreas Gruenbacher }
312a257cdd0SAndreas Gruenbacher 
313a257cdd0SAndreas Gruenbacher /*
314a257cdd0SAndreas Gruenbacher  * XDR release functions
315a257cdd0SAndreas Gruenbacher  */
316131a21c2SAl Viro static int nfsaclsvc_release_getacl(struct svc_rqst *rqstp, __be32 *p,
317a257cdd0SAndreas Gruenbacher 		struct nfsd3_getaclres *resp)
318a257cdd0SAndreas Gruenbacher {
319a257cdd0SAndreas Gruenbacher 	fh_put(&resp->fh);
320a257cdd0SAndreas Gruenbacher 	posix_acl_release(resp->acl_access);
321a257cdd0SAndreas Gruenbacher 	posix_acl_release(resp->acl_default);
322a257cdd0SAndreas Gruenbacher 	return 1;
323a257cdd0SAndreas Gruenbacher }
324a257cdd0SAndreas Gruenbacher 
325c9ce2283SGreg Banks static int nfsaclsvc_release_attrstat(struct svc_rqst *rqstp, __be32 *p,
326c9ce2283SGreg Banks 		struct nfsd_attrstat *resp)
327c9ce2283SGreg Banks {
328c9ce2283SGreg Banks 	fh_put(&resp->fh);
329c9ce2283SGreg Banks 	return 1;
330c9ce2283SGreg Banks }
331c9ce2283SGreg Banks 
332c9ce2283SGreg Banks static int nfsaclsvc_release_access(struct svc_rqst *rqstp, __be32 *p,
333c9ce2283SGreg Banks                struct nfsd3_accessres *resp)
334a257cdd0SAndreas Gruenbacher {
335a257cdd0SAndreas Gruenbacher        fh_put(&resp->fh);
336a257cdd0SAndreas Gruenbacher        return 1;
337a257cdd0SAndreas Gruenbacher }
338a257cdd0SAndreas Gruenbacher 
339a257cdd0SAndreas Gruenbacher #define nfsaclsvc_decode_voidargs	NULL
340a257cdd0SAndreas Gruenbacher #define nfsaclsvc_release_void		NULL
341a257cdd0SAndreas Gruenbacher #define nfsd3_fhandleargs	nfsd_fhandle
342a257cdd0SAndreas Gruenbacher #define nfsd3_attrstatres	nfsd_attrstat
343a257cdd0SAndreas Gruenbacher #define nfsd3_voidres		nfsd3_voidargs
344a257cdd0SAndreas Gruenbacher struct nfsd3_voidargs { int dummy; };
345a257cdd0SAndreas Gruenbacher 
346a257cdd0SAndreas Gruenbacher #define PROC(name, argt, rest, relt, cache, respsize)	\
347a257cdd0SAndreas Gruenbacher  { (svc_procfunc) nfsacld_proc_##name,		\
348a257cdd0SAndreas Gruenbacher    (kxdrproc_t) nfsaclsvc_decode_##argt##args,	\
349a257cdd0SAndreas Gruenbacher    (kxdrproc_t) nfsaclsvc_encode_##rest##res,	\
350a257cdd0SAndreas Gruenbacher    (kxdrproc_t) nfsaclsvc_release_##relt,		\
351a257cdd0SAndreas Gruenbacher    sizeof(struct nfsd3_##argt##args),		\
352a257cdd0SAndreas Gruenbacher    sizeof(struct nfsd3_##rest##res),		\
353a257cdd0SAndreas Gruenbacher    0,						\
354a257cdd0SAndreas Gruenbacher    cache,					\
355a257cdd0SAndreas Gruenbacher    respsize,					\
356a257cdd0SAndreas Gruenbacher  }
357a257cdd0SAndreas Gruenbacher 
358a257cdd0SAndreas Gruenbacher #define ST 1		/* status*/
359a257cdd0SAndreas Gruenbacher #define AT 21		/* attributes */
360a257cdd0SAndreas Gruenbacher #define pAT (1+AT)	/* post attributes - conditional */
361a257cdd0SAndreas Gruenbacher #define ACL (1+NFS_ACL_MAX_ENTRIES*3)  /* Access Control List */
362a257cdd0SAndreas Gruenbacher 
363a257cdd0SAndreas Gruenbacher static struct svc_procedure		nfsd_acl_procedures2[] = {
364a257cdd0SAndreas Gruenbacher   PROC(null,	void,		void,		void,	  RC_NOCACHE, ST),
365a257cdd0SAndreas Gruenbacher   PROC(getacl,	getacl,		getacl,		getacl,	  RC_NOCACHE, ST+1+2*(1+ACL)),
366c9ce2283SGreg Banks   PROC(setacl,	setacl,		attrstat,	attrstat, RC_NOCACHE, ST+AT),
367c9ce2283SGreg Banks   PROC(getattr, fhandle,	attrstat,	attrstat, RC_NOCACHE, ST+AT),
368c9ce2283SGreg Banks   PROC(access,	access,		access,		access,   RC_NOCACHE, ST+AT+1),
369a257cdd0SAndreas Gruenbacher };
370a257cdd0SAndreas Gruenbacher 
371a257cdd0SAndreas Gruenbacher struct svc_version	nfsd_acl_version2 = {
372a257cdd0SAndreas Gruenbacher 		.vs_vers	= 2,
373a257cdd0SAndreas Gruenbacher 		.vs_nproc	= 5,
374a257cdd0SAndreas Gruenbacher 		.vs_proc	= nfsd_acl_procedures2,
375a257cdd0SAndreas Gruenbacher 		.vs_dispatch	= nfsd_dispatch,
376a257cdd0SAndreas Gruenbacher 		.vs_xdrsize	= NFS3_SVC_XDRSIZE,
3771b7e0403SPeter Staubach 		.vs_hidden	= 0,
378a257cdd0SAndreas Gruenbacher };
379