2 * Copyright (c) 1997-2004 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.
8 * This code is derived from software contributed to Berkeley by
9 * Jan-Simon Pendry at Imperial College, London.
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
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.
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
41 * $Id: xdr_func.c,v 1.4.2.8 2004/01/06 03:15:24 ezk Exp $
46 * Complete list of all possible xdr functions which may be needed.
50 #endif /* HAVE_CONFIG_H */
59 /* forward definitions, are they needed? */
60 extern bool_t xdr_exportnode(XDR *xdrs, exportnode *objp);
61 extern bool_t xdr_groupnode(XDR *xdrs, groupnode *objp);
62 extern bool_t xdr_name(XDR *xdrs, name *objp);
65 #ifndef HAVE_XDR_ATTRSTAT
67 xdr_attrstat(XDR *xdrs, nfsattrstat *objp)
71 plog(XLOG_DEBUG, "xdr_attrstat:");
74 if (!xdr_nfsstat(xdrs, &objp->ns_status)) {
77 switch (objp->ns_status) {
79 if (!xdr_fattr(xdrs, &objp->ns_u.ns_attr_u)) {
88 #endif /* not HAVE_XDR_ATTRSTAT */
91 #ifndef HAVE_XDR_CREATEARGS
93 xdr_createargs(XDR *xdrs, nfscreateargs *objp)
97 plog(XLOG_DEBUG, "xdr_createargs:");
100 if (!xdr_diropargs(xdrs, &objp->ca_where)) {
103 if (!xdr_sattr(xdrs, &objp->ca_attributes)) {
108 #endif /* not HAVE_XDR_CREATEARGS */
111 #ifndef HAVE_XDR_DIRLIST
113 xdr_dirlist(XDR *xdrs, nfsdirlist *objp)
117 plog(XLOG_DEBUG, "xdr_dirlist:");
120 if (!xdr_pointer(xdrs, (char **) &objp->dl_entries, sizeof(nfsentry), (XDRPROC_T_TYPE) xdr_entry)) {
123 if (!xdr_bool(xdrs, &objp->dl_eof)) {
128 #endif /* not HAVE_XDR_DIRLIST */
131 #ifndef HAVE_XDR_DIROPARGS
133 xdr_diropargs(XDR *xdrs, nfsdiropargs *objp)
137 plog(XLOG_DEBUG, "xdr_diropargs:");
140 if (!xdr_nfs_fh(xdrs, &objp->da_fhandle)) {
143 if (!xdr_filename(xdrs, &objp->da_name)) {
148 #endif /* not HAVE_XDR_DIROPARGS */
151 #ifndef HAVE_XDR_DIROPOKRES
153 xdr_diropokres(XDR *xdrs, nfsdiropokres *objp)
157 plog(XLOG_DEBUG, "xdr_diropokres:");
160 if (!xdr_nfs_fh(xdrs, &objp->drok_fhandle)) {
163 if (!xdr_fattr(xdrs, &objp->drok_attributes)) {
168 #endif /* not HAVE_XDR_DIROPOKRES */
171 #ifndef HAVE_XDR_DIROPRES
173 xdr_diropres(XDR *xdrs, nfsdiropres *objp)
177 plog(XLOG_DEBUG, "xdr_diropres:");
180 if (!xdr_nfsstat(xdrs, &objp->dr_status)) {
183 switch (objp->dr_status) {
185 if (!xdr_diropokres(xdrs, &objp->dr_u.dr_drok_u)) {
194 #endif /* not HAVE_XDR_DIROPRES */
197 #ifndef HAVE_XDR_DIRPATH
199 xdr_dirpath(XDR *xdrs, dirpath *objp)
203 plog(XLOG_DEBUG, "xdr_dirpath:");
206 if (!xdr_string(xdrs, objp, MNTPATHLEN)) {
211 #endif /* not HAVE_XDR_DIRPATH */
214 #ifndef HAVE_XDR_ENTRY
216 xdr_entry(XDR *xdrs, nfsentry *objp)
220 plog(XLOG_DEBUG, "xdr_entry:");
223 if (!xdr_u_int(xdrs, &objp->ne_fileid)) {
226 if (!xdr_filename(xdrs, &objp->ne_name)) {
229 if (!xdr_nfscookie(xdrs, objp->ne_cookie)) {
232 if (!xdr_pointer(xdrs, (char **) &objp->ne_nextentry, sizeof(nfsentry), (XDRPROC_T_TYPE) xdr_entry)) {
237 #endif /* not HAVE_XDR_ENTRY */
240 #ifndef HAVE_XDR_EXPORTNODE
242 xdr_exportnode(XDR *xdrs, exportnode *objp)
246 plog(XLOG_DEBUG, "xdr_exportnode:");
249 if (!xdr_dirpath(xdrs, &objp->ex_dir)) {
252 if (!xdr_groups(xdrs, &objp->ex_groups)) {
255 if (!xdr_exports(xdrs, &objp->ex_next)) {
260 #endif /* not HAVE_XDR_EXPORTNODE */
263 #ifndef HAVE_XDR_EXPORTS
265 xdr_exports(XDR *xdrs, exports *objp)
269 plog(XLOG_DEBUG, "xdr_exports:");
272 if (!xdr_pointer(xdrs, (char **) objp, sizeof(exportnode), (XDRPROC_T_TYPE) xdr_exportnode)) {
277 #endif /* not HAVE_XDR_EXPORTS */
280 #ifndef HAVE_XDR_FATTR
282 xdr_fattr(XDR *xdrs, nfsfattr *objp)
286 plog(XLOG_DEBUG, "xdr_fattr:");
289 if (!xdr_ftype(xdrs, &objp->na_type)) {
292 if (!xdr_u_int(xdrs, &objp->na_mode)) {
295 if (!xdr_u_int(xdrs, &objp->na_nlink)) {
298 if (!xdr_u_int(xdrs, &objp->na_uid)) {
301 if (!xdr_u_int(xdrs, &objp->na_gid)) {
304 if (!xdr_u_int(xdrs, &objp->na_size)) {
307 if (!xdr_u_int(xdrs, &objp->na_blocksize)) {
310 if (!xdr_u_int(xdrs, &objp->na_rdev)) {
313 if (!xdr_u_int(xdrs, &objp->na_blocks)) {
316 if (!xdr_u_int(xdrs, &objp->na_fsid)) {
319 if (!xdr_u_int(xdrs, &objp->na_fileid)) {
322 if (!xdr_nfstime(xdrs, &objp->na_atime)) {
325 if (!xdr_nfstime(xdrs, &objp->na_mtime)) {
328 if (!xdr_nfstime(xdrs, &objp->na_ctime)) {
333 #endif /* not HAVE_XDR_FATTR */
336 #ifndef HAVE_XDR_FHANDLE
338 xdr_fhandle(XDR *xdrs, fhandle objp)
342 plog(XLOG_DEBUG, "xdr_fhandle:");
345 if (!xdr_opaque(xdrs, objp, NFS_FHSIZE)) {
350 #endif /* not HAVE_XDR_FHANDLE */
353 #ifndef HAVE_XDR_FHSTATUS
355 xdr_fhstatus(XDR *xdrs, fhstatus *objp)
359 plog(XLOG_DEBUG, "xdr_fhstatus:");
362 if (!xdr_u_int(xdrs, &objp->fhs_status)) {
365 if (objp->fhs_status == 0 && !xdr_fhandle(xdrs, objp->fhs_fh)) {
370 #endif /* not HAVE_XDR_FHSTATUS */
373 #ifndef HAVE_XDR_FILENAME
375 xdr_filename(XDR *xdrs, filename *objp)
379 plog(XLOG_DEBUG, "xdr_filename:");
382 if (!xdr_string(xdrs, objp, NFS_MAXNAMLEN)) {
387 #endif /* not HAVE_XDR_FILENAME */
390 #ifndef HAVE_XDR_FTYPE
392 xdr_ftype(XDR *xdrs, nfsftype *objp)
396 plog(XLOG_DEBUG, "xdr_ftype:");
399 if (!xdr_enum(xdrs, (enum_t *) objp)) {
404 #endif /* not HAVE_XDR_FTYPE */
407 #ifndef HAVE_XDR_GROUPNODE
409 xdr_groupnode(XDR *xdrs, groupnode *objp)
413 plog(XLOG_DEBUG, "xdr_groupnode:");
416 if (!xdr_name(xdrs, &objp->gr_name)) {
419 if (!xdr_groups(xdrs, &objp->gr_next)) {
424 #endif /* not HAVE_XDR_GROUPNODE */
427 #ifndef HAVE_XDR_GROUPS
429 xdr_groups(XDR *xdrs, groups *objp)
433 plog(XLOG_DEBUG, "xdr_groups:");
436 if (!xdr_pointer(xdrs, (char **) objp, sizeof(groupnode), (XDRPROC_T_TYPE) xdr_groupnode)) {
441 #endif /* not HAVE_XDR_GROUPS */
444 #ifndef HAVE_XDR_LINKARGS
446 xdr_linkargs(XDR *xdrs, nfslinkargs *objp)
450 plog(XLOG_DEBUG, "xdr_linkargs:");
453 if (!xdr_nfs_fh(xdrs, &objp->la_fhandle)) {
456 if (!xdr_diropargs(xdrs, &objp->la_to)) {
461 #endif /* not HAVE_XDR_LINKARGS */
464 #ifndef HAVE_XDR_MOUNTBODY
466 xdr_mountbody(XDR *xdrs, mountbody *objp)
470 plog(XLOG_DEBUG, "xdr_mountbody:");
473 if (!xdr_name(xdrs, &objp->ml_hostname)) {
476 if (!xdr_dirpath(xdrs, &objp->ml_directory)) {
479 if (!xdr_mountlist(xdrs, &objp->ml_next)) {
484 #endif /* not HAVE_XDR_MOUNTBODY */
487 #ifndef HAVE_XDR_MOUNTLIST
489 xdr_mountlist(XDR *xdrs, mountlist *objp)
493 plog(XLOG_DEBUG, "xdr_mountlist:");
496 if (!xdr_pointer(xdrs, (char **) objp, sizeof(mountbody), (XDRPROC_T_TYPE) xdr_mountbody)) {
501 #endif /* not HAVE_XDR_MOUNTLIST */
504 #if defined(HAVE_FS_NFS3) && !defined(HAVE_XDR_MOUNTRES3)
506 * This ifdef is a hack: this whole file needs to be compiled
507 * only if the system has NFS V3 and does not have the xdr_mountres3
508 * function. Autoconf should pick this source file to compile only
509 * if these two conditions apply.
513 xdr_fhandle3(XDR *xdrs, fhandle3 *objp)
517 plog(XLOG_DEBUG, "xdr_fhandle3:");
521 (char **) &objp->fhandle3_val,
522 (u_int *) &objp->fhandle3_len,
530 xdr_mountstat3(XDR *xdrs, mountstat3 *objp)
534 plog(XLOG_DEBUG, "xdr_mountstat3:");
537 if (!xdr_enum(xdrs, (enum_t *)objp))
544 xdr_mountres3_ok(XDR *xdrs, mountres3_ok *objp)
548 plog(XLOG_DEBUG, "xdr_mountres3_ok:");
551 if (!xdr_fhandle3(xdrs, &objp->fhandle))
554 (char **)&objp->auth_flavors.auth_flavors_val,
555 (u_int *) &objp->auth_flavors.auth_flavors_len,
558 (xdrproc_t) xdr_int))
565 xdr_mountres3(XDR *xdrs, mountres3 *objp)
569 plog(XLOG_DEBUG, "xdr_mountres3:");
572 if (!xdr_mountstat3(xdrs, &objp->fhs_status))
575 if (objp->fhs_status == 0) { /* 0 == MNT_OK or MNT3_OK */
576 if (!xdr_mountres3_ok(xdrs, &objp->mountres3_u.mountinfo))
581 #endif /* defined(HAVE_FS_NFS3) && !defined(HAVE_XDR_MOUNTRES3) */
584 #ifndef HAVE_XDR_NAME
586 xdr_name(XDR *xdrs, name *objp)
590 plog(XLOG_DEBUG, "xdr_name:");
593 if (!xdr_string(xdrs, objp, MNTNAMLEN)) {
598 #endif /* not HAVE_XDR_NAME */
601 #ifndef HAVE_XDR_NFS_FH
603 xdr_nfs_fh(XDR *xdrs, am_nfs_fh *objp)
607 plog(XLOG_DEBUG, "xdr_nfs_fh:");
610 if (!xdr_opaque(xdrs, (caddr_t) objp->fh_data, NFS_FHSIZE)) {
615 #endif /* not HAVE_XDR_NFS_FH */
618 #ifndef HAVE_XDR_NFSCOOKIE
620 xdr_nfscookie(XDR *xdrs, nfscookie objp)
624 plog(XLOG_DEBUG, "xdr_nfscookie:");
627 if (!xdr_opaque(xdrs, objp, NFS_COOKIESIZE)) {
632 #endif /* not HAVE_XDR_NFSCOOKIE */
635 #ifndef HAVE_XDR_NFSPATH
637 xdr_nfspath(XDR *xdrs, nfspath *objp)
641 plog(XLOG_DEBUG, "xdr_nfspath:");
644 if (!xdr_string(xdrs, objp, NFS_MAXPATHLEN)) {
649 #endif /* not HAVE_XDR_NFSPATH */
652 #ifndef HAVE_XDR_NFSSTAT
654 xdr_nfsstat(XDR *xdrs, nfsstat *objp)
658 plog(XLOG_DEBUG, "xdr_nfsstat:");
661 if (!xdr_enum(xdrs, (enum_t *) objp)) {
666 #endif /* not HAVE_XDR_NFSSTAT */
669 #ifndef HAVE_XDR_NFSTIME
671 xdr_nfstime(XDR *xdrs, nfstime *objp)
675 plog(XLOG_DEBUG, "xdr_nfstime:");
678 if (!xdr_u_int(xdrs, (u_int *) &objp->nt_seconds)) {
681 if (!xdr_u_int(xdrs, (u_int *) &objp->nt_useconds)) {
686 #endif /* not HAVE_XDR_NFSTIME */
689 #ifndef HAVE_XDR_POINTER
691 xdr_pointer(register XDR *xdrs, char **objpp, u_int obj_size, XDRPROC_T_TYPE xdr_obj)
695 plog(XLOG_DEBUG, "xdr_pointer:");
701 more_data = (*objpp != NULL);
702 if (!xdr_bool(xdrs, &more_data)) {
710 return (xdr_reference(xdrs, objpp, obj_size, xdr_obj));
712 #endif /* not HAVE_XDR_POINTER */
715 #ifndef HAVE_XDR_READARGS
717 xdr_readargs(XDR *xdrs, nfsreadargs *objp)
721 plog(XLOG_DEBUG, "xdr_readargs:");
724 if (!xdr_nfs_fh(xdrs, &objp->ra_fhandle)) {
727 if (!xdr_u_int(xdrs, &objp->ra_offset)) {
730 if (!xdr_u_int(xdrs, &objp->ra_count)) {
733 if (!xdr_u_int(xdrs, &objp->ra_totalcount)) {
738 #endif /* not HAVE_XDR_READARGS */
741 #ifndef HAVE_XDR_READDIRARGS
743 xdr_readdirargs(XDR *xdrs, nfsreaddirargs *objp)
747 plog(XLOG_DEBUG, "xdr_readdirargs:");
750 if (!xdr_nfs_fh(xdrs, &objp->rda_fhandle)) {
753 if (!xdr_nfscookie(xdrs, objp->rda_cookie)) {
756 if (!xdr_u_int(xdrs, &objp->rda_count)) {
761 #endif /* not HAVE_XDR_READDIRARGS */
764 #ifndef HAVE_XDR_READDIRRES
766 xdr_readdirres(XDR *xdrs, nfsreaddirres *objp)
770 plog(XLOG_DEBUG, "xdr_readdirres:");
773 if (!xdr_nfsstat(xdrs, &objp->rdr_status)) {
776 switch (objp->rdr_status) {
778 if (!xdr_dirlist(xdrs, &objp->rdr_u.rdr_reply_u)) {
787 #endif /* not HAVE_XDR_READDIRRES */
790 #ifndef HAVE_XDR_READLINKRES
792 xdr_readlinkres(XDR *xdrs, nfsreadlinkres *objp)
796 plog(XLOG_DEBUG, "xdr_readlinkres:");
799 if (!xdr_nfsstat(xdrs, &objp->rlr_status)) {
802 switch (objp->rlr_status) {
804 if (!xdr_nfspath(xdrs, &objp->rlr_u.rlr_data_u)) {
813 #endif /* not HAVE_XDR_READLINKRES */
816 #ifndef HAVE_XDR_READOKRES
818 xdr_readokres(XDR *xdrs, nfsreadokres *objp)
822 plog(XLOG_DEBUG, "xdr_readokres:");
825 if (!xdr_fattr(xdrs, &objp->raok_attributes)) {
829 (char **) & objp->raok_u.raok_val_u,
830 (u_int *) & objp->raok_u.raok_len_u,
836 #endif /* not HAVE_XDR_READOKRES */
839 #ifndef HAVE_XDR_READRES
841 xdr_readres(XDR *xdrs, nfsreadres *objp)
845 plog(XLOG_DEBUG, "xdr_readres:");
848 if (!xdr_nfsstat(xdrs, &objp->rr_status)) {
851 switch (objp->rr_status) {
853 if (!xdr_readokres(xdrs, &objp->rr_u.rr_reply_u)) {
862 #endif /* not HAVE_XDR_READRES */
865 #ifndef HAVE_XDR_RENAMEARGS
867 xdr_renameargs(XDR *xdrs, nfsrenameargs *objp)
871 plog(XLOG_DEBUG, "xdr_renameargs:");
874 if (!xdr_diropargs(xdrs, &objp->rna_from)) {
877 if (!xdr_diropargs(xdrs, &objp->rna_to)) {
882 #endif /* not HAVE_XDR_RENAMEARGS */
885 #ifndef HAVE_XDR_SATTR
887 xdr_sattr(XDR *xdrs, nfssattr *objp)
891 plog(XLOG_DEBUG, "xdr_sattr:");
894 if (!xdr_u_int(xdrs, &objp->sa_mode)) {
897 if (!xdr_u_int(xdrs, &objp->sa_uid)) {
900 if (!xdr_u_int(xdrs, &objp->sa_gid)) {
903 if (!xdr_u_int(xdrs, &objp->sa_size)) {
906 if (!xdr_nfstime(xdrs, &objp->sa_atime)) {
909 if (!xdr_nfstime(xdrs, &objp->sa_mtime)) {
914 #endif /* not HAVE_XDR_SATTR */
917 #ifndef HAVE_XDR_SATTRARGS
919 xdr_sattrargs(XDR *xdrs, nfssattrargs *objp)
923 plog(XLOG_DEBUG, "xdr_sattrargs:");
926 if (!xdr_nfs_fh(xdrs, &objp->sag_fhandle)) {
929 if (!xdr_sattr(xdrs, &objp->sag_attributes)) {
934 #endif /* not HAVE_XDR_SATTRARGS */
937 #ifndef HAVE_XDR_STATFSOKRES
939 xdr_statfsokres(XDR *xdrs, nfsstatfsokres *objp)
943 plog(XLOG_DEBUG, "xdr_statfsokres:");
946 if (!xdr_u_int(xdrs, &objp->sfrok_tsize)) {
949 if (!xdr_u_int(xdrs, &objp->sfrok_bsize)) {
952 if (!xdr_u_int(xdrs, &objp->sfrok_blocks)) {
955 if (!xdr_u_int(xdrs, &objp->sfrok_bfree)) {
958 if (!xdr_u_int(xdrs, &objp->sfrok_bavail)) {
963 #endif /* not HAVE_XDR_STATFSOKRES */
966 #ifndef HAVE_XDR_STATFSRES
968 xdr_statfsres(XDR *xdrs, nfsstatfsres *objp)
972 plog(XLOG_DEBUG, "xdr_statfsres:");
975 if (!xdr_nfsstat(xdrs, &objp->sfr_status)) {
978 switch (objp->sfr_status) {
980 if (!xdr_statfsokres(xdrs, &objp->sfr_u.sfr_reply_u)) {
989 #endif /* not HAVE_XDR_STATFSRES */
992 #ifndef HAVE_XDR_SYMLINKARGS
994 xdr_symlinkargs(XDR *xdrs, nfssymlinkargs *objp)
998 plog(XLOG_DEBUG, "xdr_symlinkargs:");
1001 if (!xdr_diropargs(xdrs, &objp->sla_from)) {
1004 if (!xdr_nfspath(xdrs, &objp->sla_to)) {
1007 if (!xdr_sattr(xdrs, &objp->sla_attributes)) {
1012 #endif /* not HAVE_XDR_SYMLINKARGS */
1015 #ifndef HAVE_XDR_WRITEARGS
1017 xdr_writeargs(XDR *xdrs, nfswriteargs *objp)
1020 amuDebug(D_XDRTRACE)
1021 plog(XLOG_DEBUG, "xdr_writeargs:");
1024 if (!xdr_nfs_fh(xdrs, &objp->wra_fhandle)) {
1027 if (!xdr_u_int(xdrs, &objp->wra_beginoffset)) {
1030 if (!xdr_u_int(xdrs, &objp->wra_offset)) {
1033 if (!xdr_u_int(xdrs, &objp->wra_totalcount)) {
1036 if (!xdr_bytes(xdrs,
1037 (char **) & objp->wra_u.wra_val_u,
1038 (u_int *) & objp->wra_u.wra_len_u,
1044 #endif /* not HAVE_XDR_WRITEARGS */