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