xref: /illumos-gate/usr/src/stand/lib/fs/nfs/nfs4_xdr.c (revision bbe876c0)
17c478bd9Sstevel@tonic-gate /*
27c478bd9Sstevel@tonic-gate  * CDDL HEADER START
37c478bd9Sstevel@tonic-gate  *
47c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
57c478bd9Sstevel@tonic-gate  * Common Development and Distribution License, Version 1.0 only
67c478bd9Sstevel@tonic-gate  * (the "License").  You may not use this file except in compliance
77c478bd9Sstevel@tonic-gate  * with the License.
87c478bd9Sstevel@tonic-gate  *
97c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
107c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
117c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
127c478bd9Sstevel@tonic-gate  * and limitations under the License.
137c478bd9Sstevel@tonic-gate  *
147c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
157c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
167c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
177c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
187c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
197c478bd9Sstevel@tonic-gate  *
207c478bd9Sstevel@tonic-gate  * CDDL HEADER END
217c478bd9Sstevel@tonic-gate  */
22*bbe876c0SMarcel Telka 
23*bbe876c0SMarcel Telka /*
24*bbe876c0SMarcel Telka  * Copyright 2015 Nexenta Systems, Inc.  All rights reserved.
25*bbe876c0SMarcel Telka  */
26*bbe876c0SMarcel Telka 
277c478bd9Sstevel@tonic-gate /*
287c478bd9Sstevel@tonic-gate  * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
297c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
307c478bd9Sstevel@tonic-gate  */
317c478bd9Sstevel@tonic-gate 
327c478bd9Sstevel@tonic-gate #include <sys/salib.h>
337c478bd9Sstevel@tonic-gate #include <rpc/types.h>
347c478bd9Sstevel@tonic-gate #include <rpc/xdr.h>
357c478bd9Sstevel@tonic-gate #include <rpc/rpc.h>
367c478bd9Sstevel@tonic-gate #include <rpcsvc/nfs4_prot.h>
377c478bd9Sstevel@tonic-gate #include "nfs_inet.h"
387c478bd9Sstevel@tonic-gate 
397c478bd9Sstevel@tonic-gate #define	dprintf if (boothowto & RB_DEBUG) printf
407c478bd9Sstevel@tonic-gate 
417c478bd9Sstevel@tonic-gate /*
427c478bd9Sstevel@tonic-gate  * XDR routines for NFSv4 ops.
437c478bd9Sstevel@tonic-gate  */
447c478bd9Sstevel@tonic-gate static bool_t
xdr_b_utf8string(XDR * xdrs,utf8string * objp)457c478bd9Sstevel@tonic-gate xdr_b_utf8string(XDR *xdrs, utf8string *objp)
467c478bd9Sstevel@tonic-gate {
477c478bd9Sstevel@tonic-gate 	return (xdr_bytes(xdrs, (char **)&objp->utf8string_val,
48*bbe876c0SMarcel Telka 	    (uint_t *)&objp->utf8string_len, NFS4_MAX_UTF8STRING));
497c478bd9Sstevel@tonic-gate }
507c478bd9Sstevel@tonic-gate 
517c478bd9Sstevel@tonic-gate static bool_t
xdr_nfs_bfh4(XDR * xdrs,struct nfs_bfh4 * objp)527c478bd9Sstevel@tonic-gate xdr_nfs_bfh4(XDR *xdrs, struct nfs_bfh4 *objp)
537c478bd9Sstevel@tonic-gate {
547c478bd9Sstevel@tonic-gate 	char *data = (char *)&objp->data;
557c478bd9Sstevel@tonic-gate 	return (xdr_bytes(xdrs, (char **)&data, (uint_t *)&objp->len,
56*bbe876c0SMarcel Telka 	    NFS4_FHSIZE));
577c478bd9Sstevel@tonic-gate }
587c478bd9Sstevel@tonic-gate 
597c478bd9Sstevel@tonic-gate static bool_t
xdr_b_putfh4_args(XDR * xdrs,putfh4arg_t * objp)607c478bd9Sstevel@tonic-gate xdr_b_putfh4_args(XDR *xdrs, putfh4arg_t *objp)
617c478bd9Sstevel@tonic-gate {
627c478bd9Sstevel@tonic-gate 	if (!xdr_u_int(xdrs, (uint_t *)&objp->pf_opnum))
637c478bd9Sstevel@tonic-gate 		return (FALSE);
647c478bd9Sstevel@tonic-gate 	return (xdr_nfs_bfh4(xdrs, (struct nfs_bfh4 *)&objp->pf_filehandle));
657c478bd9Sstevel@tonic-gate }
667c478bd9Sstevel@tonic-gate 
677c478bd9Sstevel@tonic-gate /*
687c478bd9Sstevel@tonic-gate  * Common xdr routines for compound.  Let the specific op routines handle
697c478bd9Sstevel@tonic-gate  * op specific portions of the compound.
707c478bd9Sstevel@tonic-gate  */
717c478bd9Sstevel@tonic-gate static bool_t
xdr_b_compound_args(XDR * xdrs,b_compound_t * objp)727c478bd9Sstevel@tonic-gate xdr_b_compound_args(XDR *xdrs, b_compound_t *objp)
737c478bd9Sstevel@tonic-gate {
747c478bd9Sstevel@tonic-gate 	if (!xdr_b_utf8string(xdrs, &objp->ca_tag)) {
757c478bd9Sstevel@tonic-gate 		return (FALSE);
767c478bd9Sstevel@tonic-gate 	}
777c478bd9Sstevel@tonic-gate 	if (!xdr_u_int(xdrs, &objp->ca_minorversion))
787c478bd9Sstevel@tonic-gate 		return (FALSE);
797c478bd9Sstevel@tonic-gate 	if (!xdr_u_int(xdrs, &objp->ca_argarray_len))
807c478bd9Sstevel@tonic-gate 		return (FALSE);
817c478bd9Sstevel@tonic-gate 	if (objp->ca_isputrootfh)
827c478bd9Sstevel@tonic-gate 		return (xdr_u_int(xdrs, &objp->ca_opputfh.pf_opnum));
837c478bd9Sstevel@tonic-gate 	return (xdr_b_putfh4_args(xdrs, &objp->ca_opputfh));
847c478bd9Sstevel@tonic-gate }
857c478bd9Sstevel@tonic-gate 
867c478bd9Sstevel@tonic-gate static bool_t
xdr_b_compound_res(XDR * xdrs,b_compound_t * objp)877c478bd9Sstevel@tonic-gate xdr_b_compound_res(XDR *xdrs, b_compound_t *objp)
887c478bd9Sstevel@tonic-gate {
897c478bd9Sstevel@tonic-gate 	if (!xdr_enum(xdrs, (enum_t *)&objp->cr_status))
907c478bd9Sstevel@tonic-gate 		return (FALSE);
917c478bd9Sstevel@tonic-gate 	if (!xdr_b_utf8string(xdrs, &objp->cr_tag))
927c478bd9Sstevel@tonic-gate 		return (FALSE);
937c478bd9Sstevel@tonic-gate 	if (!xdr_u_int(xdrs, &objp->cr_resarray_len))
947c478bd9Sstevel@tonic-gate 		return (FALSE);
957c478bd9Sstevel@tonic-gate 	if (!xdr_u_int(xdrs, &objp->cr_opputfh))
967c478bd9Sstevel@tonic-gate 		return (FALSE);
977c478bd9Sstevel@tonic-gate 	return (xdr_enum(xdrs, (enum_t *)&objp->cr_putfh_status));
987c478bd9Sstevel@tonic-gate }
997c478bd9Sstevel@tonic-gate 
1007c478bd9Sstevel@tonic-gate static bool_t
xdr_b_bitmap4(XDR * xdrs,b_bitmap4_t * objp)1017c478bd9Sstevel@tonic-gate xdr_b_bitmap4(XDR *xdrs, b_bitmap4_t *objp)
1027c478bd9Sstevel@tonic-gate {
1037c478bd9Sstevel@tonic-gate 	char *arp = (char *)&objp->b_bitmap_val;
1047c478bd9Sstevel@tonic-gate 	return (xdr_array(xdrs, (char **)&arp,
105*bbe876c0SMarcel Telka 	    (uint_t *)&objp->b_bitmap_len, ~0,
106*bbe876c0SMarcel Telka 	    sizeof (uint_t), (xdrproc_t)xdr_u_int));
1077c478bd9Sstevel@tonic-gate }
1087c478bd9Sstevel@tonic-gate 
1097c478bd9Sstevel@tonic-gate static bool_t
xdr_b_stateid4(XDR * xdrs,stateid4 * objp)1107c478bd9Sstevel@tonic-gate xdr_b_stateid4(XDR *xdrs, stateid4 *objp)
1117c478bd9Sstevel@tonic-gate {
1127c478bd9Sstevel@tonic-gate 	if (!xdr_u_int(xdrs, (uint_t *)&objp->seqid))
1137c478bd9Sstevel@tonic-gate 		return (FALSE);
114*bbe876c0SMarcel Telka 	return (xdr_opaque(xdrs, objp->other, NFS4_OTHER_SIZE));
1157c478bd9Sstevel@tonic-gate }
1167c478bd9Sstevel@tonic-gate 
1177c478bd9Sstevel@tonic-gate bool_t
xdr_getattr4_args(XDR * xdrs,getattr4arg_t * objp)1187c478bd9Sstevel@tonic-gate xdr_getattr4_args(XDR *xdrs, getattr4arg_t *objp)
1197c478bd9Sstevel@tonic-gate {
1207c478bd9Sstevel@tonic-gate 	if (!xdr_b_compound_args(xdrs, (b_compound_t *)&objp->ga_arg))
1217c478bd9Sstevel@tonic-gate 		return (FALSE);
1227c478bd9Sstevel@tonic-gate 	if (!xdr_u_int(xdrs, (uint_t *)&objp->ga_opgetattr))
1237c478bd9Sstevel@tonic-gate 		return (FALSE);
1247c478bd9Sstevel@tonic-gate 	return (xdr_b_bitmap4(xdrs, (b_bitmap4_t *)&objp->ga_attr_req));
1257c478bd9Sstevel@tonic-gate }
1267c478bd9Sstevel@tonic-gate 
1277c478bd9Sstevel@tonic-gate static bool_t
xdr_b_getattr_res_common(XDR * xdrs,getattrres_cmn_t * objp)1287c478bd9Sstevel@tonic-gate xdr_b_getattr_res_common(XDR *xdrs, getattrres_cmn_t *objp)
1297c478bd9Sstevel@tonic-gate {
1307c478bd9Sstevel@tonic-gate 	if (!xdr_u_int(xdrs, (uint_t *)&objp->gc_opgetattr))
1317c478bd9Sstevel@tonic-gate 		return (FALSE);
1327c478bd9Sstevel@tonic-gate 	if (!xdr_enum(xdrs, (enum_t *)&objp->gc_attr_status))
1337c478bd9Sstevel@tonic-gate 		return (FALSE);
1347c478bd9Sstevel@tonic-gate 
1357c478bd9Sstevel@tonic-gate 	/*
1367c478bd9Sstevel@tonic-gate 	 * If the getattr suceeded, proceed and begin to decode the attributes.
1377c478bd9Sstevel@tonic-gate 	 */
1387c478bd9Sstevel@tonic-gate 	if (objp->gc_attr_status == NFS4_OK) {
1397c478bd9Sstevel@tonic-gate 		char		attrvals[sizeof (b_fattr4_t)];
1407c478bd9Sstevel@tonic-gate 		char		*ap = attrvals;
1417c478bd9Sstevel@tonic-gate 
1427c478bd9Sstevel@tonic-gate 		if (!xdr_b_bitmap4(xdrs, (b_bitmap4_t *)&objp->gc_retattr))
1437c478bd9Sstevel@tonic-gate 			return (FALSE);
1447c478bd9Sstevel@tonic-gate 
1457c478bd9Sstevel@tonic-gate 		bzero(&attrvals, sizeof (attrvals));
1467c478bd9Sstevel@tonic-gate 		if (!xdr_bytes(xdrs, (char **)&ap,
147*bbe876c0SMarcel Telka 		    (uint_t *)&objp->gc_attrlist_len, sizeof (b_fattr4_t)))
1487c478bd9Sstevel@tonic-gate 			return (FALSE);
1497c478bd9Sstevel@tonic-gate #ifdef DEBUG
1507c478bd9Sstevel@tonic-gate 		printf("xdr_b_getattr_res_common: attrlist_len = %d\n",
151*bbe876c0SMarcel Telka 		    objp->gc_attrlist_len);
1527c478bd9Sstevel@tonic-gate #endif
1537c478bd9Sstevel@tonic-gate 		/*
1547c478bd9Sstevel@tonic-gate 		 * Go through the bitmap and see if the server
1557c478bd9Sstevel@tonic-gate 		 * sent us anything.
1567c478bd9Sstevel@tonic-gate 		 */
1577c478bd9Sstevel@tonic-gate 		if (objp->gc_attrlist_len > 0) {
1587c478bd9Sstevel@tonic-gate 			XDR		mxdrs;
1597c478bd9Sstevel@tonic-gate 			b_fattr4_t	*fattrp = &objp->gc_attrs;
1607c478bd9Sstevel@tonic-gate 			attr4_bitmap1_t bitmap1;
1617c478bd9Sstevel@tonic-gate 			attr4_bitmap2_t bitmap2;
1627c478bd9Sstevel@tonic-gate #ifdef DEBUG
1637c478bd9Sstevel@tonic-gate 			int i;
1647c478bd9Sstevel@tonic-gate 
1657c478bd9Sstevel@tonic-gate 			printf("dumping contents of attr buffer\n");
1667c478bd9Sstevel@tonic-gate 			for (i = 0; i < objp->gc_attrlist_len; i++) {
1677c478bd9Sstevel@tonic-gate 				printf("[%d] = 0x%x\n", i, ap[i]);
1687c478bd9Sstevel@tonic-gate 			}
1697c478bd9Sstevel@tonic-gate #endif
1707c478bd9Sstevel@tonic-gate 			bitmap1.word = objp->gc_retattr.b_bitmap_val[0];
1717c478bd9Sstevel@tonic-gate 			bitmap2.word = objp->gc_retattr.b_bitmap_val[1];
1727c478bd9Sstevel@tonic-gate 
1737c478bd9Sstevel@tonic-gate #ifdef DEBUG
1747c478bd9Sstevel@tonic-gate 			printf("xdr_b_getattr_res_common: bitmap1 = %d "
175*bbe876c0SMarcel Telka 			    "			bitmap2 = %d\n",
176*bbe876c0SMarcel Telka 			    bitmap1.word, bitmap2.word);
1777c478bd9Sstevel@tonic-gate #endif
1787c478bd9Sstevel@tonic-gate 			xdrmem_create(&mxdrs, ap, objp->gc_attrlist_len,
179*bbe876c0SMarcel Telka 			    XDR_DECODE);
1807c478bd9Sstevel@tonic-gate 
1817c478bd9Sstevel@tonic-gate 			/*
1827c478bd9Sstevel@tonic-gate 			 * Start with the first bitmap
1837c478bd9Sstevel@tonic-gate 			 */
1847c478bd9Sstevel@tonic-gate 			if (bitmap1.word > 0) {
1857c478bd9Sstevel@tonic-gate 				if (bitmap1.bm_supported_attrs) {
1867c478bd9Sstevel@tonic-gate 					if (!xdr_b_bitmap4(&mxdrs,
187*bbe876c0SMarcel Telka 					    (b_bitmap4_t *)&fattrp->
188*bbe876c0SMarcel Telka 					    b_supported_attrs))
1897c478bd9Sstevel@tonic-gate 						return (FALSE);
1907c478bd9Sstevel@tonic-gate 				}
1917c478bd9Sstevel@tonic-gate 
1927c478bd9Sstevel@tonic-gate 				if (bitmap1.bm_fattr4_type) {
1937c478bd9Sstevel@tonic-gate 					if (!xdr_enum(&mxdrs,
1947c478bd9Sstevel@tonic-gate 				(enum_t *)&fattrp->b_fattr4_type)) {
1957c478bd9Sstevel@tonic-gate 						return (FALSE);
1967c478bd9Sstevel@tonic-gate 					}
1977c478bd9Sstevel@tonic-gate 				}
1987c478bd9Sstevel@tonic-gate 				if (bitmap1.bm_fattr4_size) {
1997c478bd9Sstevel@tonic-gate 					if (!xdr_u_longlong_t(&mxdrs,
200*bbe876c0SMarcel Telka 					    (u_longlong_t *)&fattrp->
201*bbe876c0SMarcel Telka 					    b_fattr4_size))
2027c478bd9Sstevel@tonic-gate 						return (FALSE);
2037c478bd9Sstevel@tonic-gate 				}
2047c478bd9Sstevel@tonic-gate 
2057c478bd9Sstevel@tonic-gate 				if (bitmap1.bm_fattr4_fsid) {
2067c478bd9Sstevel@tonic-gate 					if (!xdr_u_longlong_t(&mxdrs,
207*bbe876c0SMarcel Telka 					    (u_longlong_t *)&fattrp->
208*bbe876c0SMarcel Telka 					    b_fattr4_fsid.major))
2097c478bd9Sstevel@tonic-gate 						return (FALSE);
2107c478bd9Sstevel@tonic-gate 
2117c478bd9Sstevel@tonic-gate 					if (!xdr_u_longlong_t(&mxdrs,
212*bbe876c0SMarcel Telka 					    (u_longlong_t *)&fattrp->
213*bbe876c0SMarcel Telka 					    b_fattr4_fsid.minor))
2147c478bd9Sstevel@tonic-gate 						return (FALSE);
2157c478bd9Sstevel@tonic-gate 				}
2167c478bd9Sstevel@tonic-gate 				if (bitmap1.bm_fattr4_filehandle) {
2177c478bd9Sstevel@tonic-gate 					if (!xdr_nfs_bfh4(&mxdrs,
218*bbe876c0SMarcel Telka 					    (struct nfs_bfh4 *)&fattrp->
219*bbe876c0SMarcel Telka 					    b_fattr4_filehandle))
2207c478bd9Sstevel@tonic-gate 						return (FALSE);
2217c478bd9Sstevel@tonic-gate 				}
2227c478bd9Sstevel@tonic-gate 				if (bitmap1.bm_fattr4_fileid) {
2237c478bd9Sstevel@tonic-gate 					if (!xdr_u_longlong_t(&mxdrs,
224*bbe876c0SMarcel Telka 					    (u_longlong_t *)&fattrp->
225*bbe876c0SMarcel Telka 					    b_fattr4_fileid))
2267c478bd9Sstevel@tonic-gate 						return (FALSE);
2277c478bd9Sstevel@tonic-gate 				}
2287c478bd9Sstevel@tonic-gate 			}
2297c478bd9Sstevel@tonic-gate 
2307c478bd9Sstevel@tonic-gate 			/*
2317c478bd9Sstevel@tonic-gate 			 * Now the second bitmap
2327c478bd9Sstevel@tonic-gate 			 */
2337c478bd9Sstevel@tonic-gate 			if (bitmap2.word > 0) {
2347c478bd9Sstevel@tonic-gate 				if (bitmap2.bm_fattr4_mode) {
235*bbe876c0SMarcel Telka 					if (!xdr_u_int(&mxdrs, (uint_t *)&objp->
236*bbe876c0SMarcel Telka 					    gc_attrs.b_fattr4_mode))
2377c478bd9Sstevel@tonic-gate 						return (FALSE);
2387c478bd9Sstevel@tonic-gate 				}
2397c478bd9Sstevel@tonic-gate 
2407c478bd9Sstevel@tonic-gate 				if (bitmap2.bm_fattr4_time_access) {
2417c478bd9Sstevel@tonic-gate 					if (!xdr_longlong_t(&mxdrs,
242*bbe876c0SMarcel Telka 					    (longlong_t *)&objp->gc_attrs.
243*bbe876c0SMarcel Telka 					    b_fattr4_time_access.seconds))
2447c478bd9Sstevel@tonic-gate 						return (FALSE);
2457c478bd9Sstevel@tonic-gate 					if (!xdr_u_int(&mxdrs,
246*bbe876c0SMarcel Telka 					    (uint_t *)&objp->gc_attrs.
247*bbe876c0SMarcel Telka 					    b_fattr4_time_access.nseconds))
2487c478bd9Sstevel@tonic-gate 						return (FALSE);
2497c478bd9Sstevel@tonic-gate 				}
2507c478bd9Sstevel@tonic-gate 
2517c478bd9Sstevel@tonic-gate 				if (bitmap2.bm_fattr4_time_metadata) {
2527c478bd9Sstevel@tonic-gate 					if (!xdr_longlong_t(&mxdrs,
253*bbe876c0SMarcel Telka 					    (longlong_t *)&objp->gc_attrs.
254*bbe876c0SMarcel Telka 					    b_fattr4_time_metadata.seconds))
2557c478bd9Sstevel@tonic-gate 						return (FALSE);
2567c478bd9Sstevel@tonic-gate 					if (!xdr_u_int(&mxdrs,
257*bbe876c0SMarcel Telka 					    (uint_t *)&objp->gc_attrs.
258*bbe876c0SMarcel Telka 					    b_fattr4_time_metadata.nseconds))
2597c478bd9Sstevel@tonic-gate 						return (FALSE);
2607c478bd9Sstevel@tonic-gate 				}
2617c478bd9Sstevel@tonic-gate 
2627c478bd9Sstevel@tonic-gate 				if (bitmap2.bm_fattr4_time_modify) {
2637c478bd9Sstevel@tonic-gate 					if (!xdr_longlong_t(&mxdrs,
264*bbe876c0SMarcel Telka 					    (longlong_t *)&objp->gc_attrs.
265*bbe876c0SMarcel Telka 					    b_fattr4_time_modify.seconds))
2667c478bd9Sstevel@tonic-gate 						return (FALSE);
2677c478bd9Sstevel@tonic-gate 					if (!xdr_u_int(&mxdrs,
268*bbe876c0SMarcel Telka 					    (uint_t *)&objp->gc_attrs.
269*bbe876c0SMarcel Telka 					    b_fattr4_time_modify.nseconds))
2707c478bd9Sstevel@tonic-gate 						return (FALSE);
2717c478bd9Sstevel@tonic-gate 				}
2727c478bd9Sstevel@tonic-gate 			}
2737c478bd9Sstevel@tonic-gate 		}
2747c478bd9Sstevel@tonic-gate 	}
2757c478bd9Sstevel@tonic-gate 	return (TRUE);
2767c478bd9Sstevel@tonic-gate }
2777c478bd9Sstevel@tonic-gate 
2787c478bd9Sstevel@tonic-gate bool_t
xdr_getattr4_res(XDR * xdrs,getattr4res_t * objp)2797c478bd9Sstevel@tonic-gate xdr_getattr4_res(XDR *xdrs, getattr4res_t *objp)
2807c478bd9Sstevel@tonic-gate {
2817c478bd9Sstevel@tonic-gate 	if (!xdr_b_compound_res(xdrs, (b_compound_t *)&objp->gr_res))
2827c478bd9Sstevel@tonic-gate 		return (FALSE);
2837c478bd9Sstevel@tonic-gate 	return (xdr_b_getattr_res_common(xdrs,
284*bbe876c0SMarcel Telka 	    (getattrres_cmn_t *)&objp->gr_cmn));
2857c478bd9Sstevel@tonic-gate }
2867c478bd9Sstevel@tonic-gate 
2877c478bd9Sstevel@tonic-gate bool_t
xdr_lookup4_args(XDR * xdrs,lookup4arg_t * objp)2887c478bd9Sstevel@tonic-gate xdr_lookup4_args(XDR *xdrs, lookup4arg_t *objp)
2897c478bd9Sstevel@tonic-gate {
2907c478bd9Sstevel@tonic-gate 	if (!xdr_b_compound_args(xdrs, (b_compound_t *)&objp->la_arg))
2917c478bd9Sstevel@tonic-gate 		return (FALSE);
2927c478bd9Sstevel@tonic-gate 	if (!xdr_u_int(xdrs, (uint_t *)&objp->la_oplookup))
2937c478bd9Sstevel@tonic-gate 		return (FALSE);
2947c478bd9Sstevel@tonic-gate 	if (!xdr_b_utf8string(xdrs, (utf8string *)&objp->la_pathname))
2957c478bd9Sstevel@tonic-gate 		return (FALSE);
2967c478bd9Sstevel@tonic-gate 	if (!xdr_u_int(xdrs, (uint_t *)&objp->la_opgetattr))
2977c478bd9Sstevel@tonic-gate 		return (FALSE);
2987c478bd9Sstevel@tonic-gate 	return (xdr_b_bitmap4(xdrs, (b_bitmap4_t *)&objp->la_attr_req));
2997c478bd9Sstevel@tonic-gate }
3007c478bd9Sstevel@tonic-gate 
3017c478bd9Sstevel@tonic-gate bool_t
xdr_lookup4_res(XDR * xdrs,lookup4res_t * objp)3027c478bd9Sstevel@tonic-gate xdr_lookup4_res(XDR *xdrs, lookup4res_t *objp)
3037c478bd9Sstevel@tonic-gate {
3047c478bd9Sstevel@tonic-gate 	if (!xdr_b_compound_res(xdrs, (b_compound_t *)&objp->lr_res))
3057c478bd9Sstevel@tonic-gate 		return (FALSE);
3067c478bd9Sstevel@tonic-gate 	if (!xdr_u_int(xdrs, (uint_t *)&objp->lr_oplookup))
3077c478bd9Sstevel@tonic-gate 		return (FALSE);
3087c478bd9Sstevel@tonic-gate 	if (!xdr_enum(xdrs, (enum_t *)&objp->lr_lookup_status))
3097c478bd9Sstevel@tonic-gate 		return (FALSE);
3107c478bd9Sstevel@tonic-gate 	if (objp->lr_lookup_status == NFS4_OK) {
3117c478bd9Sstevel@tonic-gate 		return (xdr_b_getattr_res_common(xdrs,
312*bbe876c0SMarcel Telka 		    (getattrres_cmn_t *)&objp->lr_gcmn));
3137c478bd9Sstevel@tonic-gate 	}
3147c478bd9Sstevel@tonic-gate 	return (TRUE);
3157c478bd9Sstevel@tonic-gate }
3167c478bd9Sstevel@tonic-gate 
3177c478bd9Sstevel@tonic-gate bool_t
xdr_lookupp4_args(XDR * xdrs,lookupp4arg_t * objp)3187c478bd9Sstevel@tonic-gate xdr_lookupp4_args(XDR *xdrs, lookupp4arg_t *objp)
3197c478bd9Sstevel@tonic-gate {
3207c478bd9Sstevel@tonic-gate 	if (!xdr_b_compound_args(xdrs, (b_compound_t *)&objp->la_arg))
3217c478bd9Sstevel@tonic-gate 		return (FALSE);
3227c478bd9Sstevel@tonic-gate 	if (!xdr_u_int(xdrs, (uint_t *)&objp->la_oplookupp))
3237c478bd9Sstevel@tonic-gate 		return (FALSE);
3247c478bd9Sstevel@tonic-gate 	if (!xdr_u_int(xdrs, (uint_t *)&objp->la_opgetattr))
3257c478bd9Sstevel@tonic-gate 		return (FALSE);
3267c478bd9Sstevel@tonic-gate 	return (xdr_b_bitmap4(xdrs, (b_bitmap4_t *)&objp->la_attr_req));
3277c478bd9Sstevel@tonic-gate }
3287c478bd9Sstevel@tonic-gate 
3297c478bd9Sstevel@tonic-gate bool_t
xdr_read4_args(XDR * xdrs,read4arg_t * objp)3307c478bd9Sstevel@tonic-gate xdr_read4_args(XDR *xdrs, read4arg_t *objp)
3317c478bd9Sstevel@tonic-gate {
3327c478bd9Sstevel@tonic-gate 	if (!xdr_b_compound_args(xdrs, (b_compound_t *)&objp->r_arg))
3337c478bd9Sstevel@tonic-gate 		return (FALSE);
3347c478bd9Sstevel@tonic-gate 	if (!xdr_u_int(xdrs, (uint_t *)&objp->r_opread))
3357c478bd9Sstevel@tonic-gate 		return (FALSE);
3367c478bd9Sstevel@tonic-gate 	if (!xdr_b_stateid4(xdrs, (stateid4 *)&objp->r_stateid))
3377c478bd9Sstevel@tonic-gate 		return (FALSE);
3387c478bd9Sstevel@tonic-gate 	if (!xdr_u_longlong_t(xdrs, (u_longlong_t *)&objp->r_offset))
3397c478bd9Sstevel@tonic-gate 		return (FALSE);
3407c478bd9Sstevel@tonic-gate 	return (xdr_u_int(xdrs, (uint_t *)&objp->r_count));
3417c478bd9Sstevel@tonic-gate }
3427c478bd9Sstevel@tonic-gate 
3437c478bd9Sstevel@tonic-gate bool_t
xdr_read4_res(XDR * xdrs,read4res_t * objp)3447c478bd9Sstevel@tonic-gate xdr_read4_res(XDR *xdrs, read4res_t *objp)
3457c478bd9Sstevel@tonic-gate {
3467c478bd9Sstevel@tonic-gate 	if (!xdr_b_compound_res(xdrs, (b_compound_t *)&objp->r_res))
3477c478bd9Sstevel@tonic-gate 		return (FALSE);
3487c478bd9Sstevel@tonic-gate 	if (!xdr_u_int(xdrs, (uint_t *)&objp->r_opread))
3497c478bd9Sstevel@tonic-gate 		return (FALSE);
3507c478bd9Sstevel@tonic-gate 	if (!xdr_enum(xdrs, (enum_t *)&objp->r_status))
3517c478bd9Sstevel@tonic-gate 		return (FALSE);
3527c478bd9Sstevel@tonic-gate 	if (objp->r_status == NFS4_OK) {
3537c478bd9Sstevel@tonic-gate 		if (!xdr_bool(xdrs, (bool_t *)&objp->r_eof))
3547c478bd9Sstevel@tonic-gate 			return (FALSE);
3557c478bd9Sstevel@tonic-gate 		return (xdr_bytes(xdrs, (char **)&objp->r_data_val,
356*bbe876c0SMarcel Telka 		    (uint_t *)&objp->r_data_len, ~0));
3577c478bd9Sstevel@tonic-gate 	}
3587c478bd9Sstevel@tonic-gate 	return (TRUE);
3597c478bd9Sstevel@tonic-gate }
3607c478bd9Sstevel@tonic-gate 
3617c478bd9Sstevel@tonic-gate bool_t
xdr_readdir4_args(XDR * xdrs,readdir4arg_t * objp)3627c478bd9Sstevel@tonic-gate xdr_readdir4_args(XDR *xdrs, readdir4arg_t *objp)
3637c478bd9Sstevel@tonic-gate {
3647c478bd9Sstevel@tonic-gate 	if (!xdr_b_compound_args(xdrs, (b_compound_t *)&objp->rd_arg))
3657c478bd9Sstevel@tonic-gate 		return (FALSE);
3667c478bd9Sstevel@tonic-gate 	if (!xdr_u_int(xdrs, (uint_t *)&objp->rd_opreaddir))
3677c478bd9Sstevel@tonic-gate 		return (FALSE);
3687c478bd9Sstevel@tonic-gate 	if (!xdr_u_longlong_t(xdrs, (u_longlong_t *)&objp->rd_cookie))
3697c478bd9Sstevel@tonic-gate 		return (FALSE);
3707c478bd9Sstevel@tonic-gate 	if (!xdr_opaque(xdrs, objp->rd_cookieverf, NFS4_VERIFIER_SIZE))
3717c478bd9Sstevel@tonic-gate 		return (FALSE);
3727c478bd9Sstevel@tonic-gate 	if (!xdr_u_int(xdrs, (uint_t *)&objp->rd_dircount))
3737c478bd9Sstevel@tonic-gate 		return (FALSE);
3747c478bd9Sstevel@tonic-gate 	if (!xdr_u_int(xdrs, (uint_t *)&objp->rd_maxcount))
3757c478bd9Sstevel@tonic-gate 		return (FALSE);
3767c478bd9Sstevel@tonic-gate 	return (xdr_b_bitmap4(xdrs, (b_bitmap4_t *)&objp->rd_attr_req));
3777c478bd9Sstevel@tonic-gate }
3787c478bd9Sstevel@tonic-gate 
3797c478bd9Sstevel@tonic-gate static bool_t
xdr_b_entry4(XDR * xdrs,b_entry4_t * objp)3807c478bd9Sstevel@tonic-gate xdr_b_entry4(XDR *xdrs, b_entry4_t *objp)
3817c478bd9Sstevel@tonic-gate {
3827c478bd9Sstevel@tonic-gate 	uint_t		attrlen;
3837c478bd9Sstevel@tonic-gate 	char		attrvals[sizeof (b_fattr4_t)];
3847c478bd9Sstevel@tonic-gate 	char		*ap = attrvals;
3857c478bd9Sstevel@tonic-gate 	XDR		mxdrs;
3867c478bd9Sstevel@tonic-gate 
3877c478bd9Sstevel@tonic-gate 	if (!xdr_u_longlong_t(xdrs, (u_longlong_t *)&objp->b_cookie))
3887c478bd9Sstevel@tonic-gate 		return (FALSE);
3897c478bd9Sstevel@tonic-gate 	if (!xdr_b_utf8string(xdrs, &objp->b_name))
3907c478bd9Sstevel@tonic-gate 		return (FALSE);
3917c478bd9Sstevel@tonic-gate 
3927c478bd9Sstevel@tonic-gate 	bzero(&attrvals, sizeof (attrvals));
3937c478bd9Sstevel@tonic-gate 	if (!xdr_bytes(xdrs, (char **)&ap, (uint_t *)&attrlen,
394*bbe876c0SMarcel Telka 	    sizeof (b_fattr4_t)))
3957c478bd9Sstevel@tonic-gate 		return (FALSE);
3967c478bd9Sstevel@tonic-gate 
3977c478bd9Sstevel@tonic-gate 	/*
3987c478bd9Sstevel@tonic-gate 	 * We are *only* interested in the fileid, so just extract that.
3997c478bd9Sstevel@tonic-gate 	 */
4007c478bd9Sstevel@tonic-gate 	if (attrlen < sizeof (uint64_t))
4017c478bd9Sstevel@tonic-gate 		return (FALSE);
4027c478bd9Sstevel@tonic-gate 
4037c478bd9Sstevel@tonic-gate 	xdrmem_create(&mxdrs, ap, attrlen, XDR_DECODE);
4047c478bd9Sstevel@tonic-gate 
4057c478bd9Sstevel@tonic-gate 	if (!xdr_u_longlong_t(&mxdrs, (u_longlong_t *)&objp->b_fileid))
4067c478bd9Sstevel@tonic-gate 		return (FALSE);
4077c478bd9Sstevel@tonic-gate 	return (xdr_pointer(xdrs, (char **)&objp->b_nextentry,
408*bbe876c0SMarcel Telka 	    sizeof (b_entry4_t), (xdrproc_t)xdr_b_entry4));
4097c478bd9Sstevel@tonic-gate }
4107c478bd9Sstevel@tonic-gate 
4117c478bd9Sstevel@tonic-gate bool_t
xdr_readdir4_res(XDR * xdrs,readdir4res_t * objp)4127c478bd9Sstevel@tonic-gate xdr_readdir4_res(XDR *xdrs, readdir4res_t *objp)
4137c478bd9Sstevel@tonic-gate {
4147c478bd9Sstevel@tonic-gate 	if (!xdr_b_compound_res(xdrs, (b_compound_t *)&objp->rd_res))
4157c478bd9Sstevel@tonic-gate 		return (FALSE);
4167c478bd9Sstevel@tonic-gate 	if (!xdr_u_int(xdrs, (uint_t *)&objp->rd_opreaddir))
4177c478bd9Sstevel@tonic-gate 		return (FALSE);
4187c478bd9Sstevel@tonic-gate 	if (!xdr_enum(xdrs, (enum_t *)&objp->rd_status))
4197c478bd9Sstevel@tonic-gate 		return (FALSE);
4207c478bd9Sstevel@tonic-gate 	if (objp->rd_status == NFS4_OK) {
4217c478bd9Sstevel@tonic-gate 		if (!xdr_opaque(xdrs, objp->rd_cookieverf, NFS4_VERIFIER_SIZE))
4227c478bd9Sstevel@tonic-gate 			return (FALSE);
4237c478bd9Sstevel@tonic-gate 		if (!xdr_pointer(xdrs, (char **)&objp->rd_entries,
424*bbe876c0SMarcel Telka 		    sizeof (b_entry4_t), (xdrproc_t)xdr_b_entry4))
4257c478bd9Sstevel@tonic-gate 			return (FALSE);
4267c478bd9Sstevel@tonic-gate 		return (xdr_bool(xdrs, &objp->rd_eof));
4277c478bd9Sstevel@tonic-gate 	}
4287c478bd9Sstevel@tonic-gate 	return (TRUE);
4297c478bd9Sstevel@tonic-gate }
4307c478bd9Sstevel@tonic-gate 
4317c478bd9Sstevel@tonic-gate bool_t
xdr_readlink4_args(XDR * xdrs,readlink4arg_t * objp)4327c478bd9Sstevel@tonic-gate xdr_readlink4_args(XDR *xdrs, readlink4arg_t *objp)
4337c478bd9Sstevel@tonic-gate {
4347c478bd9Sstevel@tonic-gate 	if (!xdr_b_compound_args(xdrs, (b_compound_t *)&objp->rl_arg))
4357c478bd9Sstevel@tonic-gate 		return (FALSE);
4367c478bd9Sstevel@tonic-gate 	return (xdr_u_int(xdrs, (uint_t *)&objp->rl_opreadlink));
4377c478bd9Sstevel@tonic-gate }
4387c478bd9Sstevel@tonic-gate 
4397c478bd9Sstevel@tonic-gate bool_t
xdr_readlink4_res(XDR * xdrs,readlink4res_t * objp)4407c478bd9Sstevel@tonic-gate xdr_readlink4_res(XDR *xdrs, readlink4res_t *objp)
4417c478bd9Sstevel@tonic-gate {
4427c478bd9Sstevel@tonic-gate 	if (!xdr_b_compound_res(xdrs, (b_compound_t *)&objp->rl_res))
4437c478bd9Sstevel@tonic-gate 		return (FALSE);
4447c478bd9Sstevel@tonic-gate 	if (!xdr_u_int(xdrs, (uint_t *)&objp->rl_opreadlink))
4457c478bd9Sstevel@tonic-gate 		return (FALSE);
4467c478bd9Sstevel@tonic-gate 	if (!xdr_enum(xdrs, (enum_t *)&objp->rl_status))
4477c478bd9Sstevel@tonic-gate 		return (FALSE);
4487c478bd9Sstevel@tonic-gate 	if (objp->rl_status == NFS4_OK)
4497c478bd9Sstevel@tonic-gate 		return (xdr_b_utf8string(xdrs, (utf8string *)&objp->rl_link));
4507c478bd9Sstevel@tonic-gate 	return (TRUE);
4517c478bd9Sstevel@tonic-gate }
452