10Sstevel@tonic-gate /*
20Sstevel@tonic-gate * CDDL HEADER START
30Sstevel@tonic-gate *
40Sstevel@tonic-gate * The contents of this file are subject to the terms of the
52170Sevanl * Common Development and Distribution License (the "License").
62170Sevanl * You may not use this file except in compliance with the License.
70Sstevel@tonic-gate *
80Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
90Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing.
100Sstevel@tonic-gate * See the License for the specific language governing permissions
110Sstevel@tonic-gate * and limitations under the License.
120Sstevel@tonic-gate *
130Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each
140Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
150Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the
160Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying
170Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner]
180Sstevel@tonic-gate *
190Sstevel@tonic-gate * CDDL HEADER END
200Sstevel@tonic-gate */
210Sstevel@tonic-gate /*
22*8610SRobert.Thurlow@Sun.COM * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
230Sstevel@tonic-gate * Use is subject to license terms.
240Sstevel@tonic-gate */
250Sstevel@tonic-gate
260Sstevel@tonic-gate /*
270Sstevel@tonic-gate * This file can not be automatically generated by rpcgen from
280Sstevel@tonic-gate * autofs_prot.x because of the xdr routines that provide readdir
290Sstevel@tonic-gate * support, its own implementation of xdr_autofs_netbuf(). rpcgen will
300Sstevel@tonic-gate * also generate xdr routines with recursion which should not be used
310Sstevel@tonic-gate * in the kernel.
320Sstevel@tonic-gate */
330Sstevel@tonic-gate
340Sstevel@tonic-gate #include <sys/param.h>
350Sstevel@tonic-gate #include <sys/kmem.h>
360Sstevel@tonic-gate #include <sys/errno.h>
370Sstevel@tonic-gate #include <sys/proc.h>
380Sstevel@tonic-gate #include <sys/vfs.h>
390Sstevel@tonic-gate #include <sys/vnode.h>
400Sstevel@tonic-gate #include <sys/pathname.h>
410Sstevel@tonic-gate #include <sys/cred.h>
420Sstevel@tonic-gate #include <sys/mount.h>
430Sstevel@tonic-gate #include <sys/cmn_err.h>
440Sstevel@tonic-gate #include <sys/debug.h>
450Sstevel@tonic-gate #include <sys/systm.h>
460Sstevel@tonic-gate #include <rpc/types.h>
470Sstevel@tonic-gate #include <rpc/xdr.h>
480Sstevel@tonic-gate #include <rpc/auth.h>
490Sstevel@tonic-gate #include <rpc/clnt.h>
500Sstevel@tonic-gate #include <sys/ticotsord.h>
510Sstevel@tonic-gate #include <sys/dirent.h>
522170Sevanl #include <sys/sysmacros.h>
530Sstevel@tonic-gate #include <fs/fs_subr.h>
540Sstevel@tonic-gate #include <sys/fs/autofs.h>
550Sstevel@tonic-gate
560Sstevel@tonic-gate bool_t xdr_autofs_netbuf(XDR *, struct netbuf *);
570Sstevel@tonic-gate bool_t xdr_mounta(XDR *, struct mounta *);
580Sstevel@tonic-gate
590Sstevel@tonic-gate bool_t
xdr_umntrequest(XDR * xdrs,umntrequest * objp)600Sstevel@tonic-gate xdr_umntrequest(XDR *xdrs, umntrequest *objp)
610Sstevel@tonic-gate {
620Sstevel@tonic-gate bool_t more_data;
630Sstevel@tonic-gate
640Sstevel@tonic-gate ASSERT(xdrs->x_op == XDR_ENCODE);
650Sstevel@tonic-gate
660Sstevel@tonic-gate for (; objp != NULL; objp = objp->next) {
670Sstevel@tonic-gate if (!xdr_bool_t(xdrs, &objp->isdirect))
680Sstevel@tonic-gate return (FALSE);
690Sstevel@tonic-gate if (!xdr_string(xdrs, &objp->mntresource, AUTOFS_MAXPATHLEN))
700Sstevel@tonic-gate return (FALSE);
710Sstevel@tonic-gate if (!xdr_string(xdrs, &objp->mntpnt, AUTOFS_MAXPATHLEN))
720Sstevel@tonic-gate return (FALSE);
730Sstevel@tonic-gate if (!xdr_string(xdrs, &objp->fstype, AUTOFS_MAXCOMPONENTLEN))
740Sstevel@tonic-gate return (FALSE);
750Sstevel@tonic-gate if (!xdr_string(xdrs, &objp->mntopts, AUTOFS_MAXOPTSLEN))
760Sstevel@tonic-gate return (FALSE);
770Sstevel@tonic-gate
780Sstevel@tonic-gate if (objp->next != NULL)
790Sstevel@tonic-gate more_data = TRUE;
800Sstevel@tonic-gate else
810Sstevel@tonic-gate more_data = FALSE;
820Sstevel@tonic-gate
830Sstevel@tonic-gate if (!xdr_bool(xdrs, &more_data))
840Sstevel@tonic-gate return (FALSE);
850Sstevel@tonic-gate }
860Sstevel@tonic-gate return (TRUE);
870Sstevel@tonic-gate }
880Sstevel@tonic-gate
890Sstevel@tonic-gate bool_t
xdr_umntres(XDR * xdrs,umntres * objp)900Sstevel@tonic-gate xdr_umntres(XDR *xdrs, umntres *objp)
910Sstevel@tonic-gate {
920Sstevel@tonic-gate return (xdr_int(xdrs, &objp->status));
930Sstevel@tonic-gate }
940Sstevel@tonic-gate
950Sstevel@tonic-gate bool_t
xdr_autofs_stat(XDR * xdrs,autofs_stat * objp)960Sstevel@tonic-gate xdr_autofs_stat(XDR *xdrs, autofs_stat *objp)
970Sstevel@tonic-gate {
980Sstevel@tonic-gate if (!xdr_enum(xdrs, (enum_t *)objp))
990Sstevel@tonic-gate return (FALSE);
1000Sstevel@tonic-gate return (TRUE);
1010Sstevel@tonic-gate }
1020Sstevel@tonic-gate
1030Sstevel@tonic-gate bool_t
xdr_autofs_action(XDR * xdrs,autofs_action * objp)1040Sstevel@tonic-gate xdr_autofs_action(XDR *xdrs, autofs_action *objp)
1050Sstevel@tonic-gate {
1060Sstevel@tonic-gate if (!xdr_enum(xdrs, (enum_t *)objp))
1070Sstevel@tonic-gate return (FALSE);
1080Sstevel@tonic-gate return (TRUE);
1090Sstevel@tonic-gate }
1100Sstevel@tonic-gate
1110Sstevel@tonic-gate bool_t
xdr_linka(XDR * xdrs,linka * objp)1120Sstevel@tonic-gate xdr_linka(XDR *xdrs, linka *objp)
1130Sstevel@tonic-gate {
1140Sstevel@tonic-gate if (!xdr_string(xdrs, &objp->dir, AUTOFS_MAXPATHLEN))
1150Sstevel@tonic-gate return (FALSE);
1160Sstevel@tonic-gate if (!xdr_string(xdrs, &objp->link, AUTOFS_MAXPATHLEN))
1170Sstevel@tonic-gate return (FALSE);
1180Sstevel@tonic-gate return (TRUE);
1190Sstevel@tonic-gate }
1200Sstevel@tonic-gate
1210Sstevel@tonic-gate bool_t
xdr_autofs_args(XDR * xdrs,autofs_args * objp)1220Sstevel@tonic-gate xdr_autofs_args(XDR *xdrs, autofs_args *objp)
1230Sstevel@tonic-gate {
1240Sstevel@tonic-gate if (!xdr_autofs_netbuf(xdrs, &objp->addr))
1250Sstevel@tonic-gate return (FALSE);
1260Sstevel@tonic-gate if (!xdr_string(xdrs, &objp->path, AUTOFS_MAXPATHLEN))
1270Sstevel@tonic-gate return (FALSE);
1280Sstevel@tonic-gate if (!xdr_string(xdrs, &objp->opts, AUTOFS_MAXOPTSLEN))
1290Sstevel@tonic-gate return (FALSE);
1300Sstevel@tonic-gate if (!xdr_string(xdrs, &objp->map, AUTOFS_MAXPATHLEN))
1310Sstevel@tonic-gate return (FALSE);
1320Sstevel@tonic-gate if (!xdr_string(xdrs, &objp->subdir, AUTOFS_MAXPATHLEN))
1330Sstevel@tonic-gate return (FALSE);
1340Sstevel@tonic-gate if (!xdr_string(xdrs, &objp->key, AUTOFS_MAXCOMPONENTLEN))
1350Sstevel@tonic-gate return (FALSE);
1360Sstevel@tonic-gate if (!xdr_int(xdrs, &objp->mount_to))
1370Sstevel@tonic-gate return (FALSE);
1380Sstevel@tonic-gate if (!xdr_int(xdrs, &objp->rpc_to))
1390Sstevel@tonic-gate return (FALSE);
1400Sstevel@tonic-gate if (!xdr_int(xdrs, &objp->direct))
1410Sstevel@tonic-gate return (FALSE);
1420Sstevel@tonic-gate return (TRUE);
1430Sstevel@tonic-gate }
1440Sstevel@tonic-gate
1450Sstevel@tonic-gate bool_t
xdr_action_list_entry(XDR * xdrs,action_list_entry * objp)1460Sstevel@tonic-gate xdr_action_list_entry(XDR *xdrs, action_list_entry *objp)
1470Sstevel@tonic-gate {
1480Sstevel@tonic-gate if (!xdr_autofs_action(xdrs, &objp->action))
1490Sstevel@tonic-gate return (FALSE);
1500Sstevel@tonic-gate switch (objp->action) {
1510Sstevel@tonic-gate case AUTOFS_MOUNT_RQ:
1520Sstevel@tonic-gate if (!xdr_mounta(xdrs, &objp->action_list_entry_u.mounta))
1530Sstevel@tonic-gate return (FALSE);
1540Sstevel@tonic-gate break;
1550Sstevel@tonic-gate case AUTOFS_LINK_RQ:
1560Sstevel@tonic-gate if (!xdr_linka(xdrs, &objp->action_list_entry_u.linka))
1570Sstevel@tonic-gate return (FALSE);
1580Sstevel@tonic-gate break;
1590Sstevel@tonic-gate default:
1600Sstevel@tonic-gate break;
1610Sstevel@tonic-gate }
1620Sstevel@tonic-gate return (TRUE);
1630Sstevel@tonic-gate }
1640Sstevel@tonic-gate
1650Sstevel@tonic-gate bool_t
xdr_action_list(XDR * xdrs,action_list * objp)1660Sstevel@tonic-gate xdr_action_list(XDR *xdrs, action_list *objp)
1670Sstevel@tonic-gate {
1680Sstevel@tonic-gate bool_t more_data = TRUE;
1690Sstevel@tonic-gate bool_t status = TRUE;
170*8610SRobert.Thurlow@Sun.COM action_list *p, *last;
1710Sstevel@tonic-gate
1720Sstevel@tonic-gate ASSERT((xdrs->x_op == XDR_DECODE) || (xdrs->x_op == XDR_FREE));
1730Sstevel@tonic-gate
1740Sstevel@tonic-gate more_data = (objp != NULL);
1750Sstevel@tonic-gate p = objp;
1760Sstevel@tonic-gate
177*8610SRobert.Thurlow@Sun.COM if (xdrs->x_op == XDR_FREE) {
178*8610SRobert.Thurlow@Sun.COM while (p != NULL) {
179*8610SRobert.Thurlow@Sun.COM if (!xdr_action_list_entry(xdrs, &p->action))
180*8610SRobert.Thurlow@Sun.COM cmn_err(CE_WARN, "xdr_action_list: "
181*8610SRobert.Thurlow@Sun.COM "action_list_entry free failed %p\n",
182*8610SRobert.Thurlow@Sun.COM (void *)&p->action);
183*8610SRobert.Thurlow@Sun.COM last = p;
184*8610SRobert.Thurlow@Sun.COM p = p->next;
185*8610SRobert.Thurlow@Sun.COM kmem_free(last, sizeof (*last));
186*8610SRobert.Thurlow@Sun.COM }
187*8610SRobert.Thurlow@Sun.COM return (status);
188*8610SRobert.Thurlow@Sun.COM }
1890Sstevel@tonic-gate
1900Sstevel@tonic-gate while (more_data) {
191*8610SRobert.Thurlow@Sun.COM if (!xdr_action_list_entry(xdrs, &p->action)) {
192*8610SRobert.Thurlow@Sun.COM status = FALSE;
193*8610SRobert.Thurlow@Sun.COM break;
194*8610SRobert.Thurlow@Sun.COM }
1950Sstevel@tonic-gate
196*8610SRobert.Thurlow@Sun.COM if (!xdr_bool(xdrs, &more_data)) {
197*8610SRobert.Thurlow@Sun.COM status = FALSE;
198*8610SRobert.Thurlow@Sun.COM break;
199*8610SRobert.Thurlow@Sun.COM }
2000Sstevel@tonic-gate
2010Sstevel@tonic-gate if (more_data) {
2020Sstevel@tonic-gate p->next = kmem_zalloc(sizeof (action_list), KM_SLEEP);
2030Sstevel@tonic-gate p = p->next;
2040Sstevel@tonic-gate if (p == NULL) {
2050Sstevel@tonic-gate status = FALSE;
206*8610SRobert.Thurlow@Sun.COM break;
2070Sstevel@tonic-gate }
2080Sstevel@tonic-gate } else
2090Sstevel@tonic-gate p->next = NULL;
2100Sstevel@tonic-gate }
2110Sstevel@tonic-gate return (status);
2120Sstevel@tonic-gate }
2130Sstevel@tonic-gate
2140Sstevel@tonic-gate bool_t
xdr_autofs_netbuf(XDR * xdrs,struct netbuf * objp)2150Sstevel@tonic-gate xdr_autofs_netbuf(XDR *xdrs, struct netbuf *objp)
2160Sstevel@tonic-gate {
2170Sstevel@tonic-gate bool_t dummy;
2180Sstevel@tonic-gate
2190Sstevel@tonic-gate if (!xdr_u_int(xdrs, (uint_t *)&objp->maxlen))
2200Sstevel@tonic-gate return (FALSE);
2210Sstevel@tonic-gate dummy = xdr_bytes(xdrs, (char **)&(objp->buf),
2220Sstevel@tonic-gate (uint_t *)&(objp->len), objp->maxlen);
2230Sstevel@tonic-gate return (dummy);
2240Sstevel@tonic-gate }
2250Sstevel@tonic-gate
2260Sstevel@tonic-gate bool_t
xdr_mounta(XDR * xdrs,struct mounta * objp)2270Sstevel@tonic-gate xdr_mounta(XDR *xdrs, struct mounta *objp)
2280Sstevel@tonic-gate {
2290Sstevel@tonic-gate if (!xdr_string(xdrs, &objp->spec, AUTOFS_MAXPATHLEN))
2300Sstevel@tonic-gate return (FALSE);
2310Sstevel@tonic-gate if (!xdr_string(xdrs, &objp->dir, AUTOFS_MAXPATHLEN))
2320Sstevel@tonic-gate return (FALSE);
2330Sstevel@tonic-gate if (!xdr_int(xdrs, &objp->flags))
2340Sstevel@tonic-gate return (FALSE);
2350Sstevel@tonic-gate if (!xdr_string(xdrs, &objp->fstype, AUTOFS_MAXCOMPONENTLEN))
2360Sstevel@tonic-gate return (FALSE);
2374068Sdm120769 if (!xdr_pointer(xdrs, (char **)&objp->dataptr, sizeof (autofs_args),
2384068Sdm120769 (xdrproc_t)xdr_autofs_args))
2394068Sdm120769 return (FALSE);
2400Sstevel@tonic-gate /*
2410Sstevel@tonic-gate * The length is the original user-land length, not the
2420Sstevel@tonic-gate * length of the native kernel autofs_args structure provided
2430Sstevel@tonic-gate * after we decode the xdr buffer. So passing the user's idea of
2440Sstevel@tonic-gate * the length is wrong and we need to stuff the length field with
2450Sstevel@tonic-gate * the length of the native structure.
2460Sstevel@tonic-gate */
2474068Sdm120769 if (!xdr_int(xdrs, &objp->datalen))
2484068Sdm120769 return (FALSE);
2494068Sdm120769 if (xdrs->x_op == XDR_DECODE)
2504068Sdm120769 objp->datalen = sizeof (struct autofs_args);
2514068Sdm120769 if (!xdr_string(xdrs, &objp->optptr, AUTOFS_MAXOPTSLEN))
2524068Sdm120769 return (FALSE);
2533901Skr143551 if (!xdr_int(xdrs, &objp->optlen))
2540Sstevel@tonic-gate return (FALSE);
2554068Sdm120769 ASSERT((xdrs->x_op == XDR_DECODE) || (xdrs->x_op == XDR_FREE));
2560Sstevel@tonic-gate return (TRUE);
2570Sstevel@tonic-gate }
2580Sstevel@tonic-gate
2590Sstevel@tonic-gate bool_t
xdr_autofs_res(XDR * xdrs,autofs_res * objp)2600Sstevel@tonic-gate xdr_autofs_res(XDR *xdrs, autofs_res *objp)
2610Sstevel@tonic-gate {
2620Sstevel@tonic-gate if (!xdr_enum(xdrs, (enum_t *)objp))
2630Sstevel@tonic-gate return (FALSE);
2640Sstevel@tonic-gate return (TRUE);
2650Sstevel@tonic-gate }
2660Sstevel@tonic-gate
2670Sstevel@tonic-gate bool_t
xdr_autofs_lookupargs(XDR * xdrs,autofs_lookupargs * objp)2680Sstevel@tonic-gate xdr_autofs_lookupargs(XDR *xdrs, autofs_lookupargs *objp)
2690Sstevel@tonic-gate {
2700Sstevel@tonic-gate if (!xdr_string(xdrs, &objp->map, AUTOFS_MAXPATHLEN))
2710Sstevel@tonic-gate return (FALSE);
2720Sstevel@tonic-gate if (!xdr_string(xdrs, &objp->path, AUTOFS_MAXPATHLEN))
2730Sstevel@tonic-gate return (FALSE);
2740Sstevel@tonic-gate if (!xdr_string(xdrs, &objp->name, AUTOFS_MAXCOMPONENTLEN))
2750Sstevel@tonic-gate return (FALSE);
2760Sstevel@tonic-gate if (!xdr_string(xdrs, &objp->subdir, AUTOFS_MAXPATHLEN))
2770Sstevel@tonic-gate return (FALSE);
2780Sstevel@tonic-gate if (!xdr_string(xdrs, &objp->opts, AUTOFS_MAXOPTSLEN))
2790Sstevel@tonic-gate return (FALSE);
2800Sstevel@tonic-gate if (!xdr_bool_t(xdrs, &objp->isdirect))
2810Sstevel@tonic-gate return (FALSE);
2823391Ssemery if (!xdr_u_int(xdrs, (uint_t *)&objp->uid))
2833391Ssemery return (FALSE);
2840Sstevel@tonic-gate return (TRUE);
2850Sstevel@tonic-gate }
2860Sstevel@tonic-gate
2870Sstevel@tonic-gate bool_t
xdr_mount_result_type(XDR * xdrs,mount_result_type * objp)2880Sstevel@tonic-gate xdr_mount_result_type(XDR *xdrs, mount_result_type *objp)
2890Sstevel@tonic-gate {
2900Sstevel@tonic-gate if (!xdr_autofs_stat(xdrs, &objp->status))
2910Sstevel@tonic-gate return (FALSE);
2920Sstevel@tonic-gate switch (objp->status) {
2930Sstevel@tonic-gate case AUTOFS_ACTION:
2940Sstevel@tonic-gate if (!xdr_pointer(xdrs,
2950Sstevel@tonic-gate (char **)&objp->mount_result_type_u.list,
2960Sstevel@tonic-gate sizeof (action_list), (xdrproc_t)xdr_action_list))
2970Sstevel@tonic-gate return (FALSE);
2980Sstevel@tonic-gate break;
2990Sstevel@tonic-gate case AUTOFS_DONE:
3000Sstevel@tonic-gate if (!xdr_int(xdrs, &objp->mount_result_type_u.error))
3010Sstevel@tonic-gate return (FALSE);
3020Sstevel@tonic-gate break;
3030Sstevel@tonic-gate }
3040Sstevel@tonic-gate return (TRUE);
3050Sstevel@tonic-gate }
3060Sstevel@tonic-gate
3070Sstevel@tonic-gate bool_t
xdr_autofs_mountres(XDR * xdrs,autofs_mountres * objp)3080Sstevel@tonic-gate xdr_autofs_mountres(XDR *xdrs, autofs_mountres *objp)
3090Sstevel@tonic-gate {
3100Sstevel@tonic-gate if (!xdr_mount_result_type(xdrs, &objp->mr_type))
3110Sstevel@tonic-gate return (FALSE);
3120Sstevel@tonic-gate if (!xdr_int(xdrs, &objp->mr_verbose))
3130Sstevel@tonic-gate return (FALSE);
3140Sstevel@tonic-gate return (TRUE);
3150Sstevel@tonic-gate }
3160Sstevel@tonic-gate
3170Sstevel@tonic-gate bool_t
xdr_lookup_result_type(XDR * xdrs,lookup_result_type * objp)3180Sstevel@tonic-gate xdr_lookup_result_type(XDR *xdrs, lookup_result_type *objp)
3190Sstevel@tonic-gate {
3200Sstevel@tonic-gate if (!xdr_autofs_action(xdrs, &objp->action))
3210Sstevel@tonic-gate return (FALSE);
3220Sstevel@tonic-gate switch (objp->action) {
3230Sstevel@tonic-gate case AUTOFS_LINK_RQ:
3240Sstevel@tonic-gate if (!xdr_linka(xdrs, &objp->lookup_result_type_u.lt_linka))
3250Sstevel@tonic-gate return (FALSE);
3260Sstevel@tonic-gate break;
3270Sstevel@tonic-gate default:
3280Sstevel@tonic-gate break;
3290Sstevel@tonic-gate }
3300Sstevel@tonic-gate return (TRUE);
3310Sstevel@tonic-gate }
3320Sstevel@tonic-gate
3330Sstevel@tonic-gate bool_t
xdr_autofs_lookupres(XDR * xdrs,autofs_lookupres * objp)3340Sstevel@tonic-gate xdr_autofs_lookupres(XDR *xdrs, autofs_lookupres *objp)
3350Sstevel@tonic-gate {
3360Sstevel@tonic-gate if (!xdr_autofs_res(xdrs, &objp->lu_res))
3370Sstevel@tonic-gate return (FALSE);
3380Sstevel@tonic-gate if (!xdr_lookup_result_type(xdrs, &objp->lu_type))
3390Sstevel@tonic-gate return (FALSE);
3400Sstevel@tonic-gate if (!xdr_int(xdrs, &objp->lu_verbose))
3410Sstevel@tonic-gate return (FALSE);
3420Sstevel@tonic-gate return (TRUE);
3430Sstevel@tonic-gate }
3440Sstevel@tonic-gate
3450Sstevel@tonic-gate bool_t
xdr_autofs_rddirargs(XDR * xdrs,autofs_rddirargs * objp)3460Sstevel@tonic-gate xdr_autofs_rddirargs(XDR *xdrs, autofs_rddirargs *objp)
3470Sstevel@tonic-gate {
3480Sstevel@tonic-gate if (!xdr_string(xdrs, &objp->rda_map, AUTOFS_MAXPATHLEN))
3490Sstevel@tonic-gate return (FALSE);
3500Sstevel@tonic-gate if (!xdr_u_int(xdrs, &objp->rda_offset))
3510Sstevel@tonic-gate return (FALSE);
3520Sstevel@tonic-gate if (!xdr_u_int(xdrs, &objp->rda_count))
3530Sstevel@tonic-gate return (FALSE);
3543391Ssemery if (!xdr_u_int(xdrs, (uint_t *)&objp->uid))
3553391Ssemery return (FALSE);
3560Sstevel@tonic-gate return (TRUE);
3570Sstevel@tonic-gate }
3580Sstevel@tonic-gate
3590Sstevel@tonic-gate /*
3600Sstevel@tonic-gate * Directory read reply:
3610Sstevel@tonic-gate * union (enum autofs_res) {
3620Sstevel@tonic-gate * AUTOFS_OK: entlist;
3630Sstevel@tonic-gate * boolean eof;
3640Sstevel@tonic-gate * default:
3650Sstevel@tonic-gate * }
3660Sstevel@tonic-gate *
3670Sstevel@tonic-gate * Directory entries
3680Sstevel@tonic-gate * struct direct {
3690Sstevel@tonic-gate * off_t d_off; * offset of next entry *
3700Sstevel@tonic-gate * u_long d_fileno; * inode number of entry *
3710Sstevel@tonic-gate * ushort_t d_reclen; * length of this record *
3720Sstevel@tonic-gate * ushort_t d_namlen; * length of string in d_name *
3730Sstevel@tonic-gate * char d_name[MAXNAMLEN + 1]; * name no longer than this *
3740Sstevel@tonic-gate * };
3750Sstevel@tonic-gate * are on the wire as:
3760Sstevel@tonic-gate * union entlist (boolean valid) {
3770Sstevel@tonic-gate * TRUE: struct otw_dirent;
3780Sstevel@tonic-gate * uint_t nxtoffset;
3790Sstevel@tonic-gate * union entlist;
3800Sstevel@tonic-gate * FALSE:
3810Sstevel@tonic-gate * }
3820Sstevel@tonic-gate * where otw_dirent is:
3830Sstevel@tonic-gate * struct dirent {
3840Sstevel@tonic-gate * uint_t de_fid;
3850Sstevel@tonic-gate * string de_name<AUTOFS_MAXPATHLEN>;
3860Sstevel@tonic-gate * }
3870Sstevel@tonic-gate */
3880Sstevel@tonic-gate
3890Sstevel@tonic-gate #ifdef nextdp
3900Sstevel@tonic-gate #undef nextdp
3910Sstevel@tonic-gate #endif
3920Sstevel@tonic-gate #define nextdp(dp) ((struct dirent64 *)((char *)(dp) + (dp)->d_reclen))
3930Sstevel@tonic-gate
3940Sstevel@tonic-gate /*
3950Sstevel@tonic-gate * ENCODE ONLY
3960Sstevel@tonic-gate */
3970Sstevel@tonic-gate bool_t
xdr_autofs_putrddirres(XDR * xdrs,struct autofsrddir * rddir,uint_t reqsize)3980Sstevel@tonic-gate xdr_autofs_putrddirres(XDR *xdrs, struct autofsrddir *rddir, uint_t reqsize)
3990Sstevel@tonic-gate {
4000Sstevel@tonic-gate struct dirent64 *dp;
4010Sstevel@tonic-gate char *name;
4020Sstevel@tonic-gate int size;
4030Sstevel@tonic-gate uint_t namlen;
4040Sstevel@tonic-gate bool_t true = TRUE;
4050Sstevel@tonic-gate bool_t false = FALSE;
4060Sstevel@tonic-gate int entrysz;
4070Sstevel@tonic-gate int tofit;
4080Sstevel@tonic-gate int bufsize;
4090Sstevel@tonic-gate uint_t ino, off;
4100Sstevel@tonic-gate
4110Sstevel@tonic-gate bufsize = 1 * BYTES_PER_XDR_UNIT;
4120Sstevel@tonic-gate for (size = rddir->rddir_size, dp = rddir->rddir_entries;
413*8610SRobert.Thurlow@Sun.COM size > 0;
414*8610SRobert.Thurlow@Sun.COM /* LINTED pointer alignment */
415*8610SRobert.Thurlow@Sun.COM size -= dp->d_reclen, dp = nextdp(dp)) {
4160Sstevel@tonic-gate if (dp->d_reclen == 0 /* || DIRSIZ(dp) > dp->d_reclen */)
4170Sstevel@tonic-gate return (FALSE);
4180Sstevel@tonic-gate if (dp->d_ino == 0)
4190Sstevel@tonic-gate continue;
4200Sstevel@tonic-gate name = dp->d_name;
4210Sstevel@tonic-gate namlen = (uint_t)strlen(name);
4220Sstevel@tonic-gate ino = (uint_t)dp->d_ino;
4230Sstevel@tonic-gate off = (uint_t)dp->d_off;
4240Sstevel@tonic-gate entrysz = (1 + 1 + 1 + 1) * BYTES_PER_XDR_UNIT +
4250Sstevel@tonic-gate roundup(namlen, BYTES_PER_XDR_UNIT);
4260Sstevel@tonic-gate tofit = entrysz + 2 * BYTES_PER_XDR_UNIT;
4270Sstevel@tonic-gate if (bufsize + tofit > reqsize) {
4280Sstevel@tonic-gate rddir->rddir_eof = FALSE;
4290Sstevel@tonic-gate break;
4300Sstevel@tonic-gate }
4310Sstevel@tonic-gate if (!xdr_bool(xdrs, &true) ||
4320Sstevel@tonic-gate !xdr_u_int(xdrs, &ino) ||
4330Sstevel@tonic-gate !xdr_bytes(xdrs, &name, &namlen, AUTOFS_MAXPATHLEN) ||
4340Sstevel@tonic-gate !xdr_u_int(xdrs, &off)) {
4350Sstevel@tonic-gate return (FALSE);
4360Sstevel@tonic-gate }
4370Sstevel@tonic-gate bufsize += entrysz;
4380Sstevel@tonic-gate }
4390Sstevel@tonic-gate if (!xdr_bool(xdrs, &false))
4400Sstevel@tonic-gate return (FALSE);
4410Sstevel@tonic-gate if (!xdr_bool(xdrs, &rddir->rddir_eof))
4420Sstevel@tonic-gate return (FALSE);
4430Sstevel@tonic-gate return (TRUE);
4440Sstevel@tonic-gate }
4450Sstevel@tonic-gate
4460Sstevel@tonic-gate
4470Sstevel@tonic-gate /*
4480Sstevel@tonic-gate * DECODE ONLY
4490Sstevel@tonic-gate */
4500Sstevel@tonic-gate bool_t
xdr_autofs_getrddirres(XDR * xdrs,struct autofsrddir * rddir)4510Sstevel@tonic-gate xdr_autofs_getrddirres(XDR *xdrs, struct autofsrddir *rddir)
4520Sstevel@tonic-gate {
4530Sstevel@tonic-gate struct dirent64 *dp;
4540Sstevel@tonic-gate uint_t namlen;
4550Sstevel@tonic-gate int size;
4560Sstevel@tonic-gate bool_t valid;
4570Sstevel@tonic-gate uint_t offset;
4580Sstevel@tonic-gate uint_t fileid;
4590Sstevel@tonic-gate
4600Sstevel@tonic-gate offset = (uint_t)-1;
4610Sstevel@tonic-gate
4620Sstevel@tonic-gate size = rddir->rddir_size;
4630Sstevel@tonic-gate dp = rddir->rddir_entries;
4640Sstevel@tonic-gate for (;;) {
4650Sstevel@tonic-gate if (!xdr_bool(xdrs, &valid))
4660Sstevel@tonic-gate return (FALSE);
4670Sstevel@tonic-gate if (!valid)
4680Sstevel@tonic-gate break;
4690Sstevel@tonic-gate if (!xdr_u_int(xdrs, &fileid) ||
4700Sstevel@tonic-gate !xdr_u_int(xdrs, &namlen))
4710Sstevel@tonic-gate return (FALSE);
4720Sstevel@tonic-gate if (DIRENT64_RECLEN(namlen) > size) {
4730Sstevel@tonic-gate rddir->rddir_eof = FALSE;
4740Sstevel@tonic-gate goto bufovflw;
4750Sstevel@tonic-gate }
4760Sstevel@tonic-gate if (!xdr_opaque(xdrs, dp->d_name, namlen)||
4770Sstevel@tonic-gate !xdr_u_int(xdrs, &offset))
4780Sstevel@tonic-gate return (FALSE);
4790Sstevel@tonic-gate dp->d_ino = fileid;
4800Sstevel@tonic-gate dp->d_reclen = (ushort_t)DIRENT64_RECLEN(namlen);
4810Sstevel@tonic-gate bzero(&dp->d_name[namlen],
4820Sstevel@tonic-gate DIRENT64_NAMELEN(dp->d_reclen) - namlen);
4830Sstevel@tonic-gate dp->d_off = offset;
4840Sstevel@tonic-gate size -= dp->d_reclen;
4850Sstevel@tonic-gate /* LINTED pointer alignment */
4860Sstevel@tonic-gate dp = nextdp(dp);
4870Sstevel@tonic-gate }
4880Sstevel@tonic-gate if (!xdr_bool(xdrs, &rddir->rddir_eof))
4890Sstevel@tonic-gate return (FALSE);
4900Sstevel@tonic-gate bufovflw:
4910Sstevel@tonic-gate rddir->rddir_size = (uint_t)((char *)dp - (char *)rddir->rddir_entries);
4920Sstevel@tonic-gate rddir->rddir_offset = offset;
4930Sstevel@tonic-gate return (TRUE);
4940Sstevel@tonic-gate }
4950Sstevel@tonic-gate
4960Sstevel@tonic-gate bool_t
xdr_autofs_rddirres(XDR * xdrs,autofs_rddirres * objp)4970Sstevel@tonic-gate xdr_autofs_rddirres(XDR *xdrs, autofs_rddirres *objp)
4980Sstevel@tonic-gate {
4990Sstevel@tonic-gate if (!xdr_enum(xdrs, (enum_t *)&objp->rd_status))
5000Sstevel@tonic-gate return (FALSE);
5010Sstevel@tonic-gate if (objp->rd_status != AUTOFS_OK)
5020Sstevel@tonic-gate return (TRUE);
5030Sstevel@tonic-gate if (xdrs->x_op == XDR_ENCODE)
5040Sstevel@tonic-gate return (xdr_autofs_putrddirres(xdrs,
5050Sstevel@tonic-gate (struct autofsrddir *)&objp->rd_rddir, objp->rd_bufsize));
5060Sstevel@tonic-gate else if (xdrs->x_op == XDR_DECODE)
5070Sstevel@tonic-gate return (xdr_autofs_getrddirres(xdrs,
5080Sstevel@tonic-gate (struct autofsrddir *)&objp->rd_rddir));
5090Sstevel@tonic-gate return (FALSE);
5100Sstevel@tonic-gate }
511