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