17c478bd9Sstevel@tonic-gate /*
27c478bd9Sstevel@tonic-gate * CDDL HEADER START
37c478bd9Sstevel@tonic-gate *
47c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the
539d3e169Sevanl * Common Development and Distribution License (the "License").
639d3e169Sevanl * You may not use this file except in compliance with the License.
77c478bd9Sstevel@tonic-gate *
87c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
97c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing.
107c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions
117c478bd9Sstevel@tonic-gate * and limitations under the License.
127c478bd9Sstevel@tonic-gate *
137c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each
147c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
157c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the
167c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying
177c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner]
187c478bd9Sstevel@tonic-gate *
197c478bd9Sstevel@tonic-gate * CDDL HEADER END
207c478bd9Sstevel@tonic-gate */
217c478bd9Sstevel@tonic-gate /*
227c478bd9Sstevel@tonic-gate * autod_xdr.c
237c478bd9Sstevel@tonic-gate *
24*2f172c55SRobert Thurlow * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
257c478bd9Sstevel@tonic-gate * Use is subject to license terms.
267c478bd9Sstevel@tonic-gate */
277c478bd9Sstevel@tonic-gate
287c478bd9Sstevel@tonic-gate /*
297c478bd9Sstevel@tonic-gate * This file can not be automatically generated by rpcgen from
307c478bd9Sstevel@tonic-gate * autofs_prot.x because of the xdr routines that provide readdir
317c478bd9Sstevel@tonic-gate * support, and my own implementation of xdr_autofs_netbuf().
327c478bd9Sstevel@tonic-gate */
337c478bd9Sstevel@tonic-gate
347c478bd9Sstevel@tonic-gate #include <sys/vfs.h>
357c478bd9Sstevel@tonic-gate #include <sys/sysmacros.h> /* includes roundup() */
367c478bd9Sstevel@tonic-gate #include <string.h>
377c478bd9Sstevel@tonic-gate #include <rpcsvc/autofs_prot.h>
38*2f172c55SRobert Thurlow #include <nfs/nfs4.h>
39*2f172c55SRobert Thurlow #include <rpcsvc/nfs4_prot.h>
407c478bd9Sstevel@tonic-gate #include <rpc/xdr.h>
410cf39dd5Spf199842 #include <stdlib.h>
420cf39dd5Spf199842 #include <strings.h>
437c478bd9Sstevel@tonic-gate
447c478bd9Sstevel@tonic-gate bool_t
xdr_autofs_stat(register XDR * xdrs,autofs_stat * objp)457c478bd9Sstevel@tonic-gate xdr_autofs_stat(register XDR *xdrs, autofs_stat *objp)
467c478bd9Sstevel@tonic-gate {
477c478bd9Sstevel@tonic-gate if (!xdr_enum(xdrs, (enum_t *)objp))
487c478bd9Sstevel@tonic-gate return (FALSE);
497c478bd9Sstevel@tonic-gate return (TRUE);
507c478bd9Sstevel@tonic-gate }
517c478bd9Sstevel@tonic-gate
527c478bd9Sstevel@tonic-gate bool_t
xdr_autofs_action(register XDR * xdrs,autofs_action * objp)537c478bd9Sstevel@tonic-gate xdr_autofs_action(register XDR *xdrs, autofs_action *objp)
547c478bd9Sstevel@tonic-gate {
557c478bd9Sstevel@tonic-gate if (!xdr_enum(xdrs, (enum_t *)objp))
567c478bd9Sstevel@tonic-gate return (FALSE);
577c478bd9Sstevel@tonic-gate return (TRUE);
587c478bd9Sstevel@tonic-gate }
597c478bd9Sstevel@tonic-gate
607c478bd9Sstevel@tonic-gate bool_t
xdr_linka(register XDR * xdrs,linka * objp)617c478bd9Sstevel@tonic-gate xdr_linka(register XDR *xdrs, linka *objp)
627c478bd9Sstevel@tonic-gate {
637c478bd9Sstevel@tonic-gate if (!xdr_string(xdrs, &objp->dir, AUTOFS_MAXPATHLEN))
647c478bd9Sstevel@tonic-gate return (FALSE);
657c478bd9Sstevel@tonic-gate if (!xdr_string(xdrs, &objp->link, AUTOFS_MAXPATHLEN))
667c478bd9Sstevel@tonic-gate return (FALSE);
677c478bd9Sstevel@tonic-gate return (TRUE);
687c478bd9Sstevel@tonic-gate }
697c478bd9Sstevel@tonic-gate
707c478bd9Sstevel@tonic-gate bool_t
xdr_autofs_netbuf(xdrs,objp)717c478bd9Sstevel@tonic-gate xdr_autofs_netbuf(xdrs, objp)
727c478bd9Sstevel@tonic-gate XDR *xdrs;
737c478bd9Sstevel@tonic-gate struct netbuf *objp;
747c478bd9Sstevel@tonic-gate {
757c478bd9Sstevel@tonic-gate bool_t dummy;
767c478bd9Sstevel@tonic-gate
777c478bd9Sstevel@tonic-gate if (!xdr_u_int(xdrs, &objp->maxlen)) {
787c478bd9Sstevel@tonic-gate return (FALSE);
797c478bd9Sstevel@tonic-gate }
807c478bd9Sstevel@tonic-gate dummy = xdr_bytes(xdrs, (char **)&(objp->buf),
8139d3e169Sevanl (uint_t *)&(objp->len), objp->maxlen);
827c478bd9Sstevel@tonic-gate return (dummy);
837c478bd9Sstevel@tonic-gate }
847c478bd9Sstevel@tonic-gate
857c478bd9Sstevel@tonic-gate bool_t
xdr_autofs_args(register XDR * xdrs,autofs_args * objp)867c478bd9Sstevel@tonic-gate xdr_autofs_args(register XDR *xdrs, autofs_args *objp)
877c478bd9Sstevel@tonic-gate {
887c478bd9Sstevel@tonic-gate if (!xdr_autofs_netbuf(xdrs, &objp->addr))
897c478bd9Sstevel@tonic-gate return (FALSE);
907c478bd9Sstevel@tonic-gate if (!xdr_string(xdrs, &objp->path, AUTOFS_MAXPATHLEN))
917c478bd9Sstevel@tonic-gate return (FALSE);
927c478bd9Sstevel@tonic-gate if (!xdr_string(xdrs, &objp->opts, AUTOFS_MAXOPTSLEN))
937c478bd9Sstevel@tonic-gate return (FALSE);
947c478bd9Sstevel@tonic-gate if (!xdr_string(xdrs, &objp->map, AUTOFS_MAXPATHLEN))
957c478bd9Sstevel@tonic-gate return (FALSE);
967c478bd9Sstevel@tonic-gate if (!xdr_string(xdrs, &objp->subdir, AUTOFS_MAXPATHLEN))
977c478bd9Sstevel@tonic-gate return (FALSE);
987c478bd9Sstevel@tonic-gate if (!xdr_string(xdrs, &objp->key, AUTOFS_MAXCOMPONENTLEN))
997c478bd9Sstevel@tonic-gate return (FALSE);
1007c478bd9Sstevel@tonic-gate if (!xdr_int(xdrs, &objp->mount_to))
1017c478bd9Sstevel@tonic-gate return (FALSE);
1027c478bd9Sstevel@tonic-gate if (!xdr_int(xdrs, &objp->rpc_to))
1037c478bd9Sstevel@tonic-gate return (FALSE);
1047c478bd9Sstevel@tonic-gate if (!xdr_int(xdrs, &objp->direct))
1057c478bd9Sstevel@tonic-gate return (FALSE);
1067c478bd9Sstevel@tonic-gate return (TRUE);
1077c478bd9Sstevel@tonic-gate }
1087c478bd9Sstevel@tonic-gate
1097c478bd9Sstevel@tonic-gate bool_t
xdr_mounta(register XDR * xdrs,struct mounta * objp)1107c478bd9Sstevel@tonic-gate xdr_mounta(register XDR *xdrs, struct mounta *objp)
1117c478bd9Sstevel@tonic-gate {
1127c478bd9Sstevel@tonic-gate if (!xdr_string(xdrs, &objp->spec, AUTOFS_MAXPATHLEN))
1137c478bd9Sstevel@tonic-gate return (FALSE);
1147c478bd9Sstevel@tonic-gate if (!xdr_string(xdrs, &objp->dir, AUTOFS_MAXPATHLEN))
1157c478bd9Sstevel@tonic-gate return (FALSE);
1167c478bd9Sstevel@tonic-gate if (!xdr_int(xdrs, &objp->flags))
1177c478bd9Sstevel@tonic-gate return (FALSE);
1187c478bd9Sstevel@tonic-gate if (!xdr_string(xdrs, &objp->fstype, AUTOFS_MAXCOMPONENTLEN))
1197c478bd9Sstevel@tonic-gate return (FALSE);
1205e1e04ceSdm120769 if (!xdr_pointer(xdrs, (char **)&objp->dataptr, sizeof (autofs_args),
1217c478bd9Sstevel@tonic-gate (xdrproc_t)xdr_autofs_args))
1227c478bd9Sstevel@tonic-gate return (FALSE);
1237c478bd9Sstevel@tonic-gate if (!xdr_int(xdrs, &objp->datalen))
1247c478bd9Sstevel@tonic-gate return (FALSE);
1257c478bd9Sstevel@tonic-gate if (!xdr_string(xdrs, &objp->optptr, AUTOFS_MAXOPTSLEN))
1267c478bd9Sstevel@tonic-gate return (FALSE);
1277c478bd9Sstevel@tonic-gate if (!xdr_int(xdrs, &objp->optlen))
1287c478bd9Sstevel@tonic-gate return (FALSE);
1297c478bd9Sstevel@tonic-gate return (TRUE);
1307c478bd9Sstevel@tonic-gate }
1317c478bd9Sstevel@tonic-gate
1327c478bd9Sstevel@tonic-gate bool_t
xdr_action_list_entry(register XDR * xdrs,action_list_entry * objp)1337c478bd9Sstevel@tonic-gate xdr_action_list_entry(register XDR *xdrs, action_list_entry *objp)
1347c478bd9Sstevel@tonic-gate {
1357c478bd9Sstevel@tonic-gate if (!xdr_autofs_action(xdrs, &objp->action))
1367c478bd9Sstevel@tonic-gate return (FALSE);
1377c478bd9Sstevel@tonic-gate switch (objp->action) {
1387c478bd9Sstevel@tonic-gate case AUTOFS_MOUNT_RQ:
1397c478bd9Sstevel@tonic-gate if (!xdr_mounta(xdrs, &objp->action_list_entry_u.mounta))
1407c478bd9Sstevel@tonic-gate return (FALSE);
1417c478bd9Sstevel@tonic-gate break;
1427c478bd9Sstevel@tonic-gate case AUTOFS_LINK_RQ:
1437c478bd9Sstevel@tonic-gate if (!xdr_linka(xdrs, &objp->action_list_entry_u.linka))
1447c478bd9Sstevel@tonic-gate return (FALSE);
1457c478bd9Sstevel@tonic-gate break;
1467c478bd9Sstevel@tonic-gate }
1477c478bd9Sstevel@tonic-gate return (TRUE);
1487c478bd9Sstevel@tonic-gate }
1497c478bd9Sstevel@tonic-gate
1507c478bd9Sstevel@tonic-gate bool_t
xdr_action_list(XDR * xdrs,action_list * objp)1510cf39dd5Spf199842 xdr_action_list(XDR *xdrs, action_list *objp)
1527c478bd9Sstevel@tonic-gate {
1530cf39dd5Spf199842 action_list *tmp_action_list;
1540cf39dd5Spf199842 bool_t more_data = TRUE;
1550cf39dd5Spf199842 bool_t first_objp = TRUE;
1560cf39dd5Spf199842
1570cf39dd5Spf199842 if (xdrs->x_op == XDR_DECODE) {
1580cf39dd5Spf199842 while (more_data) {
1597c478bd9Sstevel@tonic-gate if (!xdr_action_list_entry(xdrs, &objp->action))
1607c478bd9Sstevel@tonic-gate return (FALSE);
1610cf39dd5Spf199842 if (!xdr_bool(xdrs, &more_data))
1627c478bd9Sstevel@tonic-gate return (FALSE);
1630cf39dd5Spf199842 if (!more_data) {
1640cf39dd5Spf199842 objp->next = NULL;
1650cf39dd5Spf199842 break;
1660cf39dd5Spf199842 }
1670cf39dd5Spf199842 if (objp->next == NULL) {
1680cf39dd5Spf199842 objp->next = (action_list *)
1690cf39dd5Spf199842 mem_alloc(sizeof (action_list));
1700cf39dd5Spf199842 if (objp->next == NULL)
1710cf39dd5Spf199842 return (FALSE);
1720cf39dd5Spf199842 bzero(objp->next, sizeof (action_list));
1730cf39dd5Spf199842 }
1740cf39dd5Spf199842 objp = objp->next;
1750cf39dd5Spf199842 }
1760cf39dd5Spf199842 } else if (xdrs->x_op == XDR_ENCODE) {
1770cf39dd5Spf199842 while (more_data) {
1780cf39dd5Spf199842 if (!xdr_action_list_entry(xdrs, &objp->action))
1790cf39dd5Spf199842 return (FALSE);
1800cf39dd5Spf199842 objp = objp->next;
1810cf39dd5Spf199842 if (objp == NULL)
1820cf39dd5Spf199842 more_data = FALSE;
1830cf39dd5Spf199842 if (!xdr_bool(xdrs, &more_data))
1840cf39dd5Spf199842 return (FALSE);
1850cf39dd5Spf199842 }
1860cf39dd5Spf199842 } else {
1870cf39dd5Spf199842 while (more_data) {
1880cf39dd5Spf199842 if (!xdr_action_list_entry(xdrs, &objp->action))
1890cf39dd5Spf199842 return (FALSE);
1900cf39dd5Spf199842 tmp_action_list = objp;
1910cf39dd5Spf199842 objp = objp->next;
1920cf39dd5Spf199842 if (objp == NULL)
1930cf39dd5Spf199842 more_data = FALSE;
1940cf39dd5Spf199842 if (!first_objp)
1950cf39dd5Spf199842 mem_free(tmp_action_list, sizeof (action_list));
1960cf39dd5Spf199842 else
1970cf39dd5Spf199842 first_objp = FALSE;
1980cf39dd5Spf199842 }
1990cf39dd5Spf199842 }
2007c478bd9Sstevel@tonic-gate return (TRUE);
2017c478bd9Sstevel@tonic-gate }
2027c478bd9Sstevel@tonic-gate
2037c478bd9Sstevel@tonic-gate bool_t
xdr_umntrequest(register XDR * xdrs,umntrequest * objp)2047c478bd9Sstevel@tonic-gate xdr_umntrequest(register XDR *xdrs, umntrequest *objp)
2057c478bd9Sstevel@tonic-gate {
2067c478bd9Sstevel@tonic-gate if (!xdr_bool_t(xdrs, &objp->isdirect))
2077c478bd9Sstevel@tonic-gate return (FALSE);
2087c478bd9Sstevel@tonic-gate if (!xdr_string(xdrs, &objp->mntresource, AUTOFS_MAXPATHLEN))
2097c478bd9Sstevel@tonic-gate return (FALSE);
2107c478bd9Sstevel@tonic-gate if (!xdr_string(xdrs, &objp->mntpnt, AUTOFS_MAXPATHLEN))
2117c478bd9Sstevel@tonic-gate return (FALSE);
2127c478bd9Sstevel@tonic-gate if (!xdr_string(xdrs, &objp->fstype, AUTOFS_MAXCOMPONENTLEN))
2137c478bd9Sstevel@tonic-gate return (FALSE);
2147c478bd9Sstevel@tonic-gate if (!xdr_string(xdrs, &objp->mntopts, AUTOFS_MAXOPTSLEN))
2157c478bd9Sstevel@tonic-gate return (FALSE);
2167c478bd9Sstevel@tonic-gate if (!xdr_pointer(xdrs, (char **)&objp->next, sizeof (umntrequest),
2177c478bd9Sstevel@tonic-gate (xdrproc_t)xdr_umntrequest))
2187c478bd9Sstevel@tonic-gate return (FALSE);
2197c478bd9Sstevel@tonic-gate return (TRUE);
2207c478bd9Sstevel@tonic-gate }
2217c478bd9Sstevel@tonic-gate
2227c478bd9Sstevel@tonic-gate bool_t
xdr_umntres(register XDR * xdrs,umntres * objp)2237c478bd9Sstevel@tonic-gate xdr_umntres(register XDR *xdrs, umntres *objp)
2247c478bd9Sstevel@tonic-gate {
2257c478bd9Sstevel@tonic-gate if (!xdr_int(xdrs, &objp->status))
2267c478bd9Sstevel@tonic-gate return (FALSE);
2277c478bd9Sstevel@tonic-gate return (TRUE);
2287c478bd9Sstevel@tonic-gate }
2297c478bd9Sstevel@tonic-gate
2307c478bd9Sstevel@tonic-gate bool_t
xdr_autofs_res(xdrs,objp)2317c478bd9Sstevel@tonic-gate xdr_autofs_res(xdrs, objp)
2327c478bd9Sstevel@tonic-gate register XDR *xdrs;
2337c478bd9Sstevel@tonic-gate autofs_res *objp;
2347c478bd9Sstevel@tonic-gate {
2357c478bd9Sstevel@tonic-gate if (!xdr_enum(xdrs, (enum_t *)objp))
2367c478bd9Sstevel@tonic-gate return (FALSE);
2377c478bd9Sstevel@tonic-gate return (TRUE);
2387c478bd9Sstevel@tonic-gate }
2397c478bd9Sstevel@tonic-gate
2407c478bd9Sstevel@tonic-gate bool_t
xdr_autofs_lookupargs(xdrs,objp)2417c478bd9Sstevel@tonic-gate xdr_autofs_lookupargs(xdrs, objp)
2427c478bd9Sstevel@tonic-gate register XDR *xdrs;
2437c478bd9Sstevel@tonic-gate autofs_lookupargs *objp;
2447c478bd9Sstevel@tonic-gate {
2457c478bd9Sstevel@tonic-gate if (!xdr_string(xdrs, &objp->map, AUTOFS_MAXPATHLEN))
2467c478bd9Sstevel@tonic-gate return (FALSE);
2477c478bd9Sstevel@tonic-gate if (!xdr_string(xdrs, &objp->path, AUTOFS_MAXPATHLEN))
2487c478bd9Sstevel@tonic-gate return (FALSE);
2497c478bd9Sstevel@tonic-gate if (!xdr_string(xdrs, &objp->name, AUTOFS_MAXCOMPONENTLEN))
2507c478bd9Sstevel@tonic-gate return (FALSE);
2517c478bd9Sstevel@tonic-gate if (!xdr_string(xdrs, &objp->subdir, AUTOFS_MAXPATHLEN))
2527c478bd9Sstevel@tonic-gate return (FALSE);
2537c478bd9Sstevel@tonic-gate if (!xdr_string(xdrs, &objp->opts, AUTOFS_MAXOPTSLEN))
2547c478bd9Sstevel@tonic-gate return (FALSE);
2557c478bd9Sstevel@tonic-gate if (!xdr_bool_t(xdrs, &objp->isdirect))
2567c478bd9Sstevel@tonic-gate return (FALSE);
2573bfb48feSsemery if (!xdr_u_int(xdrs, (uint_t *)&objp->uid))
2583bfb48feSsemery return (FALSE);
2597c478bd9Sstevel@tonic-gate return (TRUE);
2607c478bd9Sstevel@tonic-gate }
2617c478bd9Sstevel@tonic-gate
2627c478bd9Sstevel@tonic-gate bool_t
xdr_mount_result_type(xdrs,objp)2637c478bd9Sstevel@tonic-gate xdr_mount_result_type(xdrs, objp)
2647c478bd9Sstevel@tonic-gate register XDR *xdrs;
2657c478bd9Sstevel@tonic-gate mount_result_type *objp;
2667c478bd9Sstevel@tonic-gate {
2677c478bd9Sstevel@tonic-gate if (!xdr_autofs_stat(xdrs, &objp->status))
2687c478bd9Sstevel@tonic-gate return (FALSE);
2697c478bd9Sstevel@tonic-gate switch (objp->status) {
2707c478bd9Sstevel@tonic-gate case AUTOFS_ACTION:
2717c478bd9Sstevel@tonic-gate if (!xdr_pointer(xdrs,
2727c478bd9Sstevel@tonic-gate (char **)&objp->mount_result_type_u.list,
2737c478bd9Sstevel@tonic-gate sizeof (action_list), (xdrproc_t)xdr_action_list))
2747c478bd9Sstevel@tonic-gate return (FALSE);
2757c478bd9Sstevel@tonic-gate break;
2767c478bd9Sstevel@tonic-gate case AUTOFS_DONE:
2777c478bd9Sstevel@tonic-gate if (!xdr_int(xdrs, &objp->mount_result_type_u.error))
2787c478bd9Sstevel@tonic-gate return (FALSE);
2797c478bd9Sstevel@tonic-gate break;
2807c478bd9Sstevel@tonic-gate }
2817c478bd9Sstevel@tonic-gate return (TRUE);
2827c478bd9Sstevel@tonic-gate }
2837c478bd9Sstevel@tonic-gate
2847c478bd9Sstevel@tonic-gate bool_t
xdr_autofs_mountres(xdrs,objp)2857c478bd9Sstevel@tonic-gate xdr_autofs_mountres(xdrs, objp)
2867c478bd9Sstevel@tonic-gate register XDR *xdrs;
2877c478bd9Sstevel@tonic-gate autofs_mountres *objp;
2887c478bd9Sstevel@tonic-gate {
2897c478bd9Sstevel@tonic-gate if (!xdr_mount_result_type(xdrs, &objp->mr_type))
2907c478bd9Sstevel@tonic-gate return (FALSE);
2917c478bd9Sstevel@tonic-gate if (!xdr_int(xdrs, &objp->mr_verbose))
2927c478bd9Sstevel@tonic-gate return (FALSE);
2937c478bd9Sstevel@tonic-gate return (TRUE);
2947c478bd9Sstevel@tonic-gate }
2957c478bd9Sstevel@tonic-gate bool_t
xdr_lookup_result_type(xdrs,objp)2967c478bd9Sstevel@tonic-gate xdr_lookup_result_type(xdrs, objp)
2977c478bd9Sstevel@tonic-gate register XDR *xdrs;
2987c478bd9Sstevel@tonic-gate lookup_result_type *objp;
2997c478bd9Sstevel@tonic-gate {
3007c478bd9Sstevel@tonic-gate if (!xdr_autofs_action(xdrs, &objp->action))
3017c478bd9Sstevel@tonic-gate return (FALSE);
3027c478bd9Sstevel@tonic-gate switch (objp->action) {
3037c478bd9Sstevel@tonic-gate case AUTOFS_LINK_RQ:
3047c478bd9Sstevel@tonic-gate if (!xdr_linka(xdrs, &objp->lookup_result_type_u.lt_linka))
3057c478bd9Sstevel@tonic-gate return (FALSE);
3067c478bd9Sstevel@tonic-gate break;
3077c478bd9Sstevel@tonic-gate }
3087c478bd9Sstevel@tonic-gate return (TRUE);
3097c478bd9Sstevel@tonic-gate }
3107c478bd9Sstevel@tonic-gate
3117c478bd9Sstevel@tonic-gate bool_t
xdr_autofs_lookupres(xdrs,objp)3127c478bd9Sstevel@tonic-gate xdr_autofs_lookupres(xdrs, objp)
3137c478bd9Sstevel@tonic-gate register XDR *xdrs;
3147c478bd9Sstevel@tonic-gate autofs_lookupres *objp;
3157c478bd9Sstevel@tonic-gate {
3167c478bd9Sstevel@tonic-gate if (!xdr_autofs_res(xdrs, &objp->lu_res))
3177c478bd9Sstevel@tonic-gate return (FALSE);
3187c478bd9Sstevel@tonic-gate if (!xdr_lookup_result_type(xdrs, &objp->lu_type))
3197c478bd9Sstevel@tonic-gate return (FALSE);
3207c478bd9Sstevel@tonic-gate if (!xdr_int(xdrs, &objp->lu_verbose))
3217c478bd9Sstevel@tonic-gate return (FALSE);
3227c478bd9Sstevel@tonic-gate return (TRUE);
3237c478bd9Sstevel@tonic-gate }
3247c478bd9Sstevel@tonic-gate
3257c478bd9Sstevel@tonic-gate /*
3267c478bd9Sstevel@tonic-gate * ******************************************************
3277c478bd9Sstevel@tonic-gate * Readdir XDR support
3287c478bd9Sstevel@tonic-gate * ******************************************************
3297c478bd9Sstevel@tonic-gate */
3307c478bd9Sstevel@tonic-gate
3317c478bd9Sstevel@tonic-gate bool_t
xdr_autofs_rddirargs(xdrs,objp)3327c478bd9Sstevel@tonic-gate xdr_autofs_rddirargs(xdrs, objp)
3337c478bd9Sstevel@tonic-gate register XDR *xdrs;
3347c478bd9Sstevel@tonic-gate autofs_rddirargs *objp;
3357c478bd9Sstevel@tonic-gate {
3367c478bd9Sstevel@tonic-gate if (!xdr_string(xdrs, &objp->rda_map, AUTOFS_MAXPATHLEN))
3377c478bd9Sstevel@tonic-gate return (FALSE);
3387c478bd9Sstevel@tonic-gate if (!xdr_u_int(xdrs, &objp->rda_offset))
3397c478bd9Sstevel@tonic-gate return (FALSE);
3407c478bd9Sstevel@tonic-gate if (!xdr_u_int(xdrs, &objp->rda_count))
3417c478bd9Sstevel@tonic-gate return (FALSE);
3423bfb48feSsemery if (!xdr_u_int(xdrs, (uint_t *)&objp->uid))
3433bfb48feSsemery return (FALSE);
3447c478bd9Sstevel@tonic-gate return (TRUE);
3457c478bd9Sstevel@tonic-gate }
3467c478bd9Sstevel@tonic-gate
3477c478bd9Sstevel@tonic-gate /*
3487c478bd9Sstevel@tonic-gate * Directory read reply:
3497c478bd9Sstevel@tonic-gate * union (enum autofs_res) {
3507c478bd9Sstevel@tonic-gate * AUTOFS_OK: entlist;
3517c478bd9Sstevel@tonic-gate * boolean eof;
3527c478bd9Sstevel@tonic-gate * default:
3537c478bd9Sstevel@tonic-gate * }
3547c478bd9Sstevel@tonic-gate *
3557c478bd9Sstevel@tonic-gate * Directory entries
3567c478bd9Sstevel@tonic-gate * struct direct {
3577c478bd9Sstevel@tonic-gate * off_t d_off; * offset of next entry *
3587c478bd9Sstevel@tonic-gate * u_long d_fileno; * inode number of entry *
3597c478bd9Sstevel@tonic-gate * u_short d_reclen; * length of this record *
3607c478bd9Sstevel@tonic-gate * u_short d_namlen; * length of string in d_name *
3617c478bd9Sstevel@tonic-gate * char d_name[MAXNAMLEN + 1]; * name no longer than this *
3627c478bd9Sstevel@tonic-gate * };
3637c478bd9Sstevel@tonic-gate * are on the wire as:
3647c478bd9Sstevel@tonic-gate * union entlist (boolean valid) {
3657c478bd9Sstevel@tonic-gate * TRUE: struct otw_dirent;
3667c478bd9Sstevel@tonic-gate * u_long nxtoffset;
3677c478bd9Sstevel@tonic-gate * union entlist;
3687c478bd9Sstevel@tonic-gate * FALSE:
3697c478bd9Sstevel@tonic-gate * }
3707c478bd9Sstevel@tonic-gate * where otw_dirent is:
3717c478bd9Sstevel@tonic-gate * struct dirent {
3727c478bd9Sstevel@tonic-gate * u_long de_fid;
3737c478bd9Sstevel@tonic-gate * string de_name<AUTOFS_MAXPATHLEN>;
3747c478bd9Sstevel@tonic-gate * }
3757c478bd9Sstevel@tonic-gate */
3767c478bd9Sstevel@tonic-gate
3777c478bd9Sstevel@tonic-gate #ifdef nextdp
3787c478bd9Sstevel@tonic-gate #undef nextdp
3797c478bd9Sstevel@tonic-gate #endif
3807c478bd9Sstevel@tonic-gate #define nextdp(dp) ((struct dirent64 *)((char *)(dp) + (dp)->d_reclen))
3817c478bd9Sstevel@tonic-gate
3827c478bd9Sstevel@tonic-gate /*
3837c478bd9Sstevel@tonic-gate * ENCODE ONLY
3847c478bd9Sstevel@tonic-gate */
3857c478bd9Sstevel@tonic-gate bool_t
xdr_autofs_putrddirres(xdrs,rddir,reqsize)3867c478bd9Sstevel@tonic-gate xdr_autofs_putrddirres(xdrs, rddir, reqsize)
3877c478bd9Sstevel@tonic-gate XDR *xdrs;
3887c478bd9Sstevel@tonic-gate struct autofsrddir *rddir;
3897c478bd9Sstevel@tonic-gate uint_t reqsize; /* requested size */
3907c478bd9Sstevel@tonic-gate {
3917c478bd9Sstevel@tonic-gate struct dirent64 *dp;
3927c478bd9Sstevel@tonic-gate char *name;
3937c478bd9Sstevel@tonic-gate int size;
39439d3e169Sevanl uint_t namlen;
3957c478bd9Sstevel@tonic-gate bool_t true = TRUE;
3967c478bd9Sstevel@tonic-gate bool_t false = FALSE;
3977c478bd9Sstevel@tonic-gate int entrysz;
3987c478bd9Sstevel@tonic-gate int tofit;
3997c478bd9Sstevel@tonic-gate int bufsize;
4007c478bd9Sstevel@tonic-gate uint_t ino, off;
4017c478bd9Sstevel@tonic-gate
4027c478bd9Sstevel@tonic-gate bufsize = 1 * BYTES_PER_XDR_UNIT;
4037c478bd9Sstevel@tonic-gate for (size = rddir->rddir_size, dp = rddir->rddir_entries;
4047c478bd9Sstevel@tonic-gate size > 0;
4057c478bd9Sstevel@tonic-gate /* LINTED pointer alignment */
4067c478bd9Sstevel@tonic-gate size -= dp->d_reclen, dp = nextdp(dp)) {
4077c478bd9Sstevel@tonic-gate if (dp->d_reclen == 0 /* || DIRSIZ(dp) > dp->d_reclen */) {
4087c478bd9Sstevel@tonic-gate return (FALSE);
4097c478bd9Sstevel@tonic-gate }
4107c478bd9Sstevel@tonic-gate if (dp->d_ino == 0) {
4117c478bd9Sstevel@tonic-gate continue;
4127c478bd9Sstevel@tonic-gate }
4137c478bd9Sstevel@tonic-gate name = dp->d_name;
4147c478bd9Sstevel@tonic-gate namlen = strlen(name);
4157c478bd9Sstevel@tonic-gate ino = (uint_t)dp->d_ino;
4167c478bd9Sstevel@tonic-gate off = (uint_t)dp->d_off;
4177c478bd9Sstevel@tonic-gate entrysz = (1 + 1 + 1 + 1) * BYTES_PER_XDR_UNIT +
4187c478bd9Sstevel@tonic-gate roundup(namlen, BYTES_PER_XDR_UNIT);
4197c478bd9Sstevel@tonic-gate tofit = entrysz + 2 * BYTES_PER_XDR_UNIT;
4207c478bd9Sstevel@tonic-gate if (bufsize + tofit > reqsize) {
4217c478bd9Sstevel@tonic-gate rddir->rddir_eof = FALSE;
4227c478bd9Sstevel@tonic-gate break;
4237c478bd9Sstevel@tonic-gate }
4247c478bd9Sstevel@tonic-gate if (!xdr_bool(xdrs, &true) ||
4257c478bd9Sstevel@tonic-gate !xdr_u_int(xdrs, &ino) ||
4267c478bd9Sstevel@tonic-gate !xdr_bytes(xdrs, &name, &namlen, AUTOFS_MAXPATHLEN) ||
4277c478bd9Sstevel@tonic-gate !xdr_u_int(xdrs, &off)) {
4287c478bd9Sstevel@tonic-gate return (FALSE);
4297c478bd9Sstevel@tonic-gate }
4307c478bd9Sstevel@tonic-gate bufsize += entrysz;
4317c478bd9Sstevel@tonic-gate }
4327c478bd9Sstevel@tonic-gate if (!xdr_bool(xdrs, &false)) {
4337c478bd9Sstevel@tonic-gate return (FALSE);
4347c478bd9Sstevel@tonic-gate }
4357c478bd9Sstevel@tonic-gate if (!xdr_bool(xdrs, &rddir->rddir_eof)) {
4367c478bd9Sstevel@tonic-gate return (FALSE);
4377c478bd9Sstevel@tonic-gate }
4387c478bd9Sstevel@tonic-gate return (TRUE);
4397c478bd9Sstevel@tonic-gate }
4407c478bd9Sstevel@tonic-gate
4417c478bd9Sstevel@tonic-gate #define DIRENT64_RECLEN(namelen) \
4427c478bd9Sstevel@tonic-gate (((int)(((dirent64_t *)0)->d_name) + 1 + (namelen) + 7) & ~ 7)
4437c478bd9Sstevel@tonic-gate #define reclen(namlen) DIRENT64_RECLEN((namlen))
4447c478bd9Sstevel@tonic-gate
4457c478bd9Sstevel@tonic-gate /*
4467c478bd9Sstevel@tonic-gate * DECODE ONLY
4477c478bd9Sstevel@tonic-gate */
4487c478bd9Sstevel@tonic-gate bool_t
xdr_autofs_getrddirres(xdrs,rddir)4497c478bd9Sstevel@tonic-gate xdr_autofs_getrddirres(xdrs, rddir)
4507c478bd9Sstevel@tonic-gate XDR *xdrs;
4517c478bd9Sstevel@tonic-gate struct autofsrddir *rddir;
4527c478bd9Sstevel@tonic-gate {
4537c478bd9Sstevel@tonic-gate struct dirent64 *dp;
45439d3e169Sevanl uint_t namlen;
4557c478bd9Sstevel@tonic-gate int size;
4567c478bd9Sstevel@tonic-gate bool_t valid;
4577c478bd9Sstevel@tonic-gate int offset = -1;
4587c478bd9Sstevel@tonic-gate uint_t fileid;
4597c478bd9Sstevel@tonic-gate
4607c478bd9Sstevel@tonic-gate size = rddir->rddir_size;
4617c478bd9Sstevel@tonic-gate dp = rddir->rddir_entries;
4627c478bd9Sstevel@tonic-gate for (;;) {
4637c478bd9Sstevel@tonic-gate if (!xdr_bool(xdrs, &valid)) {
4647c478bd9Sstevel@tonic-gate return (FALSE);
4657c478bd9Sstevel@tonic-gate }
4667c478bd9Sstevel@tonic-gate if (!valid) {
4677c478bd9Sstevel@tonic-gate break;
4687c478bd9Sstevel@tonic-gate }
4697c478bd9Sstevel@tonic-gate if (!xdr_u_int(xdrs, &fileid) ||
4707c478bd9Sstevel@tonic-gate !xdr_u_int(xdrs, &namlen)) {
4717c478bd9Sstevel@tonic-gate return (FALSE);
4727c478bd9Sstevel@tonic-gate }
4737c478bd9Sstevel@tonic-gate if (reclen(namlen) > size) {
4747c478bd9Sstevel@tonic-gate rddir->rddir_eof = FALSE;
4757c478bd9Sstevel@tonic-gate goto bufovflw;
4767c478bd9Sstevel@tonic-gate }
4777c478bd9Sstevel@tonic-gate if (!xdr_opaque(xdrs, dp->d_name, namlen)||
4787c478bd9Sstevel@tonic-gate !xdr_int(xdrs, &offset)) {
4797c478bd9Sstevel@tonic-gate return (FALSE);
4807c478bd9Sstevel@tonic-gate }
4817c478bd9Sstevel@tonic-gate dp->d_ino = fileid;
4827c478bd9Sstevel@tonic-gate dp->d_reclen = reclen(namlen);
4837c478bd9Sstevel@tonic-gate dp->d_name[namlen] = '\0';
4847c478bd9Sstevel@tonic-gate dp->d_off = offset;
4857c478bd9Sstevel@tonic-gate size -= dp->d_reclen;
4867c478bd9Sstevel@tonic-gate /* LINTED pointer alignment */
4877c478bd9Sstevel@tonic-gate dp = nextdp(dp);
4887c478bd9Sstevel@tonic-gate }
4897c478bd9Sstevel@tonic-gate if (!xdr_bool(xdrs, &rddir->rddir_eof)) {
4907c478bd9Sstevel@tonic-gate return (FALSE);
4917c478bd9Sstevel@tonic-gate }
4927c478bd9Sstevel@tonic-gate bufovflw:
4937c478bd9Sstevel@tonic-gate rddir->rddir_size = (char *)dp - (char *)(rddir->rddir_entries);
4947c478bd9Sstevel@tonic-gate rddir->rddir_offset = offset;
4957c478bd9Sstevel@tonic-gate return (TRUE);
4967c478bd9Sstevel@tonic-gate }
4977c478bd9Sstevel@tonic-gate
4987c478bd9Sstevel@tonic-gate bool_t
xdr_autofs_rddirres(register XDR * xdrs,autofs_rddirres * objp)4997c478bd9Sstevel@tonic-gate xdr_autofs_rddirres(register XDR *xdrs, autofs_rddirres *objp)
5007c478bd9Sstevel@tonic-gate {
5017c478bd9Sstevel@tonic-gate if (!xdr_enum(xdrs, (enum_t *)&objp->rd_status))
5027c478bd9Sstevel@tonic-gate return (FALSE);
5037c478bd9Sstevel@tonic-gate if (objp->rd_status != AUTOFS_OK)
5047c478bd9Sstevel@tonic-gate return (TRUE);
5057c478bd9Sstevel@tonic-gate if (xdrs->x_op == XDR_ENCODE)
5067c478bd9Sstevel@tonic-gate return (xdr_autofs_putrddirres(
5077c478bd9Sstevel@tonic-gate xdrs, (struct autofsrddir *)&objp->rd_rddir,
5087c478bd9Sstevel@tonic-gate objp->rd_bufsize));
5097c478bd9Sstevel@tonic-gate else if (xdrs->x_op == XDR_DECODE)
5107c478bd9Sstevel@tonic-gate return (xdr_autofs_getrddirres(xdrs,
5117c478bd9Sstevel@tonic-gate (struct autofsrddir *)&objp->rd_rddir));
5127c478bd9Sstevel@tonic-gate else return (FALSE);
5137c478bd9Sstevel@tonic-gate }
514