xdr_func.c revision 82794
172878Skris/*
272878Skris * Copyright (c) 1997-2001 Erez Zadok
3100772Sjhb * Copyright (c) 1990 Jan-Simon Pendry
4100772Sjhb * Copyright (c) 1990 Imperial College of Science, Technology & Medicine
5100772Sjhb * Copyright (c) 1990 The Regents of the University of California.
672878Skris * All rights reserved.
7101232Sru *
8136606Sobrien * This code is derived from software contributed to Berkeley by
9212540Simp * Jan-Simon Pendry at Imperial College, London.
10113374Sobrien *
11212540Simp * Redistribution and use in source and binary forms, with or without
12206973Sdelphij * modification, are permitted provided that the following conditions
13212540Simp * are met:
14103560Sjhb * 1. Redistributions of source code must retain the above copyright
15212540Simp *    notice, this list of conditions and the following disclaimer.
16176776Sraj * 2. Redistributions in binary form must reproduce the above copyright
17212540Simp *    notice, this list of conditions and the following disclaimer in the
18216820Smarius *    documentation and/or other materials provided with the distribution.
19212540Simp * 3. All advertising materials mentioning features or use of this software
20129217Scognet *    must display the following acknowledgment:
21212540Simp *      This product includes software developed by the University of
22177385Simp *      California, Berkeley and its contributors.
23100773Sjhb * 4. Neither the name of the University nor the names of its contributors
24100772Sjhb *    may be used to endorse or promote products derived from this software
2572878Skris *    without specific prior written permission.
2672878Skris *
2772878Skris * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
2872878Skris * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
29212540Simp * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
30243310Sjkim * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
31243310Sjkim * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
32243310Sjkim * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
33166071Sdes * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
34136607Sobrien * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
35136606Sobrien * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
36136606Sobrien * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
37136606Sobrien * SUCH DAMAGE.
38136606Sobrien *
39136606Sobrien *      %W% (Berkeley) %G%
40136606Sobrien *
41136606Sobrien * $Id: xdr_func.c,v 1.4.2.4 2001/02/02 18:28:27 ezk Exp $
42136606Sobrien *
43136606Sobrien */
44136606Sobrien
45136606Sobrien/*
46136606Sobrien * Complete list of all possible xdr functions which may be needed.
47136606Sobrien */
48136606Sobrien#ifdef HAVE_CONFIG_H
49136606Sobrien# include <config.h>
50136606Sobrien#endif /* HAVE_CONFIG_H */
51136606Sobrien#include <am_defs.h>
52218896Smm#include <amu.h>
53243310Sjkim
54243310Sjkim
55218896Smm/*
56136607Sobrien * MACROS:
57243310Sjkim */
58133525Sobrien#ifdef HAVE_FS_AUTOFS
59103045Smux# ifndef A_MAXNAME
60103045Smux#  define A_MAXNAME 255
61100773Sjhb# endif /* not A_MAXNAME */
62212540Simp# ifndef A_MAXOPTS
63219376Smm#  define A_MAXOPTS 255
64136607Sobrien# endif /* not A_MAXOPTS */
65136607Sobrien# ifndef A_MAXPATH
66216820Smarius#  define A_MAXPATH 1024
67216820Smarius# endif /* not A_MAXPATH */
68216820Smarius#endif /* HAVE_FS_AUTOFS */
69216820Smarius
70216820Smarius/* forward definitions, are they needed? */
71216820Smariusextern bool_t xdr_exportnode(XDR *xdrs, exportnode *objp);
7272878Skrisextern bool_t xdr_groupnode(XDR *xdrs, groupnode *objp);
7372878Skrisextern bool_t xdr_name(XDR *xdrs, name *objp);
74136606Sobrien
7596421Sobrien
7672878Skris#ifndef HAVE_XDR_ATTRSTAT
7796421Sobrienbool_t
78160536Simpxdr_attrstat(XDR *xdrs, nfsattrstat *objp)
79179989Sale{
80179989Sale#ifdef DEBUG
81177385Simp  amuDebug(D_XDRTRACE)
8296421Sobrien    plog(XLOG_DEBUG, "xdr_attrstat:");
83179989Sale#endif /* DEBUG */
8472878Skris
85212540Simp  if (!xdr_nfsstat(xdrs, &objp->ns_status)) {
86127888Sdfr    return (FALSE);
87133000Sobrien  }
88136606Sobrien  switch (objp->ns_status) {
89136606Sobrien  case NFS_OK:
90219640Smm    if (!xdr_fattr(xdrs, &objp->ns_u.ns_attr_u)) {
91219640Smm      return (FALSE);
92136606Sobrien    }
93136606Sobrien    break;
94136606Sobrien  default:
95212540Simp    break;
96136607Sobrien  }
97212540Simp  return (TRUE);
98136606Sobrien}
99172706Scognet#endif /* not HAVE_XDR_ATTRSTAT */
100172706Scognet
101239272Sgonzo
102239272Sgonzo#ifndef HAVE_XDR_CREATEARGS
103239272Sgonzobool_t
104239272Sgonzoxdr_createargs(XDR *xdrs, nfscreateargs *objp)
105239272Sgonzo{
106136606Sobrien#ifdef DEBUG
107239272Sgonzo  amuDebug(D_XDRTRACE)
108135678Scognet    plog(XLOG_DEBUG, "xdr_createargs:");
109215274Simp#endif /* DEBUG */
110176776Sraj
111176776Sraj  if (!xdr_diropargs(xdrs, &objp->ca_where)) {
112188923Snwhitehorn    return (FALSE);
113190681Snwhitehorn  }
114176776Sraj  if (!xdr_sattr(xdrs, &objp->ca_attributes)) {
115209868Snwhitehorn    return (FALSE);
116209868Snwhitehorn  }
117212540Simp  return (TRUE);
118177385Simp}
119177385Simp#endif /* not HAVE_XDR_CREATEARGS */
120177385Simp
121177385Simp
122177385Simp#ifndef HAVE_XDR_DIRLIST
123177385Simpbool_t
124177385Simpxdr_dirlist(XDR *xdrs, nfsdirlist *objp)
125177385Simp{
126177385Simp#ifdef DEBUG
127177385Simp  amuDebug(D_XDRTRACE)
128177385Simp    plog(XLOG_DEBUG, "xdr_dirlist:");
129177385Simp#endif /* DEBUG */
130177385Simp
131216820Smarius  if (!xdr_pointer(xdrs, (char **) &objp->dl_entries, sizeof(nfsentry), (XDRPROC_T_TYPE) xdr_entry)) {
132216820Smarius    return (FALSE);
133216820Smarius  }
134216820Smarius  if (!xdr_bool(xdrs, &objp->dl_eof)) {
135216820Smarius    return (FALSE);
136216820Smarius  }
137216820Smarius  return (TRUE);
138216820Smarius}
13972878Skris#endif /* not HAVE_XDR_DIRLIST */
14072878Skris
14172878Skris
14272878Skris#ifndef HAVE_XDR_DIROPARGS
14372878Skrisbool_t
14472878Skrisxdr_diropargs(XDR *xdrs, nfsdiropargs *objp)
145212540Simp{
146243310Sjkim#ifdef DEBUG
147243310Sjkim  amuDebug(D_XDRTRACE)
148243310Sjkim    plog(XLOG_DEBUG, "xdr_diropargs:");
149243310Sjkim#endif /* DEBUG */
150243310Sjkim
151243310Sjkim  if (!xdr_nfs_fh(xdrs, &objp->da_fhandle)) {
152243310Sjkim    return (FALSE);
153243310Sjkim  }
154243310Sjkim  if (!xdr_filename(xdrs, &objp->da_name)) {
155218896Smm    return (FALSE);
156218896Smm  }
157136607Sobrien  return (TRUE);
158136607Sobrien}
159125254Sbde#endif /* not HAVE_XDR_DIROPARGS */
160136606Sobrien
161126657Sbde
162112768Sobrien#ifndef HAVE_XDR_DIROPOKRES
163219376Smmbool_t
164103045Smuxxdr_diropokres(XDR *xdrs, nfsdiropokres *objp)
165103562Sjhb{
16674069Ssobomax#ifdef DEBUG
167103562Sjhb  amuDebug(D_XDRTRACE)
16872878Skris    plog(XLOG_DEBUG, "xdr_diropokres:");
169160497Sdes#endif /* DEBUG */
170161259Sdes
171160497Sdes  if (!xdr_nfs_fh(xdrs, &objp->drok_fhandle)) {
172160497Sdes    return (FALSE);
173176665Sjhb  }
174176665Sjhb  if (!xdr_fattr(xdrs, &objp->drok_attributes)) {
175243310Sjkim    return (FALSE);
176243310Sjkim  }
177243310Sjkim  return (TRUE);
178243310Sjkim}
179219640Smm#endif /* not HAVE_XDR_DIROPOKRES */
180219640Smm
181166071Sdes
182166069Sdes#ifndef HAVE_XDR_DIROPRES
183243310Sjkimbool_t
184243310Sjkimxdr_diropres(XDR *xdrs, nfsdiropres *objp)
185103045Smux{
186136606Sobrien#ifdef DEBUG
18773145Skris  amuDebug(D_XDRTRACE)
188136606Sobrien    plog(XLOG_DEBUG, "xdr_diropres:");
18974553Skris#endif /* DEBUG */
190136606Sobrien
19172878Skris  if (!xdr_nfsstat(xdrs, &objp->dr_status)) {
192136606Sobrien    return (FALSE);
19373145Skris  }
194136606Sobrien  switch (objp->dr_status) {
19572878Skris  case NFS_OK:
196103562Sjhb    if (!xdr_diropokres(xdrs, &objp->dr_u.dr_drok_u)) {
19772878Skris      return (FALSE);
198103562Sjhb    }
19972878Skris    break;
200103562Sjhb  default:
201212540Simp    break;
202243310Sjkim  }
203243310Sjkim  return (TRUE);
204243310Sjkim}
205243310Sjkim#endif /* not HAVE_XDR_DIROPRES */
206243310Sjkim
207243310Sjkim
208243310Sjkim#ifndef HAVE_XDR_DIRPATH
209243310Sjkimbool_t
210218896Smmxdr_dirpath(XDR *xdrs, dirpath *objp)
211243310Sjkim{
212243310Sjkim#ifdef DEBUG
213138685Sobrien  amuDebug(D_XDRTRACE)
214243310Sjkim    plog(XLOG_DEBUG, "xdr_dirpath:");
215243310Sjkim#endif /* DEBUG */
216243310Sjkim
217243310Sjkim  if (!xdr_string(xdrs, objp, MNTPATHLEN)) {
218219640Smm    return (FALSE);
219219640Smm  }
220219640Smm  return (TRUE);
221138685Sobrien}
222136607Sobrien#endif /* not HAVE_XDR_DIRPATH */
223138685Sobrien
224212540Simp
225103562Sjhb#ifndef HAVE_XDR_ENTRY
22672878Skrisbool_t
227103562Sjhbxdr_entry(XDR *xdrs, nfsentry *objp)
228216820Smarius{
229216820Smarius#ifdef DEBUG
230216820Smarius  amuDebug(D_XDRTRACE)
231216820Smarius    plog(XLOG_DEBUG, "xdr_entry:");
232216820Smarius#endif /* DEBUG */
233216820Smarius
234216820Smarius  if (!xdr_u_int(xdrs, &objp->ne_fileid)) {
235216820Smarius    return (FALSE);
236216820Smarius  }
237216820Smarius  if (!xdr_filename(xdrs, &objp->ne_name)) {
238216820Smarius    return (FALSE);
239216820Smarius  }
24072878Skris  if (!xdr_nfscookie(xdrs, objp->ne_cookie)) {
24172878Skris    return (FALSE);
242103561Sjhb  }
243216820Smarius  if (!xdr_pointer(xdrs, (char **) &objp->ne_nextentry, sizeof(nfsentry), (XDRPROC_T_TYPE) xdr_entry)) {
244204559Simp    return (FALSE);
245177385Simp  }
246177385Simp  return (TRUE);
247124347Sru}
248103561Sjhb#endif /* not HAVE_XDR_ENTRY */
249103561Sjhb
250103561Sjhb
251103561Sjhb#ifndef HAVE_XDR_EXPORTNODE
252bool_t
253xdr_exportnode(XDR *xdrs, exportnode *objp)
254{
255#ifdef DEBUG
256  amuDebug(D_XDRTRACE)
257    plog(XLOG_DEBUG, "xdr_exportnode:");
258#endif /* DEBUG */
259
260  if (!xdr_dirpath(xdrs, &objp->ex_dir)) {
261    return (FALSE);
262  }
263  if (!xdr_groups(xdrs, &objp->ex_groups)) {
264    return (FALSE);
265  }
266  if (!xdr_exports(xdrs, &objp->ex_next)) {
267    return (FALSE);
268  }
269  return (TRUE);
270}
271#endif /* not HAVE_XDR_EXPORTNODE */
272
273
274#ifndef HAVE_XDR_EXPORTS
275bool_t
276xdr_exports(XDR *xdrs, exports *objp)
277{
278#ifdef DEBUG
279  amuDebug(D_XDRTRACE)
280    plog(XLOG_DEBUG, "xdr_exports:");
281#endif /* DEBUG */
282
283  if (!xdr_pointer(xdrs, (char **) objp, sizeof(exportnode), (XDRPROC_T_TYPE) xdr_exportnode)) {
284    return (FALSE);
285  }
286  return (TRUE);
287}
288#endif /* not HAVE_XDR_EXPORTS */
289
290
291#ifndef HAVE_XDR_FATTR
292bool_t
293xdr_fattr(XDR *xdrs, nfsfattr *objp)
294{
295#ifdef DEBUG
296  amuDebug(D_XDRTRACE)
297    plog(XLOG_DEBUG, "xdr_fattr:");
298#endif /* DEBUG */
299
300  if (!xdr_ftype(xdrs, &objp->na_type)) {
301    return (FALSE);
302  }
303  if (!xdr_u_int(xdrs, &objp->na_mode)) {
304    return (FALSE);
305  }
306  if (!xdr_u_int(xdrs, &objp->na_nlink)) {
307    return (FALSE);
308  }
309  if (!xdr_u_int(xdrs, &objp->na_uid)) {
310    return (FALSE);
311  }
312  if (!xdr_u_int(xdrs, &objp->na_gid)) {
313    return (FALSE);
314  }
315  if (!xdr_u_int(xdrs, &objp->na_size)) {
316    return (FALSE);
317  }
318  if (!xdr_u_int(xdrs, &objp->na_blocksize)) {
319    return (FALSE);
320  }
321  if (!xdr_u_int(xdrs, &objp->na_rdev)) {
322    return (FALSE);
323  }
324  if (!xdr_u_int(xdrs, &objp->na_blocks)) {
325    return (FALSE);
326  }
327  if (!xdr_u_int(xdrs, &objp->na_fsid)) {
328    return (FALSE);
329  }
330  if (!xdr_u_int(xdrs, &objp->na_fileid)) {
331    return (FALSE);
332  }
333  if (!xdr_nfstime(xdrs, &objp->na_atime)) {
334    return (FALSE);
335  }
336  if (!xdr_nfstime(xdrs, &objp->na_mtime)) {
337    return (FALSE);
338  }
339  if (!xdr_nfstime(xdrs, &objp->na_ctime)) {
340    return (FALSE);
341  }
342  return (TRUE);
343}
344#endif /* not HAVE_XDR_FATTR */
345
346
347#ifndef HAVE_XDR_FHANDLE
348bool_t
349xdr_fhandle(XDR *xdrs, fhandle objp)
350{
351#ifdef DEBUG
352  amuDebug(D_XDRTRACE)
353    plog(XLOG_DEBUG, "xdr_fhandle:");
354#endif /* DEBUG */
355
356  if (!xdr_opaque(xdrs, objp, NFS_FHSIZE)) {
357    return (FALSE);
358  }
359  return (TRUE);
360}
361#endif /* not HAVE_XDR_FHANDLE */
362
363
364#ifndef HAVE_XDR_FHSTATUS
365bool_t
366xdr_fhstatus(XDR *xdrs, fhstatus *objp)
367{
368#ifdef DEBUG
369  amuDebug(D_XDRTRACE)
370    plog(XLOG_DEBUG, "xdr_fhstatus:");
371#endif /* DEBUG */
372
373  if (!xdr_u_int(xdrs, &objp->fhs_status)) {
374    return (FALSE);
375  }
376  if (objp->fhs_status == 0 && !xdr_fhandle(xdrs, objp->fhs_fh)) {
377    return (FALSE);
378  }
379  return (TRUE);
380}
381#endif /* not HAVE_XDR_FHSTATUS */
382
383
384#ifndef HAVE_XDR_FILENAME
385bool_t
386xdr_filename(XDR *xdrs, filename *objp)
387{
388#ifdef DEBUG
389  amuDebug(D_XDRTRACE)
390    plog(XLOG_DEBUG, "xdr_filename:");
391#endif /* DEBUG */
392
393  if (!xdr_string(xdrs, objp, NFS_MAXNAMLEN)) {
394    return (FALSE);
395  }
396  return (TRUE);
397}
398#endif /* not HAVE_XDR_FILENAME */
399
400
401#ifndef HAVE_XDR_FTYPE
402bool_t
403xdr_ftype(XDR *xdrs, nfsftype *objp)
404{
405#ifdef DEBUG
406  amuDebug(D_XDRTRACE)
407    plog(XLOG_DEBUG, "xdr_ftype:");
408#endif /* DEBUG */
409
410  if (!xdr_enum(xdrs, (enum_t *) objp)) {
411    return (FALSE);
412  }
413  return (TRUE);
414}
415#endif /* not HAVE_XDR_FTYPE */
416
417
418#ifndef HAVE_XDR_GROUPNODE
419bool_t
420xdr_groupnode(XDR *xdrs, groupnode *objp)
421{
422#ifdef DEBUG
423  amuDebug(D_XDRTRACE)
424    plog(XLOG_DEBUG, "xdr_groupnode:");
425#endif /* DEBUG */
426
427  if (!xdr_name(xdrs, &objp->gr_name)) {
428    return (FALSE);
429  }
430  if (!xdr_groups(xdrs, &objp->gr_next)) {
431    return (FALSE);
432  }
433  return (TRUE);
434}
435#endif /* not HAVE_XDR_GROUPNODE */
436
437
438#ifndef HAVE_XDR_GROUPS
439bool_t
440xdr_groups(XDR *xdrs, groups *objp)
441{
442#ifdef DEBUG
443  amuDebug(D_XDRTRACE)
444    plog(XLOG_DEBUG, "xdr_groups:");
445#endif /* DEBUG */
446
447  if (!xdr_pointer(xdrs, (char **) objp, sizeof(groupnode), (XDRPROC_T_TYPE) xdr_groupnode)) {
448    return (FALSE);
449  }
450  return (TRUE);
451}
452#endif /* not HAVE_XDR_GROUPS */
453
454
455#ifndef HAVE_XDR_LINKARGS
456bool_t
457xdr_linkargs(XDR *xdrs, nfslinkargs *objp)
458{
459#ifdef DEBUG
460  amuDebug(D_XDRTRACE)
461    plog(XLOG_DEBUG, "xdr_linkargs:");
462#endif /* DEBUG */
463
464  if (!xdr_nfs_fh(xdrs, &objp->la_fhandle)) {
465    return (FALSE);
466  }
467  if (!xdr_diropargs(xdrs, &objp->la_to)) {
468    return (FALSE);
469  }
470  return (TRUE);
471}
472#endif /* not HAVE_XDR_LINKARGS */
473
474
475#ifndef HAVE_XDR_MOUNTBODY
476bool_t
477xdr_mountbody(XDR *xdrs, mountbody *objp)
478{
479#ifdef DEBUG
480  amuDebug(D_XDRTRACE)
481    plog(XLOG_DEBUG, "xdr_mountbody:");
482#endif /* DEBUG */
483
484  if (!xdr_name(xdrs, &objp->ml_hostname)) {
485    return (FALSE);
486  }
487  if (!xdr_dirpath(xdrs, &objp->ml_directory)) {
488    return (FALSE);
489  }
490  if (!xdr_mountlist(xdrs, &objp->ml_next)) {
491    return (FALSE);
492  }
493  return (TRUE);
494}
495#endif /* not HAVE_XDR_MOUNTBODY */
496
497
498#ifndef HAVE_XDR_MOUNTLIST
499bool_t
500xdr_mountlist(XDR *xdrs, mountlist *objp)
501{
502#ifdef DEBUG
503  amuDebug(D_XDRTRACE)
504    plog(XLOG_DEBUG, "xdr_mountlist:");
505#endif /* DEBUG */
506
507  if (!xdr_pointer(xdrs, (char **) objp, sizeof(mountbody), (XDRPROC_T_TYPE) xdr_mountbody)) {
508    return (FALSE);
509  }
510  return (TRUE);
511}
512#endif /* not HAVE_XDR_MOUNTLIST */
513
514
515#if defined(HAVE_FS_NFS3) && !defined(HAVE_XDR_MOUNTRES3)
516/*
517 * This ifdef is a hack: this whole file needs to be compiled
518 * only if the system has NFS V3 and does not have the xdr_mountres3
519 * function.  Autoconf should pick this source file to compile only
520 * if these two conditions apply.
521 */
522
523bool_t
524xdr_fhandle3(XDR *xdrs, fhandle3 *objp)
525{
526#ifdef DEBUG
527  amuDebug(D_XDRTRACE)
528    plog(XLOG_DEBUG, "xdr_fhandle3:");
529#endif /* DEBUG */
530
531  if (!xdr_bytes(xdrs,
532		 (char **) &objp->fhandle3_val,
533		 (u_int *) &objp->fhandle3_len,
534		 FHSIZE3))
535    return (FALSE);
536  return (TRUE);
537}
538
539
540bool_t
541xdr_mountstat3(XDR *xdrs, mountstat3 *objp)
542{
543#ifdef DEBUG
544  amuDebug(D_XDRTRACE)
545    plog(XLOG_DEBUG, "xdr_mountstat3:");
546#endif /* DEBUG */
547
548  if (!xdr_enum(xdrs, (enum_t *)objp))
549    return (FALSE);
550  return (TRUE);
551}
552
553
554bool_t
555xdr_mountres3_ok(XDR *xdrs, mountres3_ok *objp)
556{
557#ifdef DEBUG
558  amuDebug(D_XDRTRACE)
559    plog(XLOG_DEBUG, "xdr_mountres3_ok:");
560#endif /* DEBUG */
561
562  if (!xdr_fhandle3(xdrs, &objp->fhandle))
563    return (FALSE);
564  if (!xdr_array(xdrs,
565		 (char **)&objp->auth_flavors.auth_flavors_val,
566		 (u_int *) &objp->auth_flavors.auth_flavors_len,
567		 ~0,
568		 sizeof (int),
569		 (xdrproc_t) xdr_int))
570    return (FALSE);
571  return (TRUE);
572}
573
574
575bool_t
576xdr_mountres3(XDR *xdrs, mountres3 *objp)
577{
578#ifdef DEBUG
579  amuDebug(D_XDRTRACE)
580    plog(XLOG_DEBUG, "xdr_mountres3:");
581#endif /* DEBUG */
582
583  if (!xdr_mountstat3(xdrs, &objp->fhs_status))
584    return (FALSE);
585
586  if (objp->fhs_status == 0) {	/* 0 == MNT_OK or MNT3_OK */
587    if (!xdr_mountres3_ok(xdrs, &objp->mountres3_u.mountinfo))
588      return (FALSE);
589  }
590  return (TRUE);
591}
592#endif /* defined(HAVE_FS_NFS3) && !defined(HAVE_XDR_MOUNTRES3) */
593
594
595#ifndef HAVE_XDR_NAME
596bool_t
597xdr_name(XDR *xdrs, name *objp)
598{
599#ifdef DEBUG
600  amuDebug(D_XDRTRACE)
601    plog(XLOG_DEBUG, "xdr_name:");
602#endif /* DEBUG */
603
604  if (!xdr_string(xdrs, objp, MNTNAMLEN)) {
605    return (FALSE);
606  }
607  return (TRUE);
608}
609#endif /* not HAVE_XDR_NAME */
610
611
612#ifndef HAVE_XDR_NFS_FH
613bool_t
614xdr_nfs_fh(XDR *xdrs, am_nfs_fh *objp)
615{
616#ifdef DEBUG
617  amuDebug(D_XDRTRACE)
618    plog(XLOG_DEBUG, "xdr_nfs_fh:");
619#endif /* DEBUG */
620
621  if (!xdr_opaque(xdrs, (caddr_t) objp->fh_data, NFS_FHSIZE)) {
622    return (FALSE);
623  }
624  return (TRUE);
625}
626#endif /* not HAVE_XDR_NFS_FH */
627
628
629#ifndef HAVE_XDR_NFSCOOKIE
630bool_t
631xdr_nfscookie(XDR *xdrs, nfscookie objp)
632{
633#ifdef DEBUG
634  amuDebug(D_XDRTRACE)
635    plog(XLOG_DEBUG, "xdr_nfscookie:");
636#endif /* DEBUG */
637
638  if (!xdr_opaque(xdrs, objp, NFS_COOKIESIZE)) {
639    return (FALSE);
640  }
641  return (TRUE);
642}
643#endif /* not HAVE_XDR_NFSCOOKIE */
644
645
646#ifndef HAVE_XDR_NFSPATH
647bool_t
648xdr_nfspath(XDR *xdrs, nfspath *objp)
649{
650#ifdef DEBUG
651  amuDebug(D_XDRTRACE)
652    plog(XLOG_DEBUG, "xdr_nfspath:");
653#endif /* DEBUG */
654
655  if (!xdr_string(xdrs, objp, NFS_MAXPATHLEN)) {
656    return (FALSE);
657  }
658  return (TRUE);
659}
660#endif /* not HAVE_XDR_NFSPATH */
661
662
663#ifndef HAVE_XDR_NFSSTAT
664bool_t
665xdr_nfsstat(XDR *xdrs, nfsstat *objp)
666{
667#ifdef DEBUG
668  amuDebug(D_XDRTRACE)
669    plog(XLOG_DEBUG, "xdr_nfsstat:");
670#endif /* DEBUG */
671
672  if (!xdr_enum(xdrs, (enum_t *) objp)) {
673    return (FALSE);
674  }
675  return (TRUE);
676}
677#endif /* not HAVE_XDR_NFSSTAT */
678
679
680#ifndef HAVE_XDR_NFSTIME
681bool_t
682xdr_nfstime(XDR *xdrs, nfstime *objp)
683{
684#ifdef DEBUG
685  amuDebug(D_XDRTRACE)
686    plog(XLOG_DEBUG, "xdr_nfstime:");
687#endif /* DEBUG */
688
689  if (!xdr_u_int(xdrs, (u_int *) &objp->nt_seconds)) {
690    return (FALSE);
691  }
692  if (!xdr_u_int(xdrs, (u_int *) &objp->nt_useconds)) {
693    return (FALSE);
694  }
695  return (TRUE);
696}
697#endif /* not HAVE_XDR_NFSTIME */
698
699
700#ifndef HAVE_XDR_POINTER
701bool_t
702xdr_pointer(register XDR *xdrs, char **objpp, u_int obj_size, XDRPROC_T_TYPE xdr_obj)
703{
704#ifdef DEBUG
705  amuDebug(D_XDRTRACE)
706    plog(XLOG_DEBUG, "xdr_pointer:");
707#endif /* DEBUG */
708
709
710  bool_t more_data;
711
712  more_data = (*objpp != NULL);
713  if (!xdr_bool(xdrs, &more_data)) {
714    return (FALSE);
715  }
716  if (!more_data) {
717    *objpp = NULL;
718    return (TRUE);
719  }
720
721  return (xdr_reference(xdrs, objpp, obj_size, xdr_obj));
722}
723#endif /* not HAVE_XDR_POINTER */
724
725
726#ifndef HAVE_XDR_READARGS
727bool_t
728xdr_readargs(XDR *xdrs, nfsreadargs *objp)
729{
730#ifdef DEBUG
731  amuDebug(D_XDRTRACE)
732    plog(XLOG_DEBUG, "xdr_readargs:");
733#endif /* DEBUG */
734
735  if (!xdr_nfs_fh(xdrs, &objp->ra_fhandle)) {
736    return (FALSE);
737  }
738  if (!xdr_u_int(xdrs, &objp->ra_offset)) {
739    return (FALSE);
740  }
741  if (!xdr_u_int(xdrs, &objp->ra_count)) {
742    return (FALSE);
743  }
744  if (!xdr_u_int(xdrs, &objp->ra_totalcount)) {
745    return (FALSE);
746  }
747  return (TRUE);
748}
749#endif /* not HAVE_XDR_READARGS */
750
751
752#ifndef HAVE_XDR_READDIRARGS
753bool_t
754xdr_readdirargs(XDR *xdrs, nfsreaddirargs *objp)
755{
756#ifdef DEBUG
757  amuDebug(D_XDRTRACE)
758    plog(XLOG_DEBUG, "xdr_readdirargs:");
759#endif /* DEBUG */
760
761  if (!xdr_nfs_fh(xdrs, &objp->rda_fhandle)) {
762    return (FALSE);
763  }
764  if (!xdr_nfscookie(xdrs, objp->rda_cookie)) {
765    return (FALSE);
766  }
767  if (!xdr_u_int(xdrs, &objp->rda_count)) {
768    return (FALSE);
769  }
770  return (TRUE);
771}
772#endif /* not HAVE_XDR_READDIRARGS */
773
774
775#ifndef HAVE_XDR_READDIRRES
776bool_t
777xdr_readdirres(XDR *xdrs, nfsreaddirres *objp)
778{
779#ifdef DEBUG
780  amuDebug(D_XDRTRACE)
781    plog(XLOG_DEBUG, "xdr_readdirres:");
782#endif /* DEBUG */
783
784  if (!xdr_nfsstat(xdrs, &objp->rdr_status)) {
785    return (FALSE);
786  }
787  switch (objp->rdr_status) {
788  case NFS_OK:
789    if (!xdr_dirlist(xdrs, &objp->rdr_u.rdr_reply_u)) {
790      return (FALSE);
791    }
792    break;
793  default:
794    break;
795  }
796  return (TRUE);
797}
798#endif /* not HAVE_XDR_READDIRRES */
799
800
801#ifndef HAVE_XDR_READLINKRES
802bool_t
803xdr_readlinkres(XDR *xdrs, nfsreadlinkres *objp)
804{
805#ifdef DEBUG
806  amuDebug(D_XDRTRACE)
807    plog(XLOG_DEBUG, "xdr_readlinkres:");
808#endif /* DEBUG */
809
810  if (!xdr_nfsstat(xdrs, &objp->rlr_status)) {
811    return (FALSE);
812  }
813  switch (objp->rlr_status) {
814  case NFS_OK:
815    if (!xdr_nfspath(xdrs, &objp->rlr_u.rlr_data_u)) {
816      return (FALSE);
817    }
818    break;
819  default:
820    break;
821  }
822  return (TRUE);
823}
824#endif /* not HAVE_XDR_READLINKRES */
825
826
827#ifndef HAVE_XDR_READOKRES
828bool_t
829xdr_readokres(XDR *xdrs, nfsreadokres *objp)
830{
831#ifdef DEBUG
832  amuDebug(D_XDRTRACE)
833    plog(XLOG_DEBUG, "xdr_readokres:");
834#endif /* DEBUG */
835
836  if (!xdr_fattr(xdrs, &objp->raok_attributes)) {
837    return (FALSE);
838  }
839  if (!xdr_bytes(xdrs,
840		 (char **) & objp->raok_u.raok_val_u,
841		 (u_int *) & objp->raok_u.raok_len_u,
842		 NFS_MAXDATA)) {
843    return (FALSE);
844  }
845  return (TRUE);
846}
847#endif /* not HAVE_XDR_READOKRES */
848
849
850#ifndef HAVE_XDR_READRES
851bool_t
852xdr_readres(XDR *xdrs, nfsreadres *objp)
853{
854#ifdef DEBUG
855  amuDebug(D_XDRTRACE)
856    plog(XLOG_DEBUG, "xdr_readres:");
857#endif /* DEBUG */
858
859  if (!xdr_nfsstat(xdrs, &objp->rr_status)) {
860    return (FALSE);
861  }
862  switch (objp->rr_status) {
863  case NFS_OK:
864    if (!xdr_readokres(xdrs, &objp->rr_u.rr_reply_u)) {
865      return (FALSE);
866    }
867    break;
868  default:
869    break;
870  }
871  return (TRUE);
872}
873#endif /* not HAVE_XDR_READRES */
874
875
876#ifndef HAVE_XDR_RENAMEARGS
877bool_t
878xdr_renameargs(XDR *xdrs, nfsrenameargs *objp)
879{
880#ifdef DEBUG
881  amuDebug(D_XDRTRACE)
882    plog(XLOG_DEBUG, "xdr_renameargs:");
883#endif /* DEBUG */
884
885  if (!xdr_diropargs(xdrs, &objp->rna_from)) {
886    return (FALSE);
887  }
888  if (!xdr_diropargs(xdrs, &objp->rna_to)) {
889    return (FALSE);
890  }
891  return (TRUE);
892}
893#endif /* not HAVE_XDR_RENAMEARGS */
894
895
896#ifndef HAVE_XDR_SATTR
897bool_t
898xdr_sattr(XDR *xdrs, nfssattr *objp)
899{
900#ifdef DEBUG
901  amuDebug(D_XDRTRACE)
902    plog(XLOG_DEBUG, "xdr_sattr:");
903#endif /* DEBUG */
904
905  if (!xdr_u_int(xdrs, &objp->sa_mode)) {
906    return (FALSE);
907  }
908  if (!xdr_u_int(xdrs, &objp->sa_uid)) {
909    return (FALSE);
910  }
911  if (!xdr_u_int(xdrs, &objp->sa_gid)) {
912    return (FALSE);
913  }
914  if (!xdr_u_int(xdrs, &objp->sa_size)) {
915    return (FALSE);
916  }
917  if (!xdr_nfstime(xdrs, &objp->sa_atime)) {
918    return (FALSE);
919  }
920  if (!xdr_nfstime(xdrs, &objp->sa_mtime)) {
921    return (FALSE);
922  }
923  return (TRUE);
924}
925#endif /* not HAVE_XDR_SATTR */
926
927
928#ifndef HAVE_XDR_SATTRARGS
929bool_t
930xdr_sattrargs(XDR *xdrs, nfssattrargs *objp)
931{
932#ifdef DEBUG
933  amuDebug(D_XDRTRACE)
934    plog(XLOG_DEBUG, "xdr_sattrargs:");
935#endif /* DEBUG */
936
937  if (!xdr_nfs_fh(xdrs, &objp->sag_fhandle)) {
938    return (FALSE);
939  }
940  if (!xdr_sattr(xdrs, &objp->sag_attributes)) {
941    return (FALSE);
942  }
943  return (TRUE);
944}
945#endif /* not HAVE_XDR_SATTRARGS */
946
947
948#ifndef HAVE_XDR_STATFSOKRES
949bool_t
950xdr_statfsokres(XDR *xdrs, nfsstatfsokres *objp)
951{
952#ifdef DEBUG
953  amuDebug(D_XDRTRACE)
954    plog(XLOG_DEBUG, "xdr_statfsokres:");
955#endif /* DEBUG */
956
957  if (!xdr_u_int(xdrs, &objp->sfrok_tsize)) {
958    return (FALSE);
959  }
960  if (!xdr_u_int(xdrs, &objp->sfrok_bsize)) {
961    return (FALSE);
962  }
963  if (!xdr_u_int(xdrs, &objp->sfrok_blocks)) {
964    return (FALSE);
965  }
966  if (!xdr_u_int(xdrs, &objp->sfrok_bfree)) {
967    return (FALSE);
968  }
969  if (!xdr_u_int(xdrs, &objp->sfrok_bavail)) {
970    return (FALSE);
971  }
972  return (TRUE);
973}
974#endif /* not HAVE_XDR_STATFSOKRES */
975
976
977#ifndef HAVE_XDR_STATFSRES
978bool_t
979xdr_statfsres(XDR *xdrs, nfsstatfsres *objp)
980{
981#ifdef DEBUG
982  amuDebug(D_XDRTRACE)
983    plog(XLOG_DEBUG, "xdr_statfsres:");
984#endif /* DEBUG */
985
986  if (!xdr_nfsstat(xdrs, &objp->sfr_status)) {
987    return (FALSE);
988  }
989  switch (objp->sfr_status) {
990  case NFS_OK:
991    if (!xdr_statfsokres(xdrs, &objp->sfr_u.sfr_reply_u)) {
992      return (FALSE);
993    }
994    break;
995  default:
996    break;
997  }
998  return (TRUE);
999}
1000#endif /* not HAVE_XDR_STATFSRES */
1001
1002
1003#ifndef HAVE_XDR_SYMLINKARGS
1004bool_t
1005xdr_symlinkargs(XDR *xdrs, nfssymlinkargs *objp)
1006{
1007#ifdef DEBUG
1008  amuDebug(D_XDRTRACE)
1009    plog(XLOG_DEBUG, "xdr_symlinkargs:");
1010#endif /* DEBUG */
1011
1012  if (!xdr_diropargs(xdrs, &objp->sla_from)) {
1013    return (FALSE);
1014  }
1015  if (!xdr_nfspath(xdrs, &objp->sla_to)) {
1016    return (FALSE);
1017  }
1018  if (!xdr_sattr(xdrs, &objp->sla_attributes)) {
1019    return (FALSE);
1020  }
1021  return (TRUE);
1022}
1023#endif /* not HAVE_XDR_SYMLINKARGS */
1024
1025
1026#ifndef HAVE_XDR_WRITEARGS
1027bool_t
1028xdr_writeargs(XDR *xdrs, nfswriteargs *objp)
1029{
1030#ifdef DEBUG
1031  amuDebug(D_XDRTRACE)
1032    plog(XLOG_DEBUG, "xdr_writeargs:");
1033#endif /* DEBUG */
1034
1035  if (!xdr_nfs_fh(xdrs, &objp->wra_fhandle)) {
1036    return (FALSE);
1037  }
1038  if (!xdr_u_int(xdrs, &objp->wra_beginoffset)) {
1039    return (FALSE);
1040  }
1041  if (!xdr_u_int(xdrs, &objp->wra_offset)) {
1042    return (FALSE);
1043  }
1044  if (!xdr_u_int(xdrs, &objp->wra_totalcount)) {
1045    return (FALSE);
1046  }
1047  if (!xdr_bytes(xdrs,
1048		 (char **) & objp->wra_u.wra_val_u,
1049		 (u_int *) & objp->wra_u.wra_len_u,
1050		 NFS_MAXDATA)) {
1051    return (FALSE);
1052  }
1053  return (TRUE);
1054}
1055#endif /* not HAVE_XDR_WRITEARGS */
1056
1057
1058/*
1059 * AUTOFS XDR FUNCTIONS:
1060 */
1061#ifdef HAVE_FS_AUTOFS
1062# ifndef HAVE_XDR_MNTREQUEST
1063bool_t
1064xdr_mntrequest(XDR *xdrs, mntrequest *objp)
1065{
1066#ifdef DEBUG
1067  amuDebug(D_XDRTRACE)
1068    plog(XLOG_DEBUG, "xdr_mntrequest:");
1069#endif /* DEBUG */
1070
1071  if (!xdr_string(xdrs, &objp->name, A_MAXNAME))
1072    return (FALSE);
1073
1074  if (!xdr_string(xdrs, &objp->map, A_MAXNAME))
1075    return (FALSE);
1076
1077  if (!xdr_string(xdrs, &objp->opts, A_MAXOPTS))
1078    return (FALSE);
1079
1080  if (!xdr_string(xdrs, &objp->path, A_MAXPATH))
1081    return (FALSE);
1082
1083  return (TRUE);
1084}
1085# endif /* not HAVE_XDR_MNTREQUEST */
1086
1087
1088# ifndef HAVE_XDR_MNTRES
1089bool_t
1090xdr_mntres(XDR *xdrs, mntres *objp)
1091{
1092#ifdef DEBUG
1093  amuDebug(D_XDRTRACE)
1094    plog(XLOG_DEBUG, "xdr_mntres:");
1095#endif /* DEBUG */
1096
1097  if (!xdr_int(xdrs, &objp->status))
1098    return (FALSE);
1099
1100  return (TRUE);
1101}
1102# endif /* not HAVE_XDR_MNTRES */
1103
1104
1105# ifndef HAVE_XDR_UMNTREQUEST
1106bool_t
1107xdr_umntrequest(XDR *xdrs, umntrequest *objp)
1108{
1109#ifdef DEBUG
1110  amuDebug(D_XDRTRACE)
1111    plog(XLOG_DEBUG, "xdr_umntrequest:");
1112#endif /* DEBUG */
1113
1114  if (!xdr_int(xdrs, &objp->isdirect))
1115    return (FALSE);
1116
1117  if (!xdr_u_int(xdrs, (u_int *) &objp->devid))
1118    return (FALSE);
1119
1120#ifdef HAVE_FIELD_UMNTREQUEST_RDEVID
1121  if (!xdr_u_long(xdrs, &objp->rdevid))
1122    return (FALSE);
1123#endif /* HAVE_FIELD_UMNTREQUEST_RDEVID */
1124
1125  if (!xdr_pointer(xdrs, (char **) &objp->next, sizeof(umntrequest), (XDRPROC_T_TYPE) xdr_umntrequest))
1126    return (FALSE);
1127
1128  return (TRUE);
1129}
1130# endif /* not HAVE_XDR_UMNTREQUEST */
1131
1132
1133# ifndef HAVE_XDR_UMNTRES
1134bool_t
1135xdr_umntres(XDR *xdrs, umntres *objp)
1136{
1137#ifdef DEBUG
1138  amuDebug(D_XDRTRACE)
1139    plog(XLOG_DEBUG, "xdr_mntres:");
1140#endif /* DEBUG */
1141
1142  if (!xdr_int(xdrs, &objp->status))
1143    return (FALSE);
1144
1145  return (TRUE);
1146}
1147# endif /* not HAVE_XDR_UMNTRES */
1148#endif /* HAVE_FS_AUTOFS */
1149