xref: /openbmc/linux/fs/nfsd/nfs2acl.c (revision 0a3adadee42f2865bb867b8c5f4955b7def9baad)
1a257cdd0SAndreas Gruenbacher /*
2f30c2269SUwe Zeisberger  * linux/fs/nfsd/nfs2acl.c
3a257cdd0SAndreas Gruenbacher  *
4a257cdd0SAndreas Gruenbacher  * Process version 2 NFSACL requests.
5a257cdd0SAndreas Gruenbacher  *
6a257cdd0SAndreas Gruenbacher  * Copyright (C) 2002-2003 Andreas Gruenbacher <agruen@suse.de>
7a257cdd0SAndreas Gruenbacher  */
8a257cdd0SAndreas Gruenbacher 
9a257cdd0SAndreas Gruenbacher #include <linux/sunrpc/svc.h>
10a257cdd0SAndreas Gruenbacher #include <linux/nfs.h>
11a257cdd0SAndreas Gruenbacher #include <linux/nfsd/nfsd.h>
12a257cdd0SAndreas Gruenbacher #include <linux/nfsd/cache.h>
13a257cdd0SAndreas Gruenbacher #include <linux/nfsd/xdr.h>
14a257cdd0SAndreas Gruenbacher #include <linux/nfsd/xdr3.h>
15a257cdd0SAndreas Gruenbacher #include <linux/posix_acl.h>
16a257cdd0SAndreas Gruenbacher #include <linux/nfsacl.h>
17*0a3adadeSJ. Bruce Fields #include "vfs.h"
18a257cdd0SAndreas Gruenbacher 
19a257cdd0SAndreas Gruenbacher #define NFSDDBG_FACILITY		NFSDDBG_PROC
20a257cdd0SAndreas Gruenbacher #define RETURN_STATUS(st)	{ resp->status = (st); return (st); }
21a257cdd0SAndreas Gruenbacher 
22a257cdd0SAndreas Gruenbacher /*
23a257cdd0SAndreas Gruenbacher  * NULL call.
24a257cdd0SAndreas Gruenbacher  */
257111c66eSAl Viro static __be32
26a257cdd0SAndreas Gruenbacher nfsacld_proc_null(struct svc_rqst *rqstp, void *argp, void *resp)
27a257cdd0SAndreas Gruenbacher {
28a257cdd0SAndreas Gruenbacher 	return nfs_ok;
29a257cdd0SAndreas Gruenbacher }
30a257cdd0SAndreas Gruenbacher 
31a257cdd0SAndreas Gruenbacher /*
32a257cdd0SAndreas Gruenbacher  * Get the Access and/or Default ACL of a file.
33a257cdd0SAndreas Gruenbacher  */
347111c66eSAl Viro static __be32 nfsacld_proc_getacl(struct svc_rqst * rqstp,
35a257cdd0SAndreas Gruenbacher 		struct nfsd3_getaclargs *argp, struct nfsd3_getaclres *resp)
36a257cdd0SAndreas Gruenbacher {
37a257cdd0SAndreas Gruenbacher 	svc_fh *fh;
38a257cdd0SAndreas Gruenbacher 	struct posix_acl *acl;
39c4d987baSAl Viro 	__be32 nfserr = 0;
40a257cdd0SAndreas Gruenbacher 
41a257cdd0SAndreas Gruenbacher 	dprintk("nfsd: GETACL(2acl)   %s\n", SVCFH_fmt(&argp->fh));
42a257cdd0SAndreas Gruenbacher 
43a257cdd0SAndreas Gruenbacher 	fh = fh_copy(&resp->fh, &argp->fh);
448837abcaSMiklos Szeredi 	nfserr = fh_verify(rqstp, &resp->fh, 0, NFSD_MAY_NOP);
458837abcaSMiklos Szeredi 	if (nfserr)
46ac8587dcSJ. Bruce Fields 		RETURN_STATUS(nfserr);
47a257cdd0SAndreas Gruenbacher 
48a257cdd0SAndreas Gruenbacher 	if (argp->mask & ~(NFS_ACL|NFS_ACLCNT|NFS_DFACL|NFS_DFACLCNT))
49a257cdd0SAndreas Gruenbacher 		RETURN_STATUS(nfserr_inval);
50a257cdd0SAndreas Gruenbacher 	resp->mask = argp->mask;
51a257cdd0SAndreas Gruenbacher 
52a257cdd0SAndreas Gruenbacher 	if (resp->mask & (NFS_ACL|NFS_ACLCNT)) {
53a257cdd0SAndreas Gruenbacher 		acl = nfsd_get_posix_acl(fh, ACL_TYPE_ACCESS);
54a257cdd0SAndreas Gruenbacher 		if (IS_ERR(acl)) {
55a257cdd0SAndreas Gruenbacher 			int err = PTR_ERR(acl);
56a257cdd0SAndreas Gruenbacher 
57a257cdd0SAndreas Gruenbacher 			if (err == -ENODATA || err == -EOPNOTSUPP)
58a257cdd0SAndreas Gruenbacher 				acl = NULL;
59a257cdd0SAndreas Gruenbacher 			else {
60a257cdd0SAndreas Gruenbacher 				nfserr = nfserrno(err);
61a257cdd0SAndreas Gruenbacher 				goto fail;
62a257cdd0SAndreas Gruenbacher 			}
63a257cdd0SAndreas Gruenbacher 		}
64a257cdd0SAndreas Gruenbacher 		if (acl == NULL) {
65a257cdd0SAndreas Gruenbacher 			/* Solaris returns the inode's minimum ACL. */
66a257cdd0SAndreas Gruenbacher 
67a257cdd0SAndreas Gruenbacher 			struct inode *inode = fh->fh_dentry->d_inode;
68a257cdd0SAndreas Gruenbacher 			acl = posix_acl_from_mode(inode->i_mode, GFP_KERNEL);
69a257cdd0SAndreas Gruenbacher 		}
70a257cdd0SAndreas Gruenbacher 		resp->acl_access = acl;
71a257cdd0SAndreas Gruenbacher 	}
72a257cdd0SAndreas Gruenbacher 	if (resp->mask & (NFS_DFACL|NFS_DFACLCNT)) {
73a257cdd0SAndreas Gruenbacher 		/* Check how Solaris handles requests for the Default ACL
74a257cdd0SAndreas Gruenbacher 		   of a non-directory! */
75a257cdd0SAndreas Gruenbacher 
76a257cdd0SAndreas Gruenbacher 		acl = nfsd_get_posix_acl(fh, ACL_TYPE_DEFAULT);
77a257cdd0SAndreas Gruenbacher 		if (IS_ERR(acl)) {
78a257cdd0SAndreas Gruenbacher 			int err = PTR_ERR(acl);
79a257cdd0SAndreas Gruenbacher 
80a257cdd0SAndreas Gruenbacher 			if (err == -ENODATA || err == -EOPNOTSUPP)
81a257cdd0SAndreas Gruenbacher 				acl = NULL;
82a257cdd0SAndreas Gruenbacher 			else {
83a257cdd0SAndreas Gruenbacher 				nfserr = nfserrno(err);
84a257cdd0SAndreas Gruenbacher 				goto fail;
85a257cdd0SAndreas Gruenbacher 			}
86a257cdd0SAndreas Gruenbacher 		}
87a257cdd0SAndreas Gruenbacher 		resp->acl_default = acl;
88a257cdd0SAndreas Gruenbacher 	}
89a257cdd0SAndreas Gruenbacher 
90a257cdd0SAndreas Gruenbacher 	/* resp->acl_{access,default} are released in nfssvc_release_getacl. */
91a257cdd0SAndreas Gruenbacher 	RETURN_STATUS(0);
92a257cdd0SAndreas Gruenbacher 
93a257cdd0SAndreas Gruenbacher fail:
94a257cdd0SAndreas Gruenbacher 	posix_acl_release(resp->acl_access);
95a257cdd0SAndreas Gruenbacher 	posix_acl_release(resp->acl_default);
96a257cdd0SAndreas Gruenbacher 	RETURN_STATUS(nfserr);
97a257cdd0SAndreas Gruenbacher }
98a257cdd0SAndreas Gruenbacher 
99a257cdd0SAndreas Gruenbacher /*
100a257cdd0SAndreas Gruenbacher  * Set the Access and/or Default ACL of a file.
101a257cdd0SAndreas Gruenbacher  */
1027111c66eSAl Viro static __be32 nfsacld_proc_setacl(struct svc_rqst * rqstp,
103a257cdd0SAndreas Gruenbacher 		struct nfsd3_setaclargs *argp,
104a257cdd0SAndreas Gruenbacher 		struct nfsd_attrstat *resp)
105a257cdd0SAndreas Gruenbacher {
106a257cdd0SAndreas Gruenbacher 	svc_fh *fh;
107c4d987baSAl Viro 	__be32 nfserr = 0;
108a257cdd0SAndreas Gruenbacher 
109a257cdd0SAndreas Gruenbacher 	dprintk("nfsd: SETACL(2acl)   %s\n", SVCFH_fmt(&argp->fh));
110a257cdd0SAndreas Gruenbacher 
111a257cdd0SAndreas Gruenbacher 	fh = fh_copy(&resp->fh, &argp->fh);
1128837abcaSMiklos Szeredi 	nfserr = fh_verify(rqstp, &resp->fh, 0, NFSD_MAY_SATTR);
113a257cdd0SAndreas Gruenbacher 
114a257cdd0SAndreas Gruenbacher 	if (!nfserr) {
115a257cdd0SAndreas Gruenbacher 		nfserr = nfserrno( nfsd_set_posix_acl(
116a257cdd0SAndreas Gruenbacher 			fh, ACL_TYPE_ACCESS, argp->acl_access) );
117a257cdd0SAndreas Gruenbacher 	}
118a257cdd0SAndreas Gruenbacher 	if (!nfserr) {
119a257cdd0SAndreas Gruenbacher 		nfserr = nfserrno( nfsd_set_posix_acl(
120a257cdd0SAndreas Gruenbacher 			fh, ACL_TYPE_DEFAULT, argp->acl_default) );
121a257cdd0SAndreas Gruenbacher 	}
122a257cdd0SAndreas Gruenbacher 
123a257cdd0SAndreas Gruenbacher 	/* argp->acl_{access,default} may have been allocated in
124a257cdd0SAndreas Gruenbacher 	   nfssvc_decode_setaclargs. */
125a257cdd0SAndreas Gruenbacher 	posix_acl_release(argp->acl_access);
126a257cdd0SAndreas Gruenbacher 	posix_acl_release(argp->acl_default);
127a257cdd0SAndreas Gruenbacher 	return nfserr;
128a257cdd0SAndreas Gruenbacher }
129a257cdd0SAndreas Gruenbacher 
130a257cdd0SAndreas Gruenbacher /*
131a257cdd0SAndreas Gruenbacher  * Check file attributes
132a257cdd0SAndreas Gruenbacher  */
1337111c66eSAl Viro static __be32 nfsacld_proc_getattr(struct svc_rqst * rqstp,
134a257cdd0SAndreas Gruenbacher 		struct nfsd_fhandle *argp, struct nfsd_attrstat *resp)
135a257cdd0SAndreas Gruenbacher {
136a257cdd0SAndreas Gruenbacher 	dprintk("nfsd: GETATTR  %s\n", SVCFH_fmt(&argp->fh));
137a257cdd0SAndreas Gruenbacher 
138a257cdd0SAndreas Gruenbacher 	fh_copy(&resp->fh, &argp->fh);
1398837abcaSMiklos Szeredi 	return fh_verify(rqstp, &resp->fh, 0, NFSD_MAY_NOP);
140a257cdd0SAndreas Gruenbacher }
141a257cdd0SAndreas Gruenbacher 
142a257cdd0SAndreas Gruenbacher /*
143a257cdd0SAndreas Gruenbacher  * Check file access
144a257cdd0SAndreas Gruenbacher  */
1457111c66eSAl Viro static __be32 nfsacld_proc_access(struct svc_rqst *rqstp, struct nfsd3_accessargs *argp,
146a257cdd0SAndreas Gruenbacher 		struct nfsd3_accessres *resp)
147a257cdd0SAndreas Gruenbacher {
148c4d987baSAl Viro 	__be32 nfserr;
149a257cdd0SAndreas Gruenbacher 
150a257cdd0SAndreas Gruenbacher 	dprintk("nfsd: ACCESS(2acl)   %s 0x%x\n",
151a257cdd0SAndreas Gruenbacher 			SVCFH_fmt(&argp->fh),
152a257cdd0SAndreas Gruenbacher 			argp->access);
153a257cdd0SAndreas Gruenbacher 
154a257cdd0SAndreas Gruenbacher 	fh_copy(&resp->fh, &argp->fh);
155a257cdd0SAndreas Gruenbacher 	resp->access = argp->access;
156a257cdd0SAndreas Gruenbacher 	nfserr = nfsd_access(rqstp, &resp->fh, &resp->access, NULL);
157a257cdd0SAndreas Gruenbacher 	return nfserr;
158a257cdd0SAndreas Gruenbacher }
159a257cdd0SAndreas Gruenbacher 
160a257cdd0SAndreas Gruenbacher /*
161a257cdd0SAndreas Gruenbacher  * XDR decode functions
162a257cdd0SAndreas Gruenbacher  */
163131a21c2SAl Viro static int nfsaclsvc_decode_getaclargs(struct svc_rqst *rqstp, __be32 *p,
164a257cdd0SAndreas Gruenbacher 		struct nfsd3_getaclargs *argp)
165a257cdd0SAndreas Gruenbacher {
166a257cdd0SAndreas Gruenbacher 	if (!(p = nfs2svc_decode_fh(p, &argp->fh)))
167a257cdd0SAndreas Gruenbacher 		return 0;
168a257cdd0SAndreas Gruenbacher 	argp->mask = ntohl(*p); p++;
169a257cdd0SAndreas Gruenbacher 
170a257cdd0SAndreas Gruenbacher 	return xdr_argsize_check(rqstp, p);
171a257cdd0SAndreas Gruenbacher }
172a257cdd0SAndreas Gruenbacher 
173a257cdd0SAndreas Gruenbacher 
174131a21c2SAl Viro static int nfsaclsvc_decode_setaclargs(struct svc_rqst *rqstp, __be32 *p,
175a257cdd0SAndreas Gruenbacher 		struct nfsd3_setaclargs *argp)
176a257cdd0SAndreas Gruenbacher {
177a257cdd0SAndreas Gruenbacher 	struct kvec *head = rqstp->rq_arg.head;
178a257cdd0SAndreas Gruenbacher 	unsigned int base;
179a257cdd0SAndreas Gruenbacher 	int n;
180a257cdd0SAndreas Gruenbacher 
181a257cdd0SAndreas Gruenbacher 	if (!(p = nfs2svc_decode_fh(p, &argp->fh)))
182a257cdd0SAndreas Gruenbacher 		return 0;
183a257cdd0SAndreas Gruenbacher 	argp->mask = ntohl(*p++);
184a257cdd0SAndreas Gruenbacher 	if (argp->mask & ~(NFS_ACL|NFS_ACLCNT|NFS_DFACL|NFS_DFACLCNT) ||
185a257cdd0SAndreas Gruenbacher 	    !xdr_argsize_check(rqstp, p))
186a257cdd0SAndreas Gruenbacher 		return 0;
187a257cdd0SAndreas Gruenbacher 
188a257cdd0SAndreas Gruenbacher 	base = (char *)p - (char *)head->iov_base;
189a257cdd0SAndreas Gruenbacher 	n = nfsacl_decode(&rqstp->rq_arg, base, NULL,
190a257cdd0SAndreas Gruenbacher 			  (argp->mask & NFS_ACL) ?
191a257cdd0SAndreas Gruenbacher 			  &argp->acl_access : NULL);
192a257cdd0SAndreas Gruenbacher 	if (n > 0)
193a257cdd0SAndreas Gruenbacher 		n = nfsacl_decode(&rqstp->rq_arg, base + n, NULL,
194a257cdd0SAndreas Gruenbacher 				  (argp->mask & NFS_DFACL) ?
195a257cdd0SAndreas Gruenbacher 				  &argp->acl_default : NULL);
196a257cdd0SAndreas Gruenbacher 	return (n > 0);
197a257cdd0SAndreas Gruenbacher }
198a257cdd0SAndreas Gruenbacher 
199131a21c2SAl Viro static int nfsaclsvc_decode_fhandleargs(struct svc_rqst *rqstp, __be32 *p,
200a257cdd0SAndreas Gruenbacher 		struct nfsd_fhandle *argp)
201a257cdd0SAndreas Gruenbacher {
202a257cdd0SAndreas Gruenbacher 	if (!(p = nfs2svc_decode_fh(p, &argp->fh)))
203a257cdd0SAndreas Gruenbacher 		return 0;
204a257cdd0SAndreas Gruenbacher 	return xdr_argsize_check(rqstp, p);
205a257cdd0SAndreas Gruenbacher }
206a257cdd0SAndreas Gruenbacher 
207131a21c2SAl Viro static int nfsaclsvc_decode_accessargs(struct svc_rqst *rqstp, __be32 *p,
208a257cdd0SAndreas Gruenbacher 		struct nfsd3_accessargs *argp)
209a257cdd0SAndreas Gruenbacher {
210a257cdd0SAndreas Gruenbacher 	if (!(p = nfs2svc_decode_fh(p, &argp->fh)))
211a257cdd0SAndreas Gruenbacher 		return 0;
212a257cdd0SAndreas Gruenbacher 	argp->access = ntohl(*p++);
213a257cdd0SAndreas Gruenbacher 
214a257cdd0SAndreas Gruenbacher 	return xdr_argsize_check(rqstp, p);
215a257cdd0SAndreas Gruenbacher }
216a257cdd0SAndreas Gruenbacher 
217a257cdd0SAndreas Gruenbacher /*
218a257cdd0SAndreas Gruenbacher  * XDR encode functions
219a257cdd0SAndreas Gruenbacher  */
220a257cdd0SAndreas Gruenbacher 
2211b7e0403SPeter Staubach /*
2221b7e0403SPeter Staubach  * There must be an encoding function for void results so svc_process
2231b7e0403SPeter Staubach  * will work properly.
2241b7e0403SPeter Staubach  */
2251b7e0403SPeter Staubach int
2261b7e0403SPeter Staubach nfsaclsvc_encode_voidres(struct svc_rqst *rqstp, __be32 *p, void *dummy)
2271b7e0403SPeter Staubach {
2281b7e0403SPeter Staubach 	return xdr_ressize_check(rqstp, p);
2291b7e0403SPeter Staubach }
2301b7e0403SPeter Staubach 
231a257cdd0SAndreas Gruenbacher /* GETACL */
232131a21c2SAl Viro static int nfsaclsvc_encode_getaclres(struct svc_rqst *rqstp, __be32 *p,
233a257cdd0SAndreas Gruenbacher 		struct nfsd3_getaclres *resp)
234a257cdd0SAndreas Gruenbacher {
235a257cdd0SAndreas Gruenbacher 	struct dentry *dentry = resp->fh.fh_dentry;
236aefa89d1SPrasad P 	struct inode *inode;
237a257cdd0SAndreas Gruenbacher 	struct kvec *head = rqstp->rq_res.head;
238a257cdd0SAndreas Gruenbacher 	unsigned int base;
239a257cdd0SAndreas Gruenbacher 	int n;
240cb65a5baSJesper Juhl 	int w;
241a257cdd0SAndreas Gruenbacher 
242aefa89d1SPrasad P 	/*
243aefa89d1SPrasad P 	 * Since this is version 2, the check for nfserr in
244aefa89d1SPrasad P 	 * nfsd_dispatch actually ensures the following cannot happen.
245aefa89d1SPrasad P 	 * However, it seems fragile to depend on that.
246aefa89d1SPrasad P 	 */
247a257cdd0SAndreas Gruenbacher 	if (dentry == NULL || dentry->d_inode == NULL)
248a257cdd0SAndreas Gruenbacher 		return 0;
249a257cdd0SAndreas Gruenbacher 	inode = dentry->d_inode;
250a257cdd0SAndreas Gruenbacher 
251a257cdd0SAndreas Gruenbacher 	p = nfs2svc_encode_fattr(rqstp, p, &resp->fh);
252a257cdd0SAndreas Gruenbacher 	*p++ = htonl(resp->mask);
253a257cdd0SAndreas Gruenbacher 	if (!xdr_ressize_check(rqstp, p))
254a257cdd0SAndreas Gruenbacher 		return 0;
255a257cdd0SAndreas Gruenbacher 	base = (char *)p - (char *)head->iov_base;
256a257cdd0SAndreas Gruenbacher 
257cb65a5baSJesper Juhl 	rqstp->rq_res.page_len = w = nfsacl_size(
258cb65a5baSJesper Juhl 		(resp->mask & NFS_ACL)   ? resp->acl_access  : NULL,
259cb65a5baSJesper Juhl 		(resp->mask & NFS_DFACL) ? resp->acl_default : NULL);
260a257cdd0SAndreas Gruenbacher 	while (w > 0) {
26144524359SNeilBrown 		if (!rqstp->rq_respages[rqstp->rq_resused++])
262a257cdd0SAndreas Gruenbacher 			return 0;
263a257cdd0SAndreas Gruenbacher 		w -= PAGE_SIZE;
264a257cdd0SAndreas Gruenbacher 	}
265a257cdd0SAndreas Gruenbacher 
266a257cdd0SAndreas Gruenbacher 	n = nfsacl_encode(&rqstp->rq_res, base, inode,
267a257cdd0SAndreas Gruenbacher 			  resp->acl_access,
268a257cdd0SAndreas Gruenbacher 			  resp->mask & NFS_ACL, 0);
269a257cdd0SAndreas Gruenbacher 	if (n > 0)
270a257cdd0SAndreas Gruenbacher 		n = nfsacl_encode(&rqstp->rq_res, base + n, inode,
271a257cdd0SAndreas Gruenbacher 				  resp->acl_default,
272a257cdd0SAndreas Gruenbacher 				  resp->mask & NFS_DFACL,
273a257cdd0SAndreas Gruenbacher 				  NFS_ACL_DEFAULT);
274a257cdd0SAndreas Gruenbacher 	if (n <= 0)
275a257cdd0SAndreas Gruenbacher 		return 0;
276a257cdd0SAndreas Gruenbacher 	return 1;
277a257cdd0SAndreas Gruenbacher }
278a257cdd0SAndreas Gruenbacher 
279131a21c2SAl Viro static int nfsaclsvc_encode_attrstatres(struct svc_rqst *rqstp, __be32 *p,
280a257cdd0SAndreas Gruenbacher 		struct nfsd_attrstat *resp)
281a257cdd0SAndreas Gruenbacher {
282a257cdd0SAndreas Gruenbacher 	p = nfs2svc_encode_fattr(rqstp, p, &resp->fh);
283a257cdd0SAndreas Gruenbacher 	return xdr_ressize_check(rqstp, p);
284a257cdd0SAndreas Gruenbacher }
285a257cdd0SAndreas Gruenbacher 
286a257cdd0SAndreas Gruenbacher /* ACCESS */
287131a21c2SAl Viro static int nfsaclsvc_encode_accessres(struct svc_rqst *rqstp, __be32 *p,
288a257cdd0SAndreas Gruenbacher 		struct nfsd3_accessres *resp)
289a257cdd0SAndreas Gruenbacher {
290a257cdd0SAndreas Gruenbacher 	p = nfs2svc_encode_fattr(rqstp, p, &resp->fh);
291a257cdd0SAndreas Gruenbacher 	*p++ = htonl(resp->access);
292a257cdd0SAndreas Gruenbacher 	return xdr_ressize_check(rqstp, p);
293a257cdd0SAndreas Gruenbacher }
294a257cdd0SAndreas Gruenbacher 
295a257cdd0SAndreas Gruenbacher /*
296a257cdd0SAndreas Gruenbacher  * XDR release functions
297a257cdd0SAndreas Gruenbacher  */
298131a21c2SAl Viro static int nfsaclsvc_release_getacl(struct svc_rqst *rqstp, __be32 *p,
299a257cdd0SAndreas Gruenbacher 		struct nfsd3_getaclres *resp)
300a257cdd0SAndreas Gruenbacher {
301a257cdd0SAndreas Gruenbacher 	fh_put(&resp->fh);
302a257cdd0SAndreas Gruenbacher 	posix_acl_release(resp->acl_access);
303a257cdd0SAndreas Gruenbacher 	posix_acl_release(resp->acl_default);
304a257cdd0SAndreas Gruenbacher 	return 1;
305a257cdd0SAndreas Gruenbacher }
306a257cdd0SAndreas Gruenbacher 
307c9ce2283SGreg Banks static int nfsaclsvc_release_attrstat(struct svc_rqst *rqstp, __be32 *p,
308c9ce2283SGreg Banks 		struct nfsd_attrstat *resp)
309c9ce2283SGreg Banks {
310c9ce2283SGreg Banks 	fh_put(&resp->fh);
311c9ce2283SGreg Banks 	return 1;
312c9ce2283SGreg Banks }
313c9ce2283SGreg Banks 
314c9ce2283SGreg Banks static int nfsaclsvc_release_access(struct svc_rqst *rqstp, __be32 *p,
315c9ce2283SGreg Banks                struct nfsd3_accessres *resp)
316a257cdd0SAndreas Gruenbacher {
317a257cdd0SAndreas Gruenbacher        fh_put(&resp->fh);
318a257cdd0SAndreas Gruenbacher        return 1;
319a257cdd0SAndreas Gruenbacher }
320a257cdd0SAndreas Gruenbacher 
321a257cdd0SAndreas Gruenbacher #define nfsaclsvc_decode_voidargs	NULL
322a257cdd0SAndreas Gruenbacher #define nfsaclsvc_release_void		NULL
323a257cdd0SAndreas Gruenbacher #define nfsd3_fhandleargs	nfsd_fhandle
324a257cdd0SAndreas Gruenbacher #define nfsd3_attrstatres	nfsd_attrstat
325a257cdd0SAndreas Gruenbacher #define nfsd3_voidres		nfsd3_voidargs
326a257cdd0SAndreas Gruenbacher struct nfsd3_voidargs { int dummy; };
327a257cdd0SAndreas Gruenbacher 
328a257cdd0SAndreas Gruenbacher #define PROC(name, argt, rest, relt, cache, respsize)	\
329a257cdd0SAndreas Gruenbacher  { (svc_procfunc) nfsacld_proc_##name,		\
330a257cdd0SAndreas Gruenbacher    (kxdrproc_t) nfsaclsvc_decode_##argt##args,	\
331a257cdd0SAndreas Gruenbacher    (kxdrproc_t) nfsaclsvc_encode_##rest##res,	\
332a257cdd0SAndreas Gruenbacher    (kxdrproc_t) nfsaclsvc_release_##relt,		\
333a257cdd0SAndreas Gruenbacher    sizeof(struct nfsd3_##argt##args),		\
334a257cdd0SAndreas Gruenbacher    sizeof(struct nfsd3_##rest##res),		\
335a257cdd0SAndreas Gruenbacher    0,						\
336a257cdd0SAndreas Gruenbacher    cache,					\
337a257cdd0SAndreas Gruenbacher    respsize,					\
338a257cdd0SAndreas Gruenbacher  }
339a257cdd0SAndreas Gruenbacher 
340a257cdd0SAndreas Gruenbacher #define ST 1		/* status*/
341a257cdd0SAndreas Gruenbacher #define AT 21		/* attributes */
342a257cdd0SAndreas Gruenbacher #define pAT (1+AT)	/* post attributes - conditional */
343a257cdd0SAndreas Gruenbacher #define ACL (1+NFS_ACL_MAX_ENTRIES*3)  /* Access Control List */
344a257cdd0SAndreas Gruenbacher 
345a257cdd0SAndreas Gruenbacher static struct svc_procedure		nfsd_acl_procedures2[] = {
346a257cdd0SAndreas Gruenbacher   PROC(null,	void,		void,		void,	  RC_NOCACHE, ST),
347a257cdd0SAndreas Gruenbacher   PROC(getacl,	getacl,		getacl,		getacl,	  RC_NOCACHE, ST+1+2*(1+ACL)),
348c9ce2283SGreg Banks   PROC(setacl,	setacl,		attrstat,	attrstat, RC_NOCACHE, ST+AT),
349c9ce2283SGreg Banks   PROC(getattr, fhandle,	attrstat,	attrstat, RC_NOCACHE, ST+AT),
350c9ce2283SGreg Banks   PROC(access,	access,		access,		access,   RC_NOCACHE, ST+AT+1),
351a257cdd0SAndreas Gruenbacher };
352a257cdd0SAndreas Gruenbacher 
353a257cdd0SAndreas Gruenbacher struct svc_version	nfsd_acl_version2 = {
354a257cdd0SAndreas Gruenbacher 		.vs_vers	= 2,
355a257cdd0SAndreas Gruenbacher 		.vs_nproc	= 5,
356a257cdd0SAndreas Gruenbacher 		.vs_proc	= nfsd_acl_procedures2,
357a257cdd0SAndreas Gruenbacher 		.vs_dispatch	= nfsd_dispatch,
358a257cdd0SAndreas Gruenbacher 		.vs_xdrsize	= NFS3_SVC_XDRSIZE,
3591b7e0403SPeter Staubach 		.vs_hidden	= 0,
360a257cdd0SAndreas Gruenbacher };
361