xref: /illumos-gate/usr/src/uts/common/fs/nfs/nfs4_xdr.c (revision 7c478bd9)
1*7c478bd9Sstevel@tonic-gate /*
2*7c478bd9Sstevel@tonic-gate  * CDDL HEADER START
3*7c478bd9Sstevel@tonic-gate  *
4*7c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5*7c478bd9Sstevel@tonic-gate  * Common Development and Distribution License, Version 1.0 only
6*7c478bd9Sstevel@tonic-gate  * (the "License").  You may not use this file except in compliance
7*7c478bd9Sstevel@tonic-gate  * with the License.
8*7c478bd9Sstevel@tonic-gate  *
9*7c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10*7c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
11*7c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
12*7c478bd9Sstevel@tonic-gate  * and limitations under the License.
13*7c478bd9Sstevel@tonic-gate  *
14*7c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
15*7c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16*7c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
17*7c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
18*7c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
19*7c478bd9Sstevel@tonic-gate  *
20*7c478bd9Sstevel@tonic-gate  * CDDL HEADER END
21*7c478bd9Sstevel@tonic-gate  */
22*7c478bd9Sstevel@tonic-gate /*
23*7c478bd9Sstevel@tonic-gate  *	Copyright 2005 Sun Microsystems, Inc.
24*7c478bd9Sstevel@tonic-gate  *	All rights reserved.  Use is subject to license terms.
25*7c478bd9Sstevel@tonic-gate  */
26*7c478bd9Sstevel@tonic-gate 
27*7c478bd9Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
28*7c478bd9Sstevel@tonic-gate 
29*7c478bd9Sstevel@tonic-gate /*
30*7c478bd9Sstevel@tonic-gate  * A handcoded version based on the original rpcgen code.
31*7c478bd9Sstevel@tonic-gate  *
32*7c478bd9Sstevel@tonic-gate  * Note: All future NFS4 protocol changes should be added by hand
33*7c478bd9Sstevel@tonic-gate  * to this file.
34*7c478bd9Sstevel@tonic-gate  *
35*7c478bd9Sstevel@tonic-gate  * CAUTION: All protocol changes must also be propagated to:
36*7c478bd9Sstevel@tonic-gate  *     usr/src/cmd/cmd-inet/usr.sbin/snoop/nfs4_xdr.c
37*7c478bd9Sstevel@tonic-gate  */
38*7c478bd9Sstevel@tonic-gate 
39*7c478bd9Sstevel@tonic-gate #include <sys/types.h>
40*7c478bd9Sstevel@tonic-gate #include <sys/sunddi.h>
41*7c478bd9Sstevel@tonic-gate #include <sys/dnlc.h>
42*7c478bd9Sstevel@tonic-gate #include <nfs/nfs.h>
43*7c478bd9Sstevel@tonic-gate #include <nfs/nfs4_kprot.h>
44*7c478bd9Sstevel@tonic-gate #include <nfs/rnode4.h>
45*7c478bd9Sstevel@tonic-gate #include <nfs/nfs4.h>
46*7c478bd9Sstevel@tonic-gate #include <nfs/nfs4_clnt.h>
47*7c478bd9Sstevel@tonic-gate #include <sys/sdt.h>
48*7c478bd9Sstevel@tonic-gate #include <rpc/rpc_rdma.h>
49*7c478bd9Sstevel@tonic-gate 
50*7c478bd9Sstevel@tonic-gate bool_t
51*7c478bd9Sstevel@tonic-gate xdr_bitmap4(XDR *xdrs, bitmap4 *objp)
52*7c478bd9Sstevel@tonic-gate {
53*7c478bd9Sstevel@tonic-gate 	int32_t len, size;
54*7c478bd9Sstevel@tonic-gate 
55*7c478bd9Sstevel@tonic-gate 	if (xdrs->x_op == XDR_FREE)
56*7c478bd9Sstevel@tonic-gate 		return (TRUE);
57*7c478bd9Sstevel@tonic-gate 
58*7c478bd9Sstevel@tonic-gate 	/*
59*7c478bd9Sstevel@tonic-gate 	 * Simplified bitmap4 processing, always encode from uint64_t
60*7c478bd9Sstevel@tonic-gate 	 * to 2 uint32_t's, always decode first 2 uint32_t's into a
61*7c478bd9Sstevel@tonic-gate 	 * uint64_t and ignore all of the rest.
62*7c478bd9Sstevel@tonic-gate 	 */
63*7c478bd9Sstevel@tonic-gate 	if (xdrs->x_op == XDR_ENCODE) {
64*7c478bd9Sstevel@tonic-gate 		len = 2;
65*7c478bd9Sstevel@tonic-gate 
66*7c478bd9Sstevel@tonic-gate 		if (!XDR_PUTINT32(xdrs, &len))
67*7c478bd9Sstevel@tonic-gate 			return (FALSE);
68*7c478bd9Sstevel@tonic-gate 
69*7c478bd9Sstevel@tonic-gate #if defined(_LITTLE_ENDIAN)
70*7c478bd9Sstevel@tonic-gate 		if (XDR_PUTINT32(xdrs, (int32_t *)((char *)objp +
71*7c478bd9Sstevel@tonic-gate 						BYTES_PER_XDR_UNIT)) == TRUE) {
72*7c478bd9Sstevel@tonic-gate 			return (XDR_PUTINT32(xdrs, (int32_t *)objp));
73*7c478bd9Sstevel@tonic-gate 		}
74*7c478bd9Sstevel@tonic-gate #elif defined(_BIG_ENDIAN)
75*7c478bd9Sstevel@tonic-gate 		if (XDR_PUTINT32(xdrs, (int32_t *)objp) == TRUE) {
76*7c478bd9Sstevel@tonic-gate 			return (XDR_PUTINT32(xdrs, (int32_t *)((char *)objp +
77*7c478bd9Sstevel@tonic-gate 						BYTES_PER_XDR_UNIT)));
78*7c478bd9Sstevel@tonic-gate 		}
79*7c478bd9Sstevel@tonic-gate #endif
80*7c478bd9Sstevel@tonic-gate 		return (FALSE);
81*7c478bd9Sstevel@tonic-gate 	}
82*7c478bd9Sstevel@tonic-gate 
83*7c478bd9Sstevel@tonic-gate 	if (!XDR_GETINT32(xdrs, &len))
84*7c478bd9Sstevel@tonic-gate 		return (FALSE);
85*7c478bd9Sstevel@tonic-gate 
86*7c478bd9Sstevel@tonic-gate 	/*
87*7c478bd9Sstevel@tonic-gate 	 * Common fast DECODE cases
88*7c478bd9Sstevel@tonic-gate 	 */
89*7c478bd9Sstevel@tonic-gate 	if (len == 2) {
90*7c478bd9Sstevel@tonic-gate #if defined(_LITTLE_ENDIAN)
91*7c478bd9Sstevel@tonic-gate 		if (XDR_GETINT32(xdrs, (int32_t *)((char *)objp +
92*7c478bd9Sstevel@tonic-gate 					BYTES_PER_XDR_UNIT)) == TRUE) {
93*7c478bd9Sstevel@tonic-gate 			return (XDR_GETINT32(xdrs, (int32_t *)objp));
94*7c478bd9Sstevel@tonic-gate 		}
95*7c478bd9Sstevel@tonic-gate #elif defined(_BIG_ENDIAN)
96*7c478bd9Sstevel@tonic-gate 		if (XDR_GETINT32(xdrs, (int32_t *)objp) == TRUE) {
97*7c478bd9Sstevel@tonic-gate 			return (XDR_GETINT32(xdrs, (int32_t *)((char *)objp +
98*7c478bd9Sstevel@tonic-gate 					BYTES_PER_XDR_UNIT)));
99*7c478bd9Sstevel@tonic-gate 		}
100*7c478bd9Sstevel@tonic-gate #endif
101*7c478bd9Sstevel@tonic-gate 		return (FALSE);
102*7c478bd9Sstevel@tonic-gate 	}
103*7c478bd9Sstevel@tonic-gate 
104*7c478bd9Sstevel@tonic-gate 	*objp = 0;
105*7c478bd9Sstevel@tonic-gate 	if (len == 0)
106*7c478bd9Sstevel@tonic-gate 		return (TRUE);
107*7c478bd9Sstevel@tonic-gate 
108*7c478bd9Sstevel@tonic-gate 	/*
109*7c478bd9Sstevel@tonic-gate 	 * The not so common DECODE cases, len == 1 || len > 2
110*7c478bd9Sstevel@tonic-gate 	 */
111*7c478bd9Sstevel@tonic-gate #if defined(_LITTLE_ENDIAN)
112*7c478bd9Sstevel@tonic-gate 	if (!XDR_GETINT32(xdrs, (int32_t *)((char *)objp + BYTES_PER_XDR_UNIT)))
113*7c478bd9Sstevel@tonic-gate 		return (FALSE);
114*7c478bd9Sstevel@tonic-gate 	if (--len == 0)
115*7c478bd9Sstevel@tonic-gate 		return (TRUE);
116*7c478bd9Sstevel@tonic-gate 	if (!XDR_GETINT32(xdrs, (int32_t *)objp))
117*7c478bd9Sstevel@tonic-gate 		return (FALSE);
118*7c478bd9Sstevel@tonic-gate #elif defined(_BIG_ENDIAN)
119*7c478bd9Sstevel@tonic-gate 	if (!XDR_GETINT32(xdrs, (int32_t *)objp))
120*7c478bd9Sstevel@tonic-gate 		return (FALSE);
121*7c478bd9Sstevel@tonic-gate 	if (--len == 0)
122*7c478bd9Sstevel@tonic-gate 		return (TRUE);
123*7c478bd9Sstevel@tonic-gate 	if (!XDR_GETINT32(xdrs, (int32_t *)((char *)objp + BYTES_PER_XDR_UNIT)))
124*7c478bd9Sstevel@tonic-gate 		return (FALSE);
125*7c478bd9Sstevel@tonic-gate #else
126*7c478bd9Sstevel@tonic-gate 	return (FALSE);
127*7c478bd9Sstevel@tonic-gate #endif
128*7c478bd9Sstevel@tonic-gate 
129*7c478bd9Sstevel@tonic-gate 	if (--len == 0)
130*7c478bd9Sstevel@tonic-gate 		return (TRUE);
131*7c478bd9Sstevel@tonic-gate 
132*7c478bd9Sstevel@tonic-gate 	size = len * BYTES_PER_XDR_UNIT;
133*7c478bd9Sstevel@tonic-gate 	return (XDR_CONTROL(xdrs, XDR_SKIPBYTES, &size));
134*7c478bd9Sstevel@tonic-gate }
135*7c478bd9Sstevel@tonic-gate 
136*7c478bd9Sstevel@tonic-gate /* Called by xdr_array, nfsid_map_xdr */
137*7c478bd9Sstevel@tonic-gate bool_t
138*7c478bd9Sstevel@tonic-gate xdr_utf8string(XDR *xdrs, utf8string *objp)
139*7c478bd9Sstevel@tonic-gate {
140*7c478bd9Sstevel@tonic-gate 	if (xdrs->x_op != XDR_FREE)
141*7c478bd9Sstevel@tonic-gate 		return (xdr_bytes(xdrs, (char **)&objp->utf8string_val,
142*7c478bd9Sstevel@tonic-gate 			(uint_t *)&objp->utf8string_len, NFS4_MAX_UTF8STRING));
143*7c478bd9Sstevel@tonic-gate 
144*7c478bd9Sstevel@tonic-gate 	if (objp->utf8string_val != NULL) {
145*7c478bd9Sstevel@tonic-gate 		kmem_free(objp->utf8string_val, objp->utf8string_len);
146*7c478bd9Sstevel@tonic-gate 		objp->utf8string_val = NULL;
147*7c478bd9Sstevel@tonic-gate 	}
148*7c478bd9Sstevel@tonic-gate 	return (TRUE);
149*7c478bd9Sstevel@tonic-gate }
150*7c478bd9Sstevel@tonic-gate 
151*7c478bd9Sstevel@tonic-gate /*
152*7c478bd9Sstevel@tonic-gate  * Called in nfs_acl_xdr.c
153*7c478bd9Sstevel@tonic-gate  */
154*7c478bd9Sstevel@tonic-gate bool_t
155*7c478bd9Sstevel@tonic-gate xdr_nfs_fh4(XDR *xdrs, nfs_fh4 *objp)
156*7c478bd9Sstevel@tonic-gate {
157*7c478bd9Sstevel@tonic-gate 	if (xdrs->x_op != XDR_FREE)
158*7c478bd9Sstevel@tonic-gate 		return (xdr_bytes(xdrs, (char **)&objp->nfs_fh4_val,
159*7c478bd9Sstevel@tonic-gate 			(uint_t *)&objp->nfs_fh4_len, NFS4_FHSIZE));
160*7c478bd9Sstevel@tonic-gate 
161*7c478bd9Sstevel@tonic-gate 	if (objp->nfs_fh4_val != NULL) {
162*7c478bd9Sstevel@tonic-gate 		kmem_free(objp->nfs_fh4_val, objp->nfs_fh4_len);
163*7c478bd9Sstevel@tonic-gate 		objp->nfs_fh4_val = NULL;
164*7c478bd9Sstevel@tonic-gate 	}
165*7c478bd9Sstevel@tonic-gate 	return (TRUE);
166*7c478bd9Sstevel@tonic-gate }
167*7c478bd9Sstevel@tonic-gate 
168*7c478bd9Sstevel@tonic-gate /* Called by xdr_array */
169*7c478bd9Sstevel@tonic-gate static bool_t
170*7c478bd9Sstevel@tonic-gate xdr_fs_location4(XDR *xdrs, fs_location4 *objp)
171*7c478bd9Sstevel@tonic-gate {
172*7c478bd9Sstevel@tonic-gate 	if (!xdr_array(xdrs, (char **)&objp->server_val,
173*7c478bd9Sstevel@tonic-gate 			(uint_t *)&objp->server_len, NFS4_FS_LOCATIONS_LIMIT,
174*7c478bd9Sstevel@tonic-gate 			sizeof (utf8string), (xdrproc_t)xdr_utf8string))
175*7c478bd9Sstevel@tonic-gate 		return (FALSE);
176*7c478bd9Sstevel@tonic-gate 	return (xdr_array(xdrs, (char **)&objp->rootpath.pathname4_val,
177*7c478bd9Sstevel@tonic-gate 			(uint_t *)&objp->rootpath.pathname4_len,
178*7c478bd9Sstevel@tonic-gate 			NFS4_MAX_PATHNAME4,
179*7c478bd9Sstevel@tonic-gate 			sizeof (utf8string), (xdrproc_t)xdr_utf8string));
180*7c478bd9Sstevel@tonic-gate }
181*7c478bd9Sstevel@tonic-gate 
182*7c478bd9Sstevel@tonic-gate /* Called by xdr_array */
183*7c478bd9Sstevel@tonic-gate static bool_t
184*7c478bd9Sstevel@tonic-gate xdr_nfsace4(XDR *xdrs, nfsace4 *objp)
185*7c478bd9Sstevel@tonic-gate {
186*7c478bd9Sstevel@tonic-gate 	if (xdrs->x_op != XDR_FREE) {
187*7c478bd9Sstevel@tonic-gate 		if (!xdr_u_int(xdrs, &objp->type))
188*7c478bd9Sstevel@tonic-gate 			return (FALSE);
189*7c478bd9Sstevel@tonic-gate 		if (!xdr_u_int(xdrs, &objp->flag))
190*7c478bd9Sstevel@tonic-gate 			return (FALSE);
191*7c478bd9Sstevel@tonic-gate 		if (!xdr_u_int(xdrs, &objp->access_mask))
192*7c478bd9Sstevel@tonic-gate 			return (FALSE);
193*7c478bd9Sstevel@tonic-gate 
194*7c478bd9Sstevel@tonic-gate 		if (xdrs->x_op == XDR_DECODE) {
195*7c478bd9Sstevel@tonic-gate 			objp->who.utf8string_val = NULL;
196*7c478bd9Sstevel@tonic-gate 			objp->who.utf8string_len = 0;
197*7c478bd9Sstevel@tonic-gate 		}
198*7c478bd9Sstevel@tonic-gate 
199*7c478bd9Sstevel@tonic-gate 		return (xdr_bytes(xdrs, (char **)&objp->who.utf8string_val,
200*7c478bd9Sstevel@tonic-gate 			(uint_t *)&objp->who.utf8string_len,
201*7c478bd9Sstevel@tonic-gate 			NFS4_MAX_UTF8STRING));
202*7c478bd9Sstevel@tonic-gate 	}
203*7c478bd9Sstevel@tonic-gate 
204*7c478bd9Sstevel@tonic-gate 	/*
205*7c478bd9Sstevel@tonic-gate 	 * Optimized free case
206*7c478bd9Sstevel@tonic-gate 	 */
207*7c478bd9Sstevel@tonic-gate 	if (objp->who.utf8string_val != NULL) {
208*7c478bd9Sstevel@tonic-gate 		kmem_free(objp->who.utf8string_val, objp->who.utf8string_len);
209*7c478bd9Sstevel@tonic-gate 		objp->who.utf8string_val = NULL;
210*7c478bd9Sstevel@tonic-gate 	}
211*7c478bd9Sstevel@tonic-gate 	return (TRUE);
212*7c478bd9Sstevel@tonic-gate }
213*7c478bd9Sstevel@tonic-gate 
214*7c478bd9Sstevel@tonic-gate /*
215*7c478bd9Sstevel@tonic-gate  * These functions are called out of nfs4_attr.c
216*7c478bd9Sstevel@tonic-gate  */
217*7c478bd9Sstevel@tonic-gate bool_t
218*7c478bd9Sstevel@tonic-gate xdr_fattr4_fsid(XDR *xdrs, fattr4_fsid *objp)
219*7c478bd9Sstevel@tonic-gate {
220*7c478bd9Sstevel@tonic-gate 	if (xdrs->x_op == XDR_FREE)
221*7c478bd9Sstevel@tonic-gate 		return (TRUE);
222*7c478bd9Sstevel@tonic-gate 
223*7c478bd9Sstevel@tonic-gate 	if (!xdr_u_longlong_t(xdrs, (u_longlong_t *)&objp->major))
224*7c478bd9Sstevel@tonic-gate 		return (FALSE);
225*7c478bd9Sstevel@tonic-gate 	return (xdr_u_longlong_t(xdrs, (u_longlong_t *)&objp->minor));
226*7c478bd9Sstevel@tonic-gate }
227*7c478bd9Sstevel@tonic-gate 
228*7c478bd9Sstevel@tonic-gate 
229*7c478bd9Sstevel@tonic-gate bool_t
230*7c478bd9Sstevel@tonic-gate xdr_fattr4_acl(XDR *xdrs, fattr4_acl *objp)
231*7c478bd9Sstevel@tonic-gate {
232*7c478bd9Sstevel@tonic-gate 	return (xdr_array(xdrs, (char **)&objp->fattr4_acl_val,
233*7c478bd9Sstevel@tonic-gate 			(uint_t *)&objp->fattr4_acl_len, NFS4_ACL_LIMIT,
234*7c478bd9Sstevel@tonic-gate 			sizeof (nfsace4), (xdrproc_t)xdr_nfsace4));
235*7c478bd9Sstevel@tonic-gate }
236*7c478bd9Sstevel@tonic-gate 
237*7c478bd9Sstevel@tonic-gate bool_t
238*7c478bd9Sstevel@tonic-gate xdr_fattr4_fs_locations(XDR *xdrs, fattr4_fs_locations *objp)
239*7c478bd9Sstevel@tonic-gate {
240*7c478bd9Sstevel@tonic-gate 	if (!xdr_array(xdrs, (char **)&objp->fs_root.pathname4_val,
241*7c478bd9Sstevel@tonic-gate 			(uint_t *)&objp->fs_root.pathname4_len,
242*7c478bd9Sstevel@tonic-gate 			NFS4_MAX_PATHNAME4,
243*7c478bd9Sstevel@tonic-gate 			sizeof (utf8string), (xdrproc_t)xdr_utf8string))
244*7c478bd9Sstevel@tonic-gate 		return (FALSE);
245*7c478bd9Sstevel@tonic-gate 	return (xdr_array(xdrs, (char **)&objp->locations_val,
246*7c478bd9Sstevel@tonic-gate 			(uint_t *)&objp->locations_len, NFS4_FS_LOCATIONS_LIMIT,
247*7c478bd9Sstevel@tonic-gate 			sizeof (fs_location4), (xdrproc_t)xdr_fs_location4));
248*7c478bd9Sstevel@tonic-gate }
249*7c478bd9Sstevel@tonic-gate 
250*7c478bd9Sstevel@tonic-gate bool_t
251*7c478bd9Sstevel@tonic-gate xdr_fattr4_rawdev(XDR *xdrs, fattr4_rawdev *objp)
252*7c478bd9Sstevel@tonic-gate {
253*7c478bd9Sstevel@tonic-gate 	if (xdrs->x_op == XDR_FREE)
254*7c478bd9Sstevel@tonic-gate 		return (TRUE);
255*7c478bd9Sstevel@tonic-gate 
256*7c478bd9Sstevel@tonic-gate 	if (!xdr_u_int(xdrs, &objp->specdata1))
257*7c478bd9Sstevel@tonic-gate 		return (FALSE);
258*7c478bd9Sstevel@tonic-gate 	return (xdr_u_int(xdrs, &objp->specdata2));
259*7c478bd9Sstevel@tonic-gate }
260*7c478bd9Sstevel@tonic-gate 
261*7c478bd9Sstevel@tonic-gate bool_t
262*7c478bd9Sstevel@tonic-gate xdr_nfstime4(XDR *xdrs, nfstime4 *objp)
263*7c478bd9Sstevel@tonic-gate {
264*7c478bd9Sstevel@tonic-gate 	if (xdrs->x_op == XDR_FREE)
265*7c478bd9Sstevel@tonic-gate 		return (TRUE);
266*7c478bd9Sstevel@tonic-gate 
267*7c478bd9Sstevel@tonic-gate 	if (!xdr_longlong_t(xdrs, (longlong_t *)&objp->seconds))
268*7c478bd9Sstevel@tonic-gate 		return (FALSE);
269*7c478bd9Sstevel@tonic-gate 	return (xdr_u_int(xdrs, &objp->nseconds));
270*7c478bd9Sstevel@tonic-gate }
271*7c478bd9Sstevel@tonic-gate 
272*7c478bd9Sstevel@tonic-gate 
273*7c478bd9Sstevel@tonic-gate /*
274*7c478bd9Sstevel@tonic-gate  * structured used for calls into xdr_ga_fattr_res() as a means
275*7c478bd9Sstevel@tonic-gate  * to do an immediate/short-term cache of owner/group strings
276*7c478bd9Sstevel@tonic-gate  * for callers like the readdir processing.  In the case of readdir,
277*7c478bd9Sstevel@tonic-gate  * it is likely that the directory objects will be owned by the same
278*7c478bd9Sstevel@tonic-gate  * owner/group and if so there is no need to call into the uid/gid
279*7c478bd9Sstevel@tonic-gate  * mapping code.  While the uid/gid interfaces have their own cache
280*7c478bd9Sstevel@tonic-gate  * having one here will reduct pathlength further.
281*7c478bd9Sstevel@tonic-gate  */
282*7c478bd9Sstevel@tonic-gate #define	MAX_OG_NAME 100
283*7c478bd9Sstevel@tonic-gate typedef struct ug_cache
284*7c478bd9Sstevel@tonic-gate {
285*7c478bd9Sstevel@tonic-gate 	uid_t	uid;
286*7c478bd9Sstevel@tonic-gate 	gid_t	gid;
287*7c478bd9Sstevel@tonic-gate 	utf8string u_curr, u_last;
288*7c478bd9Sstevel@tonic-gate 	utf8string g_curr, g_last;
289*7c478bd9Sstevel@tonic-gate 	char	u_buf1[MAX_OG_NAME];
290*7c478bd9Sstevel@tonic-gate 	char	u_buf2[MAX_OG_NAME];
291*7c478bd9Sstevel@tonic-gate 	char	g_buf1[MAX_OG_NAME];
292*7c478bd9Sstevel@tonic-gate 	char	g_buf2[MAX_OG_NAME];
293*7c478bd9Sstevel@tonic-gate } ug_cache_t;
294*7c478bd9Sstevel@tonic-gate 
295*7c478bd9Sstevel@tonic-gate #define	U_SWAP_CURR_LAST(ug) \
296*7c478bd9Sstevel@tonic-gate 	(ug)->u_last.utf8string_len = (ug)->u_curr.utf8string_len;	\
297*7c478bd9Sstevel@tonic-gate 	if ((ug)->u_last.utf8string_val == (ug)->u_buf1) {		\
298*7c478bd9Sstevel@tonic-gate 		(ug)->u_last.utf8string_val = (ug)->u_buf2;		\
299*7c478bd9Sstevel@tonic-gate 		(ug)->u_curr.utf8string_val = (ug)->u_buf1;		\
300*7c478bd9Sstevel@tonic-gate 	} else {							\
301*7c478bd9Sstevel@tonic-gate 		(ug)->u_last.utf8string_val = (ug)->u_buf1;		\
302*7c478bd9Sstevel@tonic-gate 		(ug)->u_curr.utf8string_val = (ug)->u_buf2;		\
303*7c478bd9Sstevel@tonic-gate 	}
304*7c478bd9Sstevel@tonic-gate 
305*7c478bd9Sstevel@tonic-gate #define	G_SWAP_CURR_LAST(ug) \
306*7c478bd9Sstevel@tonic-gate 	(ug)->g_last.utf8string_len = (ug)->g_curr.utf8string_len;	\
307*7c478bd9Sstevel@tonic-gate 	if ((ug)->g_last.utf8string_val == (ug)->g_buf1) {		\
308*7c478bd9Sstevel@tonic-gate 		(ug)->g_last.utf8string_val = (ug)->g_buf2;		\
309*7c478bd9Sstevel@tonic-gate 		(ug)->g_curr.utf8string_val = (ug)->g_buf1;		\
310*7c478bd9Sstevel@tonic-gate 	} else {							\
311*7c478bd9Sstevel@tonic-gate 		(ug)->g_last.utf8string_val = (ug)->g_buf1;		\
312*7c478bd9Sstevel@tonic-gate 		(ug)->g_curr.utf8string_val = (ug)->g_buf2;		\
313*7c478bd9Sstevel@tonic-gate 	}
314*7c478bd9Sstevel@tonic-gate 
315*7c478bd9Sstevel@tonic-gate static ug_cache_t *
316*7c478bd9Sstevel@tonic-gate alloc_ugcache()
317*7c478bd9Sstevel@tonic-gate {
318*7c478bd9Sstevel@tonic-gate 	ug_cache_t *pug = kmem_alloc(sizeof (ug_cache_t), KM_SLEEP);
319*7c478bd9Sstevel@tonic-gate 
320*7c478bd9Sstevel@tonic-gate 	pug->uid = pug->gid = 0;
321*7c478bd9Sstevel@tonic-gate 	pug->u_curr.utf8string_len = 0;
322*7c478bd9Sstevel@tonic-gate 	pug->u_last.utf8string_len = 0;
323*7c478bd9Sstevel@tonic-gate 	pug->g_curr.utf8string_len = 0;
324*7c478bd9Sstevel@tonic-gate 	pug->g_last.utf8string_len = 0;
325*7c478bd9Sstevel@tonic-gate 	pug->u_curr.utf8string_val = pug->u_buf1;
326*7c478bd9Sstevel@tonic-gate 	pug->u_last.utf8string_val = pug->u_buf2;
327*7c478bd9Sstevel@tonic-gate 	pug->g_curr.utf8string_val = pug->g_buf1;
328*7c478bd9Sstevel@tonic-gate 	pug->g_last.utf8string_val = pug->g_buf2;
329*7c478bd9Sstevel@tonic-gate 
330*7c478bd9Sstevel@tonic-gate 	return (pug);
331*7c478bd9Sstevel@tonic-gate }
332*7c478bd9Sstevel@tonic-gate 
333*7c478bd9Sstevel@tonic-gate static void
334*7c478bd9Sstevel@tonic-gate xdr_ga_prefill_vattr(struct nfs4_ga_res *garp, struct mntinfo4 *mi)
335*7c478bd9Sstevel@tonic-gate {
336*7c478bd9Sstevel@tonic-gate 	static vattr_t s_vattr = {
337*7c478bd9Sstevel@tonic-gate 		AT_ALL,		/* va_mask */
338*7c478bd9Sstevel@tonic-gate 		VNON,		/* va_type */
339*7c478bd9Sstevel@tonic-gate 		0777,		/* va_mode */
340*7c478bd9Sstevel@tonic-gate 		UID_NOBODY,	/* va_uid */
341*7c478bd9Sstevel@tonic-gate 		GID_NOBODY,	/* va_gid */
342*7c478bd9Sstevel@tonic-gate 		0,		/* va_fsid */
343*7c478bd9Sstevel@tonic-gate 		0,		/* va_nodeid */
344*7c478bd9Sstevel@tonic-gate 		1,		/* va_nlink */
345*7c478bd9Sstevel@tonic-gate 		0,		/* va_size */
346*7c478bd9Sstevel@tonic-gate 		{0, 0},		/* va_atime */
347*7c478bd9Sstevel@tonic-gate 		{0, 0},		/* va_mtime */
348*7c478bd9Sstevel@tonic-gate 		{0, 0},		/* va_ctime */
349*7c478bd9Sstevel@tonic-gate 		0,		/* va_rdev */
350*7c478bd9Sstevel@tonic-gate 		MAXBSIZE,	/* va_blksize */
351*7c478bd9Sstevel@tonic-gate 		0,		/* va_nblocks */
352*7c478bd9Sstevel@tonic-gate 		0		/* va_seq */
353*7c478bd9Sstevel@tonic-gate 	};
354*7c478bd9Sstevel@tonic-gate 
355*7c478bd9Sstevel@tonic-gate 
356*7c478bd9Sstevel@tonic-gate 	garp->n4g_va = s_vattr;
357*7c478bd9Sstevel@tonic-gate 	garp->n4g_va.va_fsid = mi->mi_vfsp->vfs_dev;
358*7c478bd9Sstevel@tonic-gate 	hrt2ts(gethrtime(), &garp->n4g_va.va_atime);
359*7c478bd9Sstevel@tonic-gate 	garp->n4g_va.va_mtime = garp->n4g_va.va_ctime = garp->n4g_va.va_atime;
360*7c478bd9Sstevel@tonic-gate }
361*7c478bd9Sstevel@tonic-gate 
362*7c478bd9Sstevel@tonic-gate static void
363*7c478bd9Sstevel@tonic-gate xdr_ga_prefill_statvfs(struct nfs4_ga_ext_res *gesp, struct mntinfo4 *mi)
364*7c478bd9Sstevel@tonic-gate {
365*7c478bd9Sstevel@tonic-gate 	static statvfs64_t s_sb = {
366*7c478bd9Sstevel@tonic-gate 		MAXBSIZE,	/* f_bsize */
367*7c478bd9Sstevel@tonic-gate 		DEV_BSIZE,	/* f_frsize */
368*7c478bd9Sstevel@tonic-gate 		(fsfilcnt64_t)-1, /* f_blocks */
369*7c478bd9Sstevel@tonic-gate 		(fsfilcnt64_t)-1, /* f_bfree */
370*7c478bd9Sstevel@tonic-gate 		(fsfilcnt64_t)-1, /* f_bavail */
371*7c478bd9Sstevel@tonic-gate 		(fsfilcnt64_t)-1, /* f_files */
372*7c478bd9Sstevel@tonic-gate 		(fsfilcnt64_t)-1, /* f_ffree */
373*7c478bd9Sstevel@tonic-gate 		(fsfilcnt64_t)-1, /* f_favail */
374*7c478bd9Sstevel@tonic-gate 		0,		/* f_fsid */
375*7c478bd9Sstevel@tonic-gate 		"\0",		/* f_basetype */
376*7c478bd9Sstevel@tonic-gate 		0,		/* f_flag */
377*7c478bd9Sstevel@tonic-gate 		MAXNAMELEN,	/* f_namemax */
378*7c478bd9Sstevel@tonic-gate 		"\0",		/* f_fstr */
379*7c478bd9Sstevel@tonic-gate 	};
380*7c478bd9Sstevel@tonic-gate 
381*7c478bd9Sstevel@tonic-gate 	gesp->n4g_sb = s_sb;
382*7c478bd9Sstevel@tonic-gate 	gesp->n4g_sb.f_fsid = mi->mi_vfsp->vfs_fsid.val[0];
383*7c478bd9Sstevel@tonic-gate }
384*7c478bd9Sstevel@tonic-gate 
385*7c478bd9Sstevel@tonic-gate static bool_t
386*7c478bd9Sstevel@tonic-gate xdr_ga_fattr_res(XDR *xdrs, struct nfs4_ga_res *garp, bitmap4 resbmap,
387*7c478bd9Sstevel@tonic-gate 		bitmap4 argbmap, struct mntinfo4 *mi, ug_cache_t *pug)
388*7c478bd9Sstevel@tonic-gate {
389*7c478bd9Sstevel@tonic-gate 	int truefalse;
390*7c478bd9Sstevel@tonic-gate 	struct nfs4_ga_ext_res ges, *gesp;
391*7c478bd9Sstevel@tonic-gate 	vattr_t *vap = &garp->n4g_va;
392*7c478bd9Sstevel@tonic-gate 	vsecattr_t *vsap = &garp->n4g_vsa;
393*7c478bd9Sstevel@tonic-gate 
394*7c478bd9Sstevel@tonic-gate 	ASSERT(xdrs->x_op == XDR_DECODE);
395*7c478bd9Sstevel@tonic-gate 
396*7c478bd9Sstevel@tonic-gate 	if (garp->n4g_ext_res)
397*7c478bd9Sstevel@tonic-gate 		gesp = garp->n4g_ext_res;
398*7c478bd9Sstevel@tonic-gate 	else
399*7c478bd9Sstevel@tonic-gate 		gesp = &ges;
400*7c478bd9Sstevel@tonic-gate 
401*7c478bd9Sstevel@tonic-gate 	vap->va_mask = 0;
402*7c478bd9Sstevel@tonic-gate 
403*7c478bd9Sstevel@tonic-gate 	/* Check to see if the vattr should be pre-filled */
404*7c478bd9Sstevel@tonic-gate 	if (argbmap & NFS4_VATTR_MASK)
405*7c478bd9Sstevel@tonic-gate 		xdr_ga_prefill_vattr(garp, mi);
406*7c478bd9Sstevel@tonic-gate 
407*7c478bd9Sstevel@tonic-gate 	if (argbmap & NFS4_STATFS_ATTR_MASK)
408*7c478bd9Sstevel@tonic-gate 		xdr_ga_prefill_statvfs(gesp, mi);
409*7c478bd9Sstevel@tonic-gate 
410*7c478bd9Sstevel@tonic-gate 	if (resbmap &
411*7c478bd9Sstevel@tonic-gate 	    (FATTR4_SUPPORTED_ATTRS_MASK |
412*7c478bd9Sstevel@tonic-gate 	    FATTR4_TYPE_MASK |
413*7c478bd9Sstevel@tonic-gate 	    FATTR4_FH_EXPIRE_TYPE_MASK |
414*7c478bd9Sstevel@tonic-gate 	    FATTR4_CHANGE_MASK |
415*7c478bd9Sstevel@tonic-gate 	    FATTR4_SIZE_MASK |
416*7c478bd9Sstevel@tonic-gate 	    FATTR4_LINK_SUPPORT_MASK |
417*7c478bd9Sstevel@tonic-gate 	    FATTR4_SYMLINK_SUPPORT_MASK |
418*7c478bd9Sstevel@tonic-gate 	    FATTR4_NAMED_ATTR_MASK)) {
419*7c478bd9Sstevel@tonic-gate 
420*7c478bd9Sstevel@tonic-gate 		if (resbmap & FATTR4_SUPPORTED_ATTRS_MASK) {
421*7c478bd9Sstevel@tonic-gate 			if (!xdr_bitmap4(xdrs, &gesp->n4g_suppattrs))
422*7c478bd9Sstevel@tonic-gate 				return (FALSE);
423*7c478bd9Sstevel@tonic-gate 		}
424*7c478bd9Sstevel@tonic-gate 		if (resbmap & FATTR4_TYPE_MASK) {
425*7c478bd9Sstevel@tonic-gate 			if (!XDR_GETINT32(xdrs, (int *)&vap->va_type))
426*7c478bd9Sstevel@tonic-gate 				return (FALSE);
427*7c478bd9Sstevel@tonic-gate 
428*7c478bd9Sstevel@tonic-gate 			if (vap->va_type < NF4REG ||
429*7c478bd9Sstevel@tonic-gate 			    vap->va_type > NF4NAMEDATTR)
430*7c478bd9Sstevel@tonic-gate 				vap->va_type = VBAD;
431*7c478bd9Sstevel@tonic-gate 			else
432*7c478bd9Sstevel@tonic-gate 				vap->va_type = nf4_to_vt[vap->va_type];
433*7c478bd9Sstevel@tonic-gate 			if (vap->va_type == VBLK)
434*7c478bd9Sstevel@tonic-gate 				vap->va_blksize = DEV_BSIZE;
435*7c478bd9Sstevel@tonic-gate 
436*7c478bd9Sstevel@tonic-gate 			vap->va_mask |= AT_TYPE;
437*7c478bd9Sstevel@tonic-gate 		}
438*7c478bd9Sstevel@tonic-gate 		if (resbmap & FATTR4_FH_EXPIRE_TYPE_MASK) {
439*7c478bd9Sstevel@tonic-gate 			if (!XDR_GETINT32(xdrs, (int *)&gesp->n4g_fet))
440*7c478bd9Sstevel@tonic-gate 				return (FALSE);
441*7c478bd9Sstevel@tonic-gate 		}
442*7c478bd9Sstevel@tonic-gate 		if (resbmap & FATTR4_CHANGE_MASK) {
443*7c478bd9Sstevel@tonic-gate 			if (!xdr_u_longlong_t(xdrs,
444*7c478bd9Sstevel@tonic-gate 				(u_longlong_t *)&garp->n4g_change))
445*7c478bd9Sstevel@tonic-gate 				return (FALSE);
446*7c478bd9Sstevel@tonic-gate 			garp->n4g_change_valid = 1;
447*7c478bd9Sstevel@tonic-gate 		}
448*7c478bd9Sstevel@tonic-gate 		if (resbmap & FATTR4_SIZE_MASK) {
449*7c478bd9Sstevel@tonic-gate 			if (!xdr_u_longlong_t(xdrs,
450*7c478bd9Sstevel@tonic-gate 					(u_longlong_t *)&vap->va_size))
451*7c478bd9Sstevel@tonic-gate 				return (FALSE);
452*7c478bd9Sstevel@tonic-gate 			if (!NFS4_SIZE_OK(vap->va_size)) {
453*7c478bd9Sstevel@tonic-gate 				garp->n4g_attrerr = EFBIG;
454*7c478bd9Sstevel@tonic-gate 				garp->n4g_attrwhy = NFS4_GETATTR_ATSIZE_ERR;
455*7c478bd9Sstevel@tonic-gate 			} else {
456*7c478bd9Sstevel@tonic-gate 				vap->va_mask |= AT_SIZE;
457*7c478bd9Sstevel@tonic-gate 			}
458*7c478bd9Sstevel@tonic-gate 		}
459*7c478bd9Sstevel@tonic-gate 		if (resbmap & FATTR4_LINK_SUPPORT_MASK) {
460*7c478bd9Sstevel@tonic-gate 			if (!XDR_GETINT32(xdrs, (int *)&truefalse))
461*7c478bd9Sstevel@tonic-gate 				return (FALSE);
462*7c478bd9Sstevel@tonic-gate 			gesp->n4g_pc4.pc4_link_support =
463*7c478bd9Sstevel@tonic-gate 				(truefalse ? TRUE : FALSE);
464*7c478bd9Sstevel@tonic-gate 		}
465*7c478bd9Sstevel@tonic-gate 		if (resbmap & FATTR4_SYMLINK_SUPPORT_MASK) {
466*7c478bd9Sstevel@tonic-gate 			if (!XDR_GETINT32(xdrs, (int *)&truefalse))
467*7c478bd9Sstevel@tonic-gate 				return (FALSE);
468*7c478bd9Sstevel@tonic-gate 			gesp->n4g_pc4.pc4_symlink_support =
469*7c478bd9Sstevel@tonic-gate 				(truefalse ? TRUE : FALSE);
470*7c478bd9Sstevel@tonic-gate 		}
471*7c478bd9Sstevel@tonic-gate 		if (resbmap & FATTR4_NAMED_ATTR_MASK) {
472*7c478bd9Sstevel@tonic-gate 			if (!XDR_GETINT32(xdrs, (int *)&truefalse))
473*7c478bd9Sstevel@tonic-gate 				return (FALSE);
474*7c478bd9Sstevel@tonic-gate 			gesp->n4g_pc4.pc4_xattr_exists = TRUE;
475*7c478bd9Sstevel@tonic-gate 			gesp->n4g_pc4.pc4_xattr_exists =
476*7c478bd9Sstevel@tonic-gate 				(truefalse ? TRUE : FALSE);
477*7c478bd9Sstevel@tonic-gate 		}
478*7c478bd9Sstevel@tonic-gate 	}
479*7c478bd9Sstevel@tonic-gate 	if (resbmap &
480*7c478bd9Sstevel@tonic-gate 	    (FATTR4_FSID_MASK |
481*7c478bd9Sstevel@tonic-gate 	    FATTR4_UNIQUE_HANDLES_MASK |
482*7c478bd9Sstevel@tonic-gate 	    FATTR4_LEASE_TIME_MASK |
483*7c478bd9Sstevel@tonic-gate 	    FATTR4_RDATTR_ERROR_MASK)) {
484*7c478bd9Sstevel@tonic-gate 
485*7c478bd9Sstevel@tonic-gate 		if (resbmap & FATTR4_FSID_MASK) {
486*7c478bd9Sstevel@tonic-gate 		    if ((!xdr_u_longlong_t(xdrs,
487*7c478bd9Sstevel@tonic-gate 				(u_longlong_t *)&garp->n4g_fsid.major)) ||
488*7c478bd9Sstevel@tonic-gate 			(!xdr_u_longlong_t(xdrs,
489*7c478bd9Sstevel@tonic-gate 				(u_longlong_t *)&garp->n4g_fsid.minor)))
490*7c478bd9Sstevel@tonic-gate 				return (FALSE);
491*7c478bd9Sstevel@tonic-gate 		    garp->n4g_fsid_valid = 1;
492*7c478bd9Sstevel@tonic-gate 		}
493*7c478bd9Sstevel@tonic-gate 		if (resbmap & FATTR4_UNIQUE_HANDLES_MASK) {
494*7c478bd9Sstevel@tonic-gate 			if (!XDR_GETINT32(xdrs, (int *)&truefalse))
495*7c478bd9Sstevel@tonic-gate 				return (FALSE);
496*7c478bd9Sstevel@tonic-gate 			gesp->n4g_pc4.pc4_unique_handles =
497*7c478bd9Sstevel@tonic-gate 				(truefalse ? TRUE : FALSE);
498*7c478bd9Sstevel@tonic-gate 		}
499*7c478bd9Sstevel@tonic-gate 		if (resbmap & FATTR4_LEASE_TIME_MASK) {
500*7c478bd9Sstevel@tonic-gate 			if (!XDR_GETINT32(xdrs, (int *)&gesp->n4g_leasetime))
501*7c478bd9Sstevel@tonic-gate 				return (FALSE);
502*7c478bd9Sstevel@tonic-gate 		}
503*7c478bd9Sstevel@tonic-gate 		if (resbmap & FATTR4_RDATTR_ERROR_MASK) {
504*7c478bd9Sstevel@tonic-gate 			if (!XDR_GETINT32(xdrs,
505*7c478bd9Sstevel@tonic-gate 					(int *)&gesp->n4g_rdattr_error))
506*7c478bd9Sstevel@tonic-gate 				return (FALSE);
507*7c478bd9Sstevel@tonic-gate 		}
508*7c478bd9Sstevel@tonic-gate 	}
509*7c478bd9Sstevel@tonic-gate 	if (resbmap &
510*7c478bd9Sstevel@tonic-gate 	    (FATTR4_ACL_MASK |
511*7c478bd9Sstevel@tonic-gate 	    FATTR4_ACLSUPPORT_MASK |
512*7c478bd9Sstevel@tonic-gate 	    FATTR4_ARCHIVE_MASK |
513*7c478bd9Sstevel@tonic-gate 	    FATTR4_CANSETTIME_MASK)) {
514*7c478bd9Sstevel@tonic-gate 
515*7c478bd9Sstevel@tonic-gate 		if (resbmap & FATTR4_ACL_MASK) {
516*7c478bd9Sstevel@tonic-gate 			fattr4_acl	acl;
517*7c478bd9Sstevel@tonic-gate 
518*7c478bd9Sstevel@tonic-gate 			acl.fattr4_acl_val = NULL;
519*7c478bd9Sstevel@tonic-gate 			acl.fattr4_acl_len = 0;
520*7c478bd9Sstevel@tonic-gate 
521*7c478bd9Sstevel@tonic-gate 			if (!xdr_fattr4_acl(xdrs, &acl))
522*7c478bd9Sstevel@tonic-gate 				return (FALSE);
523*7c478bd9Sstevel@tonic-gate 
524*7c478bd9Sstevel@tonic-gate 			vsap->vsa_aclcnt = acl.fattr4_acl_len;
525*7c478bd9Sstevel@tonic-gate 			vsap->vsa_aclentp = acl.fattr4_acl_val;
526*7c478bd9Sstevel@tonic-gate 			vsap->vsa_mask = VSA_ACE | VSA_ACECNT;
527*7c478bd9Sstevel@tonic-gate 
528*7c478bd9Sstevel@tonic-gate 		}
529*7c478bd9Sstevel@tonic-gate 		if (resbmap & FATTR4_ACLSUPPORT_MASK) {
530*7c478bd9Sstevel@tonic-gate 			if (!XDR_GETINT32(xdrs, (int *)&gesp->n4g_aclsupport))
531*7c478bd9Sstevel@tonic-gate 				return (FALSE);
532*7c478bd9Sstevel@tonic-gate 		}
533*7c478bd9Sstevel@tonic-gate 		if (resbmap & FATTR4_ARCHIVE_MASK) {
534*7c478bd9Sstevel@tonic-gate 			ASSERT(0);
535*7c478bd9Sstevel@tonic-gate 		}
536*7c478bd9Sstevel@tonic-gate 		if (resbmap & FATTR4_CANSETTIME_MASK) {
537*7c478bd9Sstevel@tonic-gate 			if (!XDR_GETINT32(xdrs, (int *)&truefalse))
538*7c478bd9Sstevel@tonic-gate 				return (FALSE);
539*7c478bd9Sstevel@tonic-gate 			gesp->n4g_pc4.pc4_cansettime =
540*7c478bd9Sstevel@tonic-gate 				(truefalse ? TRUE : FALSE);
541*7c478bd9Sstevel@tonic-gate 		}
542*7c478bd9Sstevel@tonic-gate 	}
543*7c478bd9Sstevel@tonic-gate 	if (resbmap &
544*7c478bd9Sstevel@tonic-gate 	    (FATTR4_CASE_INSENSITIVE_MASK |
545*7c478bd9Sstevel@tonic-gate 	    FATTR4_CASE_PRESERVING_MASK |
546*7c478bd9Sstevel@tonic-gate 	    FATTR4_CHOWN_RESTRICTED_MASK |
547*7c478bd9Sstevel@tonic-gate 	    FATTR4_FILEHANDLE_MASK |
548*7c478bd9Sstevel@tonic-gate 	    FATTR4_FILEID_MASK |
549*7c478bd9Sstevel@tonic-gate 	    FATTR4_FILES_AVAIL_MASK |
550*7c478bd9Sstevel@tonic-gate 	    FATTR4_FILES_FREE_MASK |
551*7c478bd9Sstevel@tonic-gate 	    FATTR4_FILES_TOTAL_MASK)) {
552*7c478bd9Sstevel@tonic-gate 
553*7c478bd9Sstevel@tonic-gate 		if (resbmap & FATTR4_CASE_INSENSITIVE_MASK) {
554*7c478bd9Sstevel@tonic-gate 			if (!XDR_GETINT32(xdrs, (int *)&truefalse))
555*7c478bd9Sstevel@tonic-gate 				return (FALSE);
556*7c478bd9Sstevel@tonic-gate 			gesp->n4g_pc4.pc4_case_insensitive =
557*7c478bd9Sstevel@tonic-gate 				(truefalse ? TRUE : FALSE);
558*7c478bd9Sstevel@tonic-gate 		}
559*7c478bd9Sstevel@tonic-gate 		if (resbmap & FATTR4_CASE_PRESERVING_MASK) {
560*7c478bd9Sstevel@tonic-gate 			if (!XDR_GETINT32(xdrs, (int *)&truefalse))
561*7c478bd9Sstevel@tonic-gate 				return (FALSE);
562*7c478bd9Sstevel@tonic-gate 			gesp->n4g_pc4.pc4_case_preserving =
563*7c478bd9Sstevel@tonic-gate 				(truefalse ? TRUE : FALSE);
564*7c478bd9Sstevel@tonic-gate 		}
565*7c478bd9Sstevel@tonic-gate 		if (resbmap & FATTR4_CHOWN_RESTRICTED_MASK) {
566*7c478bd9Sstevel@tonic-gate 			if (!XDR_GETINT32(xdrs, (int *)&truefalse))
567*7c478bd9Sstevel@tonic-gate 				return (FALSE);
568*7c478bd9Sstevel@tonic-gate 			gesp->n4g_pc4.pc4_chown_restricted =
569*7c478bd9Sstevel@tonic-gate 				(truefalse ? TRUE : FALSE);
570*7c478bd9Sstevel@tonic-gate 		}
571*7c478bd9Sstevel@tonic-gate 		if (resbmap & FATTR4_FILEHANDLE_MASK) {
572*7c478bd9Sstevel@tonic-gate 			gesp->n4g_fh_u.nfs_fh4_alt.len = 0;
573*7c478bd9Sstevel@tonic-gate 			gesp->n4g_fh_u.nfs_fh4_alt.val =
574*7c478bd9Sstevel@tonic-gate 				gesp->n4g_fh_u.nfs_fh4_alt.data;
575*7c478bd9Sstevel@tonic-gate 			if (!xdr_bytes(xdrs,
576*7c478bd9Sstevel@tonic-gate 			    (char **)&gesp->n4g_fh_u.n4g_fh.nfs_fh4_val,
577*7c478bd9Sstevel@tonic-gate 			    (uint_t *)&gesp->n4g_fh_u.n4g_fh.nfs_fh4_len,
578*7c478bd9Sstevel@tonic-gate 			    NFS4_FHSIZE))
579*7c478bd9Sstevel@tonic-gate 				return (FALSE);
580*7c478bd9Sstevel@tonic-gate 		}
581*7c478bd9Sstevel@tonic-gate 		if (resbmap & FATTR4_FILEID_MASK) {
582*7c478bd9Sstevel@tonic-gate 			if (!xdr_u_longlong_t(xdrs,
583*7c478bd9Sstevel@tonic-gate 					(u_longlong_t *)&vap->va_nodeid))
584*7c478bd9Sstevel@tonic-gate 				return (FALSE);
585*7c478bd9Sstevel@tonic-gate 			vap->va_mask |= AT_NODEID;
586*7c478bd9Sstevel@tonic-gate 		}
587*7c478bd9Sstevel@tonic-gate 		if (resbmap & FATTR4_FILES_AVAIL_MASK) {
588*7c478bd9Sstevel@tonic-gate 			if (!xdr_u_longlong_t(xdrs,
589*7c478bd9Sstevel@tonic-gate 				(u_longlong_t *)&gesp->n4g_sb.f_favail))
590*7c478bd9Sstevel@tonic-gate 				return (FALSE);
591*7c478bd9Sstevel@tonic-gate 		}
592*7c478bd9Sstevel@tonic-gate 		if (resbmap & FATTR4_FILES_FREE_MASK) {
593*7c478bd9Sstevel@tonic-gate 			if (!xdr_u_longlong_t(xdrs,
594*7c478bd9Sstevel@tonic-gate 				(u_longlong_t *)&gesp->n4g_sb.f_ffree))
595*7c478bd9Sstevel@tonic-gate 				return (FALSE);
596*7c478bd9Sstevel@tonic-gate 		}
597*7c478bd9Sstevel@tonic-gate 		if (resbmap & FATTR4_FILES_TOTAL_MASK) {
598*7c478bd9Sstevel@tonic-gate 			if (!xdr_u_longlong_t(xdrs,
599*7c478bd9Sstevel@tonic-gate 				(u_longlong_t *)&gesp->n4g_sb.f_files))
600*7c478bd9Sstevel@tonic-gate 				return (FALSE);
601*7c478bd9Sstevel@tonic-gate 		}
602*7c478bd9Sstevel@tonic-gate 	}
603*7c478bd9Sstevel@tonic-gate 	if (resbmap &
604*7c478bd9Sstevel@tonic-gate 	    (FATTR4_FS_LOCATIONS_MASK |
605*7c478bd9Sstevel@tonic-gate 	    FATTR4_HIDDEN_MASK |
606*7c478bd9Sstevel@tonic-gate 	    FATTR4_HOMOGENEOUS_MASK)) {
607*7c478bd9Sstevel@tonic-gate 
608*7c478bd9Sstevel@tonic-gate 		if (resbmap & FATTR4_FS_LOCATIONS_MASK) {
609*7c478bd9Sstevel@tonic-gate 			ASSERT(0);
610*7c478bd9Sstevel@tonic-gate 		}
611*7c478bd9Sstevel@tonic-gate 		if (resbmap & FATTR4_HIDDEN_MASK) {
612*7c478bd9Sstevel@tonic-gate 			ASSERT(0);
613*7c478bd9Sstevel@tonic-gate 		}
614*7c478bd9Sstevel@tonic-gate 		if (resbmap & FATTR4_HOMOGENEOUS_MASK) {
615*7c478bd9Sstevel@tonic-gate 			if (!XDR_GETINT32(xdrs, (int *)&truefalse))
616*7c478bd9Sstevel@tonic-gate 				return (FALSE);
617*7c478bd9Sstevel@tonic-gate 			gesp->n4g_pc4.pc4_homogeneous =
618*7c478bd9Sstevel@tonic-gate 				(truefalse ? TRUE : FALSE);
619*7c478bd9Sstevel@tonic-gate 		}
620*7c478bd9Sstevel@tonic-gate 	}
621*7c478bd9Sstevel@tonic-gate 	if (resbmap &
622*7c478bd9Sstevel@tonic-gate 	    (FATTR4_MAXFILESIZE_MASK |
623*7c478bd9Sstevel@tonic-gate 	    FATTR4_MAXLINK_MASK |
624*7c478bd9Sstevel@tonic-gate 	    FATTR4_MAXNAME_MASK |
625*7c478bd9Sstevel@tonic-gate 	    FATTR4_MAXREAD_MASK |
626*7c478bd9Sstevel@tonic-gate 	    FATTR4_MAXWRITE_MASK)) {
627*7c478bd9Sstevel@tonic-gate 
628*7c478bd9Sstevel@tonic-gate 		if (resbmap & FATTR4_MAXFILESIZE_MASK) {
629*7c478bd9Sstevel@tonic-gate 			if (!xdr_u_longlong_t(xdrs,
630*7c478bd9Sstevel@tonic-gate 				(u_longlong_t *)&gesp->n4g_maxfilesize))
631*7c478bd9Sstevel@tonic-gate 				return (FALSE);
632*7c478bd9Sstevel@tonic-gate 		}
633*7c478bd9Sstevel@tonic-gate 		if (resbmap & FATTR4_MAXLINK_MASK) {
634*7c478bd9Sstevel@tonic-gate 			if (!XDR_GETINT32(xdrs,
635*7c478bd9Sstevel@tonic-gate 					(int *)&gesp->n4g_pc4.pc4_link_max))
636*7c478bd9Sstevel@tonic-gate 				return (FALSE);
637*7c478bd9Sstevel@tonic-gate 		}
638*7c478bd9Sstevel@tonic-gate 		if (resbmap & FATTR4_MAXNAME_MASK) {
639*7c478bd9Sstevel@tonic-gate 			if (!XDR_GETINT32(xdrs,
640*7c478bd9Sstevel@tonic-gate 					(int *)&gesp->n4g_pc4.pc4_name_max))
641*7c478bd9Sstevel@tonic-gate 				return (FALSE);
642*7c478bd9Sstevel@tonic-gate 			gesp->n4g_sb.f_namemax = gesp->n4g_pc4.pc4_name_max;
643*7c478bd9Sstevel@tonic-gate 		}
644*7c478bd9Sstevel@tonic-gate 		if (resbmap & FATTR4_MAXREAD_MASK) {
645*7c478bd9Sstevel@tonic-gate 			if (!xdr_u_longlong_t(xdrs,
646*7c478bd9Sstevel@tonic-gate 				(u_longlong_t *)&gesp->n4g_maxread))
647*7c478bd9Sstevel@tonic-gate 				return (FALSE);
648*7c478bd9Sstevel@tonic-gate 		}
649*7c478bd9Sstevel@tonic-gate 		if (resbmap & FATTR4_MAXWRITE_MASK) {
650*7c478bd9Sstevel@tonic-gate 			if (!xdr_u_longlong_t(xdrs,
651*7c478bd9Sstevel@tonic-gate 				(u_longlong_t *)&gesp->n4g_maxwrite))
652*7c478bd9Sstevel@tonic-gate 				return (FALSE);
653*7c478bd9Sstevel@tonic-gate 		}
654*7c478bd9Sstevel@tonic-gate 	}
655*7c478bd9Sstevel@tonic-gate 	if (resbmap &
656*7c478bd9Sstevel@tonic-gate 	    (FATTR4_MIMETYPE_MASK |
657*7c478bd9Sstevel@tonic-gate 	    FATTR4_MODE_MASK |
658*7c478bd9Sstevel@tonic-gate 	    FATTR4_NO_TRUNC_MASK |
659*7c478bd9Sstevel@tonic-gate 	    FATTR4_NUMLINKS_MASK)) {
660*7c478bd9Sstevel@tonic-gate 
661*7c478bd9Sstevel@tonic-gate 		if (resbmap & FATTR4_MIMETYPE_MASK) {
662*7c478bd9Sstevel@tonic-gate 			ASSERT(0);
663*7c478bd9Sstevel@tonic-gate 		}
664*7c478bd9Sstevel@tonic-gate 		if (resbmap & FATTR4_MODE_MASK) {
665*7c478bd9Sstevel@tonic-gate 			if (!XDR_GETINT32(xdrs, (int *)&vap->va_mode))
666*7c478bd9Sstevel@tonic-gate 				return (FALSE);
667*7c478bd9Sstevel@tonic-gate 			vap->va_mask |= AT_MODE;
668*7c478bd9Sstevel@tonic-gate 		}
669*7c478bd9Sstevel@tonic-gate 		if (resbmap & FATTR4_NO_TRUNC_MASK) {
670*7c478bd9Sstevel@tonic-gate 			if (!XDR_GETINT32(xdrs, (int *)&truefalse))
671*7c478bd9Sstevel@tonic-gate 				return (FALSE);
672*7c478bd9Sstevel@tonic-gate 			gesp->n4g_pc4.pc4_no_trunc =
673*7c478bd9Sstevel@tonic-gate 				(truefalse ? TRUE : FALSE);
674*7c478bd9Sstevel@tonic-gate 		}
675*7c478bd9Sstevel@tonic-gate 		if (resbmap & FATTR4_NUMLINKS_MASK) {
676*7c478bd9Sstevel@tonic-gate 			if (!XDR_GETINT32(xdrs, (int *)&vap->va_nlink))
677*7c478bd9Sstevel@tonic-gate 				return (FALSE);
678*7c478bd9Sstevel@tonic-gate 			vap->va_mask |= AT_NLINK;
679*7c478bd9Sstevel@tonic-gate 		}
680*7c478bd9Sstevel@tonic-gate 	}
681*7c478bd9Sstevel@tonic-gate 	if (resbmap &
682*7c478bd9Sstevel@tonic-gate 	    (FATTR4_OWNER_MASK |
683*7c478bd9Sstevel@tonic-gate 	    FATTR4_OWNER_GROUP_MASK |
684*7c478bd9Sstevel@tonic-gate 	    FATTR4_QUOTA_AVAIL_HARD_MASK |
685*7c478bd9Sstevel@tonic-gate 	    FATTR4_QUOTA_AVAIL_SOFT_MASK)) {
686*7c478bd9Sstevel@tonic-gate 
687*7c478bd9Sstevel@tonic-gate 		if (resbmap & FATTR4_OWNER_MASK) {
688*7c478bd9Sstevel@tonic-gate 			uint_t *owner_length, ol;
689*7c478bd9Sstevel@tonic-gate 			char *owner_val = NULL;
690*7c478bd9Sstevel@tonic-gate 			char *owner_alloc = NULL;
691*7c478bd9Sstevel@tonic-gate 			utf8string ov;
692*7c478bd9Sstevel@tonic-gate 			int error;
693*7c478bd9Sstevel@tonic-gate 
694*7c478bd9Sstevel@tonic-gate 			/* get the OWNER_LENGTH */
695*7c478bd9Sstevel@tonic-gate 			if (!xdr_u_int(xdrs, &ol))
696*7c478bd9Sstevel@tonic-gate 				return (FALSE);
697*7c478bd9Sstevel@tonic-gate 
698*7c478bd9Sstevel@tonic-gate 			/* Manage the owner length location */
699*7c478bd9Sstevel@tonic-gate 			if (pug && ol <= MAX_OG_NAME) {
700*7c478bd9Sstevel@tonic-gate 				owner_length = &pug->u_curr.utf8string_len;
701*7c478bd9Sstevel@tonic-gate 				*owner_length = ol;
702*7c478bd9Sstevel@tonic-gate 			} else {
703*7c478bd9Sstevel@tonic-gate 				owner_length = &ol;
704*7c478bd9Sstevel@tonic-gate 			}
705*7c478bd9Sstevel@tonic-gate 
706*7c478bd9Sstevel@tonic-gate 			/* find memory to store the decode */
707*7c478bd9Sstevel@tonic-gate 			if (*owner_length > MAX_OG_NAME || pug == NULL)
708*7c478bd9Sstevel@tonic-gate 				owner_val = owner_alloc =
709*7c478bd9Sstevel@tonic-gate 					kmem_alloc(*owner_length, KM_SLEEP);
710*7c478bd9Sstevel@tonic-gate 			else
711*7c478bd9Sstevel@tonic-gate 				owner_val = pug->u_curr.utf8string_val;
712*7c478bd9Sstevel@tonic-gate 
713*7c478bd9Sstevel@tonic-gate 			/* get the OWNER string */
714*7c478bd9Sstevel@tonic-gate 			if (!xdr_opaque(xdrs, owner_val, *owner_length)) {
715*7c478bd9Sstevel@tonic-gate 				if (owner_alloc)
716*7c478bd9Sstevel@tonic-gate 					kmem_free(owner_alloc, *owner_length);
717*7c478bd9Sstevel@tonic-gate 				return (FALSE);
718*7c478bd9Sstevel@tonic-gate 			}
719*7c478bd9Sstevel@tonic-gate 
720*7c478bd9Sstevel@tonic-gate 			/* Optimize for matching if called for */
721*7c478bd9Sstevel@tonic-gate 			if (pug &&
722*7c478bd9Sstevel@tonic-gate 			    *owner_length == pug->u_last.utf8string_len &&
723*7c478bd9Sstevel@tonic-gate 			    bcmp(owner_val, pug->u_last.utf8string_val,
724*7c478bd9Sstevel@tonic-gate 					*owner_length) == 0) {
725*7c478bd9Sstevel@tonic-gate 				vap->va_uid = pug->uid;
726*7c478bd9Sstevel@tonic-gate 				vap->va_mask |= AT_UID;
727*7c478bd9Sstevel@tonic-gate 			} else {
728*7c478bd9Sstevel@tonic-gate 				uid_t uid;
729*7c478bd9Sstevel@tonic-gate 
730*7c478bd9Sstevel@tonic-gate 				ov.utf8string_len = *owner_length;
731*7c478bd9Sstevel@tonic-gate 				ov.utf8string_val = owner_val;
732*7c478bd9Sstevel@tonic-gate 				error = nfs_idmap_str_uid(&ov, &uid, FALSE);
733*7c478bd9Sstevel@tonic-gate 				/*
734*7c478bd9Sstevel@tonic-gate 				 * String was mapped, but to nobody because
735*7c478bd9Sstevel@tonic-gate 				 * we are nfsmapid, indicate it should not
736*7c478bd9Sstevel@tonic-gate 				 * be cached.
737*7c478bd9Sstevel@tonic-gate 				 */
738*7c478bd9Sstevel@tonic-gate 				if (error == ENOTSUP) {
739*7c478bd9Sstevel@tonic-gate 					error = 0;
740*7c478bd9Sstevel@tonic-gate 					garp->n4g_attrwhy =
741*7c478bd9Sstevel@tonic-gate 						NFS4_GETATTR_NOCACHE_OK;
742*7c478bd9Sstevel@tonic-gate 				}
743*7c478bd9Sstevel@tonic-gate 
744*7c478bd9Sstevel@tonic-gate 				if (error) {
745*7c478bd9Sstevel@tonic-gate 					garp->n4g_attrerr = error;
746*7c478bd9Sstevel@tonic-gate 					garp->n4g_attrwhy =
747*7c478bd9Sstevel@tonic-gate 						NFS4_GETATTR_ATUID_ERR;
748*7c478bd9Sstevel@tonic-gate 				} else {
749*7c478bd9Sstevel@tonic-gate 					vap->va_uid = uid;
750*7c478bd9Sstevel@tonic-gate 					vap->va_mask |= AT_UID;
751*7c478bd9Sstevel@tonic-gate 					if (pug && ol <= MAX_OG_NAME) {
752*7c478bd9Sstevel@tonic-gate 						pug->uid = uid;
753*7c478bd9Sstevel@tonic-gate 						U_SWAP_CURR_LAST(pug);
754*7c478bd9Sstevel@tonic-gate 					}
755*7c478bd9Sstevel@tonic-gate 				}
756*7c478bd9Sstevel@tonic-gate 				if (owner_alloc)
757*7c478bd9Sstevel@tonic-gate 					kmem_free(owner_alloc, *owner_length);
758*7c478bd9Sstevel@tonic-gate 			}
759*7c478bd9Sstevel@tonic-gate 		}
760*7c478bd9Sstevel@tonic-gate 		if (resbmap & FATTR4_OWNER_GROUP_MASK) {
761*7c478bd9Sstevel@tonic-gate 			uint_t *group_length, gl;
762*7c478bd9Sstevel@tonic-gate 			char *group_val = NULL;
763*7c478bd9Sstevel@tonic-gate 			char *group_alloc = NULL;
764*7c478bd9Sstevel@tonic-gate 			utf8string gv;
765*7c478bd9Sstevel@tonic-gate 			int error;
766*7c478bd9Sstevel@tonic-gate 
767*7c478bd9Sstevel@tonic-gate 			/* get the OWNER_GROUP_LENGTH */
768*7c478bd9Sstevel@tonic-gate 			if (!xdr_u_int(xdrs, &gl))
769*7c478bd9Sstevel@tonic-gate 				return (FALSE);
770*7c478bd9Sstevel@tonic-gate 
771*7c478bd9Sstevel@tonic-gate 			/* Manage the group length location */
772*7c478bd9Sstevel@tonic-gate 			if (pug && gl <= MAX_OG_NAME) {
773*7c478bd9Sstevel@tonic-gate 				group_length = &pug->g_curr.utf8string_len;
774*7c478bd9Sstevel@tonic-gate 				*group_length = gl;
775*7c478bd9Sstevel@tonic-gate 			} else {
776*7c478bd9Sstevel@tonic-gate 				group_length = &gl;
777*7c478bd9Sstevel@tonic-gate 			}
778*7c478bd9Sstevel@tonic-gate 
779*7c478bd9Sstevel@tonic-gate 			/* find memory to store the decode */
780*7c478bd9Sstevel@tonic-gate 			if (*group_length > MAX_OG_NAME || pug == NULL)
781*7c478bd9Sstevel@tonic-gate 				group_val = group_alloc =
782*7c478bd9Sstevel@tonic-gate 					kmem_alloc(*group_length, KM_SLEEP);
783*7c478bd9Sstevel@tonic-gate 			else
784*7c478bd9Sstevel@tonic-gate 				group_val = pug->g_curr.utf8string_val;
785*7c478bd9Sstevel@tonic-gate 
786*7c478bd9Sstevel@tonic-gate 			/* get the OWNER_GROUP string */
787*7c478bd9Sstevel@tonic-gate 			if (!xdr_opaque(xdrs, group_val, *group_length)) {
788*7c478bd9Sstevel@tonic-gate 				if (group_alloc)
789*7c478bd9Sstevel@tonic-gate 					kmem_free(group_alloc, *group_length);
790*7c478bd9Sstevel@tonic-gate 				return (FALSE);
791*7c478bd9Sstevel@tonic-gate 			}
792*7c478bd9Sstevel@tonic-gate 
793*7c478bd9Sstevel@tonic-gate 			/* Optimize for matching if called for */
794*7c478bd9Sstevel@tonic-gate 			if (pug &&
795*7c478bd9Sstevel@tonic-gate 			    *group_length == pug->g_last.utf8string_len &&
796*7c478bd9Sstevel@tonic-gate 			    bcmp(group_val, pug->g_last.utf8string_val,
797*7c478bd9Sstevel@tonic-gate 					*group_length) == 0) {
798*7c478bd9Sstevel@tonic-gate 				vap->va_gid = pug->gid;
799*7c478bd9Sstevel@tonic-gate 				vap->va_mask |= AT_GID;
800*7c478bd9Sstevel@tonic-gate 			} else {
801*7c478bd9Sstevel@tonic-gate 				uid_t gid;
802*7c478bd9Sstevel@tonic-gate 
803*7c478bd9Sstevel@tonic-gate 				gv.utf8string_len = *group_length;
804*7c478bd9Sstevel@tonic-gate 				gv.utf8string_val = group_val;
805*7c478bd9Sstevel@tonic-gate 				error = nfs_idmap_str_gid(&gv, &gid, FALSE);
806*7c478bd9Sstevel@tonic-gate 				/*
807*7c478bd9Sstevel@tonic-gate 				 * String was mapped, but to nobody because
808*7c478bd9Sstevel@tonic-gate 				 * we are nfsmapid, indicate it should not
809*7c478bd9Sstevel@tonic-gate 				 * be cached.
810*7c478bd9Sstevel@tonic-gate 				 */
811*7c478bd9Sstevel@tonic-gate 				if (error == ENOTSUP) {
812*7c478bd9Sstevel@tonic-gate 					error = 0;
813*7c478bd9Sstevel@tonic-gate 					garp->n4g_attrwhy =
814*7c478bd9Sstevel@tonic-gate 						NFS4_GETATTR_NOCACHE_OK;
815*7c478bd9Sstevel@tonic-gate 				}
816*7c478bd9Sstevel@tonic-gate 
817*7c478bd9Sstevel@tonic-gate 				if (error) {
818*7c478bd9Sstevel@tonic-gate 					garp->n4g_attrerr = error;
819*7c478bd9Sstevel@tonic-gate 					garp->n4g_attrwhy =
820*7c478bd9Sstevel@tonic-gate 						NFS4_GETATTR_ATGID_ERR;
821*7c478bd9Sstevel@tonic-gate 				} else {
822*7c478bd9Sstevel@tonic-gate 					vap->va_gid = gid;
823*7c478bd9Sstevel@tonic-gate 					vap->va_mask |= AT_GID;
824*7c478bd9Sstevel@tonic-gate 					if (pug && gl <= MAX_OG_NAME) {
825*7c478bd9Sstevel@tonic-gate 						pug->gid = gid;
826*7c478bd9Sstevel@tonic-gate 						G_SWAP_CURR_LAST(pug);
827*7c478bd9Sstevel@tonic-gate 					}
828*7c478bd9Sstevel@tonic-gate 				}
829*7c478bd9Sstevel@tonic-gate 				if (group_alloc) {
830*7c478bd9Sstevel@tonic-gate 					kmem_free(group_alloc, *group_length);
831*7c478bd9Sstevel@tonic-gate 				}
832*7c478bd9Sstevel@tonic-gate 			}
833*7c478bd9Sstevel@tonic-gate 		}
834*7c478bd9Sstevel@tonic-gate 		if (resbmap & FATTR4_QUOTA_AVAIL_HARD_MASK) {
835*7c478bd9Sstevel@tonic-gate 			ASSERT(0);
836*7c478bd9Sstevel@tonic-gate 		}
837*7c478bd9Sstevel@tonic-gate 		if (resbmap & FATTR4_QUOTA_AVAIL_SOFT_MASK) {
838*7c478bd9Sstevel@tonic-gate 			ASSERT(0);
839*7c478bd9Sstevel@tonic-gate 		}
840*7c478bd9Sstevel@tonic-gate 	}
841*7c478bd9Sstevel@tonic-gate 	if (resbmap &
842*7c478bd9Sstevel@tonic-gate 	    (FATTR4_QUOTA_USED_MASK |
843*7c478bd9Sstevel@tonic-gate 	    FATTR4_SPACE_AVAIL_MASK |
844*7c478bd9Sstevel@tonic-gate 	    FATTR4_SPACE_FREE_MASK |
845*7c478bd9Sstevel@tonic-gate 	    FATTR4_SPACE_TOTAL_MASK |
846*7c478bd9Sstevel@tonic-gate 	    FATTR4_SPACE_USED_MASK |
847*7c478bd9Sstevel@tonic-gate 	    FATTR4_SYSTEM_MASK)) {
848*7c478bd9Sstevel@tonic-gate 
849*7c478bd9Sstevel@tonic-gate 		if (resbmap & FATTR4_QUOTA_USED_MASK) {
850*7c478bd9Sstevel@tonic-gate 			ASSERT(0);
851*7c478bd9Sstevel@tonic-gate 		}
852*7c478bd9Sstevel@tonic-gate 		if (resbmap & FATTR4_RAWDEV_MASK) {
853*7c478bd9Sstevel@tonic-gate 			fattr4_rawdev rawdev;
854*7c478bd9Sstevel@tonic-gate 			if (!xdr_fattr4_rawdev(xdrs, &rawdev))
855*7c478bd9Sstevel@tonic-gate 				return (FALSE);
856*7c478bd9Sstevel@tonic-gate 
857*7c478bd9Sstevel@tonic-gate 			if (vap->va_type == VCHR || vap->va_type == VBLK) {
858*7c478bd9Sstevel@tonic-gate 				vap->va_rdev = makedevice(rawdev.specdata1,
859*7c478bd9Sstevel@tonic-gate 							rawdev.specdata2);
860*7c478bd9Sstevel@tonic-gate 			} else {
861*7c478bd9Sstevel@tonic-gate 				vap->va_rdev = 0;
862*7c478bd9Sstevel@tonic-gate 			}
863*7c478bd9Sstevel@tonic-gate 			vap->va_mask |= AT_RDEV;
864*7c478bd9Sstevel@tonic-gate 		}
865*7c478bd9Sstevel@tonic-gate 		if (resbmap & FATTR4_SPACE_AVAIL_MASK) {
866*7c478bd9Sstevel@tonic-gate 			if (!xdr_u_longlong_t(xdrs,
867*7c478bd9Sstevel@tonic-gate 				(u_longlong_t *)&gesp->n4g_sb.f_bavail))
868*7c478bd9Sstevel@tonic-gate 				return (FALSE);
869*7c478bd9Sstevel@tonic-gate 			gesp->n4g_sb.f_bavail /= DEV_BSIZE;
870*7c478bd9Sstevel@tonic-gate 		}
871*7c478bd9Sstevel@tonic-gate 		if (resbmap & FATTR4_SPACE_FREE_MASK) {
872*7c478bd9Sstevel@tonic-gate 			if (!xdr_u_longlong_t(xdrs,
873*7c478bd9Sstevel@tonic-gate 				(u_longlong_t *)&gesp->n4g_sb.f_bfree))
874*7c478bd9Sstevel@tonic-gate 				return (FALSE);
875*7c478bd9Sstevel@tonic-gate 			gesp->n4g_sb.f_bfree /= DEV_BSIZE;
876*7c478bd9Sstevel@tonic-gate 		}
877*7c478bd9Sstevel@tonic-gate 		if (resbmap & FATTR4_SPACE_TOTAL_MASK) {
878*7c478bd9Sstevel@tonic-gate 			if (!xdr_u_longlong_t(xdrs,
879*7c478bd9Sstevel@tonic-gate 				(u_longlong_t *)&gesp->n4g_sb.f_blocks))
880*7c478bd9Sstevel@tonic-gate 				return (FALSE);
881*7c478bd9Sstevel@tonic-gate 			gesp->n4g_sb.f_blocks /= DEV_BSIZE;
882*7c478bd9Sstevel@tonic-gate 		}
883*7c478bd9Sstevel@tonic-gate 		if (resbmap & FATTR4_SPACE_USED_MASK) {
884*7c478bd9Sstevel@tonic-gate 			uint64_t space_used;
885*7c478bd9Sstevel@tonic-gate 			if (!xdr_u_longlong_t(xdrs,
886*7c478bd9Sstevel@tonic-gate 						(u_longlong_t *)&space_used))
887*7c478bd9Sstevel@tonic-gate 				return (FALSE);
888*7c478bd9Sstevel@tonic-gate 
889*7c478bd9Sstevel@tonic-gate 			/* Compute space depending on device type */
890*7c478bd9Sstevel@tonic-gate 			ASSERT((vap->va_mask & AT_TYPE));
891*7c478bd9Sstevel@tonic-gate 			if (vap->va_type == VREG || vap->va_type == VDIR ||
892*7c478bd9Sstevel@tonic-gate 			    vap->va_type == VLNK) {
893*7c478bd9Sstevel@tonic-gate 				vap->va_nblocks = (u_longlong_t)
894*7c478bd9Sstevel@tonic-gate 					((space_used + (offset4)DEV_BSIZE -
895*7c478bd9Sstevel@tonic-gate 					(offset4)1) / (offset4)DEV_BSIZE);
896*7c478bd9Sstevel@tonic-gate 			} else {
897*7c478bd9Sstevel@tonic-gate 				vap->va_nblocks = 0;
898*7c478bd9Sstevel@tonic-gate 			}
899*7c478bd9Sstevel@tonic-gate 			vap->va_mask |= AT_NBLOCKS;
900*7c478bd9Sstevel@tonic-gate 		}
901*7c478bd9Sstevel@tonic-gate 		if (resbmap & FATTR4_SYSTEM_MASK) {
902*7c478bd9Sstevel@tonic-gate 			ASSERT(0);
903*7c478bd9Sstevel@tonic-gate 		}
904*7c478bd9Sstevel@tonic-gate 	}
905*7c478bd9Sstevel@tonic-gate 	if (resbmap &
906*7c478bd9Sstevel@tonic-gate 	    (FATTR4_TIME_ACCESS_MASK |
907*7c478bd9Sstevel@tonic-gate 	    FATTR4_TIME_ACCESS_SET_MASK |
908*7c478bd9Sstevel@tonic-gate 	    FATTR4_TIME_BACKUP_MASK |
909*7c478bd9Sstevel@tonic-gate 	    FATTR4_TIME_CREATE_MASK |
910*7c478bd9Sstevel@tonic-gate 	    FATTR4_TIME_DELTA_MASK |
911*7c478bd9Sstevel@tonic-gate 	    FATTR4_TIME_METADATA_MASK |
912*7c478bd9Sstevel@tonic-gate 	    FATTR4_TIME_MODIFY_MASK |
913*7c478bd9Sstevel@tonic-gate 	    FATTR4_TIME_MODIFY_SET_MASK |
914*7c478bd9Sstevel@tonic-gate 	    FATTR4_MOUNTED_ON_FILEID_MASK)) {
915*7c478bd9Sstevel@tonic-gate 
916*7c478bd9Sstevel@tonic-gate 		if (resbmap & FATTR4_TIME_ACCESS_MASK) {
917*7c478bd9Sstevel@tonic-gate 			nfstime4 atime;
918*7c478bd9Sstevel@tonic-gate 			int error;
919*7c478bd9Sstevel@tonic-gate 
920*7c478bd9Sstevel@tonic-gate 			if (!xdr_longlong_t(xdrs,
921*7c478bd9Sstevel@tonic-gate 					    (longlong_t *)&atime.seconds))
922*7c478bd9Sstevel@tonic-gate 				return (FALSE);
923*7c478bd9Sstevel@tonic-gate 			if (!XDR_GETINT32(xdrs, (int *)&atime.nseconds))
924*7c478bd9Sstevel@tonic-gate 				return (FALSE);
925*7c478bd9Sstevel@tonic-gate 			error = nfs4_time_ntov(&atime, &vap->va_atime);
926*7c478bd9Sstevel@tonic-gate 			if (error) {
927*7c478bd9Sstevel@tonic-gate 				garp->n4g_attrerr = error;
928*7c478bd9Sstevel@tonic-gate 				garp->n4g_attrwhy = NFS4_GETATTR_ATATIME_ERR;
929*7c478bd9Sstevel@tonic-gate 			}
930*7c478bd9Sstevel@tonic-gate 			vap->va_mask |= AT_ATIME;
931*7c478bd9Sstevel@tonic-gate 		}
932*7c478bd9Sstevel@tonic-gate 		if (resbmap & FATTR4_TIME_ACCESS_SET_MASK) {
933*7c478bd9Sstevel@tonic-gate 			ASSERT(0);
934*7c478bd9Sstevel@tonic-gate 		}
935*7c478bd9Sstevel@tonic-gate 		if (resbmap & FATTR4_TIME_BACKUP_MASK) {
936*7c478bd9Sstevel@tonic-gate 			ASSERT(0);
937*7c478bd9Sstevel@tonic-gate 		}
938*7c478bd9Sstevel@tonic-gate 		if (resbmap & FATTR4_TIME_CREATE_MASK) {
939*7c478bd9Sstevel@tonic-gate 			ASSERT(0);
940*7c478bd9Sstevel@tonic-gate 		}
941*7c478bd9Sstevel@tonic-gate 		if (resbmap & FATTR4_TIME_DELTA_MASK) {
942*7c478bd9Sstevel@tonic-gate 			if ((!xdr_u_longlong_t(xdrs,
943*7c478bd9Sstevel@tonic-gate 			    (u_longlong_t *)&gesp->n4g_delta.seconds)) ||
944*7c478bd9Sstevel@tonic-gate 			    (!xdr_u_int(xdrs, &gesp->n4g_delta.nseconds)))
945*7c478bd9Sstevel@tonic-gate 				return (FALSE);
946*7c478bd9Sstevel@tonic-gate 		}
947*7c478bd9Sstevel@tonic-gate 		if (resbmap & FATTR4_TIME_METADATA_MASK) {
948*7c478bd9Sstevel@tonic-gate 			nfstime4 mdt;
949*7c478bd9Sstevel@tonic-gate 			int error;
950*7c478bd9Sstevel@tonic-gate 
951*7c478bd9Sstevel@tonic-gate 			if (!xdr_longlong_t(xdrs, (longlong_t *)&mdt.seconds))
952*7c478bd9Sstevel@tonic-gate 				return (FALSE);
953*7c478bd9Sstevel@tonic-gate 			if (!XDR_GETINT32(xdrs, (int32_t *)&mdt.nseconds))
954*7c478bd9Sstevel@tonic-gate 				return (FALSE);
955*7c478bd9Sstevel@tonic-gate 			error = nfs4_time_ntov(&mdt, &vap->va_ctime);
956*7c478bd9Sstevel@tonic-gate 			if (error) {
957*7c478bd9Sstevel@tonic-gate 				garp->n4g_attrerr = error;
958*7c478bd9Sstevel@tonic-gate 				garp->n4g_attrwhy = NFS4_GETATTR_ATCTIME_ERR;
959*7c478bd9Sstevel@tonic-gate 			}
960*7c478bd9Sstevel@tonic-gate 			vap->va_mask |= AT_CTIME;
961*7c478bd9Sstevel@tonic-gate 		}
962*7c478bd9Sstevel@tonic-gate 		if (resbmap & FATTR4_TIME_MODIFY_MASK) {
963*7c478bd9Sstevel@tonic-gate 			nfstime4 mtime;
964*7c478bd9Sstevel@tonic-gate 			int error;
965*7c478bd9Sstevel@tonic-gate 
966*7c478bd9Sstevel@tonic-gate 			if (!xdr_longlong_t(xdrs,
967*7c478bd9Sstevel@tonic-gate 					    (longlong_t *)&mtime.seconds))
968*7c478bd9Sstevel@tonic-gate 				return (FALSE);
969*7c478bd9Sstevel@tonic-gate 			if (!XDR_GETINT32(xdrs, (int32_t *)&mtime.nseconds))
970*7c478bd9Sstevel@tonic-gate 				return (FALSE);
971*7c478bd9Sstevel@tonic-gate 			error = nfs4_time_ntov(&mtime, &vap->va_mtime);
972*7c478bd9Sstevel@tonic-gate 			if (error) {
973*7c478bd9Sstevel@tonic-gate 				garp->n4g_attrerr = error;
974*7c478bd9Sstevel@tonic-gate 				garp->n4g_attrwhy = NFS4_GETATTR_ATMTIME_ERR;
975*7c478bd9Sstevel@tonic-gate 			}
976*7c478bd9Sstevel@tonic-gate 			vap->va_mask |= AT_MTIME;
977*7c478bd9Sstevel@tonic-gate 		}
978*7c478bd9Sstevel@tonic-gate 		if (resbmap & FATTR4_TIME_MODIFY_SET_MASK) {
979*7c478bd9Sstevel@tonic-gate 			ASSERT(0);
980*7c478bd9Sstevel@tonic-gate 		}
981*7c478bd9Sstevel@tonic-gate 		if (resbmap & FATTR4_MOUNTED_ON_FILEID_MASK) {
982*7c478bd9Sstevel@tonic-gate 			if (!xdr_u_longlong_t(xdrs,
983*7c478bd9Sstevel@tonic-gate 					(u_longlong_t *)&garp->n4g_mon_fid))
984*7c478bd9Sstevel@tonic-gate 				return (FALSE);
985*7c478bd9Sstevel@tonic-gate 			garp->n4g_mon_fid_valid = 1;
986*7c478bd9Sstevel@tonic-gate 		}
987*7c478bd9Sstevel@tonic-gate 	}
988*7c478bd9Sstevel@tonic-gate 
989*7c478bd9Sstevel@tonic-gate 	if (resbmap & ~(NFS4_VATTR_MASK | FATTR4_ACL_MASK)) {
990*7c478bd9Sstevel@tonic-gate 		/* copy only if not provided */
991*7c478bd9Sstevel@tonic-gate 		if (garp->n4g_ext_res == NULL) {
992*7c478bd9Sstevel@tonic-gate 			garp->n4g_ext_res = kmem_alloc(sizeof (ges), KM_SLEEP);
993*7c478bd9Sstevel@tonic-gate 			bcopy(&ges, garp->n4g_ext_res, sizeof (ges));
994*7c478bd9Sstevel@tonic-gate 		}
995*7c478bd9Sstevel@tonic-gate 	}
996*7c478bd9Sstevel@tonic-gate 
997*7c478bd9Sstevel@tonic-gate 	return (TRUE);
998*7c478bd9Sstevel@tonic-gate }
999*7c478bd9Sstevel@tonic-gate 
1000*7c478bd9Sstevel@tonic-gate /*
1001*7c478bd9Sstevel@tonic-gate  * Inlined version of get_bitmap4 processing
1002*7c478bd9Sstevel@tonic-gate  */
1003*7c478bd9Sstevel@tonic-gate bitmap4
1004*7c478bd9Sstevel@tonic-gate xdr_get_bitmap4_inline(uint32_t **iptr)
1005*7c478bd9Sstevel@tonic-gate {
1006*7c478bd9Sstevel@tonic-gate 	uint32_t resbmaplen;
1007*7c478bd9Sstevel@tonic-gate 	bitmap4 bm;
1008*7c478bd9Sstevel@tonic-gate 	uint32_t *ptr = *iptr;
1009*7c478bd9Sstevel@tonic-gate 
1010*7c478bd9Sstevel@tonic-gate 	/* bitmap LENGTH */
1011*7c478bd9Sstevel@tonic-gate 	resbmaplen = IXDR_GET_U_INT32(ptr);
1012*7c478bd9Sstevel@tonic-gate 
1013*7c478bd9Sstevel@tonic-gate 	/* Inline the bitmap and attrlen for common case of two word map */
1014*7c478bd9Sstevel@tonic-gate 	if (resbmaplen == 2) {
1015*7c478bd9Sstevel@tonic-gate 		IXDR_GET_HYPER(ptr, bm);
1016*7c478bd9Sstevel@tonic-gate 		*iptr = ptr;
1017*7c478bd9Sstevel@tonic-gate 		return (bm);
1018*7c478bd9Sstevel@tonic-gate 	}
1019*7c478bd9Sstevel@tonic-gate 
1020*7c478bd9Sstevel@tonic-gate #if defined(_LITTLE_ENDIAN)
1021*7c478bd9Sstevel@tonic-gate 	bm = IXDR_GET_U_INT32(ptr);
1022*7c478bd9Sstevel@tonic-gate 	if (--resbmaplen == 0) {
1023*7c478bd9Sstevel@tonic-gate 		*iptr = ptr;
1024*7c478bd9Sstevel@tonic-gate 		return (bm);
1025*7c478bd9Sstevel@tonic-gate 	}
1026*7c478bd9Sstevel@tonic-gate 	*((uint32_t *)&bm) |= IXDR_GET_U_INT32(ptr);
1027*7c478bd9Sstevel@tonic-gate 	if (--resbmaplen == 0) {
1028*7c478bd9Sstevel@tonic-gate 		*iptr = ptr;
1029*7c478bd9Sstevel@tonic-gate 		return (bm);
1030*7c478bd9Sstevel@tonic-gate 	}
1031*7c478bd9Sstevel@tonic-gate 	ptr += resbmaplen;
1032*7c478bd9Sstevel@tonic-gate 	*iptr = ptr;
1033*7c478bd9Sstevel@tonic-gate 	return (bm);
1034*7c478bd9Sstevel@tonic-gate #elif defined(_BIG_ENDIAN)
1035*7c478bd9Sstevel@tonic-gate 	*((uint32_t *)&bm) = IXDR_GET_U_INT32(ptr);
1036*7c478bd9Sstevel@tonic-gate 	if (--resbmaplen == 0) {
1037*7c478bd9Sstevel@tonic-gate 		*iptr = ptr;
1038*7c478bd9Sstevel@tonic-gate 		return (bm);
1039*7c478bd9Sstevel@tonic-gate 	}
1040*7c478bd9Sstevel@tonic-gate 	bm |= IXDR_GET_U_INT32(ptr);
1041*7c478bd9Sstevel@tonic-gate 	if (--resbmaplen == 0) {
1042*7c478bd9Sstevel@tonic-gate 		*iptr = ptr;
1043*7c478bd9Sstevel@tonic-gate 		return (bm);
1044*7c478bd9Sstevel@tonic-gate 	}
1045*7c478bd9Sstevel@tonic-gate 	ptr += resbmaplen;
1046*7c478bd9Sstevel@tonic-gate 	*iptr = ptr;
1047*7c478bd9Sstevel@tonic-gate 	return (bm);
1048*7c478bd9Sstevel@tonic-gate #else
1049*7c478bd9Sstevel@tonic-gate 	ASSERT(0);
1050*7c478bd9Sstevel@tonic-gate 	ptr += resbmaplen;
1051*7c478bd9Sstevel@tonic-gate 	*iptr = ptr;
1052*7c478bd9Sstevel@tonic-gate 	return (0);
1053*7c478bd9Sstevel@tonic-gate #endif
1054*7c478bd9Sstevel@tonic-gate }
1055*7c478bd9Sstevel@tonic-gate 
1056*7c478bd9Sstevel@tonic-gate static bool_t
1057*7c478bd9Sstevel@tonic-gate xdr_ga_fattr_res_inline(uint32_t *ptr, struct nfs4_ga_res *garp,
1058*7c478bd9Sstevel@tonic-gate 			bitmap4 resbmap, bitmap4 argbmap, struct mntinfo4 *mi,
1059*7c478bd9Sstevel@tonic-gate 			ug_cache_t *pug)
1060*7c478bd9Sstevel@tonic-gate {
1061*7c478bd9Sstevel@tonic-gate 	int truefalse;
1062*7c478bd9Sstevel@tonic-gate 	struct nfs4_ga_ext_res ges, *gesp;
1063*7c478bd9Sstevel@tonic-gate 	vattr_t *vap = &garp->n4g_va;
1064*7c478bd9Sstevel@tonic-gate 
1065*7c478bd9Sstevel@tonic-gate 	if (garp->n4g_ext_res)
1066*7c478bd9Sstevel@tonic-gate 		gesp = garp->n4g_ext_res;
1067*7c478bd9Sstevel@tonic-gate 	else
1068*7c478bd9Sstevel@tonic-gate 		gesp = &ges;
1069*7c478bd9Sstevel@tonic-gate 
1070*7c478bd9Sstevel@tonic-gate 	vap->va_mask = 0;
1071*7c478bd9Sstevel@tonic-gate 
1072*7c478bd9Sstevel@tonic-gate 	/* Check to see if the vattr should be pre-filled */
1073*7c478bd9Sstevel@tonic-gate 	if (argbmap & NFS4_VATTR_MASK)
1074*7c478bd9Sstevel@tonic-gate 		xdr_ga_prefill_vattr(garp, mi);
1075*7c478bd9Sstevel@tonic-gate 
1076*7c478bd9Sstevel@tonic-gate 	if (argbmap & NFS4_STATFS_ATTR_MASK)
1077*7c478bd9Sstevel@tonic-gate 		xdr_ga_prefill_statvfs(gesp, mi);
1078*7c478bd9Sstevel@tonic-gate 
1079*7c478bd9Sstevel@tonic-gate 	if (resbmap &
1080*7c478bd9Sstevel@tonic-gate 	    (FATTR4_SUPPORTED_ATTRS_MASK |
1081*7c478bd9Sstevel@tonic-gate 	    FATTR4_TYPE_MASK |
1082*7c478bd9Sstevel@tonic-gate 	    FATTR4_FH_EXPIRE_TYPE_MASK |
1083*7c478bd9Sstevel@tonic-gate 	    FATTR4_CHANGE_MASK |
1084*7c478bd9Sstevel@tonic-gate 	    FATTR4_SIZE_MASK |
1085*7c478bd9Sstevel@tonic-gate 	    FATTR4_LINK_SUPPORT_MASK |
1086*7c478bd9Sstevel@tonic-gate 	    FATTR4_SYMLINK_SUPPORT_MASK |
1087*7c478bd9Sstevel@tonic-gate 	    FATTR4_NAMED_ATTR_MASK)) {
1088*7c478bd9Sstevel@tonic-gate 
1089*7c478bd9Sstevel@tonic-gate 		if (resbmap & FATTR4_SUPPORTED_ATTRS_MASK) {
1090*7c478bd9Sstevel@tonic-gate 			gesp->n4g_suppattrs = xdr_get_bitmap4_inline(&ptr);
1091*7c478bd9Sstevel@tonic-gate 		}
1092*7c478bd9Sstevel@tonic-gate 		if (resbmap & FATTR4_TYPE_MASK) {
1093*7c478bd9Sstevel@tonic-gate 			vap->va_type = IXDR_GET_U_INT32(ptr);
1094*7c478bd9Sstevel@tonic-gate 
1095*7c478bd9Sstevel@tonic-gate 			if (vap->va_type < NF4REG ||
1096*7c478bd9Sstevel@tonic-gate 			    vap->va_type > NF4NAMEDATTR)
1097*7c478bd9Sstevel@tonic-gate 				vap->va_type = VBAD;
1098*7c478bd9Sstevel@tonic-gate 			else
1099*7c478bd9Sstevel@tonic-gate 				vap->va_type = nf4_to_vt[vap->va_type];
1100*7c478bd9Sstevel@tonic-gate 			if (vap->va_type == VBLK)
1101*7c478bd9Sstevel@tonic-gate 				vap->va_blksize = DEV_BSIZE;
1102*7c478bd9Sstevel@tonic-gate 
1103*7c478bd9Sstevel@tonic-gate 			vap->va_mask |= AT_TYPE;
1104*7c478bd9Sstevel@tonic-gate 		}
1105*7c478bd9Sstevel@tonic-gate 		if (resbmap & FATTR4_FH_EXPIRE_TYPE_MASK) {
1106*7c478bd9Sstevel@tonic-gate 			gesp->n4g_fet = IXDR_GET_U_INT32(ptr);
1107*7c478bd9Sstevel@tonic-gate 		}
1108*7c478bd9Sstevel@tonic-gate 		if (resbmap & FATTR4_CHANGE_MASK) {
1109*7c478bd9Sstevel@tonic-gate 			IXDR_GET_U_HYPER(ptr, garp->n4g_change);
1110*7c478bd9Sstevel@tonic-gate 			garp->n4g_change_valid = 1;
1111*7c478bd9Sstevel@tonic-gate 		}
1112*7c478bd9Sstevel@tonic-gate 		if (resbmap & FATTR4_SIZE_MASK) {
1113*7c478bd9Sstevel@tonic-gate 			IXDR_GET_U_HYPER(ptr, vap->va_size);
1114*7c478bd9Sstevel@tonic-gate 
1115*7c478bd9Sstevel@tonic-gate 			if (!NFS4_SIZE_OK(vap->va_size)) {
1116*7c478bd9Sstevel@tonic-gate 				garp->n4g_attrerr = EFBIG;
1117*7c478bd9Sstevel@tonic-gate 				garp->n4g_attrwhy = NFS4_GETATTR_ATSIZE_ERR;
1118*7c478bd9Sstevel@tonic-gate 			} else {
1119*7c478bd9Sstevel@tonic-gate 				vap->va_mask |= AT_SIZE;
1120*7c478bd9Sstevel@tonic-gate 			}
1121*7c478bd9Sstevel@tonic-gate 		}
1122*7c478bd9Sstevel@tonic-gate 		if (resbmap & FATTR4_LINK_SUPPORT_MASK) {
1123*7c478bd9Sstevel@tonic-gate 			truefalse = IXDR_GET_U_INT32(ptr);
1124*7c478bd9Sstevel@tonic-gate 			gesp->n4g_pc4.pc4_link_support =
1125*7c478bd9Sstevel@tonic-gate 				(truefalse ? TRUE : FALSE);
1126*7c478bd9Sstevel@tonic-gate 		}
1127*7c478bd9Sstevel@tonic-gate 		if (resbmap & FATTR4_SYMLINK_SUPPORT_MASK) {
1128*7c478bd9Sstevel@tonic-gate 			truefalse = IXDR_GET_U_INT32(ptr);
1129*7c478bd9Sstevel@tonic-gate 			gesp->n4g_pc4.pc4_symlink_support =
1130*7c478bd9Sstevel@tonic-gate 				(truefalse ? TRUE : FALSE);
1131*7c478bd9Sstevel@tonic-gate 		}
1132*7c478bd9Sstevel@tonic-gate 		if (resbmap & FATTR4_NAMED_ATTR_MASK) {
1133*7c478bd9Sstevel@tonic-gate 			truefalse = IXDR_GET_U_INT32(ptr);
1134*7c478bd9Sstevel@tonic-gate 			gesp->n4g_pc4.pc4_xattr_exists = TRUE;
1135*7c478bd9Sstevel@tonic-gate 			gesp->n4g_pc4.pc4_xattr_exists =
1136*7c478bd9Sstevel@tonic-gate 				(truefalse ? TRUE : FALSE);
1137*7c478bd9Sstevel@tonic-gate 		}
1138*7c478bd9Sstevel@tonic-gate 	}
1139*7c478bd9Sstevel@tonic-gate 	if (resbmap &
1140*7c478bd9Sstevel@tonic-gate 	    (FATTR4_FSID_MASK |
1141*7c478bd9Sstevel@tonic-gate 	    FATTR4_UNIQUE_HANDLES_MASK |
1142*7c478bd9Sstevel@tonic-gate 	    FATTR4_LEASE_TIME_MASK |
1143*7c478bd9Sstevel@tonic-gate 	    FATTR4_RDATTR_ERROR_MASK)) {
1144*7c478bd9Sstevel@tonic-gate 
1145*7c478bd9Sstevel@tonic-gate 		if (resbmap & FATTR4_FSID_MASK) {
1146*7c478bd9Sstevel@tonic-gate 			IXDR_GET_U_HYPER(ptr, garp->n4g_fsid.major);
1147*7c478bd9Sstevel@tonic-gate 			IXDR_GET_U_HYPER(ptr, garp->n4g_fsid.minor);
1148*7c478bd9Sstevel@tonic-gate 			garp->n4g_fsid_valid = 1;
1149*7c478bd9Sstevel@tonic-gate 		}
1150*7c478bd9Sstevel@tonic-gate 		if (resbmap & FATTR4_UNIQUE_HANDLES_MASK) {
1151*7c478bd9Sstevel@tonic-gate 			truefalse = IXDR_GET_U_INT32(ptr);
1152*7c478bd9Sstevel@tonic-gate 			gesp->n4g_pc4.pc4_unique_handles =
1153*7c478bd9Sstevel@tonic-gate 				(truefalse ? TRUE : FALSE);
1154*7c478bd9Sstevel@tonic-gate 		}
1155*7c478bd9Sstevel@tonic-gate 		if (resbmap & FATTR4_LEASE_TIME_MASK) {
1156*7c478bd9Sstevel@tonic-gate 			gesp->n4g_leasetime = IXDR_GET_U_INT32(ptr);
1157*7c478bd9Sstevel@tonic-gate 		}
1158*7c478bd9Sstevel@tonic-gate 		if (resbmap & FATTR4_RDATTR_ERROR_MASK) {
1159*7c478bd9Sstevel@tonic-gate 			gesp->n4g_rdattr_error = IXDR_GET_U_INT32(ptr);
1160*7c478bd9Sstevel@tonic-gate 		}
1161*7c478bd9Sstevel@tonic-gate 	}
1162*7c478bd9Sstevel@tonic-gate 	if (resbmap &
1163*7c478bd9Sstevel@tonic-gate 	    (FATTR4_ACL_MASK |
1164*7c478bd9Sstevel@tonic-gate 	    FATTR4_ACLSUPPORT_MASK |
1165*7c478bd9Sstevel@tonic-gate 	    FATTR4_ARCHIVE_MASK |
1166*7c478bd9Sstevel@tonic-gate 	    FATTR4_CANSETTIME_MASK)) {
1167*7c478bd9Sstevel@tonic-gate 
1168*7c478bd9Sstevel@tonic-gate 		if (resbmap & FATTR4_ACL_MASK) {
1169*7c478bd9Sstevel@tonic-gate 			ASSERT(0);
1170*7c478bd9Sstevel@tonic-gate 		}
1171*7c478bd9Sstevel@tonic-gate 		if (resbmap & FATTR4_ACLSUPPORT_MASK) {
1172*7c478bd9Sstevel@tonic-gate 			gesp->n4g_aclsupport = IXDR_GET_U_INT32(ptr);
1173*7c478bd9Sstevel@tonic-gate 		}
1174*7c478bd9Sstevel@tonic-gate 		if (resbmap & FATTR4_ARCHIVE_MASK) {
1175*7c478bd9Sstevel@tonic-gate 			ASSERT(0);
1176*7c478bd9Sstevel@tonic-gate 		}
1177*7c478bd9Sstevel@tonic-gate 		if (resbmap & FATTR4_CANSETTIME_MASK) {
1178*7c478bd9Sstevel@tonic-gate 			truefalse = IXDR_GET_U_INT32(ptr);
1179*7c478bd9Sstevel@tonic-gate 			gesp->n4g_pc4.pc4_cansettime =
1180*7c478bd9Sstevel@tonic-gate 				(truefalse ? TRUE : FALSE);
1181*7c478bd9Sstevel@tonic-gate 		}
1182*7c478bd9Sstevel@tonic-gate 	}
1183*7c478bd9Sstevel@tonic-gate 	if (resbmap &
1184*7c478bd9Sstevel@tonic-gate 	    (FATTR4_CASE_INSENSITIVE_MASK |
1185*7c478bd9Sstevel@tonic-gate 	    FATTR4_CASE_PRESERVING_MASK |
1186*7c478bd9Sstevel@tonic-gate 	    FATTR4_CHOWN_RESTRICTED_MASK |
1187*7c478bd9Sstevel@tonic-gate 	    FATTR4_FILEHANDLE_MASK |
1188*7c478bd9Sstevel@tonic-gate 	    FATTR4_FILEID_MASK |
1189*7c478bd9Sstevel@tonic-gate 	    FATTR4_FILES_AVAIL_MASK |
1190*7c478bd9Sstevel@tonic-gate 	    FATTR4_FILES_FREE_MASK |
1191*7c478bd9Sstevel@tonic-gate 	    FATTR4_FILES_TOTAL_MASK)) {
1192*7c478bd9Sstevel@tonic-gate 
1193*7c478bd9Sstevel@tonic-gate 		if (resbmap & FATTR4_CASE_INSENSITIVE_MASK) {
1194*7c478bd9Sstevel@tonic-gate 			truefalse = IXDR_GET_U_INT32(ptr);
1195*7c478bd9Sstevel@tonic-gate 			gesp->n4g_pc4.pc4_case_insensitive =
1196*7c478bd9Sstevel@tonic-gate 				(truefalse ? TRUE : FALSE);
1197*7c478bd9Sstevel@tonic-gate 		}
1198*7c478bd9Sstevel@tonic-gate 		if (resbmap & FATTR4_CASE_PRESERVING_MASK) {
1199*7c478bd9Sstevel@tonic-gate 			truefalse = IXDR_GET_U_INT32(ptr);
1200*7c478bd9Sstevel@tonic-gate 			gesp->n4g_pc4.pc4_case_preserving =
1201*7c478bd9Sstevel@tonic-gate 				(truefalse ? TRUE : FALSE);
1202*7c478bd9Sstevel@tonic-gate 		}
1203*7c478bd9Sstevel@tonic-gate 		if (resbmap & FATTR4_CHOWN_RESTRICTED_MASK) {
1204*7c478bd9Sstevel@tonic-gate 			truefalse = IXDR_GET_U_INT32(ptr);
1205*7c478bd9Sstevel@tonic-gate 			gesp->n4g_pc4.pc4_chown_restricted =
1206*7c478bd9Sstevel@tonic-gate 				(truefalse ? TRUE : FALSE);
1207*7c478bd9Sstevel@tonic-gate 		}
1208*7c478bd9Sstevel@tonic-gate 		if (resbmap & FATTR4_FILEHANDLE_MASK) {
1209*7c478bd9Sstevel@tonic-gate 			int len = IXDR_GET_U_INT32(ptr);
1210*7c478bd9Sstevel@tonic-gate 
1211*7c478bd9Sstevel@tonic-gate 			gesp->n4g_fh_u.nfs_fh4_alt.len = 0;
1212*7c478bd9Sstevel@tonic-gate 			gesp->n4g_fh_u.nfs_fh4_alt.val =
1213*7c478bd9Sstevel@tonic-gate 				gesp->n4g_fh_u.nfs_fh4_alt.data;
1214*7c478bd9Sstevel@tonic-gate 			gesp->n4g_fh_u.n4g_fh.nfs_fh4_len = len;
1215*7c478bd9Sstevel@tonic-gate 
1216*7c478bd9Sstevel@tonic-gate 			bcopy(ptr, gesp->n4g_fh_u.n4g_fh.nfs_fh4_val, len);
1217*7c478bd9Sstevel@tonic-gate 
1218*7c478bd9Sstevel@tonic-gate 			ptr += RNDUP(len) / BYTES_PER_XDR_UNIT;
1219*7c478bd9Sstevel@tonic-gate 		}
1220*7c478bd9Sstevel@tonic-gate 		if (resbmap & FATTR4_FILEID_MASK) {
1221*7c478bd9Sstevel@tonic-gate 			IXDR_GET_U_HYPER(ptr, vap->va_nodeid);
1222*7c478bd9Sstevel@tonic-gate 			vap->va_mask |= AT_NODEID;
1223*7c478bd9Sstevel@tonic-gate 		}
1224*7c478bd9Sstevel@tonic-gate 		if (resbmap & FATTR4_FILES_AVAIL_MASK) {
1225*7c478bd9Sstevel@tonic-gate 			IXDR_GET_U_HYPER(ptr, gesp->n4g_sb.f_favail);
1226*7c478bd9Sstevel@tonic-gate 		}
1227*7c478bd9Sstevel@tonic-gate 		if (resbmap & FATTR4_FILES_FREE_MASK) {
1228*7c478bd9Sstevel@tonic-gate 			IXDR_GET_U_HYPER(ptr, gesp->n4g_sb.f_ffree);
1229*7c478bd9Sstevel@tonic-gate 		}
1230*7c478bd9Sstevel@tonic-gate 		if (resbmap & FATTR4_FILES_TOTAL_MASK) {
1231*7c478bd9Sstevel@tonic-gate 			IXDR_GET_U_HYPER(ptr, gesp->n4g_sb.f_files);
1232*7c478bd9Sstevel@tonic-gate 		}
1233*7c478bd9Sstevel@tonic-gate 	}
1234*7c478bd9Sstevel@tonic-gate 	if (resbmap &
1235*7c478bd9Sstevel@tonic-gate 	    (FATTR4_FS_LOCATIONS_MASK |
1236*7c478bd9Sstevel@tonic-gate 	    FATTR4_HIDDEN_MASK |
1237*7c478bd9Sstevel@tonic-gate 	    FATTR4_HOMOGENEOUS_MASK)) {
1238*7c478bd9Sstevel@tonic-gate 
1239*7c478bd9Sstevel@tonic-gate 		if (resbmap & FATTR4_FS_LOCATIONS_MASK) {
1240*7c478bd9Sstevel@tonic-gate 			ASSERT(0);
1241*7c478bd9Sstevel@tonic-gate 		}
1242*7c478bd9Sstevel@tonic-gate 		if (resbmap & FATTR4_HIDDEN_MASK) {
1243*7c478bd9Sstevel@tonic-gate 			ASSERT(0);
1244*7c478bd9Sstevel@tonic-gate 		}
1245*7c478bd9Sstevel@tonic-gate 		if (resbmap & FATTR4_HOMOGENEOUS_MASK) {
1246*7c478bd9Sstevel@tonic-gate 			truefalse = IXDR_GET_U_INT32(ptr);
1247*7c478bd9Sstevel@tonic-gate 			gesp->n4g_pc4.pc4_homogeneous =
1248*7c478bd9Sstevel@tonic-gate 				(truefalse ? TRUE : FALSE);
1249*7c478bd9Sstevel@tonic-gate 		}
1250*7c478bd9Sstevel@tonic-gate 	}
1251*7c478bd9Sstevel@tonic-gate 	if (resbmap &
1252*7c478bd9Sstevel@tonic-gate 	    (FATTR4_MAXFILESIZE_MASK |
1253*7c478bd9Sstevel@tonic-gate 	    FATTR4_MAXLINK_MASK |
1254*7c478bd9Sstevel@tonic-gate 	    FATTR4_MAXNAME_MASK |
1255*7c478bd9Sstevel@tonic-gate 	    FATTR4_MAXREAD_MASK |
1256*7c478bd9Sstevel@tonic-gate 	    FATTR4_MAXWRITE_MASK)) {
1257*7c478bd9Sstevel@tonic-gate 
1258*7c478bd9Sstevel@tonic-gate 		if (resbmap & FATTR4_MAXFILESIZE_MASK) {
1259*7c478bd9Sstevel@tonic-gate 			IXDR_GET_U_HYPER(ptr, gesp->n4g_maxfilesize);
1260*7c478bd9Sstevel@tonic-gate 		}
1261*7c478bd9Sstevel@tonic-gate 		if (resbmap & FATTR4_MAXLINK_MASK) {
1262*7c478bd9Sstevel@tonic-gate 			gesp->n4g_pc4.pc4_link_max = IXDR_GET_U_INT32(ptr);
1263*7c478bd9Sstevel@tonic-gate 		}
1264*7c478bd9Sstevel@tonic-gate 		if (resbmap & FATTR4_MAXNAME_MASK) {
1265*7c478bd9Sstevel@tonic-gate 			gesp->n4g_pc4.pc4_name_max = IXDR_GET_U_INT32(ptr);
1266*7c478bd9Sstevel@tonic-gate 			gesp->n4g_sb.f_namemax = gesp->n4g_pc4.pc4_name_max;
1267*7c478bd9Sstevel@tonic-gate 		}
1268*7c478bd9Sstevel@tonic-gate 		if (resbmap & FATTR4_MAXREAD_MASK) {
1269*7c478bd9Sstevel@tonic-gate 			IXDR_GET_U_HYPER(ptr, gesp->n4g_maxread);
1270*7c478bd9Sstevel@tonic-gate 		}
1271*7c478bd9Sstevel@tonic-gate 		if (resbmap & FATTR4_MAXWRITE_MASK) {
1272*7c478bd9Sstevel@tonic-gate 			IXDR_GET_U_HYPER(ptr, gesp->n4g_maxwrite);
1273*7c478bd9Sstevel@tonic-gate 		}
1274*7c478bd9Sstevel@tonic-gate 	}
1275*7c478bd9Sstevel@tonic-gate 	if (resbmap &
1276*7c478bd9Sstevel@tonic-gate 	    (FATTR4_MIMETYPE_MASK |
1277*7c478bd9Sstevel@tonic-gate 	    FATTR4_MODE_MASK |
1278*7c478bd9Sstevel@tonic-gate 	    FATTR4_NO_TRUNC_MASK |
1279*7c478bd9Sstevel@tonic-gate 	    FATTR4_NUMLINKS_MASK)) {
1280*7c478bd9Sstevel@tonic-gate 
1281*7c478bd9Sstevel@tonic-gate 		if (resbmap & FATTR4_MIMETYPE_MASK) {
1282*7c478bd9Sstevel@tonic-gate 			ASSERT(0);
1283*7c478bd9Sstevel@tonic-gate 		}
1284*7c478bd9Sstevel@tonic-gate 		if (resbmap & FATTR4_MODE_MASK) {
1285*7c478bd9Sstevel@tonic-gate 			vap->va_mode = IXDR_GET_U_INT32(ptr);
1286*7c478bd9Sstevel@tonic-gate 			vap->va_mask |= AT_MODE;
1287*7c478bd9Sstevel@tonic-gate 		}
1288*7c478bd9Sstevel@tonic-gate 		if (resbmap & FATTR4_NO_TRUNC_MASK) {
1289*7c478bd9Sstevel@tonic-gate 			truefalse = IXDR_GET_U_INT32(ptr);
1290*7c478bd9Sstevel@tonic-gate 			gesp->n4g_pc4.pc4_no_trunc =
1291*7c478bd9Sstevel@tonic-gate 				(truefalse ? TRUE : FALSE);
1292*7c478bd9Sstevel@tonic-gate 		}
1293*7c478bd9Sstevel@tonic-gate 		if (resbmap & FATTR4_NUMLINKS_MASK) {
1294*7c478bd9Sstevel@tonic-gate 			vap->va_nlink = IXDR_GET_U_INT32(ptr);
1295*7c478bd9Sstevel@tonic-gate 			vap->va_mask |= AT_NLINK;
1296*7c478bd9Sstevel@tonic-gate 		}
1297*7c478bd9Sstevel@tonic-gate 	}
1298*7c478bd9Sstevel@tonic-gate 	if (resbmap &
1299*7c478bd9Sstevel@tonic-gate 	    (FATTR4_OWNER_MASK |
1300*7c478bd9Sstevel@tonic-gate 	    FATTR4_OWNER_GROUP_MASK |
1301*7c478bd9Sstevel@tonic-gate 	    FATTR4_QUOTA_AVAIL_HARD_MASK |
1302*7c478bd9Sstevel@tonic-gate 	    FATTR4_QUOTA_AVAIL_SOFT_MASK)) {
1303*7c478bd9Sstevel@tonic-gate 
1304*7c478bd9Sstevel@tonic-gate 		if (resbmap & FATTR4_OWNER_MASK) {
1305*7c478bd9Sstevel@tonic-gate 			uint_t *owner_length, ol;
1306*7c478bd9Sstevel@tonic-gate 			char *owner_val = NULL;
1307*7c478bd9Sstevel@tonic-gate 			utf8string ov;
1308*7c478bd9Sstevel@tonic-gate 			int error;
1309*7c478bd9Sstevel@tonic-gate 
1310*7c478bd9Sstevel@tonic-gate 			/* get the OWNER_LENGTH */
1311*7c478bd9Sstevel@tonic-gate 			ol = IXDR_GET_U_INT32(ptr);
1312*7c478bd9Sstevel@tonic-gate 
1313*7c478bd9Sstevel@tonic-gate 			/* Manage the owner length location */
1314*7c478bd9Sstevel@tonic-gate 			if (pug && ol <= MAX_OG_NAME) {
1315*7c478bd9Sstevel@tonic-gate 				owner_length = &pug->u_curr.utf8string_len;
1316*7c478bd9Sstevel@tonic-gate 				*owner_length = ol;
1317*7c478bd9Sstevel@tonic-gate 			} else {
1318*7c478bd9Sstevel@tonic-gate 				owner_length = &ol;
1319*7c478bd9Sstevel@tonic-gate 			}
1320*7c478bd9Sstevel@tonic-gate 
1321*7c478bd9Sstevel@tonic-gate 			/* find memory to store the decode */
1322*7c478bd9Sstevel@tonic-gate 			if (*owner_length > MAX_OG_NAME || pug == NULL)
1323*7c478bd9Sstevel@tonic-gate 				owner_val = (char *)ptr;
1324*7c478bd9Sstevel@tonic-gate 			else
1325*7c478bd9Sstevel@tonic-gate 				owner_val = (char *)ptr;
1326*7c478bd9Sstevel@tonic-gate 
1327*7c478bd9Sstevel@tonic-gate 			/* Optimize for matching if called for */
1328*7c478bd9Sstevel@tonic-gate 			if (pug &&
1329*7c478bd9Sstevel@tonic-gate 			    *owner_length == pug->u_last.utf8string_len &&
1330*7c478bd9Sstevel@tonic-gate 			    bcmp(owner_val, pug->u_last.utf8string_val,
1331*7c478bd9Sstevel@tonic-gate 					*owner_length) == 0) {
1332*7c478bd9Sstevel@tonic-gate 				vap->va_uid = pug->uid;
1333*7c478bd9Sstevel@tonic-gate 				vap->va_mask |= AT_UID;
1334*7c478bd9Sstevel@tonic-gate 			} else {
1335*7c478bd9Sstevel@tonic-gate 				uid_t uid;
1336*7c478bd9Sstevel@tonic-gate 
1337*7c478bd9Sstevel@tonic-gate 				ov.utf8string_len = *owner_length;
1338*7c478bd9Sstevel@tonic-gate 				ov.utf8string_val = owner_val;
1339*7c478bd9Sstevel@tonic-gate 				error = nfs_idmap_str_uid(&ov, &uid, FALSE);
1340*7c478bd9Sstevel@tonic-gate 				/*
1341*7c478bd9Sstevel@tonic-gate 				 * String was mapped, but to nobody because
1342*7c478bd9Sstevel@tonic-gate 				 * we are nfsmapid, indicate it should not
1343*7c478bd9Sstevel@tonic-gate 				 * be cached.
1344*7c478bd9Sstevel@tonic-gate 				 */
1345*7c478bd9Sstevel@tonic-gate 				if (error == ENOTSUP) {
1346*7c478bd9Sstevel@tonic-gate 					error = 0;
1347*7c478bd9Sstevel@tonic-gate 					garp->n4g_attrwhy =
1348*7c478bd9Sstevel@tonic-gate 						NFS4_GETATTR_NOCACHE_OK;
1349*7c478bd9Sstevel@tonic-gate 				}
1350*7c478bd9Sstevel@tonic-gate 
1351*7c478bd9Sstevel@tonic-gate 				if (error) {
1352*7c478bd9Sstevel@tonic-gate 					garp->n4g_attrerr = error;
1353*7c478bd9Sstevel@tonic-gate 					garp->n4g_attrwhy =
1354*7c478bd9Sstevel@tonic-gate 						NFS4_GETATTR_ATUID_ERR;
1355*7c478bd9Sstevel@tonic-gate 				} else {
1356*7c478bd9Sstevel@tonic-gate 					vap->va_uid = uid;
1357*7c478bd9Sstevel@tonic-gate 					vap->va_mask |= AT_UID;
1358*7c478bd9Sstevel@tonic-gate 					/* save the results for next time */
1359*7c478bd9Sstevel@tonic-gate 					if (pug && ol <= MAX_OG_NAME) {
1360*7c478bd9Sstevel@tonic-gate 						pug->uid = uid;
1361*7c478bd9Sstevel@tonic-gate 						pug->u_curr.utf8string_len =
1362*7c478bd9Sstevel@tonic-gate 							ov.utf8string_len;
1363*7c478bd9Sstevel@tonic-gate 						bcopy(owner_val,
1364*7c478bd9Sstevel@tonic-gate 						pug->u_curr.utf8string_val, ol);
1365*7c478bd9Sstevel@tonic-gate 						U_SWAP_CURR_LAST(pug);
1366*7c478bd9Sstevel@tonic-gate 					}
1367*7c478bd9Sstevel@tonic-gate 				}
1368*7c478bd9Sstevel@tonic-gate 			}
1369*7c478bd9Sstevel@tonic-gate 			ptr += RNDUP(ol) / BYTES_PER_XDR_UNIT;
1370*7c478bd9Sstevel@tonic-gate 		}
1371*7c478bd9Sstevel@tonic-gate 		if (resbmap & FATTR4_OWNER_GROUP_MASK) {
1372*7c478bd9Sstevel@tonic-gate 			uint_t *group_length, gl;
1373*7c478bd9Sstevel@tonic-gate 			char *group_val = NULL;
1374*7c478bd9Sstevel@tonic-gate 			utf8string gv;
1375*7c478bd9Sstevel@tonic-gate 			int error;
1376*7c478bd9Sstevel@tonic-gate 
1377*7c478bd9Sstevel@tonic-gate 			/* get the OWNER_GROUP_LENGTH */
1378*7c478bd9Sstevel@tonic-gate 			gl = IXDR_GET_U_INT32(ptr);
1379*7c478bd9Sstevel@tonic-gate 
1380*7c478bd9Sstevel@tonic-gate 			/* Manage the group length location */
1381*7c478bd9Sstevel@tonic-gate 			if (pug && gl <= MAX_OG_NAME) {
1382*7c478bd9Sstevel@tonic-gate 				group_length = &pug->g_curr.utf8string_len;
1383*7c478bd9Sstevel@tonic-gate 				*group_length = gl;
1384*7c478bd9Sstevel@tonic-gate 			} else {
1385*7c478bd9Sstevel@tonic-gate 				group_length = &gl;
1386*7c478bd9Sstevel@tonic-gate 			}
1387*7c478bd9Sstevel@tonic-gate 
1388*7c478bd9Sstevel@tonic-gate 			/* find memory to store the decode */
1389*7c478bd9Sstevel@tonic-gate 			if (*group_length > MAX_OG_NAME || pug == NULL)
1390*7c478bd9Sstevel@tonic-gate 				group_val = (char *)ptr;
1391*7c478bd9Sstevel@tonic-gate 			else
1392*7c478bd9Sstevel@tonic-gate 				group_val = (char *)ptr;
1393*7c478bd9Sstevel@tonic-gate 
1394*7c478bd9Sstevel@tonic-gate 			/* Optimize for matching if called for */
1395*7c478bd9Sstevel@tonic-gate 			if (pug &&
1396*7c478bd9Sstevel@tonic-gate 			    *group_length == pug->g_last.utf8string_len &&
1397*7c478bd9Sstevel@tonic-gate 			    bcmp(group_val, pug->g_last.utf8string_val,
1398*7c478bd9Sstevel@tonic-gate 					*group_length) == 0) {
1399*7c478bd9Sstevel@tonic-gate 				vap->va_gid = pug->gid;
1400*7c478bd9Sstevel@tonic-gate 				vap->va_mask |= AT_GID;
1401*7c478bd9Sstevel@tonic-gate 			} else {
1402*7c478bd9Sstevel@tonic-gate 				uid_t gid;
1403*7c478bd9Sstevel@tonic-gate 
1404*7c478bd9Sstevel@tonic-gate 				gv.utf8string_len = *group_length;
1405*7c478bd9Sstevel@tonic-gate 				gv.utf8string_val = group_val;
1406*7c478bd9Sstevel@tonic-gate 				error = nfs_idmap_str_gid(&gv, &gid, FALSE);
1407*7c478bd9Sstevel@tonic-gate 				/*
1408*7c478bd9Sstevel@tonic-gate 				 * String was mapped, but to nobody because
1409*7c478bd9Sstevel@tonic-gate 				 * we are nfsmapid, indicate it should not
1410*7c478bd9Sstevel@tonic-gate 				 * be cached.
1411*7c478bd9Sstevel@tonic-gate 				 */
1412*7c478bd9Sstevel@tonic-gate 				if (error == ENOTSUP) {
1413*7c478bd9Sstevel@tonic-gate 					error = 0;
1414*7c478bd9Sstevel@tonic-gate 					garp->n4g_attrwhy =
1415*7c478bd9Sstevel@tonic-gate 						NFS4_GETATTR_NOCACHE_OK;
1416*7c478bd9Sstevel@tonic-gate 				}
1417*7c478bd9Sstevel@tonic-gate 
1418*7c478bd9Sstevel@tonic-gate 				if (error) {
1419*7c478bd9Sstevel@tonic-gate 					garp->n4g_attrerr = error;
1420*7c478bd9Sstevel@tonic-gate 					garp->n4g_attrwhy =
1421*7c478bd9Sstevel@tonic-gate 						NFS4_GETATTR_ATGID_ERR;
1422*7c478bd9Sstevel@tonic-gate 				} else {
1423*7c478bd9Sstevel@tonic-gate 					vap->va_gid = gid;
1424*7c478bd9Sstevel@tonic-gate 					vap->va_mask |= AT_GID;
1425*7c478bd9Sstevel@tonic-gate 					if (pug && gl <= MAX_OG_NAME) {
1426*7c478bd9Sstevel@tonic-gate 						pug->gid = gid;
1427*7c478bd9Sstevel@tonic-gate 						pug->g_curr.utf8string_len =
1428*7c478bd9Sstevel@tonic-gate 							gv.utf8string_len;
1429*7c478bd9Sstevel@tonic-gate 						bcopy(group_val,
1430*7c478bd9Sstevel@tonic-gate 						    pug->g_curr.utf8string_val,
1431*7c478bd9Sstevel@tonic-gate 						    gl);
1432*7c478bd9Sstevel@tonic-gate 						G_SWAP_CURR_LAST(pug);
1433*7c478bd9Sstevel@tonic-gate 					}
1434*7c478bd9Sstevel@tonic-gate 				}
1435*7c478bd9Sstevel@tonic-gate 			}
1436*7c478bd9Sstevel@tonic-gate 			ptr += RNDUP(gl) / BYTES_PER_XDR_UNIT;
1437*7c478bd9Sstevel@tonic-gate 		}
1438*7c478bd9Sstevel@tonic-gate 		if (resbmap & FATTR4_QUOTA_AVAIL_HARD_MASK) {
1439*7c478bd9Sstevel@tonic-gate 			ASSERT(0);
1440*7c478bd9Sstevel@tonic-gate 		}
1441*7c478bd9Sstevel@tonic-gate 		if (resbmap & FATTR4_QUOTA_AVAIL_SOFT_MASK) {
1442*7c478bd9Sstevel@tonic-gate 			ASSERT(0);
1443*7c478bd9Sstevel@tonic-gate 		}
1444*7c478bd9Sstevel@tonic-gate 	}
1445*7c478bd9Sstevel@tonic-gate 	if (resbmap &
1446*7c478bd9Sstevel@tonic-gate 	    (FATTR4_QUOTA_USED_MASK |
1447*7c478bd9Sstevel@tonic-gate 	    FATTR4_SPACE_AVAIL_MASK |
1448*7c478bd9Sstevel@tonic-gate 	    FATTR4_SPACE_FREE_MASK |
1449*7c478bd9Sstevel@tonic-gate 	    FATTR4_SPACE_TOTAL_MASK |
1450*7c478bd9Sstevel@tonic-gate 	    FATTR4_SPACE_USED_MASK |
1451*7c478bd9Sstevel@tonic-gate 	    FATTR4_SYSTEM_MASK)) {
1452*7c478bd9Sstevel@tonic-gate 
1453*7c478bd9Sstevel@tonic-gate 		if (resbmap & FATTR4_QUOTA_USED_MASK) {
1454*7c478bd9Sstevel@tonic-gate 			ASSERT(0);
1455*7c478bd9Sstevel@tonic-gate 		}
1456*7c478bd9Sstevel@tonic-gate 		if (resbmap & FATTR4_RAWDEV_MASK) {
1457*7c478bd9Sstevel@tonic-gate 			fattr4_rawdev rawdev;
1458*7c478bd9Sstevel@tonic-gate 
1459*7c478bd9Sstevel@tonic-gate 			rawdev.specdata1 = IXDR_GET_U_INT32(ptr);
1460*7c478bd9Sstevel@tonic-gate 			rawdev.specdata2 = IXDR_GET_U_INT32(ptr);
1461*7c478bd9Sstevel@tonic-gate 
1462*7c478bd9Sstevel@tonic-gate 			if (vap->va_type == VCHR || vap->va_type == VBLK) {
1463*7c478bd9Sstevel@tonic-gate 				vap->va_rdev = makedevice(rawdev.specdata1,
1464*7c478bd9Sstevel@tonic-gate 							rawdev.specdata2);
1465*7c478bd9Sstevel@tonic-gate 			} else {
1466*7c478bd9Sstevel@tonic-gate 				vap->va_rdev = 0;
1467*7c478bd9Sstevel@tonic-gate 			}
1468*7c478bd9Sstevel@tonic-gate 			vap->va_mask |= AT_RDEV;
1469*7c478bd9Sstevel@tonic-gate 		}
1470*7c478bd9Sstevel@tonic-gate 		if (resbmap & FATTR4_SPACE_AVAIL_MASK) {
1471*7c478bd9Sstevel@tonic-gate 			IXDR_GET_U_HYPER(ptr, gesp->n4g_sb.f_bavail);
1472*7c478bd9Sstevel@tonic-gate 			gesp->n4g_sb.f_bavail /= DEV_BSIZE;
1473*7c478bd9Sstevel@tonic-gate 		}
1474*7c478bd9Sstevel@tonic-gate 		if (resbmap & FATTR4_SPACE_FREE_MASK) {
1475*7c478bd9Sstevel@tonic-gate 			IXDR_GET_U_HYPER(ptr, gesp->n4g_sb.f_bfree);
1476*7c478bd9Sstevel@tonic-gate 			gesp->n4g_sb.f_bfree /= DEV_BSIZE;
1477*7c478bd9Sstevel@tonic-gate 		}
1478*7c478bd9Sstevel@tonic-gate 		if (resbmap & FATTR4_SPACE_TOTAL_MASK) {
1479*7c478bd9Sstevel@tonic-gate 			IXDR_GET_U_HYPER(ptr, gesp->n4g_sb.f_blocks);
1480*7c478bd9Sstevel@tonic-gate 			gesp->n4g_sb.f_blocks /= DEV_BSIZE;
1481*7c478bd9Sstevel@tonic-gate 		}
1482*7c478bd9Sstevel@tonic-gate 		if (resbmap & FATTR4_SPACE_USED_MASK) {
1483*7c478bd9Sstevel@tonic-gate 			uint64_t space_used;
1484*7c478bd9Sstevel@tonic-gate 			IXDR_GET_U_HYPER(ptr, space_used);
1485*7c478bd9Sstevel@tonic-gate 
1486*7c478bd9Sstevel@tonic-gate 			/* Compute space depending on device type */
1487*7c478bd9Sstevel@tonic-gate 			ASSERT((vap->va_mask & AT_TYPE));
1488*7c478bd9Sstevel@tonic-gate 			if (vap->va_type == VREG || vap->va_type == VDIR ||
1489*7c478bd9Sstevel@tonic-gate 			    vap->va_type == VLNK) {
1490*7c478bd9Sstevel@tonic-gate 				vap->va_nblocks = (u_longlong_t)
1491*7c478bd9Sstevel@tonic-gate 					((space_used + (offset4)DEV_BSIZE -
1492*7c478bd9Sstevel@tonic-gate 					(offset4)1) / (offset4)DEV_BSIZE);
1493*7c478bd9Sstevel@tonic-gate 			} else {
1494*7c478bd9Sstevel@tonic-gate 				vap->va_nblocks = 0;
1495*7c478bd9Sstevel@tonic-gate 			}
1496*7c478bd9Sstevel@tonic-gate 			vap->va_mask |= AT_NBLOCKS;
1497*7c478bd9Sstevel@tonic-gate 		}
1498*7c478bd9Sstevel@tonic-gate 		if (resbmap & FATTR4_SYSTEM_MASK) {
1499*7c478bd9Sstevel@tonic-gate 			ASSERT(0);
1500*7c478bd9Sstevel@tonic-gate 		}
1501*7c478bd9Sstevel@tonic-gate 	}
1502*7c478bd9Sstevel@tonic-gate 	if (resbmap &
1503*7c478bd9Sstevel@tonic-gate 	    (FATTR4_TIME_ACCESS_MASK |
1504*7c478bd9Sstevel@tonic-gate 	    FATTR4_TIME_ACCESS_SET_MASK |
1505*7c478bd9Sstevel@tonic-gate 	    FATTR4_TIME_BACKUP_MASK |
1506*7c478bd9Sstevel@tonic-gate 	    FATTR4_TIME_CREATE_MASK |
1507*7c478bd9Sstevel@tonic-gate 	    FATTR4_TIME_DELTA_MASK |
1508*7c478bd9Sstevel@tonic-gate 	    FATTR4_TIME_METADATA_MASK |
1509*7c478bd9Sstevel@tonic-gate 	    FATTR4_TIME_MODIFY_MASK |
1510*7c478bd9Sstevel@tonic-gate 	    FATTR4_TIME_MODIFY_SET_MASK |
1511*7c478bd9Sstevel@tonic-gate 	    FATTR4_MOUNTED_ON_FILEID_MASK)) {
1512*7c478bd9Sstevel@tonic-gate 
1513*7c478bd9Sstevel@tonic-gate 		if (resbmap & FATTR4_TIME_ACCESS_MASK) {
1514*7c478bd9Sstevel@tonic-gate 			nfstime4 atime;
1515*7c478bd9Sstevel@tonic-gate 			int error;
1516*7c478bd9Sstevel@tonic-gate 
1517*7c478bd9Sstevel@tonic-gate 			IXDR_GET_U_HYPER(ptr, atime.seconds);
1518*7c478bd9Sstevel@tonic-gate 			atime.nseconds = IXDR_GET_U_INT32(ptr);
1519*7c478bd9Sstevel@tonic-gate 
1520*7c478bd9Sstevel@tonic-gate 			error = nfs4_time_ntov(&atime, &vap->va_atime);
1521*7c478bd9Sstevel@tonic-gate 			if (error) {
1522*7c478bd9Sstevel@tonic-gate 				garp->n4g_attrerr = error;
1523*7c478bd9Sstevel@tonic-gate 				garp->n4g_attrwhy = NFS4_GETATTR_ATATIME_ERR;
1524*7c478bd9Sstevel@tonic-gate 			}
1525*7c478bd9Sstevel@tonic-gate 			vap->va_mask |= AT_ATIME;
1526*7c478bd9Sstevel@tonic-gate 		}
1527*7c478bd9Sstevel@tonic-gate 		if (resbmap & FATTR4_TIME_ACCESS_SET_MASK) {
1528*7c478bd9Sstevel@tonic-gate 			ASSERT(0);
1529*7c478bd9Sstevel@tonic-gate 		}
1530*7c478bd9Sstevel@tonic-gate 		if (resbmap & FATTR4_TIME_BACKUP_MASK) {
1531*7c478bd9Sstevel@tonic-gate 			ASSERT(0);
1532*7c478bd9Sstevel@tonic-gate 		}
1533*7c478bd9Sstevel@tonic-gate 		if (resbmap & FATTR4_TIME_CREATE_MASK) {
1534*7c478bd9Sstevel@tonic-gate 			ASSERT(0);
1535*7c478bd9Sstevel@tonic-gate 		}
1536*7c478bd9Sstevel@tonic-gate 		if (resbmap & FATTR4_TIME_DELTA_MASK) {
1537*7c478bd9Sstevel@tonic-gate 			IXDR_GET_U_HYPER(ptr, gesp->n4g_delta.seconds);
1538*7c478bd9Sstevel@tonic-gate 			gesp->n4g_delta.nseconds = IXDR_GET_U_INT32(ptr);
1539*7c478bd9Sstevel@tonic-gate 		}
1540*7c478bd9Sstevel@tonic-gate 		if (resbmap & FATTR4_TIME_METADATA_MASK) {
1541*7c478bd9Sstevel@tonic-gate 			nfstime4 mdt;
1542*7c478bd9Sstevel@tonic-gate 			int error;
1543*7c478bd9Sstevel@tonic-gate 
1544*7c478bd9Sstevel@tonic-gate 			IXDR_GET_U_HYPER(ptr, mdt.seconds);
1545*7c478bd9Sstevel@tonic-gate 			mdt.nseconds = IXDR_GET_U_INT32(ptr);
1546*7c478bd9Sstevel@tonic-gate 
1547*7c478bd9Sstevel@tonic-gate 			error = nfs4_time_ntov(&mdt, &vap->va_ctime);
1548*7c478bd9Sstevel@tonic-gate 			if (error) {
1549*7c478bd9Sstevel@tonic-gate 				garp->n4g_attrerr = error;
1550*7c478bd9Sstevel@tonic-gate 				garp->n4g_attrwhy = NFS4_GETATTR_ATCTIME_ERR;
1551*7c478bd9Sstevel@tonic-gate 			}
1552*7c478bd9Sstevel@tonic-gate 			vap->va_mask |= AT_CTIME;
1553*7c478bd9Sstevel@tonic-gate 		}
1554*7c478bd9Sstevel@tonic-gate 		if (resbmap & FATTR4_TIME_MODIFY_MASK) {
1555*7c478bd9Sstevel@tonic-gate 			nfstime4 mtime;
1556*7c478bd9Sstevel@tonic-gate 			int error;
1557*7c478bd9Sstevel@tonic-gate 
1558*7c478bd9Sstevel@tonic-gate 			IXDR_GET_U_HYPER(ptr, mtime.seconds);
1559*7c478bd9Sstevel@tonic-gate 			mtime.nseconds = IXDR_GET_U_INT32(ptr);
1560*7c478bd9Sstevel@tonic-gate 
1561*7c478bd9Sstevel@tonic-gate 			error = nfs4_time_ntov(&mtime, &vap->va_mtime);
1562*7c478bd9Sstevel@tonic-gate 			if (error) {
1563*7c478bd9Sstevel@tonic-gate 				garp->n4g_attrerr = error;
1564*7c478bd9Sstevel@tonic-gate 				garp->n4g_attrwhy = NFS4_GETATTR_ATMTIME_ERR;
1565*7c478bd9Sstevel@tonic-gate 			}
1566*7c478bd9Sstevel@tonic-gate 			vap->va_mask |= AT_MTIME;
1567*7c478bd9Sstevel@tonic-gate 		}
1568*7c478bd9Sstevel@tonic-gate 		if (resbmap & FATTR4_TIME_MODIFY_SET_MASK) {
1569*7c478bd9Sstevel@tonic-gate 			ASSERT(0);
1570*7c478bd9Sstevel@tonic-gate 		}
1571*7c478bd9Sstevel@tonic-gate 		if (resbmap & FATTR4_MOUNTED_ON_FILEID_MASK) {
1572*7c478bd9Sstevel@tonic-gate 			IXDR_GET_U_HYPER(ptr, garp->n4g_mon_fid);
1573*7c478bd9Sstevel@tonic-gate 			garp->n4g_mon_fid_valid = 1;
1574*7c478bd9Sstevel@tonic-gate 		}
1575*7c478bd9Sstevel@tonic-gate 	}
1576*7c478bd9Sstevel@tonic-gate 
1577*7c478bd9Sstevel@tonic-gate 	/*
1578*7c478bd9Sstevel@tonic-gate 	 * FATTR4_ACL_MASK is not yet supported by this function, but
1579*7c478bd9Sstevel@tonic-gate 	 * we check against it anyway, in case it ever is.
1580*7c478bd9Sstevel@tonic-gate 	 */
1581*7c478bd9Sstevel@tonic-gate 	if (resbmap & ~(NFS4_VATTR_MASK | FATTR4_ACL_MASK)) {
1582*7c478bd9Sstevel@tonic-gate 		/* copy only if not provided */
1583*7c478bd9Sstevel@tonic-gate 		if (garp->n4g_ext_res == NULL) {
1584*7c478bd9Sstevel@tonic-gate 			garp->n4g_ext_res = kmem_alloc(sizeof (ges), KM_SLEEP);
1585*7c478bd9Sstevel@tonic-gate 			bcopy(&ges, garp->n4g_ext_res, sizeof (ges));
1586*7c478bd9Sstevel@tonic-gate 		}
1587*7c478bd9Sstevel@tonic-gate 	}
1588*7c478bd9Sstevel@tonic-gate 
1589*7c478bd9Sstevel@tonic-gate 	return (TRUE);
1590*7c478bd9Sstevel@tonic-gate }
1591*7c478bd9Sstevel@tonic-gate 
1592*7c478bd9Sstevel@tonic-gate 
1593*7c478bd9Sstevel@tonic-gate /*
1594*7c478bd9Sstevel@tonic-gate  * "." and ".." buffers for filling in on read and readdir
1595*7c478bd9Sstevel@tonic-gate  * calls. Intialize the first time and fill in on every
1596*7c478bd9Sstevel@tonic-gate  * call to to readdir.
1597*7c478bd9Sstevel@tonic-gate  */
1598*7c478bd9Sstevel@tonic-gate char	*nfs4_dot_entries;
1599*7c478bd9Sstevel@tonic-gate char	*nfs4_dot_dot_entry;
1600*7c478bd9Sstevel@tonic-gate 
1601*7c478bd9Sstevel@tonic-gate /*
1602*7c478bd9Sstevel@tonic-gate  * Create the "." or ".." and pad the buffer once so they are
1603*7c478bd9Sstevel@tonic-gate  * copied out as required into the user supplied buffer everytime.
1604*7c478bd9Sstevel@tonic-gate  * DIRENT64_RECLEN(sizeof (".") - 1) = DIRENT64_RECLEN(1)
1605*7c478bd9Sstevel@tonic-gate  * DIRENT64_RECLEN(sizeof ("..") - 1) = DIRENT64_RECLEN(2)
1606*7c478bd9Sstevel@tonic-gate  */
1607*7c478bd9Sstevel@tonic-gate void
1608*7c478bd9Sstevel@tonic-gate nfs4_init_dot_entries()
1609*7c478bd9Sstevel@tonic-gate {
1610*7c478bd9Sstevel@tonic-gate 	struct dirent64 *odp;
1611*7c478bd9Sstevel@tonic-gate 
1612*7c478bd9Sstevel@tonic-gate 	/*
1613*7c478bd9Sstevel@tonic-gate 	 * zalloc it so it zeros the buffer out. Need
1614*7c478bd9Sstevel@tonic-gate 	 * to just do it once.
1615*7c478bd9Sstevel@tonic-gate 	 */
1616*7c478bd9Sstevel@tonic-gate 	nfs4_dot_entries = kmem_zalloc(DIRENT64_RECLEN(1) + DIRENT64_RECLEN(2),
1617*7c478bd9Sstevel@tonic-gate 	    KM_SLEEP);
1618*7c478bd9Sstevel@tonic-gate 
1619*7c478bd9Sstevel@tonic-gate 	odp = (struct dirent64 *)nfs4_dot_entries;
1620*7c478bd9Sstevel@tonic-gate 	odp->d_off = 1; /* magic cookie for "." entry */
1621*7c478bd9Sstevel@tonic-gate 	odp->d_reclen = DIRENT64_RECLEN(1);
1622*7c478bd9Sstevel@tonic-gate 	odp->d_name[0] = '.';
1623*7c478bd9Sstevel@tonic-gate 	odp->d_name[1] = '\0';
1624*7c478bd9Sstevel@tonic-gate 
1625*7c478bd9Sstevel@tonic-gate 	nfs4_dot_dot_entry = nfs4_dot_entries + DIRENT64_RECLEN(1);
1626*7c478bd9Sstevel@tonic-gate 	odp = (struct dirent64 *)nfs4_dot_dot_entry;
1627*7c478bd9Sstevel@tonic-gate 
1628*7c478bd9Sstevel@tonic-gate 	odp->d_off = 2;
1629*7c478bd9Sstevel@tonic-gate 	odp->d_reclen = DIRENT64_RECLEN(2);
1630*7c478bd9Sstevel@tonic-gate 	odp->d_name[0] = '.';
1631*7c478bd9Sstevel@tonic-gate 	odp->d_name[1] = '.';
1632*7c478bd9Sstevel@tonic-gate 	odp->d_name[2] = '\0';
1633*7c478bd9Sstevel@tonic-gate }
1634*7c478bd9Sstevel@tonic-gate 
1635*7c478bd9Sstevel@tonic-gate void
1636*7c478bd9Sstevel@tonic-gate nfs4_destroy_dot_entries()
1637*7c478bd9Sstevel@tonic-gate {
1638*7c478bd9Sstevel@tonic-gate 	if (nfs4_dot_entries)
1639*7c478bd9Sstevel@tonic-gate 		kmem_free(nfs4_dot_entries, DIRENT64_RECLEN(1) +
1640*7c478bd9Sstevel@tonic-gate 		    DIRENT64_RECLEN(2));
1641*7c478bd9Sstevel@tonic-gate 
1642*7c478bd9Sstevel@tonic-gate 	nfs4_dot_entries = nfs4_dot_dot_entry = NULL;
1643*7c478bd9Sstevel@tonic-gate }
1644*7c478bd9Sstevel@tonic-gate 
1645*7c478bd9Sstevel@tonic-gate bool_t
1646*7c478bd9Sstevel@tonic-gate xdr_READDIR4res_clnt(XDR *xdrs, READDIR4res_clnt *objp, READDIR4args *aobjp)
1647*7c478bd9Sstevel@tonic-gate {
1648*7c478bd9Sstevel@tonic-gate 	bool_t more_data;
1649*7c478bd9Sstevel@tonic-gate 	rddir4_cache *rdc = aobjp->rdc;
1650*7c478bd9Sstevel@tonic-gate 	dirent64_t *dp = NULL;
1651*7c478bd9Sstevel@tonic-gate 	int entry_length = 0;
1652*7c478bd9Sstevel@tonic-gate 	int space_left = 0;
1653*7c478bd9Sstevel@tonic-gate 	bitmap4 resbmap;
1654*7c478bd9Sstevel@tonic-gate 	uint32_t attrlen;
1655*7c478bd9Sstevel@tonic-gate 	nfs4_ga_res_t gar;
1656*7c478bd9Sstevel@tonic-gate 	struct nfs4_ga_ext_res ges;
1657*7c478bd9Sstevel@tonic-gate 	uint64_t last_cookie = 0;
1658*7c478bd9Sstevel@tonic-gate 	int skip_to_end;
1659*7c478bd9Sstevel@tonic-gate 	ug_cache_t *pug = NULL;
1660*7c478bd9Sstevel@tonic-gate 
1661*7c478bd9Sstevel@tonic-gate 	ASSERT(xdrs->x_op == XDR_DECODE);
1662*7c478bd9Sstevel@tonic-gate 	ASSERT(rdc->entries == NULL);
1663*7c478bd9Sstevel@tonic-gate 	ASSERT(aobjp->dircount > 0);
1664*7c478bd9Sstevel@tonic-gate 
1665*7c478bd9Sstevel@tonic-gate 	if (!xdr_int(xdrs, (int32_t *)&objp->status))
1666*7c478bd9Sstevel@tonic-gate 		return (FALSE);
1667*7c478bd9Sstevel@tonic-gate 	if (objp->status != NFS4_OK)
1668*7c478bd9Sstevel@tonic-gate 		return (TRUE);
1669*7c478bd9Sstevel@tonic-gate 
1670*7c478bd9Sstevel@tonic-gate 	gar.n4g_va.va_mask = 0;
1671*7c478bd9Sstevel@tonic-gate 	gar.n4g_change_valid = 0;
1672*7c478bd9Sstevel@tonic-gate 	gar.n4g_mon_fid_valid = 0;
1673*7c478bd9Sstevel@tonic-gate 	gar.n4g_fsid_valid = 0;
1674*7c478bd9Sstevel@tonic-gate 	gar.n4g_vsa.vsa_mask = 0;
1675*7c478bd9Sstevel@tonic-gate 	gar.n4g_attrwhy = NFS4_GETATTR_OP_OK;
1676*7c478bd9Sstevel@tonic-gate 	ges.n4g_pc4.pc4_cache_valid = 0;
1677*7c478bd9Sstevel@tonic-gate 	ges.n4g_pc4.pc4_xattr_valid = 0;
1678*7c478bd9Sstevel@tonic-gate 	gar.n4g_ext_res = &ges;
1679*7c478bd9Sstevel@tonic-gate 
1680*7c478bd9Sstevel@tonic-gate 	/* READDIR4res_clnt_free needs to kmem_free this buffer */
1681*7c478bd9Sstevel@tonic-gate 	rdc->entries = kmem_alloc(aobjp->dircount, KM_SLEEP);
1682*7c478bd9Sstevel@tonic-gate 
1683*7c478bd9Sstevel@tonic-gate 	dp = (dirent64_t *)rdc->entries;
1684*7c478bd9Sstevel@tonic-gate 	rdc->entlen = rdc->buflen = space_left = aobjp->dircount;
1685*7c478bd9Sstevel@tonic-gate 
1686*7c478bd9Sstevel@tonic-gate 	/* Fill in dot and dot-dot if needed */
1687*7c478bd9Sstevel@tonic-gate 	if (rdc->nfs4_cookie == (nfs_cookie4) 0 ||
1688*7c478bd9Sstevel@tonic-gate 		    rdc->nfs4_cookie == (nfs_cookie4) 1) {
1689*7c478bd9Sstevel@tonic-gate 
1690*7c478bd9Sstevel@tonic-gate 		if (rdc->nfs4_cookie == (nfs_cookie4)0) {
1691*7c478bd9Sstevel@tonic-gate 			bcopy(nfs4_dot_entries, rdc->entries,
1692*7c478bd9Sstevel@tonic-gate 				    DIRENT64_RECLEN(1) + DIRENT64_RECLEN(2));
1693*7c478bd9Sstevel@tonic-gate 			objp->dotp = dp;
1694*7c478bd9Sstevel@tonic-gate 			dp = (struct dirent64 *)(((char *)dp) +
1695*7c478bd9Sstevel@tonic-gate 							DIRENT64_RECLEN(1));
1696*7c478bd9Sstevel@tonic-gate 			objp->dotdotp = dp;
1697*7c478bd9Sstevel@tonic-gate 			dp = (struct dirent64 *)(((char *)dp) +
1698*7c478bd9Sstevel@tonic-gate 							DIRENT64_RECLEN(2));
1699*7c478bd9Sstevel@tonic-gate 			space_left -= DIRENT64_RECLEN(1) + DIRENT64_RECLEN(2);
1700*7c478bd9Sstevel@tonic-gate 
1701*7c478bd9Sstevel@tonic-gate 		} else	{	/* for ".." entry */
1702*7c478bd9Sstevel@tonic-gate 			bcopy(nfs4_dot_dot_entry, rdc->entries,
1703*7c478bd9Sstevel@tonic-gate 						DIRENT64_RECLEN(2));
1704*7c478bd9Sstevel@tonic-gate 			objp->dotp = NULL;
1705*7c478bd9Sstevel@tonic-gate 			objp->dotdotp = dp;
1706*7c478bd9Sstevel@tonic-gate 			dp = (struct dirent64 *)(((char *)dp) +
1707*7c478bd9Sstevel@tonic-gate 							DIRENT64_RECLEN(2));
1708*7c478bd9Sstevel@tonic-gate 			space_left -= DIRENT64_RECLEN(2);
1709*7c478bd9Sstevel@tonic-gate 		}
1710*7c478bd9Sstevel@tonic-gate 		/* Magic NFSv4 number for entry after start */
1711*7c478bd9Sstevel@tonic-gate 		last_cookie = 2;
1712*7c478bd9Sstevel@tonic-gate 	}
1713*7c478bd9Sstevel@tonic-gate 
1714*7c478bd9Sstevel@tonic-gate 	/* Get the cookie VERIFIER */
1715*7c478bd9Sstevel@tonic-gate 	if (!xdr_u_longlong_t(xdrs, (u_longlong_t *)&objp->cookieverf))
1716*7c478bd9Sstevel@tonic-gate 		goto noentries;
1717*7c478bd9Sstevel@tonic-gate 
1718*7c478bd9Sstevel@tonic-gate 	/* Get the do-we-have-a-next-entry BOOL */
1719*7c478bd9Sstevel@tonic-gate 	if (!xdr_bool(xdrs, &more_data))
1720*7c478bd9Sstevel@tonic-gate 		goto noentries;
1721*7c478bd9Sstevel@tonic-gate 
1722*7c478bd9Sstevel@tonic-gate 	if (aobjp->attr_request & (FATTR4_OWNER_MASK | FATTR4_OWNER_GROUP_MASK))
1723*7c478bd9Sstevel@tonic-gate 		pug = alloc_ugcache();
1724*7c478bd9Sstevel@tonic-gate 
1725*7c478bd9Sstevel@tonic-gate 	skip_to_end = 0;
1726*7c478bd9Sstevel@tonic-gate 	while (more_data) {
1727*7c478bd9Sstevel@tonic-gate 		uint_t namelen;
1728*7c478bd9Sstevel@tonic-gate 		uint64_t cookie;
1729*7c478bd9Sstevel@tonic-gate 
1730*7c478bd9Sstevel@tonic-gate 		/* Get the COOKIE */
1731*7c478bd9Sstevel@tonic-gate 		if (!xdr_u_longlong_t(xdrs, (u_longlong_t *)&cookie))
1732*7c478bd9Sstevel@tonic-gate 			goto noentries;
1733*7c478bd9Sstevel@tonic-gate 
1734*7c478bd9Sstevel@tonic-gate 		/* Get the LENGTH of the entry name */
1735*7c478bd9Sstevel@tonic-gate 		if (!xdr_u_int(xdrs, &namelen))
1736*7c478bd9Sstevel@tonic-gate 			goto noentries;
1737*7c478bd9Sstevel@tonic-gate 
1738*7c478bd9Sstevel@tonic-gate 		if (!skip_to_end) {
1739*7c478bd9Sstevel@tonic-gate 			/*
1740*7c478bd9Sstevel@tonic-gate 			 * With the length of the directory entry name
1741*7c478bd9Sstevel@tonic-gate 			 * in hand, figure out if there is room left
1742*7c478bd9Sstevel@tonic-gate 			 * to encode it for the requestor.  If not,
1743*7c478bd9Sstevel@tonic-gate 			 * that is okay, but the rest of the readdir
1744*7c478bd9Sstevel@tonic-gate 			 * operation result must be decoded in the
1745*7c478bd9Sstevel@tonic-gate 			 * case there are following operations
1746*7c478bd9Sstevel@tonic-gate 			 * in the compound request.  Therefore, mark
1747*7c478bd9Sstevel@tonic-gate 			 * the rest of the response as "skip" and
1748*7c478bd9Sstevel@tonic-gate 			 * decode or skip the remaining data
1749*7c478bd9Sstevel@tonic-gate 			 */
1750*7c478bd9Sstevel@tonic-gate 			entry_length = DIRENT64_RECLEN(namelen);
1751*7c478bd9Sstevel@tonic-gate 			if (space_left < entry_length)
1752*7c478bd9Sstevel@tonic-gate 				skip_to_end = 1;
1753*7c478bd9Sstevel@tonic-gate 		}
1754*7c478bd9Sstevel@tonic-gate 
1755*7c478bd9Sstevel@tonic-gate 		/* Get the NAME of the entry */
1756*7c478bd9Sstevel@tonic-gate 		if (!skip_to_end) {
1757*7c478bd9Sstevel@tonic-gate 			if (!xdr_opaque(xdrs, dp->d_name, namelen))
1758*7c478bd9Sstevel@tonic-gate 				goto noentries;
1759*7c478bd9Sstevel@tonic-gate 			bzero(&dp->d_name[namelen],
1760*7c478bd9Sstevel@tonic-gate 				DIRENT64_NAMELEN(entry_length) - namelen);
1761*7c478bd9Sstevel@tonic-gate 			dp->d_off = last_cookie = cookie;
1762*7c478bd9Sstevel@tonic-gate 			dp->d_reclen = entry_length;
1763*7c478bd9Sstevel@tonic-gate 		} else {
1764*7c478bd9Sstevel@tonic-gate 			if (!XDR_CONTROL(xdrs, XDR_SKIPBYTES, &namelen))
1765*7c478bd9Sstevel@tonic-gate 				goto noentries;
1766*7c478bd9Sstevel@tonic-gate 		}
1767*7c478bd9Sstevel@tonic-gate 
1768*7c478bd9Sstevel@tonic-gate 		/* Get the attribute BITMAP */
1769*7c478bd9Sstevel@tonic-gate 		if (!xdr_bitmap4(xdrs, &resbmap))
1770*7c478bd9Sstevel@tonic-gate 			goto noentries;
1771*7c478bd9Sstevel@tonic-gate 		/* Get the LENGTH of the attributes */
1772*7c478bd9Sstevel@tonic-gate 		if (!xdr_u_int(xdrs, (uint_t *)&attrlen))
1773*7c478bd9Sstevel@tonic-gate 			goto noentries;
1774*7c478bd9Sstevel@tonic-gate 
1775*7c478bd9Sstevel@tonic-gate 		/* Get the ATTRIBUTES */
1776*7c478bd9Sstevel@tonic-gate 		if (!skip_to_end) {
1777*7c478bd9Sstevel@tonic-gate 			uint32_t *ptr;
1778*7c478bd9Sstevel@tonic-gate 
1779*7c478bd9Sstevel@tonic-gate 			if (!(resbmap & FATTR4_ACL_MASK) &&
1780*7c478bd9Sstevel@tonic-gate 			    (ptr = (uint32_t *)XDR_INLINE(xdrs, attrlen))
1781*7c478bd9Sstevel@tonic-gate 			    != NULL) {
1782*7c478bd9Sstevel@tonic-gate 				if (!xdr_ga_fattr_res_inline(ptr, &gar, resbmap,
1783*7c478bd9Sstevel@tonic-gate 							aobjp->attr_request,
1784*7c478bd9Sstevel@tonic-gate 							aobjp->mi, pug))
1785*7c478bd9Sstevel@tonic-gate 					goto noentries;
1786*7c478bd9Sstevel@tonic-gate 			} else {
1787*7c478bd9Sstevel@tonic-gate 				if (!xdr_ga_fattr_res(xdrs, &gar, resbmap,
1788*7c478bd9Sstevel@tonic-gate 							aobjp->attr_request,
1789*7c478bd9Sstevel@tonic-gate 							aobjp->mi, pug))
1790*7c478bd9Sstevel@tonic-gate 					goto noentries;
1791*7c478bd9Sstevel@tonic-gate 			}
1792*7c478bd9Sstevel@tonic-gate 
1793*7c478bd9Sstevel@tonic-gate 			/* Fill in the d_ino per the server's fid values */
1794*7c478bd9Sstevel@tonic-gate 			/*
1795*7c478bd9Sstevel@tonic-gate 			 * Important to note that the mounted on fileid
1796*7c478bd9Sstevel@tonic-gate 			 * is returned in d_ino if supported.  This is
1797*7c478bd9Sstevel@tonic-gate 			 * expected, readdir returns the mounted on fileid
1798*7c478bd9Sstevel@tonic-gate 			 * while stat() returns the fileid of the object
1799*7c478bd9Sstevel@tonic-gate 			 * on "top" of the mount.
1800*7c478bd9Sstevel@tonic-gate 			 */
1801*7c478bd9Sstevel@tonic-gate 			if (gar.n4g_mon_fid_valid)
1802*7c478bd9Sstevel@tonic-gate 				dp->d_ino = gar.n4g_mon_fid;
1803*7c478bd9Sstevel@tonic-gate 			else if (gar.n4g_va.va_mask & AT_NODEID)
1804*7c478bd9Sstevel@tonic-gate 				dp->d_ino = gar.n4g_va.va_nodeid;
1805*7c478bd9Sstevel@tonic-gate 			else
1806*7c478bd9Sstevel@tonic-gate 				dp->d_ino = 0;
1807*7c478bd9Sstevel@tonic-gate 
1808*7c478bd9Sstevel@tonic-gate 			/* See about creating an rnode for this entry */
1809*7c478bd9Sstevel@tonic-gate 			if ((resbmap &
1810*7c478bd9Sstevel@tonic-gate 			    (NFS4_VATTR_MASK | FATTR4_FILEHANDLE_MASK)) ==
1811*7c478bd9Sstevel@tonic-gate 			    (NFS4_VATTR_MASK | FATTR4_FILEHANDLE_MASK)) {
1812*7c478bd9Sstevel@tonic-gate 				nfs4_sharedfh_t *sfhp;
1813*7c478bd9Sstevel@tonic-gate 				vnode_t *vp;
1814*7c478bd9Sstevel@tonic-gate 
1815*7c478bd9Sstevel@tonic-gate 				sfhp = sfh4_put(&ges.n4g_fh_u.n4g_fh,
1816*7c478bd9Sstevel@tonic-gate 							aobjp->mi, NULL);
1817*7c478bd9Sstevel@tonic-gate 				vp = makenfs4node(sfhp, &gar,
1818*7c478bd9Sstevel@tonic-gate 					aobjp->dvp->v_vfsp,
1819*7c478bd9Sstevel@tonic-gate 					aobjp->t,
1820*7c478bd9Sstevel@tonic-gate 					aobjp->cr,
1821*7c478bd9Sstevel@tonic-gate 					aobjp->dvp,
1822*7c478bd9Sstevel@tonic-gate 					fn_get(VTOSV(aobjp->dvp)->sv_name,
1823*7c478bd9Sstevel@tonic-gate 						dp->d_name));
1824*7c478bd9Sstevel@tonic-gate 				sfh4_rele(&sfhp);
1825*7c478bd9Sstevel@tonic-gate 				dnlc_update(aobjp->dvp, dp->d_name, vp);
1826*7c478bd9Sstevel@tonic-gate 				VN_RELE(vp);
1827*7c478bd9Sstevel@tonic-gate 			}
1828*7c478bd9Sstevel@tonic-gate 
1829*7c478bd9Sstevel@tonic-gate 			dp = (struct dirent64 *)(((caddr_t)dp) + dp->d_reclen);
1830*7c478bd9Sstevel@tonic-gate 
1831*7c478bd9Sstevel@tonic-gate 			space_left -= entry_length;
1832*7c478bd9Sstevel@tonic-gate 
1833*7c478bd9Sstevel@tonic-gate 		} else {
1834*7c478bd9Sstevel@tonic-gate 			if (!XDR_CONTROL(xdrs, XDR_SKIPBYTES, &attrlen))
1835*7c478bd9Sstevel@tonic-gate 				goto noentries;
1836*7c478bd9Sstevel@tonic-gate 		}
1837*7c478bd9Sstevel@tonic-gate 
1838*7c478bd9Sstevel@tonic-gate 		/* Get the do-we-have-a-next-entry BOOL */
1839*7c478bd9Sstevel@tonic-gate 		if (!xdr_bool(xdrs, &more_data))
1840*7c478bd9Sstevel@tonic-gate 			goto noentries;
1841*7c478bd9Sstevel@tonic-gate 	}
1842*7c478bd9Sstevel@tonic-gate 
1843*7c478bd9Sstevel@tonic-gate 	if (pug) {
1844*7c478bd9Sstevel@tonic-gate 		kmem_free(pug, sizeof (ug_cache_t));
1845*7c478bd9Sstevel@tonic-gate 		pug = NULL;
1846*7c478bd9Sstevel@tonic-gate 	}
1847*7c478bd9Sstevel@tonic-gate 
1848*7c478bd9Sstevel@tonic-gate 	/*
1849*7c478bd9Sstevel@tonic-gate 	 * Finish up the rddir cache
1850*7c478bd9Sstevel@tonic-gate 	 * If no entries were returned, free up buffer &
1851*7c478bd9Sstevel@tonic-gate 	 * set ncookie to the starting cookie for this
1852*7c478bd9Sstevel@tonic-gate 	 * readdir request so that the direof caching
1853*7c478bd9Sstevel@tonic-gate 	 * will work properly.
1854*7c478bd9Sstevel@tonic-gate 	 */
1855*7c478bd9Sstevel@tonic-gate 	ASSERT(rdc->entries);
1856*7c478bd9Sstevel@tonic-gate 	if (last_cookie == 0) {
1857*7c478bd9Sstevel@tonic-gate 		kmem_free(rdc->entries, rdc->entlen);
1858*7c478bd9Sstevel@tonic-gate 		rdc->entries = NULL;
1859*7c478bd9Sstevel@tonic-gate 		last_cookie = rdc->nfs4_cookie;
1860*7c478bd9Sstevel@tonic-gate 	}
1861*7c478bd9Sstevel@tonic-gate 
1862*7c478bd9Sstevel@tonic-gate 	rdc->actlen = rdc->entlen - space_left;
1863*7c478bd9Sstevel@tonic-gate 	rdc->nfs4_ncookie = last_cookie;
1864*7c478bd9Sstevel@tonic-gate 
1865*7c478bd9Sstevel@tonic-gate 	/* Get the EOF marker */
1866*7c478bd9Sstevel@tonic-gate 	if (!xdr_bool(xdrs, &objp->eof))
1867*7c478bd9Sstevel@tonic-gate 		goto noentries;
1868*7c478bd9Sstevel@tonic-gate 
1869*7c478bd9Sstevel@tonic-gate 	/*
1870*7c478bd9Sstevel@tonic-gate 	 * If the server returns eof and there were no
1871*7c478bd9Sstevel@tonic-gate 	 * skipped entries, set eof
1872*7c478bd9Sstevel@tonic-gate 	 */
1873*7c478bd9Sstevel@tonic-gate 	rdc->eof = (objp->eof && !skip_to_end) ? TRUE : FALSE;
1874*7c478bd9Sstevel@tonic-gate 
1875*7c478bd9Sstevel@tonic-gate 	/*
1876*7c478bd9Sstevel@tonic-gate 	 * If we encoded entries we are done
1877*7c478bd9Sstevel@tonic-gate 	 */
1878*7c478bd9Sstevel@tonic-gate 	if (rdc->entries) {
1879*7c478bd9Sstevel@tonic-gate 		rdc->error = 0;
1880*7c478bd9Sstevel@tonic-gate 		return (TRUE);
1881*7c478bd9Sstevel@tonic-gate 	}
1882*7c478bd9Sstevel@tonic-gate 
1883*7c478bd9Sstevel@tonic-gate 	/*
1884*7c478bd9Sstevel@tonic-gate 	 * If there were no entries and we skipped because
1885*7c478bd9Sstevel@tonic-gate 	 * there was not enough space, return EINVAL
1886*7c478bd9Sstevel@tonic-gate 	 */
1887*7c478bd9Sstevel@tonic-gate 	if (skip_to_end) {
1888*7c478bd9Sstevel@tonic-gate 		rdc->error = EINVAL;
1889*7c478bd9Sstevel@tonic-gate 		return (TRUE);
1890*7c478bd9Sstevel@tonic-gate 	}
1891*7c478bd9Sstevel@tonic-gate 
1892*7c478bd9Sstevel@tonic-gate 	/*
1893*7c478bd9Sstevel@tonic-gate 	 * No entries, nothing skipped, and EOF, return OK.
1894*7c478bd9Sstevel@tonic-gate 	 */
1895*7c478bd9Sstevel@tonic-gate 	if (objp->eof == TRUE) {
1896*7c478bd9Sstevel@tonic-gate 		rdc->error = 0;
1897*7c478bd9Sstevel@tonic-gate 		return (TRUE);
1898*7c478bd9Sstevel@tonic-gate 	}
1899*7c478bd9Sstevel@tonic-gate 
1900*7c478bd9Sstevel@tonic-gate 	/*
1901*7c478bd9Sstevel@tonic-gate 	 * No entries, nothing skipped, and not EOF
1902*7c478bd9Sstevel@tonic-gate 	 * probably a bad cookie, return ENOENT.
1903*7c478bd9Sstevel@tonic-gate 	 */
1904*7c478bd9Sstevel@tonic-gate 	rdc->error = ENOENT;
1905*7c478bd9Sstevel@tonic-gate 	return (TRUE);
1906*7c478bd9Sstevel@tonic-gate 
1907*7c478bd9Sstevel@tonic-gate noentries:
1908*7c478bd9Sstevel@tonic-gate 	if (rdc->entries) {
1909*7c478bd9Sstevel@tonic-gate 		kmem_free(rdc->entries, rdc->entlen);
1910*7c478bd9Sstevel@tonic-gate 		rdc->entries = NULL;
1911*7c478bd9Sstevel@tonic-gate 	}
1912*7c478bd9Sstevel@tonic-gate 	if (pug)
1913*7c478bd9Sstevel@tonic-gate 		kmem_free(pug, sizeof (ug_cache_t));
1914*7c478bd9Sstevel@tonic-gate 	rdc->error = EIO;
1915*7c478bd9Sstevel@tonic-gate 	return (FALSE);
1916*7c478bd9Sstevel@tonic-gate }
1917*7c478bd9Sstevel@tonic-gate 
1918*7c478bd9Sstevel@tonic-gate /*
1919*7c478bd9Sstevel@tonic-gate  * xdr_ga_res
1920*7c478bd9Sstevel@tonic-gate  *
1921*7c478bd9Sstevel@tonic-gate  * Returns: FALSE on raw data processing errors, TRUE otherwise.
1922*7c478bd9Sstevel@tonic-gate  *
1923*7c478bd9Sstevel@tonic-gate  * This function pre-processes the OP_GETATTR response, and then
1924*7c478bd9Sstevel@tonic-gate  * calls common routines to process the GETATTR fattr4 results into
1925*7c478bd9Sstevel@tonic-gate  * vnode attributes and other components that the client is interested
1926*7c478bd9Sstevel@tonic-gate  * in. If an error other than an RPC error is encountered, the details
1927*7c478bd9Sstevel@tonic-gate  * of the error are filled into objp, although the result of the
1928*7c478bd9Sstevel@tonic-gate  * processing is set to TRUE.
1929*7c478bd9Sstevel@tonic-gate  */
1930*7c478bd9Sstevel@tonic-gate static bool_t
1931*7c478bd9Sstevel@tonic-gate xdr_ga_res(XDR *xdrs, GETATTR4res *objp, GETATTR4args *aobjp)
1932*7c478bd9Sstevel@tonic-gate {
1933*7c478bd9Sstevel@tonic-gate 	uint32_t *ptr;
1934*7c478bd9Sstevel@tonic-gate 	bitmap4 resbmap;
1935*7c478bd9Sstevel@tonic-gate 	uint32_t attrlen;
1936*7c478bd9Sstevel@tonic-gate 
1937*7c478bd9Sstevel@tonic-gate 	ASSERT(xdrs->x_op == XDR_DECODE);
1938*7c478bd9Sstevel@tonic-gate 
1939*7c478bd9Sstevel@tonic-gate 	/* Initialize objp attribute error values */
1940*7c478bd9Sstevel@tonic-gate 	objp->ga_res.n4g_attrerr =
1941*7c478bd9Sstevel@tonic-gate 		objp->ga_res.n4g_attrwhy = NFS4_GETATTR_OP_OK;
1942*7c478bd9Sstevel@tonic-gate 
1943*7c478bd9Sstevel@tonic-gate 	if (!xdr_bitmap4(xdrs, &resbmap))
1944*7c478bd9Sstevel@tonic-gate 		return (FALSE);
1945*7c478bd9Sstevel@tonic-gate 
1946*7c478bd9Sstevel@tonic-gate 	/* save the response bitmap for the caller */
1947*7c478bd9Sstevel@tonic-gate 	objp->ga_res.n4g_resbmap = resbmap;
1948*7c478bd9Sstevel@tonic-gate 
1949*7c478bd9Sstevel@tonic-gate 	/* attrlen */
1950*7c478bd9Sstevel@tonic-gate 	if (!XDR_GETINT32(xdrs, (int32_t *)&attrlen))
1951*7c478bd9Sstevel@tonic-gate 		return (FALSE);
1952*7c478bd9Sstevel@tonic-gate 
1953*7c478bd9Sstevel@tonic-gate 	/*
1954*7c478bd9Sstevel@tonic-gate 	 * Handle case where request and response bitmaps don't match.
1955*7c478bd9Sstevel@tonic-gate 	 */
1956*7c478bd9Sstevel@tonic-gate 	if (aobjp->attr_request && aobjp->attr_request != resbmap) {
1957*7c478bd9Sstevel@tonic-gate 		bitmap4 deltabmap;
1958*7c478bd9Sstevel@tonic-gate 
1959*7c478bd9Sstevel@tonic-gate 		/*
1960*7c478bd9Sstevel@tonic-gate 		 * Return error for case where server sent extra attributes
1961*7c478bd9Sstevel@tonic-gate 		 * because the "unknown" attributes may be anywhere in the
1962*7c478bd9Sstevel@tonic-gate 		 * xdr stream and can't be properly processed.
1963*7c478bd9Sstevel@tonic-gate 		 */
1964*7c478bd9Sstevel@tonic-gate 		deltabmap = ((aobjp->attr_request ^ resbmap) & resbmap);
1965*7c478bd9Sstevel@tonic-gate 		if (deltabmap) {
1966*7c478bd9Sstevel@tonic-gate 			objp->ga_res.n4g_attrerr = EINVAL;
1967*7c478bd9Sstevel@tonic-gate 			objp->ga_res.n4g_attrwhy = NFS4_GETATTR_BITMAP_ERR;
1968*7c478bd9Sstevel@tonic-gate 			return (TRUE);
1969*7c478bd9Sstevel@tonic-gate 		}
1970*7c478bd9Sstevel@tonic-gate 
1971*7c478bd9Sstevel@tonic-gate 		/*
1972*7c478bd9Sstevel@tonic-gate 		 * Return error for case where there is a mandatory
1973*7c478bd9Sstevel@tonic-gate 		 * attribute missing in the server response. Note that
1974*7c478bd9Sstevel@tonic-gate 		 * missing recommended attributes are evaluated in the
1975*7c478bd9Sstevel@tonic-gate 		 * specific routines that decode the server response.
1976*7c478bd9Sstevel@tonic-gate 		 */
1977*7c478bd9Sstevel@tonic-gate 		deltabmap = ((aobjp->attr_request ^ resbmap)
1978*7c478bd9Sstevel@tonic-gate 				& aobjp->attr_request);
1979*7c478bd9Sstevel@tonic-gate 		if ((deltabmap & FATTR4_MANDATTR_MASK)) {
1980*7c478bd9Sstevel@tonic-gate 			objp->ga_res.n4g_attrerr = EINVAL;
1981*7c478bd9Sstevel@tonic-gate 			objp->ga_res.n4g_attrwhy = NFS4_GETATTR_MANDATTR_ERR;
1982*7c478bd9Sstevel@tonic-gate 			return (TRUE);
1983*7c478bd9Sstevel@tonic-gate 		}
1984*7c478bd9Sstevel@tonic-gate 	}
1985*7c478bd9Sstevel@tonic-gate 
1986*7c478bd9Sstevel@tonic-gate 	/* Check to see if the attrs can be inlined and go for it if so */
1987*7c478bd9Sstevel@tonic-gate 	if (!(resbmap & FATTR4_ACL_MASK) &&
1988*7c478bd9Sstevel@tonic-gate 	    (ptr = (uint32_t *)XDR_INLINE(xdrs, attrlen)) != NULL)
1989*7c478bd9Sstevel@tonic-gate 		return (xdr_ga_fattr_res_inline(ptr, &objp->ga_res,
1990*7c478bd9Sstevel@tonic-gate 					resbmap, aobjp->attr_request,
1991*7c478bd9Sstevel@tonic-gate 					aobjp->mi, NULL));
1992*7c478bd9Sstevel@tonic-gate 	else
1993*7c478bd9Sstevel@tonic-gate 		return (xdr_ga_fattr_res(xdrs, &objp->ga_res,
1994*7c478bd9Sstevel@tonic-gate 					resbmap, aobjp->attr_request,
1995*7c478bd9Sstevel@tonic-gate 					aobjp->mi, NULL));
1996*7c478bd9Sstevel@tonic-gate }
1997*7c478bd9Sstevel@tonic-gate 
1998*7c478bd9Sstevel@tonic-gate #if defined(DEBUG) && !defined(lint)
1999*7c478bd9Sstevel@tonic-gate /*
2000*7c478bd9Sstevel@tonic-gate  * We assume that an enum is a 32-bit value, check it once
2001*7c478bd9Sstevel@tonic-gate  */
2002*7c478bd9Sstevel@tonic-gate static enum szchk { SZVAL } szchkvar;
2003*7c478bd9Sstevel@tonic-gate #endif
2004*7c478bd9Sstevel@tonic-gate 
2005*7c478bd9Sstevel@tonic-gate bool_t
2006*7c478bd9Sstevel@tonic-gate xdr_settime4(XDR *xdrs, settime4 *objp)
2007*7c478bd9Sstevel@tonic-gate {
2008*7c478bd9Sstevel@tonic-gate #if defined(DEBUG) && !defined(lint)
2009*7c478bd9Sstevel@tonic-gate 	ASSERT(sizeof (szchkvar) == sizeof (int32_t));
2010*7c478bd9Sstevel@tonic-gate #endif
2011*7c478bd9Sstevel@tonic-gate 	if (xdrs->x_op == XDR_FREE)
2012*7c478bd9Sstevel@tonic-gate 		return (TRUE);
2013*7c478bd9Sstevel@tonic-gate 
2014*7c478bd9Sstevel@tonic-gate 	if (!xdr_int(xdrs, (int *)&objp->set_it))
2015*7c478bd9Sstevel@tonic-gate 		return (FALSE);
2016*7c478bd9Sstevel@tonic-gate 	if (objp->set_it != SET_TO_CLIENT_TIME4)
2017*7c478bd9Sstevel@tonic-gate 		return (TRUE);
2018*7c478bd9Sstevel@tonic-gate 	/* xdr_nfstime4 */
2019*7c478bd9Sstevel@tonic-gate 	if (!xdr_longlong_t(xdrs, (longlong_t *)&objp->time.seconds))
2020*7c478bd9Sstevel@tonic-gate 		return (FALSE);
2021*7c478bd9Sstevel@tonic-gate 	return (xdr_u_int(xdrs, &objp->time.nseconds));
2022*7c478bd9Sstevel@tonic-gate }
2023*7c478bd9Sstevel@tonic-gate 
2024*7c478bd9Sstevel@tonic-gate static bool_t
2025*7c478bd9Sstevel@tonic-gate xdr_fattr4(XDR *xdrs, fattr4 *objp)
2026*7c478bd9Sstevel@tonic-gate {
2027*7c478bd9Sstevel@tonic-gate 	if (xdrs->x_op != XDR_FREE) {
2028*7c478bd9Sstevel@tonic-gate 		if (!xdr_bitmap4(xdrs, &objp->attrmask))
2029*7c478bd9Sstevel@tonic-gate 			return (FALSE);
2030*7c478bd9Sstevel@tonic-gate 		return (xdr_bytes(xdrs, (char **)&objp->attrlist4,
2031*7c478bd9Sstevel@tonic-gate 			(uint_t *)&objp->attrlist4_len, NFS4_FATTR4_LIMIT));
2032*7c478bd9Sstevel@tonic-gate 	}
2033*7c478bd9Sstevel@tonic-gate 
2034*7c478bd9Sstevel@tonic-gate 	/*
2035*7c478bd9Sstevel@tonic-gate 	 * Optimized free case
2036*7c478bd9Sstevel@tonic-gate 	 */
2037*7c478bd9Sstevel@tonic-gate 	if (objp->attrlist4 != NULL)
2038*7c478bd9Sstevel@tonic-gate 		kmem_free(objp->attrlist4, objp->attrlist4_len);
2039*7c478bd9Sstevel@tonic-gate 	return (TRUE);
2040*7c478bd9Sstevel@tonic-gate }
2041*7c478bd9Sstevel@tonic-gate 
2042*7c478bd9Sstevel@tonic-gate static bool_t
2043*7c478bd9Sstevel@tonic-gate xdr_ACCESS4res(XDR *xdrs, ACCESS4res *objp)
2044*7c478bd9Sstevel@tonic-gate {
2045*7c478bd9Sstevel@tonic-gate 	if (!xdr_int(xdrs, (int32_t *)&objp->status))
2046*7c478bd9Sstevel@tonic-gate 		return (FALSE);
2047*7c478bd9Sstevel@tonic-gate 	if (objp->status != NFS4_OK)
2048*7c478bd9Sstevel@tonic-gate 		return (TRUE);
2049*7c478bd9Sstevel@tonic-gate 	if (!xdr_u_int(xdrs, &objp->supported))
2050*7c478bd9Sstevel@tonic-gate 		return (FALSE);
2051*7c478bd9Sstevel@tonic-gate 	return (xdr_u_int(xdrs, &objp->access));
2052*7c478bd9Sstevel@tonic-gate }
2053*7c478bd9Sstevel@tonic-gate 
2054*7c478bd9Sstevel@tonic-gate static bool_t
2055*7c478bd9Sstevel@tonic-gate xdr_CLOSE4args(XDR *xdrs, CLOSE4args *objp)
2056*7c478bd9Sstevel@tonic-gate {
2057*7c478bd9Sstevel@tonic-gate 	if (!xdr_u_int(xdrs, &objp->seqid))
2058*7c478bd9Sstevel@tonic-gate 		return (FALSE);
2059*7c478bd9Sstevel@tonic-gate 	if (!xdr_u_int(xdrs, &objp->open_stateid.seqid))
2060*7c478bd9Sstevel@tonic-gate 		return (FALSE);
2061*7c478bd9Sstevel@tonic-gate 	return (xdr_opaque(xdrs, objp->open_stateid.other, 12));
2062*7c478bd9Sstevel@tonic-gate }
2063*7c478bd9Sstevel@tonic-gate 
2064*7c478bd9Sstevel@tonic-gate static bool_t
2065*7c478bd9Sstevel@tonic-gate xdr_CLOSE4res(XDR *xdrs, CLOSE4res *objp)
2066*7c478bd9Sstevel@tonic-gate {
2067*7c478bd9Sstevel@tonic-gate 	if (!xdr_int(xdrs, (int32_t *)&objp->status))
2068*7c478bd9Sstevel@tonic-gate 		return (FALSE);
2069*7c478bd9Sstevel@tonic-gate 	if (objp->status != NFS4_OK)
2070*7c478bd9Sstevel@tonic-gate 		return (TRUE);
2071*7c478bd9Sstevel@tonic-gate 	if (!xdr_u_int(xdrs, &objp->open_stateid.seqid))
2072*7c478bd9Sstevel@tonic-gate 		return (FALSE);
2073*7c478bd9Sstevel@tonic-gate 	return (xdr_opaque(xdrs, objp->open_stateid.other, 12));
2074*7c478bd9Sstevel@tonic-gate }
2075*7c478bd9Sstevel@tonic-gate 
2076*7c478bd9Sstevel@tonic-gate static bool_t
2077*7c478bd9Sstevel@tonic-gate xdr_CREATE4args(XDR *xdrs, CREATE4args *objp)
2078*7c478bd9Sstevel@tonic-gate {
2079*7c478bd9Sstevel@tonic-gate 	if (xdrs->x_op != XDR_FREE) {
2080*7c478bd9Sstevel@tonic-gate 		if (!xdr_int(xdrs, (int32_t *)&objp->type))
2081*7c478bd9Sstevel@tonic-gate 			return (FALSE);
2082*7c478bd9Sstevel@tonic-gate 		switch (objp->type) {
2083*7c478bd9Sstevel@tonic-gate 		case NF4LNK:
2084*7c478bd9Sstevel@tonic-gate 			if (!xdr_bytes(xdrs,
2085*7c478bd9Sstevel@tonic-gate 			    (char **)&objp->ftype4_u.linkdata.utf8string_val,
2086*7c478bd9Sstevel@tonic-gate 			    (uint_t *)&objp->ftype4_u.linkdata.utf8string_len,
2087*7c478bd9Sstevel@tonic-gate 			    NFS4_MAX_UTF8STRING))
2088*7c478bd9Sstevel@tonic-gate 				return (FALSE);
2089*7c478bd9Sstevel@tonic-gate 			break;
2090*7c478bd9Sstevel@tonic-gate 		case NF4BLK:
2091*7c478bd9Sstevel@tonic-gate 		case NF4CHR:
2092*7c478bd9Sstevel@tonic-gate 			if (!xdr_u_int(xdrs, &objp->ftype4_u.devdata.specdata1))
2093*7c478bd9Sstevel@tonic-gate 				return (FALSE);
2094*7c478bd9Sstevel@tonic-gate 			if (!xdr_u_int(xdrs, &objp->ftype4_u.devdata.specdata2))
2095*7c478bd9Sstevel@tonic-gate 				return (FALSE);
2096*7c478bd9Sstevel@tonic-gate 			break;
2097*7c478bd9Sstevel@tonic-gate 		case NF4SOCK:
2098*7c478bd9Sstevel@tonic-gate 		case NF4FIFO:
2099*7c478bd9Sstevel@tonic-gate 		case NF4DIR:
2100*7c478bd9Sstevel@tonic-gate 		default:
2101*7c478bd9Sstevel@tonic-gate 			break;	/* server should return NFS4ERR_BADTYPE */
2102*7c478bd9Sstevel@tonic-gate 		}
2103*7c478bd9Sstevel@tonic-gate 		if (!xdr_bytes(xdrs, (char **)&objp->objname.utf8string_val,
2104*7c478bd9Sstevel@tonic-gate 				(uint_t *)&objp->objname.utf8string_len,
2105*7c478bd9Sstevel@tonic-gate 				NFS4_MAX_UTF8STRING))
2106*7c478bd9Sstevel@tonic-gate 			return (FALSE);
2107*7c478bd9Sstevel@tonic-gate 		return (xdr_fattr4(xdrs, &objp->createattrs));
2108*7c478bd9Sstevel@tonic-gate 	}
2109*7c478bd9Sstevel@tonic-gate 
2110*7c478bd9Sstevel@tonic-gate 	/*
2111*7c478bd9Sstevel@tonic-gate 	 * Optimized free case
2112*7c478bd9Sstevel@tonic-gate 	 */
2113*7c478bd9Sstevel@tonic-gate 	if (objp->type == NF4LNK) {
2114*7c478bd9Sstevel@tonic-gate 		if (objp->ftype4_u.linkdata.utf8string_val != NULL)
2115*7c478bd9Sstevel@tonic-gate 			kmem_free(objp->ftype4_u.linkdata.utf8string_val,
2116*7c478bd9Sstevel@tonic-gate 				objp->ftype4_u.linkdata.utf8string_len);
2117*7c478bd9Sstevel@tonic-gate 	}
2118*7c478bd9Sstevel@tonic-gate 	if (objp->objname.utf8string_val != NULL)
2119*7c478bd9Sstevel@tonic-gate 		kmem_free(objp->objname.utf8string_val,
2120*7c478bd9Sstevel@tonic-gate 			objp->objname.utf8string_len);
2121*7c478bd9Sstevel@tonic-gate 	return (xdr_fattr4(xdrs, &objp->createattrs));
2122*7c478bd9Sstevel@tonic-gate }
2123*7c478bd9Sstevel@tonic-gate 
2124*7c478bd9Sstevel@tonic-gate static bool_t
2125*7c478bd9Sstevel@tonic-gate xdr_CREATE4cargs(XDR *xdrs, CREATE4cargs *objp)
2126*7c478bd9Sstevel@tonic-gate {
2127*7c478bd9Sstevel@tonic-gate 	int len;
2128*7c478bd9Sstevel@tonic-gate 
2129*7c478bd9Sstevel@tonic-gate 	ASSERT(xdrs->x_op == XDR_ENCODE);
2130*7c478bd9Sstevel@tonic-gate 
2131*7c478bd9Sstevel@tonic-gate 	if (!XDR_PUTINT32(xdrs, (int32_t *)&objp->type))
2132*7c478bd9Sstevel@tonic-gate 		return (FALSE);
2133*7c478bd9Sstevel@tonic-gate 	switch (objp->type) {
2134*7c478bd9Sstevel@tonic-gate 	case NF4LNK:
2135*7c478bd9Sstevel@tonic-gate 		len = strlen(objp->ftype4_u.clinkdata);
2136*7c478bd9Sstevel@tonic-gate 		if (len > NFS4_MAX_UTF8STRING)
2137*7c478bd9Sstevel@tonic-gate 			return (FALSE);
2138*7c478bd9Sstevel@tonic-gate 		if (!XDR_PUTINT32(xdrs, &len))
2139*7c478bd9Sstevel@tonic-gate 			return (FALSE);
2140*7c478bd9Sstevel@tonic-gate 		if (!xdr_opaque(xdrs, objp->ftype4_u.clinkdata, len))
2141*7c478bd9Sstevel@tonic-gate 			return (FALSE);
2142*7c478bd9Sstevel@tonic-gate 		break;
2143*7c478bd9Sstevel@tonic-gate 	case NF4BLK:
2144*7c478bd9Sstevel@tonic-gate 	case NF4CHR:
2145*7c478bd9Sstevel@tonic-gate 		if (!XDR_PUTINT32(xdrs,
2146*7c478bd9Sstevel@tonic-gate 				(int32_t *)&objp->ftype4_u.devdata.specdata1))
2147*7c478bd9Sstevel@tonic-gate 			return (FALSE);
2148*7c478bd9Sstevel@tonic-gate 		if (!XDR_PUTINT32(xdrs,
2149*7c478bd9Sstevel@tonic-gate 				(int32_t *)&objp->ftype4_u.devdata.specdata2))
2150*7c478bd9Sstevel@tonic-gate 			return (FALSE);
2151*7c478bd9Sstevel@tonic-gate 		break;
2152*7c478bd9Sstevel@tonic-gate 	case NF4SOCK:
2153*7c478bd9Sstevel@tonic-gate 	case NF4FIFO:
2154*7c478bd9Sstevel@tonic-gate 	case NF4DIR:
2155*7c478bd9Sstevel@tonic-gate 	default:
2156*7c478bd9Sstevel@tonic-gate 		break;	/* server should return NFS4ERR_BADTYPE */
2157*7c478bd9Sstevel@tonic-gate 	}
2158*7c478bd9Sstevel@tonic-gate 
2159*7c478bd9Sstevel@tonic-gate 	len = strlen(objp->cname);
2160*7c478bd9Sstevel@tonic-gate 	if (len > NFS4_MAX_UTF8STRING)
2161*7c478bd9Sstevel@tonic-gate 		return (FALSE);
2162*7c478bd9Sstevel@tonic-gate 	if (!XDR_PUTINT32(xdrs, &len))
2163*7c478bd9Sstevel@tonic-gate 		return (FALSE);
2164*7c478bd9Sstevel@tonic-gate 	if (!xdr_opaque(xdrs, objp->cname, len))
2165*7c478bd9Sstevel@tonic-gate 		return (FALSE);
2166*7c478bd9Sstevel@tonic-gate 
2167*7c478bd9Sstevel@tonic-gate 	return (xdr_fattr4(xdrs, &objp->createattrs));
2168*7c478bd9Sstevel@tonic-gate }
2169*7c478bd9Sstevel@tonic-gate 
2170*7c478bd9Sstevel@tonic-gate static bool_t
2171*7c478bd9Sstevel@tonic-gate xdr_CREATE4res(XDR *xdrs, CREATE4res *objp)
2172*7c478bd9Sstevel@tonic-gate {
2173*7c478bd9Sstevel@tonic-gate 	if (!xdr_int(xdrs, (int32_t *)&objp->status))
2174*7c478bd9Sstevel@tonic-gate 		return (FALSE);
2175*7c478bd9Sstevel@tonic-gate 	if (objp->status != NFS4_OK)
2176*7c478bd9Sstevel@tonic-gate 		return (TRUE);
2177*7c478bd9Sstevel@tonic-gate 	if (!xdr_bool(xdrs, &objp->cinfo.atomic))
2178*7c478bd9Sstevel@tonic-gate 		return (FALSE);
2179*7c478bd9Sstevel@tonic-gate 	if (!xdr_u_longlong_t(xdrs, (u_longlong_t *)&objp->cinfo.before))
2180*7c478bd9Sstevel@tonic-gate 		return (FALSE);
2181*7c478bd9Sstevel@tonic-gate 	if (!xdr_u_longlong_t(xdrs, (u_longlong_t *)&objp->cinfo.after))
2182*7c478bd9Sstevel@tonic-gate 		return (FALSE);
2183*7c478bd9Sstevel@tonic-gate 	return (xdr_bitmap4(xdrs, &objp->attrset));
2184*7c478bd9Sstevel@tonic-gate }
2185*7c478bd9Sstevel@tonic-gate 
2186*7c478bd9Sstevel@tonic-gate static bool_t
2187*7c478bd9Sstevel@tonic-gate xdr_LINK4res(XDR *xdrs, LINK4res *objp)
2188*7c478bd9Sstevel@tonic-gate {
2189*7c478bd9Sstevel@tonic-gate 	if (!xdr_int(xdrs, (int32_t *)&objp->status))
2190*7c478bd9Sstevel@tonic-gate 		return (FALSE);
2191*7c478bd9Sstevel@tonic-gate 	if (objp->status != NFS4_OK)
2192*7c478bd9Sstevel@tonic-gate 		return (TRUE);
2193*7c478bd9Sstevel@tonic-gate 	if (!xdr_bool(xdrs, &objp->cinfo.atomic))
2194*7c478bd9Sstevel@tonic-gate 		return (FALSE);
2195*7c478bd9Sstevel@tonic-gate 	if (!xdr_u_longlong_t(xdrs, (u_longlong_t *)&objp->cinfo.before))
2196*7c478bd9Sstevel@tonic-gate 		return (FALSE);
2197*7c478bd9Sstevel@tonic-gate 	return (xdr_u_longlong_t(xdrs, (u_longlong_t *)&objp->cinfo.after));
2198*7c478bd9Sstevel@tonic-gate }
2199*7c478bd9Sstevel@tonic-gate 
2200*7c478bd9Sstevel@tonic-gate static bool_t
2201*7c478bd9Sstevel@tonic-gate xdr_LOCK4args(XDR *xdrs, LOCK4args *objp)
2202*7c478bd9Sstevel@tonic-gate {
2203*7c478bd9Sstevel@tonic-gate 	if (xdrs->x_op != XDR_FREE) {
2204*7c478bd9Sstevel@tonic-gate 		if (!xdr_int(xdrs, (int *)&objp->locktype))
2205*7c478bd9Sstevel@tonic-gate 			return (FALSE);
2206*7c478bd9Sstevel@tonic-gate 		if (!xdr_bool(xdrs, &objp->reclaim))
2207*7c478bd9Sstevel@tonic-gate 			return (FALSE);
2208*7c478bd9Sstevel@tonic-gate 		if (!xdr_u_longlong_t(xdrs, (u_longlong_t *)&objp->offset))
2209*7c478bd9Sstevel@tonic-gate 			return (FALSE);
2210*7c478bd9Sstevel@tonic-gate 		if (!xdr_u_longlong_t(xdrs, (u_longlong_t *)&objp->length))
2211*7c478bd9Sstevel@tonic-gate 			return (FALSE);
2212*7c478bd9Sstevel@tonic-gate 		if (!xdr_bool(xdrs, &objp->locker.new_lock_owner))
2213*7c478bd9Sstevel@tonic-gate 			return (FALSE);
2214*7c478bd9Sstevel@tonic-gate 		if (objp->locker.new_lock_owner == TRUE) {
2215*7c478bd9Sstevel@tonic-gate 			if (!xdr_u_int(xdrs, &objp->locker.locker4_u.open_owner.
2216*7c478bd9Sstevel@tonic-gate 							open_seqid))
2217*7c478bd9Sstevel@tonic-gate 				return (FALSE);
2218*7c478bd9Sstevel@tonic-gate 			if (!xdr_u_int(xdrs, &objp->locker.locker4_u.open_owner.
2219*7c478bd9Sstevel@tonic-gate 							open_stateid.seqid))
2220*7c478bd9Sstevel@tonic-gate 				return (FALSE);
2221*7c478bd9Sstevel@tonic-gate 			if (!xdr_opaque(xdrs, objp->locker.locker4_u.open_owner.
2222*7c478bd9Sstevel@tonic-gate 							open_stateid.other,
2223*7c478bd9Sstevel@tonic-gate 				    12))
2224*7c478bd9Sstevel@tonic-gate 				return (FALSE);
2225*7c478bd9Sstevel@tonic-gate 			if (!xdr_u_int(xdrs, &objp->locker.locker4_u.open_owner.
2226*7c478bd9Sstevel@tonic-gate 							lock_seqid))
2227*7c478bd9Sstevel@tonic-gate 				return (FALSE);
2228*7c478bd9Sstevel@tonic-gate 			if (!xdr_u_longlong_t(xdrs,
2229*7c478bd9Sstevel@tonic-gate 				    (u_longlong_t *)&objp->locker.locker4_u.
2230*7c478bd9Sstevel@tonic-gate 					open_owner.lock_owner.clientid))
2231*7c478bd9Sstevel@tonic-gate 				return (FALSE);
2232*7c478bd9Sstevel@tonic-gate 			return (xdr_bytes(xdrs,
2233*7c478bd9Sstevel@tonic-gate 				(char **)&objp->locker.locker4_u.open_owner.
2234*7c478bd9Sstevel@tonic-gate 				    lock_owner.owner_val,
2235*7c478bd9Sstevel@tonic-gate 				(uint_t *)&objp->locker.locker4_u.open_owner.
2236*7c478bd9Sstevel@tonic-gate 				    lock_owner.owner_len,
2237*7c478bd9Sstevel@tonic-gate 				NFS4_OPAQUE_LIMIT));
2238*7c478bd9Sstevel@tonic-gate 		}
2239*7c478bd9Sstevel@tonic-gate 
2240*7c478bd9Sstevel@tonic-gate 		if (objp->locker.new_lock_owner != FALSE)
2241*7c478bd9Sstevel@tonic-gate 			return (FALSE);
2242*7c478bd9Sstevel@tonic-gate 
2243*7c478bd9Sstevel@tonic-gate 		if (!xdr_u_int(xdrs, &objp->locker.locker4_u.lock_owner.
2244*7c478bd9Sstevel@tonic-gate 							lock_stateid.seqid))
2245*7c478bd9Sstevel@tonic-gate 			return (FALSE);
2246*7c478bd9Sstevel@tonic-gate 		if (!xdr_opaque(xdrs, objp->locker.locker4_u.lock_owner.
2247*7c478bd9Sstevel@tonic-gate 							lock_stateid.other,
2248*7c478bd9Sstevel@tonic-gate 			    12))
2249*7c478bd9Sstevel@tonic-gate 			return (FALSE);
2250*7c478bd9Sstevel@tonic-gate 		return (xdr_u_int(xdrs, &objp->locker.locker4_u.lock_owner.
2251*7c478bd9Sstevel@tonic-gate 							lock_seqid));
2252*7c478bd9Sstevel@tonic-gate 	}
2253*7c478bd9Sstevel@tonic-gate 
2254*7c478bd9Sstevel@tonic-gate 	/*
2255*7c478bd9Sstevel@tonic-gate 	 * Optimized free case
2256*7c478bd9Sstevel@tonic-gate 	 */
2257*7c478bd9Sstevel@tonic-gate 	if (objp->locker.new_lock_owner == TRUE) {
2258*7c478bd9Sstevel@tonic-gate 		if (objp->locker.locker4_u.open_owner.lock_owner.owner_val !=
2259*7c478bd9Sstevel@tonic-gate 								NULL) {
2260*7c478bd9Sstevel@tonic-gate 			kmem_free(objp->locker.locker4_u.open_owner.lock_owner.
2261*7c478bd9Sstevel@tonic-gate 							owner_val,
2262*7c478bd9Sstevel@tonic-gate 				objp->locker.locker4_u.open_owner.lock_owner.
2263*7c478bd9Sstevel@tonic-gate 							owner_len);
2264*7c478bd9Sstevel@tonic-gate 		}
2265*7c478bd9Sstevel@tonic-gate 	}
2266*7c478bd9Sstevel@tonic-gate 
2267*7c478bd9Sstevel@tonic-gate 	return (TRUE);
2268*7c478bd9Sstevel@tonic-gate }
2269*7c478bd9Sstevel@tonic-gate 
2270*7c478bd9Sstevel@tonic-gate static bool_t
2271*7c478bd9Sstevel@tonic-gate xdr_LOCK4res(XDR *xdrs, LOCK4res *objp)
2272*7c478bd9Sstevel@tonic-gate {
2273*7c478bd9Sstevel@tonic-gate 	if (xdrs->x_op != XDR_FREE) {
2274*7c478bd9Sstevel@tonic-gate 		if (!xdr_int(xdrs, (int32_t *)&objp->status))
2275*7c478bd9Sstevel@tonic-gate 			return (FALSE);
2276*7c478bd9Sstevel@tonic-gate 		if (objp->status == NFS4_OK) {
2277*7c478bd9Sstevel@tonic-gate 			if (!xdr_u_int(xdrs,
2278*7c478bd9Sstevel@tonic-gate 					&objp->LOCK4res_u.lock_stateid.seqid))
2279*7c478bd9Sstevel@tonic-gate 				return (FALSE);
2280*7c478bd9Sstevel@tonic-gate 			return (xdr_opaque(xdrs,
2281*7c478bd9Sstevel@tonic-gate 				objp->LOCK4res_u.lock_stateid.other, 12));
2282*7c478bd9Sstevel@tonic-gate 		}
2283*7c478bd9Sstevel@tonic-gate 		if (objp->status != NFS4ERR_DENIED)
2284*7c478bd9Sstevel@tonic-gate 			return (TRUE);
2285*7c478bd9Sstevel@tonic-gate 
2286*7c478bd9Sstevel@tonic-gate 		if (!xdr_u_longlong_t(xdrs, (u_longlong_t *)&objp->LOCK4res_u.
2287*7c478bd9Sstevel@tonic-gate 				denied.offset))
2288*7c478bd9Sstevel@tonic-gate 			return (FALSE);
2289*7c478bd9Sstevel@tonic-gate 		if (!xdr_u_longlong_t(xdrs, (u_longlong_t *)&objp->LOCK4res_u.
2290*7c478bd9Sstevel@tonic-gate 				denied.length))
2291*7c478bd9Sstevel@tonic-gate 			return (FALSE);
2292*7c478bd9Sstevel@tonic-gate 		if (!xdr_int(xdrs, (int *)&objp->LOCK4res_u.denied.locktype))
2293*7c478bd9Sstevel@tonic-gate 			return (FALSE);
2294*7c478bd9Sstevel@tonic-gate 		if (!xdr_u_longlong_t(xdrs, (u_longlong_t *)&objp->LOCK4res_u.
2295*7c478bd9Sstevel@tonic-gate 				denied.owner.clientid))
2296*7c478bd9Sstevel@tonic-gate 			return (FALSE);
2297*7c478bd9Sstevel@tonic-gate 		return (xdr_bytes(xdrs,
2298*7c478bd9Sstevel@tonic-gate 			    (char **)&objp->LOCK4res_u.denied.owner.owner_val,
2299*7c478bd9Sstevel@tonic-gate 			    (uint_t *)&objp->LOCK4res_u.denied.owner.owner_len,
2300*7c478bd9Sstevel@tonic-gate 			    NFS4_OPAQUE_LIMIT));
2301*7c478bd9Sstevel@tonic-gate 	}
2302*7c478bd9Sstevel@tonic-gate 
2303*7c478bd9Sstevel@tonic-gate 	/*
2304*7c478bd9Sstevel@tonic-gate 	 * Optimized free case
2305*7c478bd9Sstevel@tonic-gate 	 */
2306*7c478bd9Sstevel@tonic-gate 	if (objp->status == NFS4_OK || objp->status != NFS4ERR_DENIED)
2307*7c478bd9Sstevel@tonic-gate 		return (TRUE);
2308*7c478bd9Sstevel@tonic-gate 
2309*7c478bd9Sstevel@tonic-gate 	if (objp->LOCK4res_u.denied.owner.owner_val != NULL)
2310*7c478bd9Sstevel@tonic-gate 		kmem_free(objp->LOCK4res_u.denied.owner.owner_val,
2311*7c478bd9Sstevel@tonic-gate 			objp->LOCK4res_u.denied.owner.owner_len);
2312*7c478bd9Sstevel@tonic-gate 	return (TRUE);
2313*7c478bd9Sstevel@tonic-gate }
2314*7c478bd9Sstevel@tonic-gate 
2315*7c478bd9Sstevel@tonic-gate static bool_t
2316*7c478bd9Sstevel@tonic-gate xdr_LOCKT4args(XDR *xdrs, LOCKT4args *objp)
2317*7c478bd9Sstevel@tonic-gate {
2318*7c478bd9Sstevel@tonic-gate 	if (xdrs->x_op != XDR_FREE) {
2319*7c478bd9Sstevel@tonic-gate 		if (!xdr_int(xdrs, (int *)&objp->locktype))
2320*7c478bd9Sstevel@tonic-gate 			return (FALSE);
2321*7c478bd9Sstevel@tonic-gate 		if (!xdr_u_longlong_t(xdrs, (u_longlong_t *)&objp->offset))
2322*7c478bd9Sstevel@tonic-gate 			return (FALSE);
2323*7c478bd9Sstevel@tonic-gate 		if (!xdr_u_longlong_t(xdrs, (u_longlong_t *)&objp->length))
2324*7c478bd9Sstevel@tonic-gate 			return (FALSE);
2325*7c478bd9Sstevel@tonic-gate 		if (!xdr_u_longlong_t(xdrs,
2326*7c478bd9Sstevel@tonic-gate 					(u_longlong_t *)&objp->owner.clientid))
2327*7c478bd9Sstevel@tonic-gate 			return (FALSE);
2328*7c478bd9Sstevel@tonic-gate 		return (xdr_bytes(xdrs, (char **)&objp->owner.owner_val,
2329*7c478bd9Sstevel@tonic-gate 			(uint_t *)&objp->owner.owner_len,
2330*7c478bd9Sstevel@tonic-gate 			NFS4_OPAQUE_LIMIT));
2331*7c478bd9Sstevel@tonic-gate 	}
2332*7c478bd9Sstevel@tonic-gate 
2333*7c478bd9Sstevel@tonic-gate 	/*
2334*7c478bd9Sstevel@tonic-gate 	 * Optimized free case
2335*7c478bd9Sstevel@tonic-gate 	 */
2336*7c478bd9Sstevel@tonic-gate 	if (objp->owner.owner_val != NULL)
2337*7c478bd9Sstevel@tonic-gate 		kmem_free(objp->owner.owner_val, objp->owner.owner_len);
2338*7c478bd9Sstevel@tonic-gate 	return (TRUE);
2339*7c478bd9Sstevel@tonic-gate }
2340*7c478bd9Sstevel@tonic-gate 
2341*7c478bd9Sstevel@tonic-gate static bool_t
2342*7c478bd9Sstevel@tonic-gate xdr_LOCKT4res(XDR *xdrs, LOCKT4res *objp)
2343*7c478bd9Sstevel@tonic-gate {
2344*7c478bd9Sstevel@tonic-gate 	if (xdrs->x_op != XDR_FREE) {
2345*7c478bd9Sstevel@tonic-gate 		if (!xdr_int(xdrs, (int32_t *)&objp->status))
2346*7c478bd9Sstevel@tonic-gate 			return (FALSE);
2347*7c478bd9Sstevel@tonic-gate 		if (objp->status == NFS4_OK)
2348*7c478bd9Sstevel@tonic-gate 			return (TRUE);
2349*7c478bd9Sstevel@tonic-gate 		if (objp->status != NFS4ERR_DENIED)
2350*7c478bd9Sstevel@tonic-gate 			return (TRUE);
2351*7c478bd9Sstevel@tonic-gate 		/* xdr_LOCK4denied */
2352*7c478bd9Sstevel@tonic-gate 		if (!xdr_u_longlong_t(xdrs,
2353*7c478bd9Sstevel@tonic-gate 					(u_longlong_t *)&objp->denied.offset))
2354*7c478bd9Sstevel@tonic-gate 			return (FALSE);
2355*7c478bd9Sstevel@tonic-gate 		if (!xdr_u_longlong_t(xdrs,
2356*7c478bd9Sstevel@tonic-gate 					(u_longlong_t *)&objp->denied.length))
2357*7c478bd9Sstevel@tonic-gate 			return (FALSE);
2358*7c478bd9Sstevel@tonic-gate 		if (!xdr_int(xdrs, (int *)&objp->denied.locktype))
2359*7c478bd9Sstevel@tonic-gate 			return (FALSE);
2360*7c478bd9Sstevel@tonic-gate 		if (!xdr_u_longlong_t(xdrs,
2361*7c478bd9Sstevel@tonic-gate 				(u_longlong_t *)&objp->denied.owner.clientid))
2362*7c478bd9Sstevel@tonic-gate 			return (FALSE);
2363*7c478bd9Sstevel@tonic-gate 		return (xdr_bytes(xdrs,
2364*7c478bd9Sstevel@tonic-gate 		    (char **)&objp->denied.owner.owner_val,
2365*7c478bd9Sstevel@tonic-gate 		    (uint_t *)&objp->denied.owner.owner_len,
2366*7c478bd9Sstevel@tonic-gate 		    NFS4_OPAQUE_LIMIT));
2367*7c478bd9Sstevel@tonic-gate 	}
2368*7c478bd9Sstevel@tonic-gate 
2369*7c478bd9Sstevel@tonic-gate 	/*
2370*7c478bd9Sstevel@tonic-gate 	 * Optimized free case
2371*7c478bd9Sstevel@tonic-gate 	 */
2372*7c478bd9Sstevel@tonic-gate 	if (objp->status == NFS4_OK || objp->status != NFS4ERR_DENIED)
2373*7c478bd9Sstevel@tonic-gate 		return (TRUE);
2374*7c478bd9Sstevel@tonic-gate 	if (objp->denied.owner.owner_val != NULL)
2375*7c478bd9Sstevel@tonic-gate 		kmem_free(objp->denied.owner.owner_val,
2376*7c478bd9Sstevel@tonic-gate 				objp->denied.owner.owner_len);
2377*7c478bd9Sstevel@tonic-gate 	return (TRUE);
2378*7c478bd9Sstevel@tonic-gate }
2379*7c478bd9Sstevel@tonic-gate 
2380*7c478bd9Sstevel@tonic-gate static bool_t
2381*7c478bd9Sstevel@tonic-gate xdr_LOCKU4args(XDR *xdrs, LOCKU4args *objp)
2382*7c478bd9Sstevel@tonic-gate {
2383*7c478bd9Sstevel@tonic-gate 	if (!xdr_int(xdrs, (int *)&objp->locktype))
2384*7c478bd9Sstevel@tonic-gate 		return (FALSE);
2385*7c478bd9Sstevel@tonic-gate 	if (!xdr_u_int(xdrs, &objp->seqid))
2386*7c478bd9Sstevel@tonic-gate 		return (FALSE);
2387*7c478bd9Sstevel@tonic-gate 	if (!xdr_u_int(xdrs, &objp->lock_stateid.seqid))
2388*7c478bd9Sstevel@tonic-gate 		return (FALSE);
2389*7c478bd9Sstevel@tonic-gate 	if (!xdr_opaque(xdrs, objp->lock_stateid.other, 12))
2390*7c478bd9Sstevel@tonic-gate 		return (FALSE);
2391*7c478bd9Sstevel@tonic-gate 	if (!xdr_u_longlong_t(xdrs, (u_longlong_t *)&objp->offset))
2392*7c478bd9Sstevel@tonic-gate 		return (FALSE);
2393*7c478bd9Sstevel@tonic-gate 	return (xdr_u_longlong_t(xdrs, (u_longlong_t *)&objp->length));
2394*7c478bd9Sstevel@tonic-gate }
2395*7c478bd9Sstevel@tonic-gate 
2396*7c478bd9Sstevel@tonic-gate static bool_t
2397*7c478bd9Sstevel@tonic-gate xdr_OPEN4args(XDR *xdrs, OPEN4args *objp)
2398*7c478bd9Sstevel@tonic-gate {
2399*7c478bd9Sstevel@tonic-gate 	if (xdrs->x_op != XDR_FREE) {
2400*7c478bd9Sstevel@tonic-gate 		if (!xdr_u_int(xdrs, &objp->seqid))
2401*7c478bd9Sstevel@tonic-gate 			return (FALSE);
2402*7c478bd9Sstevel@tonic-gate 		if (!xdr_u_int(xdrs, &objp->share_access))
2403*7c478bd9Sstevel@tonic-gate 			return (FALSE);
2404*7c478bd9Sstevel@tonic-gate 		if (!xdr_u_int(xdrs, &objp->share_deny))
2405*7c478bd9Sstevel@tonic-gate 			return (FALSE);
2406*7c478bd9Sstevel@tonic-gate 
2407*7c478bd9Sstevel@tonic-gate 		/* xdr_open_owner4 */
2408*7c478bd9Sstevel@tonic-gate 		if (!xdr_u_longlong_t(xdrs,
2409*7c478bd9Sstevel@tonic-gate 					(u_longlong_t *)&objp->owner.clientid))
2410*7c478bd9Sstevel@tonic-gate 			return (FALSE);
2411*7c478bd9Sstevel@tonic-gate 		if (!xdr_bytes(xdrs, (char **)&objp->owner.owner_val,
2412*7c478bd9Sstevel@tonic-gate 				(uint_t *)&objp->owner.owner_len,
2413*7c478bd9Sstevel@tonic-gate 				NFS4_OPAQUE_LIMIT))
2414*7c478bd9Sstevel@tonic-gate 			return (FALSE);
2415*7c478bd9Sstevel@tonic-gate 
2416*7c478bd9Sstevel@tonic-gate 		/* xdr_openflag4 */
2417*7c478bd9Sstevel@tonic-gate 		if (!xdr_int(xdrs, (int *)&objp->opentype))
2418*7c478bd9Sstevel@tonic-gate 			return (FALSE);
2419*7c478bd9Sstevel@tonic-gate 		if (objp->opentype == OPEN4_CREATE) {
2420*7c478bd9Sstevel@tonic-gate 
2421*7c478bd9Sstevel@tonic-gate 			/* xdr_createhow4 */
2422*7c478bd9Sstevel@tonic-gate 			if (!xdr_int(xdrs, (int *)&objp->mode))
2423*7c478bd9Sstevel@tonic-gate 				return (FALSE);
2424*7c478bd9Sstevel@tonic-gate 			switch (objp->mode) {
2425*7c478bd9Sstevel@tonic-gate 			case UNCHECKED4:
2426*7c478bd9Sstevel@tonic-gate 			case GUARDED4:
2427*7c478bd9Sstevel@tonic-gate 				if (!xdr_fattr4(xdrs,
2428*7c478bd9Sstevel@tonic-gate 					    &objp->createhow4_u.createattrs))
2429*7c478bd9Sstevel@tonic-gate 					return (FALSE);
2430*7c478bd9Sstevel@tonic-gate 				break;
2431*7c478bd9Sstevel@tonic-gate 			case EXCLUSIVE4:
2432*7c478bd9Sstevel@tonic-gate 				if (!xdr_u_longlong_t(xdrs,
2433*7c478bd9Sstevel@tonic-gate 				    (u_longlong_t *)&objp->createhow4_u.
2434*7c478bd9Sstevel@tonic-gate 				    createverf))
2435*7c478bd9Sstevel@tonic-gate 					return (FALSE);
2436*7c478bd9Sstevel@tonic-gate 				break;
2437*7c478bd9Sstevel@tonic-gate 			default:
2438*7c478bd9Sstevel@tonic-gate 				return (FALSE);
2439*7c478bd9Sstevel@tonic-gate 			}
2440*7c478bd9Sstevel@tonic-gate 		}
2441*7c478bd9Sstevel@tonic-gate 
2442*7c478bd9Sstevel@tonic-gate 		/* xdr_open_claim4 */
2443*7c478bd9Sstevel@tonic-gate 		if (!xdr_int(xdrs, (int *)&objp->claim))
2444*7c478bd9Sstevel@tonic-gate 			return (FALSE);
2445*7c478bd9Sstevel@tonic-gate 
2446*7c478bd9Sstevel@tonic-gate 		switch (objp->claim) {
2447*7c478bd9Sstevel@tonic-gate 		case CLAIM_NULL:
2448*7c478bd9Sstevel@tonic-gate 			return (xdr_bytes(xdrs, (char **)&objp->open_claim4_u.
2449*7c478bd9Sstevel@tonic-gate 					file.utf8string_val,
2450*7c478bd9Sstevel@tonic-gate 				(uint_t *)&objp->open_claim4_u.file.
2451*7c478bd9Sstevel@tonic-gate 					utf8string_len,
2452*7c478bd9Sstevel@tonic-gate 				NFS4_MAX_UTF8STRING));
2453*7c478bd9Sstevel@tonic-gate 		case CLAIM_PREVIOUS:
2454*7c478bd9Sstevel@tonic-gate 			return (xdr_int(xdrs,
2455*7c478bd9Sstevel@tonic-gate 				(int *)&objp->open_claim4_u.delegate_type));
2456*7c478bd9Sstevel@tonic-gate 		case CLAIM_DELEGATE_CUR:
2457*7c478bd9Sstevel@tonic-gate 			if (!xdr_u_int(xdrs, (uint_t *)&objp->open_claim4_u.
2458*7c478bd9Sstevel@tonic-gate 				    delegate_cur_info.delegate_stateid.seqid))
2459*7c478bd9Sstevel@tonic-gate 				return (FALSE);
2460*7c478bd9Sstevel@tonic-gate 			if (!xdr_opaque(xdrs, objp->open_claim4_u.
2461*7c478bd9Sstevel@tonic-gate 				    delegate_cur_info.delegate_stateid.other,
2462*7c478bd9Sstevel@tonic-gate 				    12))
2463*7c478bd9Sstevel@tonic-gate 				return (FALSE);
2464*7c478bd9Sstevel@tonic-gate 			return (xdr_bytes(xdrs, (char **)&objp->open_claim4_u.
2465*7c478bd9Sstevel@tonic-gate 				delegate_cur_info.file.utf8string_val,
2466*7c478bd9Sstevel@tonic-gate 			    (uint_t *)&objp->open_claim4_u.
2467*7c478bd9Sstevel@tonic-gate 				delegate_cur_info.file.utf8string_len,
2468*7c478bd9Sstevel@tonic-gate 			    NFS4_MAX_UTF8STRING));
2469*7c478bd9Sstevel@tonic-gate 		case CLAIM_DELEGATE_PREV:
2470*7c478bd9Sstevel@tonic-gate 			return (xdr_bytes(xdrs, (char **)&objp->open_claim4_u.
2471*7c478bd9Sstevel@tonic-gate 				file_delegate_prev.utf8string_val,
2472*7c478bd9Sstevel@tonic-gate 			    (uint_t *)&objp->open_claim4_u.
2473*7c478bd9Sstevel@tonic-gate 				file_delegate_prev.utf8string_len,
2474*7c478bd9Sstevel@tonic-gate 			    NFS4_MAX_UTF8STRING));
2475*7c478bd9Sstevel@tonic-gate 		default:
2476*7c478bd9Sstevel@tonic-gate 			return (FALSE);
2477*7c478bd9Sstevel@tonic-gate 		}
2478*7c478bd9Sstevel@tonic-gate 	}
2479*7c478bd9Sstevel@tonic-gate 
2480*7c478bd9Sstevel@tonic-gate 	/*
2481*7c478bd9Sstevel@tonic-gate 	 * Optimized free case
2482*7c478bd9Sstevel@tonic-gate 	 */
2483*7c478bd9Sstevel@tonic-gate 	if (objp->owner.owner_val != NULL)
2484*7c478bd9Sstevel@tonic-gate 		kmem_free(objp->owner.owner_val, objp->owner.owner_len);
2485*7c478bd9Sstevel@tonic-gate 
2486*7c478bd9Sstevel@tonic-gate 	if (objp->opentype == OPEN4_CREATE) {
2487*7c478bd9Sstevel@tonic-gate 		switch (objp->mode) {
2488*7c478bd9Sstevel@tonic-gate 		case UNCHECKED4:
2489*7c478bd9Sstevel@tonic-gate 		case GUARDED4:
2490*7c478bd9Sstevel@tonic-gate 			(void) xdr_fattr4(xdrs,
2491*7c478bd9Sstevel@tonic-gate 					&objp->createhow4_u.createattrs);
2492*7c478bd9Sstevel@tonic-gate 			break;
2493*7c478bd9Sstevel@tonic-gate 		case EXCLUSIVE4:
2494*7c478bd9Sstevel@tonic-gate 		default:
2495*7c478bd9Sstevel@tonic-gate 			break;
2496*7c478bd9Sstevel@tonic-gate 		}
2497*7c478bd9Sstevel@tonic-gate 	}
2498*7c478bd9Sstevel@tonic-gate 
2499*7c478bd9Sstevel@tonic-gate 	switch (objp->claim) {
2500*7c478bd9Sstevel@tonic-gate 	case CLAIM_NULL:
2501*7c478bd9Sstevel@tonic-gate 		if (objp->open_claim4_u.file.utf8string_val != NULL)
2502*7c478bd9Sstevel@tonic-gate 			kmem_free(objp->open_claim4_u.file.utf8string_val,
2503*7c478bd9Sstevel@tonic-gate 				objp->open_claim4_u.file.utf8string_len);
2504*7c478bd9Sstevel@tonic-gate 		return (TRUE);
2505*7c478bd9Sstevel@tonic-gate 	case CLAIM_PREVIOUS:
2506*7c478bd9Sstevel@tonic-gate 		return (TRUE);
2507*7c478bd9Sstevel@tonic-gate 	case CLAIM_DELEGATE_CUR:
2508*7c478bd9Sstevel@tonic-gate 		if (objp->open_claim4_u.delegate_cur_info.file.utf8string_val !=
2509*7c478bd9Sstevel@tonic-gate 								NULL) {
2510*7c478bd9Sstevel@tonic-gate 			kmem_free(objp->open_claim4_u.delegate_cur_info.file.
2511*7c478bd9Sstevel@tonic-gate 							utf8string_val,
2512*7c478bd9Sstevel@tonic-gate 				objp->open_claim4_u.delegate_cur_info.file.
2513*7c478bd9Sstevel@tonic-gate 							utf8string_len);
2514*7c478bd9Sstevel@tonic-gate 		}
2515*7c478bd9Sstevel@tonic-gate 		return (TRUE);
2516*7c478bd9Sstevel@tonic-gate 	case CLAIM_DELEGATE_PREV:
2517*7c478bd9Sstevel@tonic-gate 		if (objp->open_claim4_u.file_delegate_prev.utf8string_val !=
2518*7c478bd9Sstevel@tonic-gate 								NULL) {
2519*7c478bd9Sstevel@tonic-gate 			kmem_free(objp->open_claim4_u.file_delegate_prev.
2520*7c478bd9Sstevel@tonic-gate 							utf8string_val,
2521*7c478bd9Sstevel@tonic-gate 				objp->open_claim4_u.file_delegate_prev.
2522*7c478bd9Sstevel@tonic-gate 							utf8string_len);
2523*7c478bd9Sstevel@tonic-gate 		}
2524*7c478bd9Sstevel@tonic-gate 		return (TRUE);
2525*7c478bd9Sstevel@tonic-gate 	default:
2526*7c478bd9Sstevel@tonic-gate 		return (TRUE);
2527*7c478bd9Sstevel@tonic-gate 	}
2528*7c478bd9Sstevel@tonic-gate 	/* NOTREACHED */
2529*7c478bd9Sstevel@tonic-gate }
2530*7c478bd9Sstevel@tonic-gate 
2531*7c478bd9Sstevel@tonic-gate static bool_t
2532*7c478bd9Sstevel@tonic-gate xdr_OPEN4cargs(XDR *xdrs, OPEN4cargs *objp)
2533*7c478bd9Sstevel@tonic-gate {
2534*7c478bd9Sstevel@tonic-gate 	int op;
2535*7c478bd9Sstevel@tonic-gate 	int len;
2536*7c478bd9Sstevel@tonic-gate 	rpc_inline_t *ptr;
2537*7c478bd9Sstevel@tonic-gate 
2538*7c478bd9Sstevel@tonic-gate 	ASSERT(xdrs->x_op == XDR_ENCODE);
2539*7c478bd9Sstevel@tonic-gate 
2540*7c478bd9Sstevel@tonic-gate 	/*
2541*7c478bd9Sstevel@tonic-gate 	 * We must always define the client's open_owner to be
2542*7c478bd9Sstevel@tonic-gate 	 * 4 byte aligned and sized.
2543*7c478bd9Sstevel@tonic-gate 	 */
2544*7c478bd9Sstevel@tonic-gate 	ASSERT(objp->owner.owner_len <= NFS4_OPAQUE_LIMIT);
2545*7c478bd9Sstevel@tonic-gate 	ASSERT(!(objp->owner.owner_len % BYTES_PER_XDR_UNIT));
2546*7c478bd9Sstevel@tonic-gate 
2547*7c478bd9Sstevel@tonic-gate 	len = objp->owner.owner_len;
2548*7c478bd9Sstevel@tonic-gate 	if ((ptr = XDR_INLINE(xdrs, 8 * BYTES_PER_XDR_UNIT + len)) != NULL) {
2549*7c478bd9Sstevel@tonic-gate 		int i;
2550*7c478bd9Sstevel@tonic-gate 		int32_t *ip;
2551*7c478bd9Sstevel@tonic-gate 
2552*7c478bd9Sstevel@tonic-gate 		IXDR_PUT_U_INT32(ptr, OP_OPEN);
2553*7c478bd9Sstevel@tonic-gate 		IXDR_PUT_U_INT32(ptr, objp->seqid);
2554*7c478bd9Sstevel@tonic-gate 		IXDR_PUT_U_INT32(ptr, objp->share_access);
2555*7c478bd9Sstevel@tonic-gate 		IXDR_PUT_U_INT32(ptr, objp->share_deny);
2556*7c478bd9Sstevel@tonic-gate 
2557*7c478bd9Sstevel@tonic-gate 		/* xdr_open_owner4 */
2558*7c478bd9Sstevel@tonic-gate 		IXDR_PUT_HYPER(ptr, objp->owner.clientid);
2559*7c478bd9Sstevel@tonic-gate 		IXDR_PUT_U_INT32(ptr, objp->owner.owner_len);
2560*7c478bd9Sstevel@tonic-gate 		/* We know this is very short so don't bcopy */
2561*7c478bd9Sstevel@tonic-gate 		ip = (int32_t *)objp->owner.owner_val;
2562*7c478bd9Sstevel@tonic-gate 		len /= BYTES_PER_XDR_UNIT;
2563*7c478bd9Sstevel@tonic-gate 		for (i = 0; i < len; i++)
2564*7c478bd9Sstevel@tonic-gate 			*ptr++ = *ip++;
2565*7c478bd9Sstevel@tonic-gate 
2566*7c478bd9Sstevel@tonic-gate 		/* xdr_openflag4 */
2567*7c478bd9Sstevel@tonic-gate 		IXDR_PUT_U_INT32(ptr, objp->opentype);
2568*7c478bd9Sstevel@tonic-gate 	} else {
2569*7c478bd9Sstevel@tonic-gate 		op = OP_OPEN;
2570*7c478bd9Sstevel@tonic-gate 		if (!XDR_PUTINT32(xdrs, (int32_t *)&op))
2571*7c478bd9Sstevel@tonic-gate 			return (FALSE);
2572*7c478bd9Sstevel@tonic-gate 		if (!XDR_PUTINT32(xdrs, (int32_t *)&objp->seqid))
2573*7c478bd9Sstevel@tonic-gate 			return (FALSE);
2574*7c478bd9Sstevel@tonic-gate 		if (!XDR_PUTINT32(xdrs, (int32_t *)&objp->share_access))
2575*7c478bd9Sstevel@tonic-gate 			return (FALSE);
2576*7c478bd9Sstevel@tonic-gate 		if (!XDR_PUTINT32(xdrs, (int32_t *)&objp->share_deny))
2577*7c478bd9Sstevel@tonic-gate 			return (FALSE);
2578*7c478bd9Sstevel@tonic-gate 
2579*7c478bd9Sstevel@tonic-gate 		/* xdr_open_owner4 */
2580*7c478bd9Sstevel@tonic-gate 		if (!xdr_u_longlong_t(xdrs,
2581*7c478bd9Sstevel@tonic-gate 				(u_longlong_t *)&objp->owner.clientid))
2582*7c478bd9Sstevel@tonic-gate 			return (FALSE);
2583*7c478bd9Sstevel@tonic-gate 		if (!XDR_PUTINT32(xdrs, (int32_t *)&objp->owner.owner_len))
2584*7c478bd9Sstevel@tonic-gate 			return (FALSE);
2585*7c478bd9Sstevel@tonic-gate 		if (!xdr_opaque(xdrs, objp->owner.owner_val,
2586*7c478bd9Sstevel@tonic-gate 				objp->owner.owner_len))
2587*7c478bd9Sstevel@tonic-gate 			return (FALSE);
2588*7c478bd9Sstevel@tonic-gate 
2589*7c478bd9Sstevel@tonic-gate 		/* xdr_openflag4 */
2590*7c478bd9Sstevel@tonic-gate 		if (!XDR_PUTINT32(xdrs, (int32_t *)&objp->opentype))
2591*7c478bd9Sstevel@tonic-gate 			return (FALSE);
2592*7c478bd9Sstevel@tonic-gate 	}
2593*7c478bd9Sstevel@tonic-gate 
2594*7c478bd9Sstevel@tonic-gate 	if (objp->opentype == OPEN4_CREATE) {
2595*7c478bd9Sstevel@tonic-gate 		/* xdr_createhow4 */
2596*7c478bd9Sstevel@tonic-gate 		if (!XDR_PUTINT32(xdrs, (int32_t *)&objp->mode))
2597*7c478bd9Sstevel@tonic-gate 			return (FALSE);
2598*7c478bd9Sstevel@tonic-gate 		switch (objp->mode) {
2599*7c478bd9Sstevel@tonic-gate 		case UNCHECKED4:
2600*7c478bd9Sstevel@tonic-gate 		case GUARDED4:
2601*7c478bd9Sstevel@tonic-gate 			if (!xdr_fattr4(xdrs,
2602*7c478bd9Sstevel@tonic-gate 				    &objp->createhow4_u.createattrs))
2603*7c478bd9Sstevel@tonic-gate 				return (FALSE);
2604*7c478bd9Sstevel@tonic-gate 			break;
2605*7c478bd9Sstevel@tonic-gate 		case EXCLUSIVE4:
2606*7c478bd9Sstevel@tonic-gate 			if (!xdr_u_longlong_t(xdrs,
2607*7c478bd9Sstevel@tonic-gate 			    (u_longlong_t *)&objp->createhow4_u.
2608*7c478bd9Sstevel@tonic-gate 			    createverf))
2609*7c478bd9Sstevel@tonic-gate 				return (FALSE);
2610*7c478bd9Sstevel@tonic-gate 			break;
2611*7c478bd9Sstevel@tonic-gate 		default:
2612*7c478bd9Sstevel@tonic-gate 			return (FALSE);
2613*7c478bd9Sstevel@tonic-gate 		}
2614*7c478bd9Sstevel@tonic-gate 	}
2615*7c478bd9Sstevel@tonic-gate 
2616*7c478bd9Sstevel@tonic-gate 	/* xdr_open_claim4 */
2617*7c478bd9Sstevel@tonic-gate 	if (!XDR_PUTINT32(xdrs, (int32_t *)&objp->claim))
2618*7c478bd9Sstevel@tonic-gate 		return (FALSE);
2619*7c478bd9Sstevel@tonic-gate 
2620*7c478bd9Sstevel@tonic-gate 	switch (objp->claim) {
2621*7c478bd9Sstevel@tonic-gate 	case CLAIM_NULL:
2622*7c478bd9Sstevel@tonic-gate 		len = strlen(objp->open_claim4_u.cfile);
2623*7c478bd9Sstevel@tonic-gate 		if (len > NFS4_MAX_UTF8STRING)
2624*7c478bd9Sstevel@tonic-gate 			return (FALSE);
2625*7c478bd9Sstevel@tonic-gate 		if (XDR_PUTINT32(xdrs, &len)) {
2626*7c478bd9Sstevel@tonic-gate 			return (xdr_opaque(xdrs,
2627*7c478bd9Sstevel@tonic-gate 				objp->open_claim4_u.cfile, len));
2628*7c478bd9Sstevel@tonic-gate 		}
2629*7c478bd9Sstevel@tonic-gate 		return (FALSE);
2630*7c478bd9Sstevel@tonic-gate 	case CLAIM_PREVIOUS:
2631*7c478bd9Sstevel@tonic-gate 		return (XDR_PUTINT32(xdrs,
2632*7c478bd9Sstevel@tonic-gate 			(int32_t *)&objp->open_claim4_u.delegate_type));
2633*7c478bd9Sstevel@tonic-gate 	case CLAIM_DELEGATE_CUR:
2634*7c478bd9Sstevel@tonic-gate 		if (!XDR_PUTINT32(xdrs, (int32_t *)&objp->open_claim4_u.
2635*7c478bd9Sstevel@tonic-gate 				delegate_cur_info.delegate_stateid.seqid))
2636*7c478bd9Sstevel@tonic-gate 			return (FALSE);
2637*7c478bd9Sstevel@tonic-gate 		if (!xdr_opaque(xdrs, objp->open_claim4_u.
2638*7c478bd9Sstevel@tonic-gate 				delegate_cur_info.delegate_stateid.other,
2639*7c478bd9Sstevel@tonic-gate 				12))
2640*7c478bd9Sstevel@tonic-gate 			return (FALSE);
2641*7c478bd9Sstevel@tonic-gate 		len = strlen(objp->open_claim4_u.delegate_cur_info.cfile);
2642*7c478bd9Sstevel@tonic-gate 		if (len > NFS4_MAX_UTF8STRING)
2643*7c478bd9Sstevel@tonic-gate 			return (FALSE);
2644*7c478bd9Sstevel@tonic-gate 		if (XDR_PUTINT32(xdrs, &len)) {
2645*7c478bd9Sstevel@tonic-gate 			return (xdr_opaque(xdrs,
2646*7c478bd9Sstevel@tonic-gate 				objp->open_claim4_u.delegate_cur_info.cfile,
2647*7c478bd9Sstevel@tonic-gate 				len));
2648*7c478bd9Sstevel@tonic-gate 		}
2649*7c478bd9Sstevel@tonic-gate 		return (FALSE);
2650*7c478bd9Sstevel@tonic-gate 	case CLAIM_DELEGATE_PREV:
2651*7c478bd9Sstevel@tonic-gate 		len = strlen(objp->open_claim4_u.cfile_delegate_prev);
2652*7c478bd9Sstevel@tonic-gate 		if (len > NFS4_MAX_UTF8STRING)
2653*7c478bd9Sstevel@tonic-gate 			return (FALSE);
2654*7c478bd9Sstevel@tonic-gate 		if (XDR_PUTINT32(xdrs, &len)) {
2655*7c478bd9Sstevel@tonic-gate 			return (xdr_opaque(xdrs,
2656*7c478bd9Sstevel@tonic-gate 				objp->open_claim4_u.cfile_delegate_prev, len));
2657*7c478bd9Sstevel@tonic-gate 		}
2658*7c478bd9Sstevel@tonic-gate 		return (FALSE);
2659*7c478bd9Sstevel@tonic-gate 	default:
2660*7c478bd9Sstevel@tonic-gate 		return (FALSE);
2661*7c478bd9Sstevel@tonic-gate 	}
2662*7c478bd9Sstevel@tonic-gate 	/* NOTREACHED */
2663*7c478bd9Sstevel@tonic-gate 	return (FALSE);
2664*7c478bd9Sstevel@tonic-gate }
2665*7c478bd9Sstevel@tonic-gate 
2666*7c478bd9Sstevel@tonic-gate static bool_t
2667*7c478bd9Sstevel@tonic-gate xdr_OPEN4res(XDR *xdrs, OPEN4res *objp)
2668*7c478bd9Sstevel@tonic-gate {
2669*7c478bd9Sstevel@tonic-gate 	if (xdrs->x_op != XDR_FREE) {
2670*7c478bd9Sstevel@tonic-gate 		if (!xdr_int(xdrs, (int32_t *)&objp->status))
2671*7c478bd9Sstevel@tonic-gate 			return (FALSE);
2672*7c478bd9Sstevel@tonic-gate 		if (objp->status != NFS4_OK)
2673*7c478bd9Sstevel@tonic-gate 			return (TRUE);
2674*7c478bd9Sstevel@tonic-gate 		if (!xdr_u_int(xdrs, &objp->stateid.seqid))
2675*7c478bd9Sstevel@tonic-gate 			return (FALSE);
2676*7c478bd9Sstevel@tonic-gate 		if (!xdr_opaque(xdrs, objp->stateid.other, 12))
2677*7c478bd9Sstevel@tonic-gate 			return (FALSE);
2678*7c478bd9Sstevel@tonic-gate 		if (!xdr_bool(xdrs, &objp->cinfo.atomic))
2679*7c478bd9Sstevel@tonic-gate 			return (FALSE);
2680*7c478bd9Sstevel@tonic-gate 		if (!xdr_u_longlong_t(xdrs,
2681*7c478bd9Sstevel@tonic-gate 				(u_longlong_t *)&objp->cinfo.before))
2682*7c478bd9Sstevel@tonic-gate 			return (FALSE);
2683*7c478bd9Sstevel@tonic-gate 		if (!xdr_u_longlong_t(xdrs, (u_longlong_t *)&objp->cinfo.after))
2684*7c478bd9Sstevel@tonic-gate 			return (FALSE);
2685*7c478bd9Sstevel@tonic-gate 		if (!xdr_u_int(xdrs, &objp->rflags))
2686*7c478bd9Sstevel@tonic-gate 			return (FALSE);
2687*7c478bd9Sstevel@tonic-gate 		if (!xdr_bitmap4(xdrs, &objp->attrset))
2688*7c478bd9Sstevel@tonic-gate 			return (FALSE);
2689*7c478bd9Sstevel@tonic-gate 		if (!xdr_int(xdrs,
2690*7c478bd9Sstevel@tonic-gate 			    (int *)&objp->delegation.delegation_type))
2691*7c478bd9Sstevel@tonic-gate 			return (FALSE);
2692*7c478bd9Sstevel@tonic-gate 		switch (objp->delegation.delegation_type) {
2693*7c478bd9Sstevel@tonic-gate 		case OPEN_DELEGATE_NONE:
2694*7c478bd9Sstevel@tonic-gate 			return (TRUE);
2695*7c478bd9Sstevel@tonic-gate 		case OPEN_DELEGATE_READ:
2696*7c478bd9Sstevel@tonic-gate 			if (!xdr_u_int(xdrs, &objp->delegation.
2697*7c478bd9Sstevel@tonic-gate 					open_delegation4_u.read.stateid.seqid))
2698*7c478bd9Sstevel@tonic-gate 				return (FALSE);
2699*7c478bd9Sstevel@tonic-gate 			if (!xdr_opaque(xdrs, objp->delegation.
2700*7c478bd9Sstevel@tonic-gate 					open_delegation4_u.read.stateid.other,
2701*7c478bd9Sstevel@tonic-gate 					12))
2702*7c478bd9Sstevel@tonic-gate 				return (FALSE);
2703*7c478bd9Sstevel@tonic-gate 			if (!xdr_bool(xdrs, &objp->delegation.
2704*7c478bd9Sstevel@tonic-gate 					open_delegation4_u.read.recall))
2705*7c478bd9Sstevel@tonic-gate 				return (FALSE);
2706*7c478bd9Sstevel@tonic-gate 			return (xdr_nfsace4(xdrs, &objp->delegation.
2707*7c478bd9Sstevel@tonic-gate 					open_delegation4_u.read.permissions));
2708*7c478bd9Sstevel@tonic-gate 		case OPEN_DELEGATE_WRITE:
2709*7c478bd9Sstevel@tonic-gate 			if (!xdr_u_int(xdrs, &objp->delegation.
2710*7c478bd9Sstevel@tonic-gate 					open_delegation4_u.write.stateid.seqid))
2711*7c478bd9Sstevel@tonic-gate 				return (FALSE);
2712*7c478bd9Sstevel@tonic-gate 			if (!xdr_opaque(xdrs, objp->delegation.
2713*7c478bd9Sstevel@tonic-gate 					open_delegation4_u.write.stateid.other,
2714*7c478bd9Sstevel@tonic-gate 					12))
2715*7c478bd9Sstevel@tonic-gate 				return (FALSE);
2716*7c478bd9Sstevel@tonic-gate 			if (!xdr_bool(xdrs, &objp->delegation.
2717*7c478bd9Sstevel@tonic-gate 					open_delegation4_u.write.recall))
2718*7c478bd9Sstevel@tonic-gate 				return (FALSE);
2719*7c478bd9Sstevel@tonic-gate 			if (!xdr_int(xdrs, (int *)&objp->delegation.
2720*7c478bd9Sstevel@tonic-gate 					open_delegation4_u.write.space_limit.
2721*7c478bd9Sstevel@tonic-gate 					limitby))
2722*7c478bd9Sstevel@tonic-gate 				return (FALSE);
2723*7c478bd9Sstevel@tonic-gate 			switch (objp->delegation.
2724*7c478bd9Sstevel@tonic-gate 					open_delegation4_u.write.space_limit.
2725*7c478bd9Sstevel@tonic-gate 					limitby) {
2726*7c478bd9Sstevel@tonic-gate 			case NFS_LIMIT_SIZE:
2727*7c478bd9Sstevel@tonic-gate 				if (!xdr_u_longlong_t(xdrs,
2728*7c478bd9Sstevel@tonic-gate 				    (u_longlong_t *)&objp->delegation.
2729*7c478bd9Sstevel@tonic-gate 				    open_delegation4_u.write.space_limit.
2730*7c478bd9Sstevel@tonic-gate 				    nfs_space_limit4_u.filesize))
2731*7c478bd9Sstevel@tonic-gate 					return (FALSE);
2732*7c478bd9Sstevel@tonic-gate 				break;
2733*7c478bd9Sstevel@tonic-gate 			case NFS_LIMIT_BLOCKS:
2734*7c478bd9Sstevel@tonic-gate 				if (!xdr_u_int(xdrs,
2735*7c478bd9Sstevel@tonic-gate 				    &objp->delegation.open_delegation4_u.write.
2736*7c478bd9Sstevel@tonic-gate 				    space_limit.nfs_space_limit4_u.
2737*7c478bd9Sstevel@tonic-gate 				    mod_blocks.num_blocks))
2738*7c478bd9Sstevel@tonic-gate 					return (FALSE);
2739*7c478bd9Sstevel@tonic-gate 				if (!xdr_u_int(xdrs, &objp->delegation.
2740*7c478bd9Sstevel@tonic-gate 				    open_delegation4_u.write.space_limit.
2741*7c478bd9Sstevel@tonic-gate 				    nfs_space_limit4_u.mod_blocks.
2742*7c478bd9Sstevel@tonic-gate 				    bytes_per_block))
2743*7c478bd9Sstevel@tonic-gate 					return (FALSE);
2744*7c478bd9Sstevel@tonic-gate 				break;
2745*7c478bd9Sstevel@tonic-gate 			default:
2746*7c478bd9Sstevel@tonic-gate 				return (FALSE);
2747*7c478bd9Sstevel@tonic-gate 			}
2748*7c478bd9Sstevel@tonic-gate 			return (xdr_nfsace4(xdrs, &objp->delegation.
2749*7c478bd9Sstevel@tonic-gate 			    open_delegation4_u.write.permissions));
2750*7c478bd9Sstevel@tonic-gate 		}
2751*7c478bd9Sstevel@tonic-gate 		return (FALSE);
2752*7c478bd9Sstevel@tonic-gate 	}
2753*7c478bd9Sstevel@tonic-gate 
2754*7c478bd9Sstevel@tonic-gate 	/*
2755*7c478bd9Sstevel@tonic-gate 	 * Optimized free case
2756*7c478bd9Sstevel@tonic-gate 	 */
2757*7c478bd9Sstevel@tonic-gate 	if (objp->status != NFS4_OK)
2758*7c478bd9Sstevel@tonic-gate 		return (TRUE);
2759*7c478bd9Sstevel@tonic-gate 
2760*7c478bd9Sstevel@tonic-gate 	switch (objp->delegation.delegation_type) {
2761*7c478bd9Sstevel@tonic-gate 	case OPEN_DELEGATE_NONE:
2762*7c478bd9Sstevel@tonic-gate 		return (TRUE);
2763*7c478bd9Sstevel@tonic-gate 	case OPEN_DELEGATE_READ:
2764*7c478bd9Sstevel@tonic-gate 		return (xdr_nfsace4(xdrs, &objp->delegation.
2765*7c478bd9Sstevel@tonic-gate 					open_delegation4_u.read.permissions));
2766*7c478bd9Sstevel@tonic-gate 	case OPEN_DELEGATE_WRITE:
2767*7c478bd9Sstevel@tonic-gate 		switch (objp->delegation.
2768*7c478bd9Sstevel@tonic-gate 				open_delegation4_u.write.space_limit.limitby) {
2769*7c478bd9Sstevel@tonic-gate 		case NFS_LIMIT_SIZE:
2770*7c478bd9Sstevel@tonic-gate 		case NFS_LIMIT_BLOCKS:
2771*7c478bd9Sstevel@tonic-gate 			break;
2772*7c478bd9Sstevel@tonic-gate 		default:
2773*7c478bd9Sstevel@tonic-gate 			return (FALSE);
2774*7c478bd9Sstevel@tonic-gate 		}
2775*7c478bd9Sstevel@tonic-gate 		return (xdr_nfsace4(xdrs, &objp->delegation.
2776*7c478bd9Sstevel@tonic-gate 				open_delegation4_u.write.permissions));
2777*7c478bd9Sstevel@tonic-gate 	}
2778*7c478bd9Sstevel@tonic-gate 	return (FALSE);
2779*7c478bd9Sstevel@tonic-gate }
2780*7c478bd9Sstevel@tonic-gate 
2781*7c478bd9Sstevel@tonic-gate static bool_t
2782*7c478bd9Sstevel@tonic-gate xdr_OPEN_CONFIRM4res(XDR *xdrs, OPEN_CONFIRM4res *objp)
2783*7c478bd9Sstevel@tonic-gate {
2784*7c478bd9Sstevel@tonic-gate 	if (!xdr_int(xdrs, (int32_t *)&objp->status))
2785*7c478bd9Sstevel@tonic-gate 		return (FALSE);
2786*7c478bd9Sstevel@tonic-gate 	if (objp->status != NFS4_OK)
2787*7c478bd9Sstevel@tonic-gate 		return (TRUE);
2788*7c478bd9Sstevel@tonic-gate 	if (!xdr_u_int(xdrs, &objp->open_stateid.seqid))
2789*7c478bd9Sstevel@tonic-gate 		return (FALSE);
2790*7c478bd9Sstevel@tonic-gate 	return (xdr_opaque(xdrs, objp->open_stateid.other, 12));
2791*7c478bd9Sstevel@tonic-gate }
2792*7c478bd9Sstevel@tonic-gate 
2793*7c478bd9Sstevel@tonic-gate static bool_t
2794*7c478bd9Sstevel@tonic-gate xdr_OPEN_DOWNGRADE4args(XDR *xdrs, OPEN_DOWNGRADE4args *objp)
2795*7c478bd9Sstevel@tonic-gate {
2796*7c478bd9Sstevel@tonic-gate 	if (!xdr_u_int(xdrs, &objp->open_stateid.seqid))
2797*7c478bd9Sstevel@tonic-gate 		return (FALSE);
2798*7c478bd9Sstevel@tonic-gate 	if (!xdr_opaque(xdrs, objp->open_stateid.other, 12))
2799*7c478bd9Sstevel@tonic-gate 		return (FALSE);
2800*7c478bd9Sstevel@tonic-gate 	if (!xdr_u_int(xdrs, &objp->seqid))
2801*7c478bd9Sstevel@tonic-gate 		return (FALSE);
2802*7c478bd9Sstevel@tonic-gate 	if (!xdr_u_int(xdrs, &objp->share_access))
2803*7c478bd9Sstevel@tonic-gate 		return (FALSE);
2804*7c478bd9Sstevel@tonic-gate 	return (xdr_u_int(xdrs, &objp->share_deny));
2805*7c478bd9Sstevel@tonic-gate }
2806*7c478bd9Sstevel@tonic-gate 
2807*7c478bd9Sstevel@tonic-gate static bool_t
2808*7c478bd9Sstevel@tonic-gate xdr_OPEN_DOWNGRADE4res(XDR *xdrs, OPEN_DOWNGRADE4res *objp)
2809*7c478bd9Sstevel@tonic-gate {
2810*7c478bd9Sstevel@tonic-gate 	if (!xdr_int(xdrs, (int32_t *)&objp->status))
2811*7c478bd9Sstevel@tonic-gate 		return (FALSE);
2812*7c478bd9Sstevel@tonic-gate 	if (objp->status != NFS4_OK)
2813*7c478bd9Sstevel@tonic-gate 		return (TRUE);
2814*7c478bd9Sstevel@tonic-gate 	if (!xdr_u_int(xdrs, &objp->open_stateid.seqid))
2815*7c478bd9Sstevel@tonic-gate 		return (FALSE);
2816*7c478bd9Sstevel@tonic-gate 	return (xdr_opaque(xdrs, objp->open_stateid.other, 12));
2817*7c478bd9Sstevel@tonic-gate }
2818*7c478bd9Sstevel@tonic-gate 
2819*7c478bd9Sstevel@tonic-gate static bool_t
2820*7c478bd9Sstevel@tonic-gate xdr_READ4args(XDR *xdrs, READ4args *objp)
2821*7c478bd9Sstevel@tonic-gate {
2822*7c478bd9Sstevel@tonic-gate 	if (!xdr_u_int(xdrs, &objp->stateid.seqid))
2823*7c478bd9Sstevel@tonic-gate 		return (FALSE);
2824*7c478bd9Sstevel@tonic-gate 	if (!xdr_opaque(xdrs, objp->stateid.other, 12))
2825*7c478bd9Sstevel@tonic-gate 		return (FALSE);
2826*7c478bd9Sstevel@tonic-gate 	if (!xdr_u_longlong_t(xdrs, (u_longlong_t *)&objp->offset))
2827*7c478bd9Sstevel@tonic-gate 		return (FALSE);
2828*7c478bd9Sstevel@tonic-gate 	return (xdr_u_int(xdrs, &objp->count));
2829*7c478bd9Sstevel@tonic-gate }
2830*7c478bd9Sstevel@tonic-gate 
2831*7c478bd9Sstevel@tonic-gate static bool_t
2832*7c478bd9Sstevel@tonic-gate xdr_READ4res(XDR *xdrs, READ4res *objp)
2833*7c478bd9Sstevel@tonic-gate {
2834*7c478bd9Sstevel@tonic-gate 	int i, rndup;
2835*7c478bd9Sstevel@tonic-gate 	mblk_t *mp;
2836*7c478bd9Sstevel@tonic-gate 
2837*7c478bd9Sstevel@tonic-gate 	if (xdrs->x_op == XDR_DECODE)
2838*7c478bd9Sstevel@tonic-gate 		return (FALSE);
2839*7c478bd9Sstevel@tonic-gate 
2840*7c478bd9Sstevel@tonic-gate 	if (xdrs->x_op == XDR_FREE) {
2841*7c478bd9Sstevel@tonic-gate 		/*
2842*7c478bd9Sstevel@tonic-gate 		 * Optimized free case
2843*7c478bd9Sstevel@tonic-gate 		 */
2844*7c478bd9Sstevel@tonic-gate 		if (objp->status != NFS4_OK)
2845*7c478bd9Sstevel@tonic-gate 			return (TRUE);
2846*7c478bd9Sstevel@tonic-gate 		if (objp->data_val != NULL)
2847*7c478bd9Sstevel@tonic-gate 			kmem_free(objp->data_val, objp->data_len);
2848*7c478bd9Sstevel@tonic-gate 		return (TRUE);
2849*7c478bd9Sstevel@tonic-gate 	}
2850*7c478bd9Sstevel@tonic-gate 
2851*7c478bd9Sstevel@tonic-gate 	/* on with ENCODE paths */
2852*7c478bd9Sstevel@tonic-gate 	if (!XDR_PUTINT32(xdrs, (int32_t *)&objp->status))
2853*7c478bd9Sstevel@tonic-gate 		return (FALSE);
2854*7c478bd9Sstevel@tonic-gate 	if (objp->status != NFS4_OK)
2855*7c478bd9Sstevel@tonic-gate 		return (TRUE);
2856*7c478bd9Sstevel@tonic-gate 
2857*7c478bd9Sstevel@tonic-gate 	if (!XDR_PUTINT32(xdrs, &objp->eof))
2858*7c478bd9Sstevel@tonic-gate 		return (FALSE);
2859*7c478bd9Sstevel@tonic-gate 
2860*7c478bd9Sstevel@tonic-gate 	mp = objp->mblk;
2861*7c478bd9Sstevel@tonic-gate 	if (mp != NULL && xdrs->x_ops == &xdrmblk_ops) {
2862*7c478bd9Sstevel@tonic-gate 		mp->b_wptr += objp->data_len;
2863*7c478bd9Sstevel@tonic-gate 		rndup = BYTES_PER_XDR_UNIT -
2864*7c478bd9Sstevel@tonic-gate 			(objp->data_len % BYTES_PER_XDR_UNIT);
2865*7c478bd9Sstevel@tonic-gate 		if (rndup != BYTES_PER_XDR_UNIT)
2866*7c478bd9Sstevel@tonic-gate 			for (i = 0; i < rndup; i++)
2867*7c478bd9Sstevel@tonic-gate 				*mp->b_wptr++ = '\0';
2868*7c478bd9Sstevel@tonic-gate 		if (xdrmblk_putmblk(xdrs, mp, objp->data_len) == TRUE) {
2869*7c478bd9Sstevel@tonic-gate 			objp->mblk = NULL;
2870*7c478bd9Sstevel@tonic-gate 			return (TRUE);
2871*7c478bd9Sstevel@tonic-gate 		}
2872*7c478bd9Sstevel@tonic-gate 	}
2873*7c478bd9Sstevel@tonic-gate 	return (xdr_bytes(xdrs, (char **)&objp->data_val,
2874*7c478bd9Sstevel@tonic-gate 			(uint_t *)&objp->data_len,
2875*7c478bd9Sstevel@tonic-gate 			objp->data_len));
2876*7c478bd9Sstevel@tonic-gate }
2877*7c478bd9Sstevel@tonic-gate 
2878*7c478bd9Sstevel@tonic-gate static bool_t
2879*7c478bd9Sstevel@tonic-gate xdr_READ4res_clnt(XDR *xdrs, READ4res *objp, READ4args *aobjp)
2880*7c478bd9Sstevel@tonic-gate {
2881*7c478bd9Sstevel@tonic-gate 	mblk_t *mp;
2882*7c478bd9Sstevel@tonic-gate 	size_t n;
2883*7c478bd9Sstevel@tonic-gate 	int error;
2884*7c478bd9Sstevel@tonic-gate 	uint_t size = aobjp->res_maxsize;
2885*7c478bd9Sstevel@tonic-gate 
2886*7c478bd9Sstevel@tonic-gate 	if (xdrs->x_op == XDR_ENCODE)
2887*7c478bd9Sstevel@tonic-gate 		return (FALSE);
2888*7c478bd9Sstevel@tonic-gate 
2889*7c478bd9Sstevel@tonic-gate 	if (xdrs->x_op == XDR_FREE) {
2890*7c478bd9Sstevel@tonic-gate 		/*
2891*7c478bd9Sstevel@tonic-gate 		 * Optimized free case
2892*7c478bd9Sstevel@tonic-gate 		 */
2893*7c478bd9Sstevel@tonic-gate 		if (objp->status != NFS4_OK)
2894*7c478bd9Sstevel@tonic-gate 			return (TRUE);
2895*7c478bd9Sstevel@tonic-gate 		if (objp->data_val != NULL)
2896*7c478bd9Sstevel@tonic-gate 			kmem_free(objp->data_val, objp->data_len);
2897*7c478bd9Sstevel@tonic-gate 		return (TRUE);
2898*7c478bd9Sstevel@tonic-gate 	}
2899*7c478bd9Sstevel@tonic-gate 
2900*7c478bd9Sstevel@tonic-gate 	if (!XDR_GETINT32(xdrs, (int32_t *)&objp->status))
2901*7c478bd9Sstevel@tonic-gate 		return (FALSE);
2902*7c478bd9Sstevel@tonic-gate 	if (objp->status != NFS4_OK)
2903*7c478bd9Sstevel@tonic-gate 		return (TRUE);
2904*7c478bd9Sstevel@tonic-gate 
2905*7c478bd9Sstevel@tonic-gate 	if (!XDR_GETINT32(xdrs, &objp->eof))
2906*7c478bd9Sstevel@tonic-gate 		return (FALSE);
2907*7c478bd9Sstevel@tonic-gate 
2908*7c478bd9Sstevel@tonic-gate 
2909*7c478bd9Sstevel@tonic-gate 	/*
2910*7c478bd9Sstevel@tonic-gate 	 * This is a special case such that the caller is providing a
2911*7c478bd9Sstevel@tonic-gate 	 * uio as a guide to eventual data location; this is used for
2912*7c478bd9Sstevel@tonic-gate 	 * handling DIRECTIO reads.
2913*7c478bd9Sstevel@tonic-gate 	 */
2914*7c478bd9Sstevel@tonic-gate 	if (aobjp->res_uiop != NULL) {
2915*7c478bd9Sstevel@tonic-gate 		struct uio *uiop = aobjp->res_uiop;
2916*7c478bd9Sstevel@tonic-gate 		int32_t *ptr;
2917*7c478bd9Sstevel@tonic-gate 
2918*7c478bd9Sstevel@tonic-gate 		if (xdrs->x_ops == &xdrmblk_ops) {
2919*7c478bd9Sstevel@tonic-gate 			if (!xdrmblk_getmblk(xdrs, &mp, &objp->data_len))
2920*7c478bd9Sstevel@tonic-gate 				return (FALSE);
2921*7c478bd9Sstevel@tonic-gate 
2922*7c478bd9Sstevel@tonic-gate 			if (objp->data_len == 0)
2923*7c478bd9Sstevel@tonic-gate 				return (TRUE);
2924*7c478bd9Sstevel@tonic-gate 
2925*7c478bd9Sstevel@tonic-gate 			if (objp->data_len > size)
2926*7c478bd9Sstevel@tonic-gate 				return (FALSE);
2927*7c478bd9Sstevel@tonic-gate 
2928*7c478bd9Sstevel@tonic-gate 			size = objp->data_len;
2929*7c478bd9Sstevel@tonic-gate 			do {
2930*7c478bd9Sstevel@tonic-gate 				n = MIN(size, mp->b_wptr - mp->b_rptr);
2931*7c478bd9Sstevel@tonic-gate 				if ((n = MIN(uiop->uio_resid, n)) != 0) {
2932*7c478bd9Sstevel@tonic-gate 
2933*7c478bd9Sstevel@tonic-gate 					error =	uiomove((char *)mp->b_rptr, n,
2934*7c478bd9Sstevel@tonic-gate 							UIO_READ, uiop);
2935*7c478bd9Sstevel@tonic-gate 					if (error)
2936*7c478bd9Sstevel@tonic-gate 						return (FALSE);
2937*7c478bd9Sstevel@tonic-gate 					mp->b_rptr += n;
2938*7c478bd9Sstevel@tonic-gate 					size -= n;
2939*7c478bd9Sstevel@tonic-gate 				}
2940*7c478bd9Sstevel@tonic-gate 
2941*7c478bd9Sstevel@tonic-gate 				while (mp && (mp->b_rptr >= mp->b_wptr))
2942*7c478bd9Sstevel@tonic-gate 					mp = mp->b_cont;
2943*7c478bd9Sstevel@tonic-gate 			} while (mp && size > 0 && uiop->uio_resid > 0);
2944*7c478bd9Sstevel@tonic-gate 
2945*7c478bd9Sstevel@tonic-gate 			return (TRUE);
2946*7c478bd9Sstevel@tonic-gate 		}
2947*7c478bd9Sstevel@tonic-gate 
2948*7c478bd9Sstevel@tonic-gate 		/*
2949*7c478bd9Sstevel@tonic-gate 		 * This isn't an xdrmblk stream.   Handle the likely
2950*7c478bd9Sstevel@tonic-gate 		 * case that it can be inlined (ex. xdrmem).
2951*7c478bd9Sstevel@tonic-gate 		 */
2952*7c478bd9Sstevel@tonic-gate 		if (!XDR_GETINT32(xdrs, (int32_t *)&objp->data_len))
2953*7c478bd9Sstevel@tonic-gate 			return (FALSE);
2954*7c478bd9Sstevel@tonic-gate 
2955*7c478bd9Sstevel@tonic-gate 		if (objp->data_len == 0)
2956*7c478bd9Sstevel@tonic-gate 			return (TRUE);
2957*7c478bd9Sstevel@tonic-gate 
2958*7c478bd9Sstevel@tonic-gate 		if (objp->data_len > size)
2959*7c478bd9Sstevel@tonic-gate 			return (FALSE);
2960*7c478bd9Sstevel@tonic-gate 
2961*7c478bd9Sstevel@tonic-gate 		size = (int)objp->data_len;
2962*7c478bd9Sstevel@tonic-gate 		if ((ptr = XDR_INLINE(xdrs, size)) != NULL)
2963*7c478bd9Sstevel@tonic-gate 			return (uiomove(ptr, size, UIO_READ, uiop) ?
2964*7c478bd9Sstevel@tonic-gate 				FALSE : TRUE);
2965*7c478bd9Sstevel@tonic-gate 
2966*7c478bd9Sstevel@tonic-gate 		/*
2967*7c478bd9Sstevel@tonic-gate 		 * Handle some other (unlikely) stream type that will
2968*7c478bd9Sstevel@tonic-gate 		 * need a copy.
2969*7c478bd9Sstevel@tonic-gate 		 */
2970*7c478bd9Sstevel@tonic-gate 		if ((ptr = kmem_alloc(size, KM_NOSLEEP)) == NULL)
2971*7c478bd9Sstevel@tonic-gate 			return (FALSE);
2972*7c478bd9Sstevel@tonic-gate 
2973*7c478bd9Sstevel@tonic-gate 		if (!XDR_GETBYTES(xdrs, (caddr_t)ptr, size)) {
2974*7c478bd9Sstevel@tonic-gate 			kmem_free(ptr, size);
2975*7c478bd9Sstevel@tonic-gate 			return (FALSE);
2976*7c478bd9Sstevel@tonic-gate 		}
2977*7c478bd9Sstevel@tonic-gate 		error = uiomove(ptr, size, UIO_READ, uiop);
2978*7c478bd9Sstevel@tonic-gate 		kmem_free(ptr, size);
2979*7c478bd9Sstevel@tonic-gate 
2980*7c478bd9Sstevel@tonic-gate 		return (error ? FALSE : TRUE);
2981*7c478bd9Sstevel@tonic-gate 	}
2982*7c478bd9Sstevel@tonic-gate 
2983*7c478bd9Sstevel@tonic-gate 	/*
2984*7c478bd9Sstevel@tonic-gate 	 * Check for the other special case of the caller providing
2985*7c478bd9Sstevel@tonic-gate 	 * the target area for the data.
2986*7c478bd9Sstevel@tonic-gate 	 */
2987*7c478bd9Sstevel@tonic-gate 	if (aobjp->res_data_val_alt)
2988*7c478bd9Sstevel@tonic-gate 		return (xdr_bytes(xdrs, (char **)&aobjp->res_data_val_alt,
2989*7c478bd9Sstevel@tonic-gate 				(uint_t *)&objp->data_len,
2990*7c478bd9Sstevel@tonic-gate 				aobjp->res_maxsize));
2991*7c478bd9Sstevel@tonic-gate 
2992*7c478bd9Sstevel@tonic-gate 	/* caller didn't set things up right if we got this far */
2993*7c478bd9Sstevel@tonic-gate 	return (FALSE);
2994*7c478bd9Sstevel@tonic-gate }
2995*7c478bd9Sstevel@tonic-gate 
2996*7c478bd9Sstevel@tonic-gate static bool_t
2997*7c478bd9Sstevel@tonic-gate xdr_READDIR4args(XDR *xdrs, READDIR4args *objp)
2998*7c478bd9Sstevel@tonic-gate {
2999*7c478bd9Sstevel@tonic-gate 	if (!xdr_u_longlong_t(xdrs, (u_longlong_t *)&objp->cookie))
3000*7c478bd9Sstevel@tonic-gate 		return (FALSE);
3001*7c478bd9Sstevel@tonic-gate 	if (!xdr_u_longlong_t(xdrs, (u_longlong_t *)&objp->cookieverf))
3002*7c478bd9Sstevel@tonic-gate 		return (FALSE);
3003*7c478bd9Sstevel@tonic-gate 	if (!xdr_u_int(xdrs, &objp->dircount))
3004*7c478bd9Sstevel@tonic-gate 		return (FALSE);
3005*7c478bd9Sstevel@tonic-gate 	if (!xdr_u_int(xdrs, &objp->maxcount))
3006*7c478bd9Sstevel@tonic-gate 		return (FALSE);
3007*7c478bd9Sstevel@tonic-gate 	return (xdr_bitmap4(xdrs, &objp->attr_request));
3008*7c478bd9Sstevel@tonic-gate }
3009*7c478bd9Sstevel@tonic-gate 
3010*7c478bd9Sstevel@tonic-gate /* ARGSUSED */
3011*7c478bd9Sstevel@tonic-gate static bool_t
3012*7c478bd9Sstevel@tonic-gate xdrmblk_putmblk_rd(XDR *xdrs, mblk_t *m)
3013*7c478bd9Sstevel@tonic-gate {
3014*7c478bd9Sstevel@tonic-gate 	if (((m->b_wptr - m->b_rptr) % BYTES_PER_XDR_UNIT) != 0)
3015*7c478bd9Sstevel@tonic-gate 		return (FALSE);
3016*7c478bd9Sstevel@tonic-gate 
3017*7c478bd9Sstevel@tonic-gate 	/* LINTED pointer alignment */
3018*7c478bd9Sstevel@tonic-gate 	((mblk_t *)xdrs->x_base)->b_cont = m;
3019*7c478bd9Sstevel@tonic-gate 	xdrs->x_base = (caddr_t)m;
3020*7c478bd9Sstevel@tonic-gate 	xdrs->x_handy = 0;
3021*7c478bd9Sstevel@tonic-gate 	return (TRUE);
3022*7c478bd9Sstevel@tonic-gate }
3023*7c478bd9Sstevel@tonic-gate 
3024*7c478bd9Sstevel@tonic-gate bool_t
3025*7c478bd9Sstevel@tonic-gate xdr_READDIR4res(XDR *xdrs, READDIR4res *objp)
3026*7c478bd9Sstevel@tonic-gate {
3027*7c478bd9Sstevel@tonic-gate 	mblk_t *mp = objp->mblk;
3028*7c478bd9Sstevel@tonic-gate 	bool_t ret_val;
3029*7c478bd9Sstevel@tonic-gate 	uint_t flags = 0;
3030*7c478bd9Sstevel@tonic-gate 
3031*7c478bd9Sstevel@tonic-gate 	ASSERT(xdrs->x_op == XDR_ENCODE);
3032*7c478bd9Sstevel@tonic-gate 
3033*7c478bd9Sstevel@tonic-gate 	if (!xdr_int(xdrs, (int32_t *)&objp->status))
3034*7c478bd9Sstevel@tonic-gate 		return (FALSE);
3035*7c478bd9Sstevel@tonic-gate 	if (objp->status != NFS4_OK)
3036*7c478bd9Sstevel@tonic-gate 		return (TRUE);
3037*7c478bd9Sstevel@tonic-gate 	if (mp == NULL)
3038*7c478bd9Sstevel@tonic-gate 		return (FALSE);
3039*7c478bd9Sstevel@tonic-gate 
3040*7c478bd9Sstevel@tonic-gate 	if (xdrs->x_ops == &xdrmblk_ops) {
3041*7c478bd9Sstevel@tonic-gate 		if (xdrmblk_putmblk_rd(xdrs, mp)
3042*7c478bd9Sstevel@tonic-gate 				    == TRUE) {
3043*7c478bd9Sstevel@tonic-gate 			/* mblk successfully inserted into outgoing chain */
3044*7c478bd9Sstevel@tonic-gate 			objp->mblk = NULL;
3045*7c478bd9Sstevel@tonic-gate 			return (TRUE);
3046*7c478bd9Sstevel@tonic-gate 		}
3047*7c478bd9Sstevel@tonic-gate 	}
3048*7c478bd9Sstevel@tonic-gate 
3049*7c478bd9Sstevel@tonic-gate 	ASSERT(mp->b_cont == NULL);
3050*7c478bd9Sstevel@tonic-gate 
3051*7c478bd9Sstevel@tonic-gate 	/*
3052*7c478bd9Sstevel@tonic-gate 	 * If running over RDMA, the pre-encoded m_blk needs to be moved
3053*7c478bd9Sstevel@tonic-gate 	 * without being chunked.
3054*7c478bd9Sstevel@tonic-gate 	 * Check if chunking is disabled for this xdr stream. If not disable
3055*7c478bd9Sstevel@tonic-gate 	 * it for this op and then enable it back on.
3056*7c478bd9Sstevel@tonic-gate 	 */
3057*7c478bd9Sstevel@tonic-gate 	XDR_CONTROL(xdrs, XDR_RDMAGET, &flags);
3058*7c478bd9Sstevel@tonic-gate 	if (flags & RDMA_NOCHUNK)
3059*7c478bd9Sstevel@tonic-gate 		return (xdr_opaque(xdrs, (char *)mp->b_rptr, objp->data_len));
3060*7c478bd9Sstevel@tonic-gate 
3061*7c478bd9Sstevel@tonic-gate 	flags |= RDMA_NOCHUNK;
3062*7c478bd9Sstevel@tonic-gate 	(void) XDR_CONTROL(xdrs, XDR_RDMASET, &flags);
3063*7c478bd9Sstevel@tonic-gate 	ret_val = xdr_opaque(xdrs, (char *)mp->b_rptr, objp->data_len);
3064*7c478bd9Sstevel@tonic-gate 	flags &= ~RDMA_NOCHUNK;
3065*7c478bd9Sstevel@tonic-gate 	(void) XDR_CONTROL(xdrs, XDR_RDMASET, &flags);
3066*7c478bd9Sstevel@tonic-gate 	return (ret_val);
3067*7c478bd9Sstevel@tonic-gate }
3068*7c478bd9Sstevel@tonic-gate 
3069*7c478bd9Sstevel@tonic-gate static bool_t
3070*7c478bd9Sstevel@tonic-gate xdr_READLINK4res(XDR *xdrs, READLINK4res *objp)
3071*7c478bd9Sstevel@tonic-gate {
3072*7c478bd9Sstevel@tonic-gate 	if (xdrs->x_op != XDR_FREE) {
3073*7c478bd9Sstevel@tonic-gate 		if (!xdr_int(xdrs, (int32_t *)&objp->status))
3074*7c478bd9Sstevel@tonic-gate 			return (FALSE);
3075*7c478bd9Sstevel@tonic-gate 		if (objp->status != NFS4_OK)
3076*7c478bd9Sstevel@tonic-gate 			return (TRUE);
3077*7c478bd9Sstevel@tonic-gate 		return (xdr_bytes(xdrs, (char **)&objp->link.utf8string_val,
3078*7c478bd9Sstevel@tonic-gate 			(uint_t *)&objp->link.utf8string_len,
3079*7c478bd9Sstevel@tonic-gate 			NFS4_MAX_UTF8STRING));
3080*7c478bd9Sstevel@tonic-gate 	}
3081*7c478bd9Sstevel@tonic-gate 
3082*7c478bd9Sstevel@tonic-gate 	/*
3083*7c478bd9Sstevel@tonic-gate 	 * Optimized free case
3084*7c478bd9Sstevel@tonic-gate 	 */
3085*7c478bd9Sstevel@tonic-gate 	if (objp->status != NFS4_OK)
3086*7c478bd9Sstevel@tonic-gate 		return (TRUE);
3087*7c478bd9Sstevel@tonic-gate 	if (objp->link.utf8string_val != NULL)
3088*7c478bd9Sstevel@tonic-gate 		kmem_free(objp->link.utf8string_val, objp->link.utf8string_len);
3089*7c478bd9Sstevel@tonic-gate 	return (TRUE);
3090*7c478bd9Sstevel@tonic-gate }
3091*7c478bd9Sstevel@tonic-gate 
3092*7c478bd9Sstevel@tonic-gate static bool_t
3093*7c478bd9Sstevel@tonic-gate xdr_REMOVE4res(XDR *xdrs, REMOVE4res *objp)
3094*7c478bd9Sstevel@tonic-gate {
3095*7c478bd9Sstevel@tonic-gate 	if (!xdr_int(xdrs, (int32_t *)&objp->status))
3096*7c478bd9Sstevel@tonic-gate 		return (FALSE);
3097*7c478bd9Sstevel@tonic-gate 	if (objp->status != NFS4_OK)
3098*7c478bd9Sstevel@tonic-gate 		return (TRUE);
3099*7c478bd9Sstevel@tonic-gate 	if (!xdr_bool(xdrs, &objp->cinfo.atomic))
3100*7c478bd9Sstevel@tonic-gate 		return (FALSE);
3101*7c478bd9Sstevel@tonic-gate 	if (!xdr_u_longlong_t(xdrs, (u_longlong_t *)&objp->cinfo.before))
3102*7c478bd9Sstevel@tonic-gate 		return (FALSE);
3103*7c478bd9Sstevel@tonic-gate 	return (xdr_u_longlong_t(xdrs,
3104*7c478bd9Sstevel@tonic-gate 		(u_longlong_t *)&objp->cinfo.after));
3105*7c478bd9Sstevel@tonic-gate }
3106*7c478bd9Sstevel@tonic-gate 
3107*7c478bd9Sstevel@tonic-gate static bool_t
3108*7c478bd9Sstevel@tonic-gate xdr_RENAME4res(XDR *xdrs, RENAME4res *objp)
3109*7c478bd9Sstevel@tonic-gate {
3110*7c478bd9Sstevel@tonic-gate 	if (!xdr_int(xdrs, (int32_t *)&objp->status))
3111*7c478bd9Sstevel@tonic-gate 		return (FALSE);
3112*7c478bd9Sstevel@tonic-gate 	if (objp->status != NFS4_OK)
3113*7c478bd9Sstevel@tonic-gate 		return (TRUE);
3114*7c478bd9Sstevel@tonic-gate 	if (!xdr_bool(xdrs, &objp->source_cinfo.atomic))
3115*7c478bd9Sstevel@tonic-gate 		return (FALSE);
3116*7c478bd9Sstevel@tonic-gate 	if (!xdr_u_longlong_t(xdrs,
3117*7c478bd9Sstevel@tonic-gate 	    (u_longlong_t *)&objp->source_cinfo.before))
3118*7c478bd9Sstevel@tonic-gate 		return (FALSE);
3119*7c478bd9Sstevel@tonic-gate 	if (!xdr_u_longlong_t(xdrs,
3120*7c478bd9Sstevel@tonic-gate 	    (u_longlong_t *)&objp->source_cinfo.after))
3121*7c478bd9Sstevel@tonic-gate 		return (FALSE);
3122*7c478bd9Sstevel@tonic-gate 	if (!xdr_bool(xdrs, &objp->target_cinfo.atomic))
3123*7c478bd9Sstevel@tonic-gate 		return (FALSE);
3124*7c478bd9Sstevel@tonic-gate 	if (!xdr_u_longlong_t(xdrs,
3125*7c478bd9Sstevel@tonic-gate 	    (u_longlong_t *)&objp->target_cinfo.before))
3126*7c478bd9Sstevel@tonic-gate 		return (FALSE);
3127*7c478bd9Sstevel@tonic-gate 	return (xdr_u_longlong_t(xdrs,
3128*7c478bd9Sstevel@tonic-gate 		(u_longlong_t *)&objp->target_cinfo.after));
3129*7c478bd9Sstevel@tonic-gate }
3130*7c478bd9Sstevel@tonic-gate 
3131*7c478bd9Sstevel@tonic-gate static bool_t
3132*7c478bd9Sstevel@tonic-gate xdr_secinfo4(XDR *xdrs, secinfo4 *objp)
3133*7c478bd9Sstevel@tonic-gate {
3134*7c478bd9Sstevel@tonic-gate 	if (xdrs->x_op != XDR_FREE) {
3135*7c478bd9Sstevel@tonic-gate 		if (!xdr_u_int(xdrs, &objp->flavor))
3136*7c478bd9Sstevel@tonic-gate 			return (FALSE);
3137*7c478bd9Sstevel@tonic-gate 		if (objp->flavor != RPCSEC_GSS)
3138*7c478bd9Sstevel@tonic-gate 			return (TRUE);
3139*7c478bd9Sstevel@tonic-gate 		if (!xdr_bytes(xdrs,
3140*7c478bd9Sstevel@tonic-gate 			    (char **)&objp->flavor_info.oid.sec_oid4_val,
3141*7c478bd9Sstevel@tonic-gate 			    (uint_t *)&objp->flavor_info.oid.sec_oid4_len,
3142*7c478bd9Sstevel@tonic-gate 			    NFS4_MAX_SECOID4))
3143*7c478bd9Sstevel@tonic-gate 			return (FALSE);
3144*7c478bd9Sstevel@tonic-gate 		if (!xdr_u_int(xdrs, &objp->flavor_info.qop))
3145*7c478bd9Sstevel@tonic-gate 			return (FALSE);
3146*7c478bd9Sstevel@tonic-gate 		return (xdr_int(xdrs, (int *)&objp->flavor_info.service));
3147*7c478bd9Sstevel@tonic-gate 	}
3148*7c478bd9Sstevel@tonic-gate 
3149*7c478bd9Sstevel@tonic-gate 	/*
3150*7c478bd9Sstevel@tonic-gate 	 * Optimized free path
3151*7c478bd9Sstevel@tonic-gate 	 */
3152*7c478bd9Sstevel@tonic-gate 	if (objp->flavor != RPCSEC_GSS)
3153*7c478bd9Sstevel@tonic-gate 		return (TRUE);
3154*7c478bd9Sstevel@tonic-gate 
3155*7c478bd9Sstevel@tonic-gate 	if (objp->flavor_info.oid.sec_oid4_val != NULL)
3156*7c478bd9Sstevel@tonic-gate 		kmem_free(objp->flavor_info.oid.sec_oid4_val,
3157*7c478bd9Sstevel@tonic-gate 			objp->flavor_info.oid.sec_oid4_len);
3158*7c478bd9Sstevel@tonic-gate 	return (TRUE);
3159*7c478bd9Sstevel@tonic-gate }
3160*7c478bd9Sstevel@tonic-gate 
3161*7c478bd9Sstevel@tonic-gate static bool_t
3162*7c478bd9Sstevel@tonic-gate xdr_SETCLIENTID4args(XDR *xdrs, SETCLIENTID4args *objp)
3163*7c478bd9Sstevel@tonic-gate {
3164*7c478bd9Sstevel@tonic-gate 	if (xdrs->x_op != XDR_FREE) {
3165*7c478bd9Sstevel@tonic-gate 		if (!xdr_u_longlong_t(xdrs,
3166*7c478bd9Sstevel@tonic-gate 					(u_longlong_t *)&objp->client.verifier))
3167*7c478bd9Sstevel@tonic-gate 			return (FALSE);
3168*7c478bd9Sstevel@tonic-gate 		if (!xdr_bytes(xdrs, (char **)&objp->client.id_val,
3169*7c478bd9Sstevel@tonic-gate 			    (uint_t *)&objp->client.id_len, NFS4_OPAQUE_LIMIT))
3170*7c478bd9Sstevel@tonic-gate 			return (FALSE);
3171*7c478bd9Sstevel@tonic-gate 		if (!xdr_u_int(xdrs, &objp->callback.cb_program))
3172*7c478bd9Sstevel@tonic-gate 			return (FALSE);
3173*7c478bd9Sstevel@tonic-gate 		if (!xdr_string(xdrs, &objp->callback.cb_location.r_netid,
3174*7c478bd9Sstevel@tonic-gate 						NFS4_OPAQUE_LIMIT))
3175*7c478bd9Sstevel@tonic-gate 			return (FALSE);
3176*7c478bd9Sstevel@tonic-gate 		if (!xdr_string(xdrs, &objp->callback.cb_location.r_addr,
3177*7c478bd9Sstevel@tonic-gate 						NFS4_OPAQUE_LIMIT))
3178*7c478bd9Sstevel@tonic-gate 			return (FALSE);
3179*7c478bd9Sstevel@tonic-gate 		return (xdr_u_int(xdrs, &objp->callback_ident));
3180*7c478bd9Sstevel@tonic-gate 	}
3181*7c478bd9Sstevel@tonic-gate 
3182*7c478bd9Sstevel@tonic-gate 	/*
3183*7c478bd9Sstevel@tonic-gate 	 * Optimized free case
3184*7c478bd9Sstevel@tonic-gate 	 */
3185*7c478bd9Sstevel@tonic-gate 	if (objp->client.id_val != NULL)
3186*7c478bd9Sstevel@tonic-gate 		kmem_free(objp->client.id_val, objp->client.id_len);
3187*7c478bd9Sstevel@tonic-gate 	(void) xdr_string(xdrs, &objp->callback.cb_location.r_netid,
3188*7c478bd9Sstevel@tonic-gate 							NFS4_OPAQUE_LIMIT);
3189*7c478bd9Sstevel@tonic-gate 	return (xdr_string(xdrs, &objp->callback.cb_location.r_addr,
3190*7c478bd9Sstevel@tonic-gate 							NFS4_OPAQUE_LIMIT));
3191*7c478bd9Sstevel@tonic-gate }
3192*7c478bd9Sstevel@tonic-gate 
3193*7c478bd9Sstevel@tonic-gate static bool_t
3194*7c478bd9Sstevel@tonic-gate xdr_SETCLIENTID4res(XDR *xdrs, SETCLIENTID4res *objp)
3195*7c478bd9Sstevel@tonic-gate {
3196*7c478bd9Sstevel@tonic-gate 	if (xdrs->x_op != XDR_FREE) {
3197*7c478bd9Sstevel@tonic-gate 		if (!xdr_int(xdrs, (int32_t *)&objp->status))
3198*7c478bd9Sstevel@tonic-gate 			return (FALSE);
3199*7c478bd9Sstevel@tonic-gate 		switch (objp->status) {
3200*7c478bd9Sstevel@tonic-gate 		case NFS4_OK:
3201*7c478bd9Sstevel@tonic-gate 			if (!xdr_u_longlong_t(xdrs,
3202*7c478bd9Sstevel@tonic-gate 			    (u_longlong_t *)&objp->SETCLIENTID4res_u.resok4.
3203*7c478bd9Sstevel@tonic-gate 			    clientid))
3204*7c478bd9Sstevel@tonic-gate 				return (FALSE);
3205*7c478bd9Sstevel@tonic-gate 			return (xdr_u_longlong_t(xdrs,
3206*7c478bd9Sstevel@tonic-gate 			    (u_longlong_t *)&objp->SETCLIENTID4res_u.
3207*7c478bd9Sstevel@tonic-gate 						resok4.setclientid_confirm));
3208*7c478bd9Sstevel@tonic-gate 		case NFS4ERR_CLID_INUSE:
3209*7c478bd9Sstevel@tonic-gate 			if (!xdr_string(xdrs,
3210*7c478bd9Sstevel@tonic-gate 				    &objp->SETCLIENTID4res_u.client_using.
3211*7c478bd9Sstevel@tonic-gate 				    r_netid, NFS4_OPAQUE_LIMIT))
3212*7c478bd9Sstevel@tonic-gate 				return (FALSE);
3213*7c478bd9Sstevel@tonic-gate 			return (xdr_string(xdrs,
3214*7c478bd9Sstevel@tonic-gate 				    &objp->SETCLIENTID4res_u.client_using.
3215*7c478bd9Sstevel@tonic-gate 				    r_addr, NFS4_OPAQUE_LIMIT));
3216*7c478bd9Sstevel@tonic-gate 		}
3217*7c478bd9Sstevel@tonic-gate 		return (TRUE);
3218*7c478bd9Sstevel@tonic-gate 	}
3219*7c478bd9Sstevel@tonic-gate 
3220*7c478bd9Sstevel@tonic-gate 	/*
3221*7c478bd9Sstevel@tonic-gate 	 * Optimized free case
3222*7c478bd9Sstevel@tonic-gate 	 */
3223*7c478bd9Sstevel@tonic-gate 	if (objp->status != NFS4ERR_CLID_INUSE)
3224*7c478bd9Sstevel@tonic-gate 		return (TRUE);
3225*7c478bd9Sstevel@tonic-gate 
3226*7c478bd9Sstevel@tonic-gate 	if (!xdr_string(xdrs, &objp->SETCLIENTID4res_u.client_using.r_netid,
3227*7c478bd9Sstevel@tonic-gate 							NFS4_OPAQUE_LIMIT))
3228*7c478bd9Sstevel@tonic-gate 		return (FALSE);
3229*7c478bd9Sstevel@tonic-gate 	return (xdr_string(xdrs, &objp->SETCLIENTID4res_u.client_using.r_addr,
3230*7c478bd9Sstevel@tonic-gate 							NFS4_OPAQUE_LIMIT));
3231*7c478bd9Sstevel@tonic-gate }
3232*7c478bd9Sstevel@tonic-gate 
3233*7c478bd9Sstevel@tonic-gate static bool_t
3234*7c478bd9Sstevel@tonic-gate xdr_WRITE4args(XDR *xdrs, WRITE4args *objp)
3235*7c478bd9Sstevel@tonic-gate {
3236*7c478bd9Sstevel@tonic-gate 	if (xdrs->x_op != XDR_FREE) {
3237*7c478bd9Sstevel@tonic-gate 		if (!xdr_u_int(xdrs, &objp->stateid.seqid))
3238*7c478bd9Sstevel@tonic-gate 			return (FALSE);
3239*7c478bd9Sstevel@tonic-gate 		if (!xdr_opaque(xdrs, objp->stateid.other, 12))
3240*7c478bd9Sstevel@tonic-gate 			return (FALSE);
3241*7c478bd9Sstevel@tonic-gate 		if (!xdr_u_longlong_t(xdrs, (u_longlong_t *)&objp->offset))
3242*7c478bd9Sstevel@tonic-gate 			return (FALSE);
3243*7c478bd9Sstevel@tonic-gate 		if (!xdr_int(xdrs, (int *)&objp->stable))
3244*7c478bd9Sstevel@tonic-gate 			return (FALSE);
3245*7c478bd9Sstevel@tonic-gate 		if (xdrs->x_op == XDR_DECODE) {
3246*7c478bd9Sstevel@tonic-gate 			if (xdrs->x_ops == &xdrmblk_ops) {
3247*7c478bd9Sstevel@tonic-gate 				objp->data_val = NULL;
3248*7c478bd9Sstevel@tonic-gate 				return (xdrmblk_getmblk(xdrs, &objp->mblk,
3249*7c478bd9Sstevel@tonic-gate 							&objp->data_len));
3250*7c478bd9Sstevel@tonic-gate 			}
3251*7c478bd9Sstevel@tonic-gate 			/* Else fall thru for the xdr_bytes(). */
3252*7c478bd9Sstevel@tonic-gate 			objp->mblk = NULL;
3253*7c478bd9Sstevel@tonic-gate 		}
3254*7c478bd9Sstevel@tonic-gate 		return (xdr_bytes(xdrs, (char **)&objp->data_val,
3255*7c478bd9Sstevel@tonic-gate 				(uint_t *)&objp->data_len, NFS4_DATA_LIMIT));
3256*7c478bd9Sstevel@tonic-gate 	}
3257*7c478bd9Sstevel@tonic-gate 
3258*7c478bd9Sstevel@tonic-gate 	/*
3259*7c478bd9Sstevel@tonic-gate 	 * Optimized free case
3260*7c478bd9Sstevel@tonic-gate 	 */
3261*7c478bd9Sstevel@tonic-gate 	if (objp->data_val != NULL)
3262*7c478bd9Sstevel@tonic-gate 		kmem_free(objp->data_val, objp->data_len);
3263*7c478bd9Sstevel@tonic-gate 	return (TRUE);
3264*7c478bd9Sstevel@tonic-gate }
3265*7c478bd9Sstevel@tonic-gate 
3266*7c478bd9Sstevel@tonic-gate static bool_t
3267*7c478bd9Sstevel@tonic-gate xdr_WRITE4res(XDR *xdrs, WRITE4res *objp)
3268*7c478bd9Sstevel@tonic-gate {
3269*7c478bd9Sstevel@tonic-gate 	if (!xdr_int(xdrs, (int32_t *)&objp->status))
3270*7c478bd9Sstevel@tonic-gate 		return (FALSE);
3271*7c478bd9Sstevel@tonic-gate 	if (objp->status != NFS4_OK)
3272*7c478bd9Sstevel@tonic-gate 		return (TRUE);
3273*7c478bd9Sstevel@tonic-gate 	if (!xdr_u_int(xdrs, &objp->count))
3274*7c478bd9Sstevel@tonic-gate 		return (FALSE);
3275*7c478bd9Sstevel@tonic-gate 	if (!xdr_int(xdrs, (int *)&objp->committed))
3276*7c478bd9Sstevel@tonic-gate 		return (FALSE);
3277*7c478bd9Sstevel@tonic-gate 	return (xdr_u_longlong_t(xdrs,
3278*7c478bd9Sstevel@tonic-gate 			(u_longlong_t *)&objp->writeverf));
3279*7c478bd9Sstevel@tonic-gate }
3280*7c478bd9Sstevel@tonic-gate 
3281*7c478bd9Sstevel@tonic-gate static bool_t
3282*7c478bd9Sstevel@tonic-gate xdr_nfs_argop4_free(XDR *xdrs, nfs_argop4 **arrayp, int len)
3283*7c478bd9Sstevel@tonic-gate {
3284*7c478bd9Sstevel@tonic-gate 	int i;
3285*7c478bd9Sstevel@tonic-gate 	nfs_argop4 *array = *arrayp;
3286*7c478bd9Sstevel@tonic-gate 
3287*7c478bd9Sstevel@tonic-gate 	/*
3288*7c478bd9Sstevel@tonic-gate 	 * Optimized XDR_FREE only args array
3289*7c478bd9Sstevel@tonic-gate 	 */
3290*7c478bd9Sstevel@tonic-gate 	ASSERT(xdrs->x_op == XDR_FREE);
3291*7c478bd9Sstevel@tonic-gate 
3292*7c478bd9Sstevel@tonic-gate 	/*
3293*7c478bd9Sstevel@tonic-gate 	 * Nothing to do?
3294*7c478bd9Sstevel@tonic-gate 	 */
3295*7c478bd9Sstevel@tonic-gate 	if (array == NULL)
3296*7c478bd9Sstevel@tonic-gate 		return (TRUE);
3297*7c478bd9Sstevel@tonic-gate 
3298*7c478bd9Sstevel@tonic-gate 	for (i = 0; i < len; i++) {
3299*7c478bd9Sstevel@tonic-gate 		/*
3300*7c478bd9Sstevel@tonic-gate 		 * These should be ordered by frequency of use
3301*7c478bd9Sstevel@tonic-gate 		 */
3302*7c478bd9Sstevel@tonic-gate 		switch (array[i].argop) {
3303*7c478bd9Sstevel@tonic-gate 		case OP_PUTFH:
3304*7c478bd9Sstevel@tonic-gate 			if (array[i].nfs_argop4_u.opputfh.object.nfs_fh4_val !=
3305*7c478bd9Sstevel@tonic-gate 								NULL) {
3306*7c478bd9Sstevel@tonic-gate 				kmem_free(array[i].nfs_argop4_u.opputfh.object.
3307*7c478bd9Sstevel@tonic-gate 								nfs_fh4_val,
3308*7c478bd9Sstevel@tonic-gate 					array[i].nfs_argop4_u.opputfh.object.
3309*7c478bd9Sstevel@tonic-gate 								nfs_fh4_len);
3310*7c478bd9Sstevel@tonic-gate 			}
3311*7c478bd9Sstevel@tonic-gate 			continue;
3312*7c478bd9Sstevel@tonic-gate 		case OP_GETATTR:
3313*7c478bd9Sstevel@tonic-gate 		case OP_GETFH:
3314*7c478bd9Sstevel@tonic-gate 			continue;
3315*7c478bd9Sstevel@tonic-gate 		case OP_LOOKUP:
3316*7c478bd9Sstevel@tonic-gate 			if (array[i].nfs_argop4_u.oplookup.objname.
3317*7c478bd9Sstevel@tonic-gate 						utf8string_val != NULL) {
3318*7c478bd9Sstevel@tonic-gate 				kmem_free(array[i].nfs_argop4_u.oplookup.
3319*7c478bd9Sstevel@tonic-gate 						objname.utf8string_val,
3320*7c478bd9Sstevel@tonic-gate 					array[i].nfs_argop4_u.oplookup.
3321*7c478bd9Sstevel@tonic-gate 						objname.utf8string_len);
3322*7c478bd9Sstevel@tonic-gate 			}
3323*7c478bd9Sstevel@tonic-gate 			continue;
3324*7c478bd9Sstevel@tonic-gate 		case OP_OPEN:
3325*7c478bd9Sstevel@tonic-gate 			(void) xdr_OPEN4args(xdrs,
3326*7c478bd9Sstevel@tonic-gate 						&array[i].nfs_argop4_u.opopen);
3327*7c478bd9Sstevel@tonic-gate 			continue;
3328*7c478bd9Sstevel@tonic-gate 		case OP_CLOSE:
3329*7c478bd9Sstevel@tonic-gate 		case OP_ACCESS:
3330*7c478bd9Sstevel@tonic-gate 		case OP_READ:
3331*7c478bd9Sstevel@tonic-gate 			continue;
3332*7c478bd9Sstevel@tonic-gate 		case OP_WRITE:
3333*7c478bd9Sstevel@tonic-gate 			(void) xdr_WRITE4args(xdrs,
3334*7c478bd9Sstevel@tonic-gate 						&array[i].nfs_argop4_u.opwrite);
3335*7c478bd9Sstevel@tonic-gate 			continue;
3336*7c478bd9Sstevel@tonic-gate 		case OP_DELEGRETURN:
3337*7c478bd9Sstevel@tonic-gate 		case OP_LOOKUPP:
3338*7c478bd9Sstevel@tonic-gate 		case OP_READDIR:
3339*7c478bd9Sstevel@tonic-gate 			continue;
3340*7c478bd9Sstevel@tonic-gate 		case OP_REMOVE:
3341*7c478bd9Sstevel@tonic-gate 			if (array[i].nfs_argop4_u.opremove.target.
3342*7c478bd9Sstevel@tonic-gate 						utf8string_val != NULL) {
3343*7c478bd9Sstevel@tonic-gate 				kmem_free(array[i].nfs_argop4_u.opremove.target.
3344*7c478bd9Sstevel@tonic-gate 							utf8string_val,
3345*7c478bd9Sstevel@tonic-gate 					array[i].nfs_argop4_u.opremove.target.
3346*7c478bd9Sstevel@tonic-gate 							utf8string_len);
3347*7c478bd9Sstevel@tonic-gate 			}
3348*7c478bd9Sstevel@tonic-gate 			continue;
3349*7c478bd9Sstevel@tonic-gate 		case OP_COMMIT:
3350*7c478bd9Sstevel@tonic-gate 			continue;
3351*7c478bd9Sstevel@tonic-gate 		case OP_CREATE:
3352*7c478bd9Sstevel@tonic-gate 			(void) xdr_CREATE4args(xdrs,
3353*7c478bd9Sstevel@tonic-gate 					&array[i].nfs_argop4_u.opcreate);
3354*7c478bd9Sstevel@tonic-gate 			continue;
3355*7c478bd9Sstevel@tonic-gate 		case OP_DELEGPURGE:
3356*7c478bd9Sstevel@tonic-gate 			continue;
3357*7c478bd9Sstevel@tonic-gate 		case OP_LINK:
3358*7c478bd9Sstevel@tonic-gate 			if (array[i].nfs_argop4_u.oplink.newname.
3359*7c478bd9Sstevel@tonic-gate 						utf8string_val != NULL) {
3360*7c478bd9Sstevel@tonic-gate 				kmem_free(array[i].nfs_argop4_u.oplink.newname.
3361*7c478bd9Sstevel@tonic-gate 							utf8string_val,
3362*7c478bd9Sstevel@tonic-gate 					array[i].nfs_argop4_u.oplink.newname.
3363*7c478bd9Sstevel@tonic-gate 							utf8string_len);
3364*7c478bd9Sstevel@tonic-gate 			}
3365*7c478bd9Sstevel@tonic-gate 			continue;
3366*7c478bd9Sstevel@tonic-gate 		case OP_LOCK:
3367*7c478bd9Sstevel@tonic-gate 			(void) xdr_LOCK4args(xdrs,
3368*7c478bd9Sstevel@tonic-gate 						&array[i].nfs_argop4_u.oplock);
3369*7c478bd9Sstevel@tonic-gate 			continue;
3370*7c478bd9Sstevel@tonic-gate 		case OP_LOCKT:
3371*7c478bd9Sstevel@tonic-gate 			(void) xdr_LOCKT4args(xdrs,
3372*7c478bd9Sstevel@tonic-gate 						&array[i].nfs_argop4_u.oplockt);
3373*7c478bd9Sstevel@tonic-gate 			continue;
3374*7c478bd9Sstevel@tonic-gate 		case OP_LOCKU:
3375*7c478bd9Sstevel@tonic-gate 			continue;
3376*7c478bd9Sstevel@tonic-gate 		case OP_NVERIFY:
3377*7c478bd9Sstevel@tonic-gate 			(void) xdr_fattr4(xdrs,
3378*7c478bd9Sstevel@tonic-gate 			    &array[i].nfs_argop4_u.opnverify.obj_attributes);
3379*7c478bd9Sstevel@tonic-gate 			continue;
3380*7c478bd9Sstevel@tonic-gate 		case OP_OPENATTR:
3381*7c478bd9Sstevel@tonic-gate 		case OP_OPEN_CONFIRM:
3382*7c478bd9Sstevel@tonic-gate 		case OP_OPEN_DOWNGRADE:
3383*7c478bd9Sstevel@tonic-gate 		case OP_PUTPUBFH:
3384*7c478bd9Sstevel@tonic-gate 		case OP_PUTROOTFH:
3385*7c478bd9Sstevel@tonic-gate 		case OP_READLINK:
3386*7c478bd9Sstevel@tonic-gate 			continue;
3387*7c478bd9Sstevel@tonic-gate 		case OP_RENAME:
3388*7c478bd9Sstevel@tonic-gate 			if (array[i].nfs_argop4_u.oprename.oldname.
3389*7c478bd9Sstevel@tonic-gate 						utf8string_val != NULL) {
3390*7c478bd9Sstevel@tonic-gate 				kmem_free(array[i].nfs_argop4_u.oprename.
3391*7c478bd9Sstevel@tonic-gate 						oldname.utf8string_val,
3392*7c478bd9Sstevel@tonic-gate 					array[i].nfs_argop4_u.oprename.
3393*7c478bd9Sstevel@tonic-gate 						oldname.utf8string_len);
3394*7c478bd9Sstevel@tonic-gate 			}
3395*7c478bd9Sstevel@tonic-gate 			if (array[i].nfs_argop4_u.oprename.newname.
3396*7c478bd9Sstevel@tonic-gate 						utf8string_val != NULL) {
3397*7c478bd9Sstevel@tonic-gate 				kmem_free(array[i].nfs_argop4_u.oprename.
3398*7c478bd9Sstevel@tonic-gate 						newname.utf8string_val,
3399*7c478bd9Sstevel@tonic-gate 					array[i].nfs_argop4_u.oprename.
3400*7c478bd9Sstevel@tonic-gate 						newname.utf8string_len);
3401*7c478bd9Sstevel@tonic-gate 			}
3402*7c478bd9Sstevel@tonic-gate 			continue;
3403*7c478bd9Sstevel@tonic-gate 		case OP_RENEW:
3404*7c478bd9Sstevel@tonic-gate 		case OP_RESTOREFH:
3405*7c478bd9Sstevel@tonic-gate 		case OP_SAVEFH:
3406*7c478bd9Sstevel@tonic-gate 			continue;
3407*7c478bd9Sstevel@tonic-gate 		case OP_SECINFO:
3408*7c478bd9Sstevel@tonic-gate 			if (array[i].nfs_argop4_u.opsecinfo.name.
3409*7c478bd9Sstevel@tonic-gate 						utf8string_val != NULL) {
3410*7c478bd9Sstevel@tonic-gate 				kmem_free(array[i].nfs_argop4_u.opsecinfo.name.
3411*7c478bd9Sstevel@tonic-gate 							utf8string_val,
3412*7c478bd9Sstevel@tonic-gate 					array[i].nfs_argop4_u.opsecinfo.name.
3413*7c478bd9Sstevel@tonic-gate 							utf8string_len);
3414*7c478bd9Sstevel@tonic-gate 			}
3415*7c478bd9Sstevel@tonic-gate 			continue;
3416*7c478bd9Sstevel@tonic-gate 		case OP_SETATTR:
3417*7c478bd9Sstevel@tonic-gate 			(void) xdr_fattr4(xdrs,
3418*7c478bd9Sstevel@tonic-gate 			    &array[i].nfs_argop4_u.opsetattr.obj_attributes);
3419*7c478bd9Sstevel@tonic-gate 			continue;
3420*7c478bd9Sstevel@tonic-gate 		case OP_SETCLIENTID:
3421*7c478bd9Sstevel@tonic-gate 			(void) xdr_SETCLIENTID4args(xdrs,
3422*7c478bd9Sstevel@tonic-gate 					&array[i].nfs_argop4_u.opsetclientid);
3423*7c478bd9Sstevel@tonic-gate 			continue;
3424*7c478bd9Sstevel@tonic-gate 		case OP_SETCLIENTID_CONFIRM:
3425*7c478bd9Sstevel@tonic-gate 			continue;
3426*7c478bd9Sstevel@tonic-gate 		case OP_VERIFY:
3427*7c478bd9Sstevel@tonic-gate 			(void) xdr_fattr4(xdrs,
3428*7c478bd9Sstevel@tonic-gate 				&array[i].nfs_argop4_u.opverify.obj_attributes);
3429*7c478bd9Sstevel@tonic-gate 			continue;
3430*7c478bd9Sstevel@tonic-gate 		case OP_RELEASE_LOCKOWNER:
3431*7c478bd9Sstevel@tonic-gate 			if (array[i].nfs_argop4_u.oprelease_lockowner.
3432*7c478bd9Sstevel@tonic-gate 						lock_owner.owner_val != NULL) {
3433*7c478bd9Sstevel@tonic-gate 				kmem_free(array[i].nfs_argop4_u.
3434*7c478bd9Sstevel@tonic-gate 				    oprelease_lockowner.lock_owner.owner_val,
3435*7c478bd9Sstevel@tonic-gate 					array[i].nfs_argop4_u.
3436*7c478bd9Sstevel@tonic-gate 				    oprelease_lockowner.lock_owner.owner_len);
3437*7c478bd9Sstevel@tonic-gate 			}
3438*7c478bd9Sstevel@tonic-gate 			continue;
3439*7c478bd9Sstevel@tonic-gate 		case OP_ILLEGAL:
3440*7c478bd9Sstevel@tonic-gate 			continue;
3441*7c478bd9Sstevel@tonic-gate 		default:
3442*7c478bd9Sstevel@tonic-gate 			/*
3443*7c478bd9Sstevel@tonic-gate 			 * An invalid op is a coding error, it should never
3444*7c478bd9Sstevel@tonic-gate 			 * have been decoded.
3445*7c478bd9Sstevel@tonic-gate 			 * Don't error because the caller cannot finish
3446*7c478bd9Sstevel@tonic-gate 			 * freeing the residual memory of the array.
3447*7c478bd9Sstevel@tonic-gate 			 */
3448*7c478bd9Sstevel@tonic-gate 			continue;
3449*7c478bd9Sstevel@tonic-gate 		}
3450*7c478bd9Sstevel@tonic-gate 	}
3451*7c478bd9Sstevel@tonic-gate 
3452*7c478bd9Sstevel@tonic-gate 	kmem_free(*arrayp, len * sizeof (nfs_argop4));
3453*7c478bd9Sstevel@tonic-gate 	*arrayp = NULL;
3454*7c478bd9Sstevel@tonic-gate 	return (TRUE);
3455*7c478bd9Sstevel@tonic-gate }
3456*7c478bd9Sstevel@tonic-gate 
3457*7c478bd9Sstevel@tonic-gate static bool_t
3458*7c478bd9Sstevel@tonic-gate xdr_nfs_argop4(XDR *xdrs, nfs_argop4 *objp)
3459*7c478bd9Sstevel@tonic-gate {
3460*7c478bd9Sstevel@tonic-gate 	if (!xdr_int(xdrs, (int *)&objp->argop))
3461*7c478bd9Sstevel@tonic-gate 		return (FALSE);
3462*7c478bd9Sstevel@tonic-gate 
3463*7c478bd9Sstevel@tonic-gate 	/*
3464*7c478bd9Sstevel@tonic-gate 	 * These should be ordered by frequency of use
3465*7c478bd9Sstevel@tonic-gate 	 */
3466*7c478bd9Sstevel@tonic-gate 	switch (objp->argop) {
3467*7c478bd9Sstevel@tonic-gate 	case OP_PUTFH:
3468*7c478bd9Sstevel@tonic-gate 		return (xdr_bytes(xdrs,
3469*7c478bd9Sstevel@tonic-gate 		    (char **)&objp->nfs_argop4_u.opputfh.object.nfs_fh4_val,
3470*7c478bd9Sstevel@tonic-gate 		    (uint_t *)&objp->nfs_argop4_u.opputfh.object.nfs_fh4_len,
3471*7c478bd9Sstevel@tonic-gate 		    NFS4_FHSIZE));
3472*7c478bd9Sstevel@tonic-gate 	case OP_GETATTR:
3473*7c478bd9Sstevel@tonic-gate 		return (xdr_bitmap4(xdrs,
3474*7c478bd9Sstevel@tonic-gate 				&objp->nfs_argop4_u.opgetattr.attr_request));
3475*7c478bd9Sstevel@tonic-gate 	case OP_GETFH:
3476*7c478bd9Sstevel@tonic-gate 		return (TRUE);
3477*7c478bd9Sstevel@tonic-gate 	case OP_LOOKUP:
3478*7c478bd9Sstevel@tonic-gate 		return (xdr_bytes(xdrs, (char **)&objp->nfs_argop4_u.oplookup.
3479*7c478bd9Sstevel@tonic-gate 				objname.utf8string_val,
3480*7c478bd9Sstevel@tonic-gate 			(uint_t *)&objp->nfs_argop4_u.oplookup.
3481*7c478bd9Sstevel@tonic-gate 				objname.utf8string_len,
3482*7c478bd9Sstevel@tonic-gate 			NFS4_MAX_UTF8STRING));
3483*7c478bd9Sstevel@tonic-gate 	case OP_OPEN:
3484*7c478bd9Sstevel@tonic-gate 		return (xdr_OPEN4args(xdrs, &objp->nfs_argop4_u.opopen));
3485*7c478bd9Sstevel@tonic-gate 	case OP_CLOSE:
3486*7c478bd9Sstevel@tonic-gate 		return (xdr_CLOSE4args(xdrs, &objp->nfs_argop4_u.opclose));
3487*7c478bd9Sstevel@tonic-gate 	case OP_ACCESS:
3488*7c478bd9Sstevel@tonic-gate 		return (xdr_u_int(xdrs,
3489*7c478bd9Sstevel@tonic-gate 				&objp->nfs_argop4_u.opaccess.access));
3490*7c478bd9Sstevel@tonic-gate 	case OP_READ:
3491*7c478bd9Sstevel@tonic-gate 		return (xdr_READ4args(xdrs, &objp->nfs_argop4_u.opread));
3492*7c478bd9Sstevel@tonic-gate 	case OP_WRITE:
3493*7c478bd9Sstevel@tonic-gate 		return (xdr_WRITE4args(xdrs, &objp->nfs_argop4_u.opwrite));
3494*7c478bd9Sstevel@tonic-gate 	case OP_DELEGRETURN:
3495*7c478bd9Sstevel@tonic-gate 		if (!xdr_u_int(xdrs,
3496*7c478bd9Sstevel@tonic-gate 		    &objp->nfs_argop4_u.opdelegreturn.deleg_stateid.seqid))
3497*7c478bd9Sstevel@tonic-gate 			return (FALSE);
3498*7c478bd9Sstevel@tonic-gate 		return (xdr_opaque(xdrs,
3499*7c478bd9Sstevel@tonic-gate 		    objp->nfs_argop4_u.opdelegreturn.deleg_stateid.other, 12));
3500*7c478bd9Sstevel@tonic-gate 	case OP_LOOKUPP:
3501*7c478bd9Sstevel@tonic-gate 		return (TRUE);
3502*7c478bd9Sstevel@tonic-gate 	case OP_READDIR:
3503*7c478bd9Sstevel@tonic-gate 		return (xdr_READDIR4args(xdrs, &objp->nfs_argop4_u.opreaddir));
3504*7c478bd9Sstevel@tonic-gate 	case OP_REMOVE:
3505*7c478bd9Sstevel@tonic-gate 		return (xdr_bytes(xdrs, (char **)&objp->nfs_argop4_u.opremove.
3506*7c478bd9Sstevel@tonic-gate 				target.utf8string_val,
3507*7c478bd9Sstevel@tonic-gate 			(uint_t *)&objp->nfs_argop4_u.opremove.
3508*7c478bd9Sstevel@tonic-gate 				target.utf8string_len,
3509*7c478bd9Sstevel@tonic-gate 			NFS4_MAX_UTF8STRING));
3510*7c478bd9Sstevel@tonic-gate 	case OP_COMMIT:
3511*7c478bd9Sstevel@tonic-gate 		if (!xdr_u_longlong_t(xdrs,
3512*7c478bd9Sstevel@tonic-gate 		    (u_longlong_t *)&objp->nfs_argop4_u.opcommit.offset))
3513*7c478bd9Sstevel@tonic-gate 			return (FALSE);
3514*7c478bd9Sstevel@tonic-gate 		return (xdr_u_int(xdrs, &objp->nfs_argop4_u.opcommit.count));
3515*7c478bd9Sstevel@tonic-gate 	case OP_CREATE:
3516*7c478bd9Sstevel@tonic-gate 		return (xdr_CREATE4args(xdrs, &objp->nfs_argop4_u.opcreate));
3517*7c478bd9Sstevel@tonic-gate 	case OP_DELEGPURGE:
3518*7c478bd9Sstevel@tonic-gate 		return (xdr_u_longlong_t(xdrs,
3519*7c478bd9Sstevel@tonic-gate 		    (u_longlong_t *)&objp->nfs_argop4_u.opdelegpurge.clientid));
3520*7c478bd9Sstevel@tonic-gate 	case OP_LINK:
3521*7c478bd9Sstevel@tonic-gate 		return (xdr_bytes(xdrs,
3522*7c478bd9Sstevel@tonic-gate 		    (char **)&objp->nfs_argop4_u.oplink.newname.utf8string_val,
3523*7c478bd9Sstevel@tonic-gate 		    (uint_t *)&objp->nfs_argop4_u.oplink.newname.utf8string_len,
3524*7c478bd9Sstevel@tonic-gate 		    NFS4_MAX_UTF8STRING));
3525*7c478bd9Sstevel@tonic-gate 	case OP_LOCK:
3526*7c478bd9Sstevel@tonic-gate 		return (xdr_LOCK4args(xdrs, &objp->nfs_argop4_u.oplock));
3527*7c478bd9Sstevel@tonic-gate 	case OP_LOCKT:
3528*7c478bd9Sstevel@tonic-gate 		return (xdr_LOCKT4args(xdrs, &objp->nfs_argop4_u.oplockt));
3529*7c478bd9Sstevel@tonic-gate 	case OP_LOCKU:
3530*7c478bd9Sstevel@tonic-gate 		return (xdr_LOCKU4args(xdrs, &objp->nfs_argop4_u.oplocku));
3531*7c478bd9Sstevel@tonic-gate 	case OP_NVERIFY:
3532*7c478bd9Sstevel@tonic-gate 		return (xdr_fattr4(xdrs,
3533*7c478bd9Sstevel@tonic-gate 				&objp->nfs_argop4_u.opnverify.obj_attributes));
3534*7c478bd9Sstevel@tonic-gate 	case OP_OPENATTR:
3535*7c478bd9Sstevel@tonic-gate 		return (xdr_bool(xdrs,
3536*7c478bd9Sstevel@tonic-gate 				&objp->nfs_argop4_u.opopenattr.createdir));
3537*7c478bd9Sstevel@tonic-gate 	case OP_OPEN_CONFIRM:
3538*7c478bd9Sstevel@tonic-gate 		if (!xdr_u_int(xdrs, &objp->nfs_argop4_u.opopen_confirm.
3539*7c478bd9Sstevel@tonic-gate 						open_stateid.seqid))
3540*7c478bd9Sstevel@tonic-gate 			return (FALSE);
3541*7c478bd9Sstevel@tonic-gate 		if (!xdr_opaque(xdrs, objp->nfs_argop4_u.opopen_confirm.
3542*7c478bd9Sstevel@tonic-gate 						open_stateid.other, 12))
3543*7c478bd9Sstevel@tonic-gate 			return (FALSE);
3544*7c478bd9Sstevel@tonic-gate 		return (xdr_u_int(xdrs, &objp->nfs_argop4_u.opopen_confirm.
3545*7c478bd9Sstevel@tonic-gate 						seqid));
3546*7c478bd9Sstevel@tonic-gate 	case OP_OPEN_DOWNGRADE:
3547*7c478bd9Sstevel@tonic-gate 		return (xdr_OPEN_DOWNGRADE4args(xdrs,
3548*7c478bd9Sstevel@tonic-gate 				&objp->nfs_argop4_u.opopen_downgrade));
3549*7c478bd9Sstevel@tonic-gate 	case OP_PUTPUBFH:
3550*7c478bd9Sstevel@tonic-gate 		return (TRUE);
3551*7c478bd9Sstevel@tonic-gate 	case OP_PUTROOTFH:
3552*7c478bd9Sstevel@tonic-gate 		return (TRUE);
3553*7c478bd9Sstevel@tonic-gate 	case OP_READLINK:
3554*7c478bd9Sstevel@tonic-gate 		return (TRUE);
3555*7c478bd9Sstevel@tonic-gate 	case OP_RENAME:
3556*7c478bd9Sstevel@tonic-gate 		if (!xdr_bytes(xdrs, (char **)&objp->nfs_argop4_u.oprename.
3557*7c478bd9Sstevel@tonic-gate 						oldname.utf8string_val,
3558*7c478bd9Sstevel@tonic-gate 			    (uint_t *)&objp->nfs_argop4_u.oprename.
3559*7c478bd9Sstevel@tonic-gate 						oldname.utf8string_len,
3560*7c478bd9Sstevel@tonic-gate 			    NFS4_MAX_UTF8STRING))
3561*7c478bd9Sstevel@tonic-gate 			return (FALSE);
3562*7c478bd9Sstevel@tonic-gate 		return (xdr_bytes(xdrs, (char **)&objp->nfs_argop4_u.oprename.
3563*7c478bd9Sstevel@tonic-gate 						newname.utf8string_val,
3564*7c478bd9Sstevel@tonic-gate 			    (uint_t *)&objp->nfs_argop4_u.oprename.
3565*7c478bd9Sstevel@tonic-gate 						newname.utf8string_len,
3566*7c478bd9Sstevel@tonic-gate 			    NFS4_MAX_UTF8STRING));
3567*7c478bd9Sstevel@tonic-gate 	case OP_RENEW:
3568*7c478bd9Sstevel@tonic-gate 		return (xdr_u_longlong_t(xdrs,
3569*7c478bd9Sstevel@tonic-gate 			(u_longlong_t *)&objp->nfs_argop4_u.oprenew.clientid));
3570*7c478bd9Sstevel@tonic-gate 	case OP_RESTOREFH:
3571*7c478bd9Sstevel@tonic-gate 		return (TRUE);
3572*7c478bd9Sstevel@tonic-gate 	case OP_SAVEFH:
3573*7c478bd9Sstevel@tonic-gate 		return (TRUE);
3574*7c478bd9Sstevel@tonic-gate 	case OP_SECINFO:
3575*7c478bd9Sstevel@tonic-gate 		return (xdr_bytes(xdrs,
3576*7c478bd9Sstevel@tonic-gate 		    (char **)&objp->nfs_argop4_u.opsecinfo.name.utf8string_val,
3577*7c478bd9Sstevel@tonic-gate 		    (uint_t *)&objp->nfs_argop4_u.opsecinfo.name.utf8string_len,
3578*7c478bd9Sstevel@tonic-gate 		    NFS4_MAX_UTF8STRING));
3579*7c478bd9Sstevel@tonic-gate 	case OP_SETATTR:
3580*7c478bd9Sstevel@tonic-gate 		if (!xdr_u_int(xdrs, &objp->nfs_argop4_u.opsetattr.
3581*7c478bd9Sstevel@tonic-gate 						stateid.seqid))
3582*7c478bd9Sstevel@tonic-gate 			return (FALSE);
3583*7c478bd9Sstevel@tonic-gate 		if (!xdr_opaque(xdrs, objp->nfs_argop4_u.opsetattr.
3584*7c478bd9Sstevel@tonic-gate 						stateid.other, 12))
3585*7c478bd9Sstevel@tonic-gate 			return (FALSE);
3586*7c478bd9Sstevel@tonic-gate 		return (xdr_fattr4(xdrs, &objp->nfs_argop4_u.opsetattr.
3587*7c478bd9Sstevel@tonic-gate 						obj_attributes));
3588*7c478bd9Sstevel@tonic-gate 	case OP_SETCLIENTID:
3589*7c478bd9Sstevel@tonic-gate 		return (xdr_SETCLIENTID4args(xdrs,
3590*7c478bd9Sstevel@tonic-gate 				&objp->nfs_argop4_u.opsetclientid));
3591*7c478bd9Sstevel@tonic-gate 	case OP_SETCLIENTID_CONFIRM:
3592*7c478bd9Sstevel@tonic-gate 		if (!xdr_u_longlong_t(xdrs, (u_longlong_t *)&objp->nfs_argop4_u.
3593*7c478bd9Sstevel@tonic-gate 				opsetclientid_confirm.clientid))
3594*7c478bd9Sstevel@tonic-gate 			return (FALSE);
3595*7c478bd9Sstevel@tonic-gate 		return (xdr_u_longlong_t(xdrs,
3596*7c478bd9Sstevel@tonic-gate 				(u_longlong_t *)&objp->nfs_argop4_u.
3597*7c478bd9Sstevel@tonic-gate 				opsetclientid_confirm.setclientid_confirm));
3598*7c478bd9Sstevel@tonic-gate 	case OP_VERIFY:
3599*7c478bd9Sstevel@tonic-gate 		return (xdr_fattr4(xdrs,
3600*7c478bd9Sstevel@tonic-gate 				&objp->nfs_argop4_u.opverify.obj_attributes));
3601*7c478bd9Sstevel@tonic-gate 	case OP_RELEASE_LOCKOWNER:
3602*7c478bd9Sstevel@tonic-gate 		if (!xdr_u_longlong_t(xdrs,
3603*7c478bd9Sstevel@tonic-gate 			    (u_longlong_t *)&objp->nfs_argop4_u.
3604*7c478bd9Sstevel@tonic-gate 				oprelease_lockowner.lock_owner.clientid))
3605*7c478bd9Sstevel@tonic-gate 			return (FALSE);
3606*7c478bd9Sstevel@tonic-gate 		return (xdr_bytes(xdrs,
3607*7c478bd9Sstevel@tonic-gate 			(char **)&objp->nfs_argop4_u.oprelease_lockowner.
3608*7c478bd9Sstevel@tonic-gate 				lock_owner.owner_val,
3609*7c478bd9Sstevel@tonic-gate 			(uint_t *)&objp->nfs_argop4_u.oprelease_lockowner.
3610*7c478bd9Sstevel@tonic-gate 				lock_owner.owner_len, NFS4_OPAQUE_LIMIT));
3611*7c478bd9Sstevel@tonic-gate 	case OP_ILLEGAL:
3612*7c478bd9Sstevel@tonic-gate 		return (TRUE);
3613*7c478bd9Sstevel@tonic-gate 	}
3614*7c478bd9Sstevel@tonic-gate 	return (FALSE);
3615*7c478bd9Sstevel@tonic-gate }
3616*7c478bd9Sstevel@tonic-gate 
3617*7c478bd9Sstevel@tonic-gate /*
3618*7c478bd9Sstevel@tonic-gate  * Client side encode only arg op processing
3619*7c478bd9Sstevel@tonic-gate  */
3620*7c478bd9Sstevel@tonic-gate static bool_t
3621*7c478bd9Sstevel@tonic-gate xdr_cnfs_argop4(XDR *xdrs, nfs_argop4 *objp)
3622*7c478bd9Sstevel@tonic-gate {
3623*7c478bd9Sstevel@tonic-gate 	int len;
3624*7c478bd9Sstevel@tonic-gate 	int op;
3625*7c478bd9Sstevel@tonic-gate 	nfs4_sharedfh_t *sfh;
3626*7c478bd9Sstevel@tonic-gate 	mntinfo4_t *mi;
3627*7c478bd9Sstevel@tonic-gate 	rpc_inline_t *ptr;
3628*7c478bd9Sstevel@tonic-gate 
3629*7c478bd9Sstevel@tonic-gate 	ASSERT(xdrs->x_op == XDR_ENCODE);
3630*7c478bd9Sstevel@tonic-gate 
3631*7c478bd9Sstevel@tonic-gate 	/*
3632*7c478bd9Sstevel@tonic-gate 	 * Special case the private pseudo ops
3633*7c478bd9Sstevel@tonic-gate 	 */
3634*7c478bd9Sstevel@tonic-gate 	if (!(objp->argop & SUNW_PRIVATE_OP))
3635*7c478bd9Sstevel@tonic-gate 		return (xdr_nfs_argop4(xdrs, objp));
3636*7c478bd9Sstevel@tonic-gate 
3637*7c478bd9Sstevel@tonic-gate 	/*
3638*7c478bd9Sstevel@tonic-gate 	 * These should be ordered by frequency of use
3639*7c478bd9Sstevel@tonic-gate 	 */
3640*7c478bd9Sstevel@tonic-gate 	switch (objp->argop) {
3641*7c478bd9Sstevel@tonic-gate 	case OP_CPUTFH:
3642*7c478bd9Sstevel@tonic-gate 		/*
3643*7c478bd9Sstevel@tonic-gate 		 * We are passed in the file handle as a nfs4_sharedfh_t *
3644*7c478bd9Sstevel@tonic-gate 		 * We need to acquire the correct locks so we can copy it out.
3645*7c478bd9Sstevel@tonic-gate 		 */
3646*7c478bd9Sstevel@tonic-gate 		sfh = (nfs4_sharedfh_t *)objp->nfs_argop4_u.opcputfh.sfh;
3647*7c478bd9Sstevel@tonic-gate 		mi = sfh->sfh_mi;
3648*7c478bd9Sstevel@tonic-gate 		(void) nfs_rw_enter_sig(&mi->mi_fh_lock, RW_READER, 0);
3649*7c478bd9Sstevel@tonic-gate 
3650*7c478bd9Sstevel@tonic-gate 		len = sfh->sfh_fh.nfs_fh4_len;
3651*7c478bd9Sstevel@tonic-gate 		ASSERT(len <= NFS4_FHSIZE);
3652*7c478bd9Sstevel@tonic-gate 
3653*7c478bd9Sstevel@tonic-gate 		/*
3654*7c478bd9Sstevel@tonic-gate 		 * First try and inline the copy
3655*7c478bd9Sstevel@tonic-gate 		 * Must first be a multiple of BYTES_PER_XDR_UNIT
3656*7c478bd9Sstevel@tonic-gate 		 */
3657*7c478bd9Sstevel@tonic-gate 		if (!(len % BYTES_PER_XDR_UNIT) &&
3658*7c478bd9Sstevel@tonic-gate 		    (ptr = XDR_INLINE(xdrs, 2 * BYTES_PER_XDR_UNIT + len)) !=
3659*7c478bd9Sstevel@tonic-gate 									NULL) {
3660*7c478bd9Sstevel@tonic-gate 			IXDR_PUT_U_INT32(ptr, OP_PUTFH);
3661*7c478bd9Sstevel@tonic-gate 			IXDR_PUT_U_INT32(ptr, len);
3662*7c478bd9Sstevel@tonic-gate 			bcopy(sfh->sfh_fh.nfs_fh4_val, ptr, len);
3663*7c478bd9Sstevel@tonic-gate 			nfs_rw_exit(&mi->mi_fh_lock);
3664*7c478bd9Sstevel@tonic-gate 			return (TRUE);
3665*7c478bd9Sstevel@tonic-gate 		}
3666*7c478bd9Sstevel@tonic-gate 
3667*7c478bd9Sstevel@tonic-gate 		op = OP_PUTFH;
3668*7c478bd9Sstevel@tonic-gate 		if (!XDR_PUTINT32(xdrs, &op)) {
3669*7c478bd9Sstevel@tonic-gate 			nfs_rw_exit(&mi->mi_fh_lock);
3670*7c478bd9Sstevel@tonic-gate 			return (FALSE);
3671*7c478bd9Sstevel@tonic-gate 		}
3672*7c478bd9Sstevel@tonic-gate 		if (!XDR_PUTINT32(xdrs, &len)) {
3673*7c478bd9Sstevel@tonic-gate 			nfs_rw_exit(&mi->mi_fh_lock);
3674*7c478bd9Sstevel@tonic-gate 			return (FALSE);
3675*7c478bd9Sstevel@tonic-gate 		}
3676*7c478bd9Sstevel@tonic-gate 		if (!(len % BYTES_PER_XDR_UNIT)) {
3677*7c478bd9Sstevel@tonic-gate 			if (XDR_PUTBYTES(xdrs, sfh->sfh_fh.nfs_fh4_val, len)) {
3678*7c478bd9Sstevel@tonic-gate 				nfs_rw_exit(&mi->mi_fh_lock);
3679*7c478bd9Sstevel@tonic-gate 				return (TRUE);
3680*7c478bd9Sstevel@tonic-gate 			}
3681*7c478bd9Sstevel@tonic-gate 		} else if (xdr_opaque(xdrs, sfh->sfh_fh.nfs_fh4_val, len)) {
3682*7c478bd9Sstevel@tonic-gate 			nfs_rw_exit(&mi->mi_fh_lock);
3683*7c478bd9Sstevel@tonic-gate 			return (TRUE);
3684*7c478bd9Sstevel@tonic-gate 		}
3685*7c478bd9Sstevel@tonic-gate 		nfs_rw_exit(&mi->mi_fh_lock);
3686*7c478bd9Sstevel@tonic-gate 		return (FALSE);
3687*7c478bd9Sstevel@tonic-gate 	case OP_CLOOKUP:
3688*7c478bd9Sstevel@tonic-gate 		len = strlen(objp->nfs_argop4_u.opclookup.cname);
3689*7c478bd9Sstevel@tonic-gate 		if (len > NFS4_MAX_UTF8STRING)
3690*7c478bd9Sstevel@tonic-gate 			return (FALSE);
3691*7c478bd9Sstevel@tonic-gate 		op = OP_LOOKUP;
3692*7c478bd9Sstevel@tonic-gate 		if (XDR_PUTINT32(xdrs, &op)) {
3693*7c478bd9Sstevel@tonic-gate 			if (XDR_PUTINT32(xdrs, &len)) {
3694*7c478bd9Sstevel@tonic-gate 				return (xdr_opaque(xdrs,
3695*7c478bd9Sstevel@tonic-gate 					objp->nfs_argop4_u.opclookup.cname,
3696*7c478bd9Sstevel@tonic-gate 					len));
3697*7c478bd9Sstevel@tonic-gate 			}
3698*7c478bd9Sstevel@tonic-gate 		}
3699*7c478bd9Sstevel@tonic-gate 		return (FALSE);
3700*7c478bd9Sstevel@tonic-gate 	case OP_COPEN:
3701*7c478bd9Sstevel@tonic-gate 		/* op processing inlined in xdr_OPEN4cargs */
3702*7c478bd9Sstevel@tonic-gate 		return (xdr_OPEN4cargs(xdrs, &objp->nfs_argop4_u.opcopen));
3703*7c478bd9Sstevel@tonic-gate 	case OP_CREMOVE:
3704*7c478bd9Sstevel@tonic-gate 		len = strlen(objp->nfs_argop4_u.opcremove.ctarget);
3705*7c478bd9Sstevel@tonic-gate 		if (len > NFS4_MAX_UTF8STRING)
3706*7c478bd9Sstevel@tonic-gate 			return (FALSE);
3707*7c478bd9Sstevel@tonic-gate 		op = OP_REMOVE;
3708*7c478bd9Sstevel@tonic-gate 		if (XDR_PUTINT32(xdrs, &op)) {
3709*7c478bd9Sstevel@tonic-gate 			if (XDR_PUTINT32(xdrs, &len)) {
3710*7c478bd9Sstevel@tonic-gate 				return (xdr_opaque(xdrs,
3711*7c478bd9Sstevel@tonic-gate 					objp->nfs_argop4_u.opcremove.ctarget,
3712*7c478bd9Sstevel@tonic-gate 					len));
3713*7c478bd9Sstevel@tonic-gate 			}
3714*7c478bd9Sstevel@tonic-gate 		}
3715*7c478bd9Sstevel@tonic-gate 		return (FALSE);
3716*7c478bd9Sstevel@tonic-gate 	case OP_CCREATE:
3717*7c478bd9Sstevel@tonic-gate 		op = OP_CREATE;
3718*7c478bd9Sstevel@tonic-gate 		if (!XDR_PUTINT32(xdrs, &op))
3719*7c478bd9Sstevel@tonic-gate 			return (FALSE);
3720*7c478bd9Sstevel@tonic-gate 		return (xdr_CREATE4cargs(xdrs, &objp->nfs_argop4_u.opccreate));
3721*7c478bd9Sstevel@tonic-gate 	case OP_CLINK:
3722*7c478bd9Sstevel@tonic-gate 		len = strlen(objp->nfs_argop4_u.opclink.cnewname);
3723*7c478bd9Sstevel@tonic-gate 		if (len > NFS4_MAX_UTF8STRING)
3724*7c478bd9Sstevel@tonic-gate 			return (FALSE);
3725*7c478bd9Sstevel@tonic-gate 		op = OP_LINK;
3726*7c478bd9Sstevel@tonic-gate 		if (XDR_PUTINT32(xdrs, &op)) {
3727*7c478bd9Sstevel@tonic-gate 			if (XDR_PUTINT32(xdrs, &len)) {
3728*7c478bd9Sstevel@tonic-gate 				return (xdr_opaque(xdrs,
3729*7c478bd9Sstevel@tonic-gate 					objp->nfs_argop4_u.opclink.cnewname,
3730*7c478bd9Sstevel@tonic-gate 					len));
3731*7c478bd9Sstevel@tonic-gate 			}
3732*7c478bd9Sstevel@tonic-gate 		}
3733*7c478bd9Sstevel@tonic-gate 		return (FALSE);
3734*7c478bd9Sstevel@tonic-gate 	case OP_CRENAME:
3735*7c478bd9Sstevel@tonic-gate 		len = strlen(objp->nfs_argop4_u.opcrename.coldname);
3736*7c478bd9Sstevel@tonic-gate 		if (len > NFS4_MAX_UTF8STRING)
3737*7c478bd9Sstevel@tonic-gate 			return (FALSE);
3738*7c478bd9Sstevel@tonic-gate 		op = OP_RENAME;
3739*7c478bd9Sstevel@tonic-gate 		if (!XDR_PUTINT32(xdrs, &op))
3740*7c478bd9Sstevel@tonic-gate 			return (FALSE);
3741*7c478bd9Sstevel@tonic-gate 		if (!XDR_PUTINT32(xdrs, &len))
3742*7c478bd9Sstevel@tonic-gate 			return (FALSE);
3743*7c478bd9Sstevel@tonic-gate 		if (!xdr_opaque(xdrs,
3744*7c478bd9Sstevel@tonic-gate 				objp->nfs_argop4_u.opcrename.coldname, len))
3745*7c478bd9Sstevel@tonic-gate 			return (FALSE);
3746*7c478bd9Sstevel@tonic-gate 		len = strlen(objp->nfs_argop4_u.opcrename.cnewname);
3747*7c478bd9Sstevel@tonic-gate 		if (len > NFS4_MAX_UTF8STRING)
3748*7c478bd9Sstevel@tonic-gate 			return (FALSE);
3749*7c478bd9Sstevel@tonic-gate 		if (XDR_PUTINT32(xdrs, &len)) {
3750*7c478bd9Sstevel@tonic-gate 			return (xdr_opaque(xdrs,
3751*7c478bd9Sstevel@tonic-gate 				objp->nfs_argop4_u.opcrename.cnewname, len));
3752*7c478bd9Sstevel@tonic-gate 		}
3753*7c478bd9Sstevel@tonic-gate 		return (FALSE);
3754*7c478bd9Sstevel@tonic-gate 	case OP_CSECINFO:
3755*7c478bd9Sstevel@tonic-gate 		len = strlen(objp->nfs_argop4_u.opcsecinfo.cname);
3756*7c478bd9Sstevel@tonic-gate 		if (len > NFS4_MAX_UTF8STRING)
3757*7c478bd9Sstevel@tonic-gate 			return (FALSE);
3758*7c478bd9Sstevel@tonic-gate 		op = OP_SECINFO;
3759*7c478bd9Sstevel@tonic-gate 		if (XDR_PUTINT32(xdrs, &op)) {
3760*7c478bd9Sstevel@tonic-gate 			if (XDR_PUTINT32(xdrs, &len)) {
3761*7c478bd9Sstevel@tonic-gate 				return (xdr_opaque(xdrs,
3762*7c478bd9Sstevel@tonic-gate 					objp->nfs_argop4_u.opcsecinfo.cname,
3763*7c478bd9Sstevel@tonic-gate 					len));
3764*7c478bd9Sstevel@tonic-gate 			}
3765*7c478bd9Sstevel@tonic-gate 		}
3766*7c478bd9Sstevel@tonic-gate 		return (FALSE);
3767*7c478bd9Sstevel@tonic-gate 	}
3768*7c478bd9Sstevel@tonic-gate 	return (FALSE);
3769*7c478bd9Sstevel@tonic-gate }
3770*7c478bd9Sstevel@tonic-gate 
3771*7c478bd9Sstevel@tonic-gate /*
3772*7c478bd9Sstevel@tonic-gate  * Note that the len and decode_len will only be different in the case
3773*7c478bd9Sstevel@tonic-gate  * of the client's use of this free function.  If the server is
3774*7c478bd9Sstevel@tonic-gate  * freeing results, then the len/decode_len will always match.
3775*7c478bd9Sstevel@tonic-gate  */
3776*7c478bd9Sstevel@tonic-gate static bool_t
3777*7c478bd9Sstevel@tonic-gate xdr_nfs_resop4_free(XDR *xdrs, nfs_resop4 **arrayp, int len, int decode_len)
3778*7c478bd9Sstevel@tonic-gate {
3779*7c478bd9Sstevel@tonic-gate 	int i;
3780*7c478bd9Sstevel@tonic-gate 	nfs_resop4 *array = *arrayp;
3781*7c478bd9Sstevel@tonic-gate 
3782*7c478bd9Sstevel@tonic-gate 	/*
3783*7c478bd9Sstevel@tonic-gate 	 * Optimized XDR_FREE only results array
3784*7c478bd9Sstevel@tonic-gate 	 */
3785*7c478bd9Sstevel@tonic-gate 	ASSERT(xdrs->x_op == XDR_FREE);
3786*7c478bd9Sstevel@tonic-gate 
3787*7c478bd9Sstevel@tonic-gate 	if (array == NULL)
3788*7c478bd9Sstevel@tonic-gate 		return (TRUE);
3789*7c478bd9Sstevel@tonic-gate 
3790*7c478bd9Sstevel@tonic-gate 	for (i = 0; i < decode_len; i++) {
3791*7c478bd9Sstevel@tonic-gate 		/*
3792*7c478bd9Sstevel@tonic-gate 		 * These should be ordered by frequency of use
3793*7c478bd9Sstevel@tonic-gate 		 */
3794*7c478bd9Sstevel@tonic-gate 		switch (array[i].resop) {
3795*7c478bd9Sstevel@tonic-gate 		case OP_PUTFH:
3796*7c478bd9Sstevel@tonic-gate 			continue;
3797*7c478bd9Sstevel@tonic-gate 		case OP_GETATTR:
3798*7c478bd9Sstevel@tonic-gate 			if (array[i].nfs_resop4_u.opgetattr.status != NFS4_OK)
3799*7c478bd9Sstevel@tonic-gate 				continue;
3800*7c478bd9Sstevel@tonic-gate 			if (array[i].nfs_resop4_u.opgetattr.ga_res.n4g_ext_res)
3801*7c478bd9Sstevel@tonic-gate 				kmem_free(array[i].nfs_resop4_u.opgetattr.
3802*7c478bd9Sstevel@tonic-gate 					ga_res.n4g_ext_res,
3803*7c478bd9Sstevel@tonic-gate 					sizeof (struct nfs4_ga_ext_res));
3804*7c478bd9Sstevel@tonic-gate 			continue;
3805*7c478bd9Sstevel@tonic-gate 		case OP_GETFH:
3806*7c478bd9Sstevel@tonic-gate 			if (array[i].nfs_resop4_u.opgetfh.status != NFS4_OK)
3807*7c478bd9Sstevel@tonic-gate 				continue;
3808*7c478bd9Sstevel@tonic-gate 			if (array[i].nfs_resop4_u.opgetfh.object.nfs_fh4_val !=
3809*7c478bd9Sstevel@tonic-gate 							NULL) {
3810*7c478bd9Sstevel@tonic-gate 				kmem_free(array[i].nfs_resop4_u.opgetfh.object.
3811*7c478bd9Sstevel@tonic-gate 							nfs_fh4_val,
3812*7c478bd9Sstevel@tonic-gate 					array[i].nfs_resop4_u.opgetfh.object.
3813*7c478bd9Sstevel@tonic-gate 							nfs_fh4_len);
3814*7c478bd9Sstevel@tonic-gate 			}
3815*7c478bd9Sstevel@tonic-gate 			continue;
3816*7c478bd9Sstevel@tonic-gate 		case OP_LOOKUP:
3817*7c478bd9Sstevel@tonic-gate 			continue;
3818*7c478bd9Sstevel@tonic-gate 		case OP_OPEN:
3819*7c478bd9Sstevel@tonic-gate 			(void) xdr_OPEN4res(xdrs, &array[i].nfs_resop4_u.
3820*7c478bd9Sstevel@tonic-gate 								opopen);
3821*7c478bd9Sstevel@tonic-gate 			continue;
3822*7c478bd9Sstevel@tonic-gate 		case OP_CLOSE:
3823*7c478bd9Sstevel@tonic-gate 		case OP_ACCESS:
3824*7c478bd9Sstevel@tonic-gate 			continue;
3825*7c478bd9Sstevel@tonic-gate 		case OP_READ:
3826*7c478bd9Sstevel@tonic-gate 			(void) xdr_READ4res(xdrs,
3827*7c478bd9Sstevel@tonic-gate 					    &array[i].nfs_resop4_u.
3828*7c478bd9Sstevel@tonic-gate 								opread);
3829*7c478bd9Sstevel@tonic-gate 			continue;
3830*7c478bd9Sstevel@tonic-gate 		case OP_WRITE:
3831*7c478bd9Sstevel@tonic-gate 		case OP_DELEGRETURN:
3832*7c478bd9Sstevel@tonic-gate 		case OP_LOOKUPP:
3833*7c478bd9Sstevel@tonic-gate 		case OP_READDIR:
3834*7c478bd9Sstevel@tonic-gate 		case OP_REMOVE:
3835*7c478bd9Sstevel@tonic-gate 		case OP_COMMIT:
3836*7c478bd9Sstevel@tonic-gate 		case OP_CREATE:
3837*7c478bd9Sstevel@tonic-gate 		case OP_DELEGPURGE:
3838*7c478bd9Sstevel@tonic-gate 		case OP_LINK:
3839*7c478bd9Sstevel@tonic-gate 			continue;
3840*7c478bd9Sstevel@tonic-gate 		case OP_LOCK:
3841*7c478bd9Sstevel@tonic-gate 			(void) xdr_LOCK4res(xdrs, &array[i].nfs_resop4_u.
3842*7c478bd9Sstevel@tonic-gate 								oplock);
3843*7c478bd9Sstevel@tonic-gate 			continue;
3844*7c478bd9Sstevel@tonic-gate 		case OP_LOCKT:
3845*7c478bd9Sstevel@tonic-gate 			(void) xdr_LOCKT4res(xdrs, &array[i].nfs_resop4_u.
3846*7c478bd9Sstevel@tonic-gate 								oplockt);
3847*7c478bd9Sstevel@tonic-gate 			continue;
3848*7c478bd9Sstevel@tonic-gate 		case OP_LOCKU:
3849*7c478bd9Sstevel@tonic-gate 		case OP_NVERIFY:
3850*7c478bd9Sstevel@tonic-gate 		case OP_OPENATTR:
3851*7c478bd9Sstevel@tonic-gate 		case OP_OPEN_CONFIRM:
3852*7c478bd9Sstevel@tonic-gate 		case OP_OPEN_DOWNGRADE:
3853*7c478bd9Sstevel@tonic-gate 		case OP_PUTPUBFH:
3854*7c478bd9Sstevel@tonic-gate 		case OP_PUTROOTFH:
3855*7c478bd9Sstevel@tonic-gate 		case OP_RENAME:
3856*7c478bd9Sstevel@tonic-gate 		case OP_RENEW:
3857*7c478bd9Sstevel@tonic-gate 		case OP_RESTOREFH:
3858*7c478bd9Sstevel@tonic-gate 		case OP_SAVEFH:
3859*7c478bd9Sstevel@tonic-gate 			continue;
3860*7c478bd9Sstevel@tonic-gate 		case OP_READLINK:
3861*7c478bd9Sstevel@tonic-gate 			(void) xdr_READLINK4res(xdrs, &array[i].nfs_resop4_u.
3862*7c478bd9Sstevel@tonic-gate 								opreadlink);
3863*7c478bd9Sstevel@tonic-gate 			continue;
3864*7c478bd9Sstevel@tonic-gate 		case OP_SECINFO:
3865*7c478bd9Sstevel@tonic-gate 			(void) xdr_array(xdrs,
3866*7c478bd9Sstevel@tonic-gate 				(char **)&array[i].nfs_resop4_u.opsecinfo.
3867*7c478bd9Sstevel@tonic-gate 					SECINFO4resok_val,
3868*7c478bd9Sstevel@tonic-gate 				(uint_t *)&array[i].nfs_resop4_u.opsecinfo.
3869*7c478bd9Sstevel@tonic-gate 					SECINFO4resok_len,
3870*7c478bd9Sstevel@tonic-gate 				NFS4_SECINFO_LIMIT, sizeof (secinfo4),
3871*7c478bd9Sstevel@tonic-gate 				(xdrproc_t)xdr_secinfo4);
3872*7c478bd9Sstevel@tonic-gate 			continue;
3873*7c478bd9Sstevel@tonic-gate 		case OP_SETCLIENTID:
3874*7c478bd9Sstevel@tonic-gate 			(void) xdr_SETCLIENTID4res(xdrs,
3875*7c478bd9Sstevel@tonic-gate 					&array[i].nfs_resop4_u.opsetclientid);
3876*7c478bd9Sstevel@tonic-gate 			continue;
3877*7c478bd9Sstevel@tonic-gate 		case OP_SETATTR:
3878*7c478bd9Sstevel@tonic-gate 		case OP_SETCLIENTID_CONFIRM:
3879*7c478bd9Sstevel@tonic-gate 		case OP_VERIFY:
3880*7c478bd9Sstevel@tonic-gate 		case OP_RELEASE_LOCKOWNER:
3881*7c478bd9Sstevel@tonic-gate 		case OP_ILLEGAL:
3882*7c478bd9Sstevel@tonic-gate 			continue;
3883*7c478bd9Sstevel@tonic-gate 		default:
3884*7c478bd9Sstevel@tonic-gate 			/*
3885*7c478bd9Sstevel@tonic-gate 			 * An invalid op is a coding error, it should never
3886*7c478bd9Sstevel@tonic-gate 			 * have been decoded.
3887*7c478bd9Sstevel@tonic-gate 			 * Don't error because the caller cannot finish
3888*7c478bd9Sstevel@tonic-gate 			 * freeing the residual memory of the array.
3889*7c478bd9Sstevel@tonic-gate 			 */
3890*7c478bd9Sstevel@tonic-gate 			continue;
3891*7c478bd9Sstevel@tonic-gate 		}
3892*7c478bd9Sstevel@tonic-gate 	}
3893*7c478bd9Sstevel@tonic-gate 
3894*7c478bd9Sstevel@tonic-gate 	kmem_free(*arrayp, len * sizeof (nfs_resop4));
3895*7c478bd9Sstevel@tonic-gate 	*arrayp = NULL;
3896*7c478bd9Sstevel@tonic-gate 	return (TRUE);
3897*7c478bd9Sstevel@tonic-gate }
3898*7c478bd9Sstevel@tonic-gate 
3899*7c478bd9Sstevel@tonic-gate static bool_t
3900*7c478bd9Sstevel@tonic-gate xdr_nfs_resop4(XDR *xdrs, nfs_resop4 *objp)
3901*7c478bd9Sstevel@tonic-gate {
3902*7c478bd9Sstevel@tonic-gate 	if (!xdr_int(xdrs, (int *)&objp->resop))
3903*7c478bd9Sstevel@tonic-gate 		return (FALSE);
3904*7c478bd9Sstevel@tonic-gate 	/*
3905*7c478bd9Sstevel@tonic-gate 	 * These should be ordered by frequency of use
3906*7c478bd9Sstevel@tonic-gate 	 */
3907*7c478bd9Sstevel@tonic-gate 	switch (objp->resop) {
3908*7c478bd9Sstevel@tonic-gate 	case OP_PUTFH:
3909*7c478bd9Sstevel@tonic-gate 		return (xdr_int(xdrs,
3910*7c478bd9Sstevel@tonic-gate 				(int32_t *)&objp->nfs_resop4_u.opputfh.status));
3911*7c478bd9Sstevel@tonic-gate 	case OP_GETATTR:
3912*7c478bd9Sstevel@tonic-gate 		if (!xdr_int(xdrs,
3913*7c478bd9Sstevel@tonic-gate 			    (int32_t *)&objp->nfs_resop4_u.opgetattr.status))
3914*7c478bd9Sstevel@tonic-gate 			return (FALSE);
3915*7c478bd9Sstevel@tonic-gate 		if (objp->nfs_resop4_u.opgetattr.status != NFS4_OK)
3916*7c478bd9Sstevel@tonic-gate 			return (TRUE);
3917*7c478bd9Sstevel@tonic-gate 		return (xdr_fattr4(xdrs,
3918*7c478bd9Sstevel@tonic-gate 			    &objp->nfs_resop4_u.opgetattr.obj_attributes));
3919*7c478bd9Sstevel@tonic-gate 	case OP_GETFH:
3920*7c478bd9Sstevel@tonic-gate 		if (!xdr_int(xdrs,
3921*7c478bd9Sstevel@tonic-gate 				(int32_t *)&objp->nfs_resop4_u.opgetfh.status))
3922*7c478bd9Sstevel@tonic-gate 			return (FALSE);
3923*7c478bd9Sstevel@tonic-gate 		if (objp->nfs_resop4_u.opgetfh.status != NFS4_OK)
3924*7c478bd9Sstevel@tonic-gate 			return (TRUE);
3925*7c478bd9Sstevel@tonic-gate 		return (xdr_bytes(xdrs,
3926*7c478bd9Sstevel@tonic-gate 		    (char **)&objp->nfs_resop4_u.opgetfh.object.nfs_fh4_val,
3927*7c478bd9Sstevel@tonic-gate 		    (uint_t *)&objp->nfs_resop4_u.opgetfh.object.nfs_fh4_len,
3928*7c478bd9Sstevel@tonic-gate 		    NFS4_FHSIZE));
3929*7c478bd9Sstevel@tonic-gate 	case OP_LOOKUP:
3930*7c478bd9Sstevel@tonic-gate 		return (xdr_int(xdrs,
3931*7c478bd9Sstevel@tonic-gate 			(int32_t *)&objp->nfs_resop4_u.oplookup.status));
3932*7c478bd9Sstevel@tonic-gate 	case OP_OPEN:
3933*7c478bd9Sstevel@tonic-gate 		return (xdr_OPEN4res(xdrs, &objp->nfs_resop4_u.opopen));
3934*7c478bd9Sstevel@tonic-gate 	case OP_CLOSE:
3935*7c478bd9Sstevel@tonic-gate 		return (xdr_CLOSE4res(xdrs, &objp->nfs_resop4_u.opclose));
3936*7c478bd9Sstevel@tonic-gate 	case OP_ACCESS:
3937*7c478bd9Sstevel@tonic-gate 		return (xdr_ACCESS4res(xdrs, &objp->nfs_resop4_u.opaccess));
3938*7c478bd9Sstevel@tonic-gate 	case OP_READ:
3939*7c478bd9Sstevel@tonic-gate 		return (xdr_READ4res(xdrs, &objp->nfs_resop4_u.opread));
3940*7c478bd9Sstevel@tonic-gate 	case OP_WRITE:
3941*7c478bd9Sstevel@tonic-gate 		return (xdr_WRITE4res(xdrs, &objp->nfs_resop4_u.opwrite));
3942*7c478bd9Sstevel@tonic-gate 	case OP_DELEGRETURN:
3943*7c478bd9Sstevel@tonic-gate 		return (xdr_int(xdrs,
3944*7c478bd9Sstevel@tonic-gate 			(int32_t *)&objp->nfs_resop4_u.opdelegreturn.status));
3945*7c478bd9Sstevel@tonic-gate 	case OP_LOOKUPP:
3946*7c478bd9Sstevel@tonic-gate 		return (xdr_int(xdrs,
3947*7c478bd9Sstevel@tonic-gate 			(int32_t *)&objp->nfs_resop4_u.oplookupp.status));
3948*7c478bd9Sstevel@tonic-gate 	case OP_READDIR:
3949*7c478bd9Sstevel@tonic-gate 		return (xdr_READDIR4res(xdrs, &objp->nfs_resop4_u.opreaddir));
3950*7c478bd9Sstevel@tonic-gate 	case OP_REMOVE:
3951*7c478bd9Sstevel@tonic-gate 		return (xdr_REMOVE4res(xdrs, &objp->nfs_resop4_u.opremove));
3952*7c478bd9Sstevel@tonic-gate 
3953*7c478bd9Sstevel@tonic-gate 	case OP_COMMIT:
3954*7c478bd9Sstevel@tonic-gate 		if (!xdr_int(xdrs,
3955*7c478bd9Sstevel@tonic-gate 			    (int32_t *)&objp->nfs_resop4_u.opcommit.status))
3956*7c478bd9Sstevel@tonic-gate 			return (FALSE);
3957*7c478bd9Sstevel@tonic-gate 		if (objp->nfs_resop4_u.opcommit.status != NFS4_OK)
3958*7c478bd9Sstevel@tonic-gate 			return (TRUE);
3959*7c478bd9Sstevel@tonic-gate 		return (xdr_u_longlong_t(xdrs,
3960*7c478bd9Sstevel@tonic-gate 				(u_longlong_t *)&objp->nfs_resop4_u.opcommit.
3961*7c478bd9Sstevel@tonic-gate 						writeverf));
3962*7c478bd9Sstevel@tonic-gate 	case OP_CREATE:
3963*7c478bd9Sstevel@tonic-gate 		return (xdr_CREATE4res(xdrs, &objp->nfs_resop4_u.opcreate));
3964*7c478bd9Sstevel@tonic-gate 	case OP_DELEGPURGE:
3965*7c478bd9Sstevel@tonic-gate 		return (xdr_int(xdrs,
3966*7c478bd9Sstevel@tonic-gate 			(int32_t *)&objp->nfs_resop4_u.opdelegpurge.status));
3967*7c478bd9Sstevel@tonic-gate 	case OP_LINK:
3968*7c478bd9Sstevel@tonic-gate 		return (xdr_LINK4res(xdrs, &objp->nfs_resop4_u.oplink));
3969*7c478bd9Sstevel@tonic-gate 	case OP_LOCK:
3970*7c478bd9Sstevel@tonic-gate 		return (xdr_LOCK4res(xdrs, &objp->nfs_resop4_u.oplock));
3971*7c478bd9Sstevel@tonic-gate 	case OP_LOCKT:
3972*7c478bd9Sstevel@tonic-gate 		return (xdr_LOCKT4res(xdrs, &objp->nfs_resop4_u.oplockt));
3973*7c478bd9Sstevel@tonic-gate 	case OP_LOCKU:
3974*7c478bd9Sstevel@tonic-gate 		if (!xdr_int(xdrs,
3975*7c478bd9Sstevel@tonic-gate 				(int32_t *)&objp->nfs_resop4_u.oplocku.status))
3976*7c478bd9Sstevel@tonic-gate 			return (FALSE);
3977*7c478bd9Sstevel@tonic-gate 		if (objp->nfs_resop4_u.oplocku.status != NFS4_OK)
3978*7c478bd9Sstevel@tonic-gate 			return (TRUE);
3979*7c478bd9Sstevel@tonic-gate 		if (!xdr_u_int(xdrs,
3980*7c478bd9Sstevel@tonic-gate 		    &objp->nfs_resop4_u.oplocku.lock_stateid.seqid))
3981*7c478bd9Sstevel@tonic-gate 			return (FALSE);
3982*7c478bd9Sstevel@tonic-gate 		return (xdr_opaque(xdrs,
3983*7c478bd9Sstevel@tonic-gate 		    objp->nfs_resop4_u.oplocku.lock_stateid.other,
3984*7c478bd9Sstevel@tonic-gate 		    12));
3985*7c478bd9Sstevel@tonic-gate 	case OP_NVERIFY:
3986*7c478bd9Sstevel@tonic-gate 		return (xdr_int(xdrs,
3987*7c478bd9Sstevel@tonic-gate 			(int32_t *)&objp->nfs_resop4_u.opnverify.status));
3988*7c478bd9Sstevel@tonic-gate 	case OP_OPENATTR:
3989*7c478bd9Sstevel@tonic-gate 		return (xdr_int(xdrs,
3990*7c478bd9Sstevel@tonic-gate 			(int32_t *)&objp->nfs_resop4_u.opopenattr.status));
3991*7c478bd9Sstevel@tonic-gate 	case OP_OPEN_CONFIRM:
3992*7c478bd9Sstevel@tonic-gate 		return (xdr_OPEN_CONFIRM4res(xdrs,
3993*7c478bd9Sstevel@tonic-gate 				&objp->nfs_resop4_u.opopen_confirm));
3994*7c478bd9Sstevel@tonic-gate 	case OP_OPEN_DOWNGRADE:
3995*7c478bd9Sstevel@tonic-gate 		return (xdr_OPEN_DOWNGRADE4res(xdrs,
3996*7c478bd9Sstevel@tonic-gate 				&objp->nfs_resop4_u.opopen_downgrade));
3997*7c478bd9Sstevel@tonic-gate 	case OP_PUTPUBFH:
3998*7c478bd9Sstevel@tonic-gate 		return (xdr_int(xdrs,
3999*7c478bd9Sstevel@tonic-gate 			(int32_t *)&objp->nfs_resop4_u.opputpubfh.status));
4000*7c478bd9Sstevel@tonic-gate 	case OP_PUTROOTFH:
4001*7c478bd9Sstevel@tonic-gate 		return (xdr_int(xdrs,
4002*7c478bd9Sstevel@tonic-gate 			(int32_t *)&objp->nfs_resop4_u.opputrootfh.status));
4003*7c478bd9Sstevel@tonic-gate 	case OP_READLINK:
4004*7c478bd9Sstevel@tonic-gate 		return (xdr_READLINK4res(xdrs, &objp->nfs_resop4_u.opreadlink));
4005*7c478bd9Sstevel@tonic-gate 	case OP_RENAME:
4006*7c478bd9Sstevel@tonic-gate 		return (xdr_RENAME4res(xdrs, &objp->nfs_resop4_u.oprename));
4007*7c478bd9Sstevel@tonic-gate 	case OP_RENEW:
4008*7c478bd9Sstevel@tonic-gate 		return (xdr_int(xdrs,
4009*7c478bd9Sstevel@tonic-gate 				(int32_t *)&objp->nfs_resop4_u.oprenew.status));
4010*7c478bd9Sstevel@tonic-gate 	case OP_RESTOREFH:
4011*7c478bd9Sstevel@tonic-gate 		return (xdr_int(xdrs,
4012*7c478bd9Sstevel@tonic-gate 			(int32_t *)&objp->nfs_resop4_u.oprestorefh.status));
4013*7c478bd9Sstevel@tonic-gate 	case OP_SAVEFH:
4014*7c478bd9Sstevel@tonic-gate 		return (xdr_int(xdrs,
4015*7c478bd9Sstevel@tonic-gate 			(int32_t *)&objp->nfs_resop4_u.opsavefh.status));
4016*7c478bd9Sstevel@tonic-gate 	case OP_SECINFO:
4017*7c478bd9Sstevel@tonic-gate 		if (!xdr_int(xdrs, (int32_t *)&objp->nfs_resop4_u.opsecinfo.
4018*7c478bd9Sstevel@tonic-gate 					status))
4019*7c478bd9Sstevel@tonic-gate 			return (FALSE);
4020*7c478bd9Sstevel@tonic-gate 		if (objp->nfs_resop4_u.opsecinfo.status != NFS4_OK)
4021*7c478bd9Sstevel@tonic-gate 			return (TRUE);
4022*7c478bd9Sstevel@tonic-gate 		return (xdr_array(xdrs, (char **)&objp->nfs_resop4_u.opsecinfo.
4023*7c478bd9Sstevel@tonic-gate 					SECINFO4resok_val,
4024*7c478bd9Sstevel@tonic-gate 			(uint_t *)&objp->nfs_resop4_u.opsecinfo.
4025*7c478bd9Sstevel@tonic-gate 					SECINFO4resok_len,
4026*7c478bd9Sstevel@tonic-gate 			NFS4_SECINFO_LIMIT, sizeof (secinfo4),
4027*7c478bd9Sstevel@tonic-gate 			(xdrproc_t)xdr_secinfo4));
4028*7c478bd9Sstevel@tonic-gate 	case OP_SETATTR:
4029*7c478bd9Sstevel@tonic-gate 		if (!xdr_int(xdrs, (int32_t *)&objp->nfs_resop4_u.opsetattr.
4030*7c478bd9Sstevel@tonic-gate 						status))
4031*7c478bd9Sstevel@tonic-gate 			return (FALSE);
4032*7c478bd9Sstevel@tonic-gate 		return (xdr_bitmap4(xdrs,
4033*7c478bd9Sstevel@tonic-gate 				&objp->nfs_resop4_u.opsetattr.attrsset));
4034*7c478bd9Sstevel@tonic-gate 	case OP_SETCLIENTID:
4035*7c478bd9Sstevel@tonic-gate 		return (xdr_SETCLIENTID4res(xdrs,
4036*7c478bd9Sstevel@tonic-gate 				&objp->nfs_resop4_u.opsetclientid));
4037*7c478bd9Sstevel@tonic-gate 	case OP_SETCLIENTID_CONFIRM:
4038*7c478bd9Sstevel@tonic-gate 		return (xdr_int(xdrs,
4039*7c478bd9Sstevel@tonic-gate 			(int32_t *)&objp->nfs_resop4_u.opsetclientid_confirm.
4040*7c478bd9Sstevel@tonic-gate 					status));
4041*7c478bd9Sstevel@tonic-gate 	case OP_VERIFY:
4042*7c478bd9Sstevel@tonic-gate 		return (xdr_int(xdrs,
4043*7c478bd9Sstevel@tonic-gate 			(int32_t *)&objp->nfs_resop4_u.opverify.status));
4044*7c478bd9Sstevel@tonic-gate 	case OP_RELEASE_LOCKOWNER:
4045*7c478bd9Sstevel@tonic-gate 		return (xdr_int(xdrs,
4046*7c478bd9Sstevel@tonic-gate 		    (int32_t *)&objp->nfs_resop4_u.oprelease_lockowner.status));
4047*7c478bd9Sstevel@tonic-gate 	case OP_ILLEGAL:
4048*7c478bd9Sstevel@tonic-gate 		return (xdr_int(xdrs,
4049*7c478bd9Sstevel@tonic-gate 			(int32_t *)&objp->nfs_resop4_u.opillegal.status));
4050*7c478bd9Sstevel@tonic-gate 	}
4051*7c478bd9Sstevel@tonic-gate 	return (FALSE);
4052*7c478bd9Sstevel@tonic-gate }
4053*7c478bd9Sstevel@tonic-gate 
4054*7c478bd9Sstevel@tonic-gate static bool_t
4055*7c478bd9Sstevel@tonic-gate xdr_nfs_resop4_clnt(XDR *xdrs, nfs_resop4 *objp, nfs_argop4 *aobjp)
4056*7c478bd9Sstevel@tonic-gate {
4057*7c478bd9Sstevel@tonic-gate 	if (!xdr_int(xdrs, (int *)&objp->resop))
4058*7c478bd9Sstevel@tonic-gate 		return (FALSE);
4059*7c478bd9Sstevel@tonic-gate 	/*
4060*7c478bd9Sstevel@tonic-gate 	 * These should be ordered by frequency of use
4061*7c478bd9Sstevel@tonic-gate 	 */
4062*7c478bd9Sstevel@tonic-gate 	switch (objp->resop) {
4063*7c478bd9Sstevel@tonic-gate 	case OP_PUTFH:
4064*7c478bd9Sstevel@tonic-gate 		return (xdr_int(xdrs,
4065*7c478bd9Sstevel@tonic-gate 				(int32_t *)&objp->nfs_resop4_u.opputfh.status));
4066*7c478bd9Sstevel@tonic-gate 	case OP_GETATTR:
4067*7c478bd9Sstevel@tonic-gate 		if (!xdr_int(xdrs,
4068*7c478bd9Sstevel@tonic-gate 			    (int32_t *)&objp->nfs_resop4_u.opgetattr.status))
4069*7c478bd9Sstevel@tonic-gate 			return (FALSE);
4070*7c478bd9Sstevel@tonic-gate 		if (objp->nfs_resop4_u.opgetattr.status != NFS4_OK)
4071*7c478bd9Sstevel@tonic-gate 			return (TRUE);
4072*7c478bd9Sstevel@tonic-gate 		return (xdr_ga_res(xdrs,
4073*7c478bd9Sstevel@tonic-gate 				(GETATTR4res *)&objp->nfs_resop4_u.opgetattr,
4074*7c478bd9Sstevel@tonic-gate 				&aobjp->nfs_argop4_u.opgetattr));
4075*7c478bd9Sstevel@tonic-gate 	case OP_GETFH:
4076*7c478bd9Sstevel@tonic-gate 		if (!xdr_int(xdrs,
4077*7c478bd9Sstevel@tonic-gate 				(int32_t *)&objp->nfs_resop4_u.opgetfh.status))
4078*7c478bd9Sstevel@tonic-gate 			return (FALSE);
4079*7c478bd9Sstevel@tonic-gate 		if (objp->nfs_resop4_u.opgetfh.status != NFS4_OK)
4080*7c478bd9Sstevel@tonic-gate 			return (TRUE);
4081*7c478bd9Sstevel@tonic-gate 		return (xdr_bytes(xdrs,
4082*7c478bd9Sstevel@tonic-gate 		    (char **)&objp->nfs_resop4_u.opgetfh.object.nfs_fh4_val,
4083*7c478bd9Sstevel@tonic-gate 		    (uint_t *)&objp->nfs_resop4_u.opgetfh.object.nfs_fh4_len,
4084*7c478bd9Sstevel@tonic-gate 		    NFS4_FHSIZE));
4085*7c478bd9Sstevel@tonic-gate 	case OP_LOOKUP:
4086*7c478bd9Sstevel@tonic-gate 		return (xdr_int(xdrs,
4087*7c478bd9Sstevel@tonic-gate 			(int32_t *)&objp->nfs_resop4_u.oplookup.status));
4088*7c478bd9Sstevel@tonic-gate 	case OP_NVERIFY:
4089*7c478bd9Sstevel@tonic-gate 		return (xdr_int(xdrs,
4090*7c478bd9Sstevel@tonic-gate 			(int32_t *)&objp->nfs_resop4_u.opnverify.status));
4091*7c478bd9Sstevel@tonic-gate 	case OP_OPEN:
4092*7c478bd9Sstevel@tonic-gate 		return (xdr_OPEN4res(xdrs, &objp->nfs_resop4_u.opopen));
4093*7c478bd9Sstevel@tonic-gate 	case OP_CLOSE:
4094*7c478bd9Sstevel@tonic-gate 		return (xdr_CLOSE4res(xdrs, &objp->nfs_resop4_u.opclose));
4095*7c478bd9Sstevel@tonic-gate 	case OP_ACCESS:
4096*7c478bd9Sstevel@tonic-gate 		return (xdr_ACCESS4res(xdrs, &objp->nfs_resop4_u.opaccess));
4097*7c478bd9Sstevel@tonic-gate 	case OP_READ:
4098*7c478bd9Sstevel@tonic-gate 		return (xdr_READ4res_clnt(xdrs, &objp->nfs_resop4_u.opread,
4099*7c478bd9Sstevel@tonic-gate 					&aobjp->nfs_argop4_u.opread));
4100*7c478bd9Sstevel@tonic-gate 	case OP_WRITE:
4101*7c478bd9Sstevel@tonic-gate 		return (xdr_WRITE4res(xdrs, &objp->nfs_resop4_u.opwrite));
4102*7c478bd9Sstevel@tonic-gate 	case OP_DELEGRETURN:
4103*7c478bd9Sstevel@tonic-gate 		return (xdr_int(xdrs,
4104*7c478bd9Sstevel@tonic-gate 			(int32_t *)&objp->nfs_resop4_u.opdelegreturn.status));
4105*7c478bd9Sstevel@tonic-gate 	case OP_LOOKUPP:
4106*7c478bd9Sstevel@tonic-gate 		return (xdr_int(xdrs,
4107*7c478bd9Sstevel@tonic-gate 			(int32_t *)&objp->nfs_resop4_u.oplookupp.status));
4108*7c478bd9Sstevel@tonic-gate 	case OP_READDIR:
4109*7c478bd9Sstevel@tonic-gate 		return (xdr_READDIR4res_clnt(xdrs,
4110*7c478bd9Sstevel@tonic-gate 				&objp->nfs_resop4_u.opreaddirclnt,
4111*7c478bd9Sstevel@tonic-gate 				&aobjp->nfs_argop4_u.opreaddir));
4112*7c478bd9Sstevel@tonic-gate 	case OP_REMOVE:
4113*7c478bd9Sstevel@tonic-gate 		return (xdr_REMOVE4res(xdrs, &objp->nfs_resop4_u.opremove));
4114*7c478bd9Sstevel@tonic-gate 
4115*7c478bd9Sstevel@tonic-gate 	case OP_COMMIT:
4116*7c478bd9Sstevel@tonic-gate 		if (!xdr_int(xdrs,
4117*7c478bd9Sstevel@tonic-gate 			    (int32_t *)&objp->nfs_resop4_u.opcommit.status))
4118*7c478bd9Sstevel@tonic-gate 			return (FALSE);
4119*7c478bd9Sstevel@tonic-gate 		if (objp->nfs_resop4_u.opcommit.status != NFS4_OK)
4120*7c478bd9Sstevel@tonic-gate 			return (TRUE);
4121*7c478bd9Sstevel@tonic-gate 		return (xdr_u_longlong_t(xdrs,
4122*7c478bd9Sstevel@tonic-gate 				(u_longlong_t *)&objp->nfs_resop4_u.opcommit.
4123*7c478bd9Sstevel@tonic-gate 						writeverf));
4124*7c478bd9Sstevel@tonic-gate 	case OP_CREATE:
4125*7c478bd9Sstevel@tonic-gate 		return (xdr_CREATE4res(xdrs, &objp->nfs_resop4_u.opcreate));
4126*7c478bd9Sstevel@tonic-gate 	case OP_DELEGPURGE:
4127*7c478bd9Sstevel@tonic-gate 		return (xdr_int(xdrs,
4128*7c478bd9Sstevel@tonic-gate 			(int32_t *)&objp->nfs_resop4_u.opdelegpurge.status));
4129*7c478bd9Sstevel@tonic-gate 	case OP_LINK:
4130*7c478bd9Sstevel@tonic-gate 		return (xdr_LINK4res(xdrs, &objp->nfs_resop4_u.oplink));
4131*7c478bd9Sstevel@tonic-gate 	case OP_LOCK:
4132*7c478bd9Sstevel@tonic-gate 		return (xdr_LOCK4res(xdrs, &objp->nfs_resop4_u.oplock));
4133*7c478bd9Sstevel@tonic-gate 	case OP_LOCKT:
4134*7c478bd9Sstevel@tonic-gate 		return (xdr_LOCKT4res(xdrs, &objp->nfs_resop4_u.oplockt));
4135*7c478bd9Sstevel@tonic-gate 	case OP_LOCKU:
4136*7c478bd9Sstevel@tonic-gate 		if (!xdr_int(xdrs,
4137*7c478bd9Sstevel@tonic-gate 				(int32_t *)&objp->nfs_resop4_u.oplocku.status))
4138*7c478bd9Sstevel@tonic-gate 			return (FALSE);
4139*7c478bd9Sstevel@tonic-gate 		if (objp->nfs_resop4_u.oplocku.status != NFS4_OK)
4140*7c478bd9Sstevel@tonic-gate 			return (TRUE);
4141*7c478bd9Sstevel@tonic-gate 		if (!xdr_u_int(xdrs,
4142*7c478bd9Sstevel@tonic-gate 		    &objp->nfs_resop4_u.oplocku.lock_stateid.seqid))
4143*7c478bd9Sstevel@tonic-gate 			return (FALSE);
4144*7c478bd9Sstevel@tonic-gate 		return (xdr_opaque(xdrs,
4145*7c478bd9Sstevel@tonic-gate 		    objp->nfs_resop4_u.oplocku.lock_stateid.other,
4146*7c478bd9Sstevel@tonic-gate 		    12));
4147*7c478bd9Sstevel@tonic-gate 	case OP_OPENATTR:
4148*7c478bd9Sstevel@tonic-gate 		return (xdr_int(xdrs,
4149*7c478bd9Sstevel@tonic-gate 			(int32_t *)&objp->nfs_resop4_u.opopenattr.status));
4150*7c478bd9Sstevel@tonic-gate 	case OP_OPEN_CONFIRM:
4151*7c478bd9Sstevel@tonic-gate 		return (xdr_OPEN_CONFIRM4res(xdrs,
4152*7c478bd9Sstevel@tonic-gate 				&objp->nfs_resop4_u.opopen_confirm));
4153*7c478bd9Sstevel@tonic-gate 	case OP_OPEN_DOWNGRADE:
4154*7c478bd9Sstevel@tonic-gate 		return (xdr_OPEN_DOWNGRADE4res(xdrs,
4155*7c478bd9Sstevel@tonic-gate 				&objp->nfs_resop4_u.opopen_downgrade));
4156*7c478bd9Sstevel@tonic-gate 	case OP_PUTPUBFH:
4157*7c478bd9Sstevel@tonic-gate 		return (xdr_int(xdrs,
4158*7c478bd9Sstevel@tonic-gate 			(int32_t *)&objp->nfs_resop4_u.opputpubfh.status));
4159*7c478bd9Sstevel@tonic-gate 	case OP_PUTROOTFH:
4160*7c478bd9Sstevel@tonic-gate 		return (xdr_int(xdrs,
4161*7c478bd9Sstevel@tonic-gate 			(int32_t *)&objp->nfs_resop4_u.opputrootfh.status));
4162*7c478bd9Sstevel@tonic-gate 	case OP_READLINK:
4163*7c478bd9Sstevel@tonic-gate 		return (xdr_READLINK4res(xdrs, &objp->nfs_resop4_u.opreadlink));
4164*7c478bd9Sstevel@tonic-gate 	case OP_RENAME:
4165*7c478bd9Sstevel@tonic-gate 		return (xdr_RENAME4res(xdrs, &objp->nfs_resop4_u.oprename));
4166*7c478bd9Sstevel@tonic-gate 	case OP_RENEW:
4167*7c478bd9Sstevel@tonic-gate 		return (xdr_int(xdrs,
4168*7c478bd9Sstevel@tonic-gate 				(int32_t *)&objp->nfs_resop4_u.oprenew.status));
4169*7c478bd9Sstevel@tonic-gate 	case OP_RESTOREFH:
4170*7c478bd9Sstevel@tonic-gate 		return (xdr_int(xdrs,
4171*7c478bd9Sstevel@tonic-gate 			(int32_t *)&objp->nfs_resop4_u.oprestorefh.status));
4172*7c478bd9Sstevel@tonic-gate 	case OP_SAVEFH:
4173*7c478bd9Sstevel@tonic-gate 		return (xdr_int(xdrs,
4174*7c478bd9Sstevel@tonic-gate 			(int32_t *)&objp->nfs_resop4_u.opsavefh.status));
4175*7c478bd9Sstevel@tonic-gate 	case OP_SECINFO:
4176*7c478bd9Sstevel@tonic-gate 		if (!xdr_int(xdrs, (int32_t *)&objp->nfs_resop4_u.opsecinfo.
4177*7c478bd9Sstevel@tonic-gate 					status))
4178*7c478bd9Sstevel@tonic-gate 			return (FALSE);
4179*7c478bd9Sstevel@tonic-gate 		if (objp->nfs_resop4_u.opsecinfo.status != NFS4_OK)
4180*7c478bd9Sstevel@tonic-gate 			return (TRUE);
4181*7c478bd9Sstevel@tonic-gate 		return (xdr_array(xdrs, (char **)&objp->nfs_resop4_u.opsecinfo.
4182*7c478bd9Sstevel@tonic-gate 					SECINFO4resok_val,
4183*7c478bd9Sstevel@tonic-gate 			(uint_t *)&objp->nfs_resop4_u.opsecinfo.
4184*7c478bd9Sstevel@tonic-gate 					SECINFO4resok_len,
4185*7c478bd9Sstevel@tonic-gate 			~0, sizeof (secinfo4), (xdrproc_t)xdr_secinfo4));
4186*7c478bd9Sstevel@tonic-gate 	case OP_SETATTR:
4187*7c478bd9Sstevel@tonic-gate 		if (!xdr_int(xdrs, (int32_t *)&objp->nfs_resop4_u.opsetattr.
4188*7c478bd9Sstevel@tonic-gate 						status))
4189*7c478bd9Sstevel@tonic-gate 			return (FALSE);
4190*7c478bd9Sstevel@tonic-gate 		return (xdr_bitmap4(xdrs,
4191*7c478bd9Sstevel@tonic-gate 				&objp->nfs_resop4_u.opsetattr.attrsset));
4192*7c478bd9Sstevel@tonic-gate 	case OP_SETCLIENTID:
4193*7c478bd9Sstevel@tonic-gate 		return (xdr_SETCLIENTID4res(xdrs,
4194*7c478bd9Sstevel@tonic-gate 				&objp->nfs_resop4_u.opsetclientid));
4195*7c478bd9Sstevel@tonic-gate 	case OP_SETCLIENTID_CONFIRM:
4196*7c478bd9Sstevel@tonic-gate 		return (xdr_int(xdrs,
4197*7c478bd9Sstevel@tonic-gate 			(int32_t *)&objp->nfs_resop4_u.opsetclientid_confirm.
4198*7c478bd9Sstevel@tonic-gate 					status));
4199*7c478bd9Sstevel@tonic-gate 	case OP_VERIFY:
4200*7c478bd9Sstevel@tonic-gate 		return (xdr_int(xdrs,
4201*7c478bd9Sstevel@tonic-gate 			(int32_t *)&objp->nfs_resop4_u.opverify.status));
4202*7c478bd9Sstevel@tonic-gate 	case OP_RELEASE_LOCKOWNER:
4203*7c478bd9Sstevel@tonic-gate 		return (xdr_int(xdrs,
4204*7c478bd9Sstevel@tonic-gate 		    (int32_t *)&objp->nfs_resop4_u.oprelease_lockowner.status));
4205*7c478bd9Sstevel@tonic-gate 	case OP_ILLEGAL:
4206*7c478bd9Sstevel@tonic-gate 		return (xdr_int(xdrs,
4207*7c478bd9Sstevel@tonic-gate 			(int32_t *)&objp->nfs_resop4_u.opillegal.status));
4208*7c478bd9Sstevel@tonic-gate 	}
4209*7c478bd9Sstevel@tonic-gate 	return (FALSE);
4210*7c478bd9Sstevel@tonic-gate }
4211*7c478bd9Sstevel@tonic-gate 
4212*7c478bd9Sstevel@tonic-gate bool_t
4213*7c478bd9Sstevel@tonic-gate xdr_COMPOUND4args_clnt(XDR *xdrs, COMPOUND4args_clnt *objp)
4214*7c478bd9Sstevel@tonic-gate {
4215*7c478bd9Sstevel@tonic-gate 	static int32_t twelve = 12;
4216*7c478bd9Sstevel@tonic-gate 	static int32_t minorversion = NFS4_MINORVERSION;
4217*7c478bd9Sstevel@tonic-gate 	uint32_t *ctagp;
4218*7c478bd9Sstevel@tonic-gate 	rpc_inline_t *ptr;
4219*7c478bd9Sstevel@tonic-gate 
4220*7c478bd9Sstevel@tonic-gate 	/*
4221*7c478bd9Sstevel@tonic-gate 	 * XDR_ENCODE only
4222*7c478bd9Sstevel@tonic-gate 	 */
4223*7c478bd9Sstevel@tonic-gate 	if (xdrs->x_op == XDR_FREE)
4224*7c478bd9Sstevel@tonic-gate 		return (TRUE);
4225*7c478bd9Sstevel@tonic-gate 	if (xdrs->x_op == XDR_DECODE)
4226*7c478bd9Sstevel@tonic-gate 		return (FALSE);
4227*7c478bd9Sstevel@tonic-gate 
4228*7c478bd9Sstevel@tonic-gate 	ctagp = (uint32_t *)&nfs4_ctags[objp->ctag].ct_tag;
4229*7c478bd9Sstevel@tonic-gate 
4230*7c478bd9Sstevel@tonic-gate 	if ((ptr = XDR_INLINE(xdrs, 5 * BYTES_PER_XDR_UNIT)) != NULL) {
4231*7c478bd9Sstevel@tonic-gate 		/*
4232*7c478bd9Sstevel@tonic-gate 		 * Efficiently encode fixed length tags, could be longlongs
4233*7c478bd9Sstevel@tonic-gate 		 * but 8 byte XDR alignment not assured
4234*7c478bd9Sstevel@tonic-gate 		 */
4235*7c478bd9Sstevel@tonic-gate 		IXDR_PUT_U_INT32(ptr, 12);
4236*7c478bd9Sstevel@tonic-gate 		IXDR_PUT_U_INT32(ptr, ctagp[0]);
4237*7c478bd9Sstevel@tonic-gate 		IXDR_PUT_U_INT32(ptr, ctagp[1]);
4238*7c478bd9Sstevel@tonic-gate 		IXDR_PUT_U_INT32(ptr, ctagp[2]);
4239*7c478bd9Sstevel@tonic-gate 
4240*7c478bd9Sstevel@tonic-gate 		/*
4241*7c478bd9Sstevel@tonic-gate 		 * Fixed minor version for now
4242*7c478bd9Sstevel@tonic-gate 		 */
4243*7c478bd9Sstevel@tonic-gate 		IXDR_PUT_U_INT32(ptr, NFS4_MINORVERSION);
4244*7c478bd9Sstevel@tonic-gate 	} else {
4245*7c478bd9Sstevel@tonic-gate 		if (!XDR_PUTINT32(xdrs, &twelve))
4246*7c478bd9Sstevel@tonic-gate 			return (FALSE);
4247*7c478bd9Sstevel@tonic-gate 		if (!XDR_PUTINT32(xdrs, (int32_t *)&ctagp[0]))
4248*7c478bd9Sstevel@tonic-gate 			return (FALSE);
4249*7c478bd9Sstevel@tonic-gate 		if (!XDR_PUTINT32(xdrs, (int32_t *)&ctagp[1]))
4250*7c478bd9Sstevel@tonic-gate 			return (FALSE);
4251*7c478bd9Sstevel@tonic-gate 		if (!XDR_PUTINT32(xdrs, (int32_t *)&ctagp[2]))
4252*7c478bd9Sstevel@tonic-gate 			return (FALSE);
4253*7c478bd9Sstevel@tonic-gate 		if (!XDR_PUTINT32(xdrs, (int32_t *)&minorversion))
4254*7c478bd9Sstevel@tonic-gate 			return (FALSE);
4255*7c478bd9Sstevel@tonic-gate 	}
4256*7c478bd9Sstevel@tonic-gate 
4257*7c478bd9Sstevel@tonic-gate 	return (xdr_array(xdrs, (char **)&objp->array,
4258*7c478bd9Sstevel@tonic-gate 			(uint_t *)&objp->array_len, NFS4_COMPOUND_LIMIT,
4259*7c478bd9Sstevel@tonic-gate 			sizeof (nfs_argop4), (xdrproc_t)xdr_cnfs_argop4));
4260*7c478bd9Sstevel@tonic-gate }
4261*7c478bd9Sstevel@tonic-gate 
4262*7c478bd9Sstevel@tonic-gate bool_t
4263*7c478bd9Sstevel@tonic-gate xdr_COMPOUND4args(XDR *xdrs, COMPOUND4args *objp)
4264*7c478bd9Sstevel@tonic-gate {
4265*7c478bd9Sstevel@tonic-gate 	if (!xdr_bytes(xdrs, (char **)&objp->tag.utf8string_val,
4266*7c478bd9Sstevel@tonic-gate 			(uint_t *)&objp->tag.utf8string_len,
4267*7c478bd9Sstevel@tonic-gate 			NFS4_MAX_UTF8STRING))
4268*7c478bd9Sstevel@tonic-gate 		return (FALSE);
4269*7c478bd9Sstevel@tonic-gate 	if (!xdr_u_int(xdrs, &objp->minorversion))
4270*7c478bd9Sstevel@tonic-gate 		return (FALSE);
4271*7c478bd9Sstevel@tonic-gate 	if (xdrs->x_op != XDR_FREE)
4272*7c478bd9Sstevel@tonic-gate 		return (xdr_array(xdrs, (char **)&objp->array,
4273*7c478bd9Sstevel@tonic-gate 			(uint_t *)&objp->array_len, NFS4_COMPOUND_LIMIT,
4274*7c478bd9Sstevel@tonic-gate 			sizeof (nfs_argop4), (xdrproc_t)xdr_nfs_argop4));
4275*7c478bd9Sstevel@tonic-gate 
4276*7c478bd9Sstevel@tonic-gate 	return (xdr_nfs_argop4_free(xdrs, &objp->array, objp->array_len));
4277*7c478bd9Sstevel@tonic-gate }
4278*7c478bd9Sstevel@tonic-gate 
4279*7c478bd9Sstevel@tonic-gate bool_t
4280*7c478bd9Sstevel@tonic-gate xdr_COMPOUND4res_clnt(XDR *xdrs, COMPOUND4res_clnt *objp)
4281*7c478bd9Sstevel@tonic-gate {
4282*7c478bd9Sstevel@tonic-gate 	uint32_t len;
4283*7c478bd9Sstevel@tonic-gate 	int32_t *ptr;
4284*7c478bd9Sstevel@tonic-gate 	nfs_argop4 *argop;
4285*7c478bd9Sstevel@tonic-gate 	nfs_resop4 *resop;
4286*7c478bd9Sstevel@tonic-gate 
4287*7c478bd9Sstevel@tonic-gate 	/*
4288*7c478bd9Sstevel@tonic-gate 	 * No XDR_ENCODE
4289*7c478bd9Sstevel@tonic-gate 	 */
4290*7c478bd9Sstevel@tonic-gate 	if (xdrs->x_op == XDR_ENCODE)
4291*7c478bd9Sstevel@tonic-gate 		return (FALSE);
4292*7c478bd9Sstevel@tonic-gate 
4293*7c478bd9Sstevel@tonic-gate 	if (xdrs->x_op != XDR_FREE) {
4294*7c478bd9Sstevel@tonic-gate 		if ((ptr = XDR_INLINE(xdrs, 2 * BYTES_PER_XDR_UNIT)) != NULL) {
4295*7c478bd9Sstevel@tonic-gate 			objp->status = IXDR_GET_U_INT32(ptr);
4296*7c478bd9Sstevel@tonic-gate 			len = IXDR_GET_U_INT32(ptr);
4297*7c478bd9Sstevel@tonic-gate 		} else {
4298*7c478bd9Sstevel@tonic-gate 			if (!xdr_int(xdrs, (int32_t *)&objp->status))
4299*7c478bd9Sstevel@tonic-gate 				return (FALSE);
4300*7c478bd9Sstevel@tonic-gate 			if (!xdr_u_int(xdrs, (uint32_t *)&len))
4301*7c478bd9Sstevel@tonic-gate 				return (FALSE);
4302*7c478bd9Sstevel@tonic-gate 		}
4303*7c478bd9Sstevel@tonic-gate 		if (len > NFS4_MAX_UTF8STRING)
4304*7c478bd9Sstevel@tonic-gate 			return (FALSE);
4305*7c478bd9Sstevel@tonic-gate 		/*
4306*7c478bd9Sstevel@tonic-gate 		 * Ignore the tag
4307*7c478bd9Sstevel@tonic-gate 		 */
4308*7c478bd9Sstevel@tonic-gate 		if (!XDR_CONTROL(xdrs, XDR_SKIPBYTES, &len))
4309*7c478bd9Sstevel@tonic-gate 			return (FALSE);
4310*7c478bd9Sstevel@tonic-gate 
4311*7c478bd9Sstevel@tonic-gate 		if (!xdr_int(xdrs, (int32_t *)&objp->array_len))
4312*7c478bd9Sstevel@tonic-gate 			return (FALSE);
4313*7c478bd9Sstevel@tonic-gate 
4314*7c478bd9Sstevel@tonic-gate 		if (objp->array_len > objp->argsp->array_len)
4315*7c478bd9Sstevel@tonic-gate 			return (FALSE);
4316*7c478bd9Sstevel@tonic-gate 
4317*7c478bd9Sstevel@tonic-gate 		if (objp->status == NFS_OK &&
4318*7c478bd9Sstevel@tonic-gate 		    objp->array_len != objp->argsp->array_len)
4319*7c478bd9Sstevel@tonic-gate 			return (FALSE);
4320*7c478bd9Sstevel@tonic-gate 
4321*7c478bd9Sstevel@tonic-gate 		/* Alloc the results array */
4322*7c478bd9Sstevel@tonic-gate 		argop = objp->argsp->array;
4323*7c478bd9Sstevel@tonic-gate 		len = objp->array_len * sizeof (nfs_resop4);
4324*7c478bd9Sstevel@tonic-gate 		objp->decode_len = 0;
4325*7c478bd9Sstevel@tonic-gate 		objp->array = resop = kmem_zalloc(len, KM_SLEEP);
4326*7c478bd9Sstevel@tonic-gate 
4327*7c478bd9Sstevel@tonic-gate 		for (len = 0; len < objp->array_len;
4328*7c478bd9Sstevel@tonic-gate 			len++, resop++, argop++, objp->decode_len++) {
4329*7c478bd9Sstevel@tonic-gate 			if (!xdr_nfs_resop4_clnt(xdrs, resop, argop)) {
4330*7c478bd9Sstevel@tonic-gate 				/*
4331*7c478bd9Sstevel@tonic-gate 				 * Make sure to free anything that may
4332*7c478bd9Sstevel@tonic-gate 				 * have been allocated along the way.
4333*7c478bd9Sstevel@tonic-gate 				 */
4334*7c478bd9Sstevel@tonic-gate 				xdrs->x_op = XDR_FREE;
4335*7c478bd9Sstevel@tonic-gate 				(void) xdr_nfs_resop4_free(xdrs, &objp->array,
4336*7c478bd9Sstevel@tonic-gate 							    objp->array_len,
4337*7c478bd9Sstevel@tonic-gate 							    objp->decode_len);
4338*7c478bd9Sstevel@tonic-gate 				return (FALSE);
4339*7c478bd9Sstevel@tonic-gate 			}
4340*7c478bd9Sstevel@tonic-gate 		}
4341*7c478bd9Sstevel@tonic-gate 		return (TRUE);
4342*7c478bd9Sstevel@tonic-gate 	}
4343*7c478bd9Sstevel@tonic-gate 	return (xdr_nfs_resop4_free(xdrs, &objp->array,
4344*7c478bd9Sstevel@tonic-gate 				    objp->array_len, objp->decode_len));
4345*7c478bd9Sstevel@tonic-gate }
4346*7c478bd9Sstevel@tonic-gate 
4347*7c478bd9Sstevel@tonic-gate bool_t
4348*7c478bd9Sstevel@tonic-gate xdr_COMPOUND4res(XDR *xdrs, COMPOUND4res *objp)
4349*7c478bd9Sstevel@tonic-gate {
4350*7c478bd9Sstevel@tonic-gate 	if (!xdr_int(xdrs, (int32_t *)&objp->status))
4351*7c478bd9Sstevel@tonic-gate 		return (FALSE);
4352*7c478bd9Sstevel@tonic-gate 	if (!xdr_bytes(xdrs, (char **)&objp->tag.utf8string_val,
4353*7c478bd9Sstevel@tonic-gate 			(uint_t *)&objp->tag.utf8string_len,
4354*7c478bd9Sstevel@tonic-gate 			NFS4_MAX_UTF8STRING))
4355*7c478bd9Sstevel@tonic-gate 		return (FALSE);
4356*7c478bd9Sstevel@tonic-gate 
4357*7c478bd9Sstevel@tonic-gate 	if (xdrs->x_op != XDR_FREE)
4358*7c478bd9Sstevel@tonic-gate 		return (xdr_array(xdrs, (char **)&objp->array,
4359*7c478bd9Sstevel@tonic-gate 			(uint_t *)&objp->array_len, NFS4_COMPOUND_LIMIT,
4360*7c478bd9Sstevel@tonic-gate 			sizeof (nfs_resop4), (xdrproc_t)xdr_nfs_resop4));
4361*7c478bd9Sstevel@tonic-gate 
4362*7c478bd9Sstevel@tonic-gate 	return (xdr_nfs_resop4_free(xdrs, &objp->array,
4363*7c478bd9Sstevel@tonic-gate 				    objp->array_len, objp->array_len));
4364*7c478bd9Sstevel@tonic-gate }
4365*7c478bd9Sstevel@tonic-gate 
4366*7c478bd9Sstevel@tonic-gate static bool_t
4367*7c478bd9Sstevel@tonic-gate xdr_nfs_cb_argop4(XDR *xdrs, nfs_cb_argop4 *objp)
4368*7c478bd9Sstevel@tonic-gate {
4369*7c478bd9Sstevel@tonic-gate 	if (!xdr_u_int(xdrs, &objp->argop))
4370*7c478bd9Sstevel@tonic-gate 		return (FALSE);
4371*7c478bd9Sstevel@tonic-gate 	switch (objp->argop) {
4372*7c478bd9Sstevel@tonic-gate 	case OP_CB_GETATTR:
4373*7c478bd9Sstevel@tonic-gate 		if (!xdr_bytes(xdrs,
4374*7c478bd9Sstevel@tonic-gate 		    (char **)&objp->nfs_cb_argop4_u.opcbgetattr.fh.nfs_fh4_val,
4375*7c478bd9Sstevel@tonic-gate 		    (uint_t *)&objp->nfs_cb_argop4_u.opcbgetattr.fh.nfs_fh4_len,
4376*7c478bd9Sstevel@tonic-gate 		    NFS4_FHSIZE))
4377*7c478bd9Sstevel@tonic-gate 			return (FALSE);
4378*7c478bd9Sstevel@tonic-gate 		return (xdr_bitmap4(xdrs,
4379*7c478bd9Sstevel@tonic-gate 			&objp->nfs_cb_argop4_u.opcbgetattr.attr_request));
4380*7c478bd9Sstevel@tonic-gate 	case OP_CB_RECALL:
4381*7c478bd9Sstevel@tonic-gate 		if (!xdr_u_int(xdrs,
4382*7c478bd9Sstevel@tonic-gate 			    &objp->nfs_cb_argop4_u.opcbrecall.stateid.seqid))
4383*7c478bd9Sstevel@tonic-gate 			return (FALSE);
4384*7c478bd9Sstevel@tonic-gate 		if (!xdr_opaque(xdrs,
4385*7c478bd9Sstevel@tonic-gate 			    objp->nfs_cb_argop4_u.opcbrecall.stateid.other,
4386*7c478bd9Sstevel@tonic-gate 			    12))
4387*7c478bd9Sstevel@tonic-gate 			return (FALSE);
4388*7c478bd9Sstevel@tonic-gate 		if (!xdr_bool(xdrs,
4389*7c478bd9Sstevel@tonic-gate 				&objp->nfs_cb_argop4_u.opcbrecall.truncate))
4390*7c478bd9Sstevel@tonic-gate 			return (FALSE);
4391*7c478bd9Sstevel@tonic-gate 		return (xdr_bytes(xdrs,
4392*7c478bd9Sstevel@tonic-gate 		    (char **)&objp->nfs_cb_argop4_u.opcbrecall.fh.nfs_fh4_val,
4393*7c478bd9Sstevel@tonic-gate 		    (uint_t *)&objp->nfs_cb_argop4_u.opcbrecall.fh.nfs_fh4_len,
4394*7c478bd9Sstevel@tonic-gate 		    NFS4_FHSIZE));
4395*7c478bd9Sstevel@tonic-gate 	case OP_CB_ILLEGAL:
4396*7c478bd9Sstevel@tonic-gate 		return (TRUE);
4397*7c478bd9Sstevel@tonic-gate 	}
4398*7c478bd9Sstevel@tonic-gate 	return (FALSE);
4399*7c478bd9Sstevel@tonic-gate }
4400*7c478bd9Sstevel@tonic-gate 
4401*7c478bd9Sstevel@tonic-gate static bool_t
4402*7c478bd9Sstevel@tonic-gate xdr_nfs_cb_resop4(XDR *xdrs, nfs_cb_resop4 *objp)
4403*7c478bd9Sstevel@tonic-gate {
4404*7c478bd9Sstevel@tonic-gate 	if (!xdr_u_int(xdrs, &objp->resop))
4405*7c478bd9Sstevel@tonic-gate 		return (FALSE);
4406*7c478bd9Sstevel@tonic-gate 	switch (objp->resop) {
4407*7c478bd9Sstevel@tonic-gate 	case OP_CB_GETATTR:
4408*7c478bd9Sstevel@tonic-gate 		if (!xdr_int(xdrs,
4409*7c478bd9Sstevel@tonic-gate 				(int32_t *)&objp->nfs_cb_resop4_u.opcbgetattr.
4410*7c478bd9Sstevel@tonic-gate 				    status))
4411*7c478bd9Sstevel@tonic-gate 			return (FALSE);
4412*7c478bd9Sstevel@tonic-gate 		if (objp->nfs_cb_resop4_u.opcbgetattr.status != NFS4_OK)
4413*7c478bd9Sstevel@tonic-gate 			return (TRUE);
4414*7c478bd9Sstevel@tonic-gate 		return (xdr_fattr4(xdrs,
4415*7c478bd9Sstevel@tonic-gate 				&objp->nfs_cb_resop4_u.opcbgetattr.
4416*7c478bd9Sstevel@tonic-gate 				    obj_attributes));
4417*7c478bd9Sstevel@tonic-gate 	case OP_CB_RECALL:
4418*7c478bd9Sstevel@tonic-gate 		return (xdr_int(xdrs,
4419*7c478bd9Sstevel@tonic-gate 			(int32_t *)&objp->nfs_cb_resop4_u.opcbrecall.status));
4420*7c478bd9Sstevel@tonic-gate 	case OP_CB_ILLEGAL:
4421*7c478bd9Sstevel@tonic-gate 		return (xdr_int(xdrs,
4422*7c478bd9Sstevel@tonic-gate 			(int32_t *)&objp->nfs_cb_resop4_u.opcbillegal.status));
4423*7c478bd9Sstevel@tonic-gate 	}
4424*7c478bd9Sstevel@tonic-gate 	return (FALSE);
4425*7c478bd9Sstevel@tonic-gate }
4426*7c478bd9Sstevel@tonic-gate 
4427*7c478bd9Sstevel@tonic-gate bool_t
4428*7c478bd9Sstevel@tonic-gate xdr_CB_COMPOUND4args(XDR *xdrs, CB_COMPOUND4args *objp)
4429*7c478bd9Sstevel@tonic-gate {
4430*7c478bd9Sstevel@tonic-gate 	if (!xdr_bytes(xdrs, (char **)&objp->tag.utf8string_val,
4431*7c478bd9Sstevel@tonic-gate 			(uint_t *)&objp->tag.utf8string_len,
4432*7c478bd9Sstevel@tonic-gate 			NFS4_MAX_UTF8STRING))
4433*7c478bd9Sstevel@tonic-gate 		return (FALSE);
4434*7c478bd9Sstevel@tonic-gate 	if (!xdr_u_int(xdrs, &objp->minorversion))
4435*7c478bd9Sstevel@tonic-gate 		return (FALSE);
4436*7c478bd9Sstevel@tonic-gate 	if (!xdr_u_int(xdrs, &objp->callback_ident))
4437*7c478bd9Sstevel@tonic-gate 		return (FALSE);
4438*7c478bd9Sstevel@tonic-gate 	return (xdr_array(xdrs, (char **)&objp->array,
4439*7c478bd9Sstevel@tonic-gate 			(uint_t *)&objp->array_len, NFS4_COMPOUND_LIMIT,
4440*7c478bd9Sstevel@tonic-gate 			sizeof (nfs_cb_argop4), (xdrproc_t)xdr_nfs_cb_argop4));
4441*7c478bd9Sstevel@tonic-gate }
4442*7c478bd9Sstevel@tonic-gate 
4443*7c478bd9Sstevel@tonic-gate bool_t
4444*7c478bd9Sstevel@tonic-gate xdr_CB_COMPOUND4res(XDR *xdrs, CB_COMPOUND4res *objp)
4445*7c478bd9Sstevel@tonic-gate {
4446*7c478bd9Sstevel@tonic-gate 	if (!xdr_int(xdrs, (int32_t *)&objp->status))
4447*7c478bd9Sstevel@tonic-gate 		return (FALSE);
4448*7c478bd9Sstevel@tonic-gate 	if (!xdr_bytes(xdrs, (char **)&objp->tag.utf8string_val,
4449*7c478bd9Sstevel@tonic-gate 			(uint_t *)&objp->tag.utf8string_len,
4450*7c478bd9Sstevel@tonic-gate 			NFS4_MAX_UTF8STRING))
4451*7c478bd9Sstevel@tonic-gate 		return (FALSE);
4452*7c478bd9Sstevel@tonic-gate 	return (xdr_array(xdrs, (char **)&objp->array,
4453*7c478bd9Sstevel@tonic-gate 			(uint_t *)&objp->array_len, NFS4_COMPOUND_LIMIT,
4454*7c478bd9Sstevel@tonic-gate 			sizeof (nfs_cb_resop4), (xdrproc_t)xdr_nfs_cb_resop4));
4455*7c478bd9Sstevel@tonic-gate }
4456