xref: /illumos-gate/usr/src/uts/common/fs/nfs/nfs4_attr.c (revision f44e1126)
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
52f172c55SRobert Thurlow  * Common Development and Distribution License (the "License").
62f172c55SRobert Thurlow  * 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 /*
222f172c55SRobert Thurlow  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
232f172c55SRobert Thurlow  * Use is subject to license terms.
247c478bd9Sstevel@tonic-gate  */
257c478bd9Sstevel@tonic-gate 
267c478bd9Sstevel@tonic-gate #include <sys/time.h>
277c478bd9Sstevel@tonic-gate #include <sys/systm.h>
287c478bd9Sstevel@tonic-gate 
297c478bd9Sstevel@tonic-gate #include <nfs/nfs.h>
307c478bd9Sstevel@tonic-gate #include <nfs/nfs4.h>
317c478bd9Sstevel@tonic-gate #include <nfs/rnode4.h>
327c478bd9Sstevel@tonic-gate #include <nfs/nfs4_clnt.h>
337c478bd9Sstevel@tonic-gate #include <sys/cmn_err.h>
347c478bd9Sstevel@tonic-gate 
357c478bd9Sstevel@tonic-gate static int
timestruc_to_settime4(timestruc_t * tt,settime4 * tt4,int flags)367c478bd9Sstevel@tonic-gate timestruc_to_settime4(timestruc_t *tt, settime4 *tt4, int flags)
377c478bd9Sstevel@tonic-gate {
387c478bd9Sstevel@tonic-gate 	int	error = 0;
397c478bd9Sstevel@tonic-gate 
407c478bd9Sstevel@tonic-gate 	if (flags & ATTR_UTIME) {
417c478bd9Sstevel@tonic-gate 		tt4->set_it = SET_TO_CLIENT_TIME4;
427c478bd9Sstevel@tonic-gate 		error = nfs4_time_vton(tt, &tt4->time);
437c478bd9Sstevel@tonic-gate 	} else {
447c478bd9Sstevel@tonic-gate 		tt4->set_it = SET_TO_SERVER_TIME4;
457c478bd9Sstevel@tonic-gate 	}
467c478bd9Sstevel@tonic-gate 	return (error);
477c478bd9Sstevel@tonic-gate }
487c478bd9Sstevel@tonic-gate 
497c478bd9Sstevel@tonic-gate 
507c478bd9Sstevel@tonic-gate /*
517c478bd9Sstevel@tonic-gate  * nfs4_ver_fattr4_attr translates a vattr attribute into a fattr4 attribute
527c478bd9Sstevel@tonic-gate  * for use by nfsv4 verify.  For setting atime or mtime use the entry for
537c478bd9Sstevel@tonic-gate  * time_XX (XX == access or modify).
547c478bd9Sstevel@tonic-gate  * Return TRUE if arg was set (even if there was an error) and FALSE
557c478bd9Sstevel@tonic-gate  * otherwise. Also set error code. The caller should not continue
567c478bd9Sstevel@tonic-gate  * if error was set, whether or not the return is TRUE or FALSE. Returning
577c478bd9Sstevel@tonic-gate  * FALSE does not mean there was an error, only that the attr was not set.
587c478bd9Sstevel@tonic-gate  *
597c478bd9Sstevel@tonic-gate  * Note: For now we only have the options used by setattr. In the future
607c478bd9Sstevel@tonic-gate  * the switch statement below should cover all vattr attrs and possibly
617c478bd9Sstevel@tonic-gate  * sys attrs as well.
627c478bd9Sstevel@tonic-gate  */
637c478bd9Sstevel@tonic-gate /* ARGSUSED */
647c478bd9Sstevel@tonic-gate static bool_t
nfs4_ver_fattr4_attr(vattr_t * vap,struct nfs4_ntov_map * ntovp,union nfs4_attr_u * nap,int flags,int * errorp)657c478bd9Sstevel@tonic-gate nfs4_ver_fattr4_attr(vattr_t *vap, struct nfs4_ntov_map *ntovp,
66*f44e1126SVitaliy Gusev     union nfs4_attr_u *nap, int flags, int *errorp)
677c478bd9Sstevel@tonic-gate {
687c478bd9Sstevel@tonic-gate 	bool_t	retval = TRUE;
697c478bd9Sstevel@tonic-gate 
707c478bd9Sstevel@tonic-gate 	/*
717c478bd9Sstevel@tonic-gate 	 * Special case for time set: if setting the
727c478bd9Sstevel@tonic-gate 	 * time, ignore entry for time access/modify set (setattr)
737c478bd9Sstevel@tonic-gate 	 * and instead use that of time access/modify.
747c478bd9Sstevel@tonic-gate 	 */
757c478bd9Sstevel@tonic-gate 	*errorp = 0;
767c478bd9Sstevel@tonic-gate 	/*
777c478bd9Sstevel@tonic-gate 	 * Bit matches the mask
787c478bd9Sstevel@tonic-gate 	 */
797c478bd9Sstevel@tonic-gate 	switch (ntovp->vbit & vap->va_mask) {
807c478bd9Sstevel@tonic-gate 	case AT_SIZE:
817c478bd9Sstevel@tonic-gate 		nap->size = vap->va_size;
827c478bd9Sstevel@tonic-gate 		break;
837c478bd9Sstevel@tonic-gate 	case AT_MODE:
847c478bd9Sstevel@tonic-gate 		nap->mode = vap->va_mode;
857c478bd9Sstevel@tonic-gate 		break;
867c478bd9Sstevel@tonic-gate 	case AT_UID:
877c478bd9Sstevel@tonic-gate 		/*
887c478bd9Sstevel@tonic-gate 		 * if no mapping, uid could be mapped to a numeric string,
897c478bd9Sstevel@tonic-gate 		 * e.g. 12345->"12345"
907c478bd9Sstevel@tonic-gate 		 */
917c478bd9Sstevel@tonic-gate 		if (*errorp = nfs_idmap_uid_str(vap->va_uid, &nap->owner,
927c478bd9Sstevel@tonic-gate 		    FALSE))
937c478bd9Sstevel@tonic-gate 			retval = FALSE;
947c478bd9Sstevel@tonic-gate 		break;
957c478bd9Sstevel@tonic-gate 	case AT_GID:
967c478bd9Sstevel@tonic-gate 		/*
977c478bd9Sstevel@tonic-gate 		 * if no mapping, gid will be mapped to a number string,
987c478bd9Sstevel@tonic-gate 		 * e.g. "12345"
997c478bd9Sstevel@tonic-gate 		 */
1007c478bd9Sstevel@tonic-gate 		if (*errorp = nfs_idmap_gid_str(vap->va_gid, &nap->owner_group,
1017c478bd9Sstevel@tonic-gate 		    FALSE))
1027c478bd9Sstevel@tonic-gate 			retval = FALSE;
1037c478bd9Sstevel@tonic-gate 		break;
1047c478bd9Sstevel@tonic-gate 	case AT_ATIME:
1057c478bd9Sstevel@tonic-gate 		if ((ntovp->nval != FATTR4_TIME_ACCESS) ||
1067c478bd9Sstevel@tonic-gate 		    (*errorp = nfs4_time_vton(&vap->va_ctime,
1072f172c55SRobert Thurlow 		    &nap->time_access))) {
1087c478bd9Sstevel@tonic-gate 			/*
1097c478bd9Sstevel@tonic-gate 			 * either asked for FATTR4_TIME_ACCESS_SET -
1107c478bd9Sstevel@tonic-gate 			 *	not used for setattr
1117c478bd9Sstevel@tonic-gate 			 * or system time invalid for otw transfers
1127c478bd9Sstevel@tonic-gate 			 */
1137c478bd9Sstevel@tonic-gate 			retval = FALSE;
1147c478bd9Sstevel@tonic-gate 		}
1157c478bd9Sstevel@tonic-gate 		break;
1167c478bd9Sstevel@tonic-gate 	case AT_MTIME:
1177c478bd9Sstevel@tonic-gate 		if ((ntovp->nval != FATTR4_TIME_MODIFY) ||
1187c478bd9Sstevel@tonic-gate 		    (*errorp = nfs4_time_vton(&vap->va_mtime,
1192f172c55SRobert Thurlow 		    &nap->time_modify))) {
1207c478bd9Sstevel@tonic-gate 			/*
1217c478bd9Sstevel@tonic-gate 			 * either asked for FATTR4_TIME_MODIFY_SET -
1227c478bd9Sstevel@tonic-gate 			 *	not used for setattr
1237c478bd9Sstevel@tonic-gate 			 * or system time invalid for otw transfers
1247c478bd9Sstevel@tonic-gate 			 */
1257c478bd9Sstevel@tonic-gate 			retval = FALSE;
1267c478bd9Sstevel@tonic-gate 		}
1277c478bd9Sstevel@tonic-gate 		break;
1287c478bd9Sstevel@tonic-gate 	case AT_CTIME:
1297c478bd9Sstevel@tonic-gate 		if (*errorp = nfs4_time_vton(&vap->va_ctime,
1302f172c55SRobert Thurlow 		    &nap->time_metadata)) {
1317c478bd9Sstevel@tonic-gate 			/*
1327c478bd9Sstevel@tonic-gate 			 * system time invalid for otw transfers
1337c478bd9Sstevel@tonic-gate 			 */
1347c478bd9Sstevel@tonic-gate 			retval = FALSE;
1357c478bd9Sstevel@tonic-gate 		}
1367c478bd9Sstevel@tonic-gate 		break;
1377c478bd9Sstevel@tonic-gate 	default:
1387c478bd9Sstevel@tonic-gate 		retval = FALSE;
1397c478bd9Sstevel@tonic-gate 	}
1407c478bd9Sstevel@tonic-gate 	return (retval);
1417c478bd9Sstevel@tonic-gate }
1427c478bd9Sstevel@tonic-gate 
1437c478bd9Sstevel@tonic-gate /*
1447c478bd9Sstevel@tonic-gate  * nfs4_set_fattr4_attr translates a vattr attribute into a fattr4 attribute
1457c478bd9Sstevel@tonic-gate  * for use by nfs4_setattr.  For setting atime or mtime use the entry for
1467c478bd9Sstevel@tonic-gate  * time_XX_set rather than time_XX (XX == access or modify).
1477c478bd9Sstevel@tonic-gate  * Return TRUE if arg was set (even if there was an error) and FALSE
1487c478bd9Sstevel@tonic-gate  * otherwise. Also set error code. The caller should not continue
1497c478bd9Sstevel@tonic-gate  * if error was set, whether or not the return is TRUE or FALSE. Returning
1507c478bd9Sstevel@tonic-gate  * FALSE does not mean there was an error, only that the attr was not set.
1517c478bd9Sstevel@tonic-gate  */
1527c478bd9Sstevel@tonic-gate static bool_t
nfs4_set_fattr4_attr(vattr_t * vap,vsecattr_t * vsap,struct nfs4_ntov_map * ntovp,union nfs4_attr_u * nap,int flags,int * errorp)1537c478bd9Sstevel@tonic-gate nfs4_set_fattr4_attr(vattr_t *vap, vsecattr_t *vsap,
154*f44e1126SVitaliy Gusev     struct nfs4_ntov_map *ntovp, union nfs4_attr_u *nap, int flags,
155*f44e1126SVitaliy Gusev     int *errorp)
1567c478bd9Sstevel@tonic-gate {
1577c478bd9Sstevel@tonic-gate 	bool_t	retval = TRUE;
1587c478bd9Sstevel@tonic-gate 
1597c478bd9Sstevel@tonic-gate 	/*
1607c478bd9Sstevel@tonic-gate 	 * Special case for time set: if setting the
1617c478bd9Sstevel@tonic-gate 	 * time, ignore entry for time access/modify
1627c478bd9Sstevel@tonic-gate 	 * and instead use that of time access/modify set.
1637c478bd9Sstevel@tonic-gate 	 */
1647c478bd9Sstevel@tonic-gate 	*errorp = 0;
1657c478bd9Sstevel@tonic-gate 	/*
1667c478bd9Sstevel@tonic-gate 	 * Bit matches the mask
1677c478bd9Sstevel@tonic-gate 	 */
1687c478bd9Sstevel@tonic-gate 	switch (ntovp->vbit & vap->va_mask) {
1697c478bd9Sstevel@tonic-gate 	case AT_SIZE:
1707c478bd9Sstevel@tonic-gate 		nap->size = vap->va_size;
1717c478bd9Sstevel@tonic-gate 		break;
1727c478bd9Sstevel@tonic-gate 	case AT_MODE:
1737c478bd9Sstevel@tonic-gate 		nap->mode = vap->va_mode;
1747c478bd9Sstevel@tonic-gate 		break;
1757c478bd9Sstevel@tonic-gate 	case AT_UID:
1767c478bd9Sstevel@tonic-gate 		/*
1777c478bd9Sstevel@tonic-gate 		 * if no mapping, uid will be mapped to a number string,
1787c478bd9Sstevel@tonic-gate 		 * e.g. "12345"
1797c478bd9Sstevel@tonic-gate 		 */
1807c478bd9Sstevel@tonic-gate 		if (*errorp = nfs_idmap_uid_str(vap->va_uid, &nap->owner,
1817c478bd9Sstevel@tonic-gate 		    FALSE))
1827c478bd9Sstevel@tonic-gate 			retval = FALSE;
1837c478bd9Sstevel@tonic-gate 		break;
1847c478bd9Sstevel@tonic-gate 	case AT_GID:
1857c478bd9Sstevel@tonic-gate 		/*
1867c478bd9Sstevel@tonic-gate 		 * if no mapping, gid will be mapped to a number string,
1877c478bd9Sstevel@tonic-gate 		 * e.g. "12345"
1887c478bd9Sstevel@tonic-gate 		 */
1897c478bd9Sstevel@tonic-gate 		if (*errorp = nfs_idmap_gid_str(vap->va_gid, &nap->owner_group,
1907c478bd9Sstevel@tonic-gate 		    FALSE))
1917c478bd9Sstevel@tonic-gate 			retval = FALSE;
1927c478bd9Sstevel@tonic-gate 		break;
1937c478bd9Sstevel@tonic-gate 	case AT_ATIME:
1947c478bd9Sstevel@tonic-gate 		if ((ntovp->nval != FATTR4_TIME_ACCESS_SET) ||
1957c478bd9Sstevel@tonic-gate 		    (*errorp = timestruc_to_settime4(&vap->va_atime,
1962f172c55SRobert Thurlow 		    &nap->time_access_set, flags))) {
1977c478bd9Sstevel@tonic-gate 			/* FATTR4_TIME_ACCESS - not used for verify */
1987c478bd9Sstevel@tonic-gate 			retval = FALSE;
1997c478bd9Sstevel@tonic-gate 		}
2007c478bd9Sstevel@tonic-gate 		break;
2017c478bd9Sstevel@tonic-gate 	case AT_MTIME:
2027c478bd9Sstevel@tonic-gate 		if ((ntovp->nval != FATTR4_TIME_MODIFY_SET) ||
2037c478bd9Sstevel@tonic-gate 		    (*errorp = timestruc_to_settime4(&vap->va_mtime,
2042f172c55SRobert Thurlow 		    &nap->time_modify_set, flags))) {
2057c478bd9Sstevel@tonic-gate 			/* FATTR4_TIME_MODIFY - not used for verify */
2067c478bd9Sstevel@tonic-gate 			retval = FALSE;
2077c478bd9Sstevel@tonic-gate 		}
2087c478bd9Sstevel@tonic-gate 		break;
2097c478bd9Sstevel@tonic-gate 	default:
2107c478bd9Sstevel@tonic-gate 		/*
2117c478bd9Sstevel@tonic-gate 		 * If the ntovp->vbit == 0 this is most likely the ACL.
2127c478bd9Sstevel@tonic-gate 		 */
2137c478bd9Sstevel@tonic-gate 		if (ntovp->vbit == 0 && ntovp->fbit == FATTR4_ACL_MASK) {
2147c478bd9Sstevel@tonic-gate 			ASSERT(vsap->vsa_mask == (VSA_ACE | VSA_ACECNT));
2157c478bd9Sstevel@tonic-gate 			nap->acl.fattr4_acl_len = vsap->vsa_aclcnt;
2167c478bd9Sstevel@tonic-gate 			nap->acl.fattr4_acl_val = vsap->vsa_aclentp;
2177c478bd9Sstevel@tonic-gate 		} else
2187c478bd9Sstevel@tonic-gate 			retval = FALSE;
2197c478bd9Sstevel@tonic-gate 	}
2207c478bd9Sstevel@tonic-gate 
2217c478bd9Sstevel@tonic-gate 	return (retval);
2227c478bd9Sstevel@tonic-gate }
2237c478bd9Sstevel@tonic-gate 
2247c478bd9Sstevel@tonic-gate /*
2257c478bd9Sstevel@tonic-gate  * XXX - This is a shorter version of vattr_to_fattr4 which only takes care
2267c478bd9Sstevel@tonic-gate  * of setattr args - size, mode, uid/gid, times. Eventually we should generalize
2277c478bd9Sstevel@tonic-gate  * by using nfs4_ntov_map and the same functions used by the server.
2287c478bd9Sstevel@tonic-gate  * Here we just hardcoded the setattr attributes. Note that the order is
2297c478bd9Sstevel@tonic-gate  * important - it should follow the order of the bits in the mask.
2307c478bd9Sstevel@tonic-gate  */
2317c478bd9Sstevel@tonic-gate int
vattr_to_fattr4(vattr_t * vap,vsecattr_t * vsap,fattr4 * fattrp,int flags,enum nfs_opnum4 op,bitmap4 supp)2327c478bd9Sstevel@tonic-gate vattr_to_fattr4(vattr_t *vap, vsecattr_t *vsap, fattr4 *fattrp, int flags,
233*f44e1126SVitaliy Gusev     enum nfs_opnum4 op, bitmap4 supp)
2347c478bd9Sstevel@tonic-gate {
2357c478bd9Sstevel@tonic-gate 	int i, j;
2367c478bd9Sstevel@tonic-gate 	union nfs4_attr_u *na = NULL;
2377c478bd9Sstevel@tonic-gate 	int attrcnt;
2387c478bd9Sstevel@tonic-gate 	int uid_attr = -1;
2397c478bd9Sstevel@tonic-gate 	int gid_attr = -1;
2407c478bd9Sstevel@tonic-gate 	int acl_attr = -1;
2417c478bd9Sstevel@tonic-gate 	XDR xdr;
2427c478bd9Sstevel@tonic-gate 	ulong_t xdr_size;
2437c478bd9Sstevel@tonic-gate 	char *xdr_attrs;
2447c478bd9Sstevel@tonic-gate 	int error = 0;
2457c478bd9Sstevel@tonic-gate 	uint8_t amap[NFS4_MAXNUM_ATTRS];
2467c478bd9Sstevel@tonic-gate 	uint_t va_mask = vap->va_mask;
2477c478bd9Sstevel@tonic-gate 	bool_t (*attrfunc)();
2487c478bd9Sstevel@tonic-gate 
2497c478bd9Sstevel@tonic-gate #ifndef lint
2507c478bd9Sstevel@tonic-gate 	/*
2517c478bd9Sstevel@tonic-gate 	 * Make sure that maximum attribute number can be expressed as an
2527c478bd9Sstevel@tonic-gate 	 * 8 bit quantity.
2537c478bd9Sstevel@tonic-gate 	 */
2547c478bd9Sstevel@tonic-gate 	ASSERT(NFS4_MAXNUM_ATTRS <= (UINT8_MAX + 1));
2557c478bd9Sstevel@tonic-gate #endif
2567c478bd9Sstevel@tonic-gate 	fattrp->attrmask = 0;
2577c478bd9Sstevel@tonic-gate 	fattrp->attrlist4_len = 0;
2587c478bd9Sstevel@tonic-gate 	fattrp->attrlist4 = NULL;
2597c478bd9Sstevel@tonic-gate 	na = kmem_zalloc(sizeof (union nfs4_attr_u) * nfs4_ntov_map_size,
2602f172c55SRobert Thurlow 	    KM_SLEEP);
2617c478bd9Sstevel@tonic-gate 
2627c478bd9Sstevel@tonic-gate 	if (op == OP_SETATTR || op == OP_CREATE || op == OP_OPEN) {
2637c478bd9Sstevel@tonic-gate 		/*
2647c478bd9Sstevel@tonic-gate 		 * Note we need to set the attrmask for set operations.
2657c478bd9Sstevel@tonic-gate 		 * In particular mtime and atime will be set to the
2667c478bd9Sstevel@tonic-gate 		 * servers time.
2677c478bd9Sstevel@tonic-gate 		 */
2687c478bd9Sstevel@tonic-gate 		nfs4_vmask_to_nmask_set(va_mask, &fattrp->attrmask);
2697c478bd9Sstevel@tonic-gate 		if (vsap != NULL)
2707c478bd9Sstevel@tonic-gate 			fattrp->attrmask |= FATTR4_ACL_MASK;
2717c478bd9Sstevel@tonic-gate 		attrfunc = nfs4_set_fattr4_attr;
2727c478bd9Sstevel@tonic-gate 	} else {	/* verify/nverify */
2737c478bd9Sstevel@tonic-gate 		/*
2747c478bd9Sstevel@tonic-gate 		 * Verfy/nverify use the "normal vmask_to_nmask
2757c478bd9Sstevel@tonic-gate 		 * this routine knows how to handle all vmask bits
2767c478bd9Sstevel@tonic-gate 		 */
2777c478bd9Sstevel@tonic-gate 		nfs4_vmask_to_nmask(va_mask, &fattrp->attrmask);
2787c478bd9Sstevel@tonic-gate 		/*
2797c478bd9Sstevel@tonic-gate 		 * XXX verify/nverify only works for a subset of attrs that
2807c478bd9Sstevel@tonic-gate 		 * directly map to vattr_t attrs.  So, verify/nverify is
2817c478bd9Sstevel@tonic-gate 		 * broken for servers that only support mandatory attrs.
2827c478bd9Sstevel@tonic-gate 		 * Mask out change attr for now and fix verify op to
2837c478bd9Sstevel@tonic-gate 		 * work with mandonly servers later.  nfs4_vmask_to_nmask
2847c478bd9Sstevel@tonic-gate 		 * sets change whenever it sees request for ctime/mtime,
2857c478bd9Sstevel@tonic-gate 		 * so we must turn off change because nfs4_ver_fattr4_attr
2867c478bd9Sstevel@tonic-gate 		 * will not generate args for change.  This is a bug
2877c478bd9Sstevel@tonic-gate 		 * that will be fixed later.
2887c478bd9Sstevel@tonic-gate 		 * XXX
2897c478bd9Sstevel@tonic-gate 		 */
2907c478bd9Sstevel@tonic-gate 		fattrp->attrmask &= ~FATTR4_CHANGE_MASK;
2917c478bd9Sstevel@tonic-gate 		attrfunc = nfs4_ver_fattr4_attr;
2927c478bd9Sstevel@tonic-gate 	}
2937c478bd9Sstevel@tonic-gate 
2947c478bd9Sstevel@tonic-gate 	/* Mask out any rec attrs unsupported by server */
2957c478bd9Sstevel@tonic-gate 	fattrp->attrmask &= supp;
2967c478bd9Sstevel@tonic-gate 
2977c478bd9Sstevel@tonic-gate 	attrcnt = 0;
2987c478bd9Sstevel@tonic-gate 	xdr_size = 0;
2997c478bd9Sstevel@tonic-gate 	for (i = 0; i < nfs4_ntov_map_size; i++) {
3007c478bd9Sstevel@tonic-gate 		/*
3017c478bd9Sstevel@tonic-gate 		 * In the case of FATTR4_ACL_MASK, the vbit will be 0 (zero)
3027c478bd9Sstevel@tonic-gate 		 * so we must also check if the fbit is FATTR4_ACL_MASK before
3037c478bd9Sstevel@tonic-gate 		 * skipping over this attribute.
3047c478bd9Sstevel@tonic-gate 		 */
3057c478bd9Sstevel@tonic-gate 		if (!(nfs4_ntov_map[i].vbit & vap->va_mask)) {
3067c478bd9Sstevel@tonic-gate 			if (nfs4_ntov_map[i].fbit != FATTR4_ACL_MASK)
3077c478bd9Sstevel@tonic-gate 				continue;
3087c478bd9Sstevel@tonic-gate 			if (vsap == NULL)
3097c478bd9Sstevel@tonic-gate 				continue;
3107c478bd9Sstevel@tonic-gate 		}
3117c478bd9Sstevel@tonic-gate 
3127c478bd9Sstevel@tonic-gate 		if (attrfunc == nfs4_set_fattr4_attr) {
3137c478bd9Sstevel@tonic-gate 			if (!(*attrfunc)(vap, vsap, &nfs4_ntov_map[i],
3147c478bd9Sstevel@tonic-gate 			    &na[attrcnt], flags, &error))
3157c478bd9Sstevel@tonic-gate 				continue;
3167c478bd9Sstevel@tonic-gate 		} else if (attrfunc == nfs4_ver_fattr4_attr) {
3177c478bd9Sstevel@tonic-gate 			if (!(*attrfunc)(vap, &nfs4_ntov_map[i], &na[attrcnt],
3187c478bd9Sstevel@tonic-gate 			    flags, &error))
3197c478bd9Sstevel@tonic-gate 				continue;
3207c478bd9Sstevel@tonic-gate 		}
3217c478bd9Sstevel@tonic-gate 
3227c478bd9Sstevel@tonic-gate 		if (error)
3237c478bd9Sstevel@tonic-gate 			goto done;	/* Exit! */
3247c478bd9Sstevel@tonic-gate 
3257c478bd9Sstevel@tonic-gate 		/*
3267c478bd9Sstevel@tonic-gate 		 * Calculate XDR size
3277c478bd9Sstevel@tonic-gate 		 */
3287c478bd9Sstevel@tonic-gate 		if (nfs4_ntov_map[i].xdr_size != 0) {
3297c478bd9Sstevel@tonic-gate 			/*
3307c478bd9Sstevel@tonic-gate 			 * If we are setting attributes (attrfunc is
3317c478bd9Sstevel@tonic-gate 			 * nfs4_set_fattr4_attr) and are setting the
3327c478bd9Sstevel@tonic-gate 			 * mtime or atime, adjust the xdr size down by
3337c478bd9Sstevel@tonic-gate 			 * 3 words, since we are using the server's
3347c478bd9Sstevel@tonic-gate 			 * time as the current time.  Exception: if
3357c478bd9Sstevel@tonic-gate 			 * ATTR_UTIME is set, the client sends the
3367c478bd9Sstevel@tonic-gate 			 * time, so leave the xdr size alone.
3377c478bd9Sstevel@tonic-gate 			 */
3387c478bd9Sstevel@tonic-gate 			xdr_size += nfs4_ntov_map[i].xdr_size;
3397c478bd9Sstevel@tonic-gate 			if ((nfs4_ntov_map[i].nval == FATTR4_TIME_ACCESS_SET ||
3407c478bd9Sstevel@tonic-gate 			    nfs4_ntov_map[i].nval == FATTR4_TIME_MODIFY_SET) &&
3412f172c55SRobert Thurlow 			    attrfunc == nfs4_set_fattr4_attr &&
3422f172c55SRobert Thurlow 			    !(flags & ATTR_UTIME)) {
3437c478bd9Sstevel@tonic-gate 				xdr_size -= 3 * BYTES_PER_XDR_UNIT;
3447c478bd9Sstevel@tonic-gate 			}
3457c478bd9Sstevel@tonic-gate 		} else {
3467c478bd9Sstevel@tonic-gate 			/*
3477c478bd9Sstevel@tonic-gate 			 * The only zero xdr_sizes we should see
3487c478bd9Sstevel@tonic-gate 			 * are AT_UID, AT_GID and FATTR4_ACL_MASK
3497c478bd9Sstevel@tonic-gate 			 */
3507c478bd9Sstevel@tonic-gate 			ASSERT(nfs4_ntov_map[i].vbit == AT_UID ||
3512f172c55SRobert Thurlow 			    nfs4_ntov_map[i].vbit == AT_GID ||
3522f172c55SRobert Thurlow 			    nfs4_ntov_map[i].fbit == FATTR4_ACL_MASK);
3537c478bd9Sstevel@tonic-gate 			if (nfs4_ntov_map[i].vbit == AT_UID) {
3547c478bd9Sstevel@tonic-gate 				uid_attr = attrcnt;
3557c478bd9Sstevel@tonic-gate 				xdr_size += BYTES_PER_XDR_UNIT;	/* length */
3567c478bd9Sstevel@tonic-gate 				xdr_size +=
3572f172c55SRobert Thurlow 				    RNDUP(na[attrcnt].owner.utf8string_len);
3587c478bd9Sstevel@tonic-gate 			} else if (nfs4_ntov_map[i].vbit == AT_GID) {
3597c478bd9Sstevel@tonic-gate 				gid_attr = attrcnt;
3607c478bd9Sstevel@tonic-gate 				xdr_size += BYTES_PER_XDR_UNIT;	/* length */
3617c478bd9Sstevel@tonic-gate 				xdr_size +=
3627c478bd9Sstevel@tonic-gate 				    RNDUP(
3632f172c55SRobert Thurlow 				    na[attrcnt].owner_group.utf8string_len);
3647c478bd9Sstevel@tonic-gate 			} else if (nfs4_ntov_map[i].fbit == FATTR4_ACL_MASK) {
3657c478bd9Sstevel@tonic-gate 				nfsace4 *tmpacl = (nfsace4 *)vsap->vsa_aclentp;
3667c478bd9Sstevel@tonic-gate 
3677c478bd9Sstevel@tonic-gate 				acl_attr = attrcnt;
3687c478bd9Sstevel@tonic-gate 				/* fattr4_acl_len */
3697c478bd9Sstevel@tonic-gate 				xdr_size += BYTES_PER_XDR_UNIT;
3707c478bd9Sstevel@tonic-gate 				/* fattr4_acl_val */
3717c478bd9Sstevel@tonic-gate 				xdr_size += RNDUP((vsap->vsa_aclcnt *
3727c478bd9Sstevel@tonic-gate 				    (sizeof (acetype4) + sizeof (aceflag4)
3737c478bd9Sstevel@tonic-gate 				    + sizeof (acemask4))));
3747c478bd9Sstevel@tonic-gate 
3757c478bd9Sstevel@tonic-gate 				for (j = 0; j < vsap->vsa_aclcnt; j++) {
3767c478bd9Sstevel@tonic-gate 					/* who - utf8string_len */
3777c478bd9Sstevel@tonic-gate 					xdr_size += BYTES_PER_XDR_UNIT;
3787c478bd9Sstevel@tonic-gate 					/* who - utf8string_val */
3797c478bd9Sstevel@tonic-gate 					xdr_size +=
3807c478bd9Sstevel@tonic-gate 					    RNDUP(tmpacl[j].who.utf8string_len);
3817c478bd9Sstevel@tonic-gate 				}
3827c478bd9Sstevel@tonic-gate 			}
3837c478bd9Sstevel@tonic-gate 		}
3847c478bd9Sstevel@tonic-gate 
3857c478bd9Sstevel@tonic-gate 		/*
3867c478bd9Sstevel@tonic-gate 		 * This attr is going otw
3877c478bd9Sstevel@tonic-gate 		 */
3887c478bd9Sstevel@tonic-gate 		amap[attrcnt] = (uint8_t)nfs4_ntov_map[i].nval;
3897c478bd9Sstevel@tonic-gate 		attrcnt++;
3907c478bd9Sstevel@tonic-gate 
3917c478bd9Sstevel@tonic-gate 		/*
3927c478bd9Sstevel@tonic-gate 		 * Clear this bit from test mask so we stop
3937c478bd9Sstevel@tonic-gate 		 * as soon as all requested attrs are done.
3947c478bd9Sstevel@tonic-gate 		 */
3957c478bd9Sstevel@tonic-gate 		va_mask &= ~nfs4_ntov_map[i].vbit;
3967c478bd9Sstevel@tonic-gate 		if (va_mask == 0 &&
3977c478bd9Sstevel@tonic-gate 		    (vsap == NULL || (vsap != NULL && acl_attr != -1)))
3987c478bd9Sstevel@tonic-gate 			break;
3997c478bd9Sstevel@tonic-gate 	}
4007c478bd9Sstevel@tonic-gate 
4017c478bd9Sstevel@tonic-gate 	if (attrcnt == 0) {
4027c478bd9Sstevel@tonic-gate 		goto done;
4037c478bd9Sstevel@tonic-gate 	}
4047c478bd9Sstevel@tonic-gate 
4057c478bd9Sstevel@tonic-gate 	fattrp->attrlist4 = xdr_attrs = kmem_alloc(xdr_size, KM_SLEEP);
4067c478bd9Sstevel@tonic-gate 	fattrp->attrlist4_len = xdr_size;
4077c478bd9Sstevel@tonic-gate 	xdrmem_create(&xdr, xdr_attrs, xdr_size, XDR_ENCODE);
4087c478bd9Sstevel@tonic-gate 	for (i = 0; i < attrcnt; i++) {
4097c478bd9Sstevel@tonic-gate 		if ((*nfs4_ntov_map[amap[i]].xfunc)(&xdr, &na[i]) == FALSE) {
4107c478bd9Sstevel@tonic-gate 			cmn_err(CE_WARN, "vattr_to_fattr4: xdr encode of "
4112f172c55SRobert Thurlow 			    "attribute failed\n");
4127c478bd9Sstevel@tonic-gate 			error = EINVAL;
4137c478bd9Sstevel@tonic-gate 			break;
4147c478bd9Sstevel@tonic-gate 		}
4157c478bd9Sstevel@tonic-gate 	}
4167c478bd9Sstevel@tonic-gate done:
4177c478bd9Sstevel@tonic-gate 	/*
4187c478bd9Sstevel@tonic-gate 	 * Free any malloc'd attrs, can only be uid or gid
4197c478bd9Sstevel@tonic-gate 	 */
4207c478bd9Sstevel@tonic-gate 	if (uid_attr != -1 && na[uid_attr].owner.utf8string_val != NULL) {
4217c478bd9Sstevel@tonic-gate 		kmem_free(na[uid_attr].owner.utf8string_val,
4222f172c55SRobert Thurlow 		    na[uid_attr].owner.utf8string_len);
4237c478bd9Sstevel@tonic-gate 	}
4247c478bd9Sstevel@tonic-gate 	if (gid_attr != -1 && na[gid_attr].owner_group.utf8string_val != NULL) {
4257c478bd9Sstevel@tonic-gate 		kmem_free(na[gid_attr].owner_group.utf8string_val,
4262f172c55SRobert Thurlow 		    na[gid_attr].owner_group.utf8string_len);
4277c478bd9Sstevel@tonic-gate 	}
4287c478bd9Sstevel@tonic-gate 
4297c478bd9Sstevel@tonic-gate 	/* xdrmem_destroy(&xdrs); */	/* NO-OP */
4307c478bd9Sstevel@tonic-gate 	kmem_free(na, sizeof (union nfs4_attr_u) * nfs4_ntov_map_size);
4317c478bd9Sstevel@tonic-gate 	if (error)
4327c478bd9Sstevel@tonic-gate 		nfs4_fattr4_free(fattrp);
4337c478bd9Sstevel@tonic-gate 	return (error);
4347c478bd9Sstevel@tonic-gate }
4357c478bd9Sstevel@tonic-gate 
4367c478bd9Sstevel@tonic-gate void
nfs4_fattr4_free(fattr4 * attrp)4377c478bd9Sstevel@tonic-gate nfs4_fattr4_free(fattr4 *attrp)
4387c478bd9Sstevel@tonic-gate {
4397c478bd9Sstevel@tonic-gate 	/*
4407c478bd9Sstevel@tonic-gate 	 * set attrlist4val/len to 0 because...
4417c478bd9Sstevel@tonic-gate 	 *
4427c478bd9Sstevel@tonic-gate 	 * op_readdir resfree function could call us again
4437c478bd9Sstevel@tonic-gate 	 * for last entry4 if it was able to encode the name
4447c478bd9Sstevel@tonic-gate 	 * and cookie but couldn't encode the attrs because
4457c478bd9Sstevel@tonic-gate 	 * of maxcount violation (from rddir args).  In that
4467c478bd9Sstevel@tonic-gate 	 * case, the last/partial entry4's fattr4 has already
4477c478bd9Sstevel@tonic-gate 	 * been free'd, but the entry4 remains on the end of
4487c478bd9Sstevel@tonic-gate 	 * the list.
4497c478bd9Sstevel@tonic-gate 	 */
4507c478bd9Sstevel@tonic-gate 	attrp->attrmask = 0;
4517c478bd9Sstevel@tonic-gate 
4527c478bd9Sstevel@tonic-gate 	if (attrp->attrlist4) {
4537c478bd9Sstevel@tonic-gate 		kmem_free(attrp->attrlist4, attrp->attrlist4_len);
4547c478bd9Sstevel@tonic-gate 		attrp->attrlist4 = NULL;
4557c478bd9Sstevel@tonic-gate 		attrp->attrlist4_len = 0;
4567c478bd9Sstevel@tonic-gate 	}
4577c478bd9Sstevel@tonic-gate }
4587c478bd9Sstevel@tonic-gate 
4597c478bd9Sstevel@tonic-gate /*
4607c478bd9Sstevel@tonic-gate  * Translate a vattr_t mask to a fattr4 type bitmap, caller is
4617c478bd9Sstevel@tonic-gate  * responsible for zeroing bitsval if needed.
4627c478bd9Sstevel@tonic-gate  */
4637c478bd9Sstevel@tonic-gate void
nfs4_vmask_to_nmask(uint_t vmask,bitmap4 * bitsval)4647c478bd9Sstevel@tonic-gate nfs4_vmask_to_nmask(uint_t vmask, bitmap4 *bitsval)
4657c478bd9Sstevel@tonic-gate {
4667c478bd9Sstevel@tonic-gate 	if (vmask == AT_ALL || vmask == NFS4_VTON_ATTR_MASK) {
4677c478bd9Sstevel@tonic-gate 		*bitsval |= NFS4_NTOV_ATTR_MASK;
4687c478bd9Sstevel@tonic-gate 		return;
4697c478bd9Sstevel@tonic-gate 	}
4707c478bd9Sstevel@tonic-gate 
4717c478bd9Sstevel@tonic-gate 	vmask &= NFS4_VTON_ATTR_MASK;
4727c478bd9Sstevel@tonic-gate 	if (vmask == 0) {
4737c478bd9Sstevel@tonic-gate 		return;
4747c478bd9Sstevel@tonic-gate 	}
4757c478bd9Sstevel@tonic-gate 
4767c478bd9Sstevel@tonic-gate 	if (vmask & AT_TYPE)
4777c478bd9Sstevel@tonic-gate 		*bitsval |= FATTR4_TYPE_MASK;
4787c478bd9Sstevel@tonic-gate 	if (vmask & AT_MODE)
4797c478bd9Sstevel@tonic-gate 		*bitsval |= FATTR4_MODE_MASK;
4807c478bd9Sstevel@tonic-gate 	if (vmask & AT_UID)
4817c478bd9Sstevel@tonic-gate 		*bitsval |= FATTR4_OWNER_MASK;
4827c478bd9Sstevel@tonic-gate 	if (vmask & AT_GID)
4837c478bd9Sstevel@tonic-gate 		*bitsval |= FATTR4_OWNER_GROUP_MASK;
4847c478bd9Sstevel@tonic-gate 	if (vmask & AT_FSID)
4857c478bd9Sstevel@tonic-gate 		*bitsval |= FATTR4_FSID_MASK;
4867c478bd9Sstevel@tonic-gate 	/* set mounted_on_fileid when AT_NODEID requested */
4877c478bd9Sstevel@tonic-gate 	if (vmask & AT_NODEID)
4887c478bd9Sstevel@tonic-gate 		*bitsval |= FATTR4_FILEID_MASK | FATTR4_MOUNTED_ON_FILEID_MASK;
4897c478bd9Sstevel@tonic-gate 	if (vmask & AT_NLINK)
4907c478bd9Sstevel@tonic-gate 		*bitsval |= FATTR4_NUMLINKS_MASK;
4917c478bd9Sstevel@tonic-gate 	if (vmask & AT_SIZE)
4927c478bd9Sstevel@tonic-gate 		*bitsval |= FATTR4_SIZE_MASK;
4937c478bd9Sstevel@tonic-gate 	if (vmask & AT_ATIME)
4947c478bd9Sstevel@tonic-gate 		*bitsval |= FATTR4_TIME_ACCESS_MASK;
4957c478bd9Sstevel@tonic-gate 	if (vmask & AT_MTIME)
4969720e166Sjasmith 		*bitsval |= FATTR4_TIME_MODIFY_MASK;
4979720e166Sjasmith 	/* also set CHANGE whenever AT_CTIME requested */
4987c478bd9Sstevel@tonic-gate 	if (vmask & AT_CTIME)
4997c478bd9Sstevel@tonic-gate 		*bitsval |= FATTR4_TIME_METADATA_MASK | FATTR4_CHANGE_MASK;
5007c478bd9Sstevel@tonic-gate 	if (vmask & AT_NBLOCKS)
5017c478bd9Sstevel@tonic-gate 		*bitsval |= FATTR4_SPACE_USED_MASK;
5027c478bd9Sstevel@tonic-gate 	if (vmask & AT_RDEV)
5037c478bd9Sstevel@tonic-gate 		*bitsval |= FATTR4_RAWDEV_MASK;
5047c478bd9Sstevel@tonic-gate }
5057c478bd9Sstevel@tonic-gate 
5067c478bd9Sstevel@tonic-gate /*
5077c478bd9Sstevel@tonic-gate  * nfs4_vmask_to_nmask_set is used for setattr. A separate function needed
5087c478bd9Sstevel@tonic-gate  * because of special treatment to timeset.
5097c478bd9Sstevel@tonic-gate  */
5109720e166Sjasmith void
nfs4_vmask_to_nmask_set(uint_t vmask,bitmap4 * bitsval)5117c478bd9Sstevel@tonic-gate nfs4_vmask_to_nmask_set(uint_t vmask, bitmap4 *bitsval)
5127c478bd9Sstevel@tonic-gate {
5137c478bd9Sstevel@tonic-gate 	vmask &= NFS4_VTON_ATTR_MASK_SET;
5147c478bd9Sstevel@tonic-gate 
5157c478bd9Sstevel@tonic-gate 	if (vmask == 0) {
5167c478bd9Sstevel@tonic-gate 		return;
5177c478bd9Sstevel@tonic-gate 	}
5187c478bd9Sstevel@tonic-gate 
5197c478bd9Sstevel@tonic-gate 	if (vmask & AT_MODE)
5207c478bd9Sstevel@tonic-gate 		*bitsval |= FATTR4_MODE_MASK;
5217c478bd9Sstevel@tonic-gate 	if (vmask & AT_UID)
5227c478bd9Sstevel@tonic-gate 		*bitsval |= FATTR4_OWNER_MASK;
5237c478bd9Sstevel@tonic-gate 	if (vmask & AT_GID)
5247c478bd9Sstevel@tonic-gate 		*bitsval |= FATTR4_OWNER_GROUP_MASK;
5257c478bd9Sstevel@tonic-gate 	if (vmask & AT_SIZE)
5267c478bd9Sstevel@tonic-gate 		*bitsval |= FATTR4_SIZE_MASK;
5277c478bd9Sstevel@tonic-gate 	if (vmask & AT_ATIME)
5287c478bd9Sstevel@tonic-gate 		*bitsval |= FATTR4_TIME_ACCESS_SET_MASK;
5297c478bd9Sstevel@tonic-gate 	if (vmask & AT_MTIME)
5307c478bd9Sstevel@tonic-gate 		*bitsval |= FATTR4_TIME_MODIFY_SET_MASK;
5317c478bd9Sstevel@tonic-gate }
5327c478bd9Sstevel@tonic-gate 
5337c478bd9Sstevel@tonic-gate /*
5347c478bd9Sstevel@tonic-gate  * Convert NFS Version 4 over the network attributes to the local
5357c478bd9Sstevel@tonic-gate  * virtual attributes.
5367c478bd9Sstevel@tonic-gate  */
5377c478bd9Sstevel@tonic-gate vtype_t nf4_to_vt[] = {
5387c478bd9Sstevel@tonic-gate 	VBAD, VREG, VDIR, VBLK, VCHR, VLNK, VSOCK, VFIFO, VDIR, VREG
5397c478bd9Sstevel@tonic-gate };
5407c478bd9Sstevel@tonic-gate 
5417c478bd9Sstevel@tonic-gate 
5427c478bd9Sstevel@tonic-gate /*
5437c478bd9Sstevel@tonic-gate  *	{ fbit, vbit, vfsstat, mandatory,
5447c478bd9Sstevel@tonic-gate  *		nval, xdr_size, xfunc,
5457c478bd9Sstevel@tonic-gate  *		sv_getit, prtstr },
5467c478bd9Sstevel@tonic-gate  */
5477c478bd9Sstevel@tonic-gate struct nfs4_ntov_map nfs4_ntov_map[] = {
5487c478bd9Sstevel@tonic-gate 	{ FATTR4_SUPPORTED_ATTRS_MASK, 0, FALSE, TRUE,
5497c478bd9Sstevel@tonic-gate 		FATTR4_SUPPORTED_ATTRS, 2 * BYTES_PER_XDR_UNIT, xdr_bitmap4,
5507c478bd9Sstevel@tonic-gate 		NULL, "fattr4_supported_attrs" },
5517c478bd9Sstevel@tonic-gate 
5527c478bd9Sstevel@tonic-gate 	{ FATTR4_TYPE_MASK, AT_TYPE, FALSE, TRUE,
5537c478bd9Sstevel@tonic-gate 		FATTR4_TYPE, BYTES_PER_XDR_UNIT, xdr_int,
5547c478bd9Sstevel@tonic-gate 		NULL, "fattr4_type" },
5557c478bd9Sstevel@tonic-gate 
5567c478bd9Sstevel@tonic-gate 	{ FATTR4_FH_EXPIRE_TYPE_MASK, 0, FALSE, TRUE,
5577c478bd9Sstevel@tonic-gate 		FATTR4_FH_EXPIRE_TYPE, BYTES_PER_XDR_UNIT, xdr_u_int,
5587c478bd9Sstevel@tonic-gate 		NULL, "fattr4_fh_expire_type" },
5597c478bd9Sstevel@tonic-gate 
5607c478bd9Sstevel@tonic-gate 	{ FATTR4_CHANGE_MASK, 0, FALSE, TRUE,
5617c478bd9Sstevel@tonic-gate 		FATTR4_CHANGE, 2 * BYTES_PER_XDR_UNIT, xdr_u_longlong_t,
5627c478bd9Sstevel@tonic-gate 		NULL, "fattr4_change" },
5637c478bd9Sstevel@tonic-gate 
5647c478bd9Sstevel@tonic-gate 	{ FATTR4_SIZE_MASK, AT_SIZE, FALSE, TRUE,
5657c478bd9Sstevel@tonic-gate 		FATTR4_SIZE,  2 * BYTES_PER_XDR_UNIT, xdr_u_longlong_t,
5667c478bd9Sstevel@tonic-gate 		NULL, "fattr4_size" },
5677c478bd9Sstevel@tonic-gate 
5687c478bd9Sstevel@tonic-gate 	{ FATTR4_LINK_SUPPORT_MASK, 0, FALSE, TRUE,
5697c478bd9Sstevel@tonic-gate 		FATTR4_LINK_SUPPORT, BYTES_PER_XDR_UNIT, xdr_bool,
5707c478bd9Sstevel@tonic-gate 		NULL, "fattr4_link_support" },
5717c478bd9Sstevel@tonic-gate 
5727c478bd9Sstevel@tonic-gate 	{ FATTR4_SYMLINK_SUPPORT_MASK, 0, FALSE, TRUE,
5737c478bd9Sstevel@tonic-gate 		FATTR4_SYMLINK_SUPPORT, BYTES_PER_XDR_UNIT, xdr_bool,
5747c478bd9Sstevel@tonic-gate 		NULL, "fattr4_symlink_support" },
5757c478bd9Sstevel@tonic-gate 
5767c478bd9Sstevel@tonic-gate 	{ FATTR4_NAMED_ATTR_MASK, 0, FALSE, TRUE,
5777c478bd9Sstevel@tonic-gate 		FATTR4_NAMED_ATTR, BYTES_PER_XDR_UNIT, xdr_bool,
5787c478bd9Sstevel@tonic-gate 		NULL, "fattr4_named_attr" },
5797c478bd9Sstevel@tonic-gate 
5807c478bd9Sstevel@tonic-gate 	{ FATTR4_FSID_MASK, AT_FSID, FALSE, TRUE,
5817c478bd9Sstevel@tonic-gate 		FATTR4_FSID, 4 * BYTES_PER_XDR_UNIT, xdr_fattr4_fsid,
5827c478bd9Sstevel@tonic-gate 		NULL, "fattr4_fsid" },
5837c478bd9Sstevel@tonic-gate 
5847c478bd9Sstevel@tonic-gate 	{ FATTR4_UNIQUE_HANDLES_MASK, 0, FALSE, TRUE,
5857c478bd9Sstevel@tonic-gate 		FATTR4_UNIQUE_HANDLES, BYTES_PER_XDR_UNIT, xdr_bool,
5867c478bd9Sstevel@tonic-gate 		NULL, "fattr4_unique_handles" },
5877c478bd9Sstevel@tonic-gate 
5887c478bd9Sstevel@tonic-gate 	{ FATTR4_LEASE_TIME_MASK, 0, FALSE, TRUE,
5897c478bd9Sstevel@tonic-gate 		FATTR4_LEASE_TIME, BYTES_PER_XDR_UNIT, xdr_u_int,
5907c478bd9Sstevel@tonic-gate 		NULL, "fattr4_lease_time" },
5917c478bd9Sstevel@tonic-gate 
5927c478bd9Sstevel@tonic-gate 	{ FATTR4_RDATTR_ERROR_MASK, 0, FALSE, TRUE,
5937c478bd9Sstevel@tonic-gate 		FATTR4_RDATTR_ERROR, BYTES_PER_XDR_UNIT, xdr_int,
5947c478bd9Sstevel@tonic-gate 		NULL, "fattr4_rdattr_error" },
5957c478bd9Sstevel@tonic-gate 
5967c478bd9Sstevel@tonic-gate 	{ FATTR4_ACL_MASK, 0, FALSE, FALSE,
5977c478bd9Sstevel@tonic-gate 		FATTR4_ACL, 0, xdr_fattr4_acl,
5987c478bd9Sstevel@tonic-gate 		NULL, "fattr4_acl" },
5997c478bd9Sstevel@tonic-gate 
6007c478bd9Sstevel@tonic-gate 	{ FATTR4_ACLSUPPORT_MASK, 0, FALSE, FALSE,
6017c478bd9Sstevel@tonic-gate 		FATTR4_ACLSUPPORT, BYTES_PER_XDR_UNIT, xdr_u_int,
6027c478bd9Sstevel@tonic-gate 		NULL, "fattr4_aclsupport" },
6037c478bd9Sstevel@tonic-gate 
6047c478bd9Sstevel@tonic-gate 	{ FATTR4_ARCHIVE_MASK, 0, FALSE, FALSE,
6057c478bd9Sstevel@tonic-gate 		FATTR4_ARCHIVE, BYTES_PER_XDR_UNIT, xdr_bool,
6067c478bd9Sstevel@tonic-gate 		NULL, "fattr4_archive" },
6077c478bd9Sstevel@tonic-gate 
6087c478bd9Sstevel@tonic-gate 	{ FATTR4_CANSETTIME_MASK, 0, FALSE, FALSE,
6097c478bd9Sstevel@tonic-gate 		FATTR4_CANSETTIME, BYTES_PER_XDR_UNIT, xdr_bool,
6107c478bd9Sstevel@tonic-gate 		NULL, "fattr4_cansettime" },
6117c478bd9Sstevel@tonic-gate 
6127c478bd9Sstevel@tonic-gate 	{ FATTR4_CASE_INSENSITIVE_MASK, 0, FALSE, FALSE,
6137c478bd9Sstevel@tonic-gate 		FATTR4_CASE_INSENSITIVE, BYTES_PER_XDR_UNIT, xdr_bool,
6147c478bd9Sstevel@tonic-gate 		NULL, "fattr4_case_insensitive" },
6157c478bd9Sstevel@tonic-gate 
6167c478bd9Sstevel@tonic-gate 	{ FATTR4_CASE_PRESERVING_MASK, 0, FALSE, FALSE,
6177c478bd9Sstevel@tonic-gate 		FATTR4_CASE_PRESERVING, BYTES_PER_XDR_UNIT, xdr_bool,
6187c478bd9Sstevel@tonic-gate 		NULL, "fattr4_case_preserving" },
6197c478bd9Sstevel@tonic-gate 
6207c478bd9Sstevel@tonic-gate 	{ FATTR4_CHOWN_RESTRICTED_MASK, 0, FALSE, FALSE,
6217c478bd9Sstevel@tonic-gate 		FATTR4_CHOWN_RESTRICTED, BYTES_PER_XDR_UNIT, xdr_bool,
6227c478bd9Sstevel@tonic-gate 		NULL, "fattr4_chown_restricted" },
6237c478bd9Sstevel@tonic-gate 
6247c478bd9Sstevel@tonic-gate 	{ FATTR4_FILEHANDLE_MASK, 0, FALSE, TRUE,
6257c478bd9Sstevel@tonic-gate 		FATTR4_FILEHANDLE, 0, xdr_nfs_fh4,
6267c478bd9Sstevel@tonic-gate 		NULL, "fattr4_filehandle" },
6277c478bd9Sstevel@tonic-gate 
6287c478bd9Sstevel@tonic-gate 	{ FATTR4_FILEID_MASK, AT_NODEID, FALSE, FALSE,
6297c478bd9Sstevel@tonic-gate 		FATTR4_FILEID, 2 * BYTES_PER_XDR_UNIT, xdr_u_longlong_t,
6307c478bd9Sstevel@tonic-gate 		NULL, "fattr4_fileid" },
6317c478bd9Sstevel@tonic-gate 
6327c478bd9Sstevel@tonic-gate 	{ FATTR4_FILES_AVAIL_MASK, 0, TRUE, FALSE,
6337c478bd9Sstevel@tonic-gate 		FATTR4_FILES_AVAIL, 2 * BYTES_PER_XDR_UNIT, xdr_u_longlong_t,
6347c478bd9Sstevel@tonic-gate 		NULL, "fattr4_files_avail" },
6357c478bd9Sstevel@tonic-gate 
6367c478bd9Sstevel@tonic-gate 	{ FATTR4_FILES_FREE_MASK, 0, TRUE, FALSE,
6377c478bd9Sstevel@tonic-gate 		FATTR4_FILES_FREE, 2 * BYTES_PER_XDR_UNIT, xdr_u_longlong_t,
6387c478bd9Sstevel@tonic-gate 		NULL, "fattr4_files_free" },
6397c478bd9Sstevel@tonic-gate 
6407c478bd9Sstevel@tonic-gate 	{ FATTR4_FILES_TOTAL_MASK, 0, TRUE, FALSE,
6417c478bd9Sstevel@tonic-gate 		FATTR4_FILES_TOTAL, 2 * BYTES_PER_XDR_UNIT, xdr_u_longlong_t,
6427c478bd9Sstevel@tonic-gate 		NULL, "fattr4_files_total" },
6437c478bd9Sstevel@tonic-gate 
6447c478bd9Sstevel@tonic-gate 	{ FATTR4_FS_LOCATIONS_MASK, 0, FALSE, FALSE,
6457c478bd9Sstevel@tonic-gate 		FATTR4_FS_LOCATIONS, 0, xdr_fattr4_fs_locations,
6467c478bd9Sstevel@tonic-gate 		NULL, "fattr4_fs_locations" },
6477c478bd9Sstevel@tonic-gate 
6487c478bd9Sstevel@tonic-gate 	{ FATTR4_HIDDEN_MASK, 0, FALSE, FALSE,
6497c478bd9Sstevel@tonic-gate 		FATTR4_HIDDEN, BYTES_PER_XDR_UNIT, xdr_bool,
6507c478bd9Sstevel@tonic-gate 		NULL, "fattr4_hidden" },
6517c478bd9Sstevel@tonic-gate 
6527c478bd9Sstevel@tonic-gate 	{ FATTR4_HOMOGENEOUS_MASK, 0, FALSE, FALSE,
6537c478bd9Sstevel@tonic-gate 		FATTR4_HOMOGENEOUS, BYTES_PER_XDR_UNIT, xdr_bool,
6547c478bd9Sstevel@tonic-gate 		NULL, "fattr4_homogeneous" },
6557c478bd9Sstevel@tonic-gate 
6567c478bd9Sstevel@tonic-gate 	{ FATTR4_MAXFILESIZE_MASK, 0, FALSE, FALSE,
6577c478bd9Sstevel@tonic-gate 		FATTR4_MAXFILESIZE, 2 * BYTES_PER_XDR_UNIT, xdr_u_longlong_t,
6587c478bd9Sstevel@tonic-gate 		NULL, "fattr4_maxfilesize" },
6597c478bd9Sstevel@tonic-gate 
6607c478bd9Sstevel@tonic-gate 	{ FATTR4_MAXLINK_MASK, 0, FALSE, FALSE,
6617c478bd9Sstevel@tonic-gate 		FATTR4_MAXLINK, BYTES_PER_XDR_UNIT, xdr_u_int,
6627c478bd9Sstevel@tonic-gate 		NULL, "fattr4_maxlink" },
6637c478bd9Sstevel@tonic-gate 
6647c478bd9Sstevel@tonic-gate 	{ FATTR4_MAXNAME_MASK, 0, FALSE, FALSE,
6657c478bd9Sstevel@tonic-gate 		FATTR4_MAXNAME, BYTES_PER_XDR_UNIT, xdr_u_int,
6667c478bd9Sstevel@tonic-gate 		NULL, "fattr4_maxname" },
6677c478bd9Sstevel@tonic-gate 
6687c478bd9Sstevel@tonic-gate 	{ FATTR4_MAXREAD_MASK, 0, FALSE, FALSE,
6697c478bd9Sstevel@tonic-gate 		FATTR4_MAXREAD, 2 * BYTES_PER_XDR_UNIT, xdr_u_longlong_t,
6707c478bd9Sstevel@tonic-gate 		NULL, "fattr4_maxread" },
6717c478bd9Sstevel@tonic-gate 
6727c478bd9Sstevel@tonic-gate 	{ FATTR4_MAXWRITE_MASK, 0, FALSE, FALSE,
6737c478bd9Sstevel@tonic-gate 		FATTR4_MAXWRITE, 2 * BYTES_PER_XDR_UNIT, xdr_u_longlong_t,
6747c478bd9Sstevel@tonic-gate 		NULL, "fattr4_maxwrite" },
6757c478bd9Sstevel@tonic-gate 
6767c478bd9Sstevel@tonic-gate 	{ FATTR4_MIMETYPE_MASK, 0, FALSE, FALSE,
6777c478bd9Sstevel@tonic-gate 		FATTR4_MIMETYPE, 0, xdr_utf8string,
6787c478bd9Sstevel@tonic-gate 		NULL, "fattr4_mimetype" },
6797c478bd9Sstevel@tonic-gate 
6807c478bd9Sstevel@tonic-gate 	{ FATTR4_MODE_MASK, AT_MODE, FALSE, FALSE,
6817c478bd9Sstevel@tonic-gate 		FATTR4_MODE, BYTES_PER_XDR_UNIT, xdr_u_int,
6827c478bd9Sstevel@tonic-gate 		NULL, "fattr4_mode" },
6837c478bd9Sstevel@tonic-gate 
6847c478bd9Sstevel@tonic-gate 	{ FATTR4_NO_TRUNC_MASK, 0, FALSE, FALSE,
6857c478bd9Sstevel@tonic-gate 		FATTR4_NO_TRUNC, BYTES_PER_XDR_UNIT, xdr_bool,
6867c478bd9Sstevel@tonic-gate 		NULL, "fattr4_no_trunc" },
6877c478bd9Sstevel@tonic-gate 
6887c478bd9Sstevel@tonic-gate 	{ FATTR4_NUMLINKS_MASK, AT_NLINK, FALSE, FALSE,
6897c478bd9Sstevel@tonic-gate 		FATTR4_NUMLINKS, BYTES_PER_XDR_UNIT, xdr_u_int,
6907c478bd9Sstevel@tonic-gate 		NULL, "fattr4_numlinks" },
6917c478bd9Sstevel@tonic-gate 
6927c478bd9Sstevel@tonic-gate 	{ FATTR4_OWNER_MASK, AT_UID, FALSE, FALSE,
6937c478bd9Sstevel@tonic-gate 		FATTR4_OWNER, 0, xdr_utf8string,
6947c478bd9Sstevel@tonic-gate 		NULL, "fattr4_owner" },
6957c478bd9Sstevel@tonic-gate 
6967c478bd9Sstevel@tonic-gate 	{ FATTR4_OWNER_GROUP_MASK, AT_GID, FALSE, FALSE,
6977c478bd9Sstevel@tonic-gate 		FATTR4_OWNER_GROUP, 0, xdr_utf8string,
6987c478bd9Sstevel@tonic-gate 		NULL, "fattr4_owner_group" },
6997c478bd9Sstevel@tonic-gate 
7007c478bd9Sstevel@tonic-gate 	{ FATTR4_QUOTA_AVAIL_HARD_MASK, 0, FALSE, FALSE,
7017c478bd9Sstevel@tonic-gate 		FATTR4_QUOTA_AVAIL_HARD, 2 * BYTES_PER_XDR_UNIT,
7027c478bd9Sstevel@tonic-gate 		xdr_u_longlong_t,
7037c478bd9Sstevel@tonic-gate 		NULL, "fattr4_quota_avail_hard" },
7047c478bd9Sstevel@tonic-gate 
7057c478bd9Sstevel@tonic-gate 	{ FATTR4_QUOTA_AVAIL_SOFT_MASK, 0, FALSE, FALSE,
7067c478bd9Sstevel@tonic-gate 		FATTR4_QUOTA_AVAIL_SOFT, 2 * BYTES_PER_XDR_UNIT,
7077c478bd9Sstevel@tonic-gate 		xdr_u_longlong_t,
7087c478bd9Sstevel@tonic-gate 		NULL, "fattr4_quota_avail_soft" },
7097c478bd9Sstevel@tonic-gate 
7107c478bd9Sstevel@tonic-gate 	{ FATTR4_QUOTA_USED_MASK, 0, FALSE, FALSE,
7117c478bd9Sstevel@tonic-gate 		FATTR4_QUOTA_USED, 2 * BYTES_PER_XDR_UNIT, xdr_u_longlong_t,
7127c478bd9Sstevel@tonic-gate 		NULL, "fattr4_quota_used" },
7137c478bd9Sstevel@tonic-gate 
7147c478bd9Sstevel@tonic-gate 	{ FATTR4_RAWDEV_MASK, AT_RDEV, FALSE, FALSE,
7157c478bd9Sstevel@tonic-gate 		FATTR4_RAWDEV, 2 * BYTES_PER_XDR_UNIT, xdr_fattr4_rawdev,
7167c478bd9Sstevel@tonic-gate 		NULL, "fattr4_rawdev" },
7177c478bd9Sstevel@tonic-gate 
7187c478bd9Sstevel@tonic-gate 	{ FATTR4_SPACE_AVAIL_MASK, 0, TRUE, FALSE,
7197c478bd9Sstevel@tonic-gate 		FATTR4_SPACE_AVAIL, 2 * BYTES_PER_XDR_UNIT, xdr_u_longlong_t,
7207c478bd9Sstevel@tonic-gate 		NULL, "fattr4_space_avail" },
7217c478bd9Sstevel@tonic-gate 
7227c478bd9Sstevel@tonic-gate 	{ FATTR4_SPACE_FREE_MASK, 0, TRUE, FALSE,
7237c478bd9Sstevel@tonic-gate 		FATTR4_SPACE_FREE, 2 * BYTES_PER_XDR_UNIT, xdr_u_longlong_t,
7247c478bd9Sstevel@tonic-gate 		NULL, "fattr4_space_free" },
7257c478bd9Sstevel@tonic-gate 
7267c478bd9Sstevel@tonic-gate 	{ FATTR4_SPACE_TOTAL_MASK, 0, TRUE, FALSE,
7277c478bd9Sstevel@tonic-gate 		FATTR4_SPACE_TOTAL, 2 * BYTES_PER_XDR_UNIT, xdr_u_longlong_t,
7287c478bd9Sstevel@tonic-gate 		NULL, "fattr4_space_total" },
7297c478bd9Sstevel@tonic-gate 
7307c478bd9Sstevel@tonic-gate 	{ FATTR4_SPACE_USED_MASK, AT_NBLOCKS, FALSE, FALSE,
7317c478bd9Sstevel@tonic-gate 		FATTR4_SPACE_USED, 2 * BYTES_PER_XDR_UNIT, xdr_u_longlong_t,
7327c478bd9Sstevel@tonic-gate 		NULL, "fattr4_space_used" },
7337c478bd9Sstevel@tonic-gate 
7347c478bd9Sstevel@tonic-gate 	{ FATTR4_SYSTEM_MASK, 0, FALSE, FALSE,
7357c478bd9Sstevel@tonic-gate 		FATTR4_SYSTEM, BYTES_PER_XDR_UNIT, xdr_bool,
7367c478bd9Sstevel@tonic-gate 		NULL, "fattr4_system" },
7377c478bd9Sstevel@tonic-gate 
7387c478bd9Sstevel@tonic-gate 	{ FATTR4_TIME_ACCESS_MASK, AT_ATIME, FALSE, FALSE,
7397c478bd9Sstevel@tonic-gate 		FATTR4_TIME_ACCESS, 3 * BYTES_PER_XDR_UNIT, xdr_nfstime4,
7407c478bd9Sstevel@tonic-gate 		NULL, "fattr4_time_access" },
7417c478bd9Sstevel@tonic-gate 
7427c478bd9Sstevel@tonic-gate 	{ FATTR4_TIME_ACCESS_SET_MASK, AT_ATIME, FALSE, FALSE,
7437c478bd9Sstevel@tonic-gate 		FATTR4_TIME_ACCESS_SET, 4 * BYTES_PER_XDR_UNIT, xdr_settime4,
7447c478bd9Sstevel@tonic-gate 		NULL, "fattr4_time_access_set" },
7457c478bd9Sstevel@tonic-gate 
7467c478bd9Sstevel@tonic-gate 	{ FATTR4_TIME_BACKUP_MASK, 0, FALSE, FALSE,
7477c478bd9Sstevel@tonic-gate 		FATTR4_TIME_BACKUP, 3 * BYTES_PER_XDR_UNIT, xdr_nfstime4,
7487c478bd9Sstevel@tonic-gate 		NULL, "fattr4_time_backup" },
7497c478bd9Sstevel@tonic-gate 
7507c478bd9Sstevel@tonic-gate 	{ FATTR4_TIME_CREATE_MASK, 0, FALSE, FALSE,
7517c478bd9Sstevel@tonic-gate 		FATTR4_TIME_CREATE, 3 * BYTES_PER_XDR_UNIT, xdr_nfstime4,
7527c478bd9Sstevel@tonic-gate 		NULL, "fattr4_time_create" },
7537c478bd9Sstevel@tonic-gate 
7547c478bd9Sstevel@tonic-gate 	{ FATTR4_TIME_DELTA_MASK, 0, FALSE, FALSE,
7557c478bd9Sstevel@tonic-gate 		FATTR4_TIME_DELTA, 3 * BYTES_PER_XDR_UNIT, xdr_nfstime4,
7567c478bd9Sstevel@tonic-gate 		NULL, "fattr4_time_delta" },
7577c478bd9Sstevel@tonic-gate 
7587c478bd9Sstevel@tonic-gate 	{ FATTR4_TIME_METADATA_MASK, AT_CTIME, FALSE, FALSE,
7597c478bd9Sstevel@tonic-gate 		FATTR4_TIME_METADATA, 3 * BYTES_PER_XDR_UNIT, xdr_nfstime4,
7607c478bd9Sstevel@tonic-gate 		NULL, "fattr4_time_metadata" },
7617c478bd9Sstevel@tonic-gate 
7627c478bd9Sstevel@tonic-gate 	{ FATTR4_TIME_MODIFY_MASK, AT_MTIME, FALSE, FALSE,
7637c478bd9Sstevel@tonic-gate 		FATTR4_TIME_MODIFY, 3 * BYTES_PER_XDR_UNIT, xdr_nfstime4,
7647c478bd9Sstevel@tonic-gate 		NULL, "fattr4_time_modify" },
7657c478bd9Sstevel@tonic-gate 
7667c478bd9Sstevel@tonic-gate 	{ FATTR4_TIME_MODIFY_SET_MASK, AT_MTIME, FALSE, FALSE,
7677c478bd9Sstevel@tonic-gate 		FATTR4_TIME_MODIFY_SET, 4 * BYTES_PER_XDR_UNIT, xdr_settime4,
7687c478bd9Sstevel@tonic-gate 		NULL, "fattr4_time_modify_set" },
7697c478bd9Sstevel@tonic-gate 
7702f172c55SRobert Thurlow 	{ FATTR4_MOUNTED_ON_FILEID_MASK, AT_NODEID, FALSE, FALSE,
7717c478bd9Sstevel@tonic-gate 		FATTR4_MOUNTED_ON_FILEID, 2 * BYTES_PER_XDR_UNIT,
7727c478bd9Sstevel@tonic-gate 		xdr_u_longlong_t,
7737c478bd9Sstevel@tonic-gate 		NULL, "fattr4_mounted_on_fileid" },
7747c478bd9Sstevel@tonic-gate 
775*f44e1126SVitaliy Gusev 	{ FATTR4_SUPPATTR_EXCLCREAT_MASK_LOCAL, 0, FALSE, FALSE,
776*f44e1126SVitaliy Gusev 		FATTR4_MOUNTED_ON_FILEID + 1, 0, xdr_bitmap4,
777*f44e1126SVitaliy Gusev 		NULL, "fattr4_suppattr_exclcreat" },
7787c478bd9Sstevel@tonic-gate };
7797c478bd9Sstevel@tonic-gate 
7807c478bd9Sstevel@tonic-gate uint_t nfs4_ntov_map_size = sizeof (nfs4_ntov_map) /
7817c478bd9Sstevel@tonic-gate 	sizeof (struct nfs4_ntov_map);
782