xdr_func.c revision 51292
1/*
2 * Copyright (c) 1997-1999 Erez Zadok
3 * Copyright (c) 1990 Jan-Simon Pendry
4 * Copyright (c) 1990 Imperial College of Science, Technology & Medicine
5 * Copyright (c) 1990 The Regents of the University of California.
6 * All rights reserved.
7 *
8 * This code is derived from software contributed to Berkeley by
9 * Jan-Simon Pendry at Imperial College, London.
10 *
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
13 * are met:
14 * 1. Redistributions of source code must retain the above copyright
15 *    notice, this list of conditions and the following disclaimer.
16 * 2. Redistributions in binary form must reproduce the above copyright
17 *    notice, this list of conditions and the following disclaimer in the
18 *    documentation and/or other materials provided with the distribution.
19 * 3. All advertising materials mentioning features or use of this software
20 *    must display the following acknowledgment:
21 *      This product includes software developed by the University of
22 *      California, Berkeley and its contributors.
23 * 4. Neither the name of the University nor the names of its contributors
24 *    may be used to endorse or promote products derived from this software
25 *    without specific prior written permission.
26 *
27 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
28 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
29 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
30 * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
31 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
32 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
33 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
34 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
35 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
36 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
37 * SUCH DAMAGE.
38 *
39 *      %W% (Berkeley) %G%
40 *
41 * $Id: xdr_func.c,v 1.2 1999/01/10 21:54:39 ezk Exp $
42 *
43 */
44
45/*
46 * Complete list of all possible xdr functions which may be needed.
47 */
48#ifdef HAVE_CONFIG_H
49# include <config.h>
50#endif /* HAVE_CONFIG_H */
51#include <am_defs.h>
52#include <amu.h>
53
54/*
55 * MACROS:
56 */
57#ifdef HAVE_FS_AUTOFS
58# ifndef A_MAXNAME
59#  define A_MAXNAME 255
60# endif /* not A_MAXNAME */
61# ifndef A_MAXOPTS
62#  define A_MAXOPTS 255
63# endif /* not A_MAXOPTS */
64# ifndef A_MAXPATH
65#  define A_MAXPATH 1024
66# endif /* not A_MAXPATH */
67#endif /* HAVE_FS_AUTOFS */
68
69/* forward definitions, are they needed? */
70extern bool_t xdr_exportnode(XDR *xdrs, exportnode *objp);
71extern bool_t xdr_groupnode(XDR *xdrs, groupnode *objp);
72extern bool_t xdr_name(XDR *xdrs, name *objp);
73
74
75#ifndef HAVE_XDR_ATTRSTAT
76bool_t
77xdr_attrstat(XDR *xdrs, nfsattrstat *objp)
78{
79#ifdef DEBUG
80  amuDebug(D_TRACE)
81    plog(XLOG_DEBUG, "xdr_attrstat:");
82#endif /* DEBUG */
83
84  if (!xdr_nfsstat(xdrs, &objp->ns_status)) {
85    return (FALSE);
86  }
87  switch (objp->ns_status) {
88  case NFS_OK:
89    if (!xdr_fattr(xdrs, &objp->ns_u.ns_attr_u)) {
90      return (FALSE);
91    }
92    break;
93  default:
94    break;
95  }
96  return (TRUE);
97}
98#endif /* not HAVE_XDR_ATTRSTAT */
99
100
101#ifndef HAVE_XDR_CREATEARGS
102bool_t
103xdr_createargs(XDR *xdrs, nfscreateargs *objp)
104{
105#ifdef DEBUG
106  amuDebug(D_TRACE)
107    plog(XLOG_DEBUG, "xdr_createargs:");
108#endif /* DEBUG */
109
110  if (!xdr_diropargs(xdrs, &objp->ca_where)) {
111    return (FALSE);
112  }
113  if (!xdr_sattr(xdrs, &objp->ca_attributes)) {
114    return (FALSE);
115  }
116  return (TRUE);
117}
118#endif /* not HAVE_XDR_CREATEARGS */
119
120
121#ifndef HAVE_XDR_DIRLIST
122bool_t
123xdr_dirlist(XDR *xdrs, nfsdirlist *objp)
124{
125#ifdef DEBUG
126  amuDebug(D_TRACE)
127    plog(XLOG_DEBUG, "xdr_dirlist:");
128#endif /* DEBUG */
129
130  if (!xdr_pointer(xdrs, (char **) &objp->dl_entries, sizeof(nfsentry), (XDRPROC_T_TYPE) xdr_entry)) {
131    return (FALSE);
132  }
133  if (!xdr_bool(xdrs, &objp->dl_eof)) {
134    return (FALSE);
135  }
136  return (TRUE);
137}
138#endif /* not HAVE_XDR_DIRLIST */
139
140
141#ifndef HAVE_XDR_DIROPARGS
142bool_t
143xdr_diropargs(XDR *xdrs, nfsdiropargs *objp)
144{
145#ifdef DEBUG
146  amuDebug(D_TRACE)
147    plog(XLOG_DEBUG, "xdr_diropargs:");
148#endif /* DEBUG */
149
150  if (!xdr_nfs_fh(xdrs, &objp->da_fhandle)) {
151    return (FALSE);
152  }
153  if (!xdr_filename(xdrs, &objp->da_name)) {
154    return (FALSE);
155  }
156  return (TRUE);
157}
158#endif /* not HAVE_XDR_DIROPARGS */
159
160
161#ifndef HAVE_XDR_DIROPOKRES
162bool_t
163xdr_diropokres(XDR *xdrs, nfsdiropokres *objp)
164{
165#ifdef DEBUG
166  amuDebug(D_TRACE)
167    plog(XLOG_DEBUG, "xdr_diropokres:");
168#endif /* DEBUG */
169
170  if (!xdr_nfs_fh(xdrs, &objp->drok_fhandle)) {
171    return (FALSE);
172  }
173  if (!xdr_fattr(xdrs, &objp->drok_attributes)) {
174    return (FALSE);
175  }
176  return (TRUE);
177}
178#endif /* not HAVE_XDR_DIROPOKRES */
179
180
181#ifndef HAVE_XDR_DIROPRES
182bool_t
183xdr_diropres(XDR *xdrs, nfsdiropres *objp)
184{
185#ifdef DEBUG
186  amuDebug(D_TRACE)
187    plog(XLOG_DEBUG, "xdr_diropres:");
188#endif /* DEBUG */
189
190  if (!xdr_nfsstat(xdrs, &objp->dr_status)) {
191    return (FALSE);
192  }
193  switch (objp->dr_status) {
194  case NFS_OK:
195    if (!xdr_diropokres(xdrs, &objp->dr_u.dr_drok_u)) {
196      return (FALSE);
197    }
198    break;
199  default:
200    break;
201  }
202  return (TRUE);
203}
204#endif /* not HAVE_XDR_DIROPRES */
205
206
207#ifndef HAVE_XDR_DIRPATH
208bool_t
209xdr_dirpath(XDR *xdrs, dirpath *objp)
210{
211#ifdef DEBUG
212  amuDebug(D_TRACE)
213    plog(XLOG_DEBUG, "xdr_dirpath:");
214#endif /* DEBUG */
215
216  if (!xdr_string(xdrs, objp, MNTPATHLEN)) {
217    return (FALSE);
218  }
219  return (TRUE);
220}
221#endif /* not HAVE_XDR_DIRPATH */
222
223
224#ifndef HAVE_XDR_ENTRY
225bool_t
226xdr_entry(XDR *xdrs, nfsentry *objp)
227{
228#ifdef DEBUG
229  amuDebug(D_TRACE)
230    plog(XLOG_DEBUG, "xdr_entry:");
231#endif /* DEBUG */
232
233  if (!xdr_u_int(xdrs, &objp->ne_fileid)) {
234    return (FALSE);
235  }
236  if (!xdr_filename(xdrs, &objp->ne_name)) {
237    return (FALSE);
238  }
239  if (!xdr_nfscookie(xdrs, objp->ne_cookie)) {
240    return (FALSE);
241  }
242  if (!xdr_pointer(xdrs, (char **) &objp->ne_nextentry, sizeof(nfsentry), (XDRPROC_T_TYPE) xdr_entry)) {
243    return (FALSE);
244  }
245  return (TRUE);
246}
247#endif /* not HAVE_XDR_ENTRY */
248
249
250#ifndef HAVE_XDR_EXPORTNODE
251bool_t
252xdr_exportnode(XDR *xdrs, exportnode *objp)
253{
254#ifdef DEBUG
255  amuDebug(D_TRACE)
256    plog(XLOG_DEBUG, "xdr_exportnode:");
257#endif /* DEBUG */
258
259  if (!xdr_dirpath(xdrs, &objp->ex_dir)) {
260    return (FALSE);
261  }
262  /*
263   * This cast to (groups) is needed for Irix6.  If you change it, it
264   * may produce a warning/error on other systems.
265   */
266  if (!xdr_groups(xdrs, (groups) &objp->ex_groups)) {
267    return (FALSE);
268  }
269  if (!xdr_exports(xdrs, &objp->ex_next)) {
270    return (FALSE);
271  }
272  return (TRUE);
273}
274#endif /* not HAVE_XDR_EXPORTNODE */
275
276
277#ifndef HAVE_XDR_EXPORTS
278bool_t
279xdr_exports(XDR *xdrs, exports *objp)
280{
281#ifdef DEBUG
282  amuDebug(D_TRACE)
283    plog(XLOG_DEBUG, "xdr_exports:");
284#endif /* DEBUG */
285
286  if (!xdr_pointer(xdrs, (char **) objp, sizeof(exportnode), (XDRPROC_T_TYPE) xdr_exportnode)) {
287    return (FALSE);
288  }
289  return (TRUE);
290}
291#endif /* not HAVE_XDR_EXPORTS */
292
293
294#ifndef HAVE_XDR_FATTR
295bool_t
296xdr_fattr(XDR *xdrs, nfsfattr *objp)
297{
298#ifdef DEBUG
299  amuDebug(D_TRACE)
300    plog(XLOG_DEBUG, "xdr_fattr:");
301#endif /* DEBUG */
302
303  if (!xdr_ftype(xdrs, &objp->na_type)) {
304    return (FALSE);
305  }
306  if (!xdr_u_int(xdrs, &objp->na_mode)) {
307    return (FALSE);
308  }
309  if (!xdr_u_int(xdrs, &objp->na_nlink)) {
310    return (FALSE);
311  }
312  if (!xdr_u_int(xdrs, &objp->na_uid)) {
313    return (FALSE);
314  }
315  if (!xdr_u_int(xdrs, &objp->na_gid)) {
316    return (FALSE);
317  }
318  if (!xdr_u_int(xdrs, &objp->na_size)) {
319    return (FALSE);
320  }
321  if (!xdr_u_int(xdrs, &objp->na_blocksize)) {
322    return (FALSE);
323  }
324  if (!xdr_u_int(xdrs, &objp->na_rdev)) {
325    return (FALSE);
326  }
327  if (!xdr_u_int(xdrs, &objp->na_blocks)) {
328    return (FALSE);
329  }
330  if (!xdr_u_int(xdrs, &objp->na_fsid)) {
331    return (FALSE);
332  }
333  if (!xdr_u_int(xdrs, &objp->na_fileid)) {
334    return (FALSE);
335  }
336  if (!xdr_nfstime(xdrs, &objp->na_atime)) {
337    return (FALSE);
338  }
339  if (!xdr_nfstime(xdrs, &objp->na_mtime)) {
340    return (FALSE);
341  }
342  if (!xdr_nfstime(xdrs, &objp->na_ctime)) {
343    return (FALSE);
344  }
345  return (TRUE);
346}
347#endif /* not HAVE_XDR_FATTR */
348
349
350#ifndef HAVE_XDR_FHANDLE
351bool_t
352xdr_fhandle(XDR *xdrs, fhandle objp)
353{
354#ifdef DEBUG
355  amuDebug(D_TRACE)
356    plog(XLOG_DEBUG, "xdr_fhandle:");
357#endif /* DEBUG */
358
359  if (!xdr_opaque(xdrs, objp, NFS_FHSIZE)) {
360    return (FALSE);
361  }
362  return (TRUE);
363}
364#endif /* not HAVE_XDR_FHANDLE */
365
366
367#ifndef HAVE_XDR_FHSTATUS
368bool_t
369xdr_fhstatus(XDR *xdrs, fhstatus *objp)
370{
371#ifdef DEBUG
372  amuDebug(D_TRACE)
373    plog(XLOG_DEBUG, "xdr_fhstatus:");
374#endif /* DEBUG */
375
376  if (!xdr_u_int(xdrs, &objp->fhs_status)) {
377    return (FALSE);
378  }
379  if (objp->fhs_status == 0 && !xdr_fhandle(xdrs, objp->fhs_fh)) {
380    return (FALSE);
381  }
382  return (TRUE);
383}
384#endif /* not HAVE_XDR_FHSTATUS */
385
386
387#ifndef HAVE_XDR_FILENAME
388bool_t
389xdr_filename(XDR *xdrs, filename *objp)
390{
391#ifdef DEBUG
392  amuDebug(D_TRACE)
393    plog(XLOG_DEBUG, "xdr_filename:");
394#endif /* DEBUG */
395
396  if (!xdr_string(xdrs, objp, NFS_MAXNAMLEN)) {
397    return (FALSE);
398  }
399  return (TRUE);
400}
401#endif /* not HAVE_XDR_FILENAME */
402
403
404#ifndef HAVE_XDR_FTYPE
405bool_t
406xdr_ftype(XDR *xdrs, nfsftype *objp)
407{
408#ifdef DEBUG
409  amuDebug(D_TRACE)
410    plog(XLOG_DEBUG, "xdr_ftype:");
411#endif /* DEBUG */
412
413  if (!xdr_enum(xdrs, (enum_t *) objp)) {
414    return (FALSE);
415  }
416  return (TRUE);
417}
418#endif /* not HAVE_XDR_FTYPE */
419
420
421#ifndef HAVE_XDR_GROUPNODE
422bool_t
423xdr_groupnode(XDR *xdrs, groupnode *objp)
424{
425#ifdef DEBUG
426  amuDebug(D_TRACE)
427    plog(XLOG_DEBUG, "xdr_groupnode:");
428#endif /* DEBUG */
429
430  if (!xdr_name(xdrs, &objp->gr_name)) {
431    return (FALSE);
432  }
433  /*
434   * This cast to (groups) is needed for Irix6.  If you change it, it
435   * may produce a warning/error on other systems.
436   */
437  if (!xdr_groups(xdrs, (groups) &objp->gr_next)) {
438    return (FALSE);
439  }
440  return (TRUE);
441}
442#endif /* not HAVE_XDR_GROUPNODE */
443
444
445#ifndef HAVE_XDR_GROUPS
446bool_t
447xdr_groups(XDR *xdrs, groups objp)
448{
449#ifdef DEBUG
450  amuDebug(D_TRACE)
451    plog(XLOG_DEBUG, "xdr_groups:");
452#endif /* DEBUG */
453
454  if (!xdr_pointer(xdrs, (char **) objp, sizeof(groupnode), (XDRPROC_T_TYPE) xdr_groupnode)) {
455    return (FALSE);
456  }
457  return (TRUE);
458}
459#endif /* not HAVE_XDR_GROUPS */
460
461
462#ifndef HAVE_XDR_LINKARGS
463bool_t
464xdr_linkargs(XDR *xdrs, nfslinkargs *objp)
465{
466#ifdef DEBUG
467  amuDebug(D_TRACE)
468    plog(XLOG_DEBUG, "xdr_linkargs:");
469#endif /* DEBUG */
470
471  if (!xdr_nfs_fh(xdrs, &objp->la_fhandle)) {
472    return (FALSE);
473  }
474  if (!xdr_diropargs(xdrs, &objp->la_to)) {
475    return (FALSE);
476  }
477  return (TRUE);
478}
479#endif /* not HAVE_XDR_LINKARGS */
480
481
482#ifndef HAVE_XDR_MOUNTBODY
483bool_t
484xdr_mountbody(XDR *xdrs, mountbody *objp)
485{
486#ifdef DEBUG
487  amuDebug(D_TRACE)
488    plog(XLOG_DEBUG, "xdr_mountbody:");
489#endif /* DEBUG */
490
491  if (!xdr_name(xdrs, &objp->ml_hostname)) {
492    return (FALSE);
493  }
494  if (!xdr_dirpath(xdrs, &objp->ml_directory)) {
495    return (FALSE);
496  }
497  if (!xdr_mountlist(xdrs, &objp->ml_next)) {
498    return (FALSE);
499  }
500  return (TRUE);
501}
502#endif /* not HAVE_XDR_MOUNTBODY */
503
504
505#ifndef HAVE_XDR_MOUNTLIST
506bool_t
507xdr_mountlist(XDR *xdrs, mountlist *objp)
508{
509#ifdef DEBUG
510  amuDebug(D_TRACE)
511    plog(XLOG_DEBUG, "xdr_mountlist:");
512#endif /* DEBUG */
513
514  if (!xdr_pointer(xdrs, (char **) objp, sizeof(mountbody), (XDRPROC_T_TYPE) xdr_mountbody)) {
515    return (FALSE);
516  }
517  return (TRUE);
518}
519#endif /* not HAVE_XDR_MOUNTLIST */
520
521
522#if defined(HAVE_FS_NFS3) && !defined(HAVE_XDR_MOUNTRES3)
523/*
524 * This ifdef is a hack: this whole file needs to be compiled
525 * only if the system has NFS V3 and does not have the xdr_mountres3
526 * function.  Autoconf should pick this source file to compile only
527 * if these two conditions apply.
528 */
529
530bool_t
531xdr_fhandle3(XDR *xdrs, fhandle3 *objp)
532{
533#ifdef DEBUG
534  amuDebug(D_TRACE)
535    plog(XLOG_DEBUG, "xdr_fhandle3:");
536#endif /* DEBUG */
537
538  if (!xdr_bytes(xdrs,
539		 (char **) &objp->fhandle3_val,
540		 (u_int *) &objp->fhandle3_len,
541		 FHSIZE3))
542    return (FALSE);
543  return (TRUE);
544}
545
546
547bool_t
548xdr_mountstat3(XDR *xdrs, mountstat3 *objp)
549{
550#ifdef DEBUG
551  amuDebug(D_TRACE)
552    plog(XLOG_DEBUG, "xdr_mountstat3:");
553#endif /* DEBUG */
554
555  if (!xdr_enum(xdrs, (enum_t *)objp))
556    return (FALSE);
557  return (TRUE);
558}
559
560
561bool_t
562xdr_mountres3_ok(XDR *xdrs, mountres3_ok *objp)
563{
564#ifdef DEBUG
565  amuDebug(D_TRACE)
566    plog(XLOG_DEBUG, "xdr_mountres3_ok:");
567#endif /* DEBUG */
568
569  if (!xdr_fhandle3(xdrs, &objp->fhandle))
570    return (FALSE);
571  if (!xdr_array(xdrs,
572		 (char **)&objp->auth_flavors.auth_flavors_val,
573		 (u_int *) &objp->auth_flavors.auth_flavors_len,
574		 ~0,
575		 sizeof (int),
576		 (xdrproc_t) xdr_int))
577    return (FALSE);
578  return (TRUE);
579}
580
581
582bool_t
583xdr_mountres3(XDR *xdrs, mountres3 *objp)
584{
585#ifdef DEBUG
586  amuDebug(D_TRACE)
587    plog(XLOG_DEBUG, "xdr_mountres3:");
588#endif /* DEBUG */
589
590  if (!xdr_mountstat3(xdrs, &objp->fhs_status))
591    return (FALSE);
592
593  if (objp->fhs_status == 0) {	/* 0 == MNT_OK or MNT3_OK */
594    if (!xdr_mountres3_ok(xdrs, &objp->mountres3_u.mountinfo))
595      return (FALSE);
596  }
597  return (TRUE);
598}
599#endif /* defined(HAVE_FS_NFS3) && !defined(HAVE_XDR_MOUNTRES3) */
600
601
602#ifndef HAVE_XDR_NAME
603bool_t
604xdr_name(XDR *xdrs, name *objp)
605{
606#ifdef DEBUG
607  amuDebug(D_TRACE)
608    plog(XLOG_DEBUG, "xdr_name:");
609#endif /* DEBUG */
610
611  if (!xdr_string(xdrs, objp, MNTNAMLEN)) {
612    return (FALSE);
613  }
614  return (TRUE);
615}
616#endif /* not HAVE_XDR_NAME */
617
618
619#ifndef HAVE_XDR_NFS_FH
620bool_t
621xdr_nfs_fh(XDR *xdrs, am_nfs_fh *objp)
622{
623#ifdef DEBUG
624  amuDebug(D_TRACE)
625    plog(XLOG_DEBUG, "xdr_nfs_fh:");
626#endif /* DEBUG */
627
628  if (!xdr_opaque(xdrs, (caddr_t) objp->fh_data, NFS_FHSIZE)) {
629    return (FALSE);
630  }
631  return (TRUE);
632}
633#endif /* not HAVE_XDR_NFS_FH */
634
635
636#ifndef HAVE_XDR_NFSCOOKIE
637bool_t
638xdr_nfscookie(XDR *xdrs, nfscookie objp)
639{
640#ifdef DEBUG
641  amuDebug(D_TRACE)
642    plog(XLOG_DEBUG, "xdr_nfscookie:");
643#endif /* DEBUG */
644
645  if (!xdr_opaque(xdrs, objp, NFS_COOKIESIZE)) {
646    return (FALSE);
647  }
648  return (TRUE);
649}
650#endif /* not HAVE_XDR_NFSCOOKIE */
651
652
653#ifndef HAVE_XDR_NFSPATH
654bool_t
655xdr_nfspath(XDR *xdrs, nfspath *objp)
656{
657#ifdef DEBUG
658  amuDebug(D_TRACE)
659    plog(XLOG_DEBUG, "xdr_nfspath:");
660#endif /* DEBUG */
661
662  if (!xdr_string(xdrs, objp, NFS_MAXPATHLEN)) {
663    return (FALSE);
664  }
665  return (TRUE);
666}
667#endif /* not HAVE_XDR_NFSPATH */
668
669
670#ifndef HAVE_XDR_NFSSTAT
671bool_t
672xdr_nfsstat(XDR *xdrs, nfsstat *objp)
673{
674#ifdef DEBUG
675  amuDebug(D_TRACE)
676    plog(XLOG_DEBUG, "xdr_nfsstat:");
677#endif /* DEBUG */
678
679  if (!xdr_enum(xdrs, (enum_t *) objp)) {
680    return (FALSE);
681  }
682  return (TRUE);
683}
684#endif /* not HAVE_XDR_NFSSTAT */
685
686
687#ifndef HAVE_XDR_NFSTIME
688bool_t
689xdr_nfstime(XDR *xdrs, nfstime *objp)
690{
691#ifdef DEBUG
692  amuDebug(D_TRACE)
693    plog(XLOG_DEBUG, "xdr_nfstime:");
694#endif /* DEBUG */
695
696  if (!xdr_u_int(xdrs, (u_int *) &objp->nt_seconds)) {
697    return (FALSE);
698  }
699  if (!xdr_u_int(xdrs, (u_int *) &objp->nt_useconds)) {
700    return (FALSE);
701  }
702  return (TRUE);
703}
704#endif /* not HAVE_XDR_NFSTIME */
705
706
707#ifndef HAVE_XDR_POINTER
708bool_t
709xdr_pointer(register XDR *xdrs, char **objpp, u_int obj_size, XDRPROC_T_TYPE xdr_obj)
710{
711#ifdef DEBUG
712  amuDebug(D_TRACE)
713    plog(XLOG_DEBUG, "xdr_pointer:");
714#endif /* DEBUG */
715
716
717  bool_t more_data;
718
719  more_data = (*objpp != NULL);
720  if (!xdr_bool(xdrs, &more_data)) {
721    return (FALSE);
722  }
723  if (!more_data) {
724    *objpp = NULL;
725    return (TRUE);
726  }
727
728  return (xdr_reference(xdrs, objpp, obj_size, xdr_obj));
729}
730#endif /* not HAVE_XDR_POINTER */
731
732
733#ifndef HAVE_XDR_READARGS
734bool_t
735xdr_readargs(XDR *xdrs, nfsreadargs *objp)
736{
737#ifdef DEBUG
738  amuDebug(D_TRACE)
739    plog(XLOG_DEBUG, "xdr_readargs:");
740#endif /* DEBUG */
741
742  if (!xdr_nfs_fh(xdrs, &objp->ra_fhandle)) {
743    return (FALSE);
744  }
745  if (!xdr_u_int(xdrs, &objp->ra_offset)) {
746    return (FALSE);
747  }
748  if (!xdr_u_int(xdrs, &objp->ra_count)) {
749    return (FALSE);
750  }
751  if (!xdr_u_int(xdrs, &objp->ra_totalcount)) {
752    return (FALSE);
753  }
754  return (TRUE);
755}
756#endif /* not HAVE_XDR_READARGS */
757
758
759#ifndef HAVE_XDR_READDIRARGS
760bool_t
761xdr_readdirargs(XDR *xdrs, nfsreaddirargs *objp)
762{
763#ifdef DEBUG
764  amuDebug(D_TRACE)
765    plog(XLOG_DEBUG, "xdr_readdirargs:");
766#endif /* DEBUG */
767
768  if (!xdr_nfs_fh(xdrs, &objp->rda_fhandle)) {
769    return (FALSE);
770  }
771  if (!xdr_nfscookie(xdrs, objp->rda_cookie)) {
772    return (FALSE);
773  }
774  if (!xdr_u_int(xdrs, &objp->rda_count)) {
775    return (FALSE);
776  }
777  return (TRUE);
778}
779#endif /* not HAVE_XDR_READDIRARGS */
780
781
782#ifndef HAVE_XDR_READDIRRES
783bool_t
784xdr_readdirres(XDR *xdrs, nfsreaddirres *objp)
785{
786#ifdef DEBUG
787  amuDebug(D_TRACE)
788    plog(XLOG_DEBUG, "xdr_readdirres:");
789#endif /* DEBUG */
790
791  if (!xdr_nfsstat(xdrs, &objp->rdr_status)) {
792    return (FALSE);
793  }
794  switch (objp->rdr_status) {
795  case NFS_OK:
796    if (!xdr_dirlist(xdrs, &objp->rdr_u.rdr_reply_u)) {
797      return (FALSE);
798    }
799    break;
800  default:
801    break;
802  }
803  return (TRUE);
804}
805#endif /* not HAVE_XDR_READDIRRES */
806
807
808#ifndef HAVE_XDR_READLINKRES
809bool_t
810xdr_readlinkres(XDR *xdrs, nfsreadlinkres *objp)
811{
812#ifdef DEBUG
813  amuDebug(D_TRACE)
814    plog(XLOG_DEBUG, "xdr_readlinkres:");
815#endif /* DEBUG */
816
817  if (!xdr_nfsstat(xdrs, &objp->rlr_status)) {
818    return (FALSE);
819  }
820  switch (objp->rlr_status) {
821  case NFS_OK:
822    if (!xdr_nfspath(xdrs, &objp->rlr_u.rlr_data_u)) {
823      return (FALSE);
824    }
825    break;
826  default:
827    break;
828  }
829  return (TRUE);
830}
831#endif /* not HAVE_XDR_READLINKRES */
832
833
834#ifndef HAVE_XDR_READOKRES
835bool_t
836xdr_readokres(XDR *xdrs, nfsreadokres *objp)
837{
838#ifdef DEBUG
839  amuDebug(D_TRACE)
840    plog(XLOG_DEBUG, "xdr_readokres:");
841#endif /* DEBUG */
842
843  if (!xdr_fattr(xdrs, &objp->raok_attributes)) {
844    return (FALSE);
845  }
846  if (!xdr_bytes(xdrs,
847		 (char **) & objp->raok_u.raok_val_u,
848		 (u_int *) & objp->raok_u.raok_len_u,
849		 NFS_MAXDATA)) {
850    return (FALSE);
851  }
852  return (TRUE);
853}
854#endif /* not HAVE_XDR_READOKRES */
855
856
857#ifndef HAVE_XDR_READRES
858bool_t
859xdr_readres(XDR *xdrs, nfsreadres *objp)
860{
861#ifdef DEBUG
862  amuDebug(D_TRACE)
863    plog(XLOG_DEBUG, "xdr_readres:");
864#endif /* DEBUG */
865
866  if (!xdr_nfsstat(xdrs, &objp->rr_status)) {
867    return (FALSE);
868  }
869  switch (objp->rr_status) {
870  case NFS_OK:
871    if (!xdr_readokres(xdrs, &objp->rr_u.rr_reply_u)) {
872      return (FALSE);
873    }
874    break;
875  default:
876    break;
877  }
878  return (TRUE);
879}
880#endif /* not HAVE_XDR_READRES */
881
882
883#ifndef HAVE_XDR_RENAMEARGS
884bool_t
885xdr_renameargs(XDR *xdrs, nfsrenameargs *objp)
886{
887#ifdef DEBUG
888  amuDebug(D_TRACE)
889    plog(XLOG_DEBUG, "xdr_renameargs:");
890#endif /* DEBUG */
891
892  if (!xdr_diropargs(xdrs, &objp->rna_from)) {
893    return (FALSE);
894  }
895  if (!xdr_diropargs(xdrs, &objp->rna_to)) {
896    return (FALSE);
897  }
898  return (TRUE);
899}
900#endif /* not HAVE_XDR_RENAMEARGS */
901
902
903#ifndef HAVE_XDR_SATTR
904bool_t
905xdr_sattr(XDR *xdrs, nfssattr *objp)
906{
907#ifdef DEBUG
908  amuDebug(D_TRACE)
909    plog(XLOG_DEBUG, "xdr_sattr:");
910#endif /* DEBUG */
911
912  if (!xdr_u_int(xdrs, &objp->sa_mode)) {
913    return (FALSE);
914  }
915  if (!xdr_u_int(xdrs, &objp->sa_uid)) {
916    return (FALSE);
917  }
918  if (!xdr_u_int(xdrs, &objp->sa_gid)) {
919    return (FALSE);
920  }
921  if (!xdr_u_int(xdrs, &objp->sa_size)) {
922    return (FALSE);
923  }
924  if (!xdr_nfstime(xdrs, &objp->sa_atime)) {
925    return (FALSE);
926  }
927  if (!xdr_nfstime(xdrs, &objp->sa_mtime)) {
928    return (FALSE);
929  }
930  return (TRUE);
931}
932#endif /* not HAVE_XDR_SATTR */
933
934
935#ifndef HAVE_XDR_SATTRARGS
936bool_t
937xdr_sattrargs(XDR *xdrs, nfssattrargs *objp)
938{
939#ifdef DEBUG
940  amuDebug(D_TRACE)
941    plog(XLOG_DEBUG, "xdr_sattrargs:");
942#endif /* DEBUG */
943
944  if (!xdr_nfs_fh(xdrs, &objp->sag_fhandle)) {
945    return (FALSE);
946  }
947  if (!xdr_sattr(xdrs, &objp->sag_attributes)) {
948    return (FALSE);
949  }
950  return (TRUE);
951}
952#endif /* not HAVE_XDR_SATTRARGS */
953
954
955#ifndef HAVE_XDR_STATFSOKRES
956bool_t
957xdr_statfsokres(XDR *xdrs, nfsstatfsokres *objp)
958{
959#ifdef DEBUG
960  amuDebug(D_TRACE)
961    plog(XLOG_DEBUG, "xdr_statfsokres:");
962#endif /* DEBUG */
963
964  if (!xdr_u_int(xdrs, &objp->sfrok_tsize)) {
965    return (FALSE);
966  }
967  if (!xdr_u_int(xdrs, &objp->sfrok_bsize)) {
968    return (FALSE);
969  }
970  if (!xdr_u_int(xdrs, &objp->sfrok_blocks)) {
971    return (FALSE);
972  }
973  if (!xdr_u_int(xdrs, &objp->sfrok_bfree)) {
974    return (FALSE);
975  }
976  if (!xdr_u_int(xdrs, &objp->sfrok_bavail)) {
977    return (FALSE);
978  }
979  return (TRUE);
980}
981#endif /* not HAVE_XDR_STATFSOKRES */
982
983
984#ifndef HAVE_XDR_STATFSRES
985bool_t
986xdr_statfsres(XDR *xdrs, nfsstatfsres *objp)
987{
988#ifdef DEBUG
989  amuDebug(D_TRACE)
990    plog(XLOG_DEBUG, "xdr_statfsres:");
991#endif /* DEBUG */
992
993  if (!xdr_nfsstat(xdrs, &objp->sfr_status)) {
994    return (FALSE);
995  }
996  switch (objp->sfr_status) {
997  case NFS_OK:
998    if (!xdr_statfsokres(xdrs, &objp->sfr_u.sfr_reply_u)) {
999      return (FALSE);
1000    }
1001    break;
1002  default:
1003    break;
1004  }
1005  return (TRUE);
1006}
1007#endif /* not HAVE_XDR_STATFSRES */
1008
1009
1010#ifndef HAVE_XDR_SYMLINKARGS
1011bool_t
1012xdr_symlinkargs(XDR *xdrs, nfssymlinkargs *objp)
1013{
1014#ifdef DEBUG
1015  amuDebug(D_TRACE)
1016    plog(XLOG_DEBUG, "xdr_symlinkargs:");
1017#endif /* DEBUG */
1018
1019  if (!xdr_diropargs(xdrs, &objp->sla_from)) {
1020    return (FALSE);
1021  }
1022  if (!xdr_nfspath(xdrs, &objp->sla_to)) {
1023    return (FALSE);
1024  }
1025  if (!xdr_sattr(xdrs, &objp->sla_attributes)) {
1026    return (FALSE);
1027  }
1028  return (TRUE);
1029}
1030#endif /* not HAVE_XDR_SYMLINKARGS */
1031
1032
1033#ifndef HAVE_XDR_WRITEARGS
1034bool_t
1035xdr_writeargs(XDR *xdrs, nfswriteargs *objp)
1036{
1037#ifdef DEBUG
1038  amuDebug(D_TRACE)
1039    plog(XLOG_DEBUG, "xdr_writeargs:");
1040#endif /* DEBUG */
1041
1042  if (!xdr_nfs_fh(xdrs, &objp->wra_fhandle)) {
1043    return (FALSE);
1044  }
1045  if (!xdr_u_int(xdrs, &objp->wra_beginoffset)) {
1046    return (FALSE);
1047  }
1048  if (!xdr_u_int(xdrs, &objp->wra_offset)) {
1049    return (FALSE);
1050  }
1051  if (!xdr_u_int(xdrs, &objp->wra_totalcount)) {
1052    return (FALSE);
1053  }
1054  if (!xdr_bytes(xdrs,
1055		 (char **) & objp->wra_u.wra_val_u,
1056		 (u_int *) & objp->wra_u.wra_len_u,
1057		 NFS_MAXDATA)) {
1058    return (FALSE);
1059  }
1060  return (TRUE);
1061}
1062#endif /* not HAVE_XDR_WRITEARGS */
1063
1064
1065/*
1066 * AUTOFS XDR FUNCTIONS:
1067 */
1068#ifdef HAVE_FS_AUTOFS
1069# ifndef HAVE_XDR_MNTREQUEST
1070bool_t
1071xdr_mntrequest(XDR *xdrs, mntrequest *objp)
1072{
1073#ifdef DEBUG
1074  amuDebug(D_TRACE)
1075    plog(XLOG_DEBUG, "xdr_mntrequest:");
1076#endif /* DEBUG */
1077
1078  if (!xdr_string(xdrs, &objp->name, A_MAXNAME))
1079    return (FALSE);
1080
1081  if (!xdr_string(xdrs, &objp->map, A_MAXNAME))
1082    return (FALSE);
1083
1084  if (!xdr_string(xdrs, &objp->opts, A_MAXOPTS))
1085    return (FALSE);
1086
1087  if (!xdr_string(xdrs, &objp->path, A_MAXPATH))
1088    return (FALSE);
1089
1090  return (TRUE);
1091}
1092# endif /* not HAVE_XDR_MNTREQUEST */
1093
1094
1095# ifndef HAVE_XDR_MNTRES
1096bool_t
1097xdr_mntres(XDR *xdrs, mntres *objp)
1098{
1099#ifdef DEBUG
1100  amuDebug(D_TRACE)
1101    plog(XLOG_DEBUG, "xdr_mntres:");
1102#endif /* DEBUG */
1103
1104  if (!xdr_int(xdrs, &objp->status))
1105    return (FALSE);
1106
1107  return (TRUE);
1108}
1109# endif /* not HAVE_XDR_MNTRES */
1110
1111
1112# ifndef HAVE_XDR_UMNTREQUEST
1113bool_t
1114xdr_umntrequest(XDR *xdrs, umntrequest *objp)
1115{
1116#ifdef DEBUG
1117  amuDebug(D_TRACE)
1118    plog(XLOG_DEBUG, "xdr_umntrequest:");
1119#endif /* DEBUG */
1120
1121  if (!xdr_int(xdrs, &objp->isdirect))
1122    return (FALSE);
1123
1124  if (!xdr_u_int(xdrs, (u_int *) &objp->devid))
1125    return (FALSE);
1126
1127#ifdef HAVE_FIELD_UMNTREQUEST_RDEVID
1128  if (!xdr_u_long(xdrs, &objp->rdevid))
1129    return (FALSE);
1130#endif /* HAVE_FIELD_UMNTREQUEST_RDEVID */
1131
1132  if (!xdr_pointer(xdrs, (char **) &objp->next, sizeof(umntrequest), (XDRPROC_T_TYPE) xdr_umntrequest))
1133    return (FALSE);
1134
1135  return (TRUE);
1136}
1137# endif /* not HAVE_XDR_UMNTREQUEST */
1138
1139
1140# ifndef HAVE_XDR_UMNTRES
1141bool_t
1142xdr_umntres(XDR *xdrs, umntres *objp)
1143{
1144#ifdef DEBUG
1145  amuDebug(D_TRACE)
1146    plog(XLOG_DEBUG, "xdr_mntres:");
1147#endif /* DEBUG */
1148
1149  if (!xdr_int(xdrs, &objp->status))
1150    return (FALSE);
1151
1152  return (TRUE);
1153}
1154# endif /* not HAVE_XDR_UMNTRES */
1155#endif /* HAVE_FS_AUTOFS */
1156