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 527242a7cSthurlow * Common Development and Distribution License (the "License"). 627242a7cSthurlow * 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 /* 22c242f9a0Schunli zhang - Sun Microsystems - Irvine United States * Copyright 2010 Sun Microsystems, Inc. All rights reserved. 230a701b1eSRobert Gordon * Use is subject to license terms. 247c478bd9Sstevel@tonic-gate */ 257c478bd9Sstevel@tonic-gate 267c478bd9Sstevel@tonic-gate /* 277c478bd9Sstevel@tonic-gate * A handcoded version based on the original rpcgen code. 287c478bd9Sstevel@tonic-gate * 297c478bd9Sstevel@tonic-gate * Note: All future NFS4 protocol changes should be added by hand 307c478bd9Sstevel@tonic-gate * to this file. 317c478bd9Sstevel@tonic-gate * 327c478bd9Sstevel@tonic-gate * CAUTION: All protocol changes must also be propagated to: 337c478bd9Sstevel@tonic-gate * usr/src/cmd/cmd-inet/usr.sbin/snoop/nfs4_xdr.c 347c478bd9Sstevel@tonic-gate */ 357c478bd9Sstevel@tonic-gate 367c478bd9Sstevel@tonic-gate #include <sys/types.h> 377c478bd9Sstevel@tonic-gate #include <sys/sunddi.h> 387c478bd9Sstevel@tonic-gate #include <sys/dnlc.h> 397c478bd9Sstevel@tonic-gate #include <nfs/nfs.h> 407c478bd9Sstevel@tonic-gate #include <nfs/nfs4_kprot.h> 417c478bd9Sstevel@tonic-gate #include <nfs/rnode4.h> 427c478bd9Sstevel@tonic-gate #include <nfs/nfs4.h> 437c478bd9Sstevel@tonic-gate #include <nfs/nfs4_clnt.h> 447c478bd9Sstevel@tonic-gate #include <sys/sdt.h> 452f172c55SRobert Thurlow #include <sys/mkdev.h> 467c478bd9Sstevel@tonic-gate #include <rpc/rpc_rdma.h> 472f172c55SRobert Thurlow #include <rpc/xdr.h> 482f172c55SRobert Thurlow 492f172c55SRobert Thurlow #define xdr_dev_t xdr_u_int 502f172c55SRobert Thurlow 512f172c55SRobert Thurlow extern bool_t xdr_netbuf(XDR *, struct netbuf *); 522f172c55SRobert Thurlow extern bool_t xdr_vector(XDR *, char *, const uint_t, const uint_t, 532f172c55SRobert Thurlow const xdrproc_t); 542f172c55SRobert Thurlow bool_t xdr_knetconfig(XDR *, struct knetconfig *); 557c478bd9Sstevel@tonic-gate 567c478bd9Sstevel@tonic-gate bool_t 577c478bd9Sstevel@tonic-gate xdr_bitmap4(XDR *xdrs, bitmap4 *objp) 587c478bd9Sstevel@tonic-gate { 597c478bd9Sstevel@tonic-gate int32_t len, size; 607c478bd9Sstevel@tonic-gate 617c478bd9Sstevel@tonic-gate if (xdrs->x_op == XDR_FREE) 627c478bd9Sstevel@tonic-gate return (TRUE); 637c478bd9Sstevel@tonic-gate 647c478bd9Sstevel@tonic-gate /* 657c478bd9Sstevel@tonic-gate * Simplified bitmap4 processing, always encode from uint64_t 667c478bd9Sstevel@tonic-gate * to 2 uint32_t's, always decode first 2 uint32_t's into a 677c478bd9Sstevel@tonic-gate * uint64_t and ignore all of the rest. 687c478bd9Sstevel@tonic-gate */ 697c478bd9Sstevel@tonic-gate if (xdrs->x_op == XDR_ENCODE) { 707c478bd9Sstevel@tonic-gate len = 2; 717c478bd9Sstevel@tonic-gate 727c478bd9Sstevel@tonic-gate if (!XDR_PUTINT32(xdrs, &len)) 737c478bd9Sstevel@tonic-gate return (FALSE); 747c478bd9Sstevel@tonic-gate 757c478bd9Sstevel@tonic-gate #if defined(_LITTLE_ENDIAN) 767c478bd9Sstevel@tonic-gate if (XDR_PUTINT32(xdrs, (int32_t *)((char *)objp + 770a701b1eSRobert Gordon BYTES_PER_XDR_UNIT)) == TRUE) { 787c478bd9Sstevel@tonic-gate return (XDR_PUTINT32(xdrs, (int32_t *)objp)); 797c478bd9Sstevel@tonic-gate } 807c478bd9Sstevel@tonic-gate #elif defined(_BIG_ENDIAN) 817c478bd9Sstevel@tonic-gate if (XDR_PUTINT32(xdrs, (int32_t *)objp) == TRUE) { 827c478bd9Sstevel@tonic-gate return (XDR_PUTINT32(xdrs, (int32_t *)((char *)objp + 830a701b1eSRobert Gordon BYTES_PER_XDR_UNIT))); 847c478bd9Sstevel@tonic-gate } 857c478bd9Sstevel@tonic-gate #endif 867c478bd9Sstevel@tonic-gate return (FALSE); 877c478bd9Sstevel@tonic-gate } 887c478bd9Sstevel@tonic-gate 897c478bd9Sstevel@tonic-gate if (!XDR_GETINT32(xdrs, &len)) 907c478bd9Sstevel@tonic-gate return (FALSE); 917c478bd9Sstevel@tonic-gate 927c478bd9Sstevel@tonic-gate /* 937c478bd9Sstevel@tonic-gate * Common fast DECODE cases 947c478bd9Sstevel@tonic-gate */ 957c478bd9Sstevel@tonic-gate if (len == 2) { 967c478bd9Sstevel@tonic-gate #if defined(_LITTLE_ENDIAN) 977c478bd9Sstevel@tonic-gate if (XDR_GETINT32(xdrs, (int32_t *)((char *)objp + 980a701b1eSRobert Gordon BYTES_PER_XDR_UNIT)) == TRUE) { 997c478bd9Sstevel@tonic-gate return (XDR_GETINT32(xdrs, (int32_t *)objp)); 1007c478bd9Sstevel@tonic-gate } 1017c478bd9Sstevel@tonic-gate #elif defined(_BIG_ENDIAN) 1027c478bd9Sstevel@tonic-gate if (XDR_GETINT32(xdrs, (int32_t *)objp) == TRUE) { 1037c478bd9Sstevel@tonic-gate return (XDR_GETINT32(xdrs, (int32_t *)((char *)objp + 1040a701b1eSRobert Gordon BYTES_PER_XDR_UNIT))); 1057c478bd9Sstevel@tonic-gate } 1067c478bd9Sstevel@tonic-gate #endif 1077c478bd9Sstevel@tonic-gate return (FALSE); 1087c478bd9Sstevel@tonic-gate } 1097c478bd9Sstevel@tonic-gate 1107c478bd9Sstevel@tonic-gate *objp = 0; 1117c478bd9Sstevel@tonic-gate if (len == 0) 1127c478bd9Sstevel@tonic-gate return (TRUE); 1137c478bd9Sstevel@tonic-gate 1147c478bd9Sstevel@tonic-gate /* 1157c478bd9Sstevel@tonic-gate * The not so common DECODE cases, len == 1 || len > 2 1167c478bd9Sstevel@tonic-gate */ 1177c478bd9Sstevel@tonic-gate #if defined(_LITTLE_ENDIAN) 1187c478bd9Sstevel@tonic-gate if (!XDR_GETINT32(xdrs, (int32_t *)((char *)objp + BYTES_PER_XDR_UNIT))) 1197c478bd9Sstevel@tonic-gate return (FALSE); 1207c478bd9Sstevel@tonic-gate if (--len == 0) 1217c478bd9Sstevel@tonic-gate return (TRUE); 1227c478bd9Sstevel@tonic-gate if (!XDR_GETINT32(xdrs, (int32_t *)objp)) 1237c478bd9Sstevel@tonic-gate return (FALSE); 1247c478bd9Sstevel@tonic-gate #elif defined(_BIG_ENDIAN) 1257c478bd9Sstevel@tonic-gate if (!XDR_GETINT32(xdrs, (int32_t *)objp)) 1267c478bd9Sstevel@tonic-gate return (FALSE); 1277c478bd9Sstevel@tonic-gate if (--len == 0) 1287c478bd9Sstevel@tonic-gate return (TRUE); 1297c478bd9Sstevel@tonic-gate if (!XDR_GETINT32(xdrs, (int32_t *)((char *)objp + BYTES_PER_XDR_UNIT))) 1307c478bd9Sstevel@tonic-gate return (FALSE); 1317c478bd9Sstevel@tonic-gate #else 1327c478bd9Sstevel@tonic-gate return (FALSE); 1337c478bd9Sstevel@tonic-gate #endif 1347c478bd9Sstevel@tonic-gate 1357c478bd9Sstevel@tonic-gate if (--len == 0) 1367c478bd9Sstevel@tonic-gate return (TRUE); 1377c478bd9Sstevel@tonic-gate 1387c478bd9Sstevel@tonic-gate size = len * BYTES_PER_XDR_UNIT; 1397c478bd9Sstevel@tonic-gate return (XDR_CONTROL(xdrs, XDR_SKIPBYTES, &size)); 1407c478bd9Sstevel@tonic-gate } 1417c478bd9Sstevel@tonic-gate 1427c478bd9Sstevel@tonic-gate /* Called by xdr_array, nfsid_map_xdr */ 1437c478bd9Sstevel@tonic-gate bool_t 1447c478bd9Sstevel@tonic-gate xdr_utf8string(XDR *xdrs, utf8string *objp) 1457c478bd9Sstevel@tonic-gate { 1467c478bd9Sstevel@tonic-gate if (xdrs->x_op != XDR_FREE) 1477c478bd9Sstevel@tonic-gate return (xdr_bytes(xdrs, (char **)&objp->utf8string_val, 1480a701b1eSRobert Gordon (uint_t *)&objp->utf8string_len, NFS4_MAX_UTF8STRING)); 1497c478bd9Sstevel@tonic-gate 1507c478bd9Sstevel@tonic-gate if (objp->utf8string_val != NULL) { 1517c478bd9Sstevel@tonic-gate kmem_free(objp->utf8string_val, objp->utf8string_len); 1527c478bd9Sstevel@tonic-gate objp->utf8string_val = NULL; 1537c478bd9Sstevel@tonic-gate } 1547c478bd9Sstevel@tonic-gate return (TRUE); 1557c478bd9Sstevel@tonic-gate } 1567c478bd9Sstevel@tonic-gate 1572f172c55SRobert Thurlow /* 1582f172c55SRobert Thurlow * used by NFSv4 referrals to get info needed for NFSv4 referral mount. 1592f172c55SRobert Thurlow */ 1602f172c55SRobert Thurlow bool_t 1612f172c55SRobert Thurlow xdr_nfs_fsl_info(XDR *xdrs, struct nfs_fsl_info *objp) 1622f172c55SRobert Thurlow { 1632f172c55SRobert Thurlow 1642f172c55SRobert Thurlow if (!xdr_u_int(xdrs, &objp->netbuf_len)) 1652f172c55SRobert Thurlow return (FALSE); 1662f172c55SRobert Thurlow if (!xdr_u_int(xdrs, &objp->netnm_len)) 1672f172c55SRobert Thurlow return (FALSE); 1682f172c55SRobert Thurlow if (!xdr_u_int(xdrs, &objp->knconf_len)) 1692f172c55SRobert Thurlow return (FALSE); 1702f172c55SRobert Thurlow 1712f172c55SRobert Thurlow #if defined(_LP64) 1722f172c55SRobert Thurlow /* 1732f172c55SRobert Thurlow * The object can come from a 32-bit binary; nfsmapid. 1742f172c55SRobert Thurlow * To be safe we double the size of the knetconfig to 1752f172c55SRobert Thurlow * allow some buffering for decoding. 1762f172c55SRobert Thurlow */ 1772f172c55SRobert Thurlow if (xdrs->x_op == XDR_DECODE) 1782f172c55SRobert Thurlow objp->knconf_len += sizeof (struct knetconfig); 1792f172c55SRobert Thurlow #endif 1802f172c55SRobert Thurlow 1812f172c55SRobert Thurlow if (!xdr_string(xdrs, &objp->netname, ~0)) 1822f172c55SRobert Thurlow return (FALSE); 1832f172c55SRobert Thurlow if (!xdr_pointer(xdrs, (char **)&objp->addr, objp->netbuf_len, 1842f172c55SRobert Thurlow (xdrproc_t)xdr_netbuf)) 1852f172c55SRobert Thurlow return (FALSE); 1862f172c55SRobert Thurlow if (!xdr_pointer(xdrs, (char **)&objp->knconf, 1872f172c55SRobert Thurlow objp->knconf_len, (xdrproc_t)xdr_knetconfig)) 1882f172c55SRobert Thurlow return (FALSE); 1892f172c55SRobert Thurlow return (TRUE); 1902f172c55SRobert Thurlow } 1912f172c55SRobert Thurlow 1922f172c55SRobert Thurlow bool_t 1932f172c55SRobert Thurlow xdr_knetconfig(XDR *xdrs, struct knetconfig *objp) 1942f172c55SRobert Thurlow { 1952f172c55SRobert Thurlow rpc_inline_t *buf; 1962f172c55SRobert Thurlow u_longlong_t dev64; 1972f172c55SRobert Thurlow #if !defined(_LP64) 1982f172c55SRobert Thurlow uint32_t major, minor; 1992f172c55SRobert Thurlow #endif 2002f172c55SRobert Thurlow int i; 2012f172c55SRobert Thurlow 2022f172c55SRobert Thurlow if (!xdr_u_int(xdrs, &objp->knc_semantics)) 2032f172c55SRobert Thurlow return (FALSE); 2042f172c55SRobert Thurlow if (xdrs->x_op == XDR_DECODE) { 2052f172c55SRobert Thurlow objp->knc_protofmly = (((char *)objp) + 2062f172c55SRobert Thurlow sizeof (struct knetconfig)); 2072f172c55SRobert Thurlow objp->knc_proto = objp->knc_protofmly + KNC_STRSIZE; 2082f172c55SRobert Thurlow } 2092f172c55SRobert Thurlow if (!xdr_opaque(xdrs, objp->knc_protofmly, KNC_STRSIZE)) 2102f172c55SRobert Thurlow return (FALSE); 2112f172c55SRobert Thurlow if (!xdr_opaque(xdrs, objp->knc_proto, KNC_STRSIZE)) 2122f172c55SRobert Thurlow return (FALSE); 2132f172c55SRobert Thurlow 2142f172c55SRobert Thurlow /* 2152f172c55SRobert Thurlow * For interoperability between 32-bit daemon and 64-bit kernel, 2162f172c55SRobert Thurlow * we always treat dev_t as 64-bit number and do the expanding 2172f172c55SRobert Thurlow * or compression of dev_t as needed. 2182f172c55SRobert Thurlow * We have to hand craft the conversion since there is no available 2192f172c55SRobert Thurlow * function in ddi.c. Besides ddi.c is available only in the kernel 2202f172c55SRobert Thurlow * and we want to keep both user and kernel of xdr_knetconfig() the 2212f172c55SRobert Thurlow * same for consistency. 2222f172c55SRobert Thurlow */ 2232f172c55SRobert Thurlow if (xdrs->x_op == XDR_ENCODE) { 2242f172c55SRobert Thurlow #if defined(_LP64) 2252f172c55SRobert Thurlow dev64 = objp->knc_rdev; 2262f172c55SRobert Thurlow #else 2272f172c55SRobert Thurlow major = (objp->knc_rdev >> NBITSMINOR32) & MAXMAJ32; 2282f172c55SRobert Thurlow minor = objp->knc_rdev & MAXMIN32; 2292f172c55SRobert Thurlow dev64 = (((unsigned long long)major) << NBITSMINOR64) | minor; 2302f172c55SRobert Thurlow #endif 2312f172c55SRobert Thurlow if (!xdr_u_longlong_t(xdrs, &dev64)) 2322f172c55SRobert Thurlow return (FALSE); 2332f172c55SRobert Thurlow } 2342f172c55SRobert Thurlow if (xdrs->x_op == XDR_DECODE) { 2352f172c55SRobert Thurlow #if defined(_LP64) 2362f172c55SRobert Thurlow if (!xdr_u_longlong_t(xdrs, (u_longlong_t *)&objp->knc_rdev)) 2372f172c55SRobert Thurlow return (FALSE); 2382f172c55SRobert Thurlow #else 2392f172c55SRobert Thurlow if (!xdr_u_longlong_t(xdrs, &dev64)) 2402f172c55SRobert Thurlow return (FALSE); 2412f172c55SRobert Thurlow 2422f172c55SRobert Thurlow major = (dev64 >> NBITSMINOR64) & L_MAXMAJ32; 2432f172c55SRobert Thurlow minor = dev64 & L_MAXMIN32; 2442f172c55SRobert Thurlow objp->knc_rdev = (major << L_BITSMINOR32) | minor; 2452f172c55SRobert Thurlow #endif 2462f172c55SRobert Thurlow } 2472f172c55SRobert Thurlow 2482f172c55SRobert Thurlow if (xdrs->x_op == XDR_ENCODE) { 2492f172c55SRobert Thurlow buf = XDR_INLINE(xdrs, (8) * BYTES_PER_XDR_UNIT); 2502f172c55SRobert Thurlow if (buf == NULL) { 2512f172c55SRobert Thurlow if (!xdr_vector(xdrs, (char *)objp->knc_unused, 8, 2522f172c55SRobert Thurlow sizeof (uint_t), (xdrproc_t)xdr_u_int)) 2532f172c55SRobert Thurlow return (FALSE); 2542f172c55SRobert Thurlow } else { 2552f172c55SRobert Thurlow uint_t *genp; 2562f172c55SRobert Thurlow 2572f172c55SRobert Thurlow for (i = 0, genp = objp->knc_unused; 2582f172c55SRobert Thurlow i < 8; i++) { 2592f172c55SRobert Thurlow #if defined(_LP64) || defined(_KERNEL) 2602f172c55SRobert Thurlow IXDR_PUT_U_INT32(buf, *genp++); 2612f172c55SRobert Thurlow #else 2622f172c55SRobert Thurlow IXDR_PUT_U_LONG(buf, *genp++); 2632f172c55SRobert Thurlow #endif 2642f172c55SRobert Thurlow } 2652f172c55SRobert Thurlow } 2662f172c55SRobert Thurlow return (TRUE); 2672f172c55SRobert Thurlow } else if (xdrs->x_op == XDR_DECODE) { 2682f172c55SRobert Thurlow buf = XDR_INLINE(xdrs, (8) * BYTES_PER_XDR_UNIT); 2692f172c55SRobert Thurlow if (buf == NULL) { 2702f172c55SRobert Thurlow if (!xdr_vector(xdrs, (char *)objp->knc_unused, 8, 2712f172c55SRobert Thurlow sizeof (uint_t), (xdrproc_t)xdr_u_int)) 2722f172c55SRobert Thurlow return (FALSE); 2732f172c55SRobert Thurlow } else { 2742f172c55SRobert Thurlow uint_t *genp; 2752f172c55SRobert Thurlow 2762f172c55SRobert Thurlow for (i = 0, genp = objp->knc_unused; 2772f172c55SRobert Thurlow i < 8; i++) { 2782f172c55SRobert Thurlow #if defined(_LP64) || defined(_KERNEL) 2792f172c55SRobert Thurlow *genp++ = IXDR_GET_U_INT32(buf); 2802f172c55SRobert Thurlow #else 2812f172c55SRobert Thurlow *genp++ = IXDR_GET_U_LONG(buf); 2822f172c55SRobert Thurlow #endif 2832f172c55SRobert Thurlow } 2842f172c55SRobert Thurlow } 2852f172c55SRobert Thurlow return (TRUE); 2862f172c55SRobert Thurlow } 2872f172c55SRobert Thurlow 2882f172c55SRobert Thurlow if (!xdr_vector(xdrs, (char *)objp->knc_unused, 8, 2892f172c55SRobert Thurlow sizeof (uint_t), (xdrproc_t)xdr_u_int)) 2902f172c55SRobert Thurlow return (FALSE); 2912f172c55SRobert Thurlow return (TRUE); 2922f172c55SRobert Thurlow } 2932f172c55SRobert Thurlow 2947c478bd9Sstevel@tonic-gate /* 295eac3aab7Srobinson * XDR_INLINE decode a filehandle. 2967c46fb7fSek */ 2977c46fb7fSek bool_t 298eac3aab7Srobinson xdr_inline_decode_nfs_fh4(uint32_t *ptr, nfs_fh4_fmt_t *fhp, uint32_t fhsize) 2997c46fb7fSek { 300eac3aab7Srobinson uchar_t *bp = (uchar_t *)ptr; 3014f85d229Srobinson uchar_t *cp; 302eac3aab7Srobinson uint32_t dsize; 303eac3aab7Srobinson uintptr_t resid; 3044f85d229Srobinson 3057c46fb7fSek /* 306eac3aab7Srobinson * Check to see if what the client sent us is bigger or smaller 307eac3aab7Srobinson * than what we can ever possibly send out. NFS_FHMAXDATA is 308eac3aab7Srobinson * unfortunately badly named as it is no longer the max and is 309eac3aab7Srobinson * really the min of what is sent over the wire. 3107c46fb7fSek */ 311eac3aab7Srobinson if (fhsize > sizeof (nfs_fh4_fmt_t) || fhsize < (sizeof (fsid_t) + 312eac3aab7Srobinson sizeof (ushort_t) + NFS_FHMAXDATA + 313eac3aab7Srobinson sizeof (ushort_t) + NFS_FHMAXDATA)) { 314eac3aab7Srobinson return (FALSE); 315eac3aab7Srobinson } 3164f85d229Srobinson 3177c46fb7fSek /* 318eac3aab7Srobinson * All internal parts of a filehandle are in native byte order. 319eac3aab7Srobinson * 320eac3aab7Srobinson * Decode what should be fh4_fsid, it is aligned. 3217c46fb7fSek */ 322eac3aab7Srobinson fhp->fh4_fsid.val[0] = *(uint32_t *)bp; 323eac3aab7Srobinson bp += BYTES_PER_XDR_UNIT; 324eac3aab7Srobinson fhp->fh4_fsid.val[1] = *(uint32_t *)bp; 325eac3aab7Srobinson bp += BYTES_PER_XDR_UNIT; 3267c46fb7fSek 3277c46fb7fSek /* 328eac3aab7Srobinson * Decode what should be fh4_len. fh4_len is two bytes, so we're 329eac3aab7Srobinson * unaligned now. 3307c46fb7fSek */ 331eac3aab7Srobinson cp = (uchar_t *)&fhp->fh4_len; 332eac3aab7Srobinson *cp++ = *bp++; 333eac3aab7Srobinson *cp++ = *bp++; 334eac3aab7Srobinson fhsize -= 2 * BYTES_PER_XDR_UNIT + sizeof (ushort_t); 3357c46fb7fSek 3367c46fb7fSek /* 337da6c28aaSamw * For backwards compatibility, the fid length may be less than 338eac3aab7Srobinson * NFS_FHMAXDATA, but it was always encoded as NFS_FHMAXDATA bytes. 3397c46fb7fSek */ 340eac3aab7Srobinson dsize = fhp->fh4_len < NFS_FHMAXDATA ? NFS_FHMAXDATA : fhp->fh4_len; 3417c46fb7fSek 3427c46fb7fSek /* 343eac3aab7Srobinson * Make sure the client isn't sending us a bogus length for fh4_data. 3447c46fb7fSek */ 345eac3aab7Srobinson if (fhsize < dsize) 346eac3aab7Srobinson return (FALSE); 347eac3aab7Srobinson bcopy(bp, fhp->fh4_data, dsize); 348eac3aab7Srobinson bp += dsize; 349eac3aab7Srobinson fhsize -= dsize; 3507c46fb7fSek 351eac3aab7Srobinson if (fhsize < sizeof (ushort_t)) 352eac3aab7Srobinson return (FALSE); 353eac3aab7Srobinson cp = (uchar_t *)&fhp->fh4_xlen; 354eac3aab7Srobinson *cp++ = *bp++; 355eac3aab7Srobinson *cp++ = *bp++; 356eac3aab7Srobinson fhsize -= sizeof (ushort_t); 357eac3aab7Srobinson 358eac3aab7Srobinson dsize = fhp->fh4_xlen < NFS_FHMAXDATA ? NFS_FHMAXDATA : fhp->fh4_xlen; 3597c46fb7fSek 3607c46fb7fSek /* 361eac3aab7Srobinson * Make sure the client isn't sending us a bogus length for fh4_xdata. 3627c46fb7fSek */ 363eac3aab7Srobinson if (fhsize < dsize) 364eac3aab7Srobinson return (FALSE); 365eac3aab7Srobinson bcopy(bp, fhp->fh4_xdata, dsize); 366eac3aab7Srobinson fhsize -= dsize; 367eac3aab7Srobinson bp += dsize; 3687c46fb7fSek 3697c46fb7fSek /* 370eac3aab7Srobinson * We realign things on purpose, so skip any padding 3717c46fb7fSek */ 372eac3aab7Srobinson resid = (uintptr_t)bp % BYTES_PER_XDR_UNIT; 373eac3aab7Srobinson if (resid != 0) { 374eac3aab7Srobinson if (fhsize < (BYTES_PER_XDR_UNIT - resid)) 375eac3aab7Srobinson return (FALSE); 376eac3aab7Srobinson bp += BYTES_PER_XDR_UNIT - resid; 377eac3aab7Srobinson fhsize -= BYTES_PER_XDR_UNIT - resid; 378eac3aab7Srobinson } 3797c46fb7fSek 380eac3aab7Srobinson if (fhsize < BYTES_PER_XDR_UNIT) 381eac3aab7Srobinson return (FALSE); 382eac3aab7Srobinson fhp->fh4_flag = *(uint32_t *)bp; 383eac3aab7Srobinson bp += BYTES_PER_XDR_UNIT; 384eac3aab7Srobinson fhsize -= BYTES_PER_XDR_UNIT; 3857c46fb7fSek 3867c46fb7fSek #ifdef VOLATILE_FH_TEST 387eac3aab7Srobinson if (fhsize < BYTES_PER_XDR_UNIT) 388eac3aab7Srobinson return (FALSE); 389eac3aab7Srobinson fhp->fh4_volatile_id = *(uint32_t *)bp; 390eac3aab7Srobinson bp += BYTES_PER_XDR_UNIT; 391eac3aab7Srobinson fhsize -= BYTES_PER_XDR_UNIT; 3927c46fb7fSek #endif 393eac3aab7Srobinson /* 394eac3aab7Srobinson * Make sure client didn't send extra bytes 395eac3aab7Srobinson */ 396eac3aab7Srobinson if (fhsize != 0) 397eac3aab7Srobinson return (FALSE); 3987c46fb7fSek return (TRUE); 3997c46fb7fSek } 4007c46fb7fSek 4017c46fb7fSek static bool_t 4027c46fb7fSek xdr_decode_nfs_fh4(XDR *xdrs, nfs_fh4 *objp) 4037c46fb7fSek { 4047c46fb7fSek uint32_t fhsize; /* filehandle size */ 4054f85d229Srobinson uint32_t bufsize; 4064f85d229Srobinson rpc_inline_t *ptr; 40727242a7cSthurlow uchar_t *bp; 4087c46fb7fSek 4097c46fb7fSek ASSERT(xdrs->x_op == XDR_DECODE); 4107c46fb7fSek 4117c46fb7fSek /* 4127c46fb7fSek * Retrieve the filehandle length. 4137c46fb7fSek */ 4147c46fb7fSek if (!XDR_GETINT32(xdrs, (int32_t *)&fhsize)) 4157c46fb7fSek return (FALSE); 4167c46fb7fSek 4174f85d229Srobinson objp->nfs_fh4_val = NULL; 4184f85d229Srobinson objp->nfs_fh4_len = 0; 4194f85d229Srobinson 4207c46fb7fSek /* 4214f85d229Srobinson * Check to see if what the client sent us is bigger or smaller 4224f85d229Srobinson * than what we can ever possibly send out. NFS_FHMAXDATA is 4234f85d229Srobinson * unfortunately badly named as it is no longer the max and is 4244f85d229Srobinson * really the min of what is sent over the wire. 4257c46fb7fSek */ 4264f85d229Srobinson if (fhsize > sizeof (nfs_fh4_fmt_t) || fhsize < (sizeof (fsid_t) + 4274f85d229Srobinson sizeof (ushort_t) + NFS_FHMAXDATA + 4284f85d229Srobinson sizeof (ushort_t) + NFS_FHMAXDATA)) { 4294f85d229Srobinson if (!XDR_CONTROL(xdrs, XDR_SKIPBYTES, &fhsize)) 4304f85d229Srobinson return (FALSE); 4314f85d229Srobinson return (TRUE); 4324f85d229Srobinson } 4337c46fb7fSek 4344f85d229Srobinson /* 4354f85d229Srobinson * bring in fhsize plus any padding 4364f85d229Srobinson */ 4374f85d229Srobinson bufsize = RNDUP(fhsize); 4384f85d229Srobinson ptr = XDR_INLINE(xdrs, bufsize); 439eac3aab7Srobinson bp = (uchar_t *)ptr; 4404f85d229Srobinson if (ptr == NULL) { 44127242a7cSthurlow bp = kmem_alloc(bufsize, KM_SLEEP); 44227242a7cSthurlow if (!xdr_opaque(xdrs, (char *)bp, bufsize)) { 44327242a7cSthurlow kmem_free(bp, bufsize); 4444f85d229Srobinson return (FALSE); 44527242a7cSthurlow } 4464f85d229Srobinson } 4477c46fb7fSek 4487c46fb7fSek objp->nfs_fh4_val = kmem_zalloc(sizeof (nfs_fh4_fmt_t), KM_SLEEP); 4497c46fb7fSek objp->nfs_fh4_len = sizeof (nfs_fh4_fmt_t); 450eac3aab7Srobinson 451eac3aab7Srobinson if (xdr_inline_decode_nfs_fh4((uint32_t *)bp, 452eac3aab7Srobinson (nfs_fh4_fmt_t *)objp->nfs_fh4_val, fhsize) == FALSE) { 453eac3aab7Srobinson /* 454eac3aab7Srobinson * If in the process of decoding we find the file handle 455eac3aab7Srobinson * is not correctly formed, we need to continue decoding 456eac3aab7Srobinson * and trigger an NFS layer error. Set the nfs_fh4_len to 457eac3aab7Srobinson * zero so it gets caught as a bad length. 458eac3aab7Srobinson */ 459eac3aab7Srobinson kmem_free(objp->nfs_fh4_val, objp->nfs_fh4_len); 460eac3aab7Srobinson objp->nfs_fh4_val = NULL; 461eac3aab7Srobinson objp->nfs_fh4_len = 0; 462eac3aab7Srobinson } 463eac3aab7Srobinson 464eac3aab7Srobinson if (ptr == NULL) 46527242a7cSthurlow kmem_free(bp, bufsize); 466eac3aab7Srobinson return (TRUE); 467eac3aab7Srobinson } 468eac3aab7Srobinson 469eac3aab7Srobinson /* 470eac3aab7Srobinson * XDR_INLINE encode a filehandle. 471eac3aab7Srobinson */ 472eac3aab7Srobinson bool_t 473eac3aab7Srobinson xdr_inline_encode_nfs_fh4(uint32_t **ptrp, uint32_t *ptr_redzone, 474eac3aab7Srobinson nfs_fh4_fmt_t *fhp) 475eac3aab7Srobinson { 476eac3aab7Srobinson uint32_t *ptr = *ptrp; 477eac3aab7Srobinson uchar_t *cp; 478eac3aab7Srobinson uint_t otw_len, fsize, xsize; /* otw, file, and export sizes */ 479eac3aab7Srobinson uint32_t padword; 480eac3aab7Srobinson 481eac3aab7Srobinson fsize = fhp->fh4_len < NFS_FHMAXDATA ? NFS_FHMAXDATA : fhp->fh4_len; 482eac3aab7Srobinson xsize = fhp->fh4_xlen < NFS_FHMAXDATA ? NFS_FHMAXDATA : fhp->fh4_xlen; 4837c46fb7fSek 4847c46fb7fSek /* 485eac3aab7Srobinson * First get the initial and variable sized part of the filehandle. 4867c46fb7fSek */ 487eac3aab7Srobinson otw_len = sizeof (fhp->fh4_fsid) + 488eac3aab7Srobinson sizeof (fhp->fh4_len) + fsize + 489eac3aab7Srobinson sizeof (fhp->fh4_xlen) + xsize; 4907c46fb7fSek 4917c46fb7fSek /* 492eac3aab7Srobinson * Round out to a full word. 4937c46fb7fSek */ 494eac3aab7Srobinson otw_len = RNDUP(otw_len); 495eac3aab7Srobinson padword = (otw_len / BYTES_PER_XDR_UNIT); /* includes fhlen */ 4967c46fb7fSek 4977c46fb7fSek /* 498eac3aab7Srobinson * Add in the fixed sized pieces. 4997c46fb7fSek */ 500eac3aab7Srobinson otw_len += sizeof (fhp->fh4_flag); 501eac3aab7Srobinson #ifdef VOLATILE_FH_TEST 502eac3aab7Srobinson otw_len += sizeof (fhp->fh4_volatile_id); 503eac3aab7Srobinson #endif 5047c46fb7fSek 5054f85d229Srobinson /* 506eac3aab7Srobinson * Make sure we don't exceed our buffer. 5074f85d229Srobinson */ 508eac3aab7Srobinson if ((ptr + (otw_len / BYTES_PER_XDR_UNIT) + 1) > ptr_redzone) 509eac3aab7Srobinson return (FALSE); 5107c46fb7fSek 5117c46fb7fSek /* 51227242a7cSthurlow * Zero out the padding. 5137c46fb7fSek */ 514eac3aab7Srobinson ptr[padword] = 0; 5157c46fb7fSek 51627242a7cSthurlow IXDR_PUT_U_INT32(ptr, otw_len); 51727242a7cSthurlow 5184f85d229Srobinson /* 519eac3aab7Srobinson * The rest of the filehandle is in native byteorder 5204f85d229Srobinson */ 521eac3aab7Srobinson /* fh4_fsid */ 522eac3aab7Srobinson *ptr++ = (uint32_t)fhp->fh4_fsid.val[0]; 523eac3aab7Srobinson *ptr++ = (uint32_t)fhp->fh4_fsid.val[1]; 5247c46fb7fSek 5257c46fb7fSek /* 526eac3aab7Srobinson * Since the next pieces are unaligned, we need to 527eac3aab7Srobinson * do bytewise copies. 5287c46fb7fSek */ 529eac3aab7Srobinson cp = (uchar_t *)ptr; 5307c46fb7fSek 531eac3aab7Srobinson /* fh4_len + fh4_data */ 532eac3aab7Srobinson bcopy(&fhp->fh4_len, cp, sizeof (fhp->fh4_len) + fsize); 533eac3aab7Srobinson cp += sizeof (fhp->fh4_len) + fsize; 534eac3aab7Srobinson 535eac3aab7Srobinson /* fh4_xlen + fh4_xdata */ 536eac3aab7Srobinson bcopy(&fhp->fh4_xlen, cp, sizeof (fhp->fh4_xlen) + xsize); 537eac3aab7Srobinson cp += sizeof (fhp->fh4_xlen) + xsize; 538eac3aab7Srobinson 539eac3aab7Srobinson /* do necessary rounding/padding */ 540eac3aab7Srobinson cp = (uchar_t *)RNDUP((uintptr_t)cp); 541eac3aab7Srobinson ptr = (uint32_t *)cp; 5427c46fb7fSek 5434f85d229Srobinson /* 544eac3aab7Srobinson * With the above padding, we're word aligned again. 5454f85d229Srobinson */ 546eac3aab7Srobinson ASSERT(((uintptr_t)ptr % BYTES_PER_XDR_UNIT) == 0); 547eac3aab7Srobinson 548eac3aab7Srobinson /* fh4_flag */ 549eac3aab7Srobinson *ptr++ = (uint32_t)fhp->fh4_flag; 550eac3aab7Srobinson 551eac3aab7Srobinson #ifdef VOLATILE_FH_TEST 552eac3aab7Srobinson /* fh4_volatile_id */ 553eac3aab7Srobinson *ptr++ = (uint32_t)fhp->fh4_volatile_id; 554eac3aab7Srobinson #endif 555eac3aab7Srobinson *ptrp = ptr; 556eac3aab7Srobinson 5577c46fb7fSek return (TRUE); 5587c46fb7fSek } 5597c46fb7fSek 5607c46fb7fSek static bool_t 5617c46fb7fSek xdr_encode_nfs_fh4(XDR *xdrs, nfs_fh4 *objp) 5627c46fb7fSek { 5634f85d229Srobinson uint_t otw_len, fsize, xsize; /* otw, file, and export sizes */ 5644f85d229Srobinson bool_t ret; 5654f85d229Srobinson rpc_inline_t *ptr; 5664f85d229Srobinson rpc_inline_t *buf = NULL; 5674f85d229Srobinson uint32_t *ptr_redzone; 5684f85d229Srobinson nfs_fh4_fmt_t *fhp; 5697c46fb7fSek 5707c46fb7fSek ASSERT(xdrs->x_op == XDR_ENCODE); 5717c46fb7fSek 5724f85d229Srobinson fhp = (nfs_fh4_fmt_t *)objp->nfs_fh4_val; 5734f85d229Srobinson fsize = fhp->fh4_len < NFS_FHMAXDATA ? NFS_FHMAXDATA : fhp->fh4_len; 5744f85d229Srobinson xsize = fhp->fh4_xlen < NFS_FHMAXDATA ? NFS_FHMAXDATA : fhp->fh4_xlen; 5757c46fb7fSek 5764f85d229Srobinson /* 5774f85d229Srobinson * First get the over the wire size, it is the 4 bytes 5784f85d229Srobinson * for the length, plus the combined size of the 5794f85d229Srobinson * file handle components. 5804f85d229Srobinson */ 5814f85d229Srobinson otw_len = BYTES_PER_XDR_UNIT + sizeof (fhp->fh4_fsid) + 5824f85d229Srobinson sizeof (fhp->fh4_len) + fsize + 5834f85d229Srobinson sizeof (fhp->fh4_xlen) + xsize + 5844f85d229Srobinson sizeof (fhp->fh4_flag); 5857c46fb7fSek #ifdef VOLATILE_FH_TEST 5864f85d229Srobinson otw_len += sizeof (fhp->fh4_volatile_id); 5877c46fb7fSek #endif 5887c46fb7fSek /* 5894f85d229Srobinson * Round out to a full word. 5907c46fb7fSek */ 5914f85d229Srobinson otw_len = RNDUP(otw_len); 5927c46fb7fSek 5937c46fb7fSek /* 5944f85d229Srobinson * Next try to inline the XDR stream, if that fails (rare) 5954f85d229Srobinson * allocate a buffer to encode the file handle and then 5964f85d229Srobinson * copy it using xdr_opaque and free the buffer. 5977c46fb7fSek */ 5984f85d229Srobinson ptr = XDR_INLINE(xdrs, otw_len); 5994f85d229Srobinson if (ptr == NULL) 6004f85d229Srobinson ptr = buf = kmem_alloc(otw_len, KM_SLEEP); 6017c46fb7fSek 6024f85d229Srobinson ptr_redzone = (uint32_t *)(ptr + (otw_len / BYTES_PER_XDR_UNIT)); 6034f85d229Srobinson ret = xdr_inline_encode_nfs_fh4((uint32_t **)&ptr, ptr_redzone, fhp); 6047c46fb7fSek 6054f85d229Srobinson if (buf != NULL) { 6064f85d229Srobinson if (ret == TRUE) 6074f85d229Srobinson ret = xdr_opaque(xdrs, (char *)buf, otw_len); 6084f85d229Srobinson kmem_free(buf, otw_len); 6094f85d229Srobinson } 6104f85d229Srobinson return (ret); 6117c46fb7fSek } 6127c46fb7fSek 6137c46fb7fSek /* 6147c46fb7fSek * XDR a NFSv4 filehandle. 615eac3aab7Srobinson * Encoding interprets the contents (server). 616eac3aab7Srobinson * Decoding the contents are opaque (client). 6177c478bd9Sstevel@tonic-gate */ 6187c478bd9Sstevel@tonic-gate bool_t 6197c478bd9Sstevel@tonic-gate xdr_nfs_fh4(XDR *xdrs, nfs_fh4 *objp) 6207c478bd9Sstevel@tonic-gate { 621eac3aab7Srobinson switch (xdrs->x_op) { 622eac3aab7Srobinson case XDR_ENCODE: 6237c46fb7fSek return (xdr_encode_nfs_fh4(xdrs, objp)); 624eac3aab7Srobinson case XDR_DECODE: 625eac3aab7Srobinson return (xdr_bytes(xdrs, (char **)&objp->nfs_fh4_val, 626eac3aab7Srobinson (uint_t *)&objp->nfs_fh4_len, NFS4_FHSIZE)); 627eac3aab7Srobinson case XDR_FREE: 628eac3aab7Srobinson if (objp->nfs_fh4_val != NULL) { 629eac3aab7Srobinson kmem_free(objp->nfs_fh4_val, objp->nfs_fh4_len); 630eac3aab7Srobinson objp->nfs_fh4_val = NULL; 631eac3aab7Srobinson } 632eac3aab7Srobinson return (TRUE); 6337c478bd9Sstevel@tonic-gate } 634eac3aab7Srobinson return (FALSE); 6357c478bd9Sstevel@tonic-gate } 6367c478bd9Sstevel@tonic-gate 6377c478bd9Sstevel@tonic-gate /* Called by xdr_array */ 6387c478bd9Sstevel@tonic-gate static bool_t 6397c478bd9Sstevel@tonic-gate xdr_fs_location4(XDR *xdrs, fs_location4 *objp) 6407c478bd9Sstevel@tonic-gate { 6412f172c55SRobert Thurlow if (xdrs->x_op == XDR_DECODE) { 6422f172c55SRobert Thurlow objp->server_val = NULL; 6432f172c55SRobert Thurlow objp->rootpath.pathname4_val = NULL; 6442f172c55SRobert Thurlow } 6457c478bd9Sstevel@tonic-gate if (!xdr_array(xdrs, (char **)&objp->server_val, 6462f172c55SRobert Thurlow (uint_t *)&objp->server_len, NFS4_MAX_UTF8STRING, 6470a701b1eSRobert Gordon sizeof (utf8string), (xdrproc_t)xdr_utf8string)) 6487c478bd9Sstevel@tonic-gate return (FALSE); 6497c478bd9Sstevel@tonic-gate return (xdr_array(xdrs, (char **)&objp->rootpath.pathname4_val, 6500a701b1eSRobert Gordon (uint_t *)&objp->rootpath.pathname4_len, 6510a701b1eSRobert Gordon NFS4_MAX_PATHNAME4, 6520a701b1eSRobert Gordon sizeof (utf8string), (xdrproc_t)xdr_utf8string)); 6537c478bd9Sstevel@tonic-gate } 6547c478bd9Sstevel@tonic-gate 6557c478bd9Sstevel@tonic-gate /* Called by xdr_array */ 6567c478bd9Sstevel@tonic-gate static bool_t 6577c478bd9Sstevel@tonic-gate xdr_nfsace4(XDR *xdrs, nfsace4 *objp) 6587c478bd9Sstevel@tonic-gate { 6597c478bd9Sstevel@tonic-gate if (xdrs->x_op != XDR_FREE) { 6607c478bd9Sstevel@tonic-gate if (!xdr_u_int(xdrs, &objp->type)) 6617c478bd9Sstevel@tonic-gate return (FALSE); 6627c478bd9Sstevel@tonic-gate if (!xdr_u_int(xdrs, &objp->flag)) 6637c478bd9Sstevel@tonic-gate return (FALSE); 6647c478bd9Sstevel@tonic-gate if (!xdr_u_int(xdrs, &objp->access_mask)) 6657c478bd9Sstevel@tonic-gate return (FALSE); 6667c478bd9Sstevel@tonic-gate 6677c478bd9Sstevel@tonic-gate if (xdrs->x_op == XDR_DECODE) { 6687c478bd9Sstevel@tonic-gate objp->who.utf8string_val = NULL; 6697c478bd9Sstevel@tonic-gate objp->who.utf8string_len = 0; 6707c478bd9Sstevel@tonic-gate } 6717c478bd9Sstevel@tonic-gate 6727c478bd9Sstevel@tonic-gate return (xdr_bytes(xdrs, (char **)&objp->who.utf8string_val, 6730a701b1eSRobert Gordon (uint_t *)&objp->who.utf8string_len, 6740a701b1eSRobert Gordon NFS4_MAX_UTF8STRING)); 6757c478bd9Sstevel@tonic-gate } 6767c478bd9Sstevel@tonic-gate 6777c478bd9Sstevel@tonic-gate /* 6787c478bd9Sstevel@tonic-gate * Optimized free case 6797c478bd9Sstevel@tonic-gate */ 6807c478bd9Sstevel@tonic-gate if (objp->who.utf8string_val != NULL) { 6817c478bd9Sstevel@tonic-gate kmem_free(objp->who.utf8string_val, objp->who.utf8string_len); 6827c478bd9Sstevel@tonic-gate objp->who.utf8string_val = NULL; 6837c478bd9Sstevel@tonic-gate } 6847c478bd9Sstevel@tonic-gate return (TRUE); 6857c478bd9Sstevel@tonic-gate } 6867c478bd9Sstevel@tonic-gate 6877c478bd9Sstevel@tonic-gate /* 6887c478bd9Sstevel@tonic-gate * These functions are called out of nfs4_attr.c 6897c478bd9Sstevel@tonic-gate */ 6907c478bd9Sstevel@tonic-gate bool_t 6917c478bd9Sstevel@tonic-gate xdr_fattr4_fsid(XDR *xdrs, fattr4_fsid *objp) 6927c478bd9Sstevel@tonic-gate { 6937c478bd9Sstevel@tonic-gate if (xdrs->x_op == XDR_FREE) 6947c478bd9Sstevel@tonic-gate return (TRUE); 6957c478bd9Sstevel@tonic-gate 6967c478bd9Sstevel@tonic-gate if (!xdr_u_longlong_t(xdrs, (u_longlong_t *)&objp->major)) 6977c478bd9Sstevel@tonic-gate return (FALSE); 6987c478bd9Sstevel@tonic-gate return (xdr_u_longlong_t(xdrs, (u_longlong_t *)&objp->minor)); 6997c478bd9Sstevel@tonic-gate } 7007c478bd9Sstevel@tonic-gate 7017c478bd9Sstevel@tonic-gate 7027c478bd9Sstevel@tonic-gate bool_t 7037c478bd9Sstevel@tonic-gate xdr_fattr4_acl(XDR *xdrs, fattr4_acl *objp) 7047c478bd9Sstevel@tonic-gate { 7057c478bd9Sstevel@tonic-gate return (xdr_array(xdrs, (char **)&objp->fattr4_acl_val, 7060a701b1eSRobert Gordon (uint_t *)&objp->fattr4_acl_len, NFS4_ACL_LIMIT, 7070a701b1eSRobert Gordon sizeof (nfsace4), (xdrproc_t)xdr_nfsace4)); 7087c478bd9Sstevel@tonic-gate } 7097c478bd9Sstevel@tonic-gate 7107c478bd9Sstevel@tonic-gate bool_t 7117c478bd9Sstevel@tonic-gate xdr_fattr4_fs_locations(XDR *xdrs, fattr4_fs_locations *objp) 7127c478bd9Sstevel@tonic-gate { 7132f172c55SRobert Thurlow if (xdrs->x_op == XDR_DECODE) { 7142f172c55SRobert Thurlow objp->fs_root.pathname4_len = 0; 7152f172c55SRobert Thurlow objp->fs_root.pathname4_val = NULL; 7162f172c55SRobert Thurlow objp->locations_val = NULL; 7172f172c55SRobert Thurlow } 7187c478bd9Sstevel@tonic-gate if (!xdr_array(xdrs, (char **)&objp->fs_root.pathname4_val, 7190a701b1eSRobert Gordon (uint_t *)&objp->fs_root.pathname4_len, 7200a701b1eSRobert Gordon NFS4_MAX_PATHNAME4, 7210a701b1eSRobert Gordon sizeof (utf8string), (xdrproc_t)xdr_utf8string)) 7227c478bd9Sstevel@tonic-gate return (FALSE); 7237c478bd9Sstevel@tonic-gate return (xdr_array(xdrs, (char **)&objp->locations_val, 7240a701b1eSRobert Gordon (uint_t *)&objp->locations_len, NFS4_FS_LOCATIONS_LIMIT, 7250a701b1eSRobert Gordon sizeof (fs_location4), (xdrproc_t)xdr_fs_location4)); 7267c478bd9Sstevel@tonic-gate } 7277c478bd9Sstevel@tonic-gate 7287c478bd9Sstevel@tonic-gate bool_t 7297c478bd9Sstevel@tonic-gate xdr_fattr4_rawdev(XDR *xdrs, fattr4_rawdev *objp) 7307c478bd9Sstevel@tonic-gate { 7317c478bd9Sstevel@tonic-gate if (xdrs->x_op == XDR_FREE) 7327c478bd9Sstevel@tonic-gate return (TRUE); 7337c478bd9Sstevel@tonic-gate 7347c478bd9Sstevel@tonic-gate if (!xdr_u_int(xdrs, &objp->specdata1)) 7357c478bd9Sstevel@tonic-gate return (FALSE); 7367c478bd9Sstevel@tonic-gate return (xdr_u_int(xdrs, &objp->specdata2)); 7377c478bd9Sstevel@tonic-gate } 7387c478bd9Sstevel@tonic-gate 7397c478bd9Sstevel@tonic-gate bool_t 7407c478bd9Sstevel@tonic-gate xdr_nfstime4(XDR *xdrs, nfstime4 *objp) 7417c478bd9Sstevel@tonic-gate { 7427c478bd9Sstevel@tonic-gate if (xdrs->x_op == XDR_FREE) 7437c478bd9Sstevel@tonic-gate return (TRUE); 7447c478bd9Sstevel@tonic-gate 7457c478bd9Sstevel@tonic-gate if (!xdr_longlong_t(xdrs, (longlong_t *)&objp->seconds)) 7467c478bd9Sstevel@tonic-gate return (FALSE); 7477c478bd9Sstevel@tonic-gate return (xdr_u_int(xdrs, &objp->nseconds)); 7487c478bd9Sstevel@tonic-gate } 7497c478bd9Sstevel@tonic-gate 7507c478bd9Sstevel@tonic-gate 7517c478bd9Sstevel@tonic-gate /* 7527c478bd9Sstevel@tonic-gate * structured used for calls into xdr_ga_fattr_res() as a means 7537c478bd9Sstevel@tonic-gate * to do an immediate/short-term cache of owner/group strings 7547c478bd9Sstevel@tonic-gate * for callers like the readdir processing. In the case of readdir, 7557c478bd9Sstevel@tonic-gate * it is likely that the directory objects will be owned by the same 7567c478bd9Sstevel@tonic-gate * owner/group and if so there is no need to call into the uid/gid 7577c478bd9Sstevel@tonic-gate * mapping code. While the uid/gid interfaces have their own cache 7587c478bd9Sstevel@tonic-gate * having one here will reduct pathlength further. 7597c478bd9Sstevel@tonic-gate */ 7607c478bd9Sstevel@tonic-gate #define MAX_OG_NAME 100 7617c478bd9Sstevel@tonic-gate typedef struct ug_cache 7627c478bd9Sstevel@tonic-gate { 7637c478bd9Sstevel@tonic-gate uid_t uid; 7647c478bd9Sstevel@tonic-gate gid_t gid; 7657c478bd9Sstevel@tonic-gate utf8string u_curr, u_last; 7667c478bd9Sstevel@tonic-gate utf8string g_curr, g_last; 7677c478bd9Sstevel@tonic-gate char u_buf1[MAX_OG_NAME]; 7687c478bd9Sstevel@tonic-gate char u_buf2[MAX_OG_NAME]; 7697c478bd9Sstevel@tonic-gate char g_buf1[MAX_OG_NAME]; 7707c478bd9Sstevel@tonic-gate char g_buf2[MAX_OG_NAME]; 7717c478bd9Sstevel@tonic-gate } ug_cache_t; 7727c478bd9Sstevel@tonic-gate 7737c478bd9Sstevel@tonic-gate #define U_SWAP_CURR_LAST(ug) \ 7747c478bd9Sstevel@tonic-gate (ug)->u_last.utf8string_len = (ug)->u_curr.utf8string_len; \ 7757c478bd9Sstevel@tonic-gate if ((ug)->u_last.utf8string_val == (ug)->u_buf1) { \ 7767c478bd9Sstevel@tonic-gate (ug)->u_last.utf8string_val = (ug)->u_buf2; \ 7777c478bd9Sstevel@tonic-gate (ug)->u_curr.utf8string_val = (ug)->u_buf1; \ 7787c478bd9Sstevel@tonic-gate } else { \ 7797c478bd9Sstevel@tonic-gate (ug)->u_last.utf8string_val = (ug)->u_buf1; \ 7807c478bd9Sstevel@tonic-gate (ug)->u_curr.utf8string_val = (ug)->u_buf2; \ 7817c478bd9Sstevel@tonic-gate } 7827c478bd9Sstevel@tonic-gate 7837c478bd9Sstevel@tonic-gate #define G_SWAP_CURR_LAST(ug) \ 7847c478bd9Sstevel@tonic-gate (ug)->g_last.utf8string_len = (ug)->g_curr.utf8string_len; \ 7857c478bd9Sstevel@tonic-gate if ((ug)->g_last.utf8string_val == (ug)->g_buf1) { \ 7867c478bd9Sstevel@tonic-gate (ug)->g_last.utf8string_val = (ug)->g_buf2; \ 7877c478bd9Sstevel@tonic-gate (ug)->g_curr.utf8string_val = (ug)->g_buf1; \ 7887c478bd9Sstevel@tonic-gate } else { \ 7897c478bd9Sstevel@tonic-gate (ug)->g_last.utf8string_val = (ug)->g_buf1; \ 7907c478bd9Sstevel@tonic-gate (ug)->g_curr.utf8string_val = (ug)->g_buf2; \ 7917c478bd9Sstevel@tonic-gate } 7927c478bd9Sstevel@tonic-gate 7937c478bd9Sstevel@tonic-gate static ug_cache_t * 7947c478bd9Sstevel@tonic-gate alloc_ugcache() 7957c478bd9Sstevel@tonic-gate { 7967c478bd9Sstevel@tonic-gate ug_cache_t *pug = kmem_alloc(sizeof (ug_cache_t), KM_SLEEP); 7977c478bd9Sstevel@tonic-gate 7987c478bd9Sstevel@tonic-gate pug->uid = pug->gid = 0; 7997c478bd9Sstevel@tonic-gate pug->u_curr.utf8string_len = 0; 8007c478bd9Sstevel@tonic-gate pug->u_last.utf8string_len = 0; 8017c478bd9Sstevel@tonic-gate pug->g_curr.utf8string_len = 0; 8027c478bd9Sstevel@tonic-gate pug->g_last.utf8string_len = 0; 8037c478bd9Sstevel@tonic-gate pug->u_curr.utf8string_val = pug->u_buf1; 8047c478bd9Sstevel@tonic-gate pug->u_last.utf8string_val = pug->u_buf2; 8057c478bd9Sstevel@tonic-gate pug->g_curr.utf8string_val = pug->g_buf1; 8067c478bd9Sstevel@tonic-gate pug->g_last.utf8string_val = pug->g_buf2; 8077c478bd9Sstevel@tonic-gate 8087c478bd9Sstevel@tonic-gate return (pug); 8097c478bd9Sstevel@tonic-gate } 8107c478bd9Sstevel@tonic-gate 8117c478bd9Sstevel@tonic-gate static void 8127c478bd9Sstevel@tonic-gate xdr_ga_prefill_vattr(struct nfs4_ga_res *garp, struct mntinfo4 *mi) 8137c478bd9Sstevel@tonic-gate { 8147c478bd9Sstevel@tonic-gate static vattr_t s_vattr = { 8157c478bd9Sstevel@tonic-gate AT_ALL, /* va_mask */ 8167c478bd9Sstevel@tonic-gate VNON, /* va_type */ 8177c478bd9Sstevel@tonic-gate 0777, /* va_mode */ 8187c478bd9Sstevel@tonic-gate UID_NOBODY, /* va_uid */ 8197c478bd9Sstevel@tonic-gate GID_NOBODY, /* va_gid */ 8207c478bd9Sstevel@tonic-gate 0, /* va_fsid */ 8217c478bd9Sstevel@tonic-gate 0, /* va_nodeid */ 8227c478bd9Sstevel@tonic-gate 1, /* va_nlink */ 8237c478bd9Sstevel@tonic-gate 0, /* va_size */ 8247c478bd9Sstevel@tonic-gate {0, 0}, /* va_atime */ 8257c478bd9Sstevel@tonic-gate {0, 0}, /* va_mtime */ 8267c478bd9Sstevel@tonic-gate {0, 0}, /* va_ctime */ 8277c478bd9Sstevel@tonic-gate 0, /* va_rdev */ 8287c478bd9Sstevel@tonic-gate MAXBSIZE, /* va_blksize */ 8297c478bd9Sstevel@tonic-gate 0, /* va_nblocks */ 8307c478bd9Sstevel@tonic-gate 0 /* va_seq */ 8317c478bd9Sstevel@tonic-gate }; 8327c478bd9Sstevel@tonic-gate 8337c478bd9Sstevel@tonic-gate 8347c478bd9Sstevel@tonic-gate garp->n4g_va = s_vattr; 8357c478bd9Sstevel@tonic-gate garp->n4g_va.va_fsid = mi->mi_vfsp->vfs_dev; 8367c478bd9Sstevel@tonic-gate hrt2ts(gethrtime(), &garp->n4g_va.va_atime); 8377c478bd9Sstevel@tonic-gate garp->n4g_va.va_mtime = garp->n4g_va.va_ctime = garp->n4g_va.va_atime; 8387c478bd9Sstevel@tonic-gate } 8397c478bd9Sstevel@tonic-gate 8407c478bd9Sstevel@tonic-gate static void 8417c478bd9Sstevel@tonic-gate xdr_ga_prefill_statvfs(struct nfs4_ga_ext_res *gesp, struct mntinfo4 *mi) 8427c478bd9Sstevel@tonic-gate { 8437c478bd9Sstevel@tonic-gate static statvfs64_t s_sb = { 8447c478bd9Sstevel@tonic-gate MAXBSIZE, /* f_bsize */ 8457c478bd9Sstevel@tonic-gate DEV_BSIZE, /* f_frsize */ 8467c478bd9Sstevel@tonic-gate (fsfilcnt64_t)-1, /* f_blocks */ 8477c478bd9Sstevel@tonic-gate (fsfilcnt64_t)-1, /* f_bfree */ 8487c478bd9Sstevel@tonic-gate (fsfilcnt64_t)-1, /* f_bavail */ 8497c478bd9Sstevel@tonic-gate (fsfilcnt64_t)-1, /* f_files */ 8507c478bd9Sstevel@tonic-gate (fsfilcnt64_t)-1, /* f_ffree */ 8517c478bd9Sstevel@tonic-gate (fsfilcnt64_t)-1, /* f_favail */ 8527c478bd9Sstevel@tonic-gate 0, /* f_fsid */ 8537c478bd9Sstevel@tonic-gate "\0", /* f_basetype */ 8547c478bd9Sstevel@tonic-gate 0, /* f_flag */ 8557c478bd9Sstevel@tonic-gate MAXNAMELEN, /* f_namemax */ 8567c478bd9Sstevel@tonic-gate "\0", /* f_fstr */ 8577c478bd9Sstevel@tonic-gate }; 8587c478bd9Sstevel@tonic-gate 8597c478bd9Sstevel@tonic-gate gesp->n4g_sb = s_sb; 8607c478bd9Sstevel@tonic-gate gesp->n4g_sb.f_fsid = mi->mi_vfsp->vfs_fsid.val[0]; 8617c478bd9Sstevel@tonic-gate } 8627c478bd9Sstevel@tonic-gate 8637c478bd9Sstevel@tonic-gate static bool_t 8647c478bd9Sstevel@tonic-gate xdr_ga_fattr_res(XDR *xdrs, struct nfs4_ga_res *garp, bitmap4 resbmap, 8657c478bd9Sstevel@tonic-gate bitmap4 argbmap, struct mntinfo4 *mi, ug_cache_t *pug) 8667c478bd9Sstevel@tonic-gate { 8677c478bd9Sstevel@tonic-gate int truefalse; 8687c478bd9Sstevel@tonic-gate struct nfs4_ga_ext_res ges, *gesp; 8697c478bd9Sstevel@tonic-gate vattr_t *vap = &garp->n4g_va; 8707c478bd9Sstevel@tonic-gate vsecattr_t *vsap = &garp->n4g_vsa; 8717c478bd9Sstevel@tonic-gate 8727c478bd9Sstevel@tonic-gate ASSERT(xdrs->x_op == XDR_DECODE); 8737c478bd9Sstevel@tonic-gate 8747c478bd9Sstevel@tonic-gate if (garp->n4g_ext_res) 8757c478bd9Sstevel@tonic-gate gesp = garp->n4g_ext_res; 8767c478bd9Sstevel@tonic-gate else 8777c478bd9Sstevel@tonic-gate gesp = ⩾ 8787c478bd9Sstevel@tonic-gate 8797c478bd9Sstevel@tonic-gate vap->va_mask = 0; 8807c478bd9Sstevel@tonic-gate 8817c478bd9Sstevel@tonic-gate /* Check to see if the vattr should be pre-filled */ 8827c478bd9Sstevel@tonic-gate if (argbmap & NFS4_VATTR_MASK) 8837c478bd9Sstevel@tonic-gate xdr_ga_prefill_vattr(garp, mi); 8847c478bd9Sstevel@tonic-gate 8857c478bd9Sstevel@tonic-gate if (argbmap & NFS4_STATFS_ATTR_MASK) 8867c478bd9Sstevel@tonic-gate xdr_ga_prefill_statvfs(gesp, mi); 8877c478bd9Sstevel@tonic-gate 8887c478bd9Sstevel@tonic-gate if (resbmap & 8897c478bd9Sstevel@tonic-gate (FATTR4_SUPPORTED_ATTRS_MASK | 8907c478bd9Sstevel@tonic-gate FATTR4_TYPE_MASK | 8917c478bd9Sstevel@tonic-gate FATTR4_FH_EXPIRE_TYPE_MASK | 8927c478bd9Sstevel@tonic-gate FATTR4_CHANGE_MASK | 8937c478bd9Sstevel@tonic-gate FATTR4_SIZE_MASK | 8947c478bd9Sstevel@tonic-gate FATTR4_LINK_SUPPORT_MASK | 8957c478bd9Sstevel@tonic-gate FATTR4_SYMLINK_SUPPORT_MASK | 8967c478bd9Sstevel@tonic-gate FATTR4_NAMED_ATTR_MASK)) { 8977c478bd9Sstevel@tonic-gate 8987c478bd9Sstevel@tonic-gate if (resbmap & FATTR4_SUPPORTED_ATTRS_MASK) { 8997c478bd9Sstevel@tonic-gate if (!xdr_bitmap4(xdrs, &gesp->n4g_suppattrs)) 9007c478bd9Sstevel@tonic-gate return (FALSE); 9017c478bd9Sstevel@tonic-gate } 9027c478bd9Sstevel@tonic-gate if (resbmap & FATTR4_TYPE_MASK) { 9037c478bd9Sstevel@tonic-gate if (!XDR_GETINT32(xdrs, (int *)&vap->va_type)) 9047c478bd9Sstevel@tonic-gate return (FALSE); 9057c478bd9Sstevel@tonic-gate 906*2c2d21e9SRichard Lowe if ((nfs_ftype4)vap->va_type < NF4REG || 907*2c2d21e9SRichard Lowe (nfs_ftype4)vap->va_type > NF4NAMEDATTR) 9087c478bd9Sstevel@tonic-gate vap->va_type = VBAD; 9097c478bd9Sstevel@tonic-gate else 9107c478bd9Sstevel@tonic-gate vap->va_type = nf4_to_vt[vap->va_type]; 9117c478bd9Sstevel@tonic-gate if (vap->va_type == VBLK) 9127c478bd9Sstevel@tonic-gate vap->va_blksize = DEV_BSIZE; 9137c478bd9Sstevel@tonic-gate 9147c478bd9Sstevel@tonic-gate vap->va_mask |= AT_TYPE; 9157c478bd9Sstevel@tonic-gate } 9167c478bd9Sstevel@tonic-gate if (resbmap & FATTR4_FH_EXPIRE_TYPE_MASK) { 9177c478bd9Sstevel@tonic-gate if (!XDR_GETINT32(xdrs, (int *)&gesp->n4g_fet)) 9187c478bd9Sstevel@tonic-gate return (FALSE); 9197c478bd9Sstevel@tonic-gate } 9207c478bd9Sstevel@tonic-gate if (resbmap & FATTR4_CHANGE_MASK) { 9217c478bd9Sstevel@tonic-gate if (!xdr_u_longlong_t(xdrs, 9220a701b1eSRobert Gordon (u_longlong_t *)&garp->n4g_change)) 9237c478bd9Sstevel@tonic-gate return (FALSE); 9247c478bd9Sstevel@tonic-gate garp->n4g_change_valid = 1; 9257c478bd9Sstevel@tonic-gate } 9267c478bd9Sstevel@tonic-gate if (resbmap & FATTR4_SIZE_MASK) { 9277c478bd9Sstevel@tonic-gate if (!xdr_u_longlong_t(xdrs, 9280a701b1eSRobert Gordon (u_longlong_t *)&vap->va_size)) 9297c478bd9Sstevel@tonic-gate return (FALSE); 9307c478bd9Sstevel@tonic-gate if (!NFS4_SIZE_OK(vap->va_size)) { 9317c478bd9Sstevel@tonic-gate garp->n4g_attrerr = EFBIG; 9327c478bd9Sstevel@tonic-gate garp->n4g_attrwhy = NFS4_GETATTR_ATSIZE_ERR; 9337c478bd9Sstevel@tonic-gate } else { 9347c478bd9Sstevel@tonic-gate vap->va_mask |= AT_SIZE; 9357c478bd9Sstevel@tonic-gate } 9367c478bd9Sstevel@tonic-gate } 9377c478bd9Sstevel@tonic-gate if (resbmap & FATTR4_LINK_SUPPORT_MASK) { 9387c478bd9Sstevel@tonic-gate if (!XDR_GETINT32(xdrs, (int *)&truefalse)) 9397c478bd9Sstevel@tonic-gate return (FALSE); 9407c478bd9Sstevel@tonic-gate gesp->n4g_pc4.pc4_link_support = 9410a701b1eSRobert Gordon (truefalse ? TRUE : FALSE); 9427c478bd9Sstevel@tonic-gate } 9437c478bd9Sstevel@tonic-gate if (resbmap & FATTR4_SYMLINK_SUPPORT_MASK) { 9447c478bd9Sstevel@tonic-gate if (!XDR_GETINT32(xdrs, (int *)&truefalse)) 9457c478bd9Sstevel@tonic-gate return (FALSE); 9467c478bd9Sstevel@tonic-gate gesp->n4g_pc4.pc4_symlink_support = 9470a701b1eSRobert Gordon (truefalse ? TRUE : FALSE); 9487c478bd9Sstevel@tonic-gate } 9497c478bd9Sstevel@tonic-gate if (resbmap & FATTR4_NAMED_ATTR_MASK) { 9507c478bd9Sstevel@tonic-gate if (!XDR_GETINT32(xdrs, (int *)&truefalse)) 9517c478bd9Sstevel@tonic-gate return (FALSE); 9527c478bd9Sstevel@tonic-gate gesp->n4g_pc4.pc4_xattr_exists = TRUE; 9537c478bd9Sstevel@tonic-gate gesp->n4g_pc4.pc4_xattr_exists = 9540a701b1eSRobert Gordon (truefalse ? TRUE : FALSE); 9557c478bd9Sstevel@tonic-gate } 9567c478bd9Sstevel@tonic-gate } 9577c478bd9Sstevel@tonic-gate if (resbmap & 9587c478bd9Sstevel@tonic-gate (FATTR4_FSID_MASK | 9597c478bd9Sstevel@tonic-gate FATTR4_UNIQUE_HANDLES_MASK | 9607c478bd9Sstevel@tonic-gate FATTR4_LEASE_TIME_MASK | 9617c478bd9Sstevel@tonic-gate FATTR4_RDATTR_ERROR_MASK)) { 9627c478bd9Sstevel@tonic-gate 9637c478bd9Sstevel@tonic-gate if (resbmap & FATTR4_FSID_MASK) { 9640a701b1eSRobert Gordon if ((!xdr_u_longlong_t(xdrs, 9650a701b1eSRobert Gordon (u_longlong_t *)&garp->n4g_fsid.major)) || 9660a701b1eSRobert Gordon (!xdr_u_longlong_t(xdrs, 9670a701b1eSRobert Gordon (u_longlong_t *)&garp->n4g_fsid.minor))) 9687c478bd9Sstevel@tonic-gate return (FALSE); 9690a701b1eSRobert Gordon garp->n4g_fsid_valid = 1; 9707c478bd9Sstevel@tonic-gate } 9717c478bd9Sstevel@tonic-gate if (resbmap & FATTR4_UNIQUE_HANDLES_MASK) { 9727c478bd9Sstevel@tonic-gate if (!XDR_GETINT32(xdrs, (int *)&truefalse)) 9737c478bd9Sstevel@tonic-gate return (FALSE); 9747c478bd9Sstevel@tonic-gate gesp->n4g_pc4.pc4_unique_handles = 9750a701b1eSRobert Gordon (truefalse ? TRUE : FALSE); 9767c478bd9Sstevel@tonic-gate } 9777c478bd9Sstevel@tonic-gate if (resbmap & FATTR4_LEASE_TIME_MASK) { 9787c478bd9Sstevel@tonic-gate if (!XDR_GETINT32(xdrs, (int *)&gesp->n4g_leasetime)) 9797c478bd9Sstevel@tonic-gate return (FALSE); 9807c478bd9Sstevel@tonic-gate } 9817c478bd9Sstevel@tonic-gate if (resbmap & FATTR4_RDATTR_ERROR_MASK) { 9827c478bd9Sstevel@tonic-gate if (!XDR_GETINT32(xdrs, 9830a701b1eSRobert Gordon (int *)&gesp->n4g_rdattr_error)) 9847c478bd9Sstevel@tonic-gate return (FALSE); 9857c478bd9Sstevel@tonic-gate } 9867c478bd9Sstevel@tonic-gate } 9877c478bd9Sstevel@tonic-gate if (resbmap & 9887c478bd9Sstevel@tonic-gate (FATTR4_ACL_MASK | 9897c478bd9Sstevel@tonic-gate FATTR4_ACLSUPPORT_MASK | 9907c478bd9Sstevel@tonic-gate FATTR4_ARCHIVE_MASK | 9917c478bd9Sstevel@tonic-gate FATTR4_CANSETTIME_MASK)) { 9927c478bd9Sstevel@tonic-gate 9937c478bd9Sstevel@tonic-gate if (resbmap & FATTR4_ACL_MASK) { 9947c478bd9Sstevel@tonic-gate fattr4_acl acl; 9957c478bd9Sstevel@tonic-gate 9967c478bd9Sstevel@tonic-gate acl.fattr4_acl_val = NULL; 9977c478bd9Sstevel@tonic-gate acl.fattr4_acl_len = 0; 9987c478bd9Sstevel@tonic-gate 9997c478bd9Sstevel@tonic-gate if (!xdr_fattr4_acl(xdrs, &acl)) 10007c478bd9Sstevel@tonic-gate return (FALSE); 10017c478bd9Sstevel@tonic-gate 10027c478bd9Sstevel@tonic-gate vsap->vsa_aclcnt = acl.fattr4_acl_len; 10037c478bd9Sstevel@tonic-gate vsap->vsa_aclentp = acl.fattr4_acl_val; 10047c478bd9Sstevel@tonic-gate vsap->vsa_mask = VSA_ACE | VSA_ACECNT; 1005da6c28aaSamw vsap->vsa_aclentsz = vsap->vsa_aclcnt * sizeof (ace_t); 10067c478bd9Sstevel@tonic-gate 10077c478bd9Sstevel@tonic-gate } 10087c478bd9Sstevel@tonic-gate if (resbmap & FATTR4_ACLSUPPORT_MASK) { 10097c478bd9Sstevel@tonic-gate if (!XDR_GETINT32(xdrs, (int *)&gesp->n4g_aclsupport)) 10107c478bd9Sstevel@tonic-gate return (FALSE); 10117c478bd9Sstevel@tonic-gate } 10127c478bd9Sstevel@tonic-gate if (resbmap & FATTR4_ARCHIVE_MASK) { 10137c478bd9Sstevel@tonic-gate ASSERT(0); 10147c478bd9Sstevel@tonic-gate } 10157c478bd9Sstevel@tonic-gate if (resbmap & FATTR4_CANSETTIME_MASK) { 10167c478bd9Sstevel@tonic-gate if (!XDR_GETINT32(xdrs, (int *)&truefalse)) 10177c478bd9Sstevel@tonic-gate return (FALSE); 10187c478bd9Sstevel@tonic-gate gesp->n4g_pc4.pc4_cansettime = 10190a701b1eSRobert Gordon (truefalse ? TRUE : FALSE); 10207c478bd9Sstevel@tonic-gate } 10217c478bd9Sstevel@tonic-gate } 10227c478bd9Sstevel@tonic-gate if (resbmap & 10237c478bd9Sstevel@tonic-gate (FATTR4_CASE_INSENSITIVE_MASK | 10247c478bd9Sstevel@tonic-gate FATTR4_CASE_PRESERVING_MASK | 10257c478bd9Sstevel@tonic-gate FATTR4_CHOWN_RESTRICTED_MASK | 10267c478bd9Sstevel@tonic-gate FATTR4_FILEHANDLE_MASK | 10277c478bd9Sstevel@tonic-gate FATTR4_FILEID_MASK | 10287c478bd9Sstevel@tonic-gate FATTR4_FILES_AVAIL_MASK | 10297c478bd9Sstevel@tonic-gate FATTR4_FILES_FREE_MASK | 10307c478bd9Sstevel@tonic-gate FATTR4_FILES_TOTAL_MASK)) { 10317c478bd9Sstevel@tonic-gate 10327c478bd9Sstevel@tonic-gate if (resbmap & FATTR4_CASE_INSENSITIVE_MASK) { 10337c478bd9Sstevel@tonic-gate if (!XDR_GETINT32(xdrs, (int *)&truefalse)) 10347c478bd9Sstevel@tonic-gate return (FALSE); 10357c478bd9Sstevel@tonic-gate gesp->n4g_pc4.pc4_case_insensitive = 10360a701b1eSRobert Gordon (truefalse ? TRUE : FALSE); 10377c478bd9Sstevel@tonic-gate } 10387c478bd9Sstevel@tonic-gate if (resbmap & FATTR4_CASE_PRESERVING_MASK) { 10397c478bd9Sstevel@tonic-gate if (!XDR_GETINT32(xdrs, (int *)&truefalse)) 10407c478bd9Sstevel@tonic-gate return (FALSE); 10417c478bd9Sstevel@tonic-gate gesp->n4g_pc4.pc4_case_preserving = 10420a701b1eSRobert Gordon (truefalse ? TRUE : FALSE); 10437c478bd9Sstevel@tonic-gate } 10447c478bd9Sstevel@tonic-gate if (resbmap & FATTR4_CHOWN_RESTRICTED_MASK) { 10457c478bd9Sstevel@tonic-gate if (!XDR_GETINT32(xdrs, (int *)&truefalse)) 10467c478bd9Sstevel@tonic-gate return (FALSE); 10477c478bd9Sstevel@tonic-gate gesp->n4g_pc4.pc4_chown_restricted = 10480a701b1eSRobert Gordon (truefalse ? TRUE : FALSE); 10497c478bd9Sstevel@tonic-gate } 10507c478bd9Sstevel@tonic-gate if (resbmap & FATTR4_FILEHANDLE_MASK) { 10517c478bd9Sstevel@tonic-gate gesp->n4g_fh_u.nfs_fh4_alt.len = 0; 10527c478bd9Sstevel@tonic-gate gesp->n4g_fh_u.nfs_fh4_alt.val = 10530a701b1eSRobert Gordon gesp->n4g_fh_u.nfs_fh4_alt.data; 10547c478bd9Sstevel@tonic-gate if (!xdr_bytes(xdrs, 10557c478bd9Sstevel@tonic-gate (char **)&gesp->n4g_fh_u.n4g_fh.nfs_fh4_val, 10567c478bd9Sstevel@tonic-gate (uint_t *)&gesp->n4g_fh_u.n4g_fh.nfs_fh4_len, 10577c478bd9Sstevel@tonic-gate NFS4_FHSIZE)) 10587c478bd9Sstevel@tonic-gate return (FALSE); 10597c478bd9Sstevel@tonic-gate } 10607c478bd9Sstevel@tonic-gate if (resbmap & FATTR4_FILEID_MASK) { 10617c478bd9Sstevel@tonic-gate if (!xdr_u_longlong_t(xdrs, 10620a701b1eSRobert Gordon (u_longlong_t *)&vap->va_nodeid)) 10637c478bd9Sstevel@tonic-gate return (FALSE); 10647c478bd9Sstevel@tonic-gate vap->va_mask |= AT_NODEID; 10657c478bd9Sstevel@tonic-gate } 10667c478bd9Sstevel@tonic-gate if (resbmap & FATTR4_FILES_AVAIL_MASK) { 10677c478bd9Sstevel@tonic-gate if (!xdr_u_longlong_t(xdrs, 10680a701b1eSRobert Gordon (u_longlong_t *)&gesp->n4g_sb.f_favail)) 10697c478bd9Sstevel@tonic-gate return (FALSE); 10707c478bd9Sstevel@tonic-gate } 10717c478bd9Sstevel@tonic-gate if (resbmap & FATTR4_FILES_FREE_MASK) { 10727c478bd9Sstevel@tonic-gate if (!xdr_u_longlong_t(xdrs, 10730a701b1eSRobert Gordon (u_longlong_t *)&gesp->n4g_sb.f_ffree)) 10747c478bd9Sstevel@tonic-gate return (FALSE); 10757c478bd9Sstevel@tonic-gate } 10767c478bd9Sstevel@tonic-gate if (resbmap & FATTR4_FILES_TOTAL_MASK) { 10777c478bd9Sstevel@tonic-gate if (!xdr_u_longlong_t(xdrs, 10780a701b1eSRobert Gordon (u_longlong_t *)&gesp->n4g_sb.f_files)) 10797c478bd9Sstevel@tonic-gate return (FALSE); 10807c478bd9Sstevel@tonic-gate } 10817c478bd9Sstevel@tonic-gate } 10827c478bd9Sstevel@tonic-gate if (resbmap & 10837c478bd9Sstevel@tonic-gate (FATTR4_FS_LOCATIONS_MASK | 10847c478bd9Sstevel@tonic-gate FATTR4_HIDDEN_MASK | 10857c478bd9Sstevel@tonic-gate FATTR4_HOMOGENEOUS_MASK)) { 10867c478bd9Sstevel@tonic-gate 10877c478bd9Sstevel@tonic-gate if (resbmap & FATTR4_FS_LOCATIONS_MASK) { 10882f172c55SRobert Thurlow if (!xdr_fattr4_fs_locations(xdrs, 10892f172c55SRobert Thurlow &gesp->n4g_fslocations)) 10902f172c55SRobert Thurlow return (FALSE); 10917c478bd9Sstevel@tonic-gate } 10927c478bd9Sstevel@tonic-gate if (resbmap & FATTR4_HIDDEN_MASK) { 10937c478bd9Sstevel@tonic-gate ASSERT(0); 10947c478bd9Sstevel@tonic-gate } 10957c478bd9Sstevel@tonic-gate if (resbmap & FATTR4_HOMOGENEOUS_MASK) { 10967c478bd9Sstevel@tonic-gate if (!XDR_GETINT32(xdrs, (int *)&truefalse)) 10977c478bd9Sstevel@tonic-gate return (FALSE); 10987c478bd9Sstevel@tonic-gate gesp->n4g_pc4.pc4_homogeneous = 10990a701b1eSRobert Gordon (truefalse ? TRUE : FALSE); 11007c478bd9Sstevel@tonic-gate } 11017c478bd9Sstevel@tonic-gate } 11027c478bd9Sstevel@tonic-gate if (resbmap & 11037c478bd9Sstevel@tonic-gate (FATTR4_MAXFILESIZE_MASK | 11047c478bd9Sstevel@tonic-gate FATTR4_MAXLINK_MASK | 11057c478bd9Sstevel@tonic-gate FATTR4_MAXNAME_MASK | 11067c478bd9Sstevel@tonic-gate FATTR4_MAXREAD_MASK | 11077c478bd9Sstevel@tonic-gate FATTR4_MAXWRITE_MASK)) { 11087c478bd9Sstevel@tonic-gate 11097c478bd9Sstevel@tonic-gate if (resbmap & FATTR4_MAXFILESIZE_MASK) { 11107c478bd9Sstevel@tonic-gate if (!xdr_u_longlong_t(xdrs, 11110a701b1eSRobert Gordon (u_longlong_t *)&gesp->n4g_maxfilesize)) 11127c478bd9Sstevel@tonic-gate return (FALSE); 11137c478bd9Sstevel@tonic-gate } 11147c478bd9Sstevel@tonic-gate if (resbmap & FATTR4_MAXLINK_MASK) { 11157c478bd9Sstevel@tonic-gate if (!XDR_GETINT32(xdrs, 11160a701b1eSRobert Gordon (int *)&gesp->n4g_pc4.pc4_link_max)) 11177c478bd9Sstevel@tonic-gate return (FALSE); 11187c478bd9Sstevel@tonic-gate } 11197c478bd9Sstevel@tonic-gate if (resbmap & FATTR4_MAXNAME_MASK) { 11207c478bd9Sstevel@tonic-gate if (!XDR_GETINT32(xdrs, 11210a701b1eSRobert Gordon (int *)&gesp->n4g_pc4.pc4_name_max)) 11227c478bd9Sstevel@tonic-gate return (FALSE); 11237c478bd9Sstevel@tonic-gate gesp->n4g_sb.f_namemax = gesp->n4g_pc4.pc4_name_max; 11247c478bd9Sstevel@tonic-gate } 11257c478bd9Sstevel@tonic-gate if (resbmap & FATTR4_MAXREAD_MASK) { 11267c478bd9Sstevel@tonic-gate if (!xdr_u_longlong_t(xdrs, 11270a701b1eSRobert Gordon (u_longlong_t *)&gesp->n4g_maxread)) 11287c478bd9Sstevel@tonic-gate return (FALSE); 11297c478bd9Sstevel@tonic-gate } 11307c478bd9Sstevel@tonic-gate if (resbmap & FATTR4_MAXWRITE_MASK) { 11317c478bd9Sstevel@tonic-gate if (!xdr_u_longlong_t(xdrs, 11320a701b1eSRobert Gordon (u_longlong_t *)&gesp->n4g_maxwrite)) 11337c478bd9Sstevel@tonic-gate return (FALSE); 11347c478bd9Sstevel@tonic-gate } 11357c478bd9Sstevel@tonic-gate } 11367c478bd9Sstevel@tonic-gate if (resbmap & 11377c478bd9Sstevel@tonic-gate (FATTR4_MIMETYPE_MASK | 11387c478bd9Sstevel@tonic-gate FATTR4_MODE_MASK | 11397c478bd9Sstevel@tonic-gate FATTR4_NO_TRUNC_MASK | 11407c478bd9Sstevel@tonic-gate FATTR4_NUMLINKS_MASK)) { 11417c478bd9Sstevel@tonic-gate 11427c478bd9Sstevel@tonic-gate if (resbmap & FATTR4_MIMETYPE_MASK) { 11437c478bd9Sstevel@tonic-gate ASSERT(0); 11447c478bd9Sstevel@tonic-gate } 11457c478bd9Sstevel@tonic-gate if (resbmap & FATTR4_MODE_MASK) { 11467c478bd9Sstevel@tonic-gate if (!XDR_GETINT32(xdrs, (int *)&vap->va_mode)) 11477c478bd9Sstevel@tonic-gate return (FALSE); 11487c478bd9Sstevel@tonic-gate vap->va_mask |= AT_MODE; 11497c478bd9Sstevel@tonic-gate } 11507c478bd9Sstevel@tonic-gate if (resbmap & FATTR4_NO_TRUNC_MASK) { 11517c478bd9Sstevel@tonic-gate if (!XDR_GETINT32(xdrs, (int *)&truefalse)) 11527c478bd9Sstevel@tonic-gate return (FALSE); 11537c478bd9Sstevel@tonic-gate gesp->n4g_pc4.pc4_no_trunc = 11540a701b1eSRobert Gordon (truefalse ? TRUE : FALSE); 11557c478bd9Sstevel@tonic-gate } 11567c478bd9Sstevel@tonic-gate if (resbmap & FATTR4_NUMLINKS_MASK) { 11577c478bd9Sstevel@tonic-gate if (!XDR_GETINT32(xdrs, (int *)&vap->va_nlink)) 11587c478bd9Sstevel@tonic-gate return (FALSE); 11597c478bd9Sstevel@tonic-gate vap->va_mask |= AT_NLINK; 11607c478bd9Sstevel@tonic-gate } 11617c478bd9Sstevel@tonic-gate } 11627c478bd9Sstevel@tonic-gate if (resbmap & 11637c478bd9Sstevel@tonic-gate (FATTR4_OWNER_MASK | 11647c478bd9Sstevel@tonic-gate FATTR4_OWNER_GROUP_MASK | 11657c478bd9Sstevel@tonic-gate FATTR4_QUOTA_AVAIL_HARD_MASK | 11667c478bd9Sstevel@tonic-gate FATTR4_QUOTA_AVAIL_SOFT_MASK)) { 11677c478bd9Sstevel@tonic-gate 11687c478bd9Sstevel@tonic-gate if (resbmap & FATTR4_OWNER_MASK) { 11697c478bd9Sstevel@tonic-gate uint_t *owner_length, ol; 11707c478bd9Sstevel@tonic-gate char *owner_val = NULL; 11717c478bd9Sstevel@tonic-gate char *owner_alloc = NULL; 11727c478bd9Sstevel@tonic-gate utf8string ov; 11737c478bd9Sstevel@tonic-gate int error; 11747c478bd9Sstevel@tonic-gate 11757c478bd9Sstevel@tonic-gate /* get the OWNER_LENGTH */ 11767c478bd9Sstevel@tonic-gate if (!xdr_u_int(xdrs, &ol)) 11777c478bd9Sstevel@tonic-gate return (FALSE); 11787c478bd9Sstevel@tonic-gate 11797c478bd9Sstevel@tonic-gate /* Manage the owner length location */ 11807c478bd9Sstevel@tonic-gate if (pug && ol <= MAX_OG_NAME) { 11817c478bd9Sstevel@tonic-gate owner_length = &pug->u_curr.utf8string_len; 11827c478bd9Sstevel@tonic-gate *owner_length = ol; 11837c478bd9Sstevel@tonic-gate } else { 11847c478bd9Sstevel@tonic-gate owner_length = &ol; 11857c478bd9Sstevel@tonic-gate } 11867c478bd9Sstevel@tonic-gate 11877c478bd9Sstevel@tonic-gate /* find memory to store the decode */ 11887c478bd9Sstevel@tonic-gate if (*owner_length > MAX_OG_NAME || pug == NULL) 11897c478bd9Sstevel@tonic-gate owner_val = owner_alloc = 11900a701b1eSRobert Gordon kmem_alloc(*owner_length, KM_SLEEP); 11917c478bd9Sstevel@tonic-gate else 11927c478bd9Sstevel@tonic-gate owner_val = pug->u_curr.utf8string_val; 11937c478bd9Sstevel@tonic-gate 11947c478bd9Sstevel@tonic-gate /* get the OWNER string */ 11957c478bd9Sstevel@tonic-gate if (!xdr_opaque(xdrs, owner_val, *owner_length)) { 11967c478bd9Sstevel@tonic-gate if (owner_alloc) 11977c478bd9Sstevel@tonic-gate kmem_free(owner_alloc, *owner_length); 11987c478bd9Sstevel@tonic-gate return (FALSE); 11997c478bd9Sstevel@tonic-gate } 12007c478bd9Sstevel@tonic-gate 12017c478bd9Sstevel@tonic-gate /* Optimize for matching if called for */ 12027c478bd9Sstevel@tonic-gate if (pug && 12037c478bd9Sstevel@tonic-gate *owner_length == pug->u_last.utf8string_len && 12047c478bd9Sstevel@tonic-gate bcmp(owner_val, pug->u_last.utf8string_val, 12050a701b1eSRobert Gordon *owner_length) == 0) { 12067c478bd9Sstevel@tonic-gate vap->va_uid = pug->uid; 12077c478bd9Sstevel@tonic-gate vap->va_mask |= AT_UID; 12087c478bd9Sstevel@tonic-gate } else { 12097c478bd9Sstevel@tonic-gate uid_t uid; 12107c478bd9Sstevel@tonic-gate 12117c478bd9Sstevel@tonic-gate ov.utf8string_len = *owner_length; 12127c478bd9Sstevel@tonic-gate ov.utf8string_val = owner_val; 12137c478bd9Sstevel@tonic-gate error = nfs_idmap_str_uid(&ov, &uid, FALSE); 12147c478bd9Sstevel@tonic-gate /* 12157c478bd9Sstevel@tonic-gate * String was mapped, but to nobody because 12167c478bd9Sstevel@tonic-gate * we are nfsmapid, indicate it should not 12177c478bd9Sstevel@tonic-gate * be cached. 12187c478bd9Sstevel@tonic-gate */ 12197c478bd9Sstevel@tonic-gate if (error == ENOTSUP) { 12207c478bd9Sstevel@tonic-gate error = 0; 12217c478bd9Sstevel@tonic-gate garp->n4g_attrwhy = 12220a701b1eSRobert Gordon NFS4_GETATTR_NOCACHE_OK; 12237c478bd9Sstevel@tonic-gate } 12247c478bd9Sstevel@tonic-gate 12257c478bd9Sstevel@tonic-gate if (error) { 12267c478bd9Sstevel@tonic-gate garp->n4g_attrerr = error; 12277c478bd9Sstevel@tonic-gate garp->n4g_attrwhy = 12280a701b1eSRobert Gordon NFS4_GETATTR_ATUID_ERR; 12297c478bd9Sstevel@tonic-gate } else { 12307c478bd9Sstevel@tonic-gate vap->va_uid = uid; 12317c478bd9Sstevel@tonic-gate vap->va_mask |= AT_UID; 12327c478bd9Sstevel@tonic-gate if (pug && ol <= MAX_OG_NAME) { 12337c478bd9Sstevel@tonic-gate pug->uid = uid; 12347c478bd9Sstevel@tonic-gate U_SWAP_CURR_LAST(pug); 12357c478bd9Sstevel@tonic-gate } 12367c478bd9Sstevel@tonic-gate } 12377c478bd9Sstevel@tonic-gate if (owner_alloc) 12387c478bd9Sstevel@tonic-gate kmem_free(owner_alloc, *owner_length); 12397c478bd9Sstevel@tonic-gate } 12407c478bd9Sstevel@tonic-gate } 12417c478bd9Sstevel@tonic-gate if (resbmap & FATTR4_OWNER_GROUP_MASK) { 12427c478bd9Sstevel@tonic-gate uint_t *group_length, gl; 12437c478bd9Sstevel@tonic-gate char *group_val = NULL; 12447c478bd9Sstevel@tonic-gate char *group_alloc = NULL; 12457c478bd9Sstevel@tonic-gate utf8string gv; 12467c478bd9Sstevel@tonic-gate int error; 12477c478bd9Sstevel@tonic-gate 12487c478bd9Sstevel@tonic-gate /* get the OWNER_GROUP_LENGTH */ 12497c478bd9Sstevel@tonic-gate if (!xdr_u_int(xdrs, &gl)) 12507c478bd9Sstevel@tonic-gate return (FALSE); 12517c478bd9Sstevel@tonic-gate 12527c478bd9Sstevel@tonic-gate /* Manage the group length location */ 12537c478bd9Sstevel@tonic-gate if (pug && gl <= MAX_OG_NAME) { 12547c478bd9Sstevel@tonic-gate group_length = &pug->g_curr.utf8string_len; 12557c478bd9Sstevel@tonic-gate *group_length = gl; 12567c478bd9Sstevel@tonic-gate } else { 12577c478bd9Sstevel@tonic-gate group_length = ≷ 12587c478bd9Sstevel@tonic-gate } 12597c478bd9Sstevel@tonic-gate 12607c478bd9Sstevel@tonic-gate /* find memory to store the decode */ 12617c478bd9Sstevel@tonic-gate if (*group_length > MAX_OG_NAME || pug == NULL) 12627c478bd9Sstevel@tonic-gate group_val = group_alloc = 12630a701b1eSRobert Gordon kmem_alloc(*group_length, KM_SLEEP); 12647c478bd9Sstevel@tonic-gate else 12657c478bd9Sstevel@tonic-gate group_val = pug->g_curr.utf8string_val; 12667c478bd9Sstevel@tonic-gate 12677c478bd9Sstevel@tonic-gate /* get the OWNER_GROUP string */ 12687c478bd9Sstevel@tonic-gate if (!xdr_opaque(xdrs, group_val, *group_length)) { 12697c478bd9Sstevel@tonic-gate if (group_alloc) 12707c478bd9Sstevel@tonic-gate kmem_free(group_alloc, *group_length); 12717c478bd9Sstevel@tonic-gate return (FALSE); 12727c478bd9Sstevel@tonic-gate } 12737c478bd9Sstevel@tonic-gate 12747c478bd9Sstevel@tonic-gate /* Optimize for matching if called for */ 12757c478bd9Sstevel@tonic-gate if (pug && 12767c478bd9Sstevel@tonic-gate *group_length == pug->g_last.utf8string_len && 12777c478bd9Sstevel@tonic-gate bcmp(group_val, pug->g_last.utf8string_val, 12780a701b1eSRobert Gordon *group_length) == 0) { 12797c478bd9Sstevel@tonic-gate vap->va_gid = pug->gid; 12807c478bd9Sstevel@tonic-gate vap->va_mask |= AT_GID; 12817c478bd9Sstevel@tonic-gate } else { 12827c478bd9Sstevel@tonic-gate uid_t gid; 12837c478bd9Sstevel@tonic-gate 12847c478bd9Sstevel@tonic-gate gv.utf8string_len = *group_length; 12857c478bd9Sstevel@tonic-gate gv.utf8string_val = group_val; 12867c478bd9Sstevel@tonic-gate error = nfs_idmap_str_gid(&gv, &gid, FALSE); 12877c478bd9Sstevel@tonic-gate /* 12887c478bd9Sstevel@tonic-gate * String was mapped, but to nobody because 12897c478bd9Sstevel@tonic-gate * we are nfsmapid, indicate it should not 12907c478bd9Sstevel@tonic-gate * be cached. 12917c478bd9Sstevel@tonic-gate */ 12927c478bd9Sstevel@tonic-gate if (error == ENOTSUP) { 12937c478bd9Sstevel@tonic-gate error = 0; 12947c478bd9Sstevel@tonic-gate garp->n4g_attrwhy = 12950a701b1eSRobert Gordon NFS4_GETATTR_NOCACHE_OK; 12967c478bd9Sstevel@tonic-gate } 12977c478bd9Sstevel@tonic-gate 12987c478bd9Sstevel@tonic-gate if (error) { 12997c478bd9Sstevel@tonic-gate garp->n4g_attrerr = error; 13007c478bd9Sstevel@tonic-gate garp->n4g_attrwhy = 13010a701b1eSRobert Gordon NFS4_GETATTR_ATGID_ERR; 13027c478bd9Sstevel@tonic-gate } else { 13037c478bd9Sstevel@tonic-gate vap->va_gid = gid; 13047c478bd9Sstevel@tonic-gate vap->va_mask |= AT_GID; 13057c478bd9Sstevel@tonic-gate if (pug && gl <= MAX_OG_NAME) { 13067c478bd9Sstevel@tonic-gate pug->gid = gid; 13077c478bd9Sstevel@tonic-gate G_SWAP_CURR_LAST(pug); 13087c478bd9Sstevel@tonic-gate } 13097c478bd9Sstevel@tonic-gate } 13107c478bd9Sstevel@tonic-gate if (group_alloc) { 13117c478bd9Sstevel@tonic-gate kmem_free(group_alloc, *group_length); 13127c478bd9Sstevel@tonic-gate } 13137c478bd9Sstevel@tonic-gate } 13147c478bd9Sstevel@tonic-gate } 13157c478bd9Sstevel@tonic-gate if (resbmap & FATTR4_QUOTA_AVAIL_HARD_MASK) { 13167c478bd9Sstevel@tonic-gate ASSERT(0); 13177c478bd9Sstevel@tonic-gate } 13187c478bd9Sstevel@tonic-gate if (resbmap & FATTR4_QUOTA_AVAIL_SOFT_MASK) { 13197c478bd9Sstevel@tonic-gate ASSERT(0); 13207c478bd9Sstevel@tonic-gate } 13217c478bd9Sstevel@tonic-gate } 13227c478bd9Sstevel@tonic-gate if (resbmap & 13237c478bd9Sstevel@tonic-gate (FATTR4_QUOTA_USED_MASK | 13247c478bd9Sstevel@tonic-gate FATTR4_SPACE_AVAIL_MASK | 13257c478bd9Sstevel@tonic-gate FATTR4_SPACE_FREE_MASK | 13267c478bd9Sstevel@tonic-gate FATTR4_SPACE_TOTAL_MASK | 13277c478bd9Sstevel@tonic-gate FATTR4_SPACE_USED_MASK | 13287c478bd9Sstevel@tonic-gate FATTR4_SYSTEM_MASK)) { 13297c478bd9Sstevel@tonic-gate 13307c478bd9Sstevel@tonic-gate if (resbmap & FATTR4_QUOTA_USED_MASK) { 13317c478bd9Sstevel@tonic-gate ASSERT(0); 13327c478bd9Sstevel@tonic-gate } 13337c478bd9Sstevel@tonic-gate if (resbmap & FATTR4_RAWDEV_MASK) { 13347c478bd9Sstevel@tonic-gate fattr4_rawdev rawdev; 13357c478bd9Sstevel@tonic-gate if (!xdr_fattr4_rawdev(xdrs, &rawdev)) 13367c478bd9Sstevel@tonic-gate return (FALSE); 13377c478bd9Sstevel@tonic-gate 13387c478bd9Sstevel@tonic-gate if (vap->va_type == VCHR || vap->va_type == VBLK) { 13397c478bd9Sstevel@tonic-gate vap->va_rdev = makedevice(rawdev.specdata1, 13400a701b1eSRobert Gordon rawdev.specdata2); 13417c478bd9Sstevel@tonic-gate } else { 13427c478bd9Sstevel@tonic-gate vap->va_rdev = 0; 13437c478bd9Sstevel@tonic-gate } 13447c478bd9Sstevel@tonic-gate vap->va_mask |= AT_RDEV; 13457c478bd9Sstevel@tonic-gate } 13467c478bd9Sstevel@tonic-gate if (resbmap & FATTR4_SPACE_AVAIL_MASK) { 13477c478bd9Sstevel@tonic-gate if (!xdr_u_longlong_t(xdrs, 13480a701b1eSRobert Gordon (u_longlong_t *)&gesp->n4g_sb.f_bavail)) 13497c478bd9Sstevel@tonic-gate return (FALSE); 13507c478bd9Sstevel@tonic-gate gesp->n4g_sb.f_bavail /= DEV_BSIZE; 13517c478bd9Sstevel@tonic-gate } 13527c478bd9Sstevel@tonic-gate if (resbmap & FATTR4_SPACE_FREE_MASK) { 13537c478bd9Sstevel@tonic-gate if (!xdr_u_longlong_t(xdrs, 13540a701b1eSRobert Gordon (u_longlong_t *)&gesp->n4g_sb.f_bfree)) 13557c478bd9Sstevel@tonic-gate return (FALSE); 13567c478bd9Sstevel@tonic-gate gesp->n4g_sb.f_bfree /= DEV_BSIZE; 13577c478bd9Sstevel@tonic-gate } 13587c478bd9Sstevel@tonic-gate if (resbmap & FATTR4_SPACE_TOTAL_MASK) { 13597c478bd9Sstevel@tonic-gate if (!xdr_u_longlong_t(xdrs, 13600a701b1eSRobert Gordon (u_longlong_t *)&gesp->n4g_sb.f_blocks)) 13617c478bd9Sstevel@tonic-gate return (FALSE); 13627c478bd9Sstevel@tonic-gate gesp->n4g_sb.f_blocks /= DEV_BSIZE; 13637c478bd9Sstevel@tonic-gate } 13647c478bd9Sstevel@tonic-gate if (resbmap & FATTR4_SPACE_USED_MASK) { 13657c478bd9Sstevel@tonic-gate uint64_t space_used; 13667c478bd9Sstevel@tonic-gate if (!xdr_u_longlong_t(xdrs, 13670a701b1eSRobert Gordon (u_longlong_t *)&space_used)) 13687c478bd9Sstevel@tonic-gate return (FALSE); 13697c478bd9Sstevel@tonic-gate 13707c478bd9Sstevel@tonic-gate /* Compute space depending on device type */ 13717c478bd9Sstevel@tonic-gate ASSERT((vap->va_mask & AT_TYPE)); 13727c478bd9Sstevel@tonic-gate if (vap->va_type == VREG || vap->va_type == VDIR || 13737c478bd9Sstevel@tonic-gate vap->va_type == VLNK) { 13747c478bd9Sstevel@tonic-gate vap->va_nblocks = (u_longlong_t) 13750a701b1eSRobert Gordon ((space_used + (offset4)DEV_BSIZE - 13760a701b1eSRobert Gordon (offset4)1) / (offset4)DEV_BSIZE); 13777c478bd9Sstevel@tonic-gate } else { 13787c478bd9Sstevel@tonic-gate vap->va_nblocks = 0; 13797c478bd9Sstevel@tonic-gate } 13807c478bd9Sstevel@tonic-gate vap->va_mask |= AT_NBLOCKS; 13817c478bd9Sstevel@tonic-gate } 13827c478bd9Sstevel@tonic-gate if (resbmap & FATTR4_SYSTEM_MASK) { 13837c478bd9Sstevel@tonic-gate ASSERT(0); 13847c478bd9Sstevel@tonic-gate } 13857c478bd9Sstevel@tonic-gate } 13867c478bd9Sstevel@tonic-gate if (resbmap & 13877c478bd9Sstevel@tonic-gate (FATTR4_TIME_ACCESS_MASK | 13887c478bd9Sstevel@tonic-gate FATTR4_TIME_ACCESS_SET_MASK | 13897c478bd9Sstevel@tonic-gate FATTR4_TIME_BACKUP_MASK | 13907c478bd9Sstevel@tonic-gate FATTR4_TIME_CREATE_MASK | 13917c478bd9Sstevel@tonic-gate FATTR4_TIME_DELTA_MASK | 13927c478bd9Sstevel@tonic-gate FATTR4_TIME_METADATA_MASK | 13937c478bd9Sstevel@tonic-gate FATTR4_TIME_MODIFY_MASK | 13947c478bd9Sstevel@tonic-gate FATTR4_TIME_MODIFY_SET_MASK | 13957c478bd9Sstevel@tonic-gate FATTR4_MOUNTED_ON_FILEID_MASK)) { 13967c478bd9Sstevel@tonic-gate 13977c478bd9Sstevel@tonic-gate if (resbmap & FATTR4_TIME_ACCESS_MASK) { 13987c478bd9Sstevel@tonic-gate nfstime4 atime; 13997c478bd9Sstevel@tonic-gate int error; 14007c478bd9Sstevel@tonic-gate 14017c478bd9Sstevel@tonic-gate if (!xdr_longlong_t(xdrs, 14020a701b1eSRobert Gordon (longlong_t *)&atime.seconds)) 14037c478bd9Sstevel@tonic-gate return (FALSE); 14047c478bd9Sstevel@tonic-gate if (!XDR_GETINT32(xdrs, (int *)&atime.nseconds)) 14057c478bd9Sstevel@tonic-gate return (FALSE); 14067c478bd9Sstevel@tonic-gate error = nfs4_time_ntov(&atime, &vap->va_atime); 14077c478bd9Sstevel@tonic-gate if (error) { 14087c478bd9Sstevel@tonic-gate garp->n4g_attrerr = error; 14097c478bd9Sstevel@tonic-gate garp->n4g_attrwhy = NFS4_GETATTR_ATATIME_ERR; 14107c478bd9Sstevel@tonic-gate } 14117c478bd9Sstevel@tonic-gate vap->va_mask |= AT_ATIME; 14127c478bd9Sstevel@tonic-gate } 14137c478bd9Sstevel@tonic-gate if (resbmap & FATTR4_TIME_ACCESS_SET_MASK) { 14147c478bd9Sstevel@tonic-gate ASSERT(0); 14157c478bd9Sstevel@tonic-gate } 14167c478bd9Sstevel@tonic-gate if (resbmap & FATTR4_TIME_BACKUP_MASK) { 14177c478bd9Sstevel@tonic-gate ASSERT(0); 14187c478bd9Sstevel@tonic-gate } 14197c478bd9Sstevel@tonic-gate if (resbmap & FATTR4_TIME_CREATE_MASK) { 14207c478bd9Sstevel@tonic-gate ASSERT(0); 14217c478bd9Sstevel@tonic-gate } 14227c478bd9Sstevel@tonic-gate if (resbmap & FATTR4_TIME_DELTA_MASK) { 14237c478bd9Sstevel@tonic-gate if ((!xdr_u_longlong_t(xdrs, 14247c478bd9Sstevel@tonic-gate (u_longlong_t *)&gesp->n4g_delta.seconds)) || 14257c478bd9Sstevel@tonic-gate (!xdr_u_int(xdrs, &gesp->n4g_delta.nseconds))) 14267c478bd9Sstevel@tonic-gate return (FALSE); 14277c478bd9Sstevel@tonic-gate } 14287c478bd9Sstevel@tonic-gate if (resbmap & FATTR4_TIME_METADATA_MASK) { 14297c478bd9Sstevel@tonic-gate nfstime4 mdt; 14307c478bd9Sstevel@tonic-gate int error; 14317c478bd9Sstevel@tonic-gate 14327c478bd9Sstevel@tonic-gate if (!xdr_longlong_t(xdrs, (longlong_t *)&mdt.seconds)) 14337c478bd9Sstevel@tonic-gate return (FALSE); 14347c478bd9Sstevel@tonic-gate if (!XDR_GETINT32(xdrs, (int32_t *)&mdt.nseconds)) 14357c478bd9Sstevel@tonic-gate return (FALSE); 14367c478bd9Sstevel@tonic-gate error = nfs4_time_ntov(&mdt, &vap->va_ctime); 14377c478bd9Sstevel@tonic-gate if (error) { 14387c478bd9Sstevel@tonic-gate garp->n4g_attrerr = error; 14397c478bd9Sstevel@tonic-gate garp->n4g_attrwhy = NFS4_GETATTR_ATCTIME_ERR; 14407c478bd9Sstevel@tonic-gate } 14417c478bd9Sstevel@tonic-gate vap->va_mask |= AT_CTIME; 14427c478bd9Sstevel@tonic-gate } 14437c478bd9Sstevel@tonic-gate if (resbmap & FATTR4_TIME_MODIFY_MASK) { 14447c478bd9Sstevel@tonic-gate nfstime4 mtime; 14457c478bd9Sstevel@tonic-gate int error; 14467c478bd9Sstevel@tonic-gate 14477c478bd9Sstevel@tonic-gate if (!xdr_longlong_t(xdrs, 14480a701b1eSRobert Gordon (longlong_t *)&mtime.seconds)) 14497c478bd9Sstevel@tonic-gate return (FALSE); 14507c478bd9Sstevel@tonic-gate if (!XDR_GETINT32(xdrs, (int32_t *)&mtime.nseconds)) 14517c478bd9Sstevel@tonic-gate return (FALSE); 14527c478bd9Sstevel@tonic-gate error = nfs4_time_ntov(&mtime, &vap->va_mtime); 14537c478bd9Sstevel@tonic-gate if (error) { 14547c478bd9Sstevel@tonic-gate garp->n4g_attrerr = error; 14557c478bd9Sstevel@tonic-gate garp->n4g_attrwhy = NFS4_GETATTR_ATMTIME_ERR; 14567c478bd9Sstevel@tonic-gate } 14577c478bd9Sstevel@tonic-gate vap->va_mask |= AT_MTIME; 14587c478bd9Sstevel@tonic-gate } 14597c478bd9Sstevel@tonic-gate if (resbmap & FATTR4_TIME_MODIFY_SET_MASK) { 14607c478bd9Sstevel@tonic-gate ASSERT(0); 14617c478bd9Sstevel@tonic-gate } 14627c478bd9Sstevel@tonic-gate if (resbmap & FATTR4_MOUNTED_ON_FILEID_MASK) { 14637c478bd9Sstevel@tonic-gate if (!xdr_u_longlong_t(xdrs, 14640a701b1eSRobert Gordon (u_longlong_t *)&garp->n4g_mon_fid)) 14657c478bd9Sstevel@tonic-gate return (FALSE); 14667c478bd9Sstevel@tonic-gate garp->n4g_mon_fid_valid = 1; 14677c478bd9Sstevel@tonic-gate } 14687c478bd9Sstevel@tonic-gate } 14697c478bd9Sstevel@tonic-gate 14707c478bd9Sstevel@tonic-gate if (resbmap & ~(NFS4_VATTR_MASK | FATTR4_ACL_MASK)) { 14717c478bd9Sstevel@tonic-gate /* copy only if not provided */ 14727c478bd9Sstevel@tonic-gate if (garp->n4g_ext_res == NULL) { 14737c478bd9Sstevel@tonic-gate garp->n4g_ext_res = kmem_alloc(sizeof (ges), KM_SLEEP); 14747c478bd9Sstevel@tonic-gate bcopy(&ges, garp->n4g_ext_res, sizeof (ges)); 14757c478bd9Sstevel@tonic-gate } 14767c478bd9Sstevel@tonic-gate } 14777c478bd9Sstevel@tonic-gate 14787c478bd9Sstevel@tonic-gate return (TRUE); 14797c478bd9Sstevel@tonic-gate } 14807c478bd9Sstevel@tonic-gate 14817c478bd9Sstevel@tonic-gate /* 14827c478bd9Sstevel@tonic-gate * Inlined version of get_bitmap4 processing 14837c478bd9Sstevel@tonic-gate */ 14847c478bd9Sstevel@tonic-gate bitmap4 14857c478bd9Sstevel@tonic-gate xdr_get_bitmap4_inline(uint32_t **iptr) 14867c478bd9Sstevel@tonic-gate { 14877c478bd9Sstevel@tonic-gate uint32_t resbmaplen; 14887c478bd9Sstevel@tonic-gate bitmap4 bm; 14897c478bd9Sstevel@tonic-gate uint32_t *ptr = *iptr; 14907c478bd9Sstevel@tonic-gate 14917c478bd9Sstevel@tonic-gate /* bitmap LENGTH */ 14927c478bd9Sstevel@tonic-gate resbmaplen = IXDR_GET_U_INT32(ptr); 14937c478bd9Sstevel@tonic-gate 14947c478bd9Sstevel@tonic-gate /* Inline the bitmap and attrlen for common case of two word map */ 14957c478bd9Sstevel@tonic-gate if (resbmaplen == 2) { 14967c478bd9Sstevel@tonic-gate IXDR_GET_HYPER(ptr, bm); 14977c478bd9Sstevel@tonic-gate *iptr = ptr; 14987c478bd9Sstevel@tonic-gate return (bm); 14997c478bd9Sstevel@tonic-gate } 15007c478bd9Sstevel@tonic-gate 15017c478bd9Sstevel@tonic-gate #if defined(_LITTLE_ENDIAN) 15027c478bd9Sstevel@tonic-gate bm = IXDR_GET_U_INT32(ptr); 15037c478bd9Sstevel@tonic-gate if (--resbmaplen == 0) { 15047c478bd9Sstevel@tonic-gate *iptr = ptr; 15057c478bd9Sstevel@tonic-gate return (bm); 15067c478bd9Sstevel@tonic-gate } 15077c478bd9Sstevel@tonic-gate *((uint32_t *)&bm) |= IXDR_GET_U_INT32(ptr); 15087c478bd9Sstevel@tonic-gate if (--resbmaplen == 0) { 15097c478bd9Sstevel@tonic-gate *iptr = ptr; 15107c478bd9Sstevel@tonic-gate return (bm); 15117c478bd9Sstevel@tonic-gate } 15127c478bd9Sstevel@tonic-gate ptr += resbmaplen; 15137c478bd9Sstevel@tonic-gate *iptr = ptr; 15147c478bd9Sstevel@tonic-gate return (bm); 15157c478bd9Sstevel@tonic-gate #elif defined(_BIG_ENDIAN) 15167c478bd9Sstevel@tonic-gate *((uint32_t *)&bm) = IXDR_GET_U_INT32(ptr); 15177c478bd9Sstevel@tonic-gate if (--resbmaplen == 0) { 15187c478bd9Sstevel@tonic-gate *iptr = ptr; 15197c478bd9Sstevel@tonic-gate return (bm); 15207c478bd9Sstevel@tonic-gate } 15217c478bd9Sstevel@tonic-gate bm |= IXDR_GET_U_INT32(ptr); 15227c478bd9Sstevel@tonic-gate if (--resbmaplen == 0) { 15237c478bd9Sstevel@tonic-gate *iptr = ptr; 15247c478bd9Sstevel@tonic-gate return (bm); 15257c478bd9Sstevel@tonic-gate } 15267c478bd9Sstevel@tonic-gate ptr += resbmaplen; 15277c478bd9Sstevel@tonic-gate *iptr = ptr; 15287c478bd9Sstevel@tonic-gate return (bm); 15297c478bd9Sstevel@tonic-gate #else 15307c478bd9Sstevel@tonic-gate ASSERT(0); 15317c478bd9Sstevel@tonic-gate ptr += resbmaplen; 15327c478bd9Sstevel@tonic-gate *iptr = ptr; 15337c478bd9Sstevel@tonic-gate return (0); 15347c478bd9Sstevel@tonic-gate #endif 15357c478bd9Sstevel@tonic-gate } 15367c478bd9Sstevel@tonic-gate 15377c478bd9Sstevel@tonic-gate static bool_t 15387c478bd9Sstevel@tonic-gate xdr_ga_fattr_res_inline(uint32_t *ptr, struct nfs4_ga_res *garp, 15397c478bd9Sstevel@tonic-gate bitmap4 resbmap, bitmap4 argbmap, struct mntinfo4 *mi, 15407c478bd9Sstevel@tonic-gate ug_cache_t *pug) 15417c478bd9Sstevel@tonic-gate { 15427c478bd9Sstevel@tonic-gate int truefalse; 15437c478bd9Sstevel@tonic-gate struct nfs4_ga_ext_res ges, *gesp; 15447c478bd9Sstevel@tonic-gate vattr_t *vap = &garp->n4g_va; 15457c478bd9Sstevel@tonic-gate 15467c478bd9Sstevel@tonic-gate if (garp->n4g_ext_res) 15477c478bd9Sstevel@tonic-gate gesp = garp->n4g_ext_res; 15487c478bd9Sstevel@tonic-gate else 15497c478bd9Sstevel@tonic-gate gesp = ⩾ 15507c478bd9Sstevel@tonic-gate 15517c478bd9Sstevel@tonic-gate vap->va_mask = 0; 15527c478bd9Sstevel@tonic-gate 15537c478bd9Sstevel@tonic-gate /* Check to see if the vattr should be pre-filled */ 15547c478bd9Sstevel@tonic-gate if (argbmap & NFS4_VATTR_MASK) 15557c478bd9Sstevel@tonic-gate xdr_ga_prefill_vattr(garp, mi); 15567c478bd9Sstevel@tonic-gate 15577c478bd9Sstevel@tonic-gate if (argbmap & NFS4_STATFS_ATTR_MASK) 15587c478bd9Sstevel@tonic-gate xdr_ga_prefill_statvfs(gesp, mi); 15597c478bd9Sstevel@tonic-gate 15607c478bd9Sstevel@tonic-gate if (resbmap & 15617c478bd9Sstevel@tonic-gate (FATTR4_SUPPORTED_ATTRS_MASK | 15627c478bd9Sstevel@tonic-gate FATTR4_TYPE_MASK | 15637c478bd9Sstevel@tonic-gate FATTR4_FH_EXPIRE_TYPE_MASK | 15647c478bd9Sstevel@tonic-gate FATTR4_CHANGE_MASK | 15657c478bd9Sstevel@tonic-gate FATTR4_SIZE_MASK | 15667c478bd9Sstevel@tonic-gate FATTR4_LINK_SUPPORT_MASK | 15677c478bd9Sstevel@tonic-gate FATTR4_SYMLINK_SUPPORT_MASK | 15687c478bd9Sstevel@tonic-gate FATTR4_NAMED_ATTR_MASK)) { 15697c478bd9Sstevel@tonic-gate 15707c478bd9Sstevel@tonic-gate if (resbmap & FATTR4_SUPPORTED_ATTRS_MASK) { 15717c478bd9Sstevel@tonic-gate gesp->n4g_suppattrs = xdr_get_bitmap4_inline(&ptr); 15727c478bd9Sstevel@tonic-gate } 15737c478bd9Sstevel@tonic-gate if (resbmap & FATTR4_TYPE_MASK) { 15747c478bd9Sstevel@tonic-gate vap->va_type = IXDR_GET_U_INT32(ptr); 15757c478bd9Sstevel@tonic-gate 1576*2c2d21e9SRichard Lowe if ((nfs_ftype4)vap->va_type < NF4REG || 1577*2c2d21e9SRichard Lowe (nfs_ftype4)vap->va_type > NF4NAMEDATTR) 15787c478bd9Sstevel@tonic-gate vap->va_type = VBAD; 15797c478bd9Sstevel@tonic-gate else 15807c478bd9Sstevel@tonic-gate vap->va_type = nf4_to_vt[vap->va_type]; 15817c478bd9Sstevel@tonic-gate if (vap->va_type == VBLK) 15827c478bd9Sstevel@tonic-gate vap->va_blksize = DEV_BSIZE; 15837c478bd9Sstevel@tonic-gate 15847c478bd9Sstevel@tonic-gate vap->va_mask |= AT_TYPE; 15857c478bd9Sstevel@tonic-gate } 15867c478bd9Sstevel@tonic-gate if (resbmap & FATTR4_FH_EXPIRE_TYPE_MASK) { 15877c478bd9Sstevel@tonic-gate gesp->n4g_fet = IXDR_GET_U_INT32(ptr); 15887c478bd9Sstevel@tonic-gate } 15897c478bd9Sstevel@tonic-gate if (resbmap & FATTR4_CHANGE_MASK) { 15907c478bd9Sstevel@tonic-gate IXDR_GET_U_HYPER(ptr, garp->n4g_change); 15917c478bd9Sstevel@tonic-gate garp->n4g_change_valid = 1; 15927c478bd9Sstevel@tonic-gate } 15937c478bd9Sstevel@tonic-gate if (resbmap & FATTR4_SIZE_MASK) { 15947c478bd9Sstevel@tonic-gate IXDR_GET_U_HYPER(ptr, vap->va_size); 15957c478bd9Sstevel@tonic-gate 15967c478bd9Sstevel@tonic-gate if (!NFS4_SIZE_OK(vap->va_size)) { 15977c478bd9Sstevel@tonic-gate garp->n4g_attrerr = EFBIG; 15987c478bd9Sstevel@tonic-gate garp->n4g_attrwhy = NFS4_GETATTR_ATSIZE_ERR; 15997c478bd9Sstevel@tonic-gate } else { 16007c478bd9Sstevel@tonic-gate vap->va_mask |= AT_SIZE; 16017c478bd9Sstevel@tonic-gate } 16027c478bd9Sstevel@tonic-gate } 16037c478bd9Sstevel@tonic-gate if (resbmap & FATTR4_LINK_SUPPORT_MASK) { 16047c478bd9Sstevel@tonic-gate truefalse = IXDR_GET_U_INT32(ptr); 16057c478bd9Sstevel@tonic-gate gesp->n4g_pc4.pc4_link_support = 16060a701b1eSRobert Gordon (truefalse ? TRUE : FALSE); 16077c478bd9Sstevel@tonic-gate } 16087c478bd9Sstevel@tonic-gate if (resbmap & FATTR4_SYMLINK_SUPPORT_MASK) { 16097c478bd9Sstevel@tonic-gate truefalse = IXDR_GET_U_INT32(ptr); 16107c478bd9Sstevel@tonic-gate gesp->n4g_pc4.pc4_symlink_support = 16110a701b1eSRobert Gordon (truefalse ? TRUE : FALSE); 16127c478bd9Sstevel@tonic-gate } 16137c478bd9Sstevel@tonic-gate if (resbmap & FATTR4_NAMED_ATTR_MASK) { 16147c478bd9Sstevel@tonic-gate truefalse = IXDR_GET_U_INT32(ptr); 16157c478bd9Sstevel@tonic-gate gesp->n4g_pc4.pc4_xattr_exists = TRUE; 16167c478bd9Sstevel@tonic-gate gesp->n4g_pc4.pc4_xattr_exists = 16170a701b1eSRobert Gordon (truefalse ? TRUE : FALSE); 16187c478bd9Sstevel@tonic-gate } 16197c478bd9Sstevel@tonic-gate } 16207c478bd9Sstevel@tonic-gate if (resbmap & 16217c478bd9Sstevel@tonic-gate (FATTR4_FSID_MASK | 16227c478bd9Sstevel@tonic-gate FATTR4_UNIQUE_HANDLES_MASK | 16237c478bd9Sstevel@tonic-gate FATTR4_LEASE_TIME_MASK | 16247c478bd9Sstevel@tonic-gate FATTR4_RDATTR_ERROR_MASK)) { 16257c478bd9Sstevel@tonic-gate 16267c478bd9Sstevel@tonic-gate if (resbmap & FATTR4_FSID_MASK) { 16277c478bd9Sstevel@tonic-gate IXDR_GET_U_HYPER(ptr, garp->n4g_fsid.major); 16287c478bd9Sstevel@tonic-gate IXDR_GET_U_HYPER(ptr, garp->n4g_fsid.minor); 16297c478bd9Sstevel@tonic-gate garp->n4g_fsid_valid = 1; 16307c478bd9Sstevel@tonic-gate } 16317c478bd9Sstevel@tonic-gate if (resbmap & FATTR4_UNIQUE_HANDLES_MASK) { 16327c478bd9Sstevel@tonic-gate truefalse = IXDR_GET_U_INT32(ptr); 16337c478bd9Sstevel@tonic-gate gesp->n4g_pc4.pc4_unique_handles = 16340a701b1eSRobert Gordon (truefalse ? TRUE : FALSE); 16357c478bd9Sstevel@tonic-gate } 16367c478bd9Sstevel@tonic-gate if (resbmap & FATTR4_LEASE_TIME_MASK) { 16377c478bd9Sstevel@tonic-gate gesp->n4g_leasetime = IXDR_GET_U_INT32(ptr); 16387c478bd9Sstevel@tonic-gate } 16397c478bd9Sstevel@tonic-gate if (resbmap & FATTR4_RDATTR_ERROR_MASK) { 16407c478bd9Sstevel@tonic-gate gesp->n4g_rdattr_error = IXDR_GET_U_INT32(ptr); 16417c478bd9Sstevel@tonic-gate } 16427c478bd9Sstevel@tonic-gate } 16437c478bd9Sstevel@tonic-gate if (resbmap & 16447c478bd9Sstevel@tonic-gate (FATTR4_ACL_MASK | 16457c478bd9Sstevel@tonic-gate FATTR4_ACLSUPPORT_MASK | 16467c478bd9Sstevel@tonic-gate FATTR4_ARCHIVE_MASK | 16477c478bd9Sstevel@tonic-gate FATTR4_CANSETTIME_MASK)) { 16487c478bd9Sstevel@tonic-gate 16497c478bd9Sstevel@tonic-gate if (resbmap & FATTR4_ACL_MASK) { 16507c478bd9Sstevel@tonic-gate ASSERT(0); 16517c478bd9Sstevel@tonic-gate } 16527c478bd9Sstevel@tonic-gate if (resbmap & FATTR4_ACLSUPPORT_MASK) { 16537c478bd9Sstevel@tonic-gate gesp->n4g_aclsupport = IXDR_GET_U_INT32(ptr); 16547c478bd9Sstevel@tonic-gate } 16557c478bd9Sstevel@tonic-gate if (resbmap & FATTR4_ARCHIVE_MASK) { 16567c478bd9Sstevel@tonic-gate ASSERT(0); 16577c478bd9Sstevel@tonic-gate } 16587c478bd9Sstevel@tonic-gate if (resbmap & FATTR4_CANSETTIME_MASK) { 16597c478bd9Sstevel@tonic-gate truefalse = IXDR_GET_U_INT32(ptr); 16607c478bd9Sstevel@tonic-gate gesp->n4g_pc4.pc4_cansettime = 16610a701b1eSRobert Gordon (truefalse ? TRUE : FALSE); 16627c478bd9Sstevel@tonic-gate } 16637c478bd9Sstevel@tonic-gate } 16647c478bd9Sstevel@tonic-gate if (resbmap & 16657c478bd9Sstevel@tonic-gate (FATTR4_CASE_INSENSITIVE_MASK | 16667c478bd9Sstevel@tonic-gate FATTR4_CASE_PRESERVING_MASK | 16677c478bd9Sstevel@tonic-gate FATTR4_CHOWN_RESTRICTED_MASK | 16687c478bd9Sstevel@tonic-gate FATTR4_FILEHANDLE_MASK | 16697c478bd9Sstevel@tonic-gate FATTR4_FILEID_MASK | 16707c478bd9Sstevel@tonic-gate FATTR4_FILES_AVAIL_MASK | 16717c478bd9Sstevel@tonic-gate FATTR4_FILES_FREE_MASK | 16727c478bd9Sstevel@tonic-gate FATTR4_FILES_TOTAL_MASK)) { 16737c478bd9Sstevel@tonic-gate 16747c478bd9Sstevel@tonic-gate if (resbmap & FATTR4_CASE_INSENSITIVE_MASK) { 16757c478bd9Sstevel@tonic-gate truefalse = IXDR_GET_U_INT32(ptr); 16767c478bd9Sstevel@tonic-gate gesp->n4g_pc4.pc4_case_insensitive = 16770a701b1eSRobert Gordon (truefalse ? TRUE : FALSE); 16787c478bd9Sstevel@tonic-gate } 16797c478bd9Sstevel@tonic-gate if (resbmap & FATTR4_CASE_PRESERVING_MASK) { 16807c478bd9Sstevel@tonic-gate truefalse = IXDR_GET_U_INT32(ptr); 16817c478bd9Sstevel@tonic-gate gesp->n4g_pc4.pc4_case_preserving = 16820a701b1eSRobert Gordon (truefalse ? TRUE : FALSE); 16837c478bd9Sstevel@tonic-gate } 16847c478bd9Sstevel@tonic-gate if (resbmap & FATTR4_CHOWN_RESTRICTED_MASK) { 16857c478bd9Sstevel@tonic-gate truefalse = IXDR_GET_U_INT32(ptr); 16867c478bd9Sstevel@tonic-gate gesp->n4g_pc4.pc4_chown_restricted = 16870a701b1eSRobert Gordon (truefalse ? TRUE : FALSE); 16887c478bd9Sstevel@tonic-gate } 16897c478bd9Sstevel@tonic-gate if (resbmap & FATTR4_FILEHANDLE_MASK) { 16907c478bd9Sstevel@tonic-gate int len = IXDR_GET_U_INT32(ptr); 16917c478bd9Sstevel@tonic-gate 16927c478bd9Sstevel@tonic-gate gesp->n4g_fh_u.nfs_fh4_alt.len = 0; 16937c478bd9Sstevel@tonic-gate gesp->n4g_fh_u.nfs_fh4_alt.val = 16940a701b1eSRobert Gordon gesp->n4g_fh_u.nfs_fh4_alt.data; 16957c478bd9Sstevel@tonic-gate gesp->n4g_fh_u.n4g_fh.nfs_fh4_len = len; 16967c478bd9Sstevel@tonic-gate 16977c478bd9Sstevel@tonic-gate bcopy(ptr, gesp->n4g_fh_u.n4g_fh.nfs_fh4_val, len); 16987c478bd9Sstevel@tonic-gate 16997c478bd9Sstevel@tonic-gate ptr += RNDUP(len) / BYTES_PER_XDR_UNIT; 17007c478bd9Sstevel@tonic-gate } 17017c478bd9Sstevel@tonic-gate if (resbmap & FATTR4_FILEID_MASK) { 17027c478bd9Sstevel@tonic-gate IXDR_GET_U_HYPER(ptr, vap->va_nodeid); 17037c478bd9Sstevel@tonic-gate vap->va_mask |= AT_NODEID; 17047c478bd9Sstevel@tonic-gate } 17057c478bd9Sstevel@tonic-gate if (resbmap & FATTR4_FILES_AVAIL_MASK) { 17067c478bd9Sstevel@tonic-gate IXDR_GET_U_HYPER(ptr, gesp->n4g_sb.f_favail); 17077c478bd9Sstevel@tonic-gate } 17087c478bd9Sstevel@tonic-gate if (resbmap & FATTR4_FILES_FREE_MASK) { 17097c478bd9Sstevel@tonic-gate IXDR_GET_U_HYPER(ptr, gesp->n4g_sb.f_ffree); 17107c478bd9Sstevel@tonic-gate } 17117c478bd9Sstevel@tonic-gate if (resbmap & FATTR4_FILES_TOTAL_MASK) { 17127c478bd9Sstevel@tonic-gate IXDR_GET_U_HYPER(ptr, gesp->n4g_sb.f_files); 17137c478bd9Sstevel@tonic-gate } 17147c478bd9Sstevel@tonic-gate } 17157c478bd9Sstevel@tonic-gate if (resbmap & 17167c478bd9Sstevel@tonic-gate (FATTR4_FS_LOCATIONS_MASK | 17177c478bd9Sstevel@tonic-gate FATTR4_HIDDEN_MASK | 17187c478bd9Sstevel@tonic-gate FATTR4_HOMOGENEOUS_MASK)) { 17197c478bd9Sstevel@tonic-gate 17207c478bd9Sstevel@tonic-gate if (resbmap & FATTR4_FS_LOCATIONS_MASK) { 17217c478bd9Sstevel@tonic-gate ASSERT(0); 17227c478bd9Sstevel@tonic-gate } 17237c478bd9Sstevel@tonic-gate if (resbmap & FATTR4_HIDDEN_MASK) { 17247c478bd9Sstevel@tonic-gate ASSERT(0); 17257c478bd9Sstevel@tonic-gate } 17267c478bd9Sstevel@tonic-gate if (resbmap & FATTR4_HOMOGENEOUS_MASK) { 17277c478bd9Sstevel@tonic-gate truefalse = IXDR_GET_U_INT32(ptr); 17287c478bd9Sstevel@tonic-gate gesp->n4g_pc4.pc4_homogeneous = 17290a701b1eSRobert Gordon (truefalse ? TRUE : FALSE); 17307c478bd9Sstevel@tonic-gate } 17317c478bd9Sstevel@tonic-gate } 17327c478bd9Sstevel@tonic-gate if (resbmap & 17337c478bd9Sstevel@tonic-gate (FATTR4_MAXFILESIZE_MASK | 17347c478bd9Sstevel@tonic-gate FATTR4_MAXLINK_MASK | 17357c478bd9Sstevel@tonic-gate FATTR4_MAXNAME_MASK | 17367c478bd9Sstevel@tonic-gate FATTR4_MAXREAD_MASK | 17377c478bd9Sstevel@tonic-gate FATTR4_MAXWRITE_MASK)) { 17387c478bd9Sstevel@tonic-gate 17397c478bd9Sstevel@tonic-gate if (resbmap & FATTR4_MAXFILESIZE_MASK) { 17407c478bd9Sstevel@tonic-gate IXDR_GET_U_HYPER(ptr, gesp->n4g_maxfilesize); 17417c478bd9Sstevel@tonic-gate } 17427c478bd9Sstevel@tonic-gate if (resbmap & FATTR4_MAXLINK_MASK) { 17437c478bd9Sstevel@tonic-gate gesp->n4g_pc4.pc4_link_max = IXDR_GET_U_INT32(ptr); 17447c478bd9Sstevel@tonic-gate } 17457c478bd9Sstevel@tonic-gate if (resbmap & FATTR4_MAXNAME_MASK) { 17467c478bd9Sstevel@tonic-gate gesp->n4g_pc4.pc4_name_max = IXDR_GET_U_INT32(ptr); 17477c478bd9Sstevel@tonic-gate gesp->n4g_sb.f_namemax = gesp->n4g_pc4.pc4_name_max; 17487c478bd9Sstevel@tonic-gate } 17497c478bd9Sstevel@tonic-gate if (resbmap & FATTR4_MAXREAD_MASK) { 17507c478bd9Sstevel@tonic-gate IXDR_GET_U_HYPER(ptr, gesp->n4g_maxread); 17517c478bd9Sstevel@tonic-gate } 17527c478bd9Sstevel@tonic-gate if (resbmap & FATTR4_MAXWRITE_MASK) { 17537c478bd9Sstevel@tonic-gate IXDR_GET_U_HYPER(ptr, gesp->n4g_maxwrite); 17547c478bd9Sstevel@tonic-gate } 17557c478bd9Sstevel@tonic-gate } 17567c478bd9Sstevel@tonic-gate if (resbmap & 17577c478bd9Sstevel@tonic-gate (FATTR4_MIMETYPE_MASK | 17587c478bd9Sstevel@tonic-gate FATTR4_MODE_MASK | 17597c478bd9Sstevel@tonic-gate FATTR4_NO_TRUNC_MASK | 17607c478bd9Sstevel@tonic-gate FATTR4_NUMLINKS_MASK)) { 17617c478bd9Sstevel@tonic-gate 17627c478bd9Sstevel@tonic-gate if (resbmap & FATTR4_MIMETYPE_MASK) { 17637c478bd9Sstevel@tonic-gate ASSERT(0); 17647c478bd9Sstevel@tonic-gate } 17657c478bd9Sstevel@tonic-gate if (resbmap & FATTR4_MODE_MASK) { 17667c478bd9Sstevel@tonic-gate vap->va_mode = IXDR_GET_U_INT32(ptr); 17677c478bd9Sstevel@tonic-gate vap->va_mask |= AT_MODE; 17687c478bd9Sstevel@tonic-gate } 17697c478bd9Sstevel@tonic-gate if (resbmap & FATTR4_NO_TRUNC_MASK) { 17707c478bd9Sstevel@tonic-gate truefalse = IXDR_GET_U_INT32(ptr); 17717c478bd9Sstevel@tonic-gate gesp->n4g_pc4.pc4_no_trunc = 17720a701b1eSRobert Gordon (truefalse ? TRUE : FALSE); 17737c478bd9Sstevel@tonic-gate } 17747c478bd9Sstevel@tonic-gate if (resbmap & FATTR4_NUMLINKS_MASK) { 17757c478bd9Sstevel@tonic-gate vap->va_nlink = IXDR_GET_U_INT32(ptr); 17767c478bd9Sstevel@tonic-gate vap->va_mask |= AT_NLINK; 17777c478bd9Sstevel@tonic-gate } 17787c478bd9Sstevel@tonic-gate } 17797c478bd9Sstevel@tonic-gate if (resbmap & 17807c478bd9Sstevel@tonic-gate (FATTR4_OWNER_MASK | 17817c478bd9Sstevel@tonic-gate FATTR4_OWNER_GROUP_MASK | 17827c478bd9Sstevel@tonic-gate FATTR4_QUOTA_AVAIL_HARD_MASK | 17837c478bd9Sstevel@tonic-gate FATTR4_QUOTA_AVAIL_SOFT_MASK)) { 17847c478bd9Sstevel@tonic-gate 17857c478bd9Sstevel@tonic-gate if (resbmap & FATTR4_OWNER_MASK) { 17867c478bd9Sstevel@tonic-gate uint_t *owner_length, ol; 17877c478bd9Sstevel@tonic-gate char *owner_val = NULL; 17887c478bd9Sstevel@tonic-gate utf8string ov; 17897c478bd9Sstevel@tonic-gate int error; 17907c478bd9Sstevel@tonic-gate 17917c478bd9Sstevel@tonic-gate /* get the OWNER_LENGTH */ 17927c478bd9Sstevel@tonic-gate ol = IXDR_GET_U_INT32(ptr); 17937c478bd9Sstevel@tonic-gate 17947c478bd9Sstevel@tonic-gate /* Manage the owner length location */ 17957c478bd9Sstevel@tonic-gate if (pug && ol <= MAX_OG_NAME) { 17967c478bd9Sstevel@tonic-gate owner_length = &pug->u_curr.utf8string_len; 17977c478bd9Sstevel@tonic-gate *owner_length = ol; 17987c478bd9Sstevel@tonic-gate } else { 17997c478bd9Sstevel@tonic-gate owner_length = &ol; 18007c478bd9Sstevel@tonic-gate } 18017c478bd9Sstevel@tonic-gate 18027c478bd9Sstevel@tonic-gate /* find memory to store the decode */ 18037c478bd9Sstevel@tonic-gate if (*owner_length > MAX_OG_NAME || pug == NULL) 18047c478bd9Sstevel@tonic-gate owner_val = (char *)ptr; 18057c478bd9Sstevel@tonic-gate else 18067c478bd9Sstevel@tonic-gate owner_val = (char *)ptr; 18077c478bd9Sstevel@tonic-gate 18087c478bd9Sstevel@tonic-gate /* Optimize for matching if called for */ 18097c478bd9Sstevel@tonic-gate if (pug && 18107c478bd9Sstevel@tonic-gate *owner_length == pug->u_last.utf8string_len && 18117c478bd9Sstevel@tonic-gate bcmp(owner_val, pug->u_last.utf8string_val, 18120a701b1eSRobert Gordon *owner_length) == 0) { 18137c478bd9Sstevel@tonic-gate vap->va_uid = pug->uid; 18147c478bd9Sstevel@tonic-gate vap->va_mask |= AT_UID; 18157c478bd9Sstevel@tonic-gate } else { 18167c478bd9Sstevel@tonic-gate uid_t uid; 18177c478bd9Sstevel@tonic-gate 18187c478bd9Sstevel@tonic-gate ov.utf8string_len = *owner_length; 18197c478bd9Sstevel@tonic-gate ov.utf8string_val = owner_val; 18207c478bd9Sstevel@tonic-gate error = nfs_idmap_str_uid(&ov, &uid, FALSE); 18217c478bd9Sstevel@tonic-gate /* 18227c478bd9Sstevel@tonic-gate * String was mapped, but to nobody because 18237c478bd9Sstevel@tonic-gate * we are nfsmapid, indicate it should not 18247c478bd9Sstevel@tonic-gate * be cached. 18257c478bd9Sstevel@tonic-gate */ 18267c478bd9Sstevel@tonic-gate if (error == ENOTSUP) { 18277c478bd9Sstevel@tonic-gate error = 0; 18287c478bd9Sstevel@tonic-gate garp->n4g_attrwhy = 18290a701b1eSRobert Gordon NFS4_GETATTR_NOCACHE_OK; 18307c478bd9Sstevel@tonic-gate } 18317c478bd9Sstevel@tonic-gate 18327c478bd9Sstevel@tonic-gate if (error) { 18337c478bd9Sstevel@tonic-gate garp->n4g_attrerr = error; 18347c478bd9Sstevel@tonic-gate garp->n4g_attrwhy = 18350a701b1eSRobert Gordon NFS4_GETATTR_ATUID_ERR; 18367c478bd9Sstevel@tonic-gate } else { 18377c478bd9Sstevel@tonic-gate vap->va_uid = uid; 18387c478bd9Sstevel@tonic-gate vap->va_mask |= AT_UID; 18397c478bd9Sstevel@tonic-gate /* save the results for next time */ 18407c478bd9Sstevel@tonic-gate if (pug && ol <= MAX_OG_NAME) { 18417c478bd9Sstevel@tonic-gate pug->uid = uid; 18427c478bd9Sstevel@tonic-gate pug->u_curr.utf8string_len = 18430a701b1eSRobert Gordon ov.utf8string_len; 18447c478bd9Sstevel@tonic-gate bcopy(owner_val, 18450a701b1eSRobert Gordon pug->u_curr.utf8string_val, 18460a701b1eSRobert Gordon ol); 18477c478bd9Sstevel@tonic-gate U_SWAP_CURR_LAST(pug); 18487c478bd9Sstevel@tonic-gate } 18497c478bd9Sstevel@tonic-gate } 18507c478bd9Sstevel@tonic-gate } 18517c478bd9Sstevel@tonic-gate ptr += RNDUP(ol) / BYTES_PER_XDR_UNIT; 18527c478bd9Sstevel@tonic-gate } 18537c478bd9Sstevel@tonic-gate if (resbmap & FATTR4_OWNER_GROUP_MASK) { 18547c478bd9Sstevel@tonic-gate uint_t *group_length, gl; 18557c478bd9Sstevel@tonic-gate char *group_val = NULL; 18567c478bd9Sstevel@tonic-gate utf8string gv; 18577c478bd9Sstevel@tonic-gate int error; 18587c478bd9Sstevel@tonic-gate 18597c478bd9Sstevel@tonic-gate /* get the OWNER_GROUP_LENGTH */ 18607c478bd9Sstevel@tonic-gate gl = IXDR_GET_U_INT32(ptr); 18617c478bd9Sstevel@tonic-gate 18627c478bd9Sstevel@tonic-gate /* Manage the group length location */ 18637c478bd9Sstevel@tonic-gate if (pug && gl <= MAX_OG_NAME) { 18647c478bd9Sstevel@tonic-gate group_length = &pug->g_curr.utf8string_len; 18657c478bd9Sstevel@tonic-gate *group_length = gl; 18667c478bd9Sstevel@tonic-gate } else { 18677c478bd9Sstevel@tonic-gate group_length = ≷ 18687c478bd9Sstevel@tonic-gate } 18697c478bd9Sstevel@tonic-gate 18707c478bd9Sstevel@tonic-gate /* find memory to store the decode */ 18717c478bd9Sstevel@tonic-gate if (*group_length > MAX_OG_NAME || pug == NULL) 18727c478bd9Sstevel@tonic-gate group_val = (char *)ptr; 18737c478bd9Sstevel@tonic-gate else 18747c478bd9Sstevel@tonic-gate group_val = (char *)ptr; 18757c478bd9Sstevel@tonic-gate 18767c478bd9Sstevel@tonic-gate /* Optimize for matching if called for */ 18777c478bd9Sstevel@tonic-gate if (pug && 18787c478bd9Sstevel@tonic-gate *group_length == pug->g_last.utf8string_len && 18797c478bd9Sstevel@tonic-gate bcmp(group_val, pug->g_last.utf8string_val, 18800a701b1eSRobert Gordon *group_length) == 0) { 18817c478bd9Sstevel@tonic-gate vap->va_gid = pug->gid; 18827c478bd9Sstevel@tonic-gate vap->va_mask |= AT_GID; 18837c478bd9Sstevel@tonic-gate } else { 18847c478bd9Sstevel@tonic-gate uid_t gid; 18857c478bd9Sstevel@tonic-gate 18867c478bd9Sstevel@tonic-gate gv.utf8string_len = *group_length; 18877c478bd9Sstevel@tonic-gate gv.utf8string_val = group_val; 18887c478bd9Sstevel@tonic-gate error = nfs_idmap_str_gid(&gv, &gid, FALSE); 18897c478bd9Sstevel@tonic-gate /* 18907c478bd9Sstevel@tonic-gate * String was mapped, but to nobody because 18917c478bd9Sstevel@tonic-gate * we are nfsmapid, indicate it should not 18927c478bd9Sstevel@tonic-gate * be cached. 18937c478bd9Sstevel@tonic-gate */ 18947c478bd9Sstevel@tonic-gate if (error == ENOTSUP) { 18957c478bd9Sstevel@tonic-gate error = 0; 18967c478bd9Sstevel@tonic-gate garp->n4g_attrwhy = 18970a701b1eSRobert Gordon NFS4_GETATTR_NOCACHE_OK; 18987c478bd9Sstevel@tonic-gate } 18997c478bd9Sstevel@tonic-gate 19007c478bd9Sstevel@tonic-gate if (error) { 19017c478bd9Sstevel@tonic-gate garp->n4g_attrerr = error; 19027c478bd9Sstevel@tonic-gate garp->n4g_attrwhy = 19030a701b1eSRobert Gordon NFS4_GETATTR_ATGID_ERR; 19047c478bd9Sstevel@tonic-gate } else { 19057c478bd9Sstevel@tonic-gate vap->va_gid = gid; 19067c478bd9Sstevel@tonic-gate vap->va_mask |= AT_GID; 19077c478bd9Sstevel@tonic-gate if (pug && gl <= MAX_OG_NAME) { 19087c478bd9Sstevel@tonic-gate pug->gid = gid; 19097c478bd9Sstevel@tonic-gate pug->g_curr.utf8string_len = 19100a701b1eSRobert Gordon gv.utf8string_len; 19117c478bd9Sstevel@tonic-gate bcopy(group_val, 19127c478bd9Sstevel@tonic-gate pug->g_curr.utf8string_val, 19137c478bd9Sstevel@tonic-gate gl); 19147c478bd9Sstevel@tonic-gate G_SWAP_CURR_LAST(pug); 19157c478bd9Sstevel@tonic-gate } 19167c478bd9Sstevel@tonic-gate } 19177c478bd9Sstevel@tonic-gate } 19187c478bd9Sstevel@tonic-gate ptr += RNDUP(gl) / BYTES_PER_XDR_UNIT; 19197c478bd9Sstevel@tonic-gate } 19207c478bd9Sstevel@tonic-gate if (resbmap & FATTR4_QUOTA_AVAIL_HARD_MASK) { 19217c478bd9Sstevel@tonic-gate ASSERT(0); 19227c478bd9Sstevel@tonic-gate } 19237c478bd9Sstevel@tonic-gate if (resbmap & FATTR4_QUOTA_AVAIL_SOFT_MASK) { 19247c478bd9Sstevel@tonic-gate ASSERT(0); 19257c478bd9Sstevel@tonic-gate } 19267c478bd9Sstevel@tonic-gate } 19277c478bd9Sstevel@tonic-gate if (resbmap & 19287c478bd9Sstevel@tonic-gate (FATTR4_QUOTA_USED_MASK | 19297c478bd9Sstevel@tonic-gate FATTR4_SPACE_AVAIL_MASK | 19307c478bd9Sstevel@tonic-gate FATTR4_SPACE_FREE_MASK | 19317c478bd9Sstevel@tonic-gate FATTR4_SPACE_TOTAL_MASK | 19327c478bd9Sstevel@tonic-gate FATTR4_SPACE_USED_MASK | 19337c478bd9Sstevel@tonic-gate FATTR4_SYSTEM_MASK)) { 19347c478bd9Sstevel@tonic-gate 19357c478bd9Sstevel@tonic-gate if (resbmap & FATTR4_QUOTA_USED_MASK) { 19367c478bd9Sstevel@tonic-gate ASSERT(0); 19377c478bd9Sstevel@tonic-gate } 19387c478bd9Sstevel@tonic-gate if (resbmap & FATTR4_RAWDEV_MASK) { 19397c478bd9Sstevel@tonic-gate fattr4_rawdev rawdev; 19407c478bd9Sstevel@tonic-gate 19417c478bd9Sstevel@tonic-gate rawdev.specdata1 = IXDR_GET_U_INT32(ptr); 19427c478bd9Sstevel@tonic-gate rawdev.specdata2 = IXDR_GET_U_INT32(ptr); 19437c478bd9Sstevel@tonic-gate 19447c478bd9Sstevel@tonic-gate if (vap->va_type == VCHR || vap->va_type == VBLK) { 19457c478bd9Sstevel@tonic-gate vap->va_rdev = makedevice(rawdev.specdata1, 19460a701b1eSRobert Gordon rawdev.specdata2); 19477c478bd9Sstevel@tonic-gate } else { 19487c478bd9Sstevel@tonic-gate vap->va_rdev = 0; 19497c478bd9Sstevel@tonic-gate } 19507c478bd9Sstevel@tonic-gate vap->va_mask |= AT_RDEV; 19517c478bd9Sstevel@tonic-gate } 19527c478bd9Sstevel@tonic-gate if (resbmap & FATTR4_SPACE_AVAIL_MASK) { 19537c478bd9Sstevel@tonic-gate IXDR_GET_U_HYPER(ptr, gesp->n4g_sb.f_bavail); 19547c478bd9Sstevel@tonic-gate gesp->n4g_sb.f_bavail /= DEV_BSIZE; 19557c478bd9Sstevel@tonic-gate } 19567c478bd9Sstevel@tonic-gate if (resbmap & FATTR4_SPACE_FREE_MASK) { 19577c478bd9Sstevel@tonic-gate IXDR_GET_U_HYPER(ptr, gesp->n4g_sb.f_bfree); 19587c478bd9Sstevel@tonic-gate gesp->n4g_sb.f_bfree /= DEV_BSIZE; 19597c478bd9Sstevel@tonic-gate } 19607c478bd9Sstevel@tonic-gate if (resbmap & FATTR4_SPACE_TOTAL_MASK) { 19617c478bd9Sstevel@tonic-gate IXDR_GET_U_HYPER(ptr, gesp->n4g_sb.f_blocks); 19627c478bd9Sstevel@tonic-gate gesp->n4g_sb.f_blocks /= DEV_BSIZE; 19637c478bd9Sstevel@tonic-gate } 19647c478bd9Sstevel@tonic-gate if (resbmap & FATTR4_SPACE_USED_MASK) { 19657c478bd9Sstevel@tonic-gate uint64_t space_used; 19667c478bd9Sstevel@tonic-gate IXDR_GET_U_HYPER(ptr, space_used); 19677c478bd9Sstevel@tonic-gate 19687c478bd9Sstevel@tonic-gate /* Compute space depending on device type */ 19697c478bd9Sstevel@tonic-gate ASSERT((vap->va_mask & AT_TYPE)); 19707c478bd9Sstevel@tonic-gate if (vap->va_type == VREG || vap->va_type == VDIR || 19717c478bd9Sstevel@tonic-gate vap->va_type == VLNK) { 19727c478bd9Sstevel@tonic-gate vap->va_nblocks = (u_longlong_t) 19730a701b1eSRobert Gordon ((space_used + (offset4)DEV_BSIZE - 19740a701b1eSRobert Gordon (offset4)1) / (offset4)DEV_BSIZE); 19757c478bd9Sstevel@tonic-gate } else { 19767c478bd9Sstevel@tonic-gate vap->va_nblocks = 0; 19777c478bd9Sstevel@tonic-gate } 19787c478bd9Sstevel@tonic-gate vap->va_mask |= AT_NBLOCKS; 19797c478bd9Sstevel@tonic-gate } 19807c478bd9Sstevel@tonic-gate if (resbmap & FATTR4_SYSTEM_MASK) { 19817c478bd9Sstevel@tonic-gate ASSERT(0); 19827c478bd9Sstevel@tonic-gate } 19837c478bd9Sstevel@tonic-gate } 19847c478bd9Sstevel@tonic-gate if (resbmap & 19857c478bd9Sstevel@tonic-gate (FATTR4_TIME_ACCESS_MASK | 19867c478bd9Sstevel@tonic-gate FATTR4_TIME_ACCESS_SET_MASK | 19877c478bd9Sstevel@tonic-gate FATTR4_TIME_BACKUP_MASK | 19887c478bd9Sstevel@tonic-gate FATTR4_TIME_CREATE_MASK | 19897c478bd9Sstevel@tonic-gate FATTR4_TIME_DELTA_MASK | 19907c478bd9Sstevel@tonic-gate FATTR4_TIME_METADATA_MASK | 19917c478bd9Sstevel@tonic-gate FATTR4_TIME_MODIFY_MASK | 19927c478bd9Sstevel@tonic-gate FATTR4_TIME_MODIFY_SET_MASK | 19937c478bd9Sstevel@tonic-gate FATTR4_MOUNTED_ON_FILEID_MASK)) { 19947c478bd9Sstevel@tonic-gate 19957c478bd9Sstevel@tonic-gate if (resbmap & FATTR4_TIME_ACCESS_MASK) { 19967c478bd9Sstevel@tonic-gate nfstime4 atime; 19977c478bd9Sstevel@tonic-gate int error; 19987c478bd9Sstevel@tonic-gate 19997c478bd9Sstevel@tonic-gate IXDR_GET_U_HYPER(ptr, atime.seconds); 20007c478bd9Sstevel@tonic-gate atime.nseconds = IXDR_GET_U_INT32(ptr); 20017c478bd9Sstevel@tonic-gate 20027c478bd9Sstevel@tonic-gate error = nfs4_time_ntov(&atime, &vap->va_atime); 20037c478bd9Sstevel@tonic-gate if (error) { 20047c478bd9Sstevel@tonic-gate garp->n4g_attrerr = error; 20057c478bd9Sstevel@tonic-gate garp->n4g_attrwhy = NFS4_GETATTR_ATATIME_ERR; 20067c478bd9Sstevel@tonic-gate } 20077c478bd9Sstevel@tonic-gate vap->va_mask |= AT_ATIME; 20087c478bd9Sstevel@tonic-gate } 20097c478bd9Sstevel@tonic-gate if (resbmap & FATTR4_TIME_ACCESS_SET_MASK) { 20107c478bd9Sstevel@tonic-gate ASSERT(0); 20117c478bd9Sstevel@tonic-gate } 20127c478bd9Sstevel@tonic-gate if (resbmap & FATTR4_TIME_BACKUP_MASK) { 20137c478bd9Sstevel@tonic-gate ASSERT(0); 20147c478bd9Sstevel@tonic-gate } 20157c478bd9Sstevel@tonic-gate if (resbmap & FATTR4_TIME_CREATE_MASK) { 20167c478bd9Sstevel@tonic-gate ASSERT(0); 20177c478bd9Sstevel@tonic-gate } 20187c478bd9Sstevel@tonic-gate if (resbmap & FATTR4_TIME_DELTA_MASK) { 20197c478bd9Sstevel@tonic-gate IXDR_GET_U_HYPER(ptr, gesp->n4g_delta.seconds); 20207c478bd9Sstevel@tonic-gate gesp->n4g_delta.nseconds = IXDR_GET_U_INT32(ptr); 20217c478bd9Sstevel@tonic-gate } 20227c478bd9Sstevel@tonic-gate if (resbmap & FATTR4_TIME_METADATA_MASK) { 20237c478bd9Sstevel@tonic-gate nfstime4 mdt; 20247c478bd9Sstevel@tonic-gate int error; 20257c478bd9Sstevel@tonic-gate 20267c478bd9Sstevel@tonic-gate IXDR_GET_U_HYPER(ptr, mdt.seconds); 20277c478bd9Sstevel@tonic-gate mdt.nseconds = IXDR_GET_U_INT32(ptr); 20287c478bd9Sstevel@tonic-gate 20297c478bd9Sstevel@tonic-gate error = nfs4_time_ntov(&mdt, &vap->va_ctime); 20307c478bd9Sstevel@tonic-gate if (error) { 20317c478bd9Sstevel@tonic-gate garp->n4g_attrerr = error; 20327c478bd9Sstevel@tonic-gate garp->n4g_attrwhy = NFS4_GETATTR_ATCTIME_ERR; 20337c478bd9Sstevel@tonic-gate } 20347c478bd9Sstevel@tonic-gate vap->va_mask |= AT_CTIME; 20357c478bd9Sstevel@tonic-gate } 20367c478bd9Sstevel@tonic-gate if (resbmap & FATTR4_TIME_MODIFY_MASK) { 20377c478bd9Sstevel@tonic-gate nfstime4 mtime; 20387c478bd9Sstevel@tonic-gate int error; 20397c478bd9Sstevel@tonic-gate 20407c478bd9Sstevel@tonic-gate IXDR_GET_U_HYPER(ptr, mtime.seconds); 20417c478bd9Sstevel@tonic-gate mtime.nseconds = IXDR_GET_U_INT32(ptr); 20427c478bd9Sstevel@tonic-gate 20437c478bd9Sstevel@tonic-gate error = nfs4_time_ntov(&mtime, &vap->va_mtime); 20447c478bd9Sstevel@tonic-gate if (error) { 20457c478bd9Sstevel@tonic-gate garp->n4g_attrerr = error; 20467c478bd9Sstevel@tonic-gate garp->n4g_attrwhy = NFS4_GETATTR_ATMTIME_ERR; 20477c478bd9Sstevel@tonic-gate } 20487c478bd9Sstevel@tonic-gate vap->va_mask |= AT_MTIME; 20497c478bd9Sstevel@tonic-gate } 20507c478bd9Sstevel@tonic-gate if (resbmap & FATTR4_TIME_MODIFY_SET_MASK) { 20517c478bd9Sstevel@tonic-gate ASSERT(0); 20527c478bd9Sstevel@tonic-gate } 20537c478bd9Sstevel@tonic-gate if (resbmap & FATTR4_MOUNTED_ON_FILEID_MASK) { 20547c478bd9Sstevel@tonic-gate IXDR_GET_U_HYPER(ptr, garp->n4g_mon_fid); 20557c478bd9Sstevel@tonic-gate garp->n4g_mon_fid_valid = 1; 20567c478bd9Sstevel@tonic-gate } 20577c478bd9Sstevel@tonic-gate } 20587c478bd9Sstevel@tonic-gate 20597c478bd9Sstevel@tonic-gate /* 20607c478bd9Sstevel@tonic-gate * FATTR4_ACL_MASK is not yet supported by this function, but 20617c478bd9Sstevel@tonic-gate * we check against it anyway, in case it ever is. 20627c478bd9Sstevel@tonic-gate */ 20637c478bd9Sstevel@tonic-gate if (resbmap & ~(NFS4_VATTR_MASK | FATTR4_ACL_MASK)) { 20647c478bd9Sstevel@tonic-gate /* copy only if not provided */ 20657c478bd9Sstevel@tonic-gate if (garp->n4g_ext_res == NULL) { 20667c478bd9Sstevel@tonic-gate garp->n4g_ext_res = kmem_alloc(sizeof (ges), KM_SLEEP); 20677c478bd9Sstevel@tonic-gate bcopy(&ges, garp->n4g_ext_res, sizeof (ges)); 20687c478bd9Sstevel@tonic-gate } 20697c478bd9Sstevel@tonic-gate } 20707c478bd9Sstevel@tonic-gate 20717c478bd9Sstevel@tonic-gate return (TRUE); 20727c478bd9Sstevel@tonic-gate } 20737c478bd9Sstevel@tonic-gate 20747c478bd9Sstevel@tonic-gate 20757c478bd9Sstevel@tonic-gate /* 20767c478bd9Sstevel@tonic-gate * "." and ".." buffers for filling in on read and readdir 20777c478bd9Sstevel@tonic-gate * calls. Intialize the first time and fill in on every 20787c478bd9Sstevel@tonic-gate * call to to readdir. 20797c478bd9Sstevel@tonic-gate */ 20807c478bd9Sstevel@tonic-gate char *nfs4_dot_entries; 20817c478bd9Sstevel@tonic-gate char *nfs4_dot_dot_entry; 20827c478bd9Sstevel@tonic-gate 20837c478bd9Sstevel@tonic-gate /* 20847c478bd9Sstevel@tonic-gate * Create the "." or ".." and pad the buffer once so they are 20857c478bd9Sstevel@tonic-gate * copied out as required into the user supplied buffer everytime. 20867c478bd9Sstevel@tonic-gate * DIRENT64_RECLEN(sizeof (".") - 1) = DIRENT64_RECLEN(1) 20877c478bd9Sstevel@tonic-gate * DIRENT64_RECLEN(sizeof ("..") - 1) = DIRENT64_RECLEN(2) 20887c478bd9Sstevel@tonic-gate */ 20897c478bd9Sstevel@tonic-gate void 20907c478bd9Sstevel@tonic-gate nfs4_init_dot_entries() 20917c478bd9Sstevel@tonic-gate { 20927c478bd9Sstevel@tonic-gate struct dirent64 *odp; 20937c478bd9Sstevel@tonic-gate 20947c478bd9Sstevel@tonic-gate /* 20957c478bd9Sstevel@tonic-gate * zalloc it so it zeros the buffer out. Need 20967c478bd9Sstevel@tonic-gate * to just do it once. 20977c478bd9Sstevel@tonic-gate */ 20987c478bd9Sstevel@tonic-gate nfs4_dot_entries = kmem_zalloc(DIRENT64_RECLEN(1) + DIRENT64_RECLEN(2), 20997c478bd9Sstevel@tonic-gate KM_SLEEP); 21007c478bd9Sstevel@tonic-gate 21017c478bd9Sstevel@tonic-gate odp = (struct dirent64 *)nfs4_dot_entries; 21027c478bd9Sstevel@tonic-gate odp->d_off = 1; /* magic cookie for "." entry */ 21037c478bd9Sstevel@tonic-gate odp->d_reclen = DIRENT64_RECLEN(1); 21047c478bd9Sstevel@tonic-gate odp->d_name[0] = '.'; 21057c478bd9Sstevel@tonic-gate odp->d_name[1] = '\0'; 21067c478bd9Sstevel@tonic-gate 21077c478bd9Sstevel@tonic-gate nfs4_dot_dot_entry = nfs4_dot_entries + DIRENT64_RECLEN(1); 21087c478bd9Sstevel@tonic-gate odp = (struct dirent64 *)nfs4_dot_dot_entry; 21097c478bd9Sstevel@tonic-gate 21107c478bd9Sstevel@tonic-gate odp->d_off = 2; 21117c478bd9Sstevel@tonic-gate odp->d_reclen = DIRENT64_RECLEN(2); 21127c478bd9Sstevel@tonic-gate odp->d_name[0] = '.'; 21137c478bd9Sstevel@tonic-gate odp->d_name[1] = '.'; 21147c478bd9Sstevel@tonic-gate odp->d_name[2] = '\0'; 21157c478bd9Sstevel@tonic-gate } 21167c478bd9Sstevel@tonic-gate 21177c478bd9Sstevel@tonic-gate void 21187c478bd9Sstevel@tonic-gate nfs4_destroy_dot_entries() 21197c478bd9Sstevel@tonic-gate { 21207c478bd9Sstevel@tonic-gate if (nfs4_dot_entries) 21217c478bd9Sstevel@tonic-gate kmem_free(nfs4_dot_entries, DIRENT64_RECLEN(1) + 21227c478bd9Sstevel@tonic-gate DIRENT64_RECLEN(2)); 21237c478bd9Sstevel@tonic-gate 21247c478bd9Sstevel@tonic-gate nfs4_dot_entries = nfs4_dot_dot_entry = NULL; 21257c478bd9Sstevel@tonic-gate } 21267c478bd9Sstevel@tonic-gate 21277c478bd9Sstevel@tonic-gate bool_t 21287c478bd9Sstevel@tonic-gate xdr_READDIR4res_clnt(XDR *xdrs, READDIR4res_clnt *objp, READDIR4args *aobjp) 21297c478bd9Sstevel@tonic-gate { 21307c478bd9Sstevel@tonic-gate bool_t more_data; 21317c478bd9Sstevel@tonic-gate rddir4_cache *rdc = aobjp->rdc; 21327c478bd9Sstevel@tonic-gate dirent64_t *dp = NULL; 21337c478bd9Sstevel@tonic-gate int entry_length = 0; 21347c478bd9Sstevel@tonic-gate int space_left = 0; 21357c478bd9Sstevel@tonic-gate bitmap4 resbmap; 21367c478bd9Sstevel@tonic-gate uint32_t attrlen; 21377c478bd9Sstevel@tonic-gate nfs4_ga_res_t gar; 21387c478bd9Sstevel@tonic-gate struct nfs4_ga_ext_res ges; 21397c478bd9Sstevel@tonic-gate uint64_t last_cookie = 0; 21407c478bd9Sstevel@tonic-gate int skip_to_end; 21417c478bd9Sstevel@tonic-gate ug_cache_t *pug = NULL; 21427c478bd9Sstevel@tonic-gate 21437c478bd9Sstevel@tonic-gate ASSERT(xdrs->x_op == XDR_DECODE); 21447c478bd9Sstevel@tonic-gate ASSERT(rdc->entries == NULL); 21457c478bd9Sstevel@tonic-gate ASSERT(aobjp->dircount > 0); 21467c478bd9Sstevel@tonic-gate 21477c478bd9Sstevel@tonic-gate if (!xdr_int(xdrs, (int32_t *)&objp->status)) 21487c478bd9Sstevel@tonic-gate return (FALSE); 21497c478bd9Sstevel@tonic-gate if (objp->status != NFS4_OK) 21507c478bd9Sstevel@tonic-gate return (TRUE); 21517c478bd9Sstevel@tonic-gate 21527c478bd9Sstevel@tonic-gate gar.n4g_va.va_mask = 0; 21537c478bd9Sstevel@tonic-gate gar.n4g_change_valid = 0; 21547c478bd9Sstevel@tonic-gate gar.n4g_mon_fid_valid = 0; 21557c478bd9Sstevel@tonic-gate gar.n4g_fsid_valid = 0; 21567c478bd9Sstevel@tonic-gate gar.n4g_vsa.vsa_mask = 0; 21577c478bd9Sstevel@tonic-gate gar.n4g_attrwhy = NFS4_GETATTR_OP_OK; 21587c478bd9Sstevel@tonic-gate ges.n4g_pc4.pc4_cache_valid = 0; 21597c478bd9Sstevel@tonic-gate ges.n4g_pc4.pc4_xattr_valid = 0; 21607c478bd9Sstevel@tonic-gate gar.n4g_ext_res = ⩾ 21617c478bd9Sstevel@tonic-gate 21627c478bd9Sstevel@tonic-gate /* READDIR4res_clnt_free needs to kmem_free this buffer */ 21637c478bd9Sstevel@tonic-gate rdc->entries = kmem_alloc(aobjp->dircount, KM_SLEEP); 21647c478bd9Sstevel@tonic-gate 21657c478bd9Sstevel@tonic-gate dp = (dirent64_t *)rdc->entries; 21667c478bd9Sstevel@tonic-gate rdc->entlen = rdc->buflen = space_left = aobjp->dircount; 21677c478bd9Sstevel@tonic-gate 21687c478bd9Sstevel@tonic-gate /* Fill in dot and dot-dot if needed */ 21697c478bd9Sstevel@tonic-gate if (rdc->nfs4_cookie == (nfs_cookie4) 0 || 21700a701b1eSRobert Gordon rdc->nfs4_cookie == (nfs_cookie4) 1) { 21717c478bd9Sstevel@tonic-gate 21727c478bd9Sstevel@tonic-gate if (rdc->nfs4_cookie == (nfs_cookie4)0) { 21737c478bd9Sstevel@tonic-gate bcopy(nfs4_dot_entries, rdc->entries, 21740a701b1eSRobert Gordon DIRENT64_RECLEN(1) + DIRENT64_RECLEN(2)); 21757c478bd9Sstevel@tonic-gate objp->dotp = dp; 21767c478bd9Sstevel@tonic-gate dp = (struct dirent64 *)(((char *)dp) + 21770a701b1eSRobert Gordon DIRENT64_RECLEN(1)); 21787c478bd9Sstevel@tonic-gate objp->dotdotp = dp; 21797c478bd9Sstevel@tonic-gate dp = (struct dirent64 *)(((char *)dp) + 21800a701b1eSRobert Gordon DIRENT64_RECLEN(2)); 21817c478bd9Sstevel@tonic-gate space_left -= DIRENT64_RECLEN(1) + DIRENT64_RECLEN(2); 21827c478bd9Sstevel@tonic-gate 21837c478bd9Sstevel@tonic-gate } else { /* for ".." entry */ 21847c478bd9Sstevel@tonic-gate bcopy(nfs4_dot_dot_entry, rdc->entries, 21850a701b1eSRobert Gordon DIRENT64_RECLEN(2)); 21867c478bd9Sstevel@tonic-gate objp->dotp = NULL; 21877c478bd9Sstevel@tonic-gate objp->dotdotp = dp; 21887c478bd9Sstevel@tonic-gate dp = (struct dirent64 *)(((char *)dp) + 21890a701b1eSRobert Gordon DIRENT64_RECLEN(2)); 21907c478bd9Sstevel@tonic-gate space_left -= DIRENT64_RECLEN(2); 21917c478bd9Sstevel@tonic-gate } 21927c478bd9Sstevel@tonic-gate /* Magic NFSv4 number for entry after start */ 21937c478bd9Sstevel@tonic-gate last_cookie = 2; 21947c478bd9Sstevel@tonic-gate } 21957c478bd9Sstevel@tonic-gate 21967c478bd9Sstevel@tonic-gate /* Get the cookie VERIFIER */ 21977c478bd9Sstevel@tonic-gate if (!xdr_u_longlong_t(xdrs, (u_longlong_t *)&objp->cookieverf)) 21987c478bd9Sstevel@tonic-gate goto noentries; 21997c478bd9Sstevel@tonic-gate 22007c478bd9Sstevel@tonic-gate /* Get the do-we-have-a-next-entry BOOL */ 22017c478bd9Sstevel@tonic-gate if (!xdr_bool(xdrs, &more_data)) 22027c478bd9Sstevel@tonic-gate goto noentries; 22037c478bd9Sstevel@tonic-gate 22047c478bd9Sstevel@tonic-gate if (aobjp->attr_request & (FATTR4_OWNER_MASK | FATTR4_OWNER_GROUP_MASK)) 22057c478bd9Sstevel@tonic-gate pug = alloc_ugcache(); 22067c478bd9Sstevel@tonic-gate 22077c478bd9Sstevel@tonic-gate skip_to_end = 0; 22087c478bd9Sstevel@tonic-gate while (more_data) { 22097c478bd9Sstevel@tonic-gate uint_t namelen; 22107c478bd9Sstevel@tonic-gate uint64_t cookie; 22117c478bd9Sstevel@tonic-gate 22127c478bd9Sstevel@tonic-gate /* Get the COOKIE */ 22137c478bd9Sstevel@tonic-gate if (!xdr_u_longlong_t(xdrs, (u_longlong_t *)&cookie)) 22147c478bd9Sstevel@tonic-gate goto noentries; 22157c478bd9Sstevel@tonic-gate 22167c478bd9Sstevel@tonic-gate /* Get the LENGTH of the entry name */ 22177c478bd9Sstevel@tonic-gate if (!xdr_u_int(xdrs, &namelen)) 22187c478bd9Sstevel@tonic-gate goto noentries; 22197c478bd9Sstevel@tonic-gate 22207c478bd9Sstevel@tonic-gate if (!skip_to_end) { 22217c478bd9Sstevel@tonic-gate /* 22227c478bd9Sstevel@tonic-gate * With the length of the directory entry name 22237c478bd9Sstevel@tonic-gate * in hand, figure out if there is room left 22247c478bd9Sstevel@tonic-gate * to encode it for the requestor. If not, 22257c478bd9Sstevel@tonic-gate * that is okay, but the rest of the readdir 22267c478bd9Sstevel@tonic-gate * operation result must be decoded in the 22277c478bd9Sstevel@tonic-gate * case there are following operations 22287c478bd9Sstevel@tonic-gate * in the compound request. Therefore, mark 22297c478bd9Sstevel@tonic-gate * the rest of the response as "skip" and 22307c478bd9Sstevel@tonic-gate * decode or skip the remaining data 22317c478bd9Sstevel@tonic-gate */ 22327c478bd9Sstevel@tonic-gate entry_length = DIRENT64_RECLEN(namelen); 22337c478bd9Sstevel@tonic-gate if (space_left < entry_length) 22347c478bd9Sstevel@tonic-gate skip_to_end = 1; 22357c478bd9Sstevel@tonic-gate } 22367c478bd9Sstevel@tonic-gate 22377c478bd9Sstevel@tonic-gate /* Get the NAME of the entry */ 22387c478bd9Sstevel@tonic-gate if (!skip_to_end) { 22397c478bd9Sstevel@tonic-gate if (!xdr_opaque(xdrs, dp->d_name, namelen)) 22407c478bd9Sstevel@tonic-gate goto noentries; 22417c478bd9Sstevel@tonic-gate bzero(&dp->d_name[namelen], 22420a701b1eSRobert Gordon DIRENT64_NAMELEN(entry_length) - namelen); 22437c478bd9Sstevel@tonic-gate dp->d_off = last_cookie = cookie; 22447c478bd9Sstevel@tonic-gate dp->d_reclen = entry_length; 22457c478bd9Sstevel@tonic-gate } else { 22467c478bd9Sstevel@tonic-gate if (!XDR_CONTROL(xdrs, XDR_SKIPBYTES, &namelen)) 22477c478bd9Sstevel@tonic-gate goto noentries; 22487c478bd9Sstevel@tonic-gate } 22497c478bd9Sstevel@tonic-gate 22507c478bd9Sstevel@tonic-gate /* Get the attribute BITMAP */ 22517c478bd9Sstevel@tonic-gate if (!xdr_bitmap4(xdrs, &resbmap)) 22527c478bd9Sstevel@tonic-gate goto noentries; 22537c478bd9Sstevel@tonic-gate /* Get the LENGTH of the attributes */ 22547c478bd9Sstevel@tonic-gate if (!xdr_u_int(xdrs, (uint_t *)&attrlen)) 22557c478bd9Sstevel@tonic-gate goto noentries; 22567c478bd9Sstevel@tonic-gate 22577c478bd9Sstevel@tonic-gate /* Get the ATTRIBUTES */ 22587c478bd9Sstevel@tonic-gate if (!skip_to_end) { 22597c478bd9Sstevel@tonic-gate uint32_t *ptr; 22607c478bd9Sstevel@tonic-gate 22617c478bd9Sstevel@tonic-gate if (!(resbmap & FATTR4_ACL_MASK) && 22627c478bd9Sstevel@tonic-gate (ptr = (uint32_t *)XDR_INLINE(xdrs, attrlen)) 22637c478bd9Sstevel@tonic-gate != NULL) { 22647c478bd9Sstevel@tonic-gate if (!xdr_ga_fattr_res_inline(ptr, &gar, resbmap, 22650a701b1eSRobert Gordon aobjp->attr_request, aobjp->mi, pug)) 22667c478bd9Sstevel@tonic-gate goto noentries; 22677c478bd9Sstevel@tonic-gate } else { 22687c478bd9Sstevel@tonic-gate if (!xdr_ga_fattr_res(xdrs, &gar, resbmap, 22690a701b1eSRobert Gordon aobjp->attr_request, aobjp->mi, pug)) 22707c478bd9Sstevel@tonic-gate goto noentries; 22717c478bd9Sstevel@tonic-gate } 22727c478bd9Sstevel@tonic-gate 22737c478bd9Sstevel@tonic-gate /* Fill in the d_ino per the server's fid values */ 22747c478bd9Sstevel@tonic-gate /* 22757c478bd9Sstevel@tonic-gate * Important to note that the mounted on fileid 22767c478bd9Sstevel@tonic-gate * is returned in d_ino if supported. This is 22777c478bd9Sstevel@tonic-gate * expected, readdir returns the mounted on fileid 22787c478bd9Sstevel@tonic-gate * while stat() returns the fileid of the object 22797c478bd9Sstevel@tonic-gate * on "top" of the mount. 22807c478bd9Sstevel@tonic-gate */ 22817c478bd9Sstevel@tonic-gate if (gar.n4g_mon_fid_valid) 22827c478bd9Sstevel@tonic-gate dp->d_ino = gar.n4g_mon_fid; 22837c478bd9Sstevel@tonic-gate else if (gar.n4g_va.va_mask & AT_NODEID) 22847c478bd9Sstevel@tonic-gate dp->d_ino = gar.n4g_va.va_nodeid; 22857c478bd9Sstevel@tonic-gate else 22867c478bd9Sstevel@tonic-gate dp->d_ino = 0; 22877c478bd9Sstevel@tonic-gate 22887c478bd9Sstevel@tonic-gate /* See about creating an rnode for this entry */ 22897c478bd9Sstevel@tonic-gate if ((resbmap & 22907c478bd9Sstevel@tonic-gate (NFS4_VATTR_MASK | FATTR4_FILEHANDLE_MASK)) == 22917c478bd9Sstevel@tonic-gate (NFS4_VATTR_MASK | FATTR4_FILEHANDLE_MASK)) { 22927c478bd9Sstevel@tonic-gate nfs4_sharedfh_t *sfhp; 22937c478bd9Sstevel@tonic-gate vnode_t *vp; 22947c478bd9Sstevel@tonic-gate 22957c478bd9Sstevel@tonic-gate sfhp = sfh4_put(&ges.n4g_fh_u.n4g_fh, 22960a701b1eSRobert Gordon aobjp->mi, NULL); 22977c478bd9Sstevel@tonic-gate vp = makenfs4node(sfhp, &gar, 22980a701b1eSRobert Gordon aobjp->dvp->v_vfsp, 22990a701b1eSRobert Gordon aobjp->t, 23000a701b1eSRobert Gordon aobjp->cr, 23010a701b1eSRobert Gordon aobjp->dvp, 23020a701b1eSRobert Gordon fn_get(VTOSV(aobjp->dvp)->sv_name, 2303bbf2a467SNagakiran Rajashekar dp->d_name, sfhp)); 23047c478bd9Sstevel@tonic-gate sfh4_rele(&sfhp); 23057c478bd9Sstevel@tonic-gate dnlc_update(aobjp->dvp, dp->d_name, vp); 23067c478bd9Sstevel@tonic-gate VN_RELE(vp); 23077c478bd9Sstevel@tonic-gate } 23087c478bd9Sstevel@tonic-gate 23097c478bd9Sstevel@tonic-gate dp = (struct dirent64 *)(((caddr_t)dp) + dp->d_reclen); 23107c478bd9Sstevel@tonic-gate 23117c478bd9Sstevel@tonic-gate space_left -= entry_length; 23127c478bd9Sstevel@tonic-gate 23137c478bd9Sstevel@tonic-gate } else { 23147c478bd9Sstevel@tonic-gate if (!XDR_CONTROL(xdrs, XDR_SKIPBYTES, &attrlen)) 23157c478bd9Sstevel@tonic-gate goto noentries; 23167c478bd9Sstevel@tonic-gate } 23177c478bd9Sstevel@tonic-gate 23187c478bd9Sstevel@tonic-gate /* Get the do-we-have-a-next-entry BOOL */ 23197c478bd9Sstevel@tonic-gate if (!xdr_bool(xdrs, &more_data)) 23207c478bd9Sstevel@tonic-gate goto noentries; 23217c478bd9Sstevel@tonic-gate } 23227c478bd9Sstevel@tonic-gate 23237c478bd9Sstevel@tonic-gate if (pug) { 23247c478bd9Sstevel@tonic-gate kmem_free(pug, sizeof (ug_cache_t)); 23257c478bd9Sstevel@tonic-gate pug = NULL; 23267c478bd9Sstevel@tonic-gate } 23277c478bd9Sstevel@tonic-gate 23287c478bd9Sstevel@tonic-gate /* 23297c478bd9Sstevel@tonic-gate * Finish up the rddir cache 23307c478bd9Sstevel@tonic-gate * If no entries were returned, free up buffer & 23317c478bd9Sstevel@tonic-gate * set ncookie to the starting cookie for this 23327c478bd9Sstevel@tonic-gate * readdir request so that the direof caching 23337c478bd9Sstevel@tonic-gate * will work properly. 23347c478bd9Sstevel@tonic-gate */ 23357c478bd9Sstevel@tonic-gate ASSERT(rdc->entries); 23367c478bd9Sstevel@tonic-gate if (last_cookie == 0) { 23377c478bd9Sstevel@tonic-gate kmem_free(rdc->entries, rdc->entlen); 23387c478bd9Sstevel@tonic-gate rdc->entries = NULL; 23397c478bd9Sstevel@tonic-gate last_cookie = rdc->nfs4_cookie; 23407c478bd9Sstevel@tonic-gate } 23417c478bd9Sstevel@tonic-gate 23427c478bd9Sstevel@tonic-gate rdc->actlen = rdc->entlen - space_left; 23437c478bd9Sstevel@tonic-gate rdc->nfs4_ncookie = last_cookie; 23447c478bd9Sstevel@tonic-gate 23457c478bd9Sstevel@tonic-gate /* Get the EOF marker */ 23467c478bd9Sstevel@tonic-gate if (!xdr_bool(xdrs, &objp->eof)) 23477c478bd9Sstevel@tonic-gate goto noentries; 23487c478bd9Sstevel@tonic-gate 23497c478bd9Sstevel@tonic-gate /* 23507c478bd9Sstevel@tonic-gate * If the server returns eof and there were no 23517c478bd9Sstevel@tonic-gate * skipped entries, set eof 23527c478bd9Sstevel@tonic-gate */ 23537c478bd9Sstevel@tonic-gate rdc->eof = (objp->eof && !skip_to_end) ? TRUE : FALSE; 23547c478bd9Sstevel@tonic-gate 23557c478bd9Sstevel@tonic-gate /* 23567c478bd9Sstevel@tonic-gate * If we encoded entries we are done 23577c478bd9Sstevel@tonic-gate */ 23587c478bd9Sstevel@tonic-gate if (rdc->entries) { 23597c478bd9Sstevel@tonic-gate rdc->error = 0; 23607c478bd9Sstevel@tonic-gate return (TRUE); 23617c478bd9Sstevel@tonic-gate } 23627c478bd9Sstevel@tonic-gate 23637c478bd9Sstevel@tonic-gate /* 23647c478bd9Sstevel@tonic-gate * If there were no entries and we skipped because 23657c478bd9Sstevel@tonic-gate * there was not enough space, return EINVAL 23667c478bd9Sstevel@tonic-gate */ 23677c478bd9Sstevel@tonic-gate if (skip_to_end) { 23687c478bd9Sstevel@tonic-gate rdc->error = EINVAL; 23697c478bd9Sstevel@tonic-gate return (TRUE); 23707c478bd9Sstevel@tonic-gate } 23717c478bd9Sstevel@tonic-gate 23727c478bd9Sstevel@tonic-gate /* 23737c478bd9Sstevel@tonic-gate * No entries, nothing skipped, and EOF, return OK. 23747c478bd9Sstevel@tonic-gate */ 23757c478bd9Sstevel@tonic-gate if (objp->eof == TRUE) { 23767c478bd9Sstevel@tonic-gate rdc->error = 0; 23777c478bd9Sstevel@tonic-gate return (TRUE); 23787c478bd9Sstevel@tonic-gate } 23797c478bd9Sstevel@tonic-gate 23807c478bd9Sstevel@tonic-gate /* 23817c478bd9Sstevel@tonic-gate * No entries, nothing skipped, and not EOF 23827c478bd9Sstevel@tonic-gate * probably a bad cookie, return ENOENT. 23837c478bd9Sstevel@tonic-gate */ 23847c478bd9Sstevel@tonic-gate rdc->error = ENOENT; 23857c478bd9Sstevel@tonic-gate return (TRUE); 23867c478bd9Sstevel@tonic-gate 23877c478bd9Sstevel@tonic-gate noentries: 23887c478bd9Sstevel@tonic-gate if (rdc->entries) { 23897c478bd9Sstevel@tonic-gate kmem_free(rdc->entries, rdc->entlen); 23907c478bd9Sstevel@tonic-gate rdc->entries = NULL; 23917c478bd9Sstevel@tonic-gate } 23927c478bd9Sstevel@tonic-gate if (pug) 23937c478bd9Sstevel@tonic-gate kmem_free(pug, sizeof (ug_cache_t)); 23947c478bd9Sstevel@tonic-gate rdc->error = EIO; 23957c478bd9Sstevel@tonic-gate return (FALSE); 23967c478bd9Sstevel@tonic-gate } 23977c478bd9Sstevel@tonic-gate 23987c478bd9Sstevel@tonic-gate /* 23997c478bd9Sstevel@tonic-gate * xdr_ga_res 24007c478bd9Sstevel@tonic-gate * 24017c478bd9Sstevel@tonic-gate * Returns: FALSE on raw data processing errors, TRUE otherwise. 24027c478bd9Sstevel@tonic-gate * 24037c478bd9Sstevel@tonic-gate * This function pre-processes the OP_GETATTR response, and then 24047c478bd9Sstevel@tonic-gate * calls common routines to process the GETATTR fattr4 results into 24057c478bd9Sstevel@tonic-gate * vnode attributes and other components that the client is interested 24067c478bd9Sstevel@tonic-gate * in. If an error other than an RPC error is encountered, the details 24077c478bd9Sstevel@tonic-gate * of the error are filled into objp, although the result of the 24087c478bd9Sstevel@tonic-gate * processing is set to TRUE. 24097c478bd9Sstevel@tonic-gate */ 24107c478bd9Sstevel@tonic-gate static bool_t 24117c478bd9Sstevel@tonic-gate xdr_ga_res(XDR *xdrs, GETATTR4res *objp, GETATTR4args *aobjp) 24127c478bd9Sstevel@tonic-gate { 24132f172c55SRobert Thurlow #ifdef INLINE 24147c478bd9Sstevel@tonic-gate uint32_t *ptr; 24152f172c55SRobert Thurlow #endif 24167c478bd9Sstevel@tonic-gate bitmap4 resbmap; 24177c478bd9Sstevel@tonic-gate uint32_t attrlen; 24187c478bd9Sstevel@tonic-gate 24197c478bd9Sstevel@tonic-gate ASSERT(xdrs->x_op == XDR_DECODE); 24207c478bd9Sstevel@tonic-gate 24217c478bd9Sstevel@tonic-gate /* Initialize objp attribute error values */ 24227c478bd9Sstevel@tonic-gate objp->ga_res.n4g_attrerr = 24230a701b1eSRobert Gordon objp->ga_res.n4g_attrwhy = NFS4_GETATTR_OP_OK; 24247c478bd9Sstevel@tonic-gate 24257c478bd9Sstevel@tonic-gate if (!xdr_bitmap4(xdrs, &resbmap)) 24267c478bd9Sstevel@tonic-gate return (FALSE); 24277c478bd9Sstevel@tonic-gate 24287c478bd9Sstevel@tonic-gate /* save the response bitmap for the caller */ 24297c478bd9Sstevel@tonic-gate objp->ga_res.n4g_resbmap = resbmap; 24307c478bd9Sstevel@tonic-gate 24317c478bd9Sstevel@tonic-gate /* attrlen */ 24327c478bd9Sstevel@tonic-gate if (!XDR_GETINT32(xdrs, (int32_t *)&attrlen)) 24337c478bd9Sstevel@tonic-gate return (FALSE); 24347c478bd9Sstevel@tonic-gate 24357c478bd9Sstevel@tonic-gate /* 24367c478bd9Sstevel@tonic-gate * Handle case where request and response bitmaps don't match. 24377c478bd9Sstevel@tonic-gate */ 24387c478bd9Sstevel@tonic-gate if (aobjp->attr_request && aobjp->attr_request != resbmap) { 24397c478bd9Sstevel@tonic-gate bitmap4 deltabmap; 24407c478bd9Sstevel@tonic-gate 24417c478bd9Sstevel@tonic-gate /* 24427c478bd9Sstevel@tonic-gate * Return error for case where server sent extra attributes 24437c478bd9Sstevel@tonic-gate * because the "unknown" attributes may be anywhere in the 24447c478bd9Sstevel@tonic-gate * xdr stream and can't be properly processed. 24457c478bd9Sstevel@tonic-gate */ 24467c478bd9Sstevel@tonic-gate deltabmap = ((aobjp->attr_request ^ resbmap) & resbmap); 24477c478bd9Sstevel@tonic-gate if (deltabmap) { 24487c478bd9Sstevel@tonic-gate objp->ga_res.n4g_attrerr = EINVAL; 24497c478bd9Sstevel@tonic-gate objp->ga_res.n4g_attrwhy = NFS4_GETATTR_BITMAP_ERR; 24507c478bd9Sstevel@tonic-gate return (TRUE); 24517c478bd9Sstevel@tonic-gate } 24527c478bd9Sstevel@tonic-gate 24537c478bd9Sstevel@tonic-gate /* 24547c478bd9Sstevel@tonic-gate * Return error for case where there is a mandatory 24557c478bd9Sstevel@tonic-gate * attribute missing in the server response. Note that 24567c478bd9Sstevel@tonic-gate * missing recommended attributes are evaluated in the 24577c478bd9Sstevel@tonic-gate * specific routines that decode the server response. 24587c478bd9Sstevel@tonic-gate */ 24597c478bd9Sstevel@tonic-gate deltabmap = ((aobjp->attr_request ^ resbmap) 24600a701b1eSRobert Gordon & aobjp->attr_request); 24617c478bd9Sstevel@tonic-gate if ((deltabmap & FATTR4_MANDATTR_MASK)) { 24627c478bd9Sstevel@tonic-gate objp->ga_res.n4g_attrerr = EINVAL; 24637c478bd9Sstevel@tonic-gate objp->ga_res.n4g_attrwhy = NFS4_GETATTR_MANDATTR_ERR; 24647c478bd9Sstevel@tonic-gate return (TRUE); 24657c478bd9Sstevel@tonic-gate } 24667c478bd9Sstevel@tonic-gate } 24677c478bd9Sstevel@tonic-gate 24687c478bd9Sstevel@tonic-gate /* Check to see if the attrs can be inlined and go for it if so */ 24692f172c55SRobert Thurlow #ifdef INLINE 24707c478bd9Sstevel@tonic-gate if (!(resbmap & FATTR4_ACL_MASK) && 24717c478bd9Sstevel@tonic-gate (ptr = (uint32_t *)XDR_INLINE(xdrs, attrlen)) != NULL) 24727c478bd9Sstevel@tonic-gate return (xdr_ga_fattr_res_inline(ptr, &objp->ga_res, 24730a701b1eSRobert Gordon resbmap, aobjp->attr_request, aobjp->mi, NULL)); 24747c478bd9Sstevel@tonic-gate else 24752f172c55SRobert Thurlow #endif 24767c478bd9Sstevel@tonic-gate return (xdr_ga_fattr_res(xdrs, &objp->ga_res, 24770a701b1eSRobert Gordon resbmap, aobjp->attr_request, aobjp->mi, NULL)); 24787c478bd9Sstevel@tonic-gate } 24797c478bd9Sstevel@tonic-gate 24807c478bd9Sstevel@tonic-gate #if defined(DEBUG) && !defined(lint) 24817c478bd9Sstevel@tonic-gate /* 24827c478bd9Sstevel@tonic-gate * We assume that an enum is a 32-bit value, check it once 24837c478bd9Sstevel@tonic-gate */ 24847c478bd9Sstevel@tonic-gate static enum szchk { SZVAL } szchkvar; 24857c478bd9Sstevel@tonic-gate #endif 24867c478bd9Sstevel@tonic-gate 24877c478bd9Sstevel@tonic-gate bool_t 24887c478bd9Sstevel@tonic-gate xdr_settime4(XDR *xdrs, settime4 *objp) 24897c478bd9Sstevel@tonic-gate { 24907c478bd9Sstevel@tonic-gate #if defined(DEBUG) && !defined(lint) 24917c478bd9Sstevel@tonic-gate ASSERT(sizeof (szchkvar) == sizeof (int32_t)); 24927c478bd9Sstevel@tonic-gate #endif 24937c478bd9Sstevel@tonic-gate if (xdrs->x_op == XDR_FREE) 24947c478bd9Sstevel@tonic-gate return (TRUE); 24957c478bd9Sstevel@tonic-gate 24967c478bd9Sstevel@tonic-gate if (!xdr_int(xdrs, (int *)&objp->set_it)) 24977c478bd9Sstevel@tonic-gate return (FALSE); 24987c478bd9Sstevel@tonic-gate if (objp->set_it != SET_TO_CLIENT_TIME4) 24997c478bd9Sstevel@tonic-gate return (TRUE); 25007c478bd9Sstevel@tonic-gate /* xdr_nfstime4 */ 25017c478bd9Sstevel@tonic-gate if (!xdr_longlong_t(xdrs, (longlong_t *)&objp->time.seconds)) 25027c478bd9Sstevel@tonic-gate return (FALSE); 25037c478bd9Sstevel@tonic-gate return (xdr_u_int(xdrs, &objp->time.nseconds)); 25047c478bd9Sstevel@tonic-gate } 25057c478bd9Sstevel@tonic-gate 25067c478bd9Sstevel@tonic-gate static bool_t 25077c478bd9Sstevel@tonic-gate xdr_fattr4(XDR *xdrs, fattr4 *objp) 25087c478bd9Sstevel@tonic-gate { 25097c478bd9Sstevel@tonic-gate if (xdrs->x_op != XDR_FREE) { 25107c478bd9Sstevel@tonic-gate if (!xdr_bitmap4(xdrs, &objp->attrmask)) 25117c478bd9Sstevel@tonic-gate return (FALSE); 25127c478bd9Sstevel@tonic-gate return (xdr_bytes(xdrs, (char **)&objp->attrlist4, 25130a701b1eSRobert Gordon (uint_t *)&objp->attrlist4_len, NFS4_FATTR4_LIMIT)); 25147c478bd9Sstevel@tonic-gate } 25157c478bd9Sstevel@tonic-gate 25167c478bd9Sstevel@tonic-gate /* 25177c478bd9Sstevel@tonic-gate * Optimized free case 25187c478bd9Sstevel@tonic-gate */ 25197c478bd9Sstevel@tonic-gate if (objp->attrlist4 != NULL) 25207c478bd9Sstevel@tonic-gate kmem_free(objp->attrlist4, objp->attrlist4_len); 25217c478bd9Sstevel@tonic-gate return (TRUE); 25227c478bd9Sstevel@tonic-gate } 25237c478bd9Sstevel@tonic-gate 25247c478bd9Sstevel@tonic-gate static bool_t 25257c478bd9Sstevel@tonic-gate xdr_ACCESS4res(XDR *xdrs, ACCESS4res *objp) 25267c478bd9Sstevel@tonic-gate { 25277c478bd9Sstevel@tonic-gate if (!xdr_int(xdrs, (int32_t *)&objp->status)) 25287c478bd9Sstevel@tonic-gate return (FALSE); 25297c478bd9Sstevel@tonic-gate if (objp->status != NFS4_OK) 25307c478bd9Sstevel@tonic-gate return (TRUE); 25317c478bd9Sstevel@tonic-gate if (!xdr_u_int(xdrs, &objp->supported)) 25327c478bd9Sstevel@tonic-gate return (FALSE); 25337c478bd9Sstevel@tonic-gate return (xdr_u_int(xdrs, &objp->access)); 25347c478bd9Sstevel@tonic-gate } 25357c478bd9Sstevel@tonic-gate 25367c478bd9Sstevel@tonic-gate static bool_t 25377c478bd9Sstevel@tonic-gate xdr_CLOSE4args(XDR *xdrs, CLOSE4args *objp) 25387c478bd9Sstevel@tonic-gate { 25397c478bd9Sstevel@tonic-gate if (!xdr_u_int(xdrs, &objp->seqid)) 25407c478bd9Sstevel@tonic-gate return (FALSE); 25417c478bd9Sstevel@tonic-gate if (!xdr_u_int(xdrs, &objp->open_stateid.seqid)) 25427c478bd9Sstevel@tonic-gate return (FALSE); 25437c478bd9Sstevel@tonic-gate return (xdr_opaque(xdrs, objp->open_stateid.other, 12)); 25447c478bd9Sstevel@tonic-gate } 25457c478bd9Sstevel@tonic-gate 25467c478bd9Sstevel@tonic-gate static bool_t 25477c478bd9Sstevel@tonic-gate xdr_CLOSE4res(XDR *xdrs, CLOSE4res *objp) 25487c478bd9Sstevel@tonic-gate { 25497c478bd9Sstevel@tonic-gate if (!xdr_int(xdrs, (int32_t *)&objp->status)) 25507c478bd9Sstevel@tonic-gate return (FALSE); 25517c478bd9Sstevel@tonic-gate if (objp->status != NFS4_OK) 25527c478bd9Sstevel@tonic-gate return (TRUE); 25537c478bd9Sstevel@tonic-gate if (!xdr_u_int(xdrs, &objp->open_stateid.seqid)) 25547c478bd9Sstevel@tonic-gate return (FALSE); 25557c478bd9Sstevel@tonic-gate return (xdr_opaque(xdrs, objp->open_stateid.other, 12)); 25567c478bd9Sstevel@tonic-gate } 25577c478bd9Sstevel@tonic-gate 25587c478bd9Sstevel@tonic-gate static bool_t 25597c478bd9Sstevel@tonic-gate xdr_CREATE4args(XDR *xdrs, CREATE4args *objp) 25607c478bd9Sstevel@tonic-gate { 25617c478bd9Sstevel@tonic-gate if (xdrs->x_op != XDR_FREE) { 25627c478bd9Sstevel@tonic-gate if (!xdr_int(xdrs, (int32_t *)&objp->type)) 25637c478bd9Sstevel@tonic-gate return (FALSE); 25647c478bd9Sstevel@tonic-gate switch (objp->type) { 25657c478bd9Sstevel@tonic-gate case NF4LNK: 25667c478bd9Sstevel@tonic-gate if (!xdr_bytes(xdrs, 25677c478bd9Sstevel@tonic-gate (char **)&objp->ftype4_u.linkdata.utf8string_val, 25687c478bd9Sstevel@tonic-gate (uint_t *)&objp->ftype4_u.linkdata.utf8string_len, 25697c478bd9Sstevel@tonic-gate NFS4_MAX_UTF8STRING)) 25707c478bd9Sstevel@tonic-gate return (FALSE); 25717c478bd9Sstevel@tonic-gate break; 25727c478bd9Sstevel@tonic-gate case NF4BLK: 25737c478bd9Sstevel@tonic-gate case NF4CHR: 25747c478bd9Sstevel@tonic-gate if (!xdr_u_int(xdrs, &objp->ftype4_u.devdata.specdata1)) 25757c478bd9Sstevel@tonic-gate return (FALSE); 25767c478bd9Sstevel@tonic-gate if (!xdr_u_int(xdrs, &objp->ftype4_u.devdata.specdata2)) 25777c478bd9Sstevel@tonic-gate return (FALSE); 25787c478bd9Sstevel@tonic-gate break; 25797c478bd9Sstevel@tonic-gate case NF4SOCK: 25807c478bd9Sstevel@tonic-gate case NF4FIFO: 25817c478bd9Sstevel@tonic-gate case NF4DIR: 25827c478bd9Sstevel@tonic-gate default: 25837c478bd9Sstevel@tonic-gate break; /* server should return NFS4ERR_BADTYPE */ 25847c478bd9Sstevel@tonic-gate } 25857c478bd9Sstevel@tonic-gate if (!xdr_bytes(xdrs, (char **)&objp->objname.utf8string_val, 25860a701b1eSRobert Gordon (uint_t *)&objp->objname.utf8string_len, 25870a701b1eSRobert Gordon NFS4_MAX_UTF8STRING)) 25887c478bd9Sstevel@tonic-gate return (FALSE); 25897c478bd9Sstevel@tonic-gate return (xdr_fattr4(xdrs, &objp->createattrs)); 25907c478bd9Sstevel@tonic-gate } 25917c478bd9Sstevel@tonic-gate 25927c478bd9Sstevel@tonic-gate /* 25937c478bd9Sstevel@tonic-gate * Optimized free case 25947c478bd9Sstevel@tonic-gate */ 25957c478bd9Sstevel@tonic-gate if (objp->type == NF4LNK) { 25967c478bd9Sstevel@tonic-gate if (objp->ftype4_u.linkdata.utf8string_val != NULL) 25977c478bd9Sstevel@tonic-gate kmem_free(objp->ftype4_u.linkdata.utf8string_val, 25980a701b1eSRobert Gordon objp->ftype4_u.linkdata.utf8string_len); 25997c478bd9Sstevel@tonic-gate } 26007c478bd9Sstevel@tonic-gate if (objp->objname.utf8string_val != NULL) 26017c478bd9Sstevel@tonic-gate kmem_free(objp->objname.utf8string_val, 26020a701b1eSRobert Gordon objp->objname.utf8string_len); 26037c478bd9Sstevel@tonic-gate return (xdr_fattr4(xdrs, &objp->createattrs)); 26047c478bd9Sstevel@tonic-gate } 26057c478bd9Sstevel@tonic-gate 26067c478bd9Sstevel@tonic-gate static bool_t 26077c478bd9Sstevel@tonic-gate xdr_CREATE4cargs(XDR *xdrs, CREATE4cargs *objp) 26087c478bd9Sstevel@tonic-gate { 26097c478bd9Sstevel@tonic-gate int len; 26107c478bd9Sstevel@tonic-gate 26117c478bd9Sstevel@tonic-gate ASSERT(xdrs->x_op == XDR_ENCODE); 26127c478bd9Sstevel@tonic-gate 26137c478bd9Sstevel@tonic-gate if (!XDR_PUTINT32(xdrs, (int32_t *)&objp->type)) 26147c478bd9Sstevel@tonic-gate return (FALSE); 26157c478bd9Sstevel@tonic-gate switch (objp->type) { 26167c478bd9Sstevel@tonic-gate case NF4LNK: 26177c478bd9Sstevel@tonic-gate len = strlen(objp->ftype4_u.clinkdata); 26187c478bd9Sstevel@tonic-gate if (len > NFS4_MAX_UTF8STRING) 26197c478bd9Sstevel@tonic-gate return (FALSE); 26207c478bd9Sstevel@tonic-gate if (!XDR_PUTINT32(xdrs, &len)) 26217c478bd9Sstevel@tonic-gate return (FALSE); 26227c478bd9Sstevel@tonic-gate if (!xdr_opaque(xdrs, objp->ftype4_u.clinkdata, len)) 26237c478bd9Sstevel@tonic-gate return (FALSE); 26247c478bd9Sstevel@tonic-gate break; 26257c478bd9Sstevel@tonic-gate case NF4BLK: 26267c478bd9Sstevel@tonic-gate case NF4CHR: 26277c478bd9Sstevel@tonic-gate if (!XDR_PUTINT32(xdrs, 26280a701b1eSRobert Gordon (int32_t *)&objp->ftype4_u.devdata.specdata1)) 26297c478bd9Sstevel@tonic-gate return (FALSE); 26307c478bd9Sstevel@tonic-gate if (!XDR_PUTINT32(xdrs, 26310a701b1eSRobert Gordon (int32_t *)&objp->ftype4_u.devdata.specdata2)) 26327c478bd9Sstevel@tonic-gate return (FALSE); 26337c478bd9Sstevel@tonic-gate break; 26347c478bd9Sstevel@tonic-gate case NF4SOCK: 26357c478bd9Sstevel@tonic-gate case NF4FIFO: 26367c478bd9Sstevel@tonic-gate case NF4DIR: 26377c478bd9Sstevel@tonic-gate default: 26387c478bd9Sstevel@tonic-gate break; /* server should return NFS4ERR_BADTYPE */ 26397c478bd9Sstevel@tonic-gate } 26407c478bd9Sstevel@tonic-gate 26417c478bd9Sstevel@tonic-gate len = strlen(objp->cname); 26427c478bd9Sstevel@tonic-gate if (len > NFS4_MAX_UTF8STRING) 26437c478bd9Sstevel@tonic-gate return (FALSE); 26447c478bd9Sstevel@tonic-gate if (!XDR_PUTINT32(xdrs, &len)) 26457c478bd9Sstevel@tonic-gate return (FALSE); 26467c478bd9Sstevel@tonic-gate if (!xdr_opaque(xdrs, objp->cname, len)) 26477c478bd9Sstevel@tonic-gate return (FALSE); 26487c478bd9Sstevel@tonic-gate 26497c478bd9Sstevel@tonic-gate return (xdr_fattr4(xdrs, &objp->createattrs)); 26507c478bd9Sstevel@tonic-gate } 26517c478bd9Sstevel@tonic-gate 26527c478bd9Sstevel@tonic-gate static bool_t 26537c478bd9Sstevel@tonic-gate xdr_CREATE4res(XDR *xdrs, CREATE4res *objp) 26547c478bd9Sstevel@tonic-gate { 26557c478bd9Sstevel@tonic-gate if (!xdr_int(xdrs, (int32_t *)&objp->status)) 26567c478bd9Sstevel@tonic-gate return (FALSE); 26577c478bd9Sstevel@tonic-gate if (objp->status != NFS4_OK) 26587c478bd9Sstevel@tonic-gate return (TRUE); 26597c478bd9Sstevel@tonic-gate if (!xdr_bool(xdrs, &objp->cinfo.atomic)) 26607c478bd9Sstevel@tonic-gate return (FALSE); 26617c478bd9Sstevel@tonic-gate if (!xdr_u_longlong_t(xdrs, (u_longlong_t *)&objp->cinfo.before)) 26627c478bd9Sstevel@tonic-gate return (FALSE); 26637c478bd9Sstevel@tonic-gate if (!xdr_u_longlong_t(xdrs, (u_longlong_t *)&objp->cinfo.after)) 26647c478bd9Sstevel@tonic-gate return (FALSE); 26657c478bd9Sstevel@tonic-gate return (xdr_bitmap4(xdrs, &objp->attrset)); 26667c478bd9Sstevel@tonic-gate } 26677c478bd9Sstevel@tonic-gate 26687c478bd9Sstevel@tonic-gate static bool_t 26697c478bd9Sstevel@tonic-gate xdr_LINK4res(XDR *xdrs, LINK4res *objp) 26707c478bd9Sstevel@tonic-gate { 26717c478bd9Sstevel@tonic-gate if (!xdr_int(xdrs, (int32_t *)&objp->status)) 26727c478bd9Sstevel@tonic-gate return (FALSE); 26737c478bd9Sstevel@tonic-gate if (objp->status != NFS4_OK) 26747c478bd9Sstevel@tonic-gate return (TRUE); 26757c478bd9Sstevel@tonic-gate if (!xdr_bool(xdrs, &objp->cinfo.atomic)) 26767c478bd9Sstevel@tonic-gate return (FALSE); 26777c478bd9Sstevel@tonic-gate if (!xdr_u_longlong_t(xdrs, (u_longlong_t *)&objp->cinfo.before)) 26787c478bd9Sstevel@tonic-gate return (FALSE); 26797c478bd9Sstevel@tonic-gate return (xdr_u_longlong_t(xdrs, (u_longlong_t *)&objp->cinfo.after)); 26807c478bd9Sstevel@tonic-gate } 26817c478bd9Sstevel@tonic-gate 26827c478bd9Sstevel@tonic-gate static bool_t 26837c478bd9Sstevel@tonic-gate xdr_LOCK4args(XDR *xdrs, LOCK4args *objp) 26847c478bd9Sstevel@tonic-gate { 26857c478bd9Sstevel@tonic-gate if (xdrs->x_op != XDR_FREE) { 26867c478bd9Sstevel@tonic-gate if (!xdr_int(xdrs, (int *)&objp->locktype)) 26877c478bd9Sstevel@tonic-gate return (FALSE); 26887c478bd9Sstevel@tonic-gate if (!xdr_bool(xdrs, &objp->reclaim)) 26897c478bd9Sstevel@tonic-gate return (FALSE); 26907c478bd9Sstevel@tonic-gate if (!xdr_u_longlong_t(xdrs, (u_longlong_t *)&objp->offset)) 26917c478bd9Sstevel@tonic-gate return (FALSE); 26927c478bd9Sstevel@tonic-gate if (!xdr_u_longlong_t(xdrs, (u_longlong_t *)&objp->length)) 26937c478bd9Sstevel@tonic-gate return (FALSE); 26947c478bd9Sstevel@tonic-gate if (!xdr_bool(xdrs, &objp->locker.new_lock_owner)) 26957c478bd9Sstevel@tonic-gate return (FALSE); 26967c478bd9Sstevel@tonic-gate if (objp->locker.new_lock_owner == TRUE) { 26977c478bd9Sstevel@tonic-gate if (!xdr_u_int(xdrs, &objp->locker.locker4_u.open_owner. 26980a701b1eSRobert Gordon open_seqid)) 26997c478bd9Sstevel@tonic-gate return (FALSE); 27007c478bd9Sstevel@tonic-gate if (!xdr_u_int(xdrs, &objp->locker.locker4_u.open_owner. 27010a701b1eSRobert Gordon open_stateid.seqid)) 27027c478bd9Sstevel@tonic-gate return (FALSE); 27037c478bd9Sstevel@tonic-gate if (!xdr_opaque(xdrs, objp->locker.locker4_u.open_owner. 27040a701b1eSRobert Gordon open_stateid.other, 12)) 27057c478bd9Sstevel@tonic-gate return (FALSE); 27067c478bd9Sstevel@tonic-gate if (!xdr_u_int(xdrs, &objp->locker.locker4_u.open_owner. 27070a701b1eSRobert Gordon lock_seqid)) 27087c478bd9Sstevel@tonic-gate return (FALSE); 27097c478bd9Sstevel@tonic-gate if (!xdr_u_longlong_t(xdrs, 27100a701b1eSRobert Gordon (u_longlong_t *)&objp->locker.locker4_u. 27110a701b1eSRobert Gordon open_owner.lock_owner.clientid)) 27127c478bd9Sstevel@tonic-gate return (FALSE); 27137c478bd9Sstevel@tonic-gate return (xdr_bytes(xdrs, 27140a701b1eSRobert Gordon (char **)&objp->locker.locker4_u.open_owner. 27150a701b1eSRobert Gordon lock_owner.owner_val, 27160a701b1eSRobert Gordon (uint_t *)&objp->locker.locker4_u.open_owner. 27170a701b1eSRobert Gordon lock_owner.owner_len, 27180a701b1eSRobert Gordon NFS4_OPAQUE_LIMIT)); 27197c478bd9Sstevel@tonic-gate } 27207c478bd9Sstevel@tonic-gate 27217c478bd9Sstevel@tonic-gate if (objp->locker.new_lock_owner != FALSE) 27227c478bd9Sstevel@tonic-gate return (FALSE); 27237c478bd9Sstevel@tonic-gate 27247c478bd9Sstevel@tonic-gate if (!xdr_u_int(xdrs, &objp->locker.locker4_u.lock_owner. 27250a701b1eSRobert Gordon lock_stateid.seqid)) 27267c478bd9Sstevel@tonic-gate return (FALSE); 27277c478bd9Sstevel@tonic-gate if (!xdr_opaque(xdrs, objp->locker.locker4_u.lock_owner. 27280a701b1eSRobert Gordon lock_stateid.other, 12)) 27297c478bd9Sstevel@tonic-gate return (FALSE); 27307c478bd9Sstevel@tonic-gate return (xdr_u_int(xdrs, &objp->locker.locker4_u.lock_owner. 27310a701b1eSRobert Gordon lock_seqid)); 27327c478bd9Sstevel@tonic-gate } 27337c478bd9Sstevel@tonic-gate 27347c478bd9Sstevel@tonic-gate /* 27357c478bd9Sstevel@tonic-gate * Optimized free case 27367c478bd9Sstevel@tonic-gate */ 27377c478bd9Sstevel@tonic-gate if (objp->locker.new_lock_owner == TRUE) { 27387c478bd9Sstevel@tonic-gate if (objp->locker.locker4_u.open_owner.lock_owner.owner_val != 27390a701b1eSRobert Gordon NULL) { 27407c478bd9Sstevel@tonic-gate kmem_free(objp->locker.locker4_u.open_owner.lock_owner. 27410a701b1eSRobert Gordon owner_val, 27420a701b1eSRobert Gordon objp->locker.locker4_u.open_owner.lock_owner. 27430a701b1eSRobert Gordon owner_len); 27447c478bd9Sstevel@tonic-gate } 27457c478bd9Sstevel@tonic-gate } 27467c478bd9Sstevel@tonic-gate 27477c478bd9Sstevel@tonic-gate return (TRUE); 27487c478bd9Sstevel@tonic-gate } 27497c478bd9Sstevel@tonic-gate 27507c478bd9Sstevel@tonic-gate static bool_t 27517c478bd9Sstevel@tonic-gate xdr_LOCK4res(XDR *xdrs, LOCK4res *objp) 27527c478bd9Sstevel@tonic-gate { 27537c478bd9Sstevel@tonic-gate if (xdrs->x_op != XDR_FREE) { 27547c478bd9Sstevel@tonic-gate if (!xdr_int(xdrs, (int32_t *)&objp->status)) 27557c478bd9Sstevel@tonic-gate return (FALSE); 27567c478bd9Sstevel@tonic-gate if (objp->status == NFS4_OK) { 27577c478bd9Sstevel@tonic-gate if (!xdr_u_int(xdrs, 27580a701b1eSRobert Gordon &objp->LOCK4res_u.lock_stateid.seqid)) 27597c478bd9Sstevel@tonic-gate return (FALSE); 27607c478bd9Sstevel@tonic-gate return (xdr_opaque(xdrs, 27610a701b1eSRobert Gordon objp->LOCK4res_u.lock_stateid.other, 12)); 27627c478bd9Sstevel@tonic-gate } 27637c478bd9Sstevel@tonic-gate if (objp->status != NFS4ERR_DENIED) 27647c478bd9Sstevel@tonic-gate return (TRUE); 27657c478bd9Sstevel@tonic-gate 27667c478bd9Sstevel@tonic-gate if (!xdr_u_longlong_t(xdrs, (u_longlong_t *)&objp->LOCK4res_u. 27670a701b1eSRobert Gordon denied.offset)) 27687c478bd9Sstevel@tonic-gate return (FALSE); 27697c478bd9Sstevel@tonic-gate if (!xdr_u_longlong_t(xdrs, (u_longlong_t *)&objp->LOCK4res_u. 27700a701b1eSRobert Gordon denied.length)) 27717c478bd9Sstevel@tonic-gate return (FALSE); 27727c478bd9Sstevel@tonic-gate if (!xdr_int(xdrs, (int *)&objp->LOCK4res_u.denied.locktype)) 27737c478bd9Sstevel@tonic-gate return (FALSE); 27747c478bd9Sstevel@tonic-gate if (!xdr_u_longlong_t(xdrs, (u_longlong_t *)&objp->LOCK4res_u. 27750a701b1eSRobert Gordon denied.owner.clientid)) 27767c478bd9Sstevel@tonic-gate return (FALSE); 27777c478bd9Sstevel@tonic-gate return (xdr_bytes(xdrs, 27780a701b1eSRobert Gordon (char **)&objp->LOCK4res_u.denied.owner.owner_val, 27790a701b1eSRobert Gordon (uint_t *)&objp->LOCK4res_u.denied.owner.owner_len, 27800a701b1eSRobert Gordon NFS4_OPAQUE_LIMIT)); 27817c478bd9Sstevel@tonic-gate } 27827c478bd9Sstevel@tonic-gate 27837c478bd9Sstevel@tonic-gate /* 27847c478bd9Sstevel@tonic-gate * Optimized free case 27857c478bd9Sstevel@tonic-gate */ 27867c478bd9Sstevel@tonic-gate if (objp->status == NFS4_OK || objp->status != NFS4ERR_DENIED) 27877c478bd9Sstevel@tonic-gate return (TRUE); 27887c478bd9Sstevel@tonic-gate 27897c478bd9Sstevel@tonic-gate if (objp->LOCK4res_u.denied.owner.owner_val != NULL) 27907c478bd9Sstevel@tonic-gate kmem_free(objp->LOCK4res_u.denied.owner.owner_val, 27910a701b1eSRobert Gordon objp->LOCK4res_u.denied.owner.owner_len); 27927c478bd9Sstevel@tonic-gate return (TRUE); 27937c478bd9Sstevel@tonic-gate } 27947c478bd9Sstevel@tonic-gate 27957c478bd9Sstevel@tonic-gate static bool_t 27967c478bd9Sstevel@tonic-gate xdr_LOCKT4args(XDR *xdrs, LOCKT4args *objp) 27977c478bd9Sstevel@tonic-gate { 27987c478bd9Sstevel@tonic-gate if (xdrs->x_op != XDR_FREE) { 27997c478bd9Sstevel@tonic-gate if (!xdr_int(xdrs, (int *)&objp->locktype)) 28007c478bd9Sstevel@tonic-gate return (FALSE); 28017c478bd9Sstevel@tonic-gate if (!xdr_u_longlong_t(xdrs, (u_longlong_t *)&objp->offset)) 28027c478bd9Sstevel@tonic-gate return (FALSE); 28037c478bd9Sstevel@tonic-gate if (!xdr_u_longlong_t(xdrs, (u_longlong_t *)&objp->length)) 28047c478bd9Sstevel@tonic-gate return (FALSE); 28057c478bd9Sstevel@tonic-gate if (!xdr_u_longlong_t(xdrs, 28060a701b1eSRobert Gordon (u_longlong_t *)&objp->owner.clientid)) 28077c478bd9Sstevel@tonic-gate return (FALSE); 28087c478bd9Sstevel@tonic-gate return (xdr_bytes(xdrs, (char **)&objp->owner.owner_val, 28090a701b1eSRobert Gordon (uint_t *)&objp->owner.owner_len, 28100a701b1eSRobert Gordon NFS4_OPAQUE_LIMIT)); 28117c478bd9Sstevel@tonic-gate } 28127c478bd9Sstevel@tonic-gate 28137c478bd9Sstevel@tonic-gate /* 28147c478bd9Sstevel@tonic-gate * Optimized free case 28157c478bd9Sstevel@tonic-gate */ 28167c478bd9Sstevel@tonic-gate if (objp->owner.owner_val != NULL) 28177c478bd9Sstevel@tonic-gate kmem_free(objp->owner.owner_val, objp->owner.owner_len); 28187c478bd9Sstevel@tonic-gate return (TRUE); 28197c478bd9Sstevel@tonic-gate } 28207c478bd9Sstevel@tonic-gate 28217c478bd9Sstevel@tonic-gate static bool_t 28227c478bd9Sstevel@tonic-gate xdr_LOCKT4res(XDR *xdrs, LOCKT4res *objp) 28237c478bd9Sstevel@tonic-gate { 28247c478bd9Sstevel@tonic-gate if (xdrs->x_op != XDR_FREE) { 28257c478bd9Sstevel@tonic-gate if (!xdr_int(xdrs, (int32_t *)&objp->status)) 28267c478bd9Sstevel@tonic-gate return (FALSE); 28277c478bd9Sstevel@tonic-gate if (objp->status == NFS4_OK) 28287c478bd9Sstevel@tonic-gate return (TRUE); 28297c478bd9Sstevel@tonic-gate if (objp->status != NFS4ERR_DENIED) 28307c478bd9Sstevel@tonic-gate return (TRUE); 28317c478bd9Sstevel@tonic-gate /* xdr_LOCK4denied */ 28327c478bd9Sstevel@tonic-gate if (!xdr_u_longlong_t(xdrs, 28330a701b1eSRobert Gordon (u_longlong_t *)&objp->denied.offset)) 28347c478bd9Sstevel@tonic-gate return (FALSE); 28357c478bd9Sstevel@tonic-gate if (!xdr_u_longlong_t(xdrs, 28360a701b1eSRobert Gordon (u_longlong_t *)&objp->denied.length)) 28377c478bd9Sstevel@tonic-gate return (FALSE); 28387c478bd9Sstevel@tonic-gate if (!xdr_int(xdrs, (int *)&objp->denied.locktype)) 28397c478bd9Sstevel@tonic-gate return (FALSE); 28407c478bd9Sstevel@tonic-gate if (!xdr_u_longlong_t(xdrs, 28410a701b1eSRobert Gordon (u_longlong_t *)&objp->denied.owner.clientid)) 28427c478bd9Sstevel@tonic-gate return (FALSE); 28437c478bd9Sstevel@tonic-gate return (xdr_bytes(xdrs, 28447c478bd9Sstevel@tonic-gate (char **)&objp->denied.owner.owner_val, 28457c478bd9Sstevel@tonic-gate (uint_t *)&objp->denied.owner.owner_len, 28467c478bd9Sstevel@tonic-gate NFS4_OPAQUE_LIMIT)); 28477c478bd9Sstevel@tonic-gate } 28487c478bd9Sstevel@tonic-gate 28497c478bd9Sstevel@tonic-gate /* 28507c478bd9Sstevel@tonic-gate * Optimized free case 28517c478bd9Sstevel@tonic-gate */ 28527c478bd9Sstevel@tonic-gate if (objp->status == NFS4_OK || objp->status != NFS4ERR_DENIED) 28537c478bd9Sstevel@tonic-gate return (TRUE); 28547c478bd9Sstevel@tonic-gate if (objp->denied.owner.owner_val != NULL) 28557c478bd9Sstevel@tonic-gate kmem_free(objp->denied.owner.owner_val, 28560a701b1eSRobert Gordon objp->denied.owner.owner_len); 28577c478bd9Sstevel@tonic-gate return (TRUE); 28587c478bd9Sstevel@tonic-gate } 28597c478bd9Sstevel@tonic-gate 28607c478bd9Sstevel@tonic-gate static bool_t 28617c478bd9Sstevel@tonic-gate xdr_LOCKU4args(XDR *xdrs, LOCKU4args *objp) 28627c478bd9Sstevel@tonic-gate { 28637c478bd9Sstevel@tonic-gate if (!xdr_int(xdrs, (int *)&objp->locktype)) 28647c478bd9Sstevel@tonic-gate return (FALSE); 28657c478bd9Sstevel@tonic-gate if (!xdr_u_int(xdrs, &objp->seqid)) 28667c478bd9Sstevel@tonic-gate return (FALSE); 28677c478bd9Sstevel@tonic-gate if (!xdr_u_int(xdrs, &objp->lock_stateid.seqid)) 28687c478bd9Sstevel@tonic-gate return (FALSE); 28697c478bd9Sstevel@tonic-gate if (!xdr_opaque(xdrs, objp->lock_stateid.other, 12)) 28707c478bd9Sstevel@tonic-gate return (FALSE); 28717c478bd9Sstevel@tonic-gate if (!xdr_u_longlong_t(xdrs, (u_longlong_t *)&objp->offset)) 28727c478bd9Sstevel@tonic-gate return (FALSE); 28737c478bd9Sstevel@tonic-gate return (xdr_u_longlong_t(xdrs, (u_longlong_t *)&objp->length)); 28747c478bd9Sstevel@tonic-gate } 28757c478bd9Sstevel@tonic-gate 28767c478bd9Sstevel@tonic-gate static bool_t 28777c478bd9Sstevel@tonic-gate xdr_OPEN4args(XDR *xdrs, OPEN4args *objp) 28787c478bd9Sstevel@tonic-gate { 28797c478bd9Sstevel@tonic-gate if (xdrs->x_op != XDR_FREE) { 28807c478bd9Sstevel@tonic-gate if (!xdr_u_int(xdrs, &objp->seqid)) 28817c478bd9Sstevel@tonic-gate return (FALSE); 28827c478bd9Sstevel@tonic-gate if (!xdr_u_int(xdrs, &objp->share_access)) 28837c478bd9Sstevel@tonic-gate return (FALSE); 28847c478bd9Sstevel@tonic-gate if (!xdr_u_int(xdrs, &objp->share_deny)) 28857c478bd9Sstevel@tonic-gate return (FALSE); 28867c478bd9Sstevel@tonic-gate 28877c478bd9Sstevel@tonic-gate /* xdr_open_owner4 */ 28887c478bd9Sstevel@tonic-gate if (!xdr_u_longlong_t(xdrs, 28890a701b1eSRobert Gordon (u_longlong_t *)&objp->owner.clientid)) 28907c478bd9Sstevel@tonic-gate return (FALSE); 28917c478bd9Sstevel@tonic-gate if (!xdr_bytes(xdrs, (char **)&objp->owner.owner_val, 28920a701b1eSRobert Gordon (uint_t *)&objp->owner.owner_len, 28930a701b1eSRobert Gordon NFS4_OPAQUE_LIMIT)) 28947c478bd9Sstevel@tonic-gate return (FALSE); 28957c478bd9Sstevel@tonic-gate 28967c478bd9Sstevel@tonic-gate /* xdr_openflag4 */ 28977c478bd9Sstevel@tonic-gate if (!xdr_int(xdrs, (int *)&objp->opentype)) 28987c478bd9Sstevel@tonic-gate return (FALSE); 28997c478bd9Sstevel@tonic-gate if (objp->opentype == OPEN4_CREATE) { 29007c478bd9Sstevel@tonic-gate 29017c478bd9Sstevel@tonic-gate /* xdr_createhow4 */ 29027c478bd9Sstevel@tonic-gate if (!xdr_int(xdrs, (int *)&objp->mode)) 29037c478bd9Sstevel@tonic-gate return (FALSE); 29047c478bd9Sstevel@tonic-gate switch (objp->mode) { 29057c478bd9Sstevel@tonic-gate case UNCHECKED4: 29067c478bd9Sstevel@tonic-gate case GUARDED4: 29077c478bd9Sstevel@tonic-gate if (!xdr_fattr4(xdrs, 29080a701b1eSRobert Gordon &objp->createhow4_u.createattrs)) 29097c478bd9Sstevel@tonic-gate return (FALSE); 29107c478bd9Sstevel@tonic-gate break; 29117c478bd9Sstevel@tonic-gate case EXCLUSIVE4: 29127c478bd9Sstevel@tonic-gate if (!xdr_u_longlong_t(xdrs, 29137c478bd9Sstevel@tonic-gate (u_longlong_t *)&objp->createhow4_u. 29147c478bd9Sstevel@tonic-gate createverf)) 29157c478bd9Sstevel@tonic-gate return (FALSE); 29167c478bd9Sstevel@tonic-gate break; 29177c478bd9Sstevel@tonic-gate default: 29187c478bd9Sstevel@tonic-gate return (FALSE); 29197c478bd9Sstevel@tonic-gate } 29207c478bd9Sstevel@tonic-gate } 29217c478bd9Sstevel@tonic-gate 29227c478bd9Sstevel@tonic-gate /* xdr_open_claim4 */ 29237c478bd9Sstevel@tonic-gate if (!xdr_int(xdrs, (int *)&objp->claim)) 29247c478bd9Sstevel@tonic-gate return (FALSE); 29257c478bd9Sstevel@tonic-gate 29267c478bd9Sstevel@tonic-gate switch (objp->claim) { 29277c478bd9Sstevel@tonic-gate case CLAIM_NULL: 29287c478bd9Sstevel@tonic-gate return (xdr_bytes(xdrs, (char **)&objp->open_claim4_u. 29290a701b1eSRobert Gordon file.utf8string_val, 29300a701b1eSRobert Gordon (uint_t *)&objp->open_claim4_u.file. 29310a701b1eSRobert Gordon utf8string_len, 29320a701b1eSRobert Gordon NFS4_MAX_UTF8STRING)); 29337c478bd9Sstevel@tonic-gate case CLAIM_PREVIOUS: 29347c478bd9Sstevel@tonic-gate return (xdr_int(xdrs, 29350a701b1eSRobert Gordon (int *)&objp->open_claim4_u.delegate_type)); 29367c478bd9Sstevel@tonic-gate case CLAIM_DELEGATE_CUR: 29377c478bd9Sstevel@tonic-gate if (!xdr_u_int(xdrs, (uint_t *)&objp->open_claim4_u. 29380a701b1eSRobert Gordon delegate_cur_info.delegate_stateid.seqid)) 29397c478bd9Sstevel@tonic-gate return (FALSE); 29407c478bd9Sstevel@tonic-gate if (!xdr_opaque(xdrs, objp->open_claim4_u. 29410a701b1eSRobert Gordon delegate_cur_info.delegate_stateid.other, 29420a701b1eSRobert Gordon 12)) 29437c478bd9Sstevel@tonic-gate return (FALSE); 29447c478bd9Sstevel@tonic-gate return (xdr_bytes(xdrs, (char **)&objp->open_claim4_u. 29450a701b1eSRobert Gordon delegate_cur_info.file.utf8string_val, 29467c478bd9Sstevel@tonic-gate (uint_t *)&objp->open_claim4_u. 29470a701b1eSRobert Gordon delegate_cur_info.file.utf8string_len, 29487c478bd9Sstevel@tonic-gate NFS4_MAX_UTF8STRING)); 29497c478bd9Sstevel@tonic-gate case CLAIM_DELEGATE_PREV: 29507c478bd9Sstevel@tonic-gate return (xdr_bytes(xdrs, (char **)&objp->open_claim4_u. 29510a701b1eSRobert Gordon file_delegate_prev.utf8string_val, 29527c478bd9Sstevel@tonic-gate (uint_t *)&objp->open_claim4_u. 29530a701b1eSRobert Gordon file_delegate_prev.utf8string_len, 29547c478bd9Sstevel@tonic-gate NFS4_MAX_UTF8STRING)); 29557c478bd9Sstevel@tonic-gate default: 29567c478bd9Sstevel@tonic-gate return (FALSE); 29577c478bd9Sstevel@tonic-gate } 29587c478bd9Sstevel@tonic-gate } 29597c478bd9Sstevel@tonic-gate 29607c478bd9Sstevel@tonic-gate /* 29617c478bd9Sstevel@tonic-gate * Optimized free case 29627c478bd9Sstevel@tonic-gate */ 29637c478bd9Sstevel@tonic-gate if (objp->owner.owner_val != NULL) 29647c478bd9Sstevel@tonic-gate kmem_free(objp->owner.owner_val, objp->owner.owner_len); 29657c478bd9Sstevel@tonic-gate 29667c478bd9Sstevel@tonic-gate if (objp->opentype == OPEN4_CREATE) { 29677c478bd9Sstevel@tonic-gate switch (objp->mode) { 29687c478bd9Sstevel@tonic-gate case UNCHECKED4: 29697c478bd9Sstevel@tonic-gate case GUARDED4: 29707c478bd9Sstevel@tonic-gate (void) xdr_fattr4(xdrs, 29710a701b1eSRobert Gordon &objp->createhow4_u.createattrs); 29727c478bd9Sstevel@tonic-gate break; 29737c478bd9Sstevel@tonic-gate case EXCLUSIVE4: 29747c478bd9Sstevel@tonic-gate default: 29757c478bd9Sstevel@tonic-gate break; 29767c478bd9Sstevel@tonic-gate } 29777c478bd9Sstevel@tonic-gate } 29787c478bd9Sstevel@tonic-gate 29797c478bd9Sstevel@tonic-gate switch (objp->claim) { 29807c478bd9Sstevel@tonic-gate case CLAIM_NULL: 29817c478bd9Sstevel@tonic-gate if (objp->open_claim4_u.file.utf8string_val != NULL) 29827c478bd9Sstevel@tonic-gate kmem_free(objp->open_claim4_u.file.utf8string_val, 29830a701b1eSRobert Gordon objp->open_claim4_u.file.utf8string_len); 29847c478bd9Sstevel@tonic-gate return (TRUE); 29857c478bd9Sstevel@tonic-gate case CLAIM_PREVIOUS: 29867c478bd9Sstevel@tonic-gate return (TRUE); 29877c478bd9Sstevel@tonic-gate case CLAIM_DELEGATE_CUR: 29887c478bd9Sstevel@tonic-gate if (objp->open_claim4_u.delegate_cur_info.file.utf8string_val != 29890a701b1eSRobert Gordon NULL) { 29907c478bd9Sstevel@tonic-gate kmem_free(objp->open_claim4_u.delegate_cur_info.file. 29910a701b1eSRobert Gordon utf8string_val, 29920a701b1eSRobert Gordon objp->open_claim4_u.delegate_cur_info.file. 29930a701b1eSRobert Gordon utf8string_len); 29947c478bd9Sstevel@tonic-gate } 29957c478bd9Sstevel@tonic-gate return (TRUE); 29967c478bd9Sstevel@tonic-gate case CLAIM_DELEGATE_PREV: 29977c478bd9Sstevel@tonic-gate if (objp->open_claim4_u.file_delegate_prev.utf8string_val != 29980a701b1eSRobert Gordon NULL) { 29997c478bd9Sstevel@tonic-gate kmem_free(objp->open_claim4_u.file_delegate_prev. 30000a701b1eSRobert Gordon utf8string_val, 30010a701b1eSRobert Gordon objp->open_claim4_u.file_delegate_prev. 30020a701b1eSRobert Gordon utf8string_len); 30037c478bd9Sstevel@tonic-gate } 30047c478bd9Sstevel@tonic-gate return (TRUE); 30057c478bd9Sstevel@tonic-gate default: 30067c478bd9Sstevel@tonic-gate return (TRUE); 30077c478bd9Sstevel@tonic-gate } 30087c478bd9Sstevel@tonic-gate } 30097c478bd9Sstevel@tonic-gate 30107c478bd9Sstevel@tonic-gate static bool_t 30117c478bd9Sstevel@tonic-gate xdr_OPEN4cargs(XDR *xdrs, OPEN4cargs *objp) 30127c478bd9Sstevel@tonic-gate { 30137c478bd9Sstevel@tonic-gate int op; 30147c478bd9Sstevel@tonic-gate int len; 30157c478bd9Sstevel@tonic-gate rpc_inline_t *ptr; 30167c478bd9Sstevel@tonic-gate 30177c478bd9Sstevel@tonic-gate ASSERT(xdrs->x_op == XDR_ENCODE); 30187c478bd9Sstevel@tonic-gate 30197c478bd9Sstevel@tonic-gate /* 30207c478bd9Sstevel@tonic-gate * We must always define the client's open_owner to be 30217c478bd9Sstevel@tonic-gate * 4 byte aligned and sized. 30227c478bd9Sstevel@tonic-gate */ 30237c478bd9Sstevel@tonic-gate ASSERT(objp->owner.owner_len <= NFS4_OPAQUE_LIMIT); 30247c478bd9Sstevel@tonic-gate ASSERT(!(objp->owner.owner_len % BYTES_PER_XDR_UNIT)); 30257c478bd9Sstevel@tonic-gate 30267c478bd9Sstevel@tonic-gate len = objp->owner.owner_len; 30277c478bd9Sstevel@tonic-gate if ((ptr = XDR_INLINE(xdrs, 8 * BYTES_PER_XDR_UNIT + len)) != NULL) { 30287c478bd9Sstevel@tonic-gate int i; 30297c478bd9Sstevel@tonic-gate int32_t *ip; 30307c478bd9Sstevel@tonic-gate 30317c478bd9Sstevel@tonic-gate IXDR_PUT_U_INT32(ptr, OP_OPEN); 30327c478bd9Sstevel@tonic-gate IXDR_PUT_U_INT32(ptr, objp->seqid); 30337c478bd9Sstevel@tonic-gate IXDR_PUT_U_INT32(ptr, objp->share_access); 30347c478bd9Sstevel@tonic-gate IXDR_PUT_U_INT32(ptr, objp->share_deny); 30357c478bd9Sstevel@tonic-gate 30367c478bd9Sstevel@tonic-gate /* xdr_open_owner4 */ 30377c478bd9Sstevel@tonic-gate IXDR_PUT_HYPER(ptr, objp->owner.clientid); 30387c478bd9Sstevel@tonic-gate IXDR_PUT_U_INT32(ptr, objp->owner.owner_len); 30397c478bd9Sstevel@tonic-gate /* We know this is very short so don't bcopy */ 30407c478bd9Sstevel@tonic-gate ip = (int32_t *)objp->owner.owner_val; 30417c478bd9Sstevel@tonic-gate len /= BYTES_PER_XDR_UNIT; 30427c478bd9Sstevel@tonic-gate for (i = 0; i < len; i++) 30437c478bd9Sstevel@tonic-gate *ptr++ = *ip++; 30447c478bd9Sstevel@tonic-gate 30457c478bd9Sstevel@tonic-gate /* xdr_openflag4 */ 30467c478bd9Sstevel@tonic-gate IXDR_PUT_U_INT32(ptr, objp->opentype); 30477c478bd9Sstevel@tonic-gate } else { 30487c478bd9Sstevel@tonic-gate op = OP_OPEN; 30497c478bd9Sstevel@tonic-gate if (!XDR_PUTINT32(xdrs, (int32_t *)&op)) 30507c478bd9Sstevel@tonic-gate return (FALSE); 30517c478bd9Sstevel@tonic-gate if (!XDR_PUTINT32(xdrs, (int32_t *)&objp->seqid)) 30527c478bd9Sstevel@tonic-gate return (FALSE); 30537c478bd9Sstevel@tonic-gate if (!XDR_PUTINT32(xdrs, (int32_t *)&objp->share_access)) 30547c478bd9Sstevel@tonic-gate return (FALSE); 30557c478bd9Sstevel@tonic-gate if (!XDR_PUTINT32(xdrs, (int32_t *)&objp->share_deny)) 30567c478bd9Sstevel@tonic-gate return (FALSE); 30577c478bd9Sstevel@tonic-gate 30587c478bd9Sstevel@tonic-gate /* xdr_open_owner4 */ 30597c478bd9Sstevel@tonic-gate if (!xdr_u_longlong_t(xdrs, 30600a701b1eSRobert Gordon (u_longlong_t *)&objp->owner.clientid)) 30617c478bd9Sstevel@tonic-gate return (FALSE); 30627c478bd9Sstevel@tonic-gate if (!XDR_PUTINT32(xdrs, (int32_t *)&objp->owner.owner_len)) 30637c478bd9Sstevel@tonic-gate return (FALSE); 30647c478bd9Sstevel@tonic-gate if (!xdr_opaque(xdrs, objp->owner.owner_val, 30650a701b1eSRobert Gordon objp->owner.owner_len)) 30667c478bd9Sstevel@tonic-gate return (FALSE); 30677c478bd9Sstevel@tonic-gate 30687c478bd9Sstevel@tonic-gate /* xdr_openflag4 */ 30697c478bd9Sstevel@tonic-gate if (!XDR_PUTINT32(xdrs, (int32_t *)&objp->opentype)) 30707c478bd9Sstevel@tonic-gate return (FALSE); 30717c478bd9Sstevel@tonic-gate } 30727c478bd9Sstevel@tonic-gate 30737c478bd9Sstevel@tonic-gate if (objp->opentype == OPEN4_CREATE) { 30747c478bd9Sstevel@tonic-gate /* xdr_createhow4 */ 30757c478bd9Sstevel@tonic-gate if (!XDR_PUTINT32(xdrs, (int32_t *)&objp->mode)) 30767c478bd9Sstevel@tonic-gate return (FALSE); 30777c478bd9Sstevel@tonic-gate switch (objp->mode) { 30787c478bd9Sstevel@tonic-gate case UNCHECKED4: 30797c478bd9Sstevel@tonic-gate case GUARDED4: 30807c478bd9Sstevel@tonic-gate if (!xdr_fattr4(xdrs, 30810a701b1eSRobert Gordon &objp->createhow4_u.createattrs)) 30827c478bd9Sstevel@tonic-gate return (FALSE); 30837c478bd9Sstevel@tonic-gate break; 30847c478bd9Sstevel@tonic-gate case EXCLUSIVE4: 30857c478bd9Sstevel@tonic-gate if (!xdr_u_longlong_t(xdrs, 30867c478bd9Sstevel@tonic-gate (u_longlong_t *)&objp->createhow4_u. 30877c478bd9Sstevel@tonic-gate createverf)) 30887c478bd9Sstevel@tonic-gate return (FALSE); 30897c478bd9Sstevel@tonic-gate break; 30907c478bd9Sstevel@tonic-gate default: 30917c478bd9Sstevel@tonic-gate return (FALSE); 30927c478bd9Sstevel@tonic-gate } 30937c478bd9Sstevel@tonic-gate } 30947c478bd9Sstevel@tonic-gate 30957c478bd9Sstevel@tonic-gate /* xdr_open_claim4 */ 30967c478bd9Sstevel@tonic-gate if (!XDR_PUTINT32(xdrs, (int32_t *)&objp->claim)) 30977c478bd9Sstevel@tonic-gate return (FALSE); 30987c478bd9Sstevel@tonic-gate 30997c478bd9Sstevel@tonic-gate switch (objp->claim) { 31007c478bd9Sstevel@tonic-gate case CLAIM_NULL: 31017c478bd9Sstevel@tonic-gate len = strlen(objp->open_claim4_u.cfile); 31027c478bd9Sstevel@tonic-gate if (len > NFS4_MAX_UTF8STRING) 31037c478bd9Sstevel@tonic-gate return (FALSE); 31047c478bd9Sstevel@tonic-gate if (XDR_PUTINT32(xdrs, &len)) { 31057c478bd9Sstevel@tonic-gate return (xdr_opaque(xdrs, 31060a701b1eSRobert Gordon objp->open_claim4_u.cfile, len)); 31077c478bd9Sstevel@tonic-gate } 31087c478bd9Sstevel@tonic-gate return (FALSE); 31097c478bd9Sstevel@tonic-gate case CLAIM_PREVIOUS: 31107c478bd9Sstevel@tonic-gate return (XDR_PUTINT32(xdrs, 31110a701b1eSRobert Gordon (int32_t *)&objp->open_claim4_u.delegate_type)); 31127c478bd9Sstevel@tonic-gate case CLAIM_DELEGATE_CUR: 31137c478bd9Sstevel@tonic-gate if (!XDR_PUTINT32(xdrs, (int32_t *)&objp->open_claim4_u. 31140a701b1eSRobert Gordon delegate_cur_info.delegate_stateid.seqid)) 31157c478bd9Sstevel@tonic-gate return (FALSE); 31167c478bd9Sstevel@tonic-gate if (!xdr_opaque(xdrs, objp->open_claim4_u. 31170a701b1eSRobert Gordon delegate_cur_info.delegate_stateid.other, 31180a701b1eSRobert Gordon 12)) 31197c478bd9Sstevel@tonic-gate return (FALSE); 31207c478bd9Sstevel@tonic-gate len = strlen(objp->open_claim4_u.delegate_cur_info.cfile); 31217c478bd9Sstevel@tonic-gate if (len > NFS4_MAX_UTF8STRING) 31227c478bd9Sstevel@tonic-gate return (FALSE); 31237c478bd9Sstevel@tonic-gate if (XDR_PUTINT32(xdrs, &len)) { 31247c478bd9Sstevel@tonic-gate return (xdr_opaque(xdrs, 31250a701b1eSRobert Gordon objp->open_claim4_u.delegate_cur_info.cfile, 31260a701b1eSRobert Gordon len)); 31277c478bd9Sstevel@tonic-gate } 31287c478bd9Sstevel@tonic-gate return (FALSE); 31297c478bd9Sstevel@tonic-gate case CLAIM_DELEGATE_PREV: 31307c478bd9Sstevel@tonic-gate len = strlen(objp->open_claim4_u.cfile_delegate_prev); 31317c478bd9Sstevel@tonic-gate if (len > NFS4_MAX_UTF8STRING) 31327c478bd9Sstevel@tonic-gate return (FALSE); 31337c478bd9Sstevel@tonic-gate if (XDR_PUTINT32(xdrs, &len)) { 31347c478bd9Sstevel@tonic-gate return (xdr_opaque(xdrs, 31350a701b1eSRobert Gordon objp->open_claim4_u.cfile_delegate_prev, len)); 31367c478bd9Sstevel@tonic-gate } 31377c478bd9Sstevel@tonic-gate return (FALSE); 31387c478bd9Sstevel@tonic-gate default: 31397c478bd9Sstevel@tonic-gate return (FALSE); 31407c478bd9Sstevel@tonic-gate } 31417c478bd9Sstevel@tonic-gate } 31427c478bd9Sstevel@tonic-gate 31437c478bd9Sstevel@tonic-gate static bool_t 31447c478bd9Sstevel@tonic-gate xdr_OPEN4res(XDR *xdrs, OPEN4res *objp) 31457c478bd9Sstevel@tonic-gate { 31467c478bd9Sstevel@tonic-gate if (xdrs->x_op != XDR_FREE) { 31477c478bd9Sstevel@tonic-gate if (!xdr_int(xdrs, (int32_t *)&objp->status)) 31487c478bd9Sstevel@tonic-gate return (FALSE); 31497c478bd9Sstevel@tonic-gate if (objp->status != NFS4_OK) 31507c478bd9Sstevel@tonic-gate return (TRUE); 31517c478bd9Sstevel@tonic-gate if (!xdr_u_int(xdrs, &objp->stateid.seqid)) 31527c478bd9Sstevel@tonic-gate return (FALSE); 31537c478bd9Sstevel@tonic-gate if (!xdr_opaque(xdrs, objp->stateid.other, 12)) 31547c478bd9Sstevel@tonic-gate return (FALSE); 31557c478bd9Sstevel@tonic-gate if (!xdr_bool(xdrs, &objp->cinfo.atomic)) 31567c478bd9Sstevel@tonic-gate return (FALSE); 31577c478bd9Sstevel@tonic-gate if (!xdr_u_longlong_t(xdrs, 31580a701b1eSRobert Gordon (u_longlong_t *)&objp->cinfo.before)) 31597c478bd9Sstevel@tonic-gate return (FALSE); 31607c478bd9Sstevel@tonic-gate if (!xdr_u_longlong_t(xdrs, (u_longlong_t *)&objp->cinfo.after)) 31617c478bd9Sstevel@tonic-gate return (FALSE); 31627c478bd9Sstevel@tonic-gate if (!xdr_u_int(xdrs, &objp->rflags)) 31637c478bd9Sstevel@tonic-gate return (FALSE); 31647c478bd9Sstevel@tonic-gate if (!xdr_bitmap4(xdrs, &objp->attrset)) 31657c478bd9Sstevel@tonic-gate return (FALSE); 31667c478bd9Sstevel@tonic-gate if (!xdr_int(xdrs, 31670a701b1eSRobert Gordon (int *)&objp->delegation.delegation_type)) 31687c478bd9Sstevel@tonic-gate return (FALSE); 31697c478bd9Sstevel@tonic-gate switch (objp->delegation.delegation_type) { 31707c478bd9Sstevel@tonic-gate case OPEN_DELEGATE_NONE: 31717c478bd9Sstevel@tonic-gate return (TRUE); 31727c478bd9Sstevel@tonic-gate case OPEN_DELEGATE_READ: 31737c478bd9Sstevel@tonic-gate if (!xdr_u_int(xdrs, &objp->delegation. 31740a701b1eSRobert Gordon open_delegation4_u.read.stateid.seqid)) 31757c478bd9Sstevel@tonic-gate return (FALSE); 31767c478bd9Sstevel@tonic-gate if (!xdr_opaque(xdrs, objp->delegation. 31770a701b1eSRobert Gordon open_delegation4_u.read.stateid.other, 31780a701b1eSRobert Gordon 12)) 31797c478bd9Sstevel@tonic-gate return (FALSE); 31807c478bd9Sstevel@tonic-gate if (!xdr_bool(xdrs, &objp->delegation. 31810a701b1eSRobert Gordon open_delegation4_u.read.recall)) 31827c478bd9Sstevel@tonic-gate return (FALSE); 31837c478bd9Sstevel@tonic-gate return (xdr_nfsace4(xdrs, &objp->delegation. 31840a701b1eSRobert Gordon open_delegation4_u.read.permissions)); 31857c478bd9Sstevel@tonic-gate case OPEN_DELEGATE_WRITE: 31867c478bd9Sstevel@tonic-gate if (!xdr_u_int(xdrs, &objp->delegation. 31870a701b1eSRobert Gordon open_delegation4_u.write.stateid.seqid)) 31887c478bd9Sstevel@tonic-gate return (FALSE); 31897c478bd9Sstevel@tonic-gate if (!xdr_opaque(xdrs, objp->delegation. 31900a701b1eSRobert Gordon open_delegation4_u.write.stateid.other, 31910a701b1eSRobert Gordon 12)) 31927c478bd9Sstevel@tonic-gate return (FALSE); 31937c478bd9Sstevel@tonic-gate if (!xdr_bool(xdrs, &objp->delegation. 31940a701b1eSRobert Gordon open_delegation4_u.write.recall)) 31957c478bd9Sstevel@tonic-gate return (FALSE); 31967c478bd9Sstevel@tonic-gate if (!xdr_int(xdrs, (int *)&objp->delegation. 31970a701b1eSRobert Gordon open_delegation4_u.write.space_limit. 31980a701b1eSRobert Gordon limitby)) 31997c478bd9Sstevel@tonic-gate return (FALSE); 32007c478bd9Sstevel@tonic-gate switch (objp->delegation. 32010a701b1eSRobert Gordon open_delegation4_u.write.space_limit. 32020a701b1eSRobert Gordon limitby) { 32037c478bd9Sstevel@tonic-gate case NFS_LIMIT_SIZE: 32047c478bd9Sstevel@tonic-gate if (!xdr_u_longlong_t(xdrs, 32057c478bd9Sstevel@tonic-gate (u_longlong_t *)&objp->delegation. 32067c478bd9Sstevel@tonic-gate open_delegation4_u.write.space_limit. 32077c478bd9Sstevel@tonic-gate nfs_space_limit4_u.filesize)) 32087c478bd9Sstevel@tonic-gate return (FALSE); 32097c478bd9Sstevel@tonic-gate break; 32107c478bd9Sstevel@tonic-gate case NFS_LIMIT_BLOCKS: 32117c478bd9Sstevel@tonic-gate if (!xdr_u_int(xdrs, 32127c478bd9Sstevel@tonic-gate &objp->delegation.open_delegation4_u.write. 32137c478bd9Sstevel@tonic-gate space_limit.nfs_space_limit4_u. 32147c478bd9Sstevel@tonic-gate mod_blocks.num_blocks)) 32157c478bd9Sstevel@tonic-gate return (FALSE); 32167c478bd9Sstevel@tonic-gate if (!xdr_u_int(xdrs, &objp->delegation. 32177c478bd9Sstevel@tonic-gate open_delegation4_u.write.space_limit. 32187c478bd9Sstevel@tonic-gate nfs_space_limit4_u.mod_blocks. 32197c478bd9Sstevel@tonic-gate bytes_per_block)) 32207c478bd9Sstevel@tonic-gate return (FALSE); 32217c478bd9Sstevel@tonic-gate break; 32227c478bd9Sstevel@tonic-gate default: 32237c478bd9Sstevel@tonic-gate return (FALSE); 32247c478bd9Sstevel@tonic-gate } 32257c478bd9Sstevel@tonic-gate return (xdr_nfsace4(xdrs, &objp->delegation. 32267c478bd9Sstevel@tonic-gate open_delegation4_u.write.permissions)); 32277c478bd9Sstevel@tonic-gate } 32287c478bd9Sstevel@tonic-gate return (FALSE); 32297c478bd9Sstevel@tonic-gate } 32307c478bd9Sstevel@tonic-gate 32317c478bd9Sstevel@tonic-gate /* 32327c478bd9Sstevel@tonic-gate * Optimized free case 32337c478bd9Sstevel@tonic-gate */ 32347c478bd9Sstevel@tonic-gate if (objp->status != NFS4_OK) 32357c478bd9Sstevel@tonic-gate return (TRUE); 32367c478bd9Sstevel@tonic-gate 32377c478bd9Sstevel@tonic-gate switch (objp->delegation.delegation_type) { 32387c478bd9Sstevel@tonic-gate case OPEN_DELEGATE_NONE: 32397c478bd9Sstevel@tonic-gate return (TRUE); 32407c478bd9Sstevel@tonic-gate case OPEN_DELEGATE_READ: 32417c478bd9Sstevel@tonic-gate return (xdr_nfsace4(xdrs, &objp->delegation. 32420a701b1eSRobert Gordon open_delegation4_u.read.permissions)); 32437c478bd9Sstevel@tonic-gate case OPEN_DELEGATE_WRITE: 32447c478bd9Sstevel@tonic-gate switch (objp->delegation. 32450a701b1eSRobert Gordon open_delegation4_u.write.space_limit.limitby) { 32467c478bd9Sstevel@tonic-gate case NFS_LIMIT_SIZE: 32477c478bd9Sstevel@tonic-gate case NFS_LIMIT_BLOCKS: 32487c478bd9Sstevel@tonic-gate break; 32497c478bd9Sstevel@tonic-gate default: 32507c478bd9Sstevel@tonic-gate return (FALSE); 32517c478bd9Sstevel@tonic-gate } 32527c478bd9Sstevel@tonic-gate return (xdr_nfsace4(xdrs, &objp->delegation. 32530a701b1eSRobert Gordon open_delegation4_u.write.permissions)); 32547c478bd9Sstevel@tonic-gate } 32557c478bd9Sstevel@tonic-gate return (FALSE); 32567c478bd9Sstevel@tonic-gate } 32577c478bd9Sstevel@tonic-gate 32587c478bd9Sstevel@tonic-gate static bool_t 32597c478bd9Sstevel@tonic-gate xdr_OPEN_CONFIRM4res(XDR *xdrs, OPEN_CONFIRM4res *objp) 32607c478bd9Sstevel@tonic-gate { 32617c478bd9Sstevel@tonic-gate if (!xdr_int(xdrs, (int32_t *)&objp->status)) 32627c478bd9Sstevel@tonic-gate return (FALSE); 32637c478bd9Sstevel@tonic-gate if (objp->status != NFS4_OK) 32647c478bd9Sstevel@tonic-gate return (TRUE); 32657c478bd9Sstevel@tonic-gate if (!xdr_u_int(xdrs, &objp->open_stateid.seqid)) 32667c478bd9Sstevel@tonic-gate return (FALSE); 32677c478bd9Sstevel@tonic-gate return (xdr_opaque(xdrs, objp->open_stateid.other, 12)); 32687c478bd9Sstevel@tonic-gate } 32697c478bd9Sstevel@tonic-gate 32707c478bd9Sstevel@tonic-gate static bool_t 32717c478bd9Sstevel@tonic-gate xdr_OPEN_DOWNGRADE4args(XDR *xdrs, OPEN_DOWNGRADE4args *objp) 32727c478bd9Sstevel@tonic-gate { 32737c478bd9Sstevel@tonic-gate if (!xdr_u_int(xdrs, &objp->open_stateid.seqid)) 32747c478bd9Sstevel@tonic-gate return (FALSE); 32757c478bd9Sstevel@tonic-gate if (!xdr_opaque(xdrs, objp->open_stateid.other, 12)) 32767c478bd9Sstevel@tonic-gate return (FALSE); 32777c478bd9Sstevel@tonic-gate if (!xdr_u_int(xdrs, &objp->seqid)) 32787c478bd9Sstevel@tonic-gate return (FALSE); 32797c478bd9Sstevel@tonic-gate if (!xdr_u_int(xdrs, &objp->share_access)) 32807c478bd9Sstevel@tonic-gate return (FALSE); 32817c478bd9Sstevel@tonic-gate return (xdr_u_int(xdrs, &objp->share_deny)); 32827c478bd9Sstevel@tonic-gate } 32837c478bd9Sstevel@tonic-gate 32847c478bd9Sstevel@tonic-gate static bool_t 32857c478bd9Sstevel@tonic-gate xdr_OPEN_DOWNGRADE4res(XDR *xdrs, OPEN_DOWNGRADE4res *objp) 32867c478bd9Sstevel@tonic-gate { 32877c478bd9Sstevel@tonic-gate if (!xdr_int(xdrs, (int32_t *)&objp->status)) 32887c478bd9Sstevel@tonic-gate return (FALSE); 32897c478bd9Sstevel@tonic-gate if (objp->status != NFS4_OK) 32907c478bd9Sstevel@tonic-gate return (TRUE); 32917c478bd9Sstevel@tonic-gate if (!xdr_u_int(xdrs, &objp->open_stateid.seqid)) 32927c478bd9Sstevel@tonic-gate return (FALSE); 32937c478bd9Sstevel@tonic-gate return (xdr_opaque(xdrs, objp->open_stateid.other, 12)); 32947c478bd9Sstevel@tonic-gate } 32957c478bd9Sstevel@tonic-gate 32967c478bd9Sstevel@tonic-gate static bool_t 32977c478bd9Sstevel@tonic-gate xdr_READ4args(XDR *xdrs, READ4args *objp) 32987c478bd9Sstevel@tonic-gate { 32990a701b1eSRobert Gordon rdma_chunkinfo_t rci; 33000a701b1eSRobert Gordon rdma_wlist_conn_info_t rwci; 33010a701b1eSRobert Gordon struct xdr_ops *xops = xdrrdma_xops(); 33020a701b1eSRobert Gordon 33037c478bd9Sstevel@tonic-gate if (!xdr_u_int(xdrs, &objp->stateid.seqid)) 33047c478bd9Sstevel@tonic-gate return (FALSE); 33057c478bd9Sstevel@tonic-gate if (!xdr_opaque(xdrs, objp->stateid.other, 12)) 33067c478bd9Sstevel@tonic-gate return (FALSE); 33077c478bd9Sstevel@tonic-gate if (!xdr_u_longlong_t(xdrs, (u_longlong_t *)&objp->offset)) 33087c478bd9Sstevel@tonic-gate return (FALSE); 33090a701b1eSRobert Gordon if (!xdr_u_int(xdrs, &objp->count)) 33100a701b1eSRobert Gordon return (FALSE); 33110a701b1eSRobert Gordon 33120a701b1eSRobert Gordon DTRACE_PROBE1(xdr__i__read4args_buf_len, 33130a701b1eSRobert Gordon int, objp->count); 33140a701b1eSRobert Gordon 33150a701b1eSRobert Gordon objp->wlist = NULL; 33160a701b1eSRobert Gordon 33170a701b1eSRobert Gordon if (xdrs->x_ops == xops && xdrs->x_op == XDR_ENCODE) { 33180a701b1eSRobert Gordon rci.rci_type = RCI_WRITE_ADDR_CHUNK; 33190a701b1eSRobert Gordon rci.rci_len = objp->count; 33200a701b1eSRobert Gordon (void) XDR_CONTROL(xdrs, XDR_RDMA_ADD_CHUNK, &rci); 33210a701b1eSRobert Gordon } 33220a701b1eSRobert Gordon 33230a701b1eSRobert Gordon if (xdrs->x_ops != &xdrrdma_ops || xdrs->x_op == XDR_FREE) 33240a701b1eSRobert Gordon return (TRUE); 33250a701b1eSRobert Gordon 33260a701b1eSRobert Gordon if (xdrs->x_op == XDR_ENCODE) { 33270a701b1eSRobert Gordon if (objp->res_uiop != NULL) { 33280a701b1eSRobert Gordon rci.rci_type = RCI_WRITE_UIO_CHUNK; 33290a701b1eSRobert Gordon rci.rci_a.rci_uiop = objp->res_uiop; 33300a701b1eSRobert Gordon rci.rci_len = objp->count; 33310a701b1eSRobert Gordon rci.rci_clpp = &objp->wlist; 33320a701b1eSRobert Gordon } else { 33330a701b1eSRobert Gordon rci.rci_type = RCI_WRITE_ADDR_CHUNK; 33340a701b1eSRobert Gordon rci.rci_a.rci_addr = objp->res_data_val_alt; 33350a701b1eSRobert Gordon rci.rci_len = objp->count; 33360a701b1eSRobert Gordon rci.rci_clpp = &objp->wlist; 33370a701b1eSRobert Gordon } 33380a701b1eSRobert Gordon 33390a701b1eSRobert Gordon return (XDR_CONTROL(xdrs, XDR_RDMA_ADD_CHUNK, &rci)); 33400a701b1eSRobert Gordon } 33410a701b1eSRobert Gordon 33420a701b1eSRobert Gordon /* XDR_DECODE case */ 33430a701b1eSRobert Gordon (void) XDR_CONTROL(xdrs, XDR_RDMA_GET_WCINFO, &rwci); 33440a701b1eSRobert Gordon objp->wlist = rwci.rwci_wlist; 33450a701b1eSRobert Gordon objp->conn = rwci.rwci_conn; 33460a701b1eSRobert Gordon 33470a701b1eSRobert Gordon return (TRUE); 33487c478bd9Sstevel@tonic-gate } 33497c478bd9Sstevel@tonic-gate 33507c478bd9Sstevel@tonic-gate static bool_t 33517c478bd9Sstevel@tonic-gate xdr_READ4res(XDR *xdrs, READ4res *objp) 33527c478bd9Sstevel@tonic-gate { 33537c478bd9Sstevel@tonic-gate mblk_t *mp; 33547c478bd9Sstevel@tonic-gate 33557c478bd9Sstevel@tonic-gate if (xdrs->x_op == XDR_DECODE) 33567c478bd9Sstevel@tonic-gate return (FALSE); 33577c478bd9Sstevel@tonic-gate 33587c478bd9Sstevel@tonic-gate if (xdrs->x_op == XDR_FREE) { 33597c478bd9Sstevel@tonic-gate /* 33607c478bd9Sstevel@tonic-gate * Optimized free case 33617c478bd9Sstevel@tonic-gate */ 33627c478bd9Sstevel@tonic-gate if (objp->status != NFS4_OK) 33637c478bd9Sstevel@tonic-gate return (TRUE); 33647c478bd9Sstevel@tonic-gate if (objp->data_val != NULL) 33657c478bd9Sstevel@tonic-gate kmem_free(objp->data_val, objp->data_len); 33667c478bd9Sstevel@tonic-gate return (TRUE); 33677c478bd9Sstevel@tonic-gate } 33687c478bd9Sstevel@tonic-gate 33697c478bd9Sstevel@tonic-gate /* on with ENCODE paths */ 33707c478bd9Sstevel@tonic-gate if (!XDR_PUTINT32(xdrs, (int32_t *)&objp->status)) 33717c478bd9Sstevel@tonic-gate return (FALSE); 33727c478bd9Sstevel@tonic-gate if (objp->status != NFS4_OK) 33737c478bd9Sstevel@tonic-gate return (TRUE); 33747c478bd9Sstevel@tonic-gate 33757c478bd9Sstevel@tonic-gate if (!XDR_PUTINT32(xdrs, &objp->eof)) 33767c478bd9Sstevel@tonic-gate return (FALSE); 33777c478bd9Sstevel@tonic-gate 33787c478bd9Sstevel@tonic-gate mp = objp->mblk; 33797c478bd9Sstevel@tonic-gate if (mp != NULL && xdrs->x_ops == &xdrmblk_ops) { 33807c478bd9Sstevel@tonic-gate if (xdrmblk_putmblk(xdrs, mp, objp->data_len) == TRUE) { 33817c478bd9Sstevel@tonic-gate objp->mblk = NULL; 33827c478bd9Sstevel@tonic-gate return (TRUE); 33837c478bd9Sstevel@tonic-gate } 33840a701b1eSRobert Gordon } else if (mp == NULL) { 33850a701b1eSRobert Gordon if (xdr_u_int(xdrs, &objp->data_len) == FALSE) { 33860a701b1eSRobert Gordon return (FALSE); 33870a701b1eSRobert Gordon } 33880a701b1eSRobert Gordon /* 33890a701b1eSRobert Gordon * If read data sent by wlist (RDMA_WRITE), don't do 33900a701b1eSRobert Gordon * xdr_bytes() below. RDMA_WRITE transfers the data. 33910a701b1eSRobert Gordon * Note: this is encode-only because the client code 33920a701b1eSRobert Gordon * uses xdr_READ4res_clnt to decode results. 33930a701b1eSRobert Gordon */ 33940a701b1eSRobert Gordon if (objp->wlist) { 33950a701b1eSRobert Gordon if (objp->data_len != 0) { 33960a701b1eSRobert Gordon return (xdrrdma_send_read_data( 3397f837ee4aSSiddheshwar Mahesh xdrs, objp->data_len, objp->wlist)); 33980a701b1eSRobert Gordon } 33990a701b1eSRobert Gordon return (TRUE); 34000a701b1eSRobert Gordon } 34017c478bd9Sstevel@tonic-gate } 34020a701b1eSRobert Gordon 34037c478bd9Sstevel@tonic-gate return (xdr_bytes(xdrs, (char **)&objp->data_val, 34040a701b1eSRobert Gordon (uint_t *)&objp->data_len, 34050a701b1eSRobert Gordon objp->data_len)); 34067c478bd9Sstevel@tonic-gate } 34077c478bd9Sstevel@tonic-gate 34087c478bd9Sstevel@tonic-gate static bool_t 34097c478bd9Sstevel@tonic-gate xdr_READ4res_clnt(XDR *xdrs, READ4res *objp, READ4args *aobjp) 34107c478bd9Sstevel@tonic-gate { 34117c478bd9Sstevel@tonic-gate mblk_t *mp; 34127c478bd9Sstevel@tonic-gate size_t n; 34137c478bd9Sstevel@tonic-gate int error; 34147c478bd9Sstevel@tonic-gate uint_t size = aobjp->res_maxsize; 34150a701b1eSRobert Gordon count4 ocount; 34167c478bd9Sstevel@tonic-gate 34177c478bd9Sstevel@tonic-gate if (xdrs->x_op == XDR_ENCODE) 34187c478bd9Sstevel@tonic-gate return (FALSE); 34197c478bd9Sstevel@tonic-gate 34207c478bd9Sstevel@tonic-gate if (xdrs->x_op == XDR_FREE) { 34217c478bd9Sstevel@tonic-gate /* 34227c478bd9Sstevel@tonic-gate * Optimized free case 34237c478bd9Sstevel@tonic-gate */ 34247c478bd9Sstevel@tonic-gate if (objp->status != NFS4_OK) 34257c478bd9Sstevel@tonic-gate return (TRUE); 34267c478bd9Sstevel@tonic-gate if (objp->data_val != NULL) 34277c478bd9Sstevel@tonic-gate kmem_free(objp->data_val, objp->data_len); 34287c478bd9Sstevel@tonic-gate return (TRUE); 34297c478bd9Sstevel@tonic-gate } 34307c478bd9Sstevel@tonic-gate 34317c478bd9Sstevel@tonic-gate if (!XDR_GETINT32(xdrs, (int32_t *)&objp->status)) 34327c478bd9Sstevel@tonic-gate return (FALSE); 34337c478bd9Sstevel@tonic-gate if (objp->status != NFS4_OK) 34347c478bd9Sstevel@tonic-gate return (TRUE); 34357c478bd9Sstevel@tonic-gate 34367c478bd9Sstevel@tonic-gate if (!XDR_GETINT32(xdrs, &objp->eof)) 34377c478bd9Sstevel@tonic-gate return (FALSE); 34387c478bd9Sstevel@tonic-gate 34397c478bd9Sstevel@tonic-gate 34407c478bd9Sstevel@tonic-gate /* 34417c478bd9Sstevel@tonic-gate * This is a special case such that the caller is providing a 34427c478bd9Sstevel@tonic-gate * uio as a guide to eventual data location; this is used for 34437c478bd9Sstevel@tonic-gate * handling DIRECTIO reads. 34447c478bd9Sstevel@tonic-gate */ 34457c478bd9Sstevel@tonic-gate if (aobjp->res_uiop != NULL) { 34467c478bd9Sstevel@tonic-gate struct uio *uiop = aobjp->res_uiop; 34477c478bd9Sstevel@tonic-gate int32_t *ptr; 34487c478bd9Sstevel@tonic-gate 34497c478bd9Sstevel@tonic-gate if (xdrs->x_ops == &xdrmblk_ops) { 34507c478bd9Sstevel@tonic-gate if (!xdrmblk_getmblk(xdrs, &mp, &objp->data_len)) 34517c478bd9Sstevel@tonic-gate return (FALSE); 34527c478bd9Sstevel@tonic-gate 34537c478bd9Sstevel@tonic-gate if (objp->data_len == 0) 34547c478bd9Sstevel@tonic-gate return (TRUE); 34557c478bd9Sstevel@tonic-gate 34567c478bd9Sstevel@tonic-gate if (objp->data_len > size) 34577c478bd9Sstevel@tonic-gate return (FALSE); 34587c478bd9Sstevel@tonic-gate 34597c478bd9Sstevel@tonic-gate size = objp->data_len; 34607c478bd9Sstevel@tonic-gate do { 34617c478bd9Sstevel@tonic-gate n = MIN(size, mp->b_wptr - mp->b_rptr); 34627c478bd9Sstevel@tonic-gate if ((n = MIN(uiop->uio_resid, n)) != 0) { 34637c478bd9Sstevel@tonic-gate 34647c478bd9Sstevel@tonic-gate error = uiomove((char *)mp->b_rptr, n, 34650a701b1eSRobert Gordon UIO_READ, uiop); 34667c478bd9Sstevel@tonic-gate if (error) 34677c478bd9Sstevel@tonic-gate return (FALSE); 34687c478bd9Sstevel@tonic-gate mp->b_rptr += n; 34697c478bd9Sstevel@tonic-gate size -= n; 34707c478bd9Sstevel@tonic-gate } 34717c478bd9Sstevel@tonic-gate 34727c478bd9Sstevel@tonic-gate while (mp && (mp->b_rptr >= mp->b_wptr)) 34737c478bd9Sstevel@tonic-gate mp = mp->b_cont; 34747c478bd9Sstevel@tonic-gate } while (mp && size > 0 && uiop->uio_resid > 0); 34757c478bd9Sstevel@tonic-gate 34767c478bd9Sstevel@tonic-gate return (TRUE); 34777c478bd9Sstevel@tonic-gate } 34787c478bd9Sstevel@tonic-gate 34790a701b1eSRobert Gordon if (xdrs->x_ops == &xdrrdma_ops) { 34800a701b1eSRobert Gordon struct clist *cl; 34810a701b1eSRobert Gordon 34820a701b1eSRobert Gordon XDR_CONTROL(xdrs, XDR_RDMA_GET_WLIST, &cl); 34830a701b1eSRobert Gordon 34840a701b1eSRobert Gordon objp->wlist = cl; 34850a701b1eSRobert Gordon 34860a701b1eSRobert Gordon if (objp->wlist) { 34870a701b1eSRobert Gordon /* opaque count */ 34880a701b1eSRobert Gordon if (!xdr_u_int(xdrs, &ocount)) { 34890a701b1eSRobert Gordon objp->wlist = NULL; 34900a701b1eSRobert Gordon return (FALSE); 34910a701b1eSRobert Gordon } 34920a701b1eSRobert Gordon 3493f837ee4aSSiddheshwar Mahesh objp->wlist_len = clist_len(cl); 3494f837ee4aSSiddheshwar Mahesh objp->data_len = ocount; 34950a701b1eSRobert Gordon 3496f837ee4aSSiddheshwar Mahesh if (objp->wlist_len != 3497f837ee4aSSiddheshwar Mahesh roundup( 3498f837ee4aSSiddheshwar Mahesh objp->data_len, BYTES_PER_XDR_UNIT)) { 34990a701b1eSRobert Gordon DTRACE_PROBE2( 35000a701b1eSRobert Gordon xdr__e__read4resuio_clnt_fail, 35010a701b1eSRobert Gordon int, ocount, 35020a701b1eSRobert Gordon int, objp->data_len); 35030a701b1eSRobert Gordon objp->wlist = NULL; 35040a701b1eSRobert Gordon return (FALSE); 35050a701b1eSRobert Gordon } 35060a701b1eSRobert Gordon 35070a701b1eSRobert Gordon uiop->uio_resid -= objp->data_len; 35080a701b1eSRobert Gordon uiop->uio_iov->iov_len -= objp->data_len; 35090a701b1eSRobert Gordon uiop->uio_iov->iov_base += objp->data_len; 35100a701b1eSRobert Gordon uiop->uio_loffset += objp->data_len; 35110a701b1eSRobert Gordon 35120a701b1eSRobert Gordon objp->wlist = NULL; 35130a701b1eSRobert Gordon return (TRUE); 35140a701b1eSRobert Gordon } 35150a701b1eSRobert Gordon } 35160a701b1eSRobert Gordon 35177c478bd9Sstevel@tonic-gate /* 35180a701b1eSRobert Gordon * This isn't an xdrmblk stream nor RDMA. 35190a701b1eSRobert Gordon * Handle the likely case that it can be 35200a701b1eSRobert Gordon * inlined (ex. xdrmem). 35217c478bd9Sstevel@tonic-gate */ 35227c478bd9Sstevel@tonic-gate if (!XDR_GETINT32(xdrs, (int32_t *)&objp->data_len)) 35237c478bd9Sstevel@tonic-gate return (FALSE); 35247c478bd9Sstevel@tonic-gate 35257c478bd9Sstevel@tonic-gate if (objp->data_len == 0) 35267c478bd9Sstevel@tonic-gate return (TRUE); 35277c478bd9Sstevel@tonic-gate 35287c478bd9Sstevel@tonic-gate if (objp->data_len > size) 35297c478bd9Sstevel@tonic-gate return (FALSE); 35307c478bd9Sstevel@tonic-gate 35317c478bd9Sstevel@tonic-gate size = (int)objp->data_len; 35327c478bd9Sstevel@tonic-gate if ((ptr = XDR_INLINE(xdrs, size)) != NULL) 35337c478bd9Sstevel@tonic-gate return (uiomove(ptr, size, UIO_READ, uiop) ? 35340a701b1eSRobert Gordon FALSE : TRUE); 35357c478bd9Sstevel@tonic-gate 35367c478bd9Sstevel@tonic-gate /* 35377c478bd9Sstevel@tonic-gate * Handle some other (unlikely) stream type that will 35387c478bd9Sstevel@tonic-gate * need a copy. 35397c478bd9Sstevel@tonic-gate */ 35407c478bd9Sstevel@tonic-gate if ((ptr = kmem_alloc(size, KM_NOSLEEP)) == NULL) 35417c478bd9Sstevel@tonic-gate return (FALSE); 35427c478bd9Sstevel@tonic-gate 35437c478bd9Sstevel@tonic-gate if (!XDR_GETBYTES(xdrs, (caddr_t)ptr, size)) { 35447c478bd9Sstevel@tonic-gate kmem_free(ptr, size); 35457c478bd9Sstevel@tonic-gate return (FALSE); 35467c478bd9Sstevel@tonic-gate } 35477c478bd9Sstevel@tonic-gate error = uiomove(ptr, size, UIO_READ, uiop); 35487c478bd9Sstevel@tonic-gate kmem_free(ptr, size); 35497c478bd9Sstevel@tonic-gate 35507c478bd9Sstevel@tonic-gate return (error ? FALSE : TRUE); 35517c478bd9Sstevel@tonic-gate } 35527c478bd9Sstevel@tonic-gate 35537c478bd9Sstevel@tonic-gate /* 35547c478bd9Sstevel@tonic-gate * Check for the other special case of the caller providing 35557c478bd9Sstevel@tonic-gate * the target area for the data. 35567c478bd9Sstevel@tonic-gate */ 35570a701b1eSRobert Gordon if (aobjp->res_data_val_alt == NULL) 35580a701b1eSRobert Gordon return (FALSE); 35597c478bd9Sstevel@tonic-gate 35600a701b1eSRobert Gordon /* 35610a701b1eSRobert Gordon * If read data received via RDMA_WRITE, don't do xdr_bytes(). 35620a701b1eSRobert Gordon * RDMA_WRITE already moved the data so decode length of 35630a701b1eSRobert Gordon * RDMA_WRITE. 35640a701b1eSRobert Gordon */ 35650a701b1eSRobert Gordon if (xdrs->x_ops == &xdrrdma_ops) { 35660a701b1eSRobert Gordon struct clist *cl; 35670a701b1eSRobert Gordon 35680a701b1eSRobert Gordon XDR_CONTROL(xdrs, XDR_RDMA_GET_WLIST, &cl); 35690a701b1eSRobert Gordon 35700a701b1eSRobert Gordon objp->wlist = cl; 35710a701b1eSRobert Gordon 35720a701b1eSRobert Gordon /* 35730a701b1eSRobert Gordon * Data transferred through inline if 35740a701b1eSRobert Gordon * objp->wlist == NULL 35750a701b1eSRobert Gordon */ 35760a701b1eSRobert Gordon if (objp->wlist) { 35770a701b1eSRobert Gordon /* opaque count */ 35780a701b1eSRobert Gordon if (!xdr_u_int(xdrs, &ocount)) { 35790a701b1eSRobert Gordon objp->wlist = NULL; 35800a701b1eSRobert Gordon return (FALSE); 35810a701b1eSRobert Gordon } 35820a701b1eSRobert Gordon 3583f837ee4aSSiddheshwar Mahesh objp->wlist_len = clist_len(cl); 3584f837ee4aSSiddheshwar Mahesh objp->data_len = ocount; 35850a701b1eSRobert Gordon 3586f837ee4aSSiddheshwar Mahesh if (objp->wlist_len != 3587f837ee4aSSiddheshwar Mahesh roundup( 3588f837ee4aSSiddheshwar Mahesh objp->data_len, BYTES_PER_XDR_UNIT)) { 35890a701b1eSRobert Gordon DTRACE_PROBE2( 35900a701b1eSRobert Gordon xdr__e__read4res_clnt_fail, 35910a701b1eSRobert Gordon int, ocount, 35920a701b1eSRobert Gordon int, objp->data_len); 35930a701b1eSRobert Gordon objp->wlist = NULL; 35940a701b1eSRobert Gordon return (FALSE); 35950a701b1eSRobert Gordon } 35960a701b1eSRobert Gordon 35970a701b1eSRobert Gordon objp->wlist = NULL; 35980a701b1eSRobert Gordon return (TRUE); 35990a701b1eSRobert Gordon } 36000a701b1eSRobert Gordon } 36010a701b1eSRobert Gordon 36020a701b1eSRobert Gordon return (xdr_bytes(xdrs, (char **)&aobjp->res_data_val_alt, 36030a701b1eSRobert Gordon (uint_t *)&objp->data_len, 36040a701b1eSRobert Gordon aobjp->res_maxsize)); 36057c478bd9Sstevel@tonic-gate } 36067c478bd9Sstevel@tonic-gate 36077c478bd9Sstevel@tonic-gate static bool_t 36087c478bd9Sstevel@tonic-gate xdr_READDIR4args(XDR *xdrs, READDIR4args *objp) 36097c478bd9Sstevel@tonic-gate { 36100a701b1eSRobert Gordon rdma_chunkinfo_t rci; 36110a701b1eSRobert Gordon struct xdr_ops *xops = xdrrdma_xops(); 36120a701b1eSRobert Gordon 36130a701b1eSRobert Gordon if ((xdrs->x_ops == &xdrrdma_ops || xdrs->x_ops == xops) && 36140a701b1eSRobert Gordon xdrs->x_op == XDR_ENCODE) { 36150a701b1eSRobert Gordon rci.rci_type = RCI_REPLY_CHUNK; 36160a701b1eSRobert Gordon rci.rci_len = objp->maxcount; 36170a701b1eSRobert Gordon XDR_CONTROL(xdrs, XDR_RDMA_ADD_CHUNK, &rci); 36180a701b1eSRobert Gordon } 36190a701b1eSRobert Gordon 36207c478bd9Sstevel@tonic-gate if (!xdr_u_longlong_t(xdrs, (u_longlong_t *)&objp->cookie)) 36217c478bd9Sstevel@tonic-gate return (FALSE); 36227c478bd9Sstevel@tonic-gate if (!xdr_u_longlong_t(xdrs, (u_longlong_t *)&objp->cookieverf)) 36237c478bd9Sstevel@tonic-gate return (FALSE); 36247c478bd9Sstevel@tonic-gate if (!xdr_u_int(xdrs, &objp->dircount)) 36257c478bd9Sstevel@tonic-gate return (FALSE); 36267c478bd9Sstevel@tonic-gate if (!xdr_u_int(xdrs, &objp->maxcount)) 36277c478bd9Sstevel@tonic-gate return (FALSE); 36287c478bd9Sstevel@tonic-gate return (xdr_bitmap4(xdrs, &objp->attr_request)); 36297c478bd9Sstevel@tonic-gate } 36307c478bd9Sstevel@tonic-gate 36317c478bd9Sstevel@tonic-gate /* ARGSUSED */ 36327c478bd9Sstevel@tonic-gate static bool_t 36337c478bd9Sstevel@tonic-gate xdrmblk_putmblk_rd(XDR *xdrs, mblk_t *m) 36347c478bd9Sstevel@tonic-gate { 36357c478bd9Sstevel@tonic-gate if (((m->b_wptr - m->b_rptr) % BYTES_PER_XDR_UNIT) != 0) 36367c478bd9Sstevel@tonic-gate return (FALSE); 36377c478bd9Sstevel@tonic-gate 36387c478bd9Sstevel@tonic-gate /* LINTED pointer alignment */ 36397c478bd9Sstevel@tonic-gate ((mblk_t *)xdrs->x_base)->b_cont = m; 36407c478bd9Sstevel@tonic-gate xdrs->x_base = (caddr_t)m; 36417c478bd9Sstevel@tonic-gate xdrs->x_handy = 0; 36427c478bd9Sstevel@tonic-gate return (TRUE); 36437c478bd9Sstevel@tonic-gate } 36447c478bd9Sstevel@tonic-gate 36457c478bd9Sstevel@tonic-gate bool_t 36467c478bd9Sstevel@tonic-gate xdr_READDIR4res(XDR *xdrs, READDIR4res *objp) 36477c478bd9Sstevel@tonic-gate { 36487c478bd9Sstevel@tonic-gate mblk_t *mp = objp->mblk; 36497c478bd9Sstevel@tonic-gate bool_t ret_val; 36507c478bd9Sstevel@tonic-gate uint_t flags = 0; 36517c478bd9Sstevel@tonic-gate 36527c478bd9Sstevel@tonic-gate ASSERT(xdrs->x_op == XDR_ENCODE); 36537c478bd9Sstevel@tonic-gate 36547c478bd9Sstevel@tonic-gate if (!xdr_int(xdrs, (int32_t *)&objp->status)) 36557c478bd9Sstevel@tonic-gate return (FALSE); 36567c478bd9Sstevel@tonic-gate if (objp->status != NFS4_OK) 36577c478bd9Sstevel@tonic-gate return (TRUE); 36587c478bd9Sstevel@tonic-gate if (mp == NULL) 36597c478bd9Sstevel@tonic-gate return (FALSE); 36607c478bd9Sstevel@tonic-gate 36617c478bd9Sstevel@tonic-gate if (xdrs->x_ops == &xdrmblk_ops) { 36627c478bd9Sstevel@tonic-gate if (xdrmblk_putmblk_rd(xdrs, mp) 36630a701b1eSRobert Gordon == TRUE) { 36647c478bd9Sstevel@tonic-gate /* mblk successfully inserted into outgoing chain */ 36657c478bd9Sstevel@tonic-gate objp->mblk = NULL; 36667c478bd9Sstevel@tonic-gate return (TRUE); 36677c478bd9Sstevel@tonic-gate } 36687c478bd9Sstevel@tonic-gate } 36697c478bd9Sstevel@tonic-gate 36707c478bd9Sstevel@tonic-gate ASSERT(mp->b_cont == NULL); 36717c478bd9Sstevel@tonic-gate 36727c478bd9Sstevel@tonic-gate /* 36730a701b1eSRobert Gordon * If transport is RDMA, the pre-encoded m_blk needs to be moved 36747c478bd9Sstevel@tonic-gate * without being chunked. 36750a701b1eSRobert Gordon * Check if chunking is enabled for the xdr stream. 36760a701b1eSRobert Gordon * If it is enabled, disable it temporarily for this op, 36770a701b1eSRobert Gordon * then re-enable. 36787c478bd9Sstevel@tonic-gate */ 36790a701b1eSRobert Gordon XDR_CONTROL(xdrs, XDR_RDMA_GET_FLAGS, &flags); 36800a701b1eSRobert Gordon 36810a701b1eSRobert Gordon if (!(flags & XDR_RDMA_CHUNK)) 36827c478bd9Sstevel@tonic-gate return (xdr_opaque(xdrs, (char *)mp->b_rptr, objp->data_len)); 36837c478bd9Sstevel@tonic-gate 36840a701b1eSRobert Gordon flags &= ~XDR_RDMA_CHUNK; 36850a701b1eSRobert Gordon 36860a701b1eSRobert Gordon (void) XDR_CONTROL(xdrs, XDR_RDMA_SET_FLAGS, &flags); 36870a701b1eSRobert Gordon 36887c478bd9Sstevel@tonic-gate ret_val = xdr_opaque(xdrs, (char *)mp->b_rptr, objp->data_len); 36890a701b1eSRobert Gordon 36900a701b1eSRobert Gordon flags |= XDR_RDMA_CHUNK; 36910a701b1eSRobert Gordon 36920a701b1eSRobert Gordon (void) XDR_CONTROL(xdrs, XDR_RDMA_SET_FLAGS, &flags); 36930a701b1eSRobert Gordon 36947c478bd9Sstevel@tonic-gate return (ret_val); 36957c478bd9Sstevel@tonic-gate } 36967c478bd9Sstevel@tonic-gate 36977c478bd9Sstevel@tonic-gate static bool_t 36987c478bd9Sstevel@tonic-gate xdr_READLINK4res(XDR *xdrs, READLINK4res *objp) 36997c478bd9Sstevel@tonic-gate { 37007c478bd9Sstevel@tonic-gate if (xdrs->x_op != XDR_FREE) { 37017c478bd9Sstevel@tonic-gate if (!xdr_int(xdrs, (int32_t *)&objp->status)) 37027c478bd9Sstevel@tonic-gate return (FALSE); 37037c478bd9Sstevel@tonic-gate if (objp->status != NFS4_OK) 37047c478bd9Sstevel@tonic-gate return (TRUE); 37057c478bd9Sstevel@tonic-gate return (xdr_bytes(xdrs, (char **)&objp->link.utf8string_val, 37060a701b1eSRobert Gordon (uint_t *)&objp->link.utf8string_len, 37070a701b1eSRobert Gordon NFS4_MAX_UTF8STRING)); 37087c478bd9Sstevel@tonic-gate } 37097c478bd9Sstevel@tonic-gate 37107c478bd9Sstevel@tonic-gate /* 37117c478bd9Sstevel@tonic-gate * Optimized free case 37127c478bd9Sstevel@tonic-gate */ 37137c478bd9Sstevel@tonic-gate if (objp->status != NFS4_OK) 37147c478bd9Sstevel@tonic-gate return (TRUE); 37157c478bd9Sstevel@tonic-gate if (objp->link.utf8string_val != NULL) 37167c478bd9Sstevel@tonic-gate kmem_free(objp->link.utf8string_val, objp->link.utf8string_len); 37177c478bd9Sstevel@tonic-gate return (TRUE); 37187c478bd9Sstevel@tonic-gate } 37197c478bd9Sstevel@tonic-gate 37207c478bd9Sstevel@tonic-gate static bool_t 37217c478bd9Sstevel@tonic-gate xdr_REMOVE4res(XDR *xdrs, REMOVE4res *objp) 37227c478bd9Sstevel@tonic-gate { 37237c478bd9Sstevel@tonic-gate if (!xdr_int(xdrs, (int32_t *)&objp->status)) 37247c478bd9Sstevel@tonic-gate return (FALSE); 37257c478bd9Sstevel@tonic-gate if (objp->status != NFS4_OK) 37267c478bd9Sstevel@tonic-gate return (TRUE); 37277c478bd9Sstevel@tonic-gate if (!xdr_bool(xdrs, &objp->cinfo.atomic)) 37287c478bd9Sstevel@tonic-gate return (FALSE); 37297c478bd9Sstevel@tonic-gate if (!xdr_u_longlong_t(xdrs, (u_longlong_t *)&objp->cinfo.before)) 37307c478bd9Sstevel@tonic-gate return (FALSE); 37317c478bd9Sstevel@tonic-gate return (xdr_u_longlong_t(xdrs, 37320a701b1eSRobert Gordon (u_longlong_t *)&objp->cinfo.after)); 37337c478bd9Sstevel@tonic-gate } 37347c478bd9Sstevel@tonic-gate 37357c478bd9Sstevel@tonic-gate static bool_t 37367c478bd9Sstevel@tonic-gate xdr_RENAME4res(XDR *xdrs, RENAME4res *objp) 37377c478bd9Sstevel@tonic-gate { 37387c478bd9Sstevel@tonic-gate if (!xdr_int(xdrs, (int32_t *)&objp->status)) 37397c478bd9Sstevel@tonic-gate return (FALSE); 37407c478bd9Sstevel@tonic-gate if (objp->status != NFS4_OK) 37417c478bd9Sstevel@tonic-gate return (TRUE); 37427c478bd9Sstevel@tonic-gate if (!xdr_bool(xdrs, &objp->source_cinfo.atomic)) 37437c478bd9Sstevel@tonic-gate return (FALSE); 37447c478bd9Sstevel@tonic-gate if (!xdr_u_longlong_t(xdrs, 37457c478bd9Sstevel@tonic-gate (u_longlong_t *)&objp->source_cinfo.before)) 37467c478bd9Sstevel@tonic-gate return (FALSE); 37477c478bd9Sstevel@tonic-gate if (!xdr_u_longlong_t(xdrs, 37487c478bd9Sstevel@tonic-gate (u_longlong_t *)&objp->source_cinfo.after)) 37497c478bd9Sstevel@tonic-gate return (FALSE); 37507c478bd9Sstevel@tonic-gate if (!xdr_bool(xdrs, &objp->target_cinfo.atomic)) 37517c478bd9Sstevel@tonic-gate return (FALSE); 37527c478bd9Sstevel@tonic-gate if (!xdr_u_longlong_t(xdrs, 37537c478bd9Sstevel@tonic-gate (u_longlong_t *)&objp->target_cinfo.before)) 37547c478bd9Sstevel@tonic-gate return (FALSE); 37557c478bd9Sstevel@tonic-gate return (xdr_u_longlong_t(xdrs, 37560a701b1eSRobert Gordon (u_longlong_t *)&objp->target_cinfo.after)); 37577c478bd9Sstevel@tonic-gate } 37587c478bd9Sstevel@tonic-gate 37597c478bd9Sstevel@tonic-gate static bool_t 37607c478bd9Sstevel@tonic-gate xdr_secinfo4(XDR *xdrs, secinfo4 *objp) 37617c478bd9Sstevel@tonic-gate { 37627c478bd9Sstevel@tonic-gate if (xdrs->x_op != XDR_FREE) { 37637c478bd9Sstevel@tonic-gate if (!xdr_u_int(xdrs, &objp->flavor)) 37647c478bd9Sstevel@tonic-gate return (FALSE); 37657c478bd9Sstevel@tonic-gate if (objp->flavor != RPCSEC_GSS) 37667c478bd9Sstevel@tonic-gate return (TRUE); 37677c478bd9Sstevel@tonic-gate if (!xdr_bytes(xdrs, 37680a701b1eSRobert Gordon (char **)&objp->flavor_info.oid.sec_oid4_val, 37690a701b1eSRobert Gordon (uint_t *)&objp->flavor_info.oid.sec_oid4_len, 37700a701b1eSRobert Gordon NFS4_MAX_SECOID4)) 37717c478bd9Sstevel@tonic-gate return (FALSE); 37727c478bd9Sstevel@tonic-gate if (!xdr_u_int(xdrs, &objp->flavor_info.qop)) 37737c478bd9Sstevel@tonic-gate return (FALSE); 37747c478bd9Sstevel@tonic-gate return (xdr_int(xdrs, (int *)&objp->flavor_info.service)); 37757c478bd9Sstevel@tonic-gate } 37767c478bd9Sstevel@tonic-gate 37777c478bd9Sstevel@tonic-gate /* 37787c478bd9Sstevel@tonic-gate * Optimized free path 37797c478bd9Sstevel@tonic-gate */ 37807c478bd9Sstevel@tonic-gate if (objp->flavor != RPCSEC_GSS) 37817c478bd9Sstevel@tonic-gate return (TRUE); 37827c478bd9Sstevel@tonic-gate 37837c478bd9Sstevel@tonic-gate if (objp->flavor_info.oid.sec_oid4_val != NULL) 37847c478bd9Sstevel@tonic-gate kmem_free(objp->flavor_info.oid.sec_oid4_val, 37850a701b1eSRobert Gordon objp->flavor_info.oid.sec_oid4_len); 37867c478bd9Sstevel@tonic-gate return (TRUE); 37877c478bd9Sstevel@tonic-gate } 37887c478bd9Sstevel@tonic-gate 37897c478bd9Sstevel@tonic-gate static bool_t 37907c478bd9Sstevel@tonic-gate xdr_SETCLIENTID4args(XDR *xdrs, SETCLIENTID4args *objp) 37917c478bd9Sstevel@tonic-gate { 37927c478bd9Sstevel@tonic-gate if (xdrs->x_op != XDR_FREE) { 37937c478bd9Sstevel@tonic-gate if (!xdr_u_longlong_t(xdrs, 37940a701b1eSRobert Gordon (u_longlong_t *)&objp->client.verifier)) 37957c478bd9Sstevel@tonic-gate return (FALSE); 37967c478bd9Sstevel@tonic-gate if (!xdr_bytes(xdrs, (char **)&objp->client.id_val, 37970a701b1eSRobert Gordon (uint_t *)&objp->client.id_len, NFS4_OPAQUE_LIMIT)) 37987c478bd9Sstevel@tonic-gate return (FALSE); 37997c478bd9Sstevel@tonic-gate if (!xdr_u_int(xdrs, &objp->callback.cb_program)) 38007c478bd9Sstevel@tonic-gate return (FALSE); 38017c478bd9Sstevel@tonic-gate if (!xdr_string(xdrs, &objp->callback.cb_location.r_netid, 38020a701b1eSRobert Gordon NFS4_OPAQUE_LIMIT)) 38037c478bd9Sstevel@tonic-gate return (FALSE); 38047c478bd9Sstevel@tonic-gate if (!xdr_string(xdrs, &objp->callback.cb_location.r_addr, 38050a701b1eSRobert Gordon NFS4_OPAQUE_LIMIT)) 38067c478bd9Sstevel@tonic-gate return (FALSE); 38077c478bd9Sstevel@tonic-gate return (xdr_u_int(xdrs, &objp->callback_ident)); 38087c478bd9Sstevel@tonic-gate } 38097c478bd9Sstevel@tonic-gate 38107c478bd9Sstevel@tonic-gate /* 38117c478bd9Sstevel@tonic-gate * Optimized free case 38127c478bd9Sstevel@tonic-gate */ 38137c478bd9Sstevel@tonic-gate if (objp->client.id_val != NULL) 38147c478bd9Sstevel@tonic-gate kmem_free(objp->client.id_val, objp->client.id_len); 38157c478bd9Sstevel@tonic-gate (void) xdr_string(xdrs, &objp->callback.cb_location.r_netid, 38160a701b1eSRobert Gordon NFS4_OPAQUE_LIMIT); 38177c478bd9Sstevel@tonic-gate return (xdr_string(xdrs, &objp->callback.cb_location.r_addr, 38180a701b1eSRobert Gordon NFS4_OPAQUE_LIMIT)); 38197c478bd9Sstevel@tonic-gate } 38207c478bd9Sstevel@tonic-gate 38217c478bd9Sstevel@tonic-gate static bool_t 38227c478bd9Sstevel@tonic-gate xdr_SETCLIENTID4res(XDR *xdrs, SETCLIENTID4res *objp) 38237c478bd9Sstevel@tonic-gate { 38247c478bd9Sstevel@tonic-gate if (xdrs->x_op != XDR_FREE) { 38257c478bd9Sstevel@tonic-gate if (!xdr_int(xdrs, (int32_t *)&objp->status)) 38267c478bd9Sstevel@tonic-gate return (FALSE); 38277c478bd9Sstevel@tonic-gate switch (objp->status) { 38287c478bd9Sstevel@tonic-gate case NFS4_OK: 38297c478bd9Sstevel@tonic-gate if (!xdr_u_longlong_t(xdrs, 38307c478bd9Sstevel@tonic-gate (u_longlong_t *)&objp->SETCLIENTID4res_u.resok4. 38317c478bd9Sstevel@tonic-gate clientid)) 38327c478bd9Sstevel@tonic-gate return (FALSE); 38337c478bd9Sstevel@tonic-gate return (xdr_u_longlong_t(xdrs, 38347c478bd9Sstevel@tonic-gate (u_longlong_t *)&objp->SETCLIENTID4res_u. 38350a701b1eSRobert Gordon resok4.setclientid_confirm)); 38367c478bd9Sstevel@tonic-gate case NFS4ERR_CLID_INUSE: 38377c478bd9Sstevel@tonic-gate if (!xdr_string(xdrs, 38380a701b1eSRobert Gordon &objp->SETCLIENTID4res_u.client_using. 38390a701b1eSRobert Gordon r_netid, NFS4_OPAQUE_LIMIT)) 38407c478bd9Sstevel@tonic-gate return (FALSE); 38417c478bd9Sstevel@tonic-gate return (xdr_string(xdrs, 38420a701b1eSRobert Gordon &objp->SETCLIENTID4res_u.client_using. 38430a701b1eSRobert Gordon r_addr, NFS4_OPAQUE_LIMIT)); 38447c478bd9Sstevel@tonic-gate } 38457c478bd9Sstevel@tonic-gate return (TRUE); 38467c478bd9Sstevel@tonic-gate } 38477c478bd9Sstevel@tonic-gate 38487c478bd9Sstevel@tonic-gate /* 38497c478bd9Sstevel@tonic-gate * Optimized free case 38507c478bd9Sstevel@tonic-gate */ 38517c478bd9Sstevel@tonic-gate if (objp->status != NFS4ERR_CLID_INUSE) 38527c478bd9Sstevel@tonic-gate return (TRUE); 38537c478bd9Sstevel@tonic-gate 38547c478bd9Sstevel@tonic-gate if (!xdr_string(xdrs, &objp->SETCLIENTID4res_u.client_using.r_netid, 38550a701b1eSRobert Gordon NFS4_OPAQUE_LIMIT)) 38567c478bd9Sstevel@tonic-gate return (FALSE); 38577c478bd9Sstevel@tonic-gate return (xdr_string(xdrs, &objp->SETCLIENTID4res_u.client_using.r_addr, 38580a701b1eSRobert Gordon NFS4_OPAQUE_LIMIT)); 38597c478bd9Sstevel@tonic-gate } 38607c478bd9Sstevel@tonic-gate 38617c478bd9Sstevel@tonic-gate static bool_t 38627c478bd9Sstevel@tonic-gate xdr_WRITE4args(XDR *xdrs, WRITE4args *objp) 38637c478bd9Sstevel@tonic-gate { 38647c478bd9Sstevel@tonic-gate if (xdrs->x_op != XDR_FREE) { 38657c478bd9Sstevel@tonic-gate if (!xdr_u_int(xdrs, &objp->stateid.seqid)) 38667c478bd9Sstevel@tonic-gate return (FALSE); 38677c478bd9Sstevel@tonic-gate if (!xdr_opaque(xdrs, objp->stateid.other, 12)) 38687c478bd9Sstevel@tonic-gate return (FALSE); 38697c478bd9Sstevel@tonic-gate if (!xdr_u_longlong_t(xdrs, (u_longlong_t *)&objp->offset)) 38707c478bd9Sstevel@tonic-gate return (FALSE); 38717c478bd9Sstevel@tonic-gate if (!xdr_int(xdrs, (int *)&objp->stable)) 38727c478bd9Sstevel@tonic-gate return (FALSE); 38737c478bd9Sstevel@tonic-gate if (xdrs->x_op == XDR_DECODE) { 38747c478bd9Sstevel@tonic-gate if (xdrs->x_ops == &xdrmblk_ops) { 38757c478bd9Sstevel@tonic-gate objp->data_val = NULL; 38767c478bd9Sstevel@tonic-gate return (xdrmblk_getmblk(xdrs, &objp->mblk, 38770a701b1eSRobert Gordon &objp->data_len)); 38787c478bd9Sstevel@tonic-gate } 38797c478bd9Sstevel@tonic-gate objp->mblk = NULL; 38800a701b1eSRobert Gordon if (xdrs->x_ops == &xdrrdmablk_ops) { 38810a701b1eSRobert Gordon int retval; 38820a701b1eSRobert Gordon retval = xdrrdma_getrdmablk(xdrs, 38830a701b1eSRobert Gordon &objp->rlist, 38840a701b1eSRobert Gordon &objp->data_len, 38850a701b1eSRobert Gordon &objp->conn, NFS4_DATA_LIMIT); 38860a701b1eSRobert Gordon if (retval == FALSE) 38870a701b1eSRobert Gordon return (FALSE); 3888f837ee4aSSiddheshwar Mahesh return (xdrrdma_read_from_client(objp->rlist, 38890a701b1eSRobert Gordon &objp->conn, objp->data_len)); 38900a701b1eSRobert Gordon } 38917c478bd9Sstevel@tonic-gate } 38920a701b1eSRobert Gordon /* Else fall thru for the xdr_bytes(). */ 38937c478bd9Sstevel@tonic-gate return (xdr_bytes(xdrs, (char **)&objp->data_val, 38940a701b1eSRobert Gordon (uint_t *)&objp->data_len, NFS4_DATA_LIMIT)); 38950a701b1eSRobert Gordon } 38960a701b1eSRobert Gordon if (objp->rlist != NULL) { 38970a701b1eSRobert Gordon (void) xdrrdma_free_clist(objp->conn, objp->rlist); 38980a701b1eSRobert Gordon objp->rlist = NULL; 38990a701b1eSRobert Gordon objp->data_val = NULL; 39000a701b1eSRobert Gordon 39010a701b1eSRobert Gordon return (TRUE); 39027c478bd9Sstevel@tonic-gate } 39037c478bd9Sstevel@tonic-gate 39047c478bd9Sstevel@tonic-gate /* 39057c478bd9Sstevel@tonic-gate * Optimized free case 39067c478bd9Sstevel@tonic-gate */ 39077c478bd9Sstevel@tonic-gate if (objp->data_val != NULL) 39087c478bd9Sstevel@tonic-gate kmem_free(objp->data_val, objp->data_len); 39097c478bd9Sstevel@tonic-gate return (TRUE); 39107c478bd9Sstevel@tonic-gate } 39117c478bd9Sstevel@tonic-gate 39127c478bd9Sstevel@tonic-gate static bool_t 39137c478bd9Sstevel@tonic-gate xdr_WRITE4res(XDR *xdrs, WRITE4res *objp) 39147c478bd9Sstevel@tonic-gate { 39157c478bd9Sstevel@tonic-gate if (!xdr_int(xdrs, (int32_t *)&objp->status)) 39167c478bd9Sstevel@tonic-gate return (FALSE); 39177c478bd9Sstevel@tonic-gate if (objp->status != NFS4_OK) 39187c478bd9Sstevel@tonic-gate return (TRUE); 39197c478bd9Sstevel@tonic-gate if (!xdr_u_int(xdrs, &objp->count)) 39207c478bd9Sstevel@tonic-gate return (FALSE); 39217c478bd9Sstevel@tonic-gate if (!xdr_int(xdrs, (int *)&objp->committed)) 39227c478bd9Sstevel@tonic-gate return (FALSE); 39237c478bd9Sstevel@tonic-gate return (xdr_u_longlong_t(xdrs, 39240a701b1eSRobert Gordon (u_longlong_t *)&objp->writeverf)); 39257c478bd9Sstevel@tonic-gate } 39267c478bd9Sstevel@tonic-gate 39277c478bd9Sstevel@tonic-gate static bool_t 39287c46fb7fSek xdr_snfs_argop4_free(XDR *xdrs, nfs_argop4 **arrayp, int len) 39297c478bd9Sstevel@tonic-gate { 39307c478bd9Sstevel@tonic-gate int i; 39317c478bd9Sstevel@tonic-gate nfs_argop4 *array = *arrayp; 39327c478bd9Sstevel@tonic-gate 39337c478bd9Sstevel@tonic-gate /* 39347c478bd9Sstevel@tonic-gate * Optimized XDR_FREE only args array 39357c478bd9Sstevel@tonic-gate */ 39367c478bd9Sstevel@tonic-gate ASSERT(xdrs->x_op == XDR_FREE); 39377c478bd9Sstevel@tonic-gate 39387c478bd9Sstevel@tonic-gate /* 39397c478bd9Sstevel@tonic-gate * Nothing to do? 39407c478bd9Sstevel@tonic-gate */ 39417c478bd9Sstevel@tonic-gate if (array == NULL) 39427c478bd9Sstevel@tonic-gate return (TRUE); 39437c478bd9Sstevel@tonic-gate 39447c478bd9Sstevel@tonic-gate for (i = 0; i < len; i++) { 39457c478bd9Sstevel@tonic-gate /* 39467c478bd9Sstevel@tonic-gate * These should be ordered by frequency of use 39477c478bd9Sstevel@tonic-gate */ 39487c478bd9Sstevel@tonic-gate switch (array[i].argop) { 39497c478bd9Sstevel@tonic-gate case OP_PUTFH: 39507c478bd9Sstevel@tonic-gate if (array[i].nfs_argop4_u.opputfh.object.nfs_fh4_val != 39510a701b1eSRobert Gordon NULL) { 39527c478bd9Sstevel@tonic-gate kmem_free(array[i].nfs_argop4_u.opputfh.object. 39530a701b1eSRobert Gordon nfs_fh4_val, 39540a701b1eSRobert Gordon array[i].nfs_argop4_u.opputfh.object. 39550a701b1eSRobert Gordon nfs_fh4_len); 39567c478bd9Sstevel@tonic-gate } 39577c478bd9Sstevel@tonic-gate continue; 39587c478bd9Sstevel@tonic-gate case OP_GETATTR: 39597c478bd9Sstevel@tonic-gate case OP_GETFH: 39607c478bd9Sstevel@tonic-gate continue; 39617c478bd9Sstevel@tonic-gate case OP_LOOKUP: 39627c478bd9Sstevel@tonic-gate if (array[i].nfs_argop4_u.oplookup.objname. 39630a701b1eSRobert Gordon utf8string_val != NULL) { 39647c478bd9Sstevel@tonic-gate kmem_free(array[i].nfs_argop4_u.oplookup. 39650a701b1eSRobert Gordon objname.utf8string_val, 39660a701b1eSRobert Gordon array[i].nfs_argop4_u.oplookup. 39670a701b1eSRobert Gordon objname.utf8string_len); 39687c478bd9Sstevel@tonic-gate } 39697c478bd9Sstevel@tonic-gate continue; 39707c478bd9Sstevel@tonic-gate case OP_OPEN: 39717c478bd9Sstevel@tonic-gate (void) xdr_OPEN4args(xdrs, 39720a701b1eSRobert Gordon &array[i].nfs_argop4_u.opopen); 39737c478bd9Sstevel@tonic-gate continue; 39747c478bd9Sstevel@tonic-gate case OP_CLOSE: 39757c478bd9Sstevel@tonic-gate case OP_ACCESS: 39767c478bd9Sstevel@tonic-gate case OP_READ: 39777c478bd9Sstevel@tonic-gate continue; 39787c478bd9Sstevel@tonic-gate case OP_WRITE: 39797c478bd9Sstevel@tonic-gate (void) xdr_WRITE4args(xdrs, 39800a701b1eSRobert Gordon &array[i].nfs_argop4_u.opwrite); 39817c478bd9Sstevel@tonic-gate continue; 39827c478bd9Sstevel@tonic-gate case OP_DELEGRETURN: 39837c478bd9Sstevel@tonic-gate case OP_LOOKUPP: 39847c478bd9Sstevel@tonic-gate case OP_READDIR: 39857c478bd9Sstevel@tonic-gate continue; 39867c478bd9Sstevel@tonic-gate case OP_REMOVE: 39877c478bd9Sstevel@tonic-gate if (array[i].nfs_argop4_u.opremove.target. 39880a701b1eSRobert Gordon utf8string_val != NULL) { 39897c478bd9Sstevel@tonic-gate kmem_free(array[i].nfs_argop4_u.opremove.target. 39900a701b1eSRobert Gordon utf8string_val, 39910a701b1eSRobert Gordon array[i].nfs_argop4_u.opremove.target. 39920a701b1eSRobert Gordon utf8string_len); 39937c478bd9Sstevel@tonic-gate } 39947c478bd9Sstevel@tonic-gate continue; 39957c478bd9Sstevel@tonic-gate case OP_COMMIT: 39967c478bd9Sstevel@tonic-gate continue; 39977c478bd9Sstevel@tonic-gate case OP_CREATE: 39987c478bd9Sstevel@tonic-gate (void) xdr_CREATE4args(xdrs, 39990a701b1eSRobert Gordon &array[i].nfs_argop4_u.opcreate); 40007c478bd9Sstevel@tonic-gate continue; 40017c478bd9Sstevel@tonic-gate case OP_DELEGPURGE: 40027c478bd9Sstevel@tonic-gate continue; 40037c478bd9Sstevel@tonic-gate case OP_LINK: 40047c478bd9Sstevel@tonic-gate if (array[i].nfs_argop4_u.oplink.newname. 40050a701b1eSRobert Gordon utf8string_val != NULL) { 40067c478bd9Sstevel@tonic-gate kmem_free(array[i].nfs_argop4_u.oplink.newname. 40070a701b1eSRobert Gordon utf8string_val, 40080a701b1eSRobert Gordon array[i].nfs_argop4_u.oplink.newname. 40090a701b1eSRobert Gordon utf8string_len); 40107c478bd9Sstevel@tonic-gate } 40117c478bd9Sstevel@tonic-gate continue; 40127c478bd9Sstevel@tonic-gate case OP_LOCK: 40137c478bd9Sstevel@tonic-gate (void) xdr_LOCK4args(xdrs, 40140a701b1eSRobert Gordon &array[i].nfs_argop4_u.oplock); 40157c478bd9Sstevel@tonic-gate continue; 40167c478bd9Sstevel@tonic-gate case OP_LOCKT: 40177c478bd9Sstevel@tonic-gate (void) xdr_LOCKT4args(xdrs, 40180a701b1eSRobert Gordon &array[i].nfs_argop4_u.oplockt); 40197c478bd9Sstevel@tonic-gate continue; 40207c478bd9Sstevel@tonic-gate case OP_LOCKU: 40217c478bd9Sstevel@tonic-gate continue; 40227c478bd9Sstevel@tonic-gate case OP_NVERIFY: 40237c478bd9Sstevel@tonic-gate (void) xdr_fattr4(xdrs, 40247c478bd9Sstevel@tonic-gate &array[i].nfs_argop4_u.opnverify.obj_attributes); 40257c478bd9Sstevel@tonic-gate continue; 40267c478bd9Sstevel@tonic-gate case OP_OPENATTR: 40277c478bd9Sstevel@tonic-gate case OP_OPEN_CONFIRM: 40287c478bd9Sstevel@tonic-gate case OP_OPEN_DOWNGRADE: 40297c478bd9Sstevel@tonic-gate case OP_PUTPUBFH: 40307c478bd9Sstevel@tonic-gate case OP_PUTROOTFH: 40317c478bd9Sstevel@tonic-gate case OP_READLINK: 40327c478bd9Sstevel@tonic-gate continue; 40337c478bd9Sstevel@tonic-gate case OP_RENAME: 40347c478bd9Sstevel@tonic-gate if (array[i].nfs_argop4_u.oprename.oldname. 40350a701b1eSRobert Gordon utf8string_val != NULL) { 40367c478bd9Sstevel@tonic-gate kmem_free(array[i].nfs_argop4_u.oprename. 40370a701b1eSRobert Gordon oldname.utf8string_val, 40380a701b1eSRobert Gordon array[i].nfs_argop4_u.oprename. 40390a701b1eSRobert Gordon oldname.utf8string_len); 40407c478bd9Sstevel@tonic-gate } 40417c478bd9Sstevel@tonic-gate if (array[i].nfs_argop4_u.oprename.newname. 40420a701b1eSRobert Gordon utf8string_val != NULL) { 40437c478bd9Sstevel@tonic-gate kmem_free(array[i].nfs_argop4_u.oprename. 40440a701b1eSRobert Gordon newname.utf8string_val, 40450a701b1eSRobert Gordon array[i].nfs_argop4_u.oprename. 40460a701b1eSRobert Gordon newname.utf8string_len); 40477c478bd9Sstevel@tonic-gate } 40487c478bd9Sstevel@tonic-gate continue; 40497c478bd9Sstevel@tonic-gate case OP_RENEW: 40507c478bd9Sstevel@tonic-gate case OP_RESTOREFH: 40517c478bd9Sstevel@tonic-gate case OP_SAVEFH: 40527c478bd9Sstevel@tonic-gate continue; 40537c478bd9Sstevel@tonic-gate case OP_SECINFO: 40547c478bd9Sstevel@tonic-gate if (array[i].nfs_argop4_u.opsecinfo.name. 40550a701b1eSRobert Gordon utf8string_val != NULL) { 40567c478bd9Sstevel@tonic-gate kmem_free(array[i].nfs_argop4_u.opsecinfo.name. 40570a701b1eSRobert Gordon utf8string_val, 40580a701b1eSRobert Gordon array[i].nfs_argop4_u.opsecinfo.name. 40590a701b1eSRobert Gordon utf8string_len); 40607c478bd9Sstevel@tonic-gate } 40617c478bd9Sstevel@tonic-gate continue; 40627c478bd9Sstevel@tonic-gate case OP_SETATTR: 40637c478bd9Sstevel@tonic-gate (void) xdr_fattr4(xdrs, 40647c478bd9Sstevel@tonic-gate &array[i].nfs_argop4_u.opsetattr.obj_attributes); 40657c478bd9Sstevel@tonic-gate continue; 40667c478bd9Sstevel@tonic-gate case OP_SETCLIENTID: 40677c478bd9Sstevel@tonic-gate (void) xdr_SETCLIENTID4args(xdrs, 40680a701b1eSRobert Gordon &array[i].nfs_argop4_u.opsetclientid); 40697c478bd9Sstevel@tonic-gate continue; 40707c478bd9Sstevel@tonic-gate case OP_SETCLIENTID_CONFIRM: 40717c478bd9Sstevel@tonic-gate continue; 40727c478bd9Sstevel@tonic-gate case OP_VERIFY: 40737c478bd9Sstevel@tonic-gate (void) xdr_fattr4(xdrs, 40740a701b1eSRobert Gordon &array[i].nfs_argop4_u.opverify.obj_attributes); 40757c478bd9Sstevel@tonic-gate continue; 40767c478bd9Sstevel@tonic-gate case OP_RELEASE_LOCKOWNER: 40777c478bd9Sstevel@tonic-gate if (array[i].nfs_argop4_u.oprelease_lockowner. 40780a701b1eSRobert Gordon lock_owner.owner_val != NULL) { 40797c478bd9Sstevel@tonic-gate kmem_free(array[i].nfs_argop4_u. 40807c478bd9Sstevel@tonic-gate oprelease_lockowner.lock_owner.owner_val, 40810a701b1eSRobert Gordon array[i].nfs_argop4_u. 40827c478bd9Sstevel@tonic-gate oprelease_lockowner.lock_owner.owner_len); 40837c478bd9Sstevel@tonic-gate } 40847c478bd9Sstevel@tonic-gate continue; 40857c478bd9Sstevel@tonic-gate case OP_ILLEGAL: 40867c478bd9Sstevel@tonic-gate continue; 40877c478bd9Sstevel@tonic-gate default: 40887c478bd9Sstevel@tonic-gate /* 40897c478bd9Sstevel@tonic-gate * An invalid op is a coding error, it should never 40907c478bd9Sstevel@tonic-gate * have been decoded. 40917c478bd9Sstevel@tonic-gate * Don't error because the caller cannot finish 40927c478bd9Sstevel@tonic-gate * freeing the residual memory of the array. 40937c478bd9Sstevel@tonic-gate */ 40947c478bd9Sstevel@tonic-gate continue; 40957c478bd9Sstevel@tonic-gate } 40967c478bd9Sstevel@tonic-gate } 40977c478bd9Sstevel@tonic-gate 40987c478bd9Sstevel@tonic-gate kmem_free(*arrayp, len * sizeof (nfs_argop4)); 40997c478bd9Sstevel@tonic-gate *arrayp = NULL; 41007c478bd9Sstevel@tonic-gate return (TRUE); 41017c478bd9Sstevel@tonic-gate } 41027c478bd9Sstevel@tonic-gate 41037c478bd9Sstevel@tonic-gate static bool_t 41047c478bd9Sstevel@tonic-gate xdr_nfs_argop4(XDR *xdrs, nfs_argop4 *objp) 41057c478bd9Sstevel@tonic-gate { 41060a701b1eSRobert Gordon rdma_chunkinfo_t rci; 41070a701b1eSRobert Gordon struct xdr_ops *xops = xdrrdma_xops(); 41080a701b1eSRobert Gordon 41097c478bd9Sstevel@tonic-gate /* 41107c478bd9Sstevel@tonic-gate * These should be ordered by frequency of use 41117c478bd9Sstevel@tonic-gate */ 41127c478bd9Sstevel@tonic-gate switch (objp->argop) { 41137c478bd9Sstevel@tonic-gate case OP_PUTFH: 41147c478bd9Sstevel@tonic-gate return (xdr_bytes(xdrs, 41157c478bd9Sstevel@tonic-gate (char **)&objp->nfs_argop4_u.opputfh.object.nfs_fh4_val, 41167c478bd9Sstevel@tonic-gate (uint_t *)&objp->nfs_argop4_u.opputfh.object.nfs_fh4_len, 41177c478bd9Sstevel@tonic-gate NFS4_FHSIZE)); 41187c478bd9Sstevel@tonic-gate case OP_GETATTR: 41198ca9c6bbSFaramarz Jalalian - Sun Microsystems - Irvine United States /* 41208ca9c6bbSFaramarz Jalalian - Sun Microsystems - Irvine United States * ACLs can become relatively large ( > 8K) and the default 41218ca9c6bbSFaramarz Jalalian - Sun Microsystems - Irvine United States * 8K reply chunk of RDMA may not suffice. Check for 41228ca9c6bbSFaramarz Jalalian - Sun Microsystems - Irvine United States * get ACL bit and if it's RDMA, add a chunk equal the size 41238ca9c6bbSFaramarz Jalalian - Sun Microsystems - Irvine United States * of the transfer size to the reply chunk list. 41248ca9c6bbSFaramarz Jalalian - Sun Microsystems - Irvine United States */ 41258ca9c6bbSFaramarz Jalalian - Sun Microsystems - Irvine United States if ((xdrs->x_ops == &xdrrdma_ops || xdrs->x_ops == xops) && 41268ca9c6bbSFaramarz Jalalian - Sun Microsystems - Irvine United States (xdrs->x_op == XDR_ENCODE) && 41278ca9c6bbSFaramarz Jalalian - Sun Microsystems - Irvine United States (objp->nfs_argop4_u.opgetattr.attr_request & 41288ca9c6bbSFaramarz Jalalian - Sun Microsystems - Irvine United States FATTR4_ACL_MASK)) { 41298ca9c6bbSFaramarz Jalalian - Sun Microsystems - Irvine United States rci.rci_type = RCI_REPLY_CHUNK; 41308ca9c6bbSFaramarz Jalalian - Sun Microsystems - Irvine United States rci.rci_len = objp->nfs_argop4_u.opgetattr.mi->mi_tsize; 41318ca9c6bbSFaramarz Jalalian - Sun Microsystems - Irvine United States XDR_CONTROL(xdrs, XDR_RDMA_ADD_CHUNK, &rci); 41328ca9c6bbSFaramarz Jalalian - Sun Microsystems - Irvine United States 41338ca9c6bbSFaramarz Jalalian - Sun Microsystems - Irvine United States DTRACE_PROBE1(xdr__i__argop4__getattr, int, 41348ca9c6bbSFaramarz Jalalian - Sun Microsystems - Irvine United States rci.rci_len); 41358ca9c6bbSFaramarz Jalalian - Sun Microsystems - Irvine United States } 41367c478bd9Sstevel@tonic-gate return (xdr_bitmap4(xdrs, 41370a701b1eSRobert Gordon &objp->nfs_argop4_u.opgetattr.attr_request)); 41387c478bd9Sstevel@tonic-gate case OP_GETFH: 41397c478bd9Sstevel@tonic-gate return (TRUE); 41407c478bd9Sstevel@tonic-gate case OP_LOOKUP: 41417c478bd9Sstevel@tonic-gate return (xdr_bytes(xdrs, (char **)&objp->nfs_argop4_u.oplookup. 41420a701b1eSRobert Gordon objname.utf8string_val, 41430a701b1eSRobert Gordon (uint_t *)&objp->nfs_argop4_u.oplookup. 41440a701b1eSRobert Gordon objname.utf8string_len, 41450a701b1eSRobert Gordon NFS4_MAX_UTF8STRING)); 41467c478bd9Sstevel@tonic-gate case OP_OPEN: 41477c478bd9Sstevel@tonic-gate return (xdr_OPEN4args(xdrs, &objp->nfs_argop4_u.opopen)); 41487c478bd9Sstevel@tonic-gate case OP_CLOSE: 41497c478bd9Sstevel@tonic-gate return (xdr_CLOSE4args(xdrs, &objp->nfs_argop4_u.opclose)); 41507c478bd9Sstevel@tonic-gate case OP_ACCESS: 41517c478bd9Sstevel@tonic-gate return (xdr_u_int(xdrs, 41520a701b1eSRobert Gordon &objp->nfs_argop4_u.opaccess.access)); 41537c478bd9Sstevel@tonic-gate case OP_READ: 41547c478bd9Sstevel@tonic-gate return (xdr_READ4args(xdrs, &objp->nfs_argop4_u.opread)); 41557c478bd9Sstevel@tonic-gate case OP_WRITE: 41567c478bd9Sstevel@tonic-gate return (xdr_WRITE4args(xdrs, &objp->nfs_argop4_u.opwrite)); 41577c478bd9Sstevel@tonic-gate case OP_DELEGRETURN: 41587c478bd9Sstevel@tonic-gate if (!xdr_u_int(xdrs, 41597c478bd9Sstevel@tonic-gate &objp->nfs_argop4_u.opdelegreturn.deleg_stateid.seqid)) 41607c478bd9Sstevel@tonic-gate return (FALSE); 41617c478bd9Sstevel@tonic-gate return (xdr_opaque(xdrs, 41627c478bd9Sstevel@tonic-gate objp->nfs_argop4_u.opdelegreturn.deleg_stateid.other, 12)); 41637c478bd9Sstevel@tonic-gate case OP_LOOKUPP: 41647c478bd9Sstevel@tonic-gate return (TRUE); 41657c478bd9Sstevel@tonic-gate case OP_READDIR: 41667c478bd9Sstevel@tonic-gate return (xdr_READDIR4args(xdrs, &objp->nfs_argop4_u.opreaddir)); 41677c478bd9Sstevel@tonic-gate case OP_REMOVE: 41687c478bd9Sstevel@tonic-gate return (xdr_bytes(xdrs, (char **)&objp->nfs_argop4_u.opremove. 41690a701b1eSRobert Gordon target.utf8string_val, 41700a701b1eSRobert Gordon (uint_t *)&objp->nfs_argop4_u.opremove. 41710a701b1eSRobert Gordon target.utf8string_len, 41720a701b1eSRobert Gordon NFS4_MAX_UTF8STRING)); 41737c478bd9Sstevel@tonic-gate case OP_COMMIT: 41747c478bd9Sstevel@tonic-gate if (!xdr_u_longlong_t(xdrs, 41757c478bd9Sstevel@tonic-gate (u_longlong_t *)&objp->nfs_argop4_u.opcommit.offset)) 41767c478bd9Sstevel@tonic-gate return (FALSE); 41777c478bd9Sstevel@tonic-gate return (xdr_u_int(xdrs, &objp->nfs_argop4_u.opcommit.count)); 41787c478bd9Sstevel@tonic-gate case OP_CREATE: 41797c478bd9Sstevel@tonic-gate return (xdr_CREATE4args(xdrs, &objp->nfs_argop4_u.opcreate)); 41807c478bd9Sstevel@tonic-gate case OP_DELEGPURGE: 41817c478bd9Sstevel@tonic-gate return (xdr_u_longlong_t(xdrs, 41827c478bd9Sstevel@tonic-gate (u_longlong_t *)&objp->nfs_argop4_u.opdelegpurge.clientid)); 41837c478bd9Sstevel@tonic-gate case OP_LINK: 41847c478bd9Sstevel@tonic-gate return (xdr_bytes(xdrs, 41857c478bd9Sstevel@tonic-gate (char **)&objp->nfs_argop4_u.oplink.newname.utf8string_val, 41867c478bd9Sstevel@tonic-gate (uint_t *)&objp->nfs_argop4_u.oplink.newname.utf8string_len, 41877c478bd9Sstevel@tonic-gate NFS4_MAX_UTF8STRING)); 41887c478bd9Sstevel@tonic-gate case OP_LOCK: 41897c478bd9Sstevel@tonic-gate return (xdr_LOCK4args(xdrs, &objp->nfs_argop4_u.oplock)); 41907c478bd9Sstevel@tonic-gate case OP_LOCKT: 41917c478bd9Sstevel@tonic-gate return (xdr_LOCKT4args(xdrs, &objp->nfs_argop4_u.oplockt)); 41927c478bd9Sstevel@tonic-gate case OP_LOCKU: 41937c478bd9Sstevel@tonic-gate return (xdr_LOCKU4args(xdrs, &objp->nfs_argop4_u.oplocku)); 41947c478bd9Sstevel@tonic-gate case OP_NVERIFY: 41957c478bd9Sstevel@tonic-gate return (xdr_fattr4(xdrs, 41960a701b1eSRobert Gordon &objp->nfs_argop4_u.opnverify.obj_attributes)); 41977c478bd9Sstevel@tonic-gate case OP_OPENATTR: 41987c478bd9Sstevel@tonic-gate return (xdr_bool(xdrs, 41990a701b1eSRobert Gordon &objp->nfs_argop4_u.opopenattr.createdir)); 42007c478bd9Sstevel@tonic-gate case OP_OPEN_CONFIRM: 42017c478bd9Sstevel@tonic-gate if (!xdr_u_int(xdrs, &objp->nfs_argop4_u.opopen_confirm. 42020a701b1eSRobert Gordon open_stateid.seqid)) 42037c478bd9Sstevel@tonic-gate return (FALSE); 42047c478bd9Sstevel@tonic-gate if (!xdr_opaque(xdrs, objp->nfs_argop4_u.opopen_confirm. 42050a701b1eSRobert Gordon open_stateid.other, 12)) 42067c478bd9Sstevel@tonic-gate return (FALSE); 42077c478bd9Sstevel@tonic-gate return (xdr_u_int(xdrs, &objp->nfs_argop4_u.opopen_confirm. 42080a701b1eSRobert Gordon seqid)); 42097c478bd9Sstevel@tonic-gate case OP_OPEN_DOWNGRADE: 42107c478bd9Sstevel@tonic-gate return (xdr_OPEN_DOWNGRADE4args(xdrs, 42110a701b1eSRobert Gordon &objp->nfs_argop4_u.opopen_downgrade)); 42127c478bd9Sstevel@tonic-gate case OP_PUTPUBFH: 42137c478bd9Sstevel@tonic-gate return (TRUE); 42147c478bd9Sstevel@tonic-gate case OP_PUTROOTFH: 42157c478bd9Sstevel@tonic-gate return (TRUE); 42167c478bd9Sstevel@tonic-gate case OP_READLINK: 42170a701b1eSRobert Gordon if ((xdrs->x_ops == &xdrrdma_ops || xdrs->x_ops == xops) && 42180a701b1eSRobert Gordon xdrs->x_op == XDR_ENCODE) { 42190a701b1eSRobert Gordon rci.rci_type = RCI_REPLY_CHUNK; 42200a701b1eSRobert Gordon rci.rci_len = MAXPATHLEN; 42210a701b1eSRobert Gordon XDR_CONTROL(xdrs, XDR_RDMA_ADD_CHUNK, &rci); 42220a701b1eSRobert Gordon } 42237c478bd9Sstevel@tonic-gate return (TRUE); 42247c478bd9Sstevel@tonic-gate case OP_RENAME: 42257c478bd9Sstevel@tonic-gate if (!xdr_bytes(xdrs, (char **)&objp->nfs_argop4_u.oprename. 42260a701b1eSRobert Gordon oldname.utf8string_val, 42270a701b1eSRobert Gordon (uint_t *)&objp->nfs_argop4_u.oprename. 42280a701b1eSRobert Gordon oldname.utf8string_len, 42290a701b1eSRobert Gordon NFS4_MAX_UTF8STRING)) 42307c478bd9Sstevel@tonic-gate return (FALSE); 42317c478bd9Sstevel@tonic-gate return (xdr_bytes(xdrs, (char **)&objp->nfs_argop4_u.oprename. 42320a701b1eSRobert Gordon newname.utf8string_val, 42330a701b1eSRobert Gordon (uint_t *)&objp->nfs_argop4_u.oprename. 42340a701b1eSRobert Gordon newname.utf8string_len, 42350a701b1eSRobert Gordon NFS4_MAX_UTF8STRING)); 42367c478bd9Sstevel@tonic-gate case OP_RENEW: 42377c478bd9Sstevel@tonic-gate return (xdr_u_longlong_t(xdrs, 42380a701b1eSRobert Gordon (u_longlong_t *)&objp->nfs_argop4_u.oprenew.clientid)); 42397c478bd9Sstevel@tonic-gate case OP_RESTOREFH: 42407c478bd9Sstevel@tonic-gate return (TRUE); 42417c478bd9Sstevel@tonic-gate case OP_SAVEFH: 42427c478bd9Sstevel@tonic-gate return (TRUE); 42437c478bd9Sstevel@tonic-gate case OP_SECINFO: 42447c478bd9Sstevel@tonic-gate return (xdr_bytes(xdrs, 42457c478bd9Sstevel@tonic-gate (char **)&objp->nfs_argop4_u.opsecinfo.name.utf8string_val, 42467c478bd9Sstevel@tonic-gate (uint_t *)&objp->nfs_argop4_u.opsecinfo.name.utf8string_len, 42477c478bd9Sstevel@tonic-gate NFS4_MAX_UTF8STRING)); 42487c478bd9Sstevel@tonic-gate case OP_SETATTR: 42497c478bd9Sstevel@tonic-gate if (!xdr_u_int(xdrs, &objp->nfs_argop4_u.opsetattr. 42500a701b1eSRobert Gordon stateid.seqid)) 42517c478bd9Sstevel@tonic-gate return (FALSE); 42527c478bd9Sstevel@tonic-gate if (!xdr_opaque(xdrs, objp->nfs_argop4_u.opsetattr. 42530a701b1eSRobert Gordon stateid.other, 12)) 42547c478bd9Sstevel@tonic-gate return (FALSE); 42557c478bd9Sstevel@tonic-gate return (xdr_fattr4(xdrs, &objp->nfs_argop4_u.opsetattr. 42560a701b1eSRobert Gordon obj_attributes)); 42577c478bd9Sstevel@tonic-gate case OP_SETCLIENTID: 42587c478bd9Sstevel@tonic-gate return (xdr_SETCLIENTID4args(xdrs, 42590a701b1eSRobert Gordon &objp->nfs_argop4_u.opsetclientid)); 42607c478bd9Sstevel@tonic-gate case OP_SETCLIENTID_CONFIRM: 42617c478bd9Sstevel@tonic-gate if (!xdr_u_longlong_t(xdrs, (u_longlong_t *)&objp->nfs_argop4_u. 42620a701b1eSRobert Gordon opsetclientid_confirm.clientid)) 42637c478bd9Sstevel@tonic-gate return (FALSE); 42647c478bd9Sstevel@tonic-gate return (xdr_u_longlong_t(xdrs, 42650a701b1eSRobert Gordon (u_longlong_t *)&objp->nfs_argop4_u. 42660a701b1eSRobert Gordon opsetclientid_confirm.setclientid_confirm)); 42677c478bd9Sstevel@tonic-gate case OP_VERIFY: 42687c478bd9Sstevel@tonic-gate return (xdr_fattr4(xdrs, 42690a701b1eSRobert Gordon &objp->nfs_argop4_u.opverify.obj_attributes)); 42707c478bd9Sstevel@tonic-gate case OP_RELEASE_LOCKOWNER: 42717c478bd9Sstevel@tonic-gate if (!xdr_u_longlong_t(xdrs, 42720a701b1eSRobert Gordon (u_longlong_t *)&objp->nfs_argop4_u. 42730a701b1eSRobert Gordon oprelease_lockowner.lock_owner.clientid)) 42747c478bd9Sstevel@tonic-gate return (FALSE); 42757c478bd9Sstevel@tonic-gate return (xdr_bytes(xdrs, 42760a701b1eSRobert Gordon (char **)&objp->nfs_argop4_u.oprelease_lockowner. 42770a701b1eSRobert Gordon lock_owner.owner_val, 42780a701b1eSRobert Gordon (uint_t *)&objp->nfs_argop4_u.oprelease_lockowner. 42790a701b1eSRobert Gordon lock_owner.owner_len, NFS4_OPAQUE_LIMIT)); 42807c478bd9Sstevel@tonic-gate case OP_ILLEGAL: 42817c478bd9Sstevel@tonic-gate return (TRUE); 42827c478bd9Sstevel@tonic-gate } 42837c478bd9Sstevel@tonic-gate return (FALSE); 42847c478bd9Sstevel@tonic-gate } 42857c478bd9Sstevel@tonic-gate 42867c46fb7fSek static bool_t 42877c46fb7fSek xdr_cnfs_argop4_wrap(XDR *xdrs, nfs_argop4 *objp) 42887c46fb7fSek { 42897c46fb7fSek if (!xdr_int(xdrs, (int *)&objp->argop)) 42907c46fb7fSek return (FALSE); 42917c46fb7fSek 42927c46fb7fSek return (xdr_nfs_argop4(xdrs, objp)); 42937c46fb7fSek } 42947c46fb7fSek 42957c46fb7fSek static bool_t 42967c46fb7fSek xdr_snfs_argop4(XDR *xdrs, nfs_argop4 *objp) 42977c46fb7fSek { 42987c46fb7fSek if (!xdr_int(xdrs, (int *)&objp->argop)) 42997c46fb7fSek return (FALSE); 43007c46fb7fSek 43017c46fb7fSek switch (objp->argop) { 43027c46fb7fSek case OP_PUTFH: 43037c46fb7fSek return (xdr_decode_nfs_fh4(xdrs, 43040a701b1eSRobert Gordon &objp->nfs_argop4_u.opputfh.object)); 43057c46fb7fSek default: 43067c46fb7fSek return (xdr_nfs_argop4(xdrs, objp)); 43077c46fb7fSek } 43087c46fb7fSek } 43097c46fb7fSek 43107c478bd9Sstevel@tonic-gate /* 43117c478bd9Sstevel@tonic-gate * Client side encode only arg op processing 43127c478bd9Sstevel@tonic-gate */ 43137c478bd9Sstevel@tonic-gate static bool_t 43147c478bd9Sstevel@tonic-gate xdr_cnfs_argop4(XDR *xdrs, nfs_argop4 *objp) 43157c478bd9Sstevel@tonic-gate { 43167c478bd9Sstevel@tonic-gate int len; 43177c478bd9Sstevel@tonic-gate int op; 43187c478bd9Sstevel@tonic-gate nfs4_sharedfh_t *sfh; 43197c478bd9Sstevel@tonic-gate mntinfo4_t *mi; 43207c478bd9Sstevel@tonic-gate rpc_inline_t *ptr; 43217c478bd9Sstevel@tonic-gate 43227c478bd9Sstevel@tonic-gate ASSERT(xdrs->x_op == XDR_ENCODE); 43237c478bd9Sstevel@tonic-gate 43247c478bd9Sstevel@tonic-gate /* 43257c478bd9Sstevel@tonic-gate * Special case the private pseudo ops 43267c478bd9Sstevel@tonic-gate */ 43277c478bd9Sstevel@tonic-gate if (!(objp->argop & SUNW_PRIVATE_OP)) 43287c46fb7fSek return (xdr_cnfs_argop4_wrap(xdrs, objp)); 43297c478bd9Sstevel@tonic-gate 43307c478bd9Sstevel@tonic-gate /* 43317c478bd9Sstevel@tonic-gate * These should be ordered by frequency of use 43327c478bd9Sstevel@tonic-gate */ 43337c478bd9Sstevel@tonic-gate switch (objp->argop) { 43347c478bd9Sstevel@tonic-gate case OP_CPUTFH: 43357c478bd9Sstevel@tonic-gate /* 43367c478bd9Sstevel@tonic-gate * We are passed in the file handle as a nfs4_sharedfh_t * 43377c478bd9Sstevel@tonic-gate * We need to acquire the correct locks so we can copy it out. 43387c478bd9Sstevel@tonic-gate */ 43397c478bd9Sstevel@tonic-gate sfh = (nfs4_sharedfh_t *)objp->nfs_argop4_u.opcputfh.sfh; 43407c478bd9Sstevel@tonic-gate mi = sfh->sfh_mi; 43417c478bd9Sstevel@tonic-gate (void) nfs_rw_enter_sig(&mi->mi_fh_lock, RW_READER, 0); 43427c478bd9Sstevel@tonic-gate 43437c478bd9Sstevel@tonic-gate len = sfh->sfh_fh.nfs_fh4_len; 43447c478bd9Sstevel@tonic-gate ASSERT(len <= NFS4_FHSIZE); 43457c478bd9Sstevel@tonic-gate 43467c478bd9Sstevel@tonic-gate /* 43477c478bd9Sstevel@tonic-gate * First try and inline the copy 43487c478bd9Sstevel@tonic-gate * Must first be a multiple of BYTES_PER_XDR_UNIT 43497c478bd9Sstevel@tonic-gate */ 43507c478bd9Sstevel@tonic-gate if (!(len % BYTES_PER_XDR_UNIT) && 43517c478bd9Sstevel@tonic-gate (ptr = XDR_INLINE(xdrs, 2 * BYTES_PER_XDR_UNIT + len)) != 43520a701b1eSRobert Gordon NULL) { 43537c478bd9Sstevel@tonic-gate IXDR_PUT_U_INT32(ptr, OP_PUTFH); 43547c478bd9Sstevel@tonic-gate IXDR_PUT_U_INT32(ptr, len); 43557c478bd9Sstevel@tonic-gate bcopy(sfh->sfh_fh.nfs_fh4_val, ptr, len); 43567c478bd9Sstevel@tonic-gate nfs_rw_exit(&mi->mi_fh_lock); 43577c478bd9Sstevel@tonic-gate return (TRUE); 43587c478bd9Sstevel@tonic-gate } 43597c478bd9Sstevel@tonic-gate 43607c478bd9Sstevel@tonic-gate op = OP_PUTFH; 43617c478bd9Sstevel@tonic-gate if (!XDR_PUTINT32(xdrs, &op)) { 43627c478bd9Sstevel@tonic-gate nfs_rw_exit(&mi->mi_fh_lock); 43637c478bd9Sstevel@tonic-gate return (FALSE); 43647c478bd9Sstevel@tonic-gate } 43657c478bd9Sstevel@tonic-gate if (!XDR_PUTINT32(xdrs, &len)) { 43667c478bd9Sstevel@tonic-gate nfs_rw_exit(&mi->mi_fh_lock); 43677c478bd9Sstevel@tonic-gate return (FALSE); 43687c478bd9Sstevel@tonic-gate } 43697c478bd9Sstevel@tonic-gate if (!(len % BYTES_PER_XDR_UNIT)) { 43707c478bd9Sstevel@tonic-gate if (XDR_PUTBYTES(xdrs, sfh->sfh_fh.nfs_fh4_val, len)) { 43717c478bd9Sstevel@tonic-gate nfs_rw_exit(&mi->mi_fh_lock); 43727c478bd9Sstevel@tonic-gate return (TRUE); 43737c478bd9Sstevel@tonic-gate } 43747c478bd9Sstevel@tonic-gate } else if (xdr_opaque(xdrs, sfh->sfh_fh.nfs_fh4_val, len)) { 43757c478bd9Sstevel@tonic-gate nfs_rw_exit(&mi->mi_fh_lock); 43767c478bd9Sstevel@tonic-gate return (TRUE); 43777c478bd9Sstevel@tonic-gate } 43787c478bd9Sstevel@tonic-gate nfs_rw_exit(&mi->mi_fh_lock); 43797c478bd9Sstevel@tonic-gate return (FALSE); 43807c478bd9Sstevel@tonic-gate case OP_CLOOKUP: 43817c478bd9Sstevel@tonic-gate len = strlen(objp->nfs_argop4_u.opclookup.cname); 43827c478bd9Sstevel@tonic-gate if (len > NFS4_MAX_UTF8STRING) 43837c478bd9Sstevel@tonic-gate return (FALSE); 43847c478bd9Sstevel@tonic-gate op = OP_LOOKUP; 43857c478bd9Sstevel@tonic-gate if (XDR_PUTINT32(xdrs, &op)) { 43867c478bd9Sstevel@tonic-gate if (XDR_PUTINT32(xdrs, &len)) { 43877c478bd9Sstevel@tonic-gate return (xdr_opaque(xdrs, 43880a701b1eSRobert Gordon objp->nfs_argop4_u.opclookup.cname, 43890a701b1eSRobert Gordon len)); 43907c478bd9Sstevel@tonic-gate } 43917c478bd9Sstevel@tonic-gate } 43927c478bd9Sstevel@tonic-gate return (FALSE); 43937c478bd9Sstevel@tonic-gate case OP_COPEN: 43947c478bd9Sstevel@tonic-gate /* op processing inlined in xdr_OPEN4cargs */ 43957c478bd9Sstevel@tonic-gate return (xdr_OPEN4cargs(xdrs, &objp->nfs_argop4_u.opcopen)); 43967c478bd9Sstevel@tonic-gate case OP_CREMOVE: 43977c478bd9Sstevel@tonic-gate len = strlen(objp->nfs_argop4_u.opcremove.ctarget); 43987c478bd9Sstevel@tonic-gate if (len > NFS4_MAX_UTF8STRING) 43997c478bd9Sstevel@tonic-gate return (FALSE); 44007c478bd9Sstevel@tonic-gate op = OP_REMOVE; 44017c478bd9Sstevel@tonic-gate if (XDR_PUTINT32(xdrs, &op)) { 44027c478bd9Sstevel@tonic-gate if (XDR_PUTINT32(xdrs, &len)) { 44037c478bd9Sstevel@tonic-gate return (xdr_opaque(xdrs, 44040a701b1eSRobert Gordon objp->nfs_argop4_u.opcremove.ctarget, 44050a701b1eSRobert Gordon len)); 44067c478bd9Sstevel@tonic-gate } 44077c478bd9Sstevel@tonic-gate } 44087c478bd9Sstevel@tonic-gate return (FALSE); 44097c478bd9Sstevel@tonic-gate case OP_CCREATE: 44107c478bd9Sstevel@tonic-gate op = OP_CREATE; 44117c478bd9Sstevel@tonic-gate if (!XDR_PUTINT32(xdrs, &op)) 44127c478bd9Sstevel@tonic-gate return (FALSE); 44137c478bd9Sstevel@tonic-gate return (xdr_CREATE4cargs(xdrs, &objp->nfs_argop4_u.opccreate)); 44147c478bd9Sstevel@tonic-gate case OP_CLINK: 44157c478bd9Sstevel@tonic-gate len = strlen(objp->nfs_argop4_u.opclink.cnewname); 44167c478bd9Sstevel@tonic-gate if (len > NFS4_MAX_UTF8STRING) 44177c478bd9Sstevel@tonic-gate return (FALSE); 44187c478bd9Sstevel@tonic-gate op = OP_LINK; 44197c478bd9Sstevel@tonic-gate if (XDR_PUTINT32(xdrs, &op)) { 44207c478bd9Sstevel@tonic-gate if (XDR_PUTINT32(xdrs, &len)) { 44217c478bd9Sstevel@tonic-gate return (xdr_opaque(xdrs, 44220a701b1eSRobert Gordon objp->nfs_argop4_u.opclink.cnewname, 44230a701b1eSRobert Gordon len)); 44247c478bd9Sstevel@tonic-gate } 44257c478bd9Sstevel@tonic-gate } 44267c478bd9Sstevel@tonic-gate return (FALSE); 44277c478bd9Sstevel@tonic-gate case OP_CRENAME: 44287c478bd9Sstevel@tonic-gate len = strlen(objp->nfs_argop4_u.opcrename.coldname); 44297c478bd9Sstevel@tonic-gate if (len > NFS4_MAX_UTF8STRING) 44307c478bd9Sstevel@tonic-gate return (FALSE); 44317c478bd9Sstevel@tonic-gate op = OP_RENAME; 44327c478bd9Sstevel@tonic-gate if (!XDR_PUTINT32(xdrs, &op)) 44337c478bd9Sstevel@tonic-gate return (FALSE); 44347c478bd9Sstevel@tonic-gate if (!XDR_PUTINT32(xdrs, &len)) 44357c478bd9Sstevel@tonic-gate return (FALSE); 44367c478bd9Sstevel@tonic-gate if (!xdr_opaque(xdrs, 44370a701b1eSRobert Gordon objp->nfs_argop4_u.opcrename.coldname, len)) 44387c478bd9Sstevel@tonic-gate return (FALSE); 44397c478bd9Sstevel@tonic-gate len = strlen(objp->nfs_argop4_u.opcrename.cnewname); 44407c478bd9Sstevel@tonic-gate if (len > NFS4_MAX_UTF8STRING) 44417c478bd9Sstevel@tonic-gate return (FALSE); 44427c478bd9Sstevel@tonic-gate if (XDR_PUTINT32(xdrs, &len)) { 44437c478bd9Sstevel@tonic-gate return (xdr_opaque(xdrs, 44440a701b1eSRobert Gordon objp->nfs_argop4_u.opcrename.cnewname, len)); 44457c478bd9Sstevel@tonic-gate } 44467c478bd9Sstevel@tonic-gate return (FALSE); 44477c478bd9Sstevel@tonic-gate case OP_CSECINFO: 44487c478bd9Sstevel@tonic-gate len = strlen(objp->nfs_argop4_u.opcsecinfo.cname); 44497c478bd9Sstevel@tonic-gate if (len > NFS4_MAX_UTF8STRING) 44507c478bd9Sstevel@tonic-gate return (FALSE); 44517c478bd9Sstevel@tonic-gate op = OP_SECINFO; 44527c478bd9Sstevel@tonic-gate if (XDR_PUTINT32(xdrs, &op)) { 44537c478bd9Sstevel@tonic-gate if (XDR_PUTINT32(xdrs, &len)) { 44547c478bd9Sstevel@tonic-gate return (xdr_opaque(xdrs, 44550a701b1eSRobert Gordon objp->nfs_argop4_u.opcsecinfo.cname, 44560a701b1eSRobert Gordon len)); 44577c478bd9Sstevel@tonic-gate } 44587c478bd9Sstevel@tonic-gate } 44597c478bd9Sstevel@tonic-gate return (FALSE); 44607c478bd9Sstevel@tonic-gate } 44617c478bd9Sstevel@tonic-gate return (FALSE); 44627c478bd9Sstevel@tonic-gate } 44637c478bd9Sstevel@tonic-gate 44647c478bd9Sstevel@tonic-gate /* 44657c478bd9Sstevel@tonic-gate * Note that the len and decode_len will only be different in the case 44667c478bd9Sstevel@tonic-gate * of the client's use of this free function. If the server is 44677c478bd9Sstevel@tonic-gate * freeing results, then the len/decode_len will always match. 44687c478bd9Sstevel@tonic-gate */ 44697c478bd9Sstevel@tonic-gate static bool_t 44707c478bd9Sstevel@tonic-gate xdr_nfs_resop4_free(XDR *xdrs, nfs_resop4 **arrayp, int len, int decode_len) 44717c478bd9Sstevel@tonic-gate { 44727c478bd9Sstevel@tonic-gate int i; 44737c478bd9Sstevel@tonic-gate nfs_resop4 *array = *arrayp; 44742f172c55SRobert Thurlow nfs4_ga_res_t *gr; 44757c478bd9Sstevel@tonic-gate 44767c478bd9Sstevel@tonic-gate /* 44777c478bd9Sstevel@tonic-gate * Optimized XDR_FREE only results array 44787c478bd9Sstevel@tonic-gate */ 44797c478bd9Sstevel@tonic-gate ASSERT(xdrs->x_op == XDR_FREE); 44807c478bd9Sstevel@tonic-gate 44817c478bd9Sstevel@tonic-gate if (array == NULL) 44827c478bd9Sstevel@tonic-gate return (TRUE); 44837c478bd9Sstevel@tonic-gate 44847c478bd9Sstevel@tonic-gate for (i = 0; i < decode_len; i++) { 44857c478bd9Sstevel@tonic-gate /* 44867c478bd9Sstevel@tonic-gate * These should be ordered by frequency of use 44877c478bd9Sstevel@tonic-gate */ 44887c478bd9Sstevel@tonic-gate switch (array[i].resop) { 44897c478bd9Sstevel@tonic-gate case OP_PUTFH: 44907c478bd9Sstevel@tonic-gate continue; 44917c478bd9Sstevel@tonic-gate case OP_GETATTR: 44927c478bd9Sstevel@tonic-gate if (array[i].nfs_resop4_u.opgetattr.status != NFS4_OK) 44937c478bd9Sstevel@tonic-gate continue; 44942f172c55SRobert Thurlow 44952f172c55SRobert Thurlow gr = &array[i].nfs_resop4_u.opgetattr.ga_res; 44962f172c55SRobert Thurlow if (gr->n4g_ext_res) { 44972f172c55SRobert Thurlow if (gr->n4g_resbmap & FATTR4_FS_LOCATIONS_MASK) 44982f172c55SRobert Thurlow (void) xdr_fattr4_fs_locations(xdrs, 44992f172c55SRobert Thurlow &gr->n4g_ext_res->n4g_fslocations); 45002f172c55SRobert Thurlow kmem_free(gr->n4g_ext_res, 45010a701b1eSRobert Gordon sizeof (struct nfs4_ga_ext_res)); 45022f172c55SRobert Thurlow } 45037c478bd9Sstevel@tonic-gate continue; 45047c478bd9Sstevel@tonic-gate case OP_GETFH: 45057c478bd9Sstevel@tonic-gate if (array[i].nfs_resop4_u.opgetfh.status != NFS4_OK) 45067c478bd9Sstevel@tonic-gate continue; 45077c478bd9Sstevel@tonic-gate if (array[i].nfs_resop4_u.opgetfh.object.nfs_fh4_val != 45080a701b1eSRobert Gordon NULL) { 45097c478bd9Sstevel@tonic-gate kmem_free(array[i].nfs_resop4_u.opgetfh.object. 45100a701b1eSRobert Gordon nfs_fh4_val, 45110a701b1eSRobert Gordon array[i].nfs_resop4_u.opgetfh.object. 45120a701b1eSRobert Gordon nfs_fh4_len); 45137c478bd9Sstevel@tonic-gate } 45147c478bd9Sstevel@tonic-gate continue; 45157c478bd9Sstevel@tonic-gate case OP_LOOKUP: 45167c478bd9Sstevel@tonic-gate continue; 45177c478bd9Sstevel@tonic-gate case OP_OPEN: 45187c478bd9Sstevel@tonic-gate (void) xdr_OPEN4res(xdrs, &array[i].nfs_resop4_u. 45190a701b1eSRobert Gordon opopen); 45207c478bd9Sstevel@tonic-gate continue; 45217c478bd9Sstevel@tonic-gate case OP_CLOSE: 45227c478bd9Sstevel@tonic-gate case OP_ACCESS: 45237c478bd9Sstevel@tonic-gate continue; 45247c478bd9Sstevel@tonic-gate case OP_READ: 45257c478bd9Sstevel@tonic-gate (void) xdr_READ4res(xdrs, 45260a701b1eSRobert Gordon &array[i].nfs_resop4_u.opread); 45277c478bd9Sstevel@tonic-gate continue; 45287c478bd9Sstevel@tonic-gate case OP_WRITE: 45297c478bd9Sstevel@tonic-gate case OP_DELEGRETURN: 45307c478bd9Sstevel@tonic-gate case OP_LOOKUPP: 45317c478bd9Sstevel@tonic-gate case OP_READDIR: 45327c478bd9Sstevel@tonic-gate case OP_REMOVE: 45337c478bd9Sstevel@tonic-gate case OP_COMMIT: 45347c478bd9Sstevel@tonic-gate case OP_CREATE: 45357c478bd9Sstevel@tonic-gate case OP_DELEGPURGE: 45367c478bd9Sstevel@tonic-gate case OP_LINK: 45377c478bd9Sstevel@tonic-gate continue; 45387c478bd9Sstevel@tonic-gate case OP_LOCK: 45397c478bd9Sstevel@tonic-gate (void) xdr_LOCK4res(xdrs, &array[i].nfs_resop4_u. 45400a701b1eSRobert Gordon oplock); 45417c478bd9Sstevel@tonic-gate continue; 45427c478bd9Sstevel@tonic-gate case OP_LOCKT: 45437c478bd9Sstevel@tonic-gate (void) xdr_LOCKT4res(xdrs, &array[i].nfs_resop4_u. 45440a701b1eSRobert Gordon oplockt); 45457c478bd9Sstevel@tonic-gate continue; 45467c478bd9Sstevel@tonic-gate case OP_LOCKU: 45477c478bd9Sstevel@tonic-gate case OP_NVERIFY: 45487c478bd9Sstevel@tonic-gate case OP_OPENATTR: 45497c478bd9Sstevel@tonic-gate case OP_OPEN_CONFIRM: 45507c478bd9Sstevel@tonic-gate case OP_OPEN_DOWNGRADE: 45517c478bd9Sstevel@tonic-gate case OP_PUTPUBFH: 45527c478bd9Sstevel@tonic-gate case OP_PUTROOTFH: 45537c478bd9Sstevel@tonic-gate case OP_RENAME: 45547c478bd9Sstevel@tonic-gate case OP_RENEW: 45557c478bd9Sstevel@tonic-gate case OP_RESTOREFH: 45567c478bd9Sstevel@tonic-gate case OP_SAVEFH: 45577c478bd9Sstevel@tonic-gate continue; 45587c478bd9Sstevel@tonic-gate case OP_READLINK: 45597c478bd9Sstevel@tonic-gate (void) xdr_READLINK4res(xdrs, &array[i].nfs_resop4_u. 45600a701b1eSRobert Gordon opreadlink); 45617c478bd9Sstevel@tonic-gate continue; 45627c478bd9Sstevel@tonic-gate case OP_SECINFO: 45637c478bd9Sstevel@tonic-gate (void) xdr_array(xdrs, 45640a701b1eSRobert Gordon (char **)&array[i].nfs_resop4_u.opsecinfo. 45650a701b1eSRobert Gordon SECINFO4resok_val, 45660a701b1eSRobert Gordon (uint_t *)&array[i].nfs_resop4_u.opsecinfo. 45670a701b1eSRobert Gordon SECINFO4resok_len, 45680a701b1eSRobert Gordon NFS4_SECINFO_LIMIT, sizeof (secinfo4), 45690a701b1eSRobert Gordon (xdrproc_t)xdr_secinfo4); 45707c478bd9Sstevel@tonic-gate continue; 45717c478bd9Sstevel@tonic-gate case OP_SETCLIENTID: 45727c478bd9Sstevel@tonic-gate (void) xdr_SETCLIENTID4res(xdrs, 45730a701b1eSRobert Gordon &array[i].nfs_resop4_u.opsetclientid); 45747c478bd9Sstevel@tonic-gate continue; 45757c478bd9Sstevel@tonic-gate case OP_SETATTR: 45767c478bd9Sstevel@tonic-gate case OP_SETCLIENTID_CONFIRM: 45777c478bd9Sstevel@tonic-gate case OP_VERIFY: 45787c478bd9Sstevel@tonic-gate case OP_RELEASE_LOCKOWNER: 45797c478bd9Sstevel@tonic-gate case OP_ILLEGAL: 45807c478bd9Sstevel@tonic-gate continue; 45817c478bd9Sstevel@tonic-gate default: 45827c478bd9Sstevel@tonic-gate /* 45837c478bd9Sstevel@tonic-gate * An invalid op is a coding error, it should never 45847c478bd9Sstevel@tonic-gate * have been decoded. 45857c478bd9Sstevel@tonic-gate * Don't error because the caller cannot finish 45867c478bd9Sstevel@tonic-gate * freeing the residual memory of the array. 45877c478bd9Sstevel@tonic-gate */ 45887c478bd9Sstevel@tonic-gate continue; 45897c478bd9Sstevel@tonic-gate } 45907c478bd9Sstevel@tonic-gate } 45917c478bd9Sstevel@tonic-gate 45927c478bd9Sstevel@tonic-gate kmem_free(*arrayp, len * sizeof (nfs_resop4)); 45937c478bd9Sstevel@tonic-gate *arrayp = NULL; 45947c478bd9Sstevel@tonic-gate return (TRUE); 45957c478bd9Sstevel@tonic-gate } 45967c478bd9Sstevel@tonic-gate 45977c46fb7fSek static bool_t 45987c46fb7fSek xdr_snfs_resop4_free(XDR *xdrs, nfs_resop4 **arrayp, int len, int decode_len) 45997c46fb7fSek { 46007c46fb7fSek return (xdr_nfs_resop4_free(xdrs, arrayp, len, decode_len)); 46017c46fb7fSek } 46027c46fb7fSek 46037c478bd9Sstevel@tonic-gate static bool_t 46047c478bd9Sstevel@tonic-gate xdr_nfs_resop4(XDR *xdrs, nfs_resop4 *objp) 46057c478bd9Sstevel@tonic-gate { 46067c478bd9Sstevel@tonic-gate /* 46077c478bd9Sstevel@tonic-gate * These should be ordered by frequency of use 46087c478bd9Sstevel@tonic-gate */ 46097c478bd9Sstevel@tonic-gate switch (objp->resop) { 46107c478bd9Sstevel@tonic-gate case OP_PUTFH: 46117c478bd9Sstevel@tonic-gate return (xdr_int(xdrs, 46120a701b1eSRobert Gordon (int32_t *)&objp->nfs_resop4_u.opputfh.status)); 46137c478bd9Sstevel@tonic-gate case OP_GETATTR: 46147c478bd9Sstevel@tonic-gate if (!xdr_int(xdrs, 46150a701b1eSRobert Gordon (int32_t *)&objp->nfs_resop4_u.opgetattr.status)) 46167c478bd9Sstevel@tonic-gate return (FALSE); 46177c478bd9Sstevel@tonic-gate if (objp->nfs_resop4_u.opgetattr.status != NFS4_OK) 46187c478bd9Sstevel@tonic-gate return (TRUE); 46197c478bd9Sstevel@tonic-gate return (xdr_fattr4(xdrs, 46200a701b1eSRobert Gordon &objp->nfs_resop4_u.opgetattr.obj_attributes)); 46217c478bd9Sstevel@tonic-gate case OP_GETFH: 46227c478bd9Sstevel@tonic-gate if (!xdr_int(xdrs, 46230a701b1eSRobert Gordon (int32_t *)&objp->nfs_resop4_u.opgetfh.status)) 46247c478bd9Sstevel@tonic-gate return (FALSE); 46257c478bd9Sstevel@tonic-gate if (objp->nfs_resop4_u.opgetfh.status != NFS4_OK) 46267c478bd9Sstevel@tonic-gate return (TRUE); 46277c478bd9Sstevel@tonic-gate return (xdr_bytes(xdrs, 46287c478bd9Sstevel@tonic-gate (char **)&objp->nfs_resop4_u.opgetfh.object.nfs_fh4_val, 46297c478bd9Sstevel@tonic-gate (uint_t *)&objp->nfs_resop4_u.opgetfh.object.nfs_fh4_len, 46307c478bd9Sstevel@tonic-gate NFS4_FHSIZE)); 46317c478bd9Sstevel@tonic-gate case OP_LOOKUP: 46327c478bd9Sstevel@tonic-gate return (xdr_int(xdrs, 46330a701b1eSRobert Gordon (int32_t *)&objp->nfs_resop4_u.oplookup.status)); 46347c478bd9Sstevel@tonic-gate case OP_OPEN: 46357c478bd9Sstevel@tonic-gate return (xdr_OPEN4res(xdrs, &objp->nfs_resop4_u.opopen)); 46367c478bd9Sstevel@tonic-gate case OP_CLOSE: 46377c478bd9Sstevel@tonic-gate return (xdr_CLOSE4res(xdrs, &objp->nfs_resop4_u.opclose)); 46387c478bd9Sstevel@tonic-gate case OP_ACCESS: 46397c478bd9Sstevel@tonic-gate return (xdr_ACCESS4res(xdrs, &objp->nfs_resop4_u.opaccess)); 46407c478bd9Sstevel@tonic-gate case OP_READ: 46417c478bd9Sstevel@tonic-gate return (xdr_READ4res(xdrs, &objp->nfs_resop4_u.opread)); 46427c478bd9Sstevel@tonic-gate case OP_WRITE: 46437c478bd9Sstevel@tonic-gate return (xdr_WRITE4res(xdrs, &objp->nfs_resop4_u.opwrite)); 46447c478bd9Sstevel@tonic-gate case OP_DELEGRETURN: 46457c478bd9Sstevel@tonic-gate return (xdr_int(xdrs, 46460a701b1eSRobert Gordon (int32_t *)&objp->nfs_resop4_u.opdelegreturn.status)); 46477c478bd9Sstevel@tonic-gate case OP_LOOKUPP: 46487c478bd9Sstevel@tonic-gate return (xdr_int(xdrs, 46490a701b1eSRobert Gordon (int32_t *)&objp->nfs_resop4_u.oplookupp.status)); 46507c478bd9Sstevel@tonic-gate case OP_READDIR: 46517c478bd9Sstevel@tonic-gate return (xdr_READDIR4res(xdrs, &objp->nfs_resop4_u.opreaddir)); 46527c478bd9Sstevel@tonic-gate case OP_REMOVE: 46537c478bd9Sstevel@tonic-gate return (xdr_REMOVE4res(xdrs, &objp->nfs_resop4_u.opremove)); 46547c478bd9Sstevel@tonic-gate 46557c478bd9Sstevel@tonic-gate case OP_COMMIT: 46567c478bd9Sstevel@tonic-gate if (!xdr_int(xdrs, 46570a701b1eSRobert Gordon (int32_t *)&objp->nfs_resop4_u.opcommit.status)) 46587c478bd9Sstevel@tonic-gate return (FALSE); 46597c478bd9Sstevel@tonic-gate if (objp->nfs_resop4_u.opcommit.status != NFS4_OK) 46607c478bd9Sstevel@tonic-gate return (TRUE); 46617c478bd9Sstevel@tonic-gate return (xdr_u_longlong_t(xdrs, 46620a701b1eSRobert Gordon (u_longlong_t *)&objp->nfs_resop4_u.opcommit. 46630a701b1eSRobert Gordon writeverf)); 46647c478bd9Sstevel@tonic-gate case OP_CREATE: 46657c478bd9Sstevel@tonic-gate return (xdr_CREATE4res(xdrs, &objp->nfs_resop4_u.opcreate)); 46667c478bd9Sstevel@tonic-gate case OP_DELEGPURGE: 46677c478bd9Sstevel@tonic-gate return (xdr_int(xdrs, 46680a701b1eSRobert Gordon (int32_t *)&objp->nfs_resop4_u.opdelegpurge.status)); 46697c478bd9Sstevel@tonic-gate case OP_LINK: 46707c478bd9Sstevel@tonic-gate return (xdr_LINK4res(xdrs, &objp->nfs_resop4_u.oplink)); 46717c478bd9Sstevel@tonic-gate case OP_LOCK: 46727c478bd9Sstevel@tonic-gate return (xdr_LOCK4res(xdrs, &objp->nfs_resop4_u.oplock)); 46737c478bd9Sstevel@tonic-gate case OP_LOCKT: 46747c478bd9Sstevel@tonic-gate return (xdr_LOCKT4res(xdrs, &objp->nfs_resop4_u.oplockt)); 46757c478bd9Sstevel@tonic-gate case OP_LOCKU: 46767c478bd9Sstevel@tonic-gate if (!xdr_int(xdrs, 46770a701b1eSRobert Gordon (int32_t *)&objp->nfs_resop4_u.oplocku.status)) 46787c478bd9Sstevel@tonic-gate return (FALSE); 46797c478bd9Sstevel@tonic-gate if (objp->nfs_resop4_u.oplocku.status != NFS4_OK) 46807c478bd9Sstevel@tonic-gate return (TRUE); 46817c478bd9Sstevel@tonic-gate if (!xdr_u_int(xdrs, 46827c478bd9Sstevel@tonic-gate &objp->nfs_resop4_u.oplocku.lock_stateid.seqid)) 46837c478bd9Sstevel@tonic-gate return (FALSE); 46847c478bd9Sstevel@tonic-gate return (xdr_opaque(xdrs, 46857c478bd9Sstevel@tonic-gate objp->nfs_resop4_u.oplocku.lock_stateid.other, 46867c478bd9Sstevel@tonic-gate 12)); 46877c478bd9Sstevel@tonic-gate case OP_NVERIFY: 46887c478bd9Sstevel@tonic-gate return (xdr_int(xdrs, 46890a701b1eSRobert Gordon (int32_t *)&objp->nfs_resop4_u.opnverify.status)); 46907c478bd9Sstevel@tonic-gate case OP_OPENATTR: 46917c478bd9Sstevel@tonic-gate return (xdr_int(xdrs, 46920a701b1eSRobert Gordon (int32_t *)&objp->nfs_resop4_u.opopenattr.status)); 46937c478bd9Sstevel@tonic-gate case OP_OPEN_CONFIRM: 46947c478bd9Sstevel@tonic-gate return (xdr_OPEN_CONFIRM4res(xdrs, 46950a701b1eSRobert Gordon &objp->nfs_resop4_u.opopen_confirm)); 46967c478bd9Sstevel@tonic-gate case OP_OPEN_DOWNGRADE: 46977c478bd9Sstevel@tonic-gate return (xdr_OPEN_DOWNGRADE4res(xdrs, 46980a701b1eSRobert Gordon &objp->nfs_resop4_u.opopen_downgrade)); 46997c478bd9Sstevel@tonic-gate case OP_PUTPUBFH: 47007c478bd9Sstevel@tonic-gate return (xdr_int(xdrs, 47010a701b1eSRobert Gordon (int32_t *)&objp->nfs_resop4_u.opputpubfh.status)); 47027c478bd9Sstevel@tonic-gate case OP_PUTROOTFH: 47037c478bd9Sstevel@tonic-gate return (xdr_int(xdrs, 47040a701b1eSRobert Gordon (int32_t *)&objp->nfs_resop4_u.opputrootfh.status)); 47057c478bd9Sstevel@tonic-gate case OP_READLINK: 47067c478bd9Sstevel@tonic-gate return (xdr_READLINK4res(xdrs, &objp->nfs_resop4_u.opreadlink)); 47077c478bd9Sstevel@tonic-gate case OP_RENAME: 47087c478bd9Sstevel@tonic-gate return (xdr_RENAME4res(xdrs, &objp->nfs_resop4_u.oprename)); 47097c478bd9Sstevel@tonic-gate case OP_RENEW: 47107c478bd9Sstevel@tonic-gate return (xdr_int(xdrs, 47110a701b1eSRobert Gordon (int32_t *)&objp->nfs_resop4_u.oprenew.status)); 47127c478bd9Sstevel@tonic-gate case OP_RESTOREFH: 47137c478bd9Sstevel@tonic-gate return (xdr_int(xdrs, 47140a701b1eSRobert Gordon (int32_t *)&objp->nfs_resop4_u.oprestorefh.status)); 47157c478bd9Sstevel@tonic-gate case OP_SAVEFH: 47167c478bd9Sstevel@tonic-gate return (xdr_int(xdrs, 47170a701b1eSRobert Gordon (int32_t *)&objp->nfs_resop4_u.opsavefh.status)); 47187c478bd9Sstevel@tonic-gate case OP_SECINFO: 47197c478bd9Sstevel@tonic-gate if (!xdr_int(xdrs, (int32_t *)&objp->nfs_resop4_u.opsecinfo. 47200a701b1eSRobert Gordon status)) 47217c478bd9Sstevel@tonic-gate return (FALSE); 47227c478bd9Sstevel@tonic-gate if (objp->nfs_resop4_u.opsecinfo.status != NFS4_OK) 47237c478bd9Sstevel@tonic-gate return (TRUE); 47247c478bd9Sstevel@tonic-gate return (xdr_array(xdrs, (char **)&objp->nfs_resop4_u.opsecinfo. 47250a701b1eSRobert Gordon SECINFO4resok_val, 47260a701b1eSRobert Gordon (uint_t *)&objp->nfs_resop4_u.opsecinfo. 47270a701b1eSRobert Gordon SECINFO4resok_len, 47280a701b1eSRobert Gordon NFS4_SECINFO_LIMIT, sizeof (secinfo4), 47290a701b1eSRobert Gordon (xdrproc_t)xdr_secinfo4)); 47307c478bd9Sstevel@tonic-gate case OP_SETATTR: 47317c478bd9Sstevel@tonic-gate if (!xdr_int(xdrs, (int32_t *)&objp->nfs_resop4_u.opsetattr. 47320a701b1eSRobert Gordon status)) 47337c478bd9Sstevel@tonic-gate return (FALSE); 47347c478bd9Sstevel@tonic-gate return (xdr_bitmap4(xdrs, 47350a701b1eSRobert Gordon &objp->nfs_resop4_u.opsetattr.attrsset)); 47367c478bd9Sstevel@tonic-gate case OP_SETCLIENTID: 47377c478bd9Sstevel@tonic-gate return (xdr_SETCLIENTID4res(xdrs, 47380a701b1eSRobert Gordon &objp->nfs_resop4_u.opsetclientid)); 47397c478bd9Sstevel@tonic-gate case OP_SETCLIENTID_CONFIRM: 47407c478bd9Sstevel@tonic-gate return (xdr_int(xdrs, 47410a701b1eSRobert Gordon (int32_t *)&objp->nfs_resop4_u.opsetclientid_confirm. 47420a701b1eSRobert Gordon status)); 47437c478bd9Sstevel@tonic-gate case OP_VERIFY: 47447c478bd9Sstevel@tonic-gate return (xdr_int(xdrs, 47450a701b1eSRobert Gordon (int32_t *)&objp->nfs_resop4_u.opverify.status)); 47467c478bd9Sstevel@tonic-gate case OP_RELEASE_LOCKOWNER: 47477c478bd9Sstevel@tonic-gate return (xdr_int(xdrs, 47487c478bd9Sstevel@tonic-gate (int32_t *)&objp->nfs_resop4_u.oprelease_lockowner.status)); 47497c478bd9Sstevel@tonic-gate case OP_ILLEGAL: 47507c478bd9Sstevel@tonic-gate return (xdr_int(xdrs, 47510a701b1eSRobert Gordon (int32_t *)&objp->nfs_resop4_u.opillegal.status)); 47527c478bd9Sstevel@tonic-gate } 47537c478bd9Sstevel@tonic-gate return (FALSE); 47547c478bd9Sstevel@tonic-gate } 47557c478bd9Sstevel@tonic-gate 47567c46fb7fSek static bool_t 47577c46fb7fSek xdr_snfs_resop4(XDR *xdrs, nfs_resop4 *objp) 47587c46fb7fSek { 47597c46fb7fSek if (!xdr_int(xdrs, (int *)&objp->resop)) 47607c46fb7fSek return (FALSE); 47617c46fb7fSek 47627c46fb7fSek switch (objp->resop) { 47637c46fb7fSek case OP_GETFH: 47647c46fb7fSek if (!XDR_PUTINT32(xdrs, 47657c46fb7fSek (int32_t *)&objp->nfs_resop4_u.opgetfh.status)) 47667c46fb7fSek return (FALSE); 47677c46fb7fSek if (objp->nfs_resop4_u.opgetfh.status != NFS4_OK) 47687c46fb7fSek return (TRUE); 47697c46fb7fSek return (xdr_encode_nfs_fh4(xdrs, 4770eac3aab7Srobinson &objp->nfs_resop4_u.opgetfh.object)); 47717c46fb7fSek default: 47727c46fb7fSek return (xdr_nfs_resop4(xdrs, objp)); 47737c46fb7fSek } 47747c46fb7fSek } 47757c46fb7fSek 47767c478bd9Sstevel@tonic-gate static bool_t 47777c478bd9Sstevel@tonic-gate xdr_nfs_resop4_clnt(XDR *xdrs, nfs_resop4 *objp, nfs_argop4 *aobjp) 47787c478bd9Sstevel@tonic-gate { 47797c478bd9Sstevel@tonic-gate if (!xdr_int(xdrs, (int *)&objp->resop)) 47807c478bd9Sstevel@tonic-gate return (FALSE); 47817c478bd9Sstevel@tonic-gate /* 47827c478bd9Sstevel@tonic-gate * These should be ordered by frequency of use 47837c478bd9Sstevel@tonic-gate */ 47847c478bd9Sstevel@tonic-gate switch (objp->resop) { 47857c478bd9Sstevel@tonic-gate case OP_PUTFH: 47867c478bd9Sstevel@tonic-gate return (xdr_int(xdrs, 47870a701b1eSRobert Gordon (int32_t *)&objp->nfs_resop4_u.opputfh.status)); 47887c478bd9Sstevel@tonic-gate case OP_GETATTR: 47897c478bd9Sstevel@tonic-gate if (!xdr_int(xdrs, 47900a701b1eSRobert Gordon (int32_t *)&objp->nfs_resop4_u.opgetattr.status)) 47917c478bd9Sstevel@tonic-gate return (FALSE); 47927c478bd9Sstevel@tonic-gate if (objp->nfs_resop4_u.opgetattr.status != NFS4_OK) 47937c478bd9Sstevel@tonic-gate return (TRUE); 47947c478bd9Sstevel@tonic-gate return (xdr_ga_res(xdrs, 47950a701b1eSRobert Gordon (GETATTR4res *)&objp->nfs_resop4_u.opgetattr, 47960a701b1eSRobert Gordon &aobjp->nfs_argop4_u.opgetattr)); 47977c478bd9Sstevel@tonic-gate case OP_GETFH: 47987c478bd9Sstevel@tonic-gate if (!xdr_int(xdrs, 47990a701b1eSRobert Gordon (int32_t *)&objp->nfs_resop4_u.opgetfh.status)) 48007c478bd9Sstevel@tonic-gate return (FALSE); 48017c478bd9Sstevel@tonic-gate if (objp->nfs_resop4_u.opgetfh.status != NFS4_OK) 48027c478bd9Sstevel@tonic-gate return (TRUE); 48037c478bd9Sstevel@tonic-gate return (xdr_bytes(xdrs, 48047c478bd9Sstevel@tonic-gate (char **)&objp->nfs_resop4_u.opgetfh.object.nfs_fh4_val, 48057c478bd9Sstevel@tonic-gate (uint_t *)&objp->nfs_resop4_u.opgetfh.object.nfs_fh4_len, 48067c478bd9Sstevel@tonic-gate NFS4_FHSIZE)); 48077c478bd9Sstevel@tonic-gate case OP_LOOKUP: 48087c478bd9Sstevel@tonic-gate return (xdr_int(xdrs, 48090a701b1eSRobert Gordon (int32_t *)&objp->nfs_resop4_u.oplookup.status)); 48107c478bd9Sstevel@tonic-gate case OP_NVERIFY: 48117c478bd9Sstevel@tonic-gate return (xdr_int(xdrs, 48120a701b1eSRobert Gordon (int32_t *)&objp->nfs_resop4_u.opnverify.status)); 48137c478bd9Sstevel@tonic-gate case OP_OPEN: 48147c478bd9Sstevel@tonic-gate return (xdr_OPEN4res(xdrs, &objp->nfs_resop4_u.opopen)); 48157c478bd9Sstevel@tonic-gate case OP_CLOSE: 48167c478bd9Sstevel@tonic-gate return (xdr_CLOSE4res(xdrs, &objp->nfs_resop4_u.opclose)); 48177c478bd9Sstevel@tonic-gate case OP_ACCESS: 48187c478bd9Sstevel@tonic-gate return (xdr_ACCESS4res(xdrs, &objp->nfs_resop4_u.opaccess)); 48197c478bd9Sstevel@tonic-gate case OP_READ: 48207c478bd9Sstevel@tonic-gate return (xdr_READ4res_clnt(xdrs, &objp->nfs_resop4_u.opread, 48210a701b1eSRobert Gordon &aobjp->nfs_argop4_u.opread)); 48227c478bd9Sstevel@tonic-gate case OP_WRITE: 48237c478bd9Sstevel@tonic-gate return (xdr_WRITE4res(xdrs, &objp->nfs_resop4_u.opwrite)); 48247c478bd9Sstevel@tonic-gate case OP_DELEGRETURN: 48257c478bd9Sstevel@tonic-gate return (xdr_int(xdrs, 48260a701b1eSRobert Gordon (int32_t *)&objp->nfs_resop4_u.opdelegreturn.status)); 48277c478bd9Sstevel@tonic-gate case OP_LOOKUPP: 48287c478bd9Sstevel@tonic-gate return (xdr_int(xdrs, 48290a701b1eSRobert Gordon (int32_t *)&objp->nfs_resop4_u.oplookupp.status)); 48307c478bd9Sstevel@tonic-gate case OP_READDIR: 48317c478bd9Sstevel@tonic-gate return (xdr_READDIR4res_clnt(xdrs, 48320a701b1eSRobert Gordon &objp->nfs_resop4_u.opreaddirclnt, 48330a701b1eSRobert Gordon &aobjp->nfs_argop4_u.opreaddir)); 48347c478bd9Sstevel@tonic-gate case OP_REMOVE: 48357c478bd9Sstevel@tonic-gate return (xdr_REMOVE4res(xdrs, &objp->nfs_resop4_u.opremove)); 48367c478bd9Sstevel@tonic-gate 48377c478bd9Sstevel@tonic-gate case OP_COMMIT: 48387c478bd9Sstevel@tonic-gate if (!xdr_int(xdrs, 48390a701b1eSRobert Gordon (int32_t *)&objp->nfs_resop4_u.opcommit.status)) 48407c478bd9Sstevel@tonic-gate return (FALSE); 48417c478bd9Sstevel@tonic-gate if (objp->nfs_resop4_u.opcommit.status != NFS4_OK) 48427c478bd9Sstevel@tonic-gate return (TRUE); 48437c478bd9Sstevel@tonic-gate return (xdr_u_longlong_t(xdrs, 48440a701b1eSRobert Gordon (u_longlong_t *)&objp->nfs_resop4_u.opcommit. 48450a701b1eSRobert Gordon writeverf)); 48467c478bd9Sstevel@tonic-gate case OP_CREATE: 48477c478bd9Sstevel@tonic-gate return (xdr_CREATE4res(xdrs, &objp->nfs_resop4_u.opcreate)); 48487c478bd9Sstevel@tonic-gate case OP_DELEGPURGE: 48497c478bd9Sstevel@tonic-gate return (xdr_int(xdrs, 48500a701b1eSRobert Gordon (int32_t *)&objp->nfs_resop4_u.opdelegpurge.status)); 48517c478bd9Sstevel@tonic-gate case OP_LINK: 48527c478bd9Sstevel@tonic-gate return (xdr_LINK4res(xdrs, &objp->nfs_resop4_u.oplink)); 48537c478bd9Sstevel@tonic-gate case OP_LOCK: 48547c478bd9Sstevel@tonic-gate return (xdr_LOCK4res(xdrs, &objp->nfs_resop4_u.oplock)); 48557c478bd9Sstevel@tonic-gate case OP_LOCKT: 48567c478bd9Sstevel@tonic-gate return (xdr_LOCKT4res(xdrs, &objp->nfs_resop4_u.oplockt)); 48577c478bd9Sstevel@tonic-gate case OP_LOCKU: 48587c478bd9Sstevel@tonic-gate if (!xdr_int(xdrs, 48590a701b1eSRobert Gordon (int32_t *)&objp->nfs_resop4_u.oplocku.status)) 48607c478bd9Sstevel@tonic-gate return (FALSE); 48617c478bd9Sstevel@tonic-gate if (objp->nfs_resop4_u.oplocku.status != NFS4_OK) 48627c478bd9Sstevel@tonic-gate return (TRUE); 48637c478bd9Sstevel@tonic-gate if (!xdr_u_int(xdrs, 48647c478bd9Sstevel@tonic-gate &objp->nfs_resop4_u.oplocku.lock_stateid.seqid)) 48657c478bd9Sstevel@tonic-gate return (FALSE); 48667c478bd9Sstevel@tonic-gate return (xdr_opaque(xdrs, 48677c478bd9Sstevel@tonic-gate objp->nfs_resop4_u.oplocku.lock_stateid.other, 48687c478bd9Sstevel@tonic-gate 12)); 48697c478bd9Sstevel@tonic-gate case OP_OPENATTR: 48707c478bd9Sstevel@tonic-gate return (xdr_int(xdrs, 48710a701b1eSRobert Gordon (int32_t *)&objp->nfs_resop4_u.opopenattr.status)); 48727c478bd9Sstevel@tonic-gate case OP_OPEN_CONFIRM: 48737c478bd9Sstevel@tonic-gate return (xdr_OPEN_CONFIRM4res(xdrs, 48740a701b1eSRobert Gordon &objp->nfs_resop4_u.opopen_confirm)); 48757c478bd9Sstevel@tonic-gate case OP_OPEN_DOWNGRADE: 48767c478bd9Sstevel@tonic-gate return (xdr_OPEN_DOWNGRADE4res(xdrs, 48770a701b1eSRobert Gordon &objp->nfs_resop4_u.opopen_downgrade)); 48787c478bd9Sstevel@tonic-gate case OP_PUTPUBFH: 48797c478bd9Sstevel@tonic-gate return (xdr_int(xdrs, 48800a701b1eSRobert Gordon (int32_t *)&objp->nfs_resop4_u.opputpubfh.status)); 48817c478bd9Sstevel@tonic-gate case OP_PUTROOTFH: 48827c478bd9Sstevel@tonic-gate return (xdr_int(xdrs, 48830a701b1eSRobert Gordon (int32_t *)&objp->nfs_resop4_u.opputrootfh.status)); 48847c478bd9Sstevel@tonic-gate case OP_READLINK: 48857c478bd9Sstevel@tonic-gate return (xdr_READLINK4res(xdrs, &objp->nfs_resop4_u.opreadlink)); 48867c478bd9Sstevel@tonic-gate case OP_RENAME: 48877c478bd9Sstevel@tonic-gate return (xdr_RENAME4res(xdrs, &objp->nfs_resop4_u.oprename)); 48887c478bd9Sstevel@tonic-gate case OP_RENEW: 48897c478bd9Sstevel@tonic-gate return (xdr_int(xdrs, 48900a701b1eSRobert Gordon (int32_t *)&objp->nfs_resop4_u.oprenew.status)); 48917c478bd9Sstevel@tonic-gate case OP_RESTOREFH: 48927c478bd9Sstevel@tonic-gate return (xdr_int(xdrs, 48930a701b1eSRobert Gordon (int32_t *)&objp->nfs_resop4_u.oprestorefh.status)); 48947c478bd9Sstevel@tonic-gate case OP_SAVEFH: 48957c478bd9Sstevel@tonic-gate return (xdr_int(xdrs, 48960a701b1eSRobert Gordon (int32_t *)&objp->nfs_resop4_u.opsavefh.status)); 48977c478bd9Sstevel@tonic-gate case OP_SECINFO: 48987c478bd9Sstevel@tonic-gate if (!xdr_int(xdrs, (int32_t *)&objp->nfs_resop4_u.opsecinfo. 48990a701b1eSRobert Gordon status)) 49007c478bd9Sstevel@tonic-gate return (FALSE); 49017c478bd9Sstevel@tonic-gate if (objp->nfs_resop4_u.opsecinfo.status != NFS4_OK) 49027c478bd9Sstevel@tonic-gate return (TRUE); 49037c478bd9Sstevel@tonic-gate return (xdr_array(xdrs, (char **)&objp->nfs_resop4_u.opsecinfo. 49040a701b1eSRobert Gordon SECINFO4resok_val, 49050a701b1eSRobert Gordon (uint_t *)&objp->nfs_resop4_u.opsecinfo. 49060a701b1eSRobert Gordon SECINFO4resok_len, 49070a701b1eSRobert Gordon ~0, sizeof (secinfo4), (xdrproc_t)xdr_secinfo4)); 49087c478bd9Sstevel@tonic-gate case OP_SETATTR: 49097c478bd9Sstevel@tonic-gate if (!xdr_int(xdrs, (int32_t *)&objp->nfs_resop4_u.opsetattr. 49100a701b1eSRobert Gordon status)) 49117c478bd9Sstevel@tonic-gate return (FALSE); 49127c478bd9Sstevel@tonic-gate return (xdr_bitmap4(xdrs, 49130a701b1eSRobert Gordon &objp->nfs_resop4_u.opsetattr.attrsset)); 49147c478bd9Sstevel@tonic-gate case OP_SETCLIENTID: 49157c478bd9Sstevel@tonic-gate return (xdr_SETCLIENTID4res(xdrs, 49160a701b1eSRobert Gordon &objp->nfs_resop4_u.opsetclientid)); 49177c478bd9Sstevel@tonic-gate case OP_SETCLIENTID_CONFIRM: 49187c478bd9Sstevel@tonic-gate return (xdr_int(xdrs, 49190a701b1eSRobert Gordon (int32_t *)&objp->nfs_resop4_u.opsetclientid_confirm. 49200a701b1eSRobert Gordon status)); 49217c478bd9Sstevel@tonic-gate case OP_VERIFY: 49227c478bd9Sstevel@tonic-gate return (xdr_int(xdrs, 49230a701b1eSRobert Gordon (int32_t *)&objp->nfs_resop4_u.opverify.status)); 49247c478bd9Sstevel@tonic-gate case OP_RELEASE_LOCKOWNER: 49257c478bd9Sstevel@tonic-gate return (xdr_int(xdrs, 49267c478bd9Sstevel@tonic-gate (int32_t *)&objp->nfs_resop4_u.oprelease_lockowner.status)); 49277c478bd9Sstevel@tonic-gate case OP_ILLEGAL: 49287c478bd9Sstevel@tonic-gate return (xdr_int(xdrs, 49290a701b1eSRobert Gordon (int32_t *)&objp->nfs_resop4_u.opillegal.status)); 49307c478bd9Sstevel@tonic-gate } 49317c478bd9Sstevel@tonic-gate return (FALSE); 49327c478bd9Sstevel@tonic-gate } 49337c478bd9Sstevel@tonic-gate 49347c478bd9Sstevel@tonic-gate bool_t 49357c478bd9Sstevel@tonic-gate xdr_COMPOUND4args_clnt(XDR *xdrs, COMPOUND4args_clnt *objp) 49367c478bd9Sstevel@tonic-gate { 49377c478bd9Sstevel@tonic-gate static int32_t twelve = 12; 49387c478bd9Sstevel@tonic-gate static int32_t minorversion = NFS4_MINORVERSION; 49397c478bd9Sstevel@tonic-gate uint32_t *ctagp; 49407c478bd9Sstevel@tonic-gate rpc_inline_t *ptr; 49410a701b1eSRobert Gordon rdma_chunkinfo_t rci; 49420a701b1eSRobert Gordon struct xdr_ops *xops = xdrrdma_xops(); 49437c478bd9Sstevel@tonic-gate 49447c478bd9Sstevel@tonic-gate /* 49457c478bd9Sstevel@tonic-gate * XDR_ENCODE only 49467c478bd9Sstevel@tonic-gate */ 49477c478bd9Sstevel@tonic-gate if (xdrs->x_op == XDR_FREE) 49487c478bd9Sstevel@tonic-gate return (TRUE); 49497c478bd9Sstevel@tonic-gate if (xdrs->x_op == XDR_DECODE) 49507c478bd9Sstevel@tonic-gate return (FALSE); 49517c478bd9Sstevel@tonic-gate 49527c478bd9Sstevel@tonic-gate ctagp = (uint32_t *)&nfs4_ctags[objp->ctag].ct_tag; 49537c478bd9Sstevel@tonic-gate 49547c478bd9Sstevel@tonic-gate if ((ptr = XDR_INLINE(xdrs, 5 * BYTES_PER_XDR_UNIT)) != NULL) { 49557c478bd9Sstevel@tonic-gate /* 49567c478bd9Sstevel@tonic-gate * Efficiently encode fixed length tags, could be longlongs 49577c478bd9Sstevel@tonic-gate * but 8 byte XDR alignment not assured 49587c478bd9Sstevel@tonic-gate */ 49597c478bd9Sstevel@tonic-gate IXDR_PUT_U_INT32(ptr, 12); 49607c478bd9Sstevel@tonic-gate IXDR_PUT_U_INT32(ptr, ctagp[0]); 49617c478bd9Sstevel@tonic-gate IXDR_PUT_U_INT32(ptr, ctagp[1]); 49627c478bd9Sstevel@tonic-gate IXDR_PUT_U_INT32(ptr, ctagp[2]); 49637c478bd9Sstevel@tonic-gate 49647c478bd9Sstevel@tonic-gate /* 49657c478bd9Sstevel@tonic-gate * Fixed minor version for now 49667c478bd9Sstevel@tonic-gate */ 49677c478bd9Sstevel@tonic-gate IXDR_PUT_U_INT32(ptr, NFS4_MINORVERSION); 49687c478bd9Sstevel@tonic-gate } else { 49697c478bd9Sstevel@tonic-gate if (!XDR_PUTINT32(xdrs, &twelve)) 49707c478bd9Sstevel@tonic-gate return (FALSE); 49717c478bd9Sstevel@tonic-gate if (!XDR_PUTINT32(xdrs, (int32_t *)&ctagp[0])) 49727c478bd9Sstevel@tonic-gate return (FALSE); 49737c478bd9Sstevel@tonic-gate if (!XDR_PUTINT32(xdrs, (int32_t *)&ctagp[1])) 49747c478bd9Sstevel@tonic-gate return (FALSE); 49757c478bd9Sstevel@tonic-gate if (!XDR_PUTINT32(xdrs, (int32_t *)&ctagp[2])) 49767c478bd9Sstevel@tonic-gate return (FALSE); 49777c478bd9Sstevel@tonic-gate if (!XDR_PUTINT32(xdrs, (int32_t *)&minorversion)) 49787c478bd9Sstevel@tonic-gate return (FALSE); 49797c478bd9Sstevel@tonic-gate } 49800a701b1eSRobert Gordon if (xdrs->x_ops == &xdrrdma_ops || xdrs->x_ops == xops) { 49810a701b1eSRobert Gordon rci.rci_type = RCI_REPLY_CHUNK; 49820a701b1eSRobert Gordon rci.rci_len = MAXPATHLEN * 2; 49830a701b1eSRobert Gordon XDR_CONTROL(xdrs, XDR_RDMA_ADD_CHUNK, &rci); 49840a701b1eSRobert Gordon } 49857c478bd9Sstevel@tonic-gate 49867c478bd9Sstevel@tonic-gate return (xdr_array(xdrs, (char **)&objp->array, 49870a701b1eSRobert Gordon (uint_t *)&objp->array_len, NFS4_COMPOUND_LIMIT, 49880a701b1eSRobert Gordon sizeof (nfs_argop4), (xdrproc_t)xdr_cnfs_argop4)); 49897c478bd9Sstevel@tonic-gate } 49907c478bd9Sstevel@tonic-gate 49917c478bd9Sstevel@tonic-gate bool_t 49927c46fb7fSek xdr_COMPOUND4args_srv(XDR *xdrs, COMPOUND4args *objp) 49937c478bd9Sstevel@tonic-gate { 49947c478bd9Sstevel@tonic-gate if (!xdr_bytes(xdrs, (char **)&objp->tag.utf8string_val, 49950a701b1eSRobert Gordon (uint_t *)&objp->tag.utf8string_len, 49960a701b1eSRobert Gordon NFS4_MAX_UTF8STRING)) 49977c478bd9Sstevel@tonic-gate return (FALSE); 49987c478bd9Sstevel@tonic-gate if (!xdr_u_int(xdrs, &objp->minorversion)) 49997c478bd9Sstevel@tonic-gate return (FALSE); 50007c478bd9Sstevel@tonic-gate if (xdrs->x_op != XDR_FREE) 50017c478bd9Sstevel@tonic-gate return (xdr_array(xdrs, (char **)&objp->array, 50020a701b1eSRobert Gordon (uint_t *)&objp->array_len, NFS4_COMPOUND_LIMIT, 50030a701b1eSRobert Gordon sizeof (nfs_argop4), (xdrproc_t)xdr_snfs_argop4)); 50047c478bd9Sstevel@tonic-gate 50057c46fb7fSek return (xdr_snfs_argop4_free(xdrs, &objp->array, objp->array_len)); 50067c478bd9Sstevel@tonic-gate } 50077c478bd9Sstevel@tonic-gate 50087c478bd9Sstevel@tonic-gate bool_t 50097c478bd9Sstevel@tonic-gate xdr_COMPOUND4res_clnt(XDR *xdrs, COMPOUND4res_clnt *objp) 50107c478bd9Sstevel@tonic-gate { 50117c478bd9Sstevel@tonic-gate uint32_t len; 50127c478bd9Sstevel@tonic-gate int32_t *ptr; 50137c478bd9Sstevel@tonic-gate nfs_argop4 *argop; 50147c478bd9Sstevel@tonic-gate nfs_resop4 *resop; 50157c478bd9Sstevel@tonic-gate 50167c478bd9Sstevel@tonic-gate /* 50177c478bd9Sstevel@tonic-gate * No XDR_ENCODE 50187c478bd9Sstevel@tonic-gate */ 50197c478bd9Sstevel@tonic-gate if (xdrs->x_op == XDR_ENCODE) 50207c478bd9Sstevel@tonic-gate return (FALSE); 50217c478bd9Sstevel@tonic-gate 50227c478bd9Sstevel@tonic-gate if (xdrs->x_op != XDR_FREE) { 50237c478bd9Sstevel@tonic-gate if ((ptr = XDR_INLINE(xdrs, 2 * BYTES_PER_XDR_UNIT)) != NULL) { 50247c478bd9Sstevel@tonic-gate objp->status = IXDR_GET_U_INT32(ptr); 50257c478bd9Sstevel@tonic-gate len = IXDR_GET_U_INT32(ptr); 50267c478bd9Sstevel@tonic-gate } else { 50277c478bd9Sstevel@tonic-gate if (!xdr_int(xdrs, (int32_t *)&objp->status)) 50287c478bd9Sstevel@tonic-gate return (FALSE); 50297c478bd9Sstevel@tonic-gate if (!xdr_u_int(xdrs, (uint32_t *)&len)) 50307c478bd9Sstevel@tonic-gate return (FALSE); 50317c478bd9Sstevel@tonic-gate } 50327c478bd9Sstevel@tonic-gate if (len > NFS4_MAX_UTF8STRING) 50337c478bd9Sstevel@tonic-gate return (FALSE); 50347c478bd9Sstevel@tonic-gate /* 50357c478bd9Sstevel@tonic-gate * Ignore the tag 50367c478bd9Sstevel@tonic-gate */ 50377c478bd9Sstevel@tonic-gate if (!XDR_CONTROL(xdrs, XDR_SKIPBYTES, &len)) 50387c478bd9Sstevel@tonic-gate return (FALSE); 50397c478bd9Sstevel@tonic-gate 50407c478bd9Sstevel@tonic-gate if (!xdr_int(xdrs, (int32_t *)&objp->array_len)) 50417c478bd9Sstevel@tonic-gate return (FALSE); 50427c478bd9Sstevel@tonic-gate 50437c478bd9Sstevel@tonic-gate if (objp->array_len > objp->argsp->array_len) 50447c478bd9Sstevel@tonic-gate return (FALSE); 50457c478bd9Sstevel@tonic-gate 5046*2c2d21e9SRichard Lowe if (objp->status == NFS4_OK && 50477c478bd9Sstevel@tonic-gate objp->array_len != objp->argsp->array_len) 50487c478bd9Sstevel@tonic-gate return (FALSE); 50497c478bd9Sstevel@tonic-gate 50507c478bd9Sstevel@tonic-gate /* Alloc the results array */ 50517c478bd9Sstevel@tonic-gate argop = objp->argsp->array; 50527c478bd9Sstevel@tonic-gate len = objp->array_len * sizeof (nfs_resop4); 50537c478bd9Sstevel@tonic-gate objp->decode_len = 0; 50547c478bd9Sstevel@tonic-gate objp->array = resop = kmem_zalloc(len, KM_SLEEP); 50557c478bd9Sstevel@tonic-gate 50567c478bd9Sstevel@tonic-gate for (len = 0; len < objp->array_len; 50570a701b1eSRobert Gordon len++, resop++, argop++, objp->decode_len++) { 50587c478bd9Sstevel@tonic-gate if (!xdr_nfs_resop4_clnt(xdrs, resop, argop)) { 50597c478bd9Sstevel@tonic-gate /* 50607c478bd9Sstevel@tonic-gate * Make sure to free anything that may 50617c478bd9Sstevel@tonic-gate * have been allocated along the way. 50627c478bd9Sstevel@tonic-gate */ 50637c478bd9Sstevel@tonic-gate xdrs->x_op = XDR_FREE; 50647c478bd9Sstevel@tonic-gate (void) xdr_nfs_resop4_free(xdrs, &objp->array, 50650a701b1eSRobert Gordon objp->array_len, 50660a701b1eSRobert Gordon objp->decode_len); 50677c478bd9Sstevel@tonic-gate return (FALSE); 50687c478bd9Sstevel@tonic-gate } 50697c478bd9Sstevel@tonic-gate } 50707c478bd9Sstevel@tonic-gate return (TRUE); 50717c478bd9Sstevel@tonic-gate } 50727c478bd9Sstevel@tonic-gate return (xdr_nfs_resop4_free(xdrs, &objp->array, 50730a701b1eSRobert Gordon objp->array_len, objp->decode_len)); 50747c478bd9Sstevel@tonic-gate } 50757c478bd9Sstevel@tonic-gate 50767c478bd9Sstevel@tonic-gate bool_t 50777c46fb7fSek xdr_COMPOUND4res_srv(XDR *xdrs, COMPOUND4res *objp) 50787c478bd9Sstevel@tonic-gate { 50797c478bd9Sstevel@tonic-gate if (!xdr_int(xdrs, (int32_t *)&objp->status)) 50807c478bd9Sstevel@tonic-gate return (FALSE); 50817c478bd9Sstevel@tonic-gate if (!xdr_bytes(xdrs, (char **)&objp->tag.utf8string_val, 50820a701b1eSRobert Gordon (uint_t *)&objp->tag.utf8string_len, 50830a701b1eSRobert Gordon NFS4_MAX_UTF8STRING)) 50847c478bd9Sstevel@tonic-gate return (FALSE); 50857c478bd9Sstevel@tonic-gate 50867c478bd9Sstevel@tonic-gate if (xdrs->x_op != XDR_FREE) 50877c478bd9Sstevel@tonic-gate return (xdr_array(xdrs, (char **)&objp->array, 50880a701b1eSRobert Gordon (uint_t *)&objp->array_len, NFS4_COMPOUND_LIMIT, 50890a701b1eSRobert Gordon sizeof (nfs_resop4), (xdrproc_t)xdr_snfs_resop4)); 50907c478bd9Sstevel@tonic-gate 50917c46fb7fSek return (xdr_snfs_resop4_free(xdrs, &objp->array, 50920a701b1eSRobert Gordon objp->array_len, objp->array_len)); 50937c478bd9Sstevel@tonic-gate } 50947c478bd9Sstevel@tonic-gate 5095eac3aab7Srobinson /* 5096eac3aab7Srobinson * NFS server side callback, initiating the callback request so it 5097eac3aab7Srobinson * is the RPC client. Must convert from server's internal filehandle 5098eac3aab7Srobinson * format to wire format. 5099eac3aab7Srobinson */ 51007c478bd9Sstevel@tonic-gate static bool_t 5101eac3aab7Srobinson xdr_snfs_cb_argop4(XDR *xdrs, nfs_cb_argop4 *objp) 51027c478bd9Sstevel@tonic-gate { 5103eac3aab7Srobinson CB_GETATTR4args *gargs; 5104eac3aab7Srobinson CB_RECALL4args *rargs; 5105eac3aab7Srobinson 5106eac3aab7Srobinson ASSERT(xdrs->x_op == XDR_ENCODE); 5107eac3aab7Srobinson 5108eac3aab7Srobinson if (!XDR_PUTINT32(xdrs, (int32_t *)&objp->argop)) 5109eac3aab7Srobinson return (FALSE); 5110eac3aab7Srobinson 5111eac3aab7Srobinson switch (objp->argop) { 5112eac3aab7Srobinson case OP_CB_GETATTR: 5113eac3aab7Srobinson gargs = &objp->nfs_cb_argop4_u.opcbgetattr; 5114eac3aab7Srobinson 5115eac3aab7Srobinson if (!xdr_encode_nfs_fh4(xdrs, &gargs->fh)) 5116eac3aab7Srobinson return (FALSE); 5117eac3aab7Srobinson return (xdr_bitmap4(xdrs, &gargs->attr_request)); 5118eac3aab7Srobinson case OP_CB_RECALL: 5119eac3aab7Srobinson rargs = &objp->nfs_cb_argop4_u.opcbrecall; 5120eac3aab7Srobinson 5121eac3aab7Srobinson if (!XDR_PUTINT32(xdrs, (int32_t *)&rargs->stateid.seqid)) 5122eac3aab7Srobinson return (FALSE); 5123eac3aab7Srobinson if (!xdr_opaque(xdrs, rargs->stateid.other, 12)) 5124eac3aab7Srobinson return (FALSE); 5125eac3aab7Srobinson if (!XDR_PUTINT32(xdrs, (int32_t *)&rargs->truncate)) 5126eac3aab7Srobinson return (FALSE); 5127eac3aab7Srobinson return (xdr_encode_nfs_fh4(xdrs, &rargs->fh)); 5128eac3aab7Srobinson case OP_CB_ILLEGAL: 5129eac3aab7Srobinson return (TRUE); 5130eac3aab7Srobinson } 5131eac3aab7Srobinson return (FALSE); 5132eac3aab7Srobinson } 5133eac3aab7Srobinson 5134eac3aab7Srobinson /* 5135eac3aab7Srobinson * NFS client side callback, receiving the callback request so it 5136eac3aab7Srobinson * is the RPC server. Must treat the file handles as opaque. 5137eac3aab7Srobinson */ 5138eac3aab7Srobinson static bool_t 5139eac3aab7Srobinson xdr_cnfs_cb_argop4(XDR *xdrs, nfs_cb_argop4 *objp) 5140eac3aab7Srobinson { 5141eac3aab7Srobinson CB_GETATTR4args *gargs; 5142eac3aab7Srobinson CB_RECALL4args *rargs; 5143eac3aab7Srobinson 5144eac3aab7Srobinson ASSERT(xdrs->x_op != XDR_ENCODE); 5145eac3aab7Srobinson 51467c478bd9Sstevel@tonic-gate if (!xdr_u_int(xdrs, &objp->argop)) 51477c478bd9Sstevel@tonic-gate return (FALSE); 51487c478bd9Sstevel@tonic-gate switch (objp->argop) { 51497c478bd9Sstevel@tonic-gate case OP_CB_GETATTR: 5150eac3aab7Srobinson gargs = &objp->nfs_cb_argop4_u.opcbgetattr; 5151eac3aab7Srobinson 5152eac3aab7Srobinson if (!xdr_bytes(xdrs, (char **)&gargs->fh.nfs_fh4_val, 5153eac3aab7Srobinson (uint_t *)&gargs->fh.nfs_fh4_len, NFS4_FHSIZE)) 51547c478bd9Sstevel@tonic-gate return (FALSE); 5155eac3aab7Srobinson return (xdr_bitmap4(xdrs, &gargs->attr_request)); 51567c478bd9Sstevel@tonic-gate case OP_CB_RECALL: 5157eac3aab7Srobinson rargs = &objp->nfs_cb_argop4_u.opcbrecall; 5158eac3aab7Srobinson 5159eac3aab7Srobinson if (!xdr_u_int(xdrs, &rargs->stateid.seqid)) 51607c478bd9Sstevel@tonic-gate return (FALSE); 5161eac3aab7Srobinson if (!xdr_opaque(xdrs, rargs->stateid.other, 12)) 51627c478bd9Sstevel@tonic-gate return (FALSE); 5163eac3aab7Srobinson if (!xdr_bool(xdrs, &rargs->truncate)) 51647c478bd9Sstevel@tonic-gate return (FALSE); 5165eac3aab7Srobinson return (xdr_bytes(xdrs, (char **)&rargs->fh.nfs_fh4_val, 5166eac3aab7Srobinson (uint_t *)&rargs->fh.nfs_fh4_len, NFS4_FHSIZE)); 51677c478bd9Sstevel@tonic-gate case OP_CB_ILLEGAL: 51687c478bd9Sstevel@tonic-gate return (TRUE); 51697c478bd9Sstevel@tonic-gate } 51707c478bd9Sstevel@tonic-gate return (FALSE); 51717c478bd9Sstevel@tonic-gate } 51727c478bd9Sstevel@tonic-gate 51737c478bd9Sstevel@tonic-gate static bool_t 51747c478bd9Sstevel@tonic-gate xdr_nfs_cb_resop4(XDR *xdrs, nfs_cb_resop4 *objp) 51757c478bd9Sstevel@tonic-gate { 51767c478bd9Sstevel@tonic-gate if (!xdr_u_int(xdrs, &objp->resop)) 51777c478bd9Sstevel@tonic-gate return (FALSE); 51787c478bd9Sstevel@tonic-gate switch (objp->resop) { 51797c478bd9Sstevel@tonic-gate case OP_CB_GETATTR: 51807c478bd9Sstevel@tonic-gate if (!xdr_int(xdrs, 51810a701b1eSRobert Gordon (int32_t *)&objp->nfs_cb_resop4_u.opcbgetattr. 51820a701b1eSRobert Gordon status)) 51837c478bd9Sstevel@tonic-gate return (FALSE); 51847c478bd9Sstevel@tonic-gate if (objp->nfs_cb_resop4_u.opcbgetattr.status != NFS4_OK) 51857c478bd9Sstevel@tonic-gate return (TRUE); 51867c478bd9Sstevel@tonic-gate return (xdr_fattr4(xdrs, 51870a701b1eSRobert Gordon &objp->nfs_cb_resop4_u.opcbgetattr. 51880a701b1eSRobert Gordon obj_attributes)); 51897c478bd9Sstevel@tonic-gate case OP_CB_RECALL: 51907c478bd9Sstevel@tonic-gate return (xdr_int(xdrs, 51910a701b1eSRobert Gordon (int32_t *)&objp->nfs_cb_resop4_u.opcbrecall.status)); 51927c478bd9Sstevel@tonic-gate case OP_CB_ILLEGAL: 51937c478bd9Sstevel@tonic-gate return (xdr_int(xdrs, 51940a701b1eSRobert Gordon (int32_t *)&objp->nfs_cb_resop4_u.opcbillegal.status)); 51957c478bd9Sstevel@tonic-gate } 51967c478bd9Sstevel@tonic-gate return (FALSE); 51977c478bd9Sstevel@tonic-gate } 51987c478bd9Sstevel@tonic-gate 5199eac3aab7Srobinson /* 5200eac3aab7Srobinson * The NFS client side callback, RPC server 5201eac3aab7Srobinson */ 5202eac3aab7Srobinson bool_t 5203eac3aab7Srobinson xdr_CB_COMPOUND4args_clnt(XDR *xdrs, CB_COMPOUND4args *objp) 5204eac3aab7Srobinson { 5205eac3aab7Srobinson if (!xdr_bytes(xdrs, (char **)&objp->tag.utf8string_val, 52060a701b1eSRobert Gordon (uint_t *)&objp->tag.utf8string_len, 52070a701b1eSRobert Gordon NFS4_MAX_UTF8STRING)) 5208eac3aab7Srobinson return (FALSE); 5209eac3aab7Srobinson if (!xdr_u_int(xdrs, &objp->minorversion)) 5210eac3aab7Srobinson return (FALSE); 5211eac3aab7Srobinson if (!xdr_u_int(xdrs, &objp->callback_ident)) 5212eac3aab7Srobinson return (FALSE); 5213eac3aab7Srobinson return (xdr_array(xdrs, (char **)&objp->array, 52140a701b1eSRobert Gordon (uint_t *)&objp->array_len, NFS4_COMPOUND_LIMIT, 52150a701b1eSRobert Gordon sizeof (nfs_cb_argop4), (xdrproc_t)xdr_cnfs_cb_argop4)); 5216eac3aab7Srobinson } 5217eac3aab7Srobinson 5218eac3aab7Srobinson /* 5219eac3aab7Srobinson * The NFS server side callback, RPC client 5220eac3aab7Srobinson */ 52217c478bd9Sstevel@tonic-gate bool_t 5222eac3aab7Srobinson xdr_CB_COMPOUND4args_srv(XDR *xdrs, CB_COMPOUND4args *objp) 52237c478bd9Sstevel@tonic-gate { 52247c478bd9Sstevel@tonic-gate if (!xdr_bytes(xdrs, (char **)&objp->tag.utf8string_val, 52250a701b1eSRobert Gordon (uint_t *)&objp->tag.utf8string_len, 52260a701b1eSRobert Gordon NFS4_MAX_UTF8STRING)) 52277c478bd9Sstevel@tonic-gate return (FALSE); 52287c478bd9Sstevel@tonic-gate if (!xdr_u_int(xdrs, &objp->minorversion)) 52297c478bd9Sstevel@tonic-gate return (FALSE); 52307c478bd9Sstevel@tonic-gate if (!xdr_u_int(xdrs, &objp->callback_ident)) 52317c478bd9Sstevel@tonic-gate return (FALSE); 52327c478bd9Sstevel@tonic-gate return (xdr_array(xdrs, (char **)&objp->array, 52330a701b1eSRobert Gordon (uint_t *)&objp->array_len, NFS4_COMPOUND_LIMIT, 52340a701b1eSRobert Gordon sizeof (nfs_cb_argop4), (xdrproc_t)xdr_snfs_cb_argop4)); 52357c478bd9Sstevel@tonic-gate } 52367c478bd9Sstevel@tonic-gate 52377c478bd9Sstevel@tonic-gate bool_t 52387c478bd9Sstevel@tonic-gate xdr_CB_COMPOUND4res(XDR *xdrs, CB_COMPOUND4res *objp) 52397c478bd9Sstevel@tonic-gate { 52407c478bd9Sstevel@tonic-gate if (!xdr_int(xdrs, (int32_t *)&objp->status)) 52417c478bd9Sstevel@tonic-gate return (FALSE); 52427c478bd9Sstevel@tonic-gate if (!xdr_bytes(xdrs, (char **)&objp->tag.utf8string_val, 52430a701b1eSRobert Gordon (uint_t *)&objp->tag.utf8string_len, 52440a701b1eSRobert Gordon NFS4_MAX_UTF8STRING)) 52457c478bd9Sstevel@tonic-gate return (FALSE); 52467c478bd9Sstevel@tonic-gate return (xdr_array(xdrs, (char **)&objp->array, 52470a701b1eSRobert Gordon (uint_t *)&objp->array_len, NFS4_COMPOUND_LIMIT, 52480a701b1eSRobert Gordon sizeof (nfs_cb_resop4), (xdrproc_t)xdr_nfs_cb_resop4)); 52497c478bd9Sstevel@tonic-gate } 5250