1*0Sstevel@tonic-gate /*
2*0Sstevel@tonic-gate * CDDL HEADER START
3*0Sstevel@tonic-gate *
4*0Sstevel@tonic-gate * The contents of this file are subject to the terms of the
5*0Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only
6*0Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance
7*0Sstevel@tonic-gate * with the License.
8*0Sstevel@tonic-gate *
9*0Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10*0Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing.
11*0Sstevel@tonic-gate * See the License for the specific language governing permissions
12*0Sstevel@tonic-gate * and limitations under the License.
13*0Sstevel@tonic-gate *
14*0Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each
15*0Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16*0Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the
17*0Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying
18*0Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner]
19*0Sstevel@tonic-gate *
20*0Sstevel@tonic-gate * CDDL HEADER END
21*0Sstevel@tonic-gate */
22*0Sstevel@tonic-gate /*
23*0Sstevel@tonic-gate * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
24*0Sstevel@tonic-gate * Use is subject to license terms.
25*0Sstevel@tonic-gate */
26*0Sstevel@tonic-gate
27*0Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI"
28*0Sstevel@tonic-gate
29*0Sstevel@tonic-gate #include <sys/salib.h>
30*0Sstevel@tonic-gate #include <rpc/types.h>
31*0Sstevel@tonic-gate #include <rpc/xdr.h>
32*0Sstevel@tonic-gate #include <rpc/rpc.h>
33*0Sstevel@tonic-gate #include <rpcsvc/nfs4_prot.h>
34*0Sstevel@tonic-gate #include "nfs_inet.h"
35*0Sstevel@tonic-gate
36*0Sstevel@tonic-gate #define dprintf if (boothowto & RB_DEBUG) printf
37*0Sstevel@tonic-gate
38*0Sstevel@tonic-gate /*
39*0Sstevel@tonic-gate * XDR routines for NFSv4 ops.
40*0Sstevel@tonic-gate */
41*0Sstevel@tonic-gate static bool_t
xdr_b_utf8string(XDR * xdrs,utf8string * objp)42*0Sstevel@tonic-gate xdr_b_utf8string(XDR *xdrs, utf8string *objp)
43*0Sstevel@tonic-gate {
44*0Sstevel@tonic-gate return (xdr_bytes(xdrs, (char **)&objp->utf8string_val,
45*0Sstevel@tonic-gate (uint_t *)&objp->utf8string_len, NFS4_MAX_UTF8STRING));
46*0Sstevel@tonic-gate }
47*0Sstevel@tonic-gate
48*0Sstevel@tonic-gate static bool_t
xdr_nfs_bfh4(XDR * xdrs,struct nfs_bfh4 * objp)49*0Sstevel@tonic-gate xdr_nfs_bfh4(XDR *xdrs, struct nfs_bfh4 *objp)
50*0Sstevel@tonic-gate {
51*0Sstevel@tonic-gate char *data = (char *)&objp->data;
52*0Sstevel@tonic-gate return (xdr_bytes(xdrs, (char **)&data, (uint_t *)&objp->len,
53*0Sstevel@tonic-gate NFS4_FHSIZE));
54*0Sstevel@tonic-gate }
55*0Sstevel@tonic-gate
56*0Sstevel@tonic-gate static bool_t
xdr_b_putfh4_args(XDR * xdrs,putfh4arg_t * objp)57*0Sstevel@tonic-gate xdr_b_putfh4_args(XDR *xdrs, putfh4arg_t *objp)
58*0Sstevel@tonic-gate {
59*0Sstevel@tonic-gate if (!xdr_u_int(xdrs, (uint_t *)&objp->pf_opnum))
60*0Sstevel@tonic-gate return (FALSE);
61*0Sstevel@tonic-gate return (xdr_nfs_bfh4(xdrs, (struct nfs_bfh4 *)&objp->pf_filehandle));
62*0Sstevel@tonic-gate }
63*0Sstevel@tonic-gate
64*0Sstevel@tonic-gate /*
65*0Sstevel@tonic-gate * Common xdr routines for compound. Let the specific op routines handle
66*0Sstevel@tonic-gate * op specific portions of the compound.
67*0Sstevel@tonic-gate */
68*0Sstevel@tonic-gate static bool_t
xdr_b_compound_args(XDR * xdrs,b_compound_t * objp)69*0Sstevel@tonic-gate xdr_b_compound_args(XDR *xdrs, b_compound_t *objp)
70*0Sstevel@tonic-gate {
71*0Sstevel@tonic-gate if (!xdr_b_utf8string(xdrs, &objp->ca_tag)) {
72*0Sstevel@tonic-gate return (FALSE);
73*0Sstevel@tonic-gate }
74*0Sstevel@tonic-gate if (!xdr_u_int(xdrs, &objp->ca_minorversion))
75*0Sstevel@tonic-gate return (FALSE);
76*0Sstevel@tonic-gate if (!xdr_u_int(xdrs, &objp->ca_argarray_len))
77*0Sstevel@tonic-gate return (FALSE);
78*0Sstevel@tonic-gate if (objp->ca_isputrootfh)
79*0Sstevel@tonic-gate return (xdr_u_int(xdrs, &objp->ca_opputfh.pf_opnum));
80*0Sstevel@tonic-gate return (xdr_b_putfh4_args(xdrs, &objp->ca_opputfh));
81*0Sstevel@tonic-gate }
82*0Sstevel@tonic-gate
83*0Sstevel@tonic-gate static bool_t
xdr_b_compound_res(XDR * xdrs,b_compound_t * objp)84*0Sstevel@tonic-gate xdr_b_compound_res(XDR *xdrs, b_compound_t *objp)
85*0Sstevel@tonic-gate {
86*0Sstevel@tonic-gate if (!xdr_enum(xdrs, (enum_t *)&objp->cr_status))
87*0Sstevel@tonic-gate return (FALSE);
88*0Sstevel@tonic-gate if (!xdr_b_utf8string(xdrs, &objp->cr_tag))
89*0Sstevel@tonic-gate return (FALSE);
90*0Sstevel@tonic-gate if (!xdr_u_int(xdrs, &objp->cr_resarray_len))
91*0Sstevel@tonic-gate return (FALSE);
92*0Sstevel@tonic-gate if (!xdr_u_int(xdrs, &objp->cr_opputfh))
93*0Sstevel@tonic-gate return (FALSE);
94*0Sstevel@tonic-gate return (xdr_enum(xdrs, (enum_t *)&objp->cr_putfh_status));
95*0Sstevel@tonic-gate }
96*0Sstevel@tonic-gate
97*0Sstevel@tonic-gate static bool_t
xdr_b_bitmap4(XDR * xdrs,b_bitmap4_t * objp)98*0Sstevel@tonic-gate xdr_b_bitmap4(XDR *xdrs, b_bitmap4_t *objp)
99*0Sstevel@tonic-gate {
100*0Sstevel@tonic-gate char *arp = (char *)&objp->b_bitmap_val;
101*0Sstevel@tonic-gate return (xdr_array(xdrs, (char **)&arp,
102*0Sstevel@tonic-gate (uint_t *)&objp->b_bitmap_len, ~0,
103*0Sstevel@tonic-gate sizeof (uint_t), (xdrproc_t)xdr_u_int));
104*0Sstevel@tonic-gate }
105*0Sstevel@tonic-gate
106*0Sstevel@tonic-gate static bool_t
xdr_b_stateid4(XDR * xdrs,stateid4 * objp)107*0Sstevel@tonic-gate xdr_b_stateid4(XDR *xdrs, stateid4 *objp)
108*0Sstevel@tonic-gate {
109*0Sstevel@tonic-gate if (!xdr_u_int(xdrs, (uint_t *)&objp->seqid))
110*0Sstevel@tonic-gate return (FALSE);
111*0Sstevel@tonic-gate return (xdr_opaque(xdrs, objp->other, 12));
112*0Sstevel@tonic-gate }
113*0Sstevel@tonic-gate
114*0Sstevel@tonic-gate bool_t
xdr_getattr4_args(XDR * xdrs,getattr4arg_t * objp)115*0Sstevel@tonic-gate xdr_getattr4_args(XDR *xdrs, getattr4arg_t *objp)
116*0Sstevel@tonic-gate {
117*0Sstevel@tonic-gate if (!xdr_b_compound_args(xdrs, (b_compound_t *)&objp->ga_arg))
118*0Sstevel@tonic-gate return (FALSE);
119*0Sstevel@tonic-gate if (!xdr_u_int(xdrs, (uint_t *)&objp->ga_opgetattr))
120*0Sstevel@tonic-gate return (FALSE);
121*0Sstevel@tonic-gate return (xdr_b_bitmap4(xdrs, (b_bitmap4_t *)&objp->ga_attr_req));
122*0Sstevel@tonic-gate }
123*0Sstevel@tonic-gate
124*0Sstevel@tonic-gate static bool_t
xdr_b_getattr_res_common(XDR * xdrs,getattrres_cmn_t * objp)125*0Sstevel@tonic-gate xdr_b_getattr_res_common(XDR *xdrs, getattrres_cmn_t *objp)
126*0Sstevel@tonic-gate {
127*0Sstevel@tonic-gate if (!xdr_u_int(xdrs, (uint_t *)&objp->gc_opgetattr))
128*0Sstevel@tonic-gate return (FALSE);
129*0Sstevel@tonic-gate if (!xdr_enum(xdrs, (enum_t *)&objp->gc_attr_status))
130*0Sstevel@tonic-gate return (FALSE);
131*0Sstevel@tonic-gate
132*0Sstevel@tonic-gate /*
133*0Sstevel@tonic-gate * If the getattr suceeded, proceed and begin to decode the attributes.
134*0Sstevel@tonic-gate */
135*0Sstevel@tonic-gate if (objp->gc_attr_status == NFS4_OK) {
136*0Sstevel@tonic-gate char attrvals[sizeof (b_fattr4_t)];
137*0Sstevel@tonic-gate char *ap = attrvals;
138*0Sstevel@tonic-gate
139*0Sstevel@tonic-gate if (!xdr_b_bitmap4(xdrs, (b_bitmap4_t *)&objp->gc_retattr))
140*0Sstevel@tonic-gate return (FALSE);
141*0Sstevel@tonic-gate
142*0Sstevel@tonic-gate bzero(&attrvals, sizeof (attrvals));
143*0Sstevel@tonic-gate if (!xdr_bytes(xdrs, (char **)&ap,
144*0Sstevel@tonic-gate (uint_t *)&objp->gc_attrlist_len,
145*0Sstevel@tonic-gate sizeof (b_fattr4_t)))
146*0Sstevel@tonic-gate return (FALSE);
147*0Sstevel@tonic-gate #ifdef DEBUG
148*0Sstevel@tonic-gate printf("xdr_b_getattr_res_common: attrlist_len = %d\n",
149*0Sstevel@tonic-gate objp->gc_attrlist_len);
150*0Sstevel@tonic-gate #endif
151*0Sstevel@tonic-gate /*
152*0Sstevel@tonic-gate * Go through the bitmap and see if the server
153*0Sstevel@tonic-gate * sent us anything.
154*0Sstevel@tonic-gate */
155*0Sstevel@tonic-gate if (objp->gc_attrlist_len > 0) {
156*0Sstevel@tonic-gate XDR mxdrs;
157*0Sstevel@tonic-gate b_fattr4_t *fattrp = &objp->gc_attrs;
158*0Sstevel@tonic-gate attr4_bitmap1_t bitmap1;
159*0Sstevel@tonic-gate attr4_bitmap2_t bitmap2;
160*0Sstevel@tonic-gate #ifdef DEBUG
161*0Sstevel@tonic-gate int i;
162*0Sstevel@tonic-gate
163*0Sstevel@tonic-gate printf("dumping contents of attr buffer\n");
164*0Sstevel@tonic-gate for (i = 0; i < objp->gc_attrlist_len; i++) {
165*0Sstevel@tonic-gate printf("[%d] = 0x%x\n", i, ap[i]);
166*0Sstevel@tonic-gate }
167*0Sstevel@tonic-gate #endif
168*0Sstevel@tonic-gate bitmap1.word = objp->gc_retattr.b_bitmap_val[0];
169*0Sstevel@tonic-gate bitmap2.word = objp->gc_retattr.b_bitmap_val[1];
170*0Sstevel@tonic-gate
171*0Sstevel@tonic-gate #ifdef DEBUG
172*0Sstevel@tonic-gate printf("xdr_b_getattr_res_common: bitmap1 = %d "
173*0Sstevel@tonic-gate " bitmap2 = %d\n",
174*0Sstevel@tonic-gate bitmap1.word, bitmap2.word);
175*0Sstevel@tonic-gate #endif
176*0Sstevel@tonic-gate xdrmem_create(&mxdrs, ap, objp->gc_attrlist_len,
177*0Sstevel@tonic-gate XDR_DECODE);
178*0Sstevel@tonic-gate
179*0Sstevel@tonic-gate /*
180*0Sstevel@tonic-gate * Start with the first bitmap
181*0Sstevel@tonic-gate */
182*0Sstevel@tonic-gate if (bitmap1.word > 0) {
183*0Sstevel@tonic-gate if (bitmap1.bm_supported_attrs) {
184*0Sstevel@tonic-gate if (!xdr_b_bitmap4(&mxdrs,
185*0Sstevel@tonic-gate (b_bitmap4_t *)&fattrp->b_supported_attrs))
186*0Sstevel@tonic-gate return (FALSE);
187*0Sstevel@tonic-gate }
188*0Sstevel@tonic-gate
189*0Sstevel@tonic-gate if (bitmap1.bm_fattr4_type) {
190*0Sstevel@tonic-gate if (!xdr_enum(&mxdrs,
191*0Sstevel@tonic-gate (enum_t *)&fattrp->b_fattr4_type)) {
192*0Sstevel@tonic-gate return (FALSE);
193*0Sstevel@tonic-gate }
194*0Sstevel@tonic-gate }
195*0Sstevel@tonic-gate if (bitmap1.bm_fattr4_size) {
196*0Sstevel@tonic-gate if (!xdr_u_longlong_t(&mxdrs,
197*0Sstevel@tonic-gate (u_longlong_t *)&fattrp->b_fattr4_size))
198*0Sstevel@tonic-gate return (FALSE);
199*0Sstevel@tonic-gate }
200*0Sstevel@tonic-gate
201*0Sstevel@tonic-gate if (bitmap1.bm_fattr4_fsid) {
202*0Sstevel@tonic-gate if (!xdr_u_longlong_t(&mxdrs,
203*0Sstevel@tonic-gate (u_longlong_t *)&fattrp->b_fattr4_fsid.major))
204*0Sstevel@tonic-gate return (FALSE);
205*0Sstevel@tonic-gate
206*0Sstevel@tonic-gate if (!xdr_u_longlong_t(&mxdrs,
207*0Sstevel@tonic-gate (u_longlong_t *)&fattrp->b_fattr4_fsid.minor))
208*0Sstevel@tonic-gate return (FALSE);
209*0Sstevel@tonic-gate }
210*0Sstevel@tonic-gate if (bitmap1.bm_fattr4_filehandle) {
211*0Sstevel@tonic-gate if (!xdr_nfs_bfh4(&mxdrs,
212*0Sstevel@tonic-gate (struct nfs_bfh4 *)&fattrp->b_fattr4_filehandle))
213*0Sstevel@tonic-gate return (FALSE);
214*0Sstevel@tonic-gate }
215*0Sstevel@tonic-gate if (bitmap1.bm_fattr4_fileid) {
216*0Sstevel@tonic-gate if (!xdr_u_longlong_t(&mxdrs,
217*0Sstevel@tonic-gate (u_longlong_t *)&fattrp->b_fattr4_fileid))
218*0Sstevel@tonic-gate return (FALSE);
219*0Sstevel@tonic-gate }
220*0Sstevel@tonic-gate }
221*0Sstevel@tonic-gate
222*0Sstevel@tonic-gate /*
223*0Sstevel@tonic-gate * Now the second bitmap
224*0Sstevel@tonic-gate */
225*0Sstevel@tonic-gate if (bitmap2.word > 0) {
226*0Sstevel@tonic-gate if (bitmap2.bm_fattr4_mode) {
227*0Sstevel@tonic-gate if (!xdr_u_int(&mxdrs,
228*0Sstevel@tonic-gate (uint_t *)&objp->gc_attrs.b_fattr4_mode))
229*0Sstevel@tonic-gate return (FALSE);
230*0Sstevel@tonic-gate }
231*0Sstevel@tonic-gate
232*0Sstevel@tonic-gate if (bitmap2.bm_fattr4_time_access) {
233*0Sstevel@tonic-gate if (!xdr_longlong_t(&mxdrs,
234*0Sstevel@tonic-gate (longlong_t *)&objp->gc_attrs.b_fattr4_time_access.seconds))
235*0Sstevel@tonic-gate return (FALSE);
236*0Sstevel@tonic-gate if (!xdr_u_int(&mxdrs,
237*0Sstevel@tonic-gate (uint_t *)&objp->gc_attrs.b_fattr4_time_access.nseconds))
238*0Sstevel@tonic-gate return (FALSE);
239*0Sstevel@tonic-gate }
240*0Sstevel@tonic-gate
241*0Sstevel@tonic-gate if (bitmap2.bm_fattr4_time_metadata) {
242*0Sstevel@tonic-gate if (!xdr_longlong_t(&mxdrs,
243*0Sstevel@tonic-gate (longlong_t *)&objp->gc_attrs.b_fattr4_time_metadata.seconds))
244*0Sstevel@tonic-gate return (FALSE);
245*0Sstevel@tonic-gate if (!xdr_u_int(&mxdrs,
246*0Sstevel@tonic-gate (uint_t *)&objp->gc_attrs.b_fattr4_time_metadata.nseconds))
247*0Sstevel@tonic-gate return (FALSE);
248*0Sstevel@tonic-gate }
249*0Sstevel@tonic-gate
250*0Sstevel@tonic-gate if (bitmap2.bm_fattr4_time_modify) {
251*0Sstevel@tonic-gate if (!xdr_longlong_t(&mxdrs,
252*0Sstevel@tonic-gate (longlong_t *)&objp->gc_attrs.b_fattr4_time_modify.seconds))
253*0Sstevel@tonic-gate return (FALSE);
254*0Sstevel@tonic-gate if (!xdr_u_int(&mxdrs,
255*0Sstevel@tonic-gate (uint_t *)&objp->gc_attrs.b_fattr4_time_modify.nseconds))
256*0Sstevel@tonic-gate return (FALSE);
257*0Sstevel@tonic-gate }
258*0Sstevel@tonic-gate }
259*0Sstevel@tonic-gate }
260*0Sstevel@tonic-gate }
261*0Sstevel@tonic-gate return (TRUE);
262*0Sstevel@tonic-gate }
263*0Sstevel@tonic-gate
264*0Sstevel@tonic-gate bool_t
xdr_getattr4_res(XDR * xdrs,getattr4res_t * objp)265*0Sstevel@tonic-gate xdr_getattr4_res(XDR *xdrs, getattr4res_t *objp)
266*0Sstevel@tonic-gate {
267*0Sstevel@tonic-gate if (!xdr_b_compound_res(xdrs, (b_compound_t *)&objp->gr_res))
268*0Sstevel@tonic-gate return (FALSE);
269*0Sstevel@tonic-gate return (xdr_b_getattr_res_common(xdrs,
270*0Sstevel@tonic-gate (getattrres_cmn_t *)&objp->gr_cmn));
271*0Sstevel@tonic-gate }
272*0Sstevel@tonic-gate
273*0Sstevel@tonic-gate bool_t
xdr_lookup4_args(XDR * xdrs,lookup4arg_t * objp)274*0Sstevel@tonic-gate xdr_lookup4_args(XDR *xdrs, lookup4arg_t *objp)
275*0Sstevel@tonic-gate {
276*0Sstevel@tonic-gate if (!xdr_b_compound_args(xdrs, (b_compound_t *)&objp->la_arg))
277*0Sstevel@tonic-gate return (FALSE);
278*0Sstevel@tonic-gate if (!xdr_u_int(xdrs, (uint_t *)&objp->la_oplookup))
279*0Sstevel@tonic-gate return (FALSE);
280*0Sstevel@tonic-gate if (!xdr_b_utf8string(xdrs, (utf8string *)&objp->la_pathname))
281*0Sstevel@tonic-gate return (FALSE);
282*0Sstevel@tonic-gate if (!xdr_u_int(xdrs, (uint_t *)&objp->la_opgetattr))
283*0Sstevel@tonic-gate return (FALSE);
284*0Sstevel@tonic-gate return (xdr_b_bitmap4(xdrs, (b_bitmap4_t *)&objp->la_attr_req));
285*0Sstevel@tonic-gate }
286*0Sstevel@tonic-gate
287*0Sstevel@tonic-gate bool_t
xdr_lookup4_res(XDR * xdrs,lookup4res_t * objp)288*0Sstevel@tonic-gate xdr_lookup4_res(XDR *xdrs, lookup4res_t *objp)
289*0Sstevel@tonic-gate {
290*0Sstevel@tonic-gate if (!xdr_b_compound_res(xdrs, (b_compound_t *)&objp->lr_res))
291*0Sstevel@tonic-gate return (FALSE);
292*0Sstevel@tonic-gate if (!xdr_u_int(xdrs, (uint_t *)&objp->lr_oplookup))
293*0Sstevel@tonic-gate return (FALSE);
294*0Sstevel@tonic-gate if (!xdr_enum(xdrs, (enum_t *)&objp->lr_lookup_status))
295*0Sstevel@tonic-gate return (FALSE);
296*0Sstevel@tonic-gate if (objp->lr_lookup_status == NFS4_OK) {
297*0Sstevel@tonic-gate return (xdr_b_getattr_res_common(xdrs,
298*0Sstevel@tonic-gate (getattrres_cmn_t *)&objp->lr_gcmn));
299*0Sstevel@tonic-gate }
300*0Sstevel@tonic-gate return (TRUE);
301*0Sstevel@tonic-gate }
302*0Sstevel@tonic-gate
303*0Sstevel@tonic-gate bool_t
xdr_lookupp4_args(XDR * xdrs,lookupp4arg_t * objp)304*0Sstevel@tonic-gate xdr_lookupp4_args(XDR *xdrs, lookupp4arg_t *objp)
305*0Sstevel@tonic-gate {
306*0Sstevel@tonic-gate if (!xdr_b_compound_args(xdrs, (b_compound_t *)&objp->la_arg))
307*0Sstevel@tonic-gate return (FALSE);
308*0Sstevel@tonic-gate if (!xdr_u_int(xdrs, (uint_t *)&objp->la_oplookupp))
309*0Sstevel@tonic-gate return (FALSE);
310*0Sstevel@tonic-gate if (!xdr_u_int(xdrs, (uint_t *)&objp->la_opgetattr))
311*0Sstevel@tonic-gate return (FALSE);
312*0Sstevel@tonic-gate return (xdr_b_bitmap4(xdrs, (b_bitmap4_t *)&objp->la_attr_req));
313*0Sstevel@tonic-gate }
314*0Sstevel@tonic-gate
315*0Sstevel@tonic-gate bool_t
xdr_read4_args(XDR * xdrs,read4arg_t * objp)316*0Sstevel@tonic-gate xdr_read4_args(XDR *xdrs, read4arg_t *objp)
317*0Sstevel@tonic-gate {
318*0Sstevel@tonic-gate if (!xdr_b_compound_args(xdrs, (b_compound_t *)&objp->r_arg))
319*0Sstevel@tonic-gate return (FALSE);
320*0Sstevel@tonic-gate if (!xdr_u_int(xdrs, (uint_t *)&objp->r_opread))
321*0Sstevel@tonic-gate return (FALSE);
322*0Sstevel@tonic-gate if (!xdr_b_stateid4(xdrs, (stateid4 *)&objp->r_stateid))
323*0Sstevel@tonic-gate return (FALSE);
324*0Sstevel@tonic-gate if (!xdr_u_longlong_t(xdrs, (u_longlong_t *)&objp->r_offset))
325*0Sstevel@tonic-gate return (FALSE);
326*0Sstevel@tonic-gate return (xdr_u_int(xdrs, (uint_t *)&objp->r_count));
327*0Sstevel@tonic-gate }
328*0Sstevel@tonic-gate
329*0Sstevel@tonic-gate bool_t
xdr_read4_res(XDR * xdrs,read4res_t * objp)330*0Sstevel@tonic-gate xdr_read4_res(XDR *xdrs, read4res_t *objp)
331*0Sstevel@tonic-gate {
332*0Sstevel@tonic-gate if (!xdr_b_compound_res(xdrs, (b_compound_t *)&objp->r_res))
333*0Sstevel@tonic-gate return (FALSE);
334*0Sstevel@tonic-gate if (!xdr_u_int(xdrs, (uint_t *)&objp->r_opread))
335*0Sstevel@tonic-gate return (FALSE);
336*0Sstevel@tonic-gate if (!xdr_enum(xdrs, (enum_t *)&objp->r_status))
337*0Sstevel@tonic-gate return (FALSE);
338*0Sstevel@tonic-gate if (objp->r_status == NFS4_OK) {
339*0Sstevel@tonic-gate if (!xdr_bool(xdrs, (bool_t *)&objp->r_eof))
340*0Sstevel@tonic-gate return (FALSE);
341*0Sstevel@tonic-gate return (xdr_bytes(xdrs, (char **)&objp->r_data_val,
342*0Sstevel@tonic-gate (uint_t *)&objp->r_data_len, ~0));
343*0Sstevel@tonic-gate }
344*0Sstevel@tonic-gate return (TRUE);
345*0Sstevel@tonic-gate }
346*0Sstevel@tonic-gate
347*0Sstevel@tonic-gate bool_t
xdr_readdir4_args(XDR * xdrs,readdir4arg_t * objp)348*0Sstevel@tonic-gate xdr_readdir4_args(XDR *xdrs, readdir4arg_t *objp)
349*0Sstevel@tonic-gate {
350*0Sstevel@tonic-gate if (!xdr_b_compound_args(xdrs, (b_compound_t *)&objp->rd_arg))
351*0Sstevel@tonic-gate return (FALSE);
352*0Sstevel@tonic-gate if (!xdr_u_int(xdrs, (uint_t *)&objp->rd_opreaddir))
353*0Sstevel@tonic-gate return (FALSE);
354*0Sstevel@tonic-gate if (!xdr_u_longlong_t(xdrs, (u_longlong_t *)&objp->rd_cookie))
355*0Sstevel@tonic-gate return (FALSE);
356*0Sstevel@tonic-gate if (!xdr_opaque(xdrs, objp->rd_cookieverf, NFS4_VERIFIER_SIZE))
357*0Sstevel@tonic-gate return (FALSE);
358*0Sstevel@tonic-gate if (!xdr_u_int(xdrs, (uint_t *)&objp->rd_dircount))
359*0Sstevel@tonic-gate return (FALSE);
360*0Sstevel@tonic-gate if (!xdr_u_int(xdrs, (uint_t *)&objp->rd_maxcount))
361*0Sstevel@tonic-gate return (FALSE);
362*0Sstevel@tonic-gate return (xdr_b_bitmap4(xdrs, (b_bitmap4_t *)&objp->rd_attr_req));
363*0Sstevel@tonic-gate }
364*0Sstevel@tonic-gate
365*0Sstevel@tonic-gate static bool_t
xdr_b_entry4(XDR * xdrs,b_entry4_t * objp)366*0Sstevel@tonic-gate xdr_b_entry4(XDR *xdrs, b_entry4_t *objp)
367*0Sstevel@tonic-gate {
368*0Sstevel@tonic-gate uint_t attrlen;
369*0Sstevel@tonic-gate char attrvals[sizeof (b_fattr4_t)];
370*0Sstevel@tonic-gate char *ap = attrvals;
371*0Sstevel@tonic-gate XDR mxdrs;
372*0Sstevel@tonic-gate
373*0Sstevel@tonic-gate if (!xdr_u_longlong_t(xdrs, (u_longlong_t *)&objp->b_cookie))
374*0Sstevel@tonic-gate return (FALSE);
375*0Sstevel@tonic-gate if (!xdr_b_utf8string(xdrs, &objp->b_name))
376*0Sstevel@tonic-gate return (FALSE);
377*0Sstevel@tonic-gate
378*0Sstevel@tonic-gate bzero(&attrvals, sizeof (attrvals));
379*0Sstevel@tonic-gate if (!xdr_bytes(xdrs, (char **)&ap, (uint_t *)&attrlen,
380*0Sstevel@tonic-gate sizeof (b_fattr4_t)))
381*0Sstevel@tonic-gate return (FALSE);
382*0Sstevel@tonic-gate
383*0Sstevel@tonic-gate /*
384*0Sstevel@tonic-gate * We are *only* interested in the fileid, so just extract that.
385*0Sstevel@tonic-gate */
386*0Sstevel@tonic-gate if (attrlen < sizeof (uint64_t))
387*0Sstevel@tonic-gate return (FALSE);
388*0Sstevel@tonic-gate
389*0Sstevel@tonic-gate xdrmem_create(&mxdrs, ap, attrlen, XDR_DECODE);
390*0Sstevel@tonic-gate
391*0Sstevel@tonic-gate if (!xdr_u_longlong_t(&mxdrs, (u_longlong_t *)&objp->b_fileid))
392*0Sstevel@tonic-gate return (FALSE);
393*0Sstevel@tonic-gate return (xdr_pointer(xdrs, (char **)&objp->b_nextentry,
394*0Sstevel@tonic-gate sizeof (b_entry4_t), (xdrproc_t)xdr_b_entry4));
395*0Sstevel@tonic-gate }
396*0Sstevel@tonic-gate
397*0Sstevel@tonic-gate bool_t
xdr_readdir4_res(XDR * xdrs,readdir4res_t * objp)398*0Sstevel@tonic-gate xdr_readdir4_res(XDR *xdrs, readdir4res_t *objp)
399*0Sstevel@tonic-gate {
400*0Sstevel@tonic-gate if (!xdr_b_compound_res(xdrs, (b_compound_t *)&objp->rd_res))
401*0Sstevel@tonic-gate return (FALSE);
402*0Sstevel@tonic-gate if (!xdr_u_int(xdrs, (uint_t *)&objp->rd_opreaddir))
403*0Sstevel@tonic-gate return (FALSE);
404*0Sstevel@tonic-gate if (!xdr_enum(xdrs, (enum_t *)&objp->rd_status))
405*0Sstevel@tonic-gate return (FALSE);
406*0Sstevel@tonic-gate if (objp->rd_status == NFS4_OK) {
407*0Sstevel@tonic-gate if (!xdr_opaque(xdrs, objp->rd_cookieverf, NFS4_VERIFIER_SIZE))
408*0Sstevel@tonic-gate return (FALSE);
409*0Sstevel@tonic-gate if (!xdr_pointer(xdrs, (char **)&objp->rd_entries,
410*0Sstevel@tonic-gate sizeof (b_entry4_t), (xdrproc_t)xdr_b_entry4))
411*0Sstevel@tonic-gate return (FALSE);
412*0Sstevel@tonic-gate return (xdr_bool(xdrs, &objp->rd_eof));
413*0Sstevel@tonic-gate }
414*0Sstevel@tonic-gate return (TRUE);
415*0Sstevel@tonic-gate }
416*0Sstevel@tonic-gate
417*0Sstevel@tonic-gate bool_t
xdr_readlink4_args(XDR * xdrs,readlink4arg_t * objp)418*0Sstevel@tonic-gate xdr_readlink4_args(XDR *xdrs, readlink4arg_t *objp)
419*0Sstevel@tonic-gate {
420*0Sstevel@tonic-gate if (!xdr_b_compound_args(xdrs, (b_compound_t *)&objp->rl_arg))
421*0Sstevel@tonic-gate return (FALSE);
422*0Sstevel@tonic-gate return (xdr_u_int(xdrs, (uint_t *)&objp->rl_opreadlink));
423*0Sstevel@tonic-gate }
424*0Sstevel@tonic-gate
425*0Sstevel@tonic-gate bool_t
xdr_readlink4_res(XDR * xdrs,readlink4res_t * objp)426*0Sstevel@tonic-gate xdr_readlink4_res(XDR *xdrs, readlink4res_t *objp)
427*0Sstevel@tonic-gate {
428*0Sstevel@tonic-gate if (!xdr_b_compound_res(xdrs, (b_compound_t *)&objp->rl_res))
429*0Sstevel@tonic-gate return (FALSE);
430*0Sstevel@tonic-gate if (!xdr_u_int(xdrs, (uint_t *)&objp->rl_opreadlink))
431*0Sstevel@tonic-gate return (FALSE);
432*0Sstevel@tonic-gate if (!xdr_enum(xdrs, (enum_t *)&objp->rl_status))
433*0Sstevel@tonic-gate return (FALSE);
434*0Sstevel@tonic-gate if (objp->rl_status == NFS4_OK)
435*0Sstevel@tonic-gate return (xdr_b_utf8string(xdrs, (utf8string *)&objp->rl_link));
436*0Sstevel@tonic-gate return (TRUE);
437*0Sstevel@tonic-gate }
438