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 /* 22*24101b26SRobert Thurlow * Copyright 2008 Sun Microsystems, Inc. All rights reserved. 237c478bd9Sstevel@tonic-gate * Use is subject to license terms. 247c478bd9Sstevel@tonic-gate */ 257c478bd9Sstevel@tonic-gate 267c478bd9Sstevel@tonic-gate /* 277c478bd9Sstevel@tonic-gate * This file can not be automatically generated by rpcgen from 287c478bd9Sstevel@tonic-gate * autofs_prot.x because of the xdr routines that provide readdir 297c478bd9Sstevel@tonic-gate * support, its own implementation of xdr_autofs_netbuf(). rpcgen will 307c478bd9Sstevel@tonic-gate * also generate xdr routines with recursion which should not be used 317c478bd9Sstevel@tonic-gate * in the kernel. 327c478bd9Sstevel@tonic-gate */ 337c478bd9Sstevel@tonic-gate 347c478bd9Sstevel@tonic-gate #include <sys/param.h> 357c478bd9Sstevel@tonic-gate #include <sys/kmem.h> 367c478bd9Sstevel@tonic-gate #include <sys/errno.h> 377c478bd9Sstevel@tonic-gate #include <sys/proc.h> 387c478bd9Sstevel@tonic-gate #include <sys/vfs.h> 397c478bd9Sstevel@tonic-gate #include <sys/vnode.h> 407c478bd9Sstevel@tonic-gate #include <sys/pathname.h> 417c478bd9Sstevel@tonic-gate #include <sys/cred.h> 427c478bd9Sstevel@tonic-gate #include <sys/mount.h> 437c478bd9Sstevel@tonic-gate #include <sys/cmn_err.h> 447c478bd9Sstevel@tonic-gate #include <sys/debug.h> 457c478bd9Sstevel@tonic-gate #include <sys/systm.h> 467c478bd9Sstevel@tonic-gate #include <rpc/types.h> 477c478bd9Sstevel@tonic-gate #include <rpc/xdr.h> 487c478bd9Sstevel@tonic-gate #include <rpc/auth.h> 497c478bd9Sstevel@tonic-gate #include <rpc/clnt.h> 507c478bd9Sstevel@tonic-gate #include <sys/ticotsord.h> 517c478bd9Sstevel@tonic-gate #include <sys/dirent.h> 5239d3e169Sevanl #include <sys/sysmacros.h> 537c478bd9Sstevel@tonic-gate #include <fs/fs_subr.h> 547c478bd9Sstevel@tonic-gate #include <sys/fs/autofs.h> 557c478bd9Sstevel@tonic-gate 567c478bd9Sstevel@tonic-gate bool_t xdr_autofs_netbuf(XDR *, struct netbuf *); 577c478bd9Sstevel@tonic-gate bool_t xdr_mounta(XDR *, struct mounta *); 587c478bd9Sstevel@tonic-gate 597c478bd9Sstevel@tonic-gate bool_t 607c478bd9Sstevel@tonic-gate xdr_umntrequest(XDR *xdrs, umntrequest *objp) 617c478bd9Sstevel@tonic-gate { 627c478bd9Sstevel@tonic-gate bool_t more_data; 637c478bd9Sstevel@tonic-gate 647c478bd9Sstevel@tonic-gate ASSERT(xdrs->x_op == XDR_ENCODE); 657c478bd9Sstevel@tonic-gate 667c478bd9Sstevel@tonic-gate for (; objp != NULL; objp = objp->next) { 677c478bd9Sstevel@tonic-gate if (!xdr_bool_t(xdrs, &objp->isdirect)) 687c478bd9Sstevel@tonic-gate return (FALSE); 697c478bd9Sstevel@tonic-gate if (!xdr_string(xdrs, &objp->mntresource, AUTOFS_MAXPATHLEN)) 707c478bd9Sstevel@tonic-gate return (FALSE); 717c478bd9Sstevel@tonic-gate if (!xdr_string(xdrs, &objp->mntpnt, AUTOFS_MAXPATHLEN)) 727c478bd9Sstevel@tonic-gate return (FALSE); 737c478bd9Sstevel@tonic-gate if (!xdr_string(xdrs, &objp->fstype, AUTOFS_MAXCOMPONENTLEN)) 747c478bd9Sstevel@tonic-gate return (FALSE); 757c478bd9Sstevel@tonic-gate if (!xdr_string(xdrs, &objp->mntopts, AUTOFS_MAXOPTSLEN)) 767c478bd9Sstevel@tonic-gate return (FALSE); 777c478bd9Sstevel@tonic-gate 787c478bd9Sstevel@tonic-gate if (objp->next != NULL) 797c478bd9Sstevel@tonic-gate more_data = TRUE; 807c478bd9Sstevel@tonic-gate else 817c478bd9Sstevel@tonic-gate more_data = FALSE; 827c478bd9Sstevel@tonic-gate 837c478bd9Sstevel@tonic-gate if (!xdr_bool(xdrs, &more_data)) 847c478bd9Sstevel@tonic-gate return (FALSE); 857c478bd9Sstevel@tonic-gate } 867c478bd9Sstevel@tonic-gate return (TRUE); 877c478bd9Sstevel@tonic-gate } 887c478bd9Sstevel@tonic-gate 897c478bd9Sstevel@tonic-gate bool_t 907c478bd9Sstevel@tonic-gate xdr_umntres(XDR *xdrs, umntres *objp) 917c478bd9Sstevel@tonic-gate { 927c478bd9Sstevel@tonic-gate return (xdr_int(xdrs, &objp->status)); 937c478bd9Sstevel@tonic-gate } 947c478bd9Sstevel@tonic-gate 957c478bd9Sstevel@tonic-gate bool_t 967c478bd9Sstevel@tonic-gate xdr_autofs_stat(XDR *xdrs, autofs_stat *objp) 977c478bd9Sstevel@tonic-gate { 987c478bd9Sstevel@tonic-gate if (!xdr_enum(xdrs, (enum_t *)objp)) 997c478bd9Sstevel@tonic-gate return (FALSE); 1007c478bd9Sstevel@tonic-gate return (TRUE); 1017c478bd9Sstevel@tonic-gate } 1027c478bd9Sstevel@tonic-gate 1037c478bd9Sstevel@tonic-gate bool_t 1047c478bd9Sstevel@tonic-gate xdr_autofs_action(XDR *xdrs, autofs_action *objp) 1057c478bd9Sstevel@tonic-gate { 1067c478bd9Sstevel@tonic-gate if (!xdr_enum(xdrs, (enum_t *)objp)) 1077c478bd9Sstevel@tonic-gate return (FALSE); 1087c478bd9Sstevel@tonic-gate return (TRUE); 1097c478bd9Sstevel@tonic-gate } 1107c478bd9Sstevel@tonic-gate 1117c478bd9Sstevel@tonic-gate bool_t 1127c478bd9Sstevel@tonic-gate xdr_linka(XDR *xdrs, linka *objp) 1137c478bd9Sstevel@tonic-gate { 1147c478bd9Sstevel@tonic-gate if (!xdr_string(xdrs, &objp->dir, AUTOFS_MAXPATHLEN)) 1157c478bd9Sstevel@tonic-gate return (FALSE); 1167c478bd9Sstevel@tonic-gate if (!xdr_string(xdrs, &objp->link, AUTOFS_MAXPATHLEN)) 1177c478bd9Sstevel@tonic-gate return (FALSE); 1187c478bd9Sstevel@tonic-gate return (TRUE); 1197c478bd9Sstevel@tonic-gate } 1207c478bd9Sstevel@tonic-gate 1217c478bd9Sstevel@tonic-gate bool_t 1227c478bd9Sstevel@tonic-gate xdr_autofs_args(XDR *xdrs, autofs_args *objp) 1237c478bd9Sstevel@tonic-gate { 1247c478bd9Sstevel@tonic-gate if (!xdr_autofs_netbuf(xdrs, &objp->addr)) 1257c478bd9Sstevel@tonic-gate return (FALSE); 1267c478bd9Sstevel@tonic-gate if (!xdr_string(xdrs, &objp->path, AUTOFS_MAXPATHLEN)) 1277c478bd9Sstevel@tonic-gate return (FALSE); 1287c478bd9Sstevel@tonic-gate if (!xdr_string(xdrs, &objp->opts, AUTOFS_MAXOPTSLEN)) 1297c478bd9Sstevel@tonic-gate return (FALSE); 1307c478bd9Sstevel@tonic-gate if (!xdr_string(xdrs, &objp->map, AUTOFS_MAXPATHLEN)) 1317c478bd9Sstevel@tonic-gate return (FALSE); 1327c478bd9Sstevel@tonic-gate if (!xdr_string(xdrs, &objp->subdir, AUTOFS_MAXPATHLEN)) 1337c478bd9Sstevel@tonic-gate return (FALSE); 1347c478bd9Sstevel@tonic-gate if (!xdr_string(xdrs, &objp->key, AUTOFS_MAXCOMPONENTLEN)) 1357c478bd9Sstevel@tonic-gate return (FALSE); 1367c478bd9Sstevel@tonic-gate if (!xdr_int(xdrs, &objp->mount_to)) 1377c478bd9Sstevel@tonic-gate return (FALSE); 1387c478bd9Sstevel@tonic-gate if (!xdr_int(xdrs, &objp->rpc_to)) 1397c478bd9Sstevel@tonic-gate return (FALSE); 1407c478bd9Sstevel@tonic-gate if (!xdr_int(xdrs, &objp->direct)) 1417c478bd9Sstevel@tonic-gate return (FALSE); 1427c478bd9Sstevel@tonic-gate return (TRUE); 1437c478bd9Sstevel@tonic-gate } 1447c478bd9Sstevel@tonic-gate 1457c478bd9Sstevel@tonic-gate bool_t 1467c478bd9Sstevel@tonic-gate xdr_action_list_entry(XDR *xdrs, action_list_entry *objp) 1477c478bd9Sstevel@tonic-gate { 1487c478bd9Sstevel@tonic-gate if (!xdr_autofs_action(xdrs, &objp->action)) 1497c478bd9Sstevel@tonic-gate return (FALSE); 1507c478bd9Sstevel@tonic-gate switch (objp->action) { 1517c478bd9Sstevel@tonic-gate case AUTOFS_MOUNT_RQ: 1527c478bd9Sstevel@tonic-gate if (!xdr_mounta(xdrs, &objp->action_list_entry_u.mounta)) 1537c478bd9Sstevel@tonic-gate return (FALSE); 1547c478bd9Sstevel@tonic-gate break; 1557c478bd9Sstevel@tonic-gate case AUTOFS_LINK_RQ: 1567c478bd9Sstevel@tonic-gate if (!xdr_linka(xdrs, &objp->action_list_entry_u.linka)) 1577c478bd9Sstevel@tonic-gate return (FALSE); 1587c478bd9Sstevel@tonic-gate break; 1597c478bd9Sstevel@tonic-gate default: 1607c478bd9Sstevel@tonic-gate break; 1617c478bd9Sstevel@tonic-gate } 1627c478bd9Sstevel@tonic-gate return (TRUE); 1637c478bd9Sstevel@tonic-gate } 1647c478bd9Sstevel@tonic-gate 1657c478bd9Sstevel@tonic-gate bool_t 1667c478bd9Sstevel@tonic-gate xdr_action_list(XDR *xdrs, action_list *objp) 1677c478bd9Sstevel@tonic-gate { 1687c478bd9Sstevel@tonic-gate bool_t more_data = TRUE; 1697c478bd9Sstevel@tonic-gate bool_t status = TRUE; 170*24101b26SRobert Thurlow action_list *p, *last; 1717c478bd9Sstevel@tonic-gate 1727c478bd9Sstevel@tonic-gate ASSERT((xdrs->x_op == XDR_DECODE) || (xdrs->x_op == XDR_FREE)); 1737c478bd9Sstevel@tonic-gate 1747c478bd9Sstevel@tonic-gate more_data = (objp != NULL); 1757c478bd9Sstevel@tonic-gate p = objp; 1767c478bd9Sstevel@tonic-gate 177*24101b26SRobert Thurlow if (xdrs->x_op == XDR_FREE) { 178*24101b26SRobert Thurlow while (p != NULL) { 179*24101b26SRobert Thurlow if (!xdr_action_list_entry(xdrs, &p->action)) 180*24101b26SRobert Thurlow cmn_err(CE_WARN, "xdr_action_list: " 181*24101b26SRobert Thurlow "action_list_entry free failed %p\n", 182*24101b26SRobert Thurlow (void *)&p->action); 183*24101b26SRobert Thurlow last = p; 184*24101b26SRobert Thurlow p = p->next; 185*24101b26SRobert Thurlow kmem_free(last, sizeof (*last)); 186*24101b26SRobert Thurlow } 187*24101b26SRobert Thurlow return (status); 188*24101b26SRobert Thurlow } 1897c478bd9Sstevel@tonic-gate 1907c478bd9Sstevel@tonic-gate while (more_data) { 191*24101b26SRobert Thurlow if (!xdr_action_list_entry(xdrs, &p->action)) { 192*24101b26SRobert Thurlow status = FALSE; 193*24101b26SRobert Thurlow break; 194*24101b26SRobert Thurlow } 1957c478bd9Sstevel@tonic-gate 196*24101b26SRobert Thurlow if (!xdr_bool(xdrs, &more_data)) { 197*24101b26SRobert Thurlow status = FALSE; 198*24101b26SRobert Thurlow break; 199*24101b26SRobert Thurlow } 2007c478bd9Sstevel@tonic-gate 2017c478bd9Sstevel@tonic-gate if (more_data) { 2027c478bd9Sstevel@tonic-gate p->next = kmem_zalloc(sizeof (action_list), KM_SLEEP); 2037c478bd9Sstevel@tonic-gate p = p->next; 2047c478bd9Sstevel@tonic-gate if (p == NULL) { 2057c478bd9Sstevel@tonic-gate status = FALSE; 206*24101b26SRobert Thurlow break; 2077c478bd9Sstevel@tonic-gate } 2087c478bd9Sstevel@tonic-gate } else 2097c478bd9Sstevel@tonic-gate p->next = NULL; 2107c478bd9Sstevel@tonic-gate } 2117c478bd9Sstevel@tonic-gate return (status); 2127c478bd9Sstevel@tonic-gate } 2137c478bd9Sstevel@tonic-gate 2147c478bd9Sstevel@tonic-gate bool_t 2157c478bd9Sstevel@tonic-gate xdr_autofs_netbuf(XDR *xdrs, struct netbuf *objp) 2167c478bd9Sstevel@tonic-gate { 2177c478bd9Sstevel@tonic-gate bool_t dummy; 2187c478bd9Sstevel@tonic-gate 2197c478bd9Sstevel@tonic-gate if (!xdr_u_int(xdrs, (uint_t *)&objp->maxlen)) 2207c478bd9Sstevel@tonic-gate return (FALSE); 2217c478bd9Sstevel@tonic-gate dummy = xdr_bytes(xdrs, (char **)&(objp->buf), 2227c478bd9Sstevel@tonic-gate (uint_t *)&(objp->len), objp->maxlen); 2237c478bd9Sstevel@tonic-gate return (dummy); 2247c478bd9Sstevel@tonic-gate } 2257c478bd9Sstevel@tonic-gate 2267c478bd9Sstevel@tonic-gate bool_t 2277c478bd9Sstevel@tonic-gate xdr_mounta(XDR *xdrs, struct mounta *objp) 2287c478bd9Sstevel@tonic-gate { 2297c478bd9Sstevel@tonic-gate if (!xdr_string(xdrs, &objp->spec, AUTOFS_MAXPATHLEN)) 2307c478bd9Sstevel@tonic-gate return (FALSE); 2317c478bd9Sstevel@tonic-gate if (!xdr_string(xdrs, &objp->dir, AUTOFS_MAXPATHLEN)) 2327c478bd9Sstevel@tonic-gate return (FALSE); 2337c478bd9Sstevel@tonic-gate if (!xdr_int(xdrs, &objp->flags)) 2347c478bd9Sstevel@tonic-gate return (FALSE); 2357c478bd9Sstevel@tonic-gate if (!xdr_string(xdrs, &objp->fstype, AUTOFS_MAXCOMPONENTLEN)) 2367c478bd9Sstevel@tonic-gate return (FALSE); 2375e1e04ceSdm120769 if (!xdr_pointer(xdrs, (char **)&objp->dataptr, sizeof (autofs_args), 2385e1e04ceSdm120769 (xdrproc_t)xdr_autofs_args)) 2395e1e04ceSdm120769 return (FALSE); 2407c478bd9Sstevel@tonic-gate /* 2417c478bd9Sstevel@tonic-gate * The length is the original user-land length, not the 2427c478bd9Sstevel@tonic-gate * length of the native kernel autofs_args structure provided 2437c478bd9Sstevel@tonic-gate * after we decode the xdr buffer. So passing the user's idea of 2447c478bd9Sstevel@tonic-gate * the length is wrong and we need to stuff the length field with 2457c478bd9Sstevel@tonic-gate * the length of the native structure. 2467c478bd9Sstevel@tonic-gate */ 2477c478bd9Sstevel@tonic-gate if (!xdr_int(xdrs, &objp->datalen)) 2487c478bd9Sstevel@tonic-gate return (FALSE); 2497c478bd9Sstevel@tonic-gate if (xdrs->x_op == XDR_DECODE) 2507c478bd9Sstevel@tonic-gate objp->datalen = sizeof (struct autofs_args); 2517c478bd9Sstevel@tonic-gate if (!xdr_string(xdrs, &objp->optptr, AUTOFS_MAXOPTSLEN)) 2527c478bd9Sstevel@tonic-gate return (FALSE); 2537c478bd9Sstevel@tonic-gate if (!xdr_int(xdrs, &objp->optlen)) 2547c478bd9Sstevel@tonic-gate return (FALSE); 2555e1e04ceSdm120769 ASSERT((xdrs->x_op == XDR_DECODE) || (xdrs->x_op == XDR_FREE)); 2567c478bd9Sstevel@tonic-gate return (TRUE); 2577c478bd9Sstevel@tonic-gate } 2587c478bd9Sstevel@tonic-gate 2597c478bd9Sstevel@tonic-gate bool_t 2607c478bd9Sstevel@tonic-gate xdr_autofs_res(XDR *xdrs, autofs_res *objp) 2617c478bd9Sstevel@tonic-gate { 2627c478bd9Sstevel@tonic-gate if (!xdr_enum(xdrs, (enum_t *)objp)) 2637c478bd9Sstevel@tonic-gate return (FALSE); 2647c478bd9Sstevel@tonic-gate return (TRUE); 2657c478bd9Sstevel@tonic-gate } 2667c478bd9Sstevel@tonic-gate 2677c478bd9Sstevel@tonic-gate bool_t 2687c478bd9Sstevel@tonic-gate xdr_autofs_lookupargs(XDR *xdrs, autofs_lookupargs *objp) 2697c478bd9Sstevel@tonic-gate { 2707c478bd9Sstevel@tonic-gate if (!xdr_string(xdrs, &objp->map, AUTOFS_MAXPATHLEN)) 2717c478bd9Sstevel@tonic-gate return (FALSE); 2727c478bd9Sstevel@tonic-gate if (!xdr_string(xdrs, &objp->path, AUTOFS_MAXPATHLEN)) 2737c478bd9Sstevel@tonic-gate return (FALSE); 2747c478bd9Sstevel@tonic-gate if (!xdr_string(xdrs, &objp->name, AUTOFS_MAXCOMPONENTLEN)) 2757c478bd9Sstevel@tonic-gate return (FALSE); 2767c478bd9Sstevel@tonic-gate if (!xdr_string(xdrs, &objp->subdir, AUTOFS_MAXPATHLEN)) 2777c478bd9Sstevel@tonic-gate return (FALSE); 2787c478bd9Sstevel@tonic-gate if (!xdr_string(xdrs, &objp->opts, AUTOFS_MAXOPTSLEN)) 2797c478bd9Sstevel@tonic-gate return (FALSE); 2807c478bd9Sstevel@tonic-gate if (!xdr_bool_t(xdrs, &objp->isdirect)) 2817c478bd9Sstevel@tonic-gate return (FALSE); 2823bfb48feSsemery if (!xdr_u_int(xdrs, (uint_t *)&objp->uid)) 2833bfb48feSsemery return (FALSE); 2847c478bd9Sstevel@tonic-gate return (TRUE); 2857c478bd9Sstevel@tonic-gate } 2867c478bd9Sstevel@tonic-gate 2877c478bd9Sstevel@tonic-gate bool_t 2887c478bd9Sstevel@tonic-gate xdr_mount_result_type(XDR *xdrs, mount_result_type *objp) 2897c478bd9Sstevel@tonic-gate { 2907c478bd9Sstevel@tonic-gate if (!xdr_autofs_stat(xdrs, &objp->status)) 2917c478bd9Sstevel@tonic-gate return (FALSE); 2927c478bd9Sstevel@tonic-gate switch (objp->status) { 2937c478bd9Sstevel@tonic-gate case AUTOFS_ACTION: 2947c478bd9Sstevel@tonic-gate if (!xdr_pointer(xdrs, 2957c478bd9Sstevel@tonic-gate (char **)&objp->mount_result_type_u.list, 2967c478bd9Sstevel@tonic-gate sizeof (action_list), (xdrproc_t)xdr_action_list)) 2977c478bd9Sstevel@tonic-gate return (FALSE); 2987c478bd9Sstevel@tonic-gate break; 2997c478bd9Sstevel@tonic-gate case AUTOFS_DONE: 3007c478bd9Sstevel@tonic-gate if (!xdr_int(xdrs, &objp->mount_result_type_u.error)) 3017c478bd9Sstevel@tonic-gate return (FALSE); 3027c478bd9Sstevel@tonic-gate break; 3037c478bd9Sstevel@tonic-gate } 3047c478bd9Sstevel@tonic-gate return (TRUE); 3057c478bd9Sstevel@tonic-gate } 3067c478bd9Sstevel@tonic-gate 3077c478bd9Sstevel@tonic-gate bool_t 3087c478bd9Sstevel@tonic-gate xdr_autofs_mountres(XDR *xdrs, autofs_mountres *objp) 3097c478bd9Sstevel@tonic-gate { 3107c478bd9Sstevel@tonic-gate if (!xdr_mount_result_type(xdrs, &objp->mr_type)) 3117c478bd9Sstevel@tonic-gate return (FALSE); 3127c478bd9Sstevel@tonic-gate if (!xdr_int(xdrs, &objp->mr_verbose)) 3137c478bd9Sstevel@tonic-gate return (FALSE); 3147c478bd9Sstevel@tonic-gate return (TRUE); 3157c478bd9Sstevel@tonic-gate } 3167c478bd9Sstevel@tonic-gate 3177c478bd9Sstevel@tonic-gate bool_t 3187c478bd9Sstevel@tonic-gate xdr_lookup_result_type(XDR *xdrs, lookup_result_type *objp) 3197c478bd9Sstevel@tonic-gate { 3207c478bd9Sstevel@tonic-gate if (!xdr_autofs_action(xdrs, &objp->action)) 3217c478bd9Sstevel@tonic-gate return (FALSE); 3227c478bd9Sstevel@tonic-gate switch (objp->action) { 3237c478bd9Sstevel@tonic-gate case AUTOFS_LINK_RQ: 3247c478bd9Sstevel@tonic-gate if (!xdr_linka(xdrs, &objp->lookup_result_type_u.lt_linka)) 3257c478bd9Sstevel@tonic-gate return (FALSE); 3267c478bd9Sstevel@tonic-gate break; 3277c478bd9Sstevel@tonic-gate default: 3287c478bd9Sstevel@tonic-gate break; 3297c478bd9Sstevel@tonic-gate } 3307c478bd9Sstevel@tonic-gate return (TRUE); 3317c478bd9Sstevel@tonic-gate } 3327c478bd9Sstevel@tonic-gate 3337c478bd9Sstevel@tonic-gate bool_t 3347c478bd9Sstevel@tonic-gate xdr_autofs_lookupres(XDR *xdrs, autofs_lookupres *objp) 3357c478bd9Sstevel@tonic-gate { 3367c478bd9Sstevel@tonic-gate if (!xdr_autofs_res(xdrs, &objp->lu_res)) 3377c478bd9Sstevel@tonic-gate return (FALSE); 3387c478bd9Sstevel@tonic-gate if (!xdr_lookup_result_type(xdrs, &objp->lu_type)) 3397c478bd9Sstevel@tonic-gate return (FALSE); 3407c478bd9Sstevel@tonic-gate if (!xdr_int(xdrs, &objp->lu_verbose)) 3417c478bd9Sstevel@tonic-gate return (FALSE); 3427c478bd9Sstevel@tonic-gate return (TRUE); 3437c478bd9Sstevel@tonic-gate } 3447c478bd9Sstevel@tonic-gate 3457c478bd9Sstevel@tonic-gate bool_t 3467c478bd9Sstevel@tonic-gate xdr_autofs_rddirargs(XDR *xdrs, autofs_rddirargs *objp) 3477c478bd9Sstevel@tonic-gate { 3487c478bd9Sstevel@tonic-gate if (!xdr_string(xdrs, &objp->rda_map, AUTOFS_MAXPATHLEN)) 3497c478bd9Sstevel@tonic-gate return (FALSE); 3507c478bd9Sstevel@tonic-gate if (!xdr_u_int(xdrs, &objp->rda_offset)) 3517c478bd9Sstevel@tonic-gate return (FALSE); 3527c478bd9Sstevel@tonic-gate if (!xdr_u_int(xdrs, &objp->rda_count)) 3537c478bd9Sstevel@tonic-gate return (FALSE); 3543bfb48feSsemery if (!xdr_u_int(xdrs, (uint_t *)&objp->uid)) 3553bfb48feSsemery return (FALSE); 3567c478bd9Sstevel@tonic-gate return (TRUE); 3577c478bd9Sstevel@tonic-gate } 3587c478bd9Sstevel@tonic-gate 3597c478bd9Sstevel@tonic-gate /* 3607c478bd9Sstevel@tonic-gate * Directory read reply: 3617c478bd9Sstevel@tonic-gate * union (enum autofs_res) { 3627c478bd9Sstevel@tonic-gate * AUTOFS_OK: entlist; 3637c478bd9Sstevel@tonic-gate * boolean eof; 3647c478bd9Sstevel@tonic-gate * default: 3657c478bd9Sstevel@tonic-gate * } 3667c478bd9Sstevel@tonic-gate * 3677c478bd9Sstevel@tonic-gate * Directory entries 3687c478bd9Sstevel@tonic-gate * struct direct { 3697c478bd9Sstevel@tonic-gate * off_t d_off; * offset of next entry * 3707c478bd9Sstevel@tonic-gate * u_long d_fileno; * inode number of entry * 3717c478bd9Sstevel@tonic-gate * ushort_t d_reclen; * length of this record * 3727c478bd9Sstevel@tonic-gate * ushort_t d_namlen; * length of string in d_name * 3737c478bd9Sstevel@tonic-gate * char d_name[MAXNAMLEN + 1]; * name no longer than this * 3747c478bd9Sstevel@tonic-gate * }; 3757c478bd9Sstevel@tonic-gate * are on the wire as: 3767c478bd9Sstevel@tonic-gate * union entlist (boolean valid) { 3777c478bd9Sstevel@tonic-gate * TRUE: struct otw_dirent; 3787c478bd9Sstevel@tonic-gate * uint_t nxtoffset; 3797c478bd9Sstevel@tonic-gate * union entlist; 3807c478bd9Sstevel@tonic-gate * FALSE: 3817c478bd9Sstevel@tonic-gate * } 3827c478bd9Sstevel@tonic-gate * where otw_dirent is: 3837c478bd9Sstevel@tonic-gate * struct dirent { 3847c478bd9Sstevel@tonic-gate * uint_t de_fid; 3857c478bd9Sstevel@tonic-gate * string de_name<AUTOFS_MAXPATHLEN>; 3867c478bd9Sstevel@tonic-gate * } 3877c478bd9Sstevel@tonic-gate */ 3887c478bd9Sstevel@tonic-gate 3897c478bd9Sstevel@tonic-gate #ifdef nextdp 3907c478bd9Sstevel@tonic-gate #undef nextdp 3917c478bd9Sstevel@tonic-gate #endif 3927c478bd9Sstevel@tonic-gate #define nextdp(dp) ((struct dirent64 *)((char *)(dp) + (dp)->d_reclen)) 3937c478bd9Sstevel@tonic-gate 3947c478bd9Sstevel@tonic-gate /* 3957c478bd9Sstevel@tonic-gate * ENCODE ONLY 3967c478bd9Sstevel@tonic-gate */ 3977c478bd9Sstevel@tonic-gate bool_t 3987c478bd9Sstevel@tonic-gate xdr_autofs_putrddirres(XDR *xdrs, struct autofsrddir *rddir, uint_t reqsize) 3997c478bd9Sstevel@tonic-gate { 4007c478bd9Sstevel@tonic-gate struct dirent64 *dp; 4017c478bd9Sstevel@tonic-gate char *name; 4027c478bd9Sstevel@tonic-gate int size; 4037c478bd9Sstevel@tonic-gate uint_t namlen; 4047c478bd9Sstevel@tonic-gate bool_t true = TRUE; 4057c478bd9Sstevel@tonic-gate bool_t false = FALSE; 4067c478bd9Sstevel@tonic-gate int entrysz; 4077c478bd9Sstevel@tonic-gate int tofit; 4087c478bd9Sstevel@tonic-gate int bufsize; 4097c478bd9Sstevel@tonic-gate uint_t ino, off; 4107c478bd9Sstevel@tonic-gate 4117c478bd9Sstevel@tonic-gate bufsize = 1 * BYTES_PER_XDR_UNIT; 4127c478bd9Sstevel@tonic-gate for (size = rddir->rddir_size, dp = rddir->rddir_entries; 4137c478bd9Sstevel@tonic-gate size > 0; 4147c478bd9Sstevel@tonic-gate /* LINTED pointer alignment */ 4157c478bd9Sstevel@tonic-gate size -= dp->d_reclen, dp = nextdp(dp)) { 4167c478bd9Sstevel@tonic-gate if (dp->d_reclen == 0 /* || DIRSIZ(dp) > dp->d_reclen */) 4177c478bd9Sstevel@tonic-gate return (FALSE); 4187c478bd9Sstevel@tonic-gate if (dp->d_ino == 0) 4197c478bd9Sstevel@tonic-gate continue; 4207c478bd9Sstevel@tonic-gate name = dp->d_name; 4217c478bd9Sstevel@tonic-gate namlen = (uint_t)strlen(name); 4227c478bd9Sstevel@tonic-gate ino = (uint_t)dp->d_ino; 4237c478bd9Sstevel@tonic-gate off = (uint_t)dp->d_off; 4247c478bd9Sstevel@tonic-gate entrysz = (1 + 1 + 1 + 1) * BYTES_PER_XDR_UNIT + 4257c478bd9Sstevel@tonic-gate roundup(namlen, BYTES_PER_XDR_UNIT); 4267c478bd9Sstevel@tonic-gate tofit = entrysz + 2 * BYTES_PER_XDR_UNIT; 4277c478bd9Sstevel@tonic-gate if (bufsize + tofit > reqsize) { 4287c478bd9Sstevel@tonic-gate rddir->rddir_eof = FALSE; 4297c478bd9Sstevel@tonic-gate break; 4307c478bd9Sstevel@tonic-gate } 4317c478bd9Sstevel@tonic-gate if (!xdr_bool(xdrs, &true) || 4327c478bd9Sstevel@tonic-gate !xdr_u_int(xdrs, &ino) || 4337c478bd9Sstevel@tonic-gate !xdr_bytes(xdrs, &name, &namlen, AUTOFS_MAXPATHLEN) || 4347c478bd9Sstevel@tonic-gate !xdr_u_int(xdrs, &off)) { 4357c478bd9Sstevel@tonic-gate return (FALSE); 4367c478bd9Sstevel@tonic-gate } 4377c478bd9Sstevel@tonic-gate bufsize += entrysz; 4387c478bd9Sstevel@tonic-gate } 4397c478bd9Sstevel@tonic-gate if (!xdr_bool(xdrs, &false)) 4407c478bd9Sstevel@tonic-gate return (FALSE); 4417c478bd9Sstevel@tonic-gate if (!xdr_bool(xdrs, &rddir->rddir_eof)) 4427c478bd9Sstevel@tonic-gate return (FALSE); 4437c478bd9Sstevel@tonic-gate return (TRUE); 4447c478bd9Sstevel@tonic-gate } 4457c478bd9Sstevel@tonic-gate 4467c478bd9Sstevel@tonic-gate 4477c478bd9Sstevel@tonic-gate /* 4487c478bd9Sstevel@tonic-gate * DECODE ONLY 4497c478bd9Sstevel@tonic-gate */ 4507c478bd9Sstevel@tonic-gate bool_t 4517c478bd9Sstevel@tonic-gate xdr_autofs_getrddirres(XDR *xdrs, struct autofsrddir *rddir) 4527c478bd9Sstevel@tonic-gate { 4537c478bd9Sstevel@tonic-gate struct dirent64 *dp; 4547c478bd9Sstevel@tonic-gate uint_t namlen; 4557c478bd9Sstevel@tonic-gate int size; 4567c478bd9Sstevel@tonic-gate bool_t valid; 4577c478bd9Sstevel@tonic-gate uint_t offset; 4587c478bd9Sstevel@tonic-gate uint_t fileid; 4597c478bd9Sstevel@tonic-gate 4607c478bd9Sstevel@tonic-gate offset = (uint_t)-1; 4617c478bd9Sstevel@tonic-gate 4627c478bd9Sstevel@tonic-gate size = rddir->rddir_size; 4637c478bd9Sstevel@tonic-gate dp = rddir->rddir_entries; 4647c478bd9Sstevel@tonic-gate for (;;) { 4657c478bd9Sstevel@tonic-gate if (!xdr_bool(xdrs, &valid)) 4667c478bd9Sstevel@tonic-gate return (FALSE); 4677c478bd9Sstevel@tonic-gate if (!valid) 4687c478bd9Sstevel@tonic-gate break; 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 if (DIRENT64_RECLEN(namlen) > size) { 4737c478bd9Sstevel@tonic-gate rddir->rddir_eof = FALSE; 4747c478bd9Sstevel@tonic-gate goto bufovflw; 4757c478bd9Sstevel@tonic-gate } 4767c478bd9Sstevel@tonic-gate if (!xdr_opaque(xdrs, dp->d_name, namlen)|| 4777c478bd9Sstevel@tonic-gate !xdr_u_int(xdrs, &offset)) 4787c478bd9Sstevel@tonic-gate return (FALSE); 4797c478bd9Sstevel@tonic-gate dp->d_ino = fileid; 4807c478bd9Sstevel@tonic-gate dp->d_reclen = (ushort_t)DIRENT64_RECLEN(namlen); 4817c478bd9Sstevel@tonic-gate bzero(&dp->d_name[namlen], 4827c478bd9Sstevel@tonic-gate DIRENT64_NAMELEN(dp->d_reclen) - namlen); 4837c478bd9Sstevel@tonic-gate dp->d_off = offset; 4847c478bd9Sstevel@tonic-gate size -= dp->d_reclen; 4857c478bd9Sstevel@tonic-gate /* LINTED pointer alignment */ 4867c478bd9Sstevel@tonic-gate dp = nextdp(dp); 4877c478bd9Sstevel@tonic-gate } 4887c478bd9Sstevel@tonic-gate if (!xdr_bool(xdrs, &rddir->rddir_eof)) 4897c478bd9Sstevel@tonic-gate return (FALSE); 4907c478bd9Sstevel@tonic-gate bufovflw: 4917c478bd9Sstevel@tonic-gate rddir->rddir_size = (uint_t)((char *)dp - (char *)rddir->rddir_entries); 4927c478bd9Sstevel@tonic-gate rddir->rddir_offset = offset; 4937c478bd9Sstevel@tonic-gate return (TRUE); 4947c478bd9Sstevel@tonic-gate } 4957c478bd9Sstevel@tonic-gate 4967c478bd9Sstevel@tonic-gate bool_t 4977c478bd9Sstevel@tonic-gate xdr_autofs_rddirres(XDR *xdrs, autofs_rddirres *objp) 4987c478bd9Sstevel@tonic-gate { 4997c478bd9Sstevel@tonic-gate if (!xdr_enum(xdrs, (enum_t *)&objp->rd_status)) 5007c478bd9Sstevel@tonic-gate return (FALSE); 5017c478bd9Sstevel@tonic-gate if (objp->rd_status != AUTOFS_OK) 5027c478bd9Sstevel@tonic-gate return (TRUE); 5037c478bd9Sstevel@tonic-gate if (xdrs->x_op == XDR_ENCODE) 5047c478bd9Sstevel@tonic-gate return (xdr_autofs_putrddirres(xdrs, 5057c478bd9Sstevel@tonic-gate (struct autofsrddir *)&objp->rd_rddir, objp->rd_bufsize)); 5067c478bd9Sstevel@tonic-gate else if (xdrs->x_op == XDR_DECODE) 5077c478bd9Sstevel@tonic-gate return (xdr_autofs_getrddirres(xdrs, 5087c478bd9Sstevel@tonic-gate (struct autofsrddir *)&objp->rd_rddir)); 5097c478bd9Sstevel@tonic-gate return (FALSE); 5107c478bd9Sstevel@tonic-gate } 511