xref: /netbsd-src/sys/fs/nfs/nlm/nlm_prot_server.c (revision d687e96a027d668c69e289ca0ac86d6257cf26c3)
1*d687e96aSpgoyette /*	$NetBSD: nlm_prot_server.c,v 1.2 2016/12/13 21:58:17 pgoyette Exp $	*/
26ca35587Sdholland /*-
36ca35587Sdholland  * Copyright (c) 2008 Isilon Inc http://www.isilon.com/
46ca35587Sdholland  * Authors: Doug Rabson <dfr@rabson.org>
56ca35587Sdholland  * Developed with Red Inc: Alfred Perlstein <alfred@freebsd.org>
66ca35587Sdholland  *
76ca35587Sdholland  * Redistribution and use in source and binary forms, with or without
86ca35587Sdholland  * modification, are permitted provided that the following conditions
96ca35587Sdholland  * are met:
106ca35587Sdholland  * 1. Redistributions of source code must retain the above copyright
116ca35587Sdholland  *    notice, this list of conditions and the following disclaimer.
126ca35587Sdholland  * 2. Redistributions in binary form must reproduce the above copyright
136ca35587Sdholland  *    notice, this list of conditions and the following disclaimer in the
146ca35587Sdholland  *    documentation and/or other materials provided with the distribution.
156ca35587Sdholland  *
166ca35587Sdholland  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
176ca35587Sdholland  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
186ca35587Sdholland  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
196ca35587Sdholland  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
206ca35587Sdholland  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
216ca35587Sdholland  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
226ca35587Sdholland  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
236ca35587Sdholland  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
246ca35587Sdholland  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
256ca35587Sdholland  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
266ca35587Sdholland  * SUCH DAMAGE.
276ca35587Sdholland  */
286ca35587Sdholland 
296ca35587Sdholland #include <sys/cdefs.h>
306ca35587Sdholland #ifndef lint
316ca35587Sdholland /*static char sccsid[] = "from: @(#)nlm_prot.x 1.8 87/09/21 Copyr 1987 Sun Micro";*/
326ca35587Sdholland /*static char sccsid[] = "from: * @(#)nlm_prot.x	2.1 88/08/01 4.0 RPCSRC";*/
336ca35587Sdholland /* __RCSID("NetBSD: nlm_prot.x,v 1.6 2000/06/07 14:30:15 bouyer Exp "); */
346ca35587Sdholland #endif /* not lint */
356ca35587Sdholland /* __FBSDID("FreeBSD: head/sys/nlm/nlm_prot_server.c 197840 2009-10-07 19:50:14Z zml "); */
36*d687e96aSpgoyette __RCSID("$NetBSD: nlm_prot_server.c,v 1.2 2016/12/13 21:58:17 pgoyette Exp $");
376ca35587Sdholland 
386ca35587Sdholland #include <sys/param.h>
396ca35587Sdholland #include <sys/malloc.h>
406ca35587Sdholland #include <sys/systm.h>
416ca35587Sdholland 
42*d687e96aSpgoyette #include <fs/nfs/nlm/nlm_prot.h>
43*d687e96aSpgoyette #include <fs/nfs/nlm/nlm.h>
446ca35587Sdholland 
456ca35587Sdholland /**********************************************************************/
466ca35587Sdholland 
476ca35587Sdholland /*
486ca35587Sdholland  * Convert between various versions of the protocol structures.
496ca35587Sdholland  */
506ca35587Sdholland 
516ca35587Sdholland static void
nlm_convert_to_nlm4_lock(struct nlm4_lock * dst,struct nlm_lock * src)526ca35587Sdholland nlm_convert_to_nlm4_lock(struct nlm4_lock *dst, struct nlm_lock *src)
536ca35587Sdholland {
546ca35587Sdholland 
556ca35587Sdholland 	dst->caller_name = src->caller_name;
566ca35587Sdholland 	dst->fh = src->fh;
576ca35587Sdholland 	dst->oh = src->oh;
586ca35587Sdholland 	dst->svid = src->svid;
596ca35587Sdholland 	dst->l_offset = src->l_offset;
606ca35587Sdholland 	dst->l_len = src->l_len;
616ca35587Sdholland }
626ca35587Sdholland 
636ca35587Sdholland static void
nlm_convert_to_nlm4_share(struct nlm4_share * dst,struct nlm_share * src)646ca35587Sdholland nlm_convert_to_nlm4_share(struct nlm4_share *dst, struct nlm_share *src)
656ca35587Sdholland {
666ca35587Sdholland 
676ca35587Sdholland 	dst->caller_name = src->caller_name;
686ca35587Sdholland 	dst->fh = src->fh;
696ca35587Sdholland 	dst->oh = src->oh;
706ca35587Sdholland 	dst->mode = src->mode;
716ca35587Sdholland 	dst->access = src->access;
726ca35587Sdholland }
736ca35587Sdholland 
746ca35587Sdholland static void
nlm_convert_to_nlm_holder(struct nlm_holder * dst,struct nlm4_holder * src)756ca35587Sdholland nlm_convert_to_nlm_holder(struct nlm_holder *dst, struct nlm4_holder *src)
766ca35587Sdholland {
776ca35587Sdholland 
786ca35587Sdholland 	dst->exclusive = src->exclusive;
796ca35587Sdholland 	dst->svid = src->svid;
806ca35587Sdholland 	dst->oh = src->oh;
816ca35587Sdholland 	dst->l_offset = src->l_offset;
826ca35587Sdholland 	dst->l_len = src->l_len;
836ca35587Sdholland }
846ca35587Sdholland 
856ca35587Sdholland static void
nlm_convert_to_nlm4_holder(struct nlm4_holder * dst,struct nlm_holder * src)866ca35587Sdholland nlm_convert_to_nlm4_holder(struct nlm4_holder *dst, struct nlm_holder *src)
876ca35587Sdholland {
886ca35587Sdholland 
896ca35587Sdholland 	dst->exclusive = src->exclusive;
906ca35587Sdholland 	dst->svid = src->svid;
916ca35587Sdholland 	dst->oh = src->oh;
926ca35587Sdholland 	dst->l_offset = src->l_offset;
936ca35587Sdholland 	dst->l_len = src->l_len;
946ca35587Sdholland }
956ca35587Sdholland 
966ca35587Sdholland static enum nlm_stats
nlm_convert_to_nlm_stats(enum nlm4_stats src)976ca35587Sdholland nlm_convert_to_nlm_stats(enum nlm4_stats src)
986ca35587Sdholland {
996ca35587Sdholland 	if (src > nlm4_deadlck)
1006ca35587Sdholland 		return nlm_denied;
1016ca35587Sdholland 	return (enum nlm_stats) src;
1026ca35587Sdholland }
1036ca35587Sdholland 
1046ca35587Sdholland static void
nlm_convert_to_nlm_res(struct nlm_res * dst,struct nlm4_res * src)1056ca35587Sdholland nlm_convert_to_nlm_res(struct nlm_res *dst, struct nlm4_res *src)
1066ca35587Sdholland {
1076ca35587Sdholland 	dst->cookie = src->cookie;
1086ca35587Sdholland 	dst->stat.stat = nlm_convert_to_nlm_stats(src->stat.stat);
1096ca35587Sdholland }
1106ca35587Sdholland 
1116ca35587Sdholland static void
nlm_convert_to_nlm4_res(struct nlm4_res * dst,struct nlm_res * src)1126ca35587Sdholland nlm_convert_to_nlm4_res(struct nlm4_res *dst, struct nlm_res *src)
1136ca35587Sdholland {
1146ca35587Sdholland 	dst->cookie = src->cookie;
1156ca35587Sdholland 	dst->stat.stat = (enum nlm4_stats) src->stat.stat;
1166ca35587Sdholland }
1176ca35587Sdholland 
1186ca35587Sdholland /**********************************************************************/
1196ca35587Sdholland 
1206ca35587Sdholland /*
1216ca35587Sdholland  * RPC server stubs.
1226ca35587Sdholland  */
1236ca35587Sdholland 
1246ca35587Sdholland bool_t
nlm_sm_notify_0_svc(struct nlm_sm_status * argp,void * result,struct svc_req * rqstp)1256ca35587Sdholland nlm_sm_notify_0_svc(struct nlm_sm_status *argp, void *result, struct svc_req *rqstp)
1266ca35587Sdholland {
1276ca35587Sdholland 	nlm_sm_notify(argp);
1286ca35587Sdholland 
1296ca35587Sdholland 	return (TRUE);
1306ca35587Sdholland }
1316ca35587Sdholland 
1326ca35587Sdholland bool_t
nlm_test_1_svc(struct nlm_testargs * argp,nlm_testres * result,struct svc_req * rqstp)1336ca35587Sdholland nlm_test_1_svc(struct nlm_testargs *argp, nlm_testres *result, struct svc_req *rqstp)
1346ca35587Sdholland {
1356ca35587Sdholland 	bool_t retval;
1366ca35587Sdholland 	nlm4_testargs args4;
1376ca35587Sdholland 	nlm4_testres res4;
1386ca35587Sdholland 
1396ca35587Sdholland 	args4.cookie = argp->cookie;
1406ca35587Sdholland 	args4.exclusive = argp->exclusive;
1416ca35587Sdholland 	nlm_convert_to_nlm4_lock(&args4.alock, &argp->alock);
1426ca35587Sdholland 
1436ca35587Sdholland 	retval = nlm4_test_4_svc(&args4, &res4, rqstp);
1446ca35587Sdholland 	if (retval) {
1456ca35587Sdholland 		result->cookie = res4.cookie;
1466ca35587Sdholland 		result->stat.stat = nlm_convert_to_nlm_stats(res4.stat.stat);
1476ca35587Sdholland 		if (result->stat.stat == nlm_denied)
1486ca35587Sdholland 			nlm_convert_to_nlm_holder(
1496ca35587Sdholland 				&result->stat.nlm_testrply_u.holder,
1506ca35587Sdholland 				&res4.stat.nlm4_testrply_u.holder);
1516ca35587Sdholland 	}
1526ca35587Sdholland 
1536ca35587Sdholland 	return (retval);
1546ca35587Sdholland }
1556ca35587Sdholland 
1566ca35587Sdholland bool_t
nlm_lock_1_svc(struct nlm_lockargs * argp,nlm_res * result,struct svc_req * rqstp)1576ca35587Sdholland nlm_lock_1_svc(struct nlm_lockargs *argp, nlm_res *result, struct svc_req *rqstp)
1586ca35587Sdholland {
1596ca35587Sdholland 	bool_t retval;
1606ca35587Sdholland 	nlm4_lockargs args4;
1616ca35587Sdholland 	nlm4_res res4;
1626ca35587Sdholland 
1636ca35587Sdholland 	args4.cookie = argp->cookie;
1646ca35587Sdholland 	args4.block = argp->block;
1656ca35587Sdholland 	args4.exclusive = argp->exclusive;
1666ca35587Sdholland 	nlm_convert_to_nlm4_lock(&args4.alock, &argp->alock);
1676ca35587Sdholland 	args4.reclaim = argp->reclaim;
1686ca35587Sdholland 	args4.state = argp->state;
1696ca35587Sdholland 
1706ca35587Sdholland 	retval = nlm4_lock_4_svc(&args4, &res4, rqstp);
1716ca35587Sdholland 	if (retval)
1726ca35587Sdholland 		nlm_convert_to_nlm_res(result, &res4);
1736ca35587Sdholland 
1746ca35587Sdholland 	return (retval);
1756ca35587Sdholland }
1766ca35587Sdholland 
1776ca35587Sdholland bool_t
nlm_cancel_1_svc(struct nlm_cancargs * argp,nlm_res * result,struct svc_req * rqstp)1786ca35587Sdholland nlm_cancel_1_svc(struct nlm_cancargs *argp, nlm_res *result, struct svc_req *rqstp)
1796ca35587Sdholland {
1806ca35587Sdholland 	bool_t retval;
1816ca35587Sdholland 	nlm4_cancargs args4;
1826ca35587Sdholland 	nlm4_res res4;
1836ca35587Sdholland 
1846ca35587Sdholland 	args4.cookie = argp->cookie;
1856ca35587Sdholland 	args4.block = argp->block;
1866ca35587Sdholland 	args4.exclusive = argp->exclusive;
1876ca35587Sdholland 	nlm_convert_to_nlm4_lock(&args4.alock, &argp->alock);
1886ca35587Sdholland 
1896ca35587Sdholland 	retval = nlm4_cancel_4_svc(&args4, &res4, rqstp);
1906ca35587Sdholland 	if (retval)
1916ca35587Sdholland 		nlm_convert_to_nlm_res(result, &res4);
1926ca35587Sdholland 
1936ca35587Sdholland 	return (retval);
1946ca35587Sdholland }
1956ca35587Sdholland 
1966ca35587Sdholland bool_t
nlm_unlock_1_svc(struct nlm_unlockargs * argp,nlm_res * result,struct svc_req * rqstp)1976ca35587Sdholland nlm_unlock_1_svc(struct nlm_unlockargs *argp, nlm_res *result, struct svc_req *rqstp)
1986ca35587Sdholland {
1996ca35587Sdholland 	bool_t retval;
2006ca35587Sdholland 	nlm4_unlockargs args4;
2016ca35587Sdholland 	nlm4_res res4;
2026ca35587Sdholland 
2036ca35587Sdholland 	args4.cookie = argp->cookie;
2046ca35587Sdholland 	nlm_convert_to_nlm4_lock(&args4.alock, &argp->alock);
2056ca35587Sdholland 
2066ca35587Sdholland 	retval = nlm4_unlock_4_svc(&args4, &res4, rqstp);
2076ca35587Sdholland 	if (retval)
2086ca35587Sdholland 		nlm_convert_to_nlm_res(result, &res4);
2096ca35587Sdholland 
2106ca35587Sdholland 	return (retval);
2116ca35587Sdholland }
2126ca35587Sdholland 
2136ca35587Sdholland bool_t
nlm_granted_1_svc(struct nlm_testargs * argp,nlm_res * result,struct svc_req * rqstp)2146ca35587Sdholland nlm_granted_1_svc(struct nlm_testargs *argp, nlm_res *result, struct svc_req *rqstp)
2156ca35587Sdholland {
2166ca35587Sdholland 	bool_t retval;
2176ca35587Sdholland 	nlm4_testargs args4;
2186ca35587Sdholland 	nlm4_res res4;
2196ca35587Sdholland 
2206ca35587Sdholland 	args4.cookie = argp->cookie;
2216ca35587Sdholland 	args4.exclusive = argp->exclusive;
2226ca35587Sdholland 	nlm_convert_to_nlm4_lock(&args4.alock, &argp->alock);
2236ca35587Sdholland 
2246ca35587Sdholland 	retval = nlm4_granted_4_svc(&args4, &res4, rqstp);
2256ca35587Sdholland 	if (retval)
2266ca35587Sdholland 		nlm_convert_to_nlm_res(result, &res4);
2276ca35587Sdholland 
2286ca35587Sdholland 	return (retval);
2296ca35587Sdholland }
2306ca35587Sdholland 
2316ca35587Sdholland bool_t
nlm_test_msg_1_svc(struct nlm_testargs * argp,void * result,struct svc_req * rqstp)2326ca35587Sdholland nlm_test_msg_1_svc(struct nlm_testargs *argp, void *result, struct svc_req *rqstp)
2336ca35587Sdholland {
2346ca35587Sdholland 	nlm4_testargs args4;
2356ca35587Sdholland 	nlm4_testres res4;
2366ca35587Sdholland 	nlm_testres res;
2376ca35587Sdholland 	CLIENT *rpc;
2386ca35587Sdholland 	char dummy;
2396ca35587Sdholland 
2406ca35587Sdholland 	args4.cookie = argp->cookie;
2416ca35587Sdholland 	args4.exclusive = argp->exclusive;
2426ca35587Sdholland 	nlm_convert_to_nlm4_lock(&args4.alock, &argp->alock);
2436ca35587Sdholland 
2446ca35587Sdholland 	if (nlm_do_test(&args4, &res4, rqstp, &rpc))
2456ca35587Sdholland 		return (FALSE);
2466ca35587Sdholland 
2476ca35587Sdholland 	res.cookie = res4.cookie;
2486ca35587Sdholland 	res.stat.stat = nlm_convert_to_nlm_stats(res4.stat.stat);
2496ca35587Sdholland 	if (res.stat.stat == nlm_denied)
2506ca35587Sdholland 		nlm_convert_to_nlm_holder(
2516ca35587Sdholland 			&res.stat.nlm_testrply_u.holder,
2526ca35587Sdholland 			&res4.stat.nlm4_testrply_u.holder);
2536ca35587Sdholland 
2546ca35587Sdholland 	if (rpc) {
2556ca35587Sdholland 		nlm_test_res_1(&res, &dummy, rpc, NULL, nlm_zero_tv);
2566ca35587Sdholland 		CLNT_RELEASE(rpc);
2576ca35587Sdholland 	}
2586ca35587Sdholland 	xdr_free((xdrproc_t) xdr_nlm_testres, &res);
2596ca35587Sdholland 
2606ca35587Sdholland 	return (FALSE);
2616ca35587Sdholland }
2626ca35587Sdholland 
2636ca35587Sdholland bool_t
nlm_lock_msg_1_svc(struct nlm_lockargs * argp,void * result,struct svc_req * rqstp)2646ca35587Sdholland nlm_lock_msg_1_svc(struct nlm_lockargs *argp, void *result, struct svc_req *rqstp)
2656ca35587Sdholland {
2666ca35587Sdholland 	nlm4_lockargs args4;
2676ca35587Sdholland 	nlm4_res res4;
2686ca35587Sdholland 	nlm_res res;
2696ca35587Sdholland 	CLIENT *rpc;
2706ca35587Sdholland 	char dummy;
2716ca35587Sdholland 
2726ca35587Sdholland 	args4.cookie = argp->cookie;
2736ca35587Sdholland 	args4.block = argp->block;
2746ca35587Sdholland 	args4.exclusive = argp->exclusive;
2756ca35587Sdholland 	nlm_convert_to_nlm4_lock(&args4.alock, &argp->alock);
2766ca35587Sdholland 	args4.reclaim = argp->reclaim;
2776ca35587Sdholland 	args4.state = argp->state;
2786ca35587Sdholland 
2796ca35587Sdholland 	if (nlm_do_lock(&args4, &res4, rqstp, TRUE, &rpc))
2806ca35587Sdholland 		return (FALSE);
2816ca35587Sdholland 
2826ca35587Sdholland 	nlm_convert_to_nlm_res(&res, &res4);
2836ca35587Sdholland 
2846ca35587Sdholland 	if (rpc) {
2856ca35587Sdholland 		nlm_lock_res_1(&res, &dummy, rpc, NULL, nlm_zero_tv);
2866ca35587Sdholland 		CLNT_RELEASE(rpc);
2876ca35587Sdholland 	}
2886ca35587Sdholland 	xdr_free((xdrproc_t) xdr_nlm_res, &res);
2896ca35587Sdholland 
2906ca35587Sdholland 	return (FALSE);
2916ca35587Sdholland }
2926ca35587Sdholland 
2936ca35587Sdholland bool_t
nlm_cancel_msg_1_svc(struct nlm_cancargs * argp,void * result,struct svc_req * rqstp)2946ca35587Sdholland nlm_cancel_msg_1_svc(struct nlm_cancargs *argp, void *result, struct svc_req *rqstp)
2956ca35587Sdholland {
2966ca35587Sdholland 	nlm4_cancargs args4;
2976ca35587Sdholland 	nlm4_res res4;
2986ca35587Sdholland 	nlm_res res;
2996ca35587Sdholland 	CLIENT *rpc;
3006ca35587Sdholland 	char dummy;
3016ca35587Sdholland 
3026ca35587Sdholland 	args4.cookie = argp->cookie;
3036ca35587Sdholland 	args4.block = argp->block;
3046ca35587Sdholland 	args4.exclusive = argp->exclusive;
3056ca35587Sdholland 	nlm_convert_to_nlm4_lock(&args4.alock, &argp->alock);
3066ca35587Sdholland 
3076ca35587Sdholland 	if (nlm_do_cancel(&args4, &res4, rqstp, &rpc))
3086ca35587Sdholland 		return (FALSE);
3096ca35587Sdholland 
3106ca35587Sdholland 	nlm_convert_to_nlm_res(&res, &res4);
3116ca35587Sdholland 
3126ca35587Sdholland 	if (rpc) {
3136ca35587Sdholland 		nlm_cancel_res_1(&res, &dummy, rpc, NULL, nlm_zero_tv);
3146ca35587Sdholland 		CLNT_RELEASE(rpc);
3156ca35587Sdholland 	}
3166ca35587Sdholland 	xdr_free((xdrproc_t) xdr_nlm_res, &res);
3176ca35587Sdholland 
3186ca35587Sdholland 	return (FALSE);
3196ca35587Sdholland }
3206ca35587Sdholland 
3216ca35587Sdholland bool_t
nlm_unlock_msg_1_svc(struct nlm_unlockargs * argp,void * result,struct svc_req * rqstp)3226ca35587Sdholland nlm_unlock_msg_1_svc(struct nlm_unlockargs *argp, void *result, struct svc_req *rqstp)
3236ca35587Sdholland {
3246ca35587Sdholland 	nlm4_unlockargs args4;
3256ca35587Sdholland 	nlm4_res res4;
3266ca35587Sdholland 	nlm_res res;
3276ca35587Sdholland 	CLIENT *rpc;
3286ca35587Sdholland 	char dummy;
3296ca35587Sdholland 
3306ca35587Sdholland 	args4.cookie = argp->cookie;
3316ca35587Sdholland 	nlm_convert_to_nlm4_lock(&args4.alock, &argp->alock);
3326ca35587Sdholland 
3336ca35587Sdholland 	if (nlm_do_unlock(&args4, &res4, rqstp, &rpc))
3346ca35587Sdholland 		return (FALSE);
3356ca35587Sdholland 
3366ca35587Sdholland 	nlm_convert_to_nlm_res(&res, &res4);
3376ca35587Sdholland 
3386ca35587Sdholland 	if (rpc) {
3396ca35587Sdholland 		nlm_unlock_res_1(&res, &dummy, rpc, NULL, nlm_zero_tv);
3406ca35587Sdholland 		CLNT_RELEASE(rpc);
3416ca35587Sdholland 	}
3426ca35587Sdholland 	xdr_free((xdrproc_t) xdr_nlm_res, &res);
3436ca35587Sdholland 
3446ca35587Sdholland 	return (FALSE);
3456ca35587Sdholland }
3466ca35587Sdholland 
3476ca35587Sdholland bool_t
nlm_granted_msg_1_svc(struct nlm_testargs * argp,void * result,struct svc_req * rqstp)3486ca35587Sdholland nlm_granted_msg_1_svc(struct nlm_testargs *argp, void *result, struct svc_req *rqstp)
3496ca35587Sdholland {
3506ca35587Sdholland 	nlm4_testargs args4;
3516ca35587Sdholland 	nlm4_res res4;
3526ca35587Sdholland 	nlm_res res;
3536ca35587Sdholland 	CLIENT *rpc;
3546ca35587Sdholland 	char dummy;
3556ca35587Sdholland 
3566ca35587Sdholland 	args4.cookie = argp->cookie;
3576ca35587Sdholland 	args4.exclusive = argp->exclusive;
3586ca35587Sdholland 	nlm_convert_to_nlm4_lock(&args4.alock, &argp->alock);
3596ca35587Sdholland 
3606ca35587Sdholland 	if (nlm_do_granted(&args4, &res4, rqstp, &rpc))
3616ca35587Sdholland 		return (FALSE);
3626ca35587Sdholland 
3636ca35587Sdholland 	nlm_convert_to_nlm_res(&res, &res4);
3646ca35587Sdholland 
3656ca35587Sdholland 	if (rpc) {
3666ca35587Sdholland 		nlm_granted_res_1(&res, &dummy, rpc, NULL, nlm_zero_tv);
3676ca35587Sdholland 		CLNT_RELEASE(rpc);
3686ca35587Sdholland 	}
3696ca35587Sdholland 	xdr_free((xdrproc_t) xdr_nlm_res, &res);
3706ca35587Sdholland 
3716ca35587Sdholland 	return (FALSE);
3726ca35587Sdholland }
3736ca35587Sdholland 
3746ca35587Sdholland bool_t
nlm_test_res_1_svc(nlm_testres * argp,void * result,struct svc_req * rqstp)3756ca35587Sdholland nlm_test_res_1_svc(nlm_testres *argp, void *result, struct svc_req *rqstp)
3766ca35587Sdholland {
3776ca35587Sdholland 	nlm4_testres args4;
3786ca35587Sdholland 
3796ca35587Sdholland 	args4.cookie = argp->cookie;
3806ca35587Sdholland 	if (argp->stat.stat == nlm_denied)
3816ca35587Sdholland 		nlm_convert_to_nlm4_holder(
3826ca35587Sdholland 			&args4.stat.nlm4_testrply_u.holder,
3836ca35587Sdholland 			&argp->stat.nlm_testrply_u.holder);
3846ca35587Sdholland 
3856ca35587Sdholland 	return (nlm4_test_res_4_svc(&args4, result, rqstp));
3866ca35587Sdholland }
3876ca35587Sdholland 
3886ca35587Sdholland bool_t
nlm_lock_res_1_svc(nlm_res * argp,void * result,struct svc_req * rqstp)3896ca35587Sdholland nlm_lock_res_1_svc(nlm_res *argp, void *result, struct svc_req *rqstp)
3906ca35587Sdholland {
3916ca35587Sdholland 	nlm4_res arg4;
3926ca35587Sdholland 
3936ca35587Sdholland 	nlm_convert_to_nlm4_res(&arg4, argp);
3946ca35587Sdholland 	return (nlm4_lock_res_4_svc(&arg4, result, rqstp));
3956ca35587Sdholland }
3966ca35587Sdholland 
3976ca35587Sdholland bool_t
nlm_cancel_res_1_svc(nlm_res * argp,void * result,struct svc_req * rqstp)3986ca35587Sdholland nlm_cancel_res_1_svc(nlm_res *argp, void *result, struct svc_req *rqstp)
3996ca35587Sdholland {
4006ca35587Sdholland 	nlm4_res arg4;
4016ca35587Sdholland 
4026ca35587Sdholland 	nlm_convert_to_nlm4_res(&arg4, argp);
4036ca35587Sdholland 	return (nlm4_cancel_res_4_svc(&arg4, result, rqstp));
4046ca35587Sdholland }
4056ca35587Sdholland 
4066ca35587Sdholland bool_t
nlm_unlock_res_1_svc(nlm_res * argp,void * result,struct svc_req * rqstp)4076ca35587Sdholland nlm_unlock_res_1_svc(nlm_res *argp, void *result, struct svc_req *rqstp)
4086ca35587Sdholland {
4096ca35587Sdholland 	nlm4_res arg4;
4106ca35587Sdholland 
4116ca35587Sdholland 	nlm_convert_to_nlm4_res(&arg4, argp);
4126ca35587Sdholland 	return (nlm4_unlock_res_4_svc(&arg4, result, rqstp));
4136ca35587Sdholland }
4146ca35587Sdholland 
4156ca35587Sdholland bool_t
nlm_granted_res_1_svc(nlm_res * argp,void * result,struct svc_req * rqstp)4166ca35587Sdholland nlm_granted_res_1_svc(nlm_res *argp, void *result, struct svc_req *rqstp)
4176ca35587Sdholland {
4186ca35587Sdholland 	nlm4_res arg4;
4196ca35587Sdholland 
4206ca35587Sdholland 	nlm_convert_to_nlm4_res(&arg4, argp);
4216ca35587Sdholland 	return (nlm4_granted_res_4_svc(&arg4, result, rqstp));
4226ca35587Sdholland }
4236ca35587Sdholland 
4246ca35587Sdholland int
nlm_prog_1_freeresult(SVCXPRT * transp,xdrproc_t xdr_result,caddr_t result)4256ca35587Sdholland nlm_prog_1_freeresult(SVCXPRT *transp, xdrproc_t xdr_result, caddr_t result)
4266ca35587Sdholland {
4276ca35587Sdholland 
4286ca35587Sdholland 	(void) xdr_free(xdr_result, result);
4296ca35587Sdholland 	return (TRUE);
4306ca35587Sdholland }
4316ca35587Sdholland 
4326ca35587Sdholland bool_t
nlm_share_3_svc(nlm_shareargs * argp,nlm_shareres * result,struct svc_req * rqstp)4336ca35587Sdholland nlm_share_3_svc(nlm_shareargs *argp, nlm_shareres *result, struct svc_req *rqstp)
4346ca35587Sdholland {
4356ca35587Sdholland 	bool_t retval;
4366ca35587Sdholland 	nlm4_shareargs args4;
4376ca35587Sdholland 	nlm4_shareres res4;
4386ca35587Sdholland 
4396ca35587Sdholland 	args4.cookie = argp->cookie;
4406ca35587Sdholland 	nlm_convert_to_nlm4_share(&args4.share, &argp->share);
4416ca35587Sdholland 	args4.reclaim = argp->reclaim;
4426ca35587Sdholland 
4436ca35587Sdholland 	retval = nlm4_share_4_svc(&args4, &res4, rqstp);
4446ca35587Sdholland 	if (retval) {
4456ca35587Sdholland 		result->cookie = res4.cookie;
4466ca35587Sdholland 		result->stat = nlm_convert_to_nlm_stats(res4.stat);
4476ca35587Sdholland 		result->sequence = res4.sequence;
4486ca35587Sdholland 	}
4496ca35587Sdholland 
4506ca35587Sdholland 	return (retval);
4516ca35587Sdholland }
4526ca35587Sdholland 
4536ca35587Sdholland bool_t
nlm_unshare_3_svc(nlm_shareargs * argp,nlm_shareres * result,struct svc_req * rqstp)4546ca35587Sdholland nlm_unshare_3_svc(nlm_shareargs *argp, nlm_shareres *result, struct svc_req *rqstp)
4556ca35587Sdholland {
4566ca35587Sdholland 	bool_t retval;
4576ca35587Sdholland 	nlm4_shareargs args4;
4586ca35587Sdholland 	nlm4_shareres res4;
4596ca35587Sdholland 
4606ca35587Sdholland 	args4.cookie = argp->cookie;
4616ca35587Sdholland 	nlm_convert_to_nlm4_share(&args4.share, &argp->share);
4626ca35587Sdholland 	args4.reclaim = argp->reclaim;
4636ca35587Sdholland 
4646ca35587Sdholland 	retval = nlm4_unshare_4_svc(&args4, &res4, rqstp);
4656ca35587Sdholland 	if (retval) {
4666ca35587Sdholland 		result->cookie = res4.cookie;
4676ca35587Sdholland 		result->stat = nlm_convert_to_nlm_stats(res4.stat);
4686ca35587Sdholland 		result->sequence = res4.sequence;
4696ca35587Sdholland 	}
4706ca35587Sdholland 
4716ca35587Sdholland 	return (retval);
4726ca35587Sdholland }
4736ca35587Sdholland 
4746ca35587Sdholland bool_t
nlm_nm_lock_3_svc(nlm_lockargs * argp,nlm_res * result,struct svc_req * rqstp)4756ca35587Sdholland nlm_nm_lock_3_svc(nlm_lockargs *argp, nlm_res *result, struct svc_req *rqstp)
4766ca35587Sdholland {
4776ca35587Sdholland 	bool_t retval;
4786ca35587Sdholland 	nlm4_lockargs args4;
4796ca35587Sdholland 	nlm4_res res4;
4806ca35587Sdholland 
4816ca35587Sdholland 	args4.cookie = argp->cookie;
4826ca35587Sdholland 	args4.block = argp->block;
4836ca35587Sdholland 	args4.exclusive = argp->exclusive;
4846ca35587Sdholland 	nlm_convert_to_nlm4_lock(&args4.alock, &argp->alock);
4856ca35587Sdholland 	args4.reclaim = argp->reclaim;
4866ca35587Sdholland 	args4.state = argp->state;
4876ca35587Sdholland 
4886ca35587Sdholland 	retval = nlm4_nm_lock_4_svc(&args4, &res4, rqstp);
4896ca35587Sdholland 	if (retval)
4906ca35587Sdholland 		nlm_convert_to_nlm_res(result, &res4);
4916ca35587Sdholland 
4926ca35587Sdholland 	return (retval);
4936ca35587Sdholland }
4946ca35587Sdholland 
4956ca35587Sdholland bool_t
nlm_free_all_3_svc(nlm_notify * argp,void * result,struct svc_req * rqstp)4966ca35587Sdholland nlm_free_all_3_svc(nlm_notify *argp, void *result, struct svc_req *rqstp)
4976ca35587Sdholland {
4986ca35587Sdholland 	struct nlm4_notify args4;
4996ca35587Sdholland 
5006ca35587Sdholland 	args4.name = argp->name;
5016ca35587Sdholland 	args4.state = argp->state;
5026ca35587Sdholland 
5036ca35587Sdholland 	return (nlm4_free_all_4_svc(&args4, result, rqstp));
5046ca35587Sdholland }
5056ca35587Sdholland 
5066ca35587Sdholland int
nlm_prog_3_freeresult(SVCXPRT * transp,xdrproc_t xdr_result,caddr_t result)5076ca35587Sdholland nlm_prog_3_freeresult(SVCXPRT *transp, xdrproc_t xdr_result, caddr_t result)
5086ca35587Sdholland {
5096ca35587Sdholland 
5106ca35587Sdholland 	(void) xdr_free(xdr_result, result);
5116ca35587Sdholland 	return (TRUE);
5126ca35587Sdholland }
5136ca35587Sdholland 
5146ca35587Sdholland bool_t
nlm4_test_4_svc(nlm4_testargs * argp,nlm4_testres * result,struct svc_req * rqstp)5156ca35587Sdholland nlm4_test_4_svc(nlm4_testargs *argp, nlm4_testres *result, struct svc_req *rqstp)
5166ca35587Sdholland {
5176ca35587Sdholland 
5186ca35587Sdholland 	nlm_do_test(argp, result, rqstp, NULL);
5196ca35587Sdholland 	return (TRUE);
5206ca35587Sdholland }
5216ca35587Sdholland 
5226ca35587Sdholland bool_t
nlm4_lock_4_svc(nlm4_lockargs * argp,nlm4_res * result,struct svc_req * rqstp)5236ca35587Sdholland nlm4_lock_4_svc(nlm4_lockargs *argp, nlm4_res *result, struct svc_req *rqstp)
5246ca35587Sdholland {
5256ca35587Sdholland 
5266ca35587Sdholland 	nlm_do_lock(argp, result, rqstp, TRUE, NULL);
5276ca35587Sdholland 	return (TRUE);
5286ca35587Sdholland }
5296ca35587Sdholland 
5306ca35587Sdholland bool_t
nlm4_cancel_4_svc(nlm4_cancargs * argp,nlm4_res * result,struct svc_req * rqstp)5316ca35587Sdholland nlm4_cancel_4_svc(nlm4_cancargs *argp, nlm4_res *result, struct svc_req *rqstp)
5326ca35587Sdholland {
5336ca35587Sdholland 
5346ca35587Sdholland 	nlm_do_cancel(argp, result, rqstp, NULL);
5356ca35587Sdholland 	return (TRUE);
5366ca35587Sdholland }
5376ca35587Sdholland 
5386ca35587Sdholland bool_t
nlm4_unlock_4_svc(nlm4_unlockargs * argp,nlm4_res * result,struct svc_req * rqstp)5396ca35587Sdholland nlm4_unlock_4_svc(nlm4_unlockargs *argp, nlm4_res *result, struct svc_req *rqstp)
5406ca35587Sdholland {
5416ca35587Sdholland 
5426ca35587Sdholland 	nlm_do_unlock(argp, result, rqstp, NULL);
5436ca35587Sdholland 	return (TRUE);
5446ca35587Sdholland }
5456ca35587Sdholland 
5466ca35587Sdholland bool_t
nlm4_granted_4_svc(nlm4_testargs * argp,nlm4_res * result,struct svc_req * rqstp)5476ca35587Sdholland nlm4_granted_4_svc(nlm4_testargs *argp, nlm4_res *result, struct svc_req *rqstp)
5486ca35587Sdholland {
5496ca35587Sdholland 
5506ca35587Sdholland 	nlm_do_granted(argp, result, rqstp, NULL);
5516ca35587Sdholland 	return (TRUE);
5526ca35587Sdholland }
5536ca35587Sdholland 
5546ca35587Sdholland bool_t
nlm4_test_msg_4_svc(nlm4_testargs * argp,void * result,struct svc_req * rqstp)5556ca35587Sdholland nlm4_test_msg_4_svc(nlm4_testargs *argp, void *result, struct svc_req *rqstp)
5566ca35587Sdholland {
5576ca35587Sdholland 	nlm4_testres res4;
5586ca35587Sdholland 	CLIENT *rpc;
5596ca35587Sdholland 	char dummy;
5606ca35587Sdholland 
5616ca35587Sdholland 	if (nlm_do_test(argp, &res4, rqstp, &rpc))
5626ca35587Sdholland 		return (FALSE);
5636ca35587Sdholland 	if (rpc) {
5646ca35587Sdholland 		nlm4_test_res_4(&res4, &dummy, rpc, NULL, nlm_zero_tv);
5656ca35587Sdholland 		CLNT_RELEASE(rpc);
5666ca35587Sdholland 	}
5676ca35587Sdholland 	xdr_free((xdrproc_t) xdr_nlm4_testres, &res4);
5686ca35587Sdholland 
5696ca35587Sdholland 	return (FALSE);
5706ca35587Sdholland }
5716ca35587Sdholland 
5726ca35587Sdholland bool_t
nlm4_lock_msg_4_svc(nlm4_lockargs * argp,void * result,struct svc_req * rqstp)5736ca35587Sdholland nlm4_lock_msg_4_svc(nlm4_lockargs *argp, void *result, struct svc_req *rqstp)
5746ca35587Sdholland {
5756ca35587Sdholland 	nlm4_res res4;
5766ca35587Sdholland 	CLIENT *rpc;
5776ca35587Sdholland 	char dummy;
5786ca35587Sdholland 
5796ca35587Sdholland 	if (nlm_do_lock(argp, &res4, rqstp, TRUE, &rpc))
5806ca35587Sdholland 		return (FALSE);
5816ca35587Sdholland 	if (rpc) {
5826ca35587Sdholland 		nlm4_lock_res_4(&res4, &dummy, rpc, NULL, nlm_zero_tv);
5836ca35587Sdholland 		CLNT_RELEASE(rpc);
5846ca35587Sdholland 	}
5856ca35587Sdholland 	xdr_free((xdrproc_t) xdr_nlm4_res, &res4);
5866ca35587Sdholland 
5876ca35587Sdholland 	return (FALSE);
5886ca35587Sdholland }
5896ca35587Sdholland 
5906ca35587Sdholland bool_t
nlm4_cancel_msg_4_svc(nlm4_cancargs * argp,void * result,struct svc_req * rqstp)5916ca35587Sdholland nlm4_cancel_msg_4_svc(nlm4_cancargs *argp, void *result, struct svc_req *rqstp)
5926ca35587Sdholland {
5936ca35587Sdholland 	nlm4_res res4;
5946ca35587Sdholland 	CLIENT *rpc;
5956ca35587Sdholland 	char dummy;
5966ca35587Sdholland 
5976ca35587Sdholland 	if (nlm_do_cancel(argp, &res4, rqstp, &rpc))
5986ca35587Sdholland 		return (FALSE);
5996ca35587Sdholland 	if (rpc) {
6006ca35587Sdholland 		nlm4_cancel_res_4(&res4, &dummy, rpc, NULL, nlm_zero_tv);
6016ca35587Sdholland 		CLNT_RELEASE(rpc);
6026ca35587Sdholland 	}
6036ca35587Sdholland 	xdr_free((xdrproc_t) xdr_nlm4_res, &res4);
6046ca35587Sdholland 
6056ca35587Sdholland 	return (FALSE);
6066ca35587Sdholland }
6076ca35587Sdholland 
6086ca35587Sdholland bool_t
nlm4_unlock_msg_4_svc(nlm4_unlockargs * argp,void * result,struct svc_req * rqstp)6096ca35587Sdholland nlm4_unlock_msg_4_svc(nlm4_unlockargs *argp, void *result, struct svc_req *rqstp)
6106ca35587Sdholland {
6116ca35587Sdholland 	nlm4_res res4;
6126ca35587Sdholland 	CLIENT *rpc;
6136ca35587Sdholland 	char dummy;
6146ca35587Sdholland 
6156ca35587Sdholland 	if (nlm_do_unlock(argp, &res4, rqstp, &rpc))
6166ca35587Sdholland 		return (FALSE);
6176ca35587Sdholland 	if (rpc) {
6186ca35587Sdholland 		nlm4_unlock_res_4(&res4, &dummy, rpc, NULL, nlm_zero_tv);
6196ca35587Sdholland 		CLNT_RELEASE(rpc);
6206ca35587Sdholland 	}
6216ca35587Sdholland 	xdr_free((xdrproc_t) xdr_nlm4_res, &res4);
6226ca35587Sdholland 
6236ca35587Sdholland 	return (FALSE);
6246ca35587Sdholland }
6256ca35587Sdholland 
6266ca35587Sdholland bool_t
nlm4_granted_msg_4_svc(nlm4_testargs * argp,void * result,struct svc_req * rqstp)6276ca35587Sdholland nlm4_granted_msg_4_svc(nlm4_testargs *argp, void *result, struct svc_req *rqstp)
6286ca35587Sdholland {
6296ca35587Sdholland 	nlm4_res res4;
6306ca35587Sdholland 	CLIENT *rpc;
6316ca35587Sdholland 	char dummy;
6326ca35587Sdholland 
6336ca35587Sdholland 	if (nlm_do_granted(argp, &res4, rqstp, &rpc))
6346ca35587Sdholland 		return (FALSE);
6356ca35587Sdholland 	if (rpc) {
6366ca35587Sdholland 		nlm4_granted_res_4(&res4, &dummy, rpc, NULL, nlm_zero_tv);
6376ca35587Sdholland 		CLNT_RELEASE(rpc);
6386ca35587Sdholland 	}
6396ca35587Sdholland 	xdr_free((xdrproc_t) xdr_nlm4_res, &res4);
6406ca35587Sdholland 
6416ca35587Sdholland 	return (FALSE);
6426ca35587Sdholland }
6436ca35587Sdholland 
6446ca35587Sdholland bool_t
nlm4_test_res_4_svc(nlm4_testres * argp,void * result,struct svc_req * rqstp)6456ca35587Sdholland nlm4_test_res_4_svc(nlm4_testres *argp, void *result, struct svc_req *rqstp)
6466ca35587Sdholland {
6476ca35587Sdholland 
6486ca35587Sdholland 	return (FALSE);
6496ca35587Sdholland }
6506ca35587Sdholland 
6516ca35587Sdholland bool_t
nlm4_lock_res_4_svc(nlm4_res * argp,void * result,struct svc_req * rqstp)6526ca35587Sdholland nlm4_lock_res_4_svc(nlm4_res *argp, void *result, struct svc_req *rqstp)
6536ca35587Sdholland {
6546ca35587Sdholland 
6556ca35587Sdholland 	return (FALSE);
6566ca35587Sdholland }
6576ca35587Sdholland 
6586ca35587Sdholland bool_t
nlm4_cancel_res_4_svc(nlm4_res * argp,void * result,struct svc_req * rqstp)6596ca35587Sdholland nlm4_cancel_res_4_svc(nlm4_res *argp, void *result, struct svc_req *rqstp)
6606ca35587Sdholland {
6616ca35587Sdholland 
6626ca35587Sdholland 	return (FALSE);
6636ca35587Sdholland }
6646ca35587Sdholland 
6656ca35587Sdholland bool_t
nlm4_unlock_res_4_svc(nlm4_res * argp,void * result,struct svc_req * rqstp)6666ca35587Sdholland nlm4_unlock_res_4_svc(nlm4_res *argp, void *result, struct svc_req *rqstp)
6676ca35587Sdholland {
6686ca35587Sdholland 
6696ca35587Sdholland 	return (FALSE);
6706ca35587Sdholland }
6716ca35587Sdholland 
6726ca35587Sdholland bool_t
nlm4_granted_res_4_svc(nlm4_res * argp,void * result,struct svc_req * rqstp)6736ca35587Sdholland nlm4_granted_res_4_svc(nlm4_res *argp, void *result, struct svc_req *rqstp)
6746ca35587Sdholland {
6756ca35587Sdholland 
6766ca35587Sdholland 	nlm_do_granted_res(argp, rqstp);
6776ca35587Sdholland 	return (FALSE);
6786ca35587Sdholland }
6796ca35587Sdholland 
6806ca35587Sdholland bool_t
nlm4_share_4_svc(nlm4_shareargs * argp,nlm4_shareres * result,struct svc_req * rqstp)6816ca35587Sdholland nlm4_share_4_svc(nlm4_shareargs *argp, nlm4_shareres *result, struct svc_req *rqstp)
6826ca35587Sdholland {
6836ca35587Sdholland 
6846ca35587Sdholland 	memset(result, 0, sizeof(*result));
6856ca35587Sdholland 	result->stat = nlm4_denied;
6866ca35587Sdholland 	return (TRUE);
6876ca35587Sdholland }
6886ca35587Sdholland 
6896ca35587Sdholland bool_t
nlm4_unshare_4_svc(nlm4_shareargs * argp,nlm4_shareres * result,struct svc_req * rqstp)6906ca35587Sdholland nlm4_unshare_4_svc(nlm4_shareargs *argp, nlm4_shareres *result, struct svc_req *rqstp)
6916ca35587Sdholland {
6926ca35587Sdholland 
6936ca35587Sdholland 	memset(result, 0, sizeof(*result));
6946ca35587Sdholland 	result->stat = nlm4_denied;
6956ca35587Sdholland 	return (TRUE);
6966ca35587Sdholland }
6976ca35587Sdholland 
6986ca35587Sdholland bool_t
nlm4_nm_lock_4_svc(nlm4_lockargs * argp,nlm4_res * result,struct svc_req * rqstp)6996ca35587Sdholland nlm4_nm_lock_4_svc(nlm4_lockargs *argp, nlm4_res *result, struct svc_req *rqstp)
7006ca35587Sdholland {
7016ca35587Sdholland 
7026ca35587Sdholland 	nlm_do_lock(argp, result, rqstp, FALSE, NULL);
7036ca35587Sdholland 	return (TRUE);
7046ca35587Sdholland }
7056ca35587Sdholland 
7066ca35587Sdholland bool_t
nlm4_free_all_4_svc(nlm4_notify * argp,void * result,struct svc_req * rqstp)7076ca35587Sdholland nlm4_free_all_4_svc(nlm4_notify *argp, void *result, struct svc_req *rqstp)
7086ca35587Sdholland {
7096ca35587Sdholland 
7106ca35587Sdholland 	nlm_do_free_all(argp);
7116ca35587Sdholland 	return (TRUE);
7126ca35587Sdholland }
7136ca35587Sdholland 
7146ca35587Sdholland int
nlm_prog_4_freeresult(SVCXPRT * transp,xdrproc_t xdr_result,caddr_t result)7156ca35587Sdholland nlm_prog_4_freeresult(SVCXPRT *transp, xdrproc_t xdr_result, caddr_t result)
7166ca35587Sdholland {
7176ca35587Sdholland 
7186ca35587Sdholland 	(void) xdr_free(xdr_result, result);
7196ca35587Sdholland 	return (TRUE);
7206ca35587Sdholland }
721