Home | History | Annotate | Line # | Download | only in nfs
nfsm_subs.h revision 1.36
      1 /*	$NetBSD: nfsm_subs.h,v 1.36 2004/04/05 10:41:45 yamt Exp $	*/
      2 
      3 /*
      4  * Copyright (c) 1989, 1993
      5  *	The Regents of the University of California.  All rights reserved.
      6  *
      7  * This code is derived from software contributed to Berkeley by
      8  * Rick Macklem at The University of Guelph.
      9  *
     10  * Redistribution and use in source and binary forms, with or without
     11  * modification, are permitted provided that the following conditions
     12  * are met:
     13  * 1. Redistributions of source code must retain the above copyright
     14  *    notice, this list of conditions and the following disclaimer.
     15  * 2. Redistributions in binary form must reproduce the above copyright
     16  *    notice, this list of conditions and the following disclaimer in the
     17  *    documentation and/or other materials provided with the distribution.
     18  * 3. Neither the name of the University nor the names of its contributors
     19  *    may be used to endorse or promote products derived from this software
     20  *    without specific prior written permission.
     21  *
     22  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
     23  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     24  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     25  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
     26  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     27  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     28  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     29  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     30  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     31  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     32  * SUCH DAMAGE.
     33  *
     34  *	@(#)nfsm_subs.h	8.2 (Berkeley) 3/30/95
     35  */
     36 
     37 
     38 #ifndef _NFS_NFSM_SUBS_H_
     39 #define _NFS_NFSM_SUBS_H_
     40 
     41 
     42 /*
     43  * These macros do strange and peculiar things to mbuf chains for
     44  * the assistance of the nfs code. To attempt to use them for any
     45  * other purpose will be dangerous. (they make weird assumptions)
     46  */
     47 
     48 /*
     49  * First define what the actual subs. return
     50  */
     51 
     52 #define	M_HASCL(m)	((m)->m_flags & M_EXT)
     53 #define	NFSMINOFF(m) \
     54 		if (M_HASCL(m)) \
     55 			(m)->m_data = (m)->m_ext.ext_buf; \
     56 		else if ((m)->m_flags & M_PKTHDR) \
     57 			(m)->m_data = (m)->m_pktdat; \
     58 		else \
     59 			(m)->m_data = (m)->m_dat
     60 #define	NFSMADV(m, s)	(m)->m_data += (s)
     61 #define	NFSMSIZ(m)	((M_HASCL(m)) ? (m)->m_ext.ext_size : \
     62 				(((m)->m_flags & M_PKTHDR) ? MHLEN : MLEN))
     63 
     64 /*
     65  * Now for the macros that do the simple stuff and call the functions
     66  * for the hard stuff.
     67  * These macros use several vars. declared in nfsm_reqhead and these
     68  * vars. must not be used elsewhere unless you are careful not to corrupt
     69  * them. The vars. starting with pN and tN (N=1,2,3,..) are temporaries
     70  * that may be used so long as the value is not expected to retained
     71  * after a macro.
     72  * I know, this is kind of dorkey, but it makes the actual op functions
     73  * fairly clean and deals with the mess caused by the xdr discriminating
     74  * unions.
     75  */
     76 
     77 #define	nfsm_build(a,c,s) \
     78 		{ if ((s) > M_TRAILINGSPACE(mb)) { \
     79 			struct mbuf *mb2; \
     80 			mb2 = m_get(M_WAIT, MT_DATA); \
     81 			MCLAIM(mb2, &nfs_mowner); \
     82 			if ((s) > MLEN) \
     83 				panic("build > MLEN"); \
     84 			mb->m_next = mb2; \
     85 			mb = mb2; \
     86 			mb->m_len = 0; \
     87 			bpos = mtod(mb, caddr_t); \
     88 		} \
     89 		(a) = (c)(bpos); \
     90 		mb->m_len += (s); \
     91 		bpos += (s); }
     92 
     93 #define nfsm_aligned(p) ALIGNED_POINTER(p,u_int32_t)
     94 
     95 #define	nfsm_dissect(a, c, s) \
     96 		{ t1 = mtod(md, caddr_t)+md->m_len-dpos; \
     97 		if (t1 >= (s) && nfsm_aligned(dpos)) { \
     98 			(a) = (c)(dpos); \
     99 			dpos += (s); \
    100 		} else if ((t1 = nfsm_disct(&md, &dpos, (s), t1, &cp2)) != 0){ \
    101 			error = t1; \
    102 			m_freem(mrep); \
    103 			goto nfsmout; \
    104 		} else { \
    105 			(a) = (c)cp2; \
    106 		} }
    107 
    108 #define nfsm_fhtom(n, v3) \
    109 	      { if (v3) { \
    110 			t2 = nfsm_rndup((n)->n_fhsize) + NFSX_UNSIGNED; \
    111 			if (t2 <= M_TRAILINGSPACE(mb)) { \
    112 				nfsm_build(tl, u_int32_t *, t2); \
    113 				*tl++ = txdr_unsigned((n)->n_fhsize); \
    114 				*(tl + ((t2>>2) - 2)) = 0; \
    115 				memcpy((caddr_t)tl,(caddr_t)(n)->n_fhp, \
    116 					(n)->n_fhsize); \
    117 			} else if ((t2 = nfsm_strtmbuf(&mb, &bpos, \
    118 				(caddr_t)(n)->n_fhp, \
    119 				  (n)->n_fhsize)) != 0) { \
    120 				error = t2; \
    121 				m_freem(mreq); \
    122 				goto nfsmout; \
    123 			} \
    124 		} else { \
    125 			nfsm_build(cp, caddr_t, NFSX_V2FH); \
    126 			memcpy(cp, (caddr_t)(n)->n_fhp, NFSX_V2FH); \
    127 		} }
    128 
    129 #define nfsm_srvfhtom(f, v3) \
    130 		{ if (v3) { \
    131 			nfsm_build(tl, u_int32_t *, NFSX_UNSIGNED + NFSX_V3FH); \
    132 			*tl++ = txdr_unsigned(NFSX_V3FH); \
    133 			memcpy((caddr_t)tl, (caddr_t)(f), NFSX_V3FH); \
    134 		} else { \
    135 			nfsm_build(cp, caddr_t, NFSX_V2FH); \
    136 			memcpy(cp, (caddr_t)(f), NFSX_V2FH); \
    137 		} }
    138 
    139 #define nfsm_srvpostop_fh(f) \
    140 		{ nfsm_build(tl, u_int32_t *, 2 * NFSX_UNSIGNED + NFSX_V3FH); \
    141 		*tl++ = nfs_true; \
    142 		*tl++ = txdr_unsigned(NFSX_V3FH); \
    143 		memcpy((caddr_t)tl, (caddr_t)(f), NFSX_V3FH); \
    144 		}
    145 
    146 /*
    147  * nfsm_mtofh: dissect a "resulted obj" part of create-like operations
    148  * like mkdir.
    149  *
    150  * for nfsv3, dissect post_op_fh3 and following post_op_attr.
    151  * for nfsv2, dissect fhandle and following fattr.
    152  *
    153  * d: (IN) the vnode of the parent directry.
    154  * v: (OUT) the corresponding vnode (we allocate one if needed)
    155  * v3: (IN) true for nfsv3.
    156  * f: (OUT) true if we got valid filehandle.  always true for nfsv2.
    157  */
    158 
    159 #define nfsm_mtofh(d, v, v3, f) \
    160 		{ struct nfsnode *ttnp; nfsfh_t *ttfhp; int ttfhsize; \
    161 		int hasattr = 0; \
    162 		if (v3) { \
    163 			nfsm_dissect(tl, u_int32_t *, NFSX_UNSIGNED); \
    164 			(f) = fxdr_unsigned(int, *tl); \
    165 		} else { \
    166 			(f) = 1; \
    167 			hasattr = 1; \
    168 		} \
    169 		if (f) { \
    170 			nfsm_getfh(ttfhp, ttfhsize, (v3)); \
    171 			if ((t1 = nfs_nget((d)->v_mount, ttfhp, ttfhsize, \
    172 				&ttnp)) != 0) { \
    173 				error = t1; \
    174 				m_freem(mrep); \
    175 				goto nfsmout; \
    176 			} \
    177 			(v) = NFSTOV(ttnp); \
    178 		} \
    179 		if (v3) { \
    180 			nfsm_dissect(tl, u_int32_t *, NFSX_UNSIGNED); \
    181 			if (f) \
    182 				hasattr = fxdr_unsigned(int, *tl); \
    183 			else if (fxdr_unsigned(int, *tl)) \
    184 				nfsm_adv(NFSX_V3FATTR); \
    185 		} \
    186 		if (f && hasattr) \
    187 			nfsm_loadattr((v), (struct vattr *)0, 0); \
    188 		}
    189 
    190 /*
    191  * nfsm_getfh: dissect a filehandle.
    192  *
    193  * f: (OUT) a filehandle.
    194  * s: (OUT) size of the filehandle in bytes.
    195  * v3: (IN) true if nfsv3.
    196  */
    197 
    198 #define nfsm_getfh(f, s, v3) \
    199 		{ if (v3) { \
    200 			nfsm_dissect(tl, u_int32_t *, NFSX_UNSIGNED); \
    201 			if (((s) = fxdr_unsigned(int, *tl)) <= 0 || \
    202 				(s) > NFSX_V3FHMAX) { \
    203 				m_freem(mrep); \
    204 				error = EBADRPC; \
    205 				goto nfsmout; \
    206 			} \
    207 		} else \
    208 			(s) = NFSX_V2FH; \
    209 		nfsm_dissect((f), nfsfh_t *, nfsm_rndup(s)); }
    210 
    211 #define	nfsm_loadattr(v, a, flags) \
    212 		{ struct vnode *ttvp = (v); \
    213 		if ((t1 = nfsm_loadattrcache(&ttvp, &md, &dpos, (a), (flags))) \
    214 		    != 0) { \
    215 			error = t1; \
    216 			m_freem(mrep); \
    217 			goto nfsmout; \
    218 		} \
    219 		(v) = ttvp; }
    220 
    221 /*
    222  * nfsm_postop_attr: process nfsv3 post_op_attr
    223  *
    224  * dissect post_op_attr.  if we got a one,
    225  * call nfsm_loadattrcache to update attribute cache.
    226  *
    227  * v: (IN/OUT) the corresponding vnode
    228  * f: (OUT) true if we got valid attribute
    229  * flags: (IN) flags for nfsm_loadattrcache
    230  */
    231 
    232 #define	nfsm_postop_attr(v, f, flags) \
    233 		{ struct vnode *ttvp = (v); \
    234 		nfsm_dissect(tl, u_int32_t *, NFSX_UNSIGNED); \
    235 		if (((f) = fxdr_unsigned(int, *tl)) != 0) { \
    236 			if ((t1 = nfsm_loadattrcache(&ttvp, &md, &dpos, \
    237 				(struct vattr *)0, (flags))) != 0) { \
    238 				error = t1; \
    239 				(f) = 0; \
    240 				m_freem(mrep); \
    241 				goto nfsmout; \
    242 			} \
    243 			(v) = ttvp; \
    244 		} }
    245 
    246 /*
    247  * nfsm_wcc_data: process nfsv3 wcc_data
    248  *
    249  * dissect pre_op_attr and then let nfsm_postop_attr dissect post_op_attr.
    250  *
    251  * v: (IN/OUT) the corresponding vnode
    252  * f: (IN/OUT)
    253  *	NFSV3_WCCRATTR	return true if we got valid post_op_attr.
    254  *	NFSV3_WCCCHK	return true if pre_op_attr's mtime is the same
    255  *			as our n_mtime.  (ie. our cache isn't stale.)
    256  * flags: (IN) flags for nfsm_loadattrcache
    257  */
    258 
    259 /* Used as (f) for nfsm_wcc_data() */
    260 #define NFSV3_WCCRATTR	0
    261 #define NFSV3_WCCCHK	1
    262 
    263 #define	nfsm_wcc_data(v, f, flags) \
    264 		{ int ttattrf, ttretf = 0, renewctime = 0, renewnctime = 0; \
    265 		nfsm_dissect(tl, u_int32_t *, NFSX_UNSIGNED); \
    266 		if (*tl == nfs_true) { \
    267 			struct timespec ctime; \
    268 			nfsm_dissect(tl, u_int32_t *, 6 * NFSX_UNSIGNED); \
    269 			fxdr_nfsv3time(tl + 4, &ctime); \
    270 			if (VTONFS(v)->n_ctime == ctime.tv_sec) \
    271 				renewctime = 1; \
    272 			if ((v)->v_type == VDIR) { \
    273 				if (timespeccmp(&VTONFS(v)->n_nctime, \
    274 				    &ctime, ==)) \
    275 					renewnctime = 1; \
    276 			} \
    277 			if (f) { \
    278 				struct timespec mtime; \
    279 				fxdr_nfsv3time(tl + 2, &mtime); \
    280 				ttretf = timespeccmp(&VTONFS(v)->n_mtime, \
    281 				    &mtime, ==); \
    282 			} \
    283 		} \
    284 		nfsm_postop_attr((v), ttattrf, (flags)); \
    285 		if (renewctime && ttattrf) \
    286 			VTONFS(v)->n_ctime = VTONFS(v)->n_vattr->va_ctime.tv_sec; \
    287 		if (renewnctime && ttattrf) \
    288 			VTONFS(v)->n_nctime = VTONFS(v)->n_vattr->va_ctime; \
    289 		if (f) { \
    290 			(f) = ttretf; \
    291 		} else { \
    292 			(f) = ttattrf; \
    293 		} }
    294 
    295 /* If full is true, set all fields, otherwise just set mode and time fields */
    296 #define nfsm_v3attrbuild(a, full)						\
    297 		{ if ((a)->va_mode != (mode_t)VNOVAL) {				\
    298 			nfsm_build(tl, u_int32_t *, 2 * NFSX_UNSIGNED);		\
    299 			*tl++ = nfs_true;					\
    300 			*tl = txdr_unsigned((a)->va_mode);			\
    301 		} else {							\
    302 			nfsm_build(tl, u_int32_t *, NFSX_UNSIGNED);		\
    303 			*tl = nfs_false;					\
    304 		}								\
    305 		if ((full) && (a)->va_uid != (uid_t)VNOVAL) {			\
    306 			nfsm_build(tl, u_int32_t *, 2 * NFSX_UNSIGNED);		\
    307 			*tl++ = nfs_true;					\
    308 			*tl = txdr_unsigned((a)->va_uid);			\
    309 		} else {							\
    310 			nfsm_build(tl, u_int32_t *, NFSX_UNSIGNED);		\
    311 			*tl = nfs_false;					\
    312 		}								\
    313 		if ((full) && (a)->va_gid != (gid_t)VNOVAL) {			\
    314 			nfsm_build(tl, u_int32_t *, 2 * NFSX_UNSIGNED);		\
    315 			*tl++ = nfs_true;					\
    316 			*tl = txdr_unsigned((a)->va_gid);			\
    317 		} else {							\
    318 			nfsm_build(tl, u_int32_t *, NFSX_UNSIGNED);		\
    319 			*tl = nfs_false;					\
    320 		}								\
    321 		if ((full) && (a)->va_size != VNOVAL) {				\
    322 			nfsm_build(tl, u_int32_t *, 3 * NFSX_UNSIGNED);		\
    323 			*tl++ = nfs_true;					\
    324 			txdr_hyper((a)->va_size, tl);				\
    325 		} else {							\
    326 			nfsm_build(tl, u_int32_t *, NFSX_UNSIGNED);		\
    327 			*tl = nfs_false;					\
    328 		}								\
    329 		if ((a)->va_atime.tv_sec != VNOVAL) {				\
    330 			if ((a)->va_atime.tv_sec != time.tv_sec) {		\
    331 				nfsm_build(tl, u_int32_t *, 3 * NFSX_UNSIGNED);	\
    332 				*tl++ = txdr_unsigned(NFSV3SATTRTIME_TOCLIENT);	\
    333 				txdr_nfsv3time(&(a)->va_atime, tl);		\
    334 			} else {						\
    335 				nfsm_build(tl, u_int32_t *, NFSX_UNSIGNED);	\
    336 				*tl = txdr_unsigned(NFSV3SATTRTIME_TOSERVER);	\
    337 			}							\
    338 		} else {							\
    339 			nfsm_build(tl, u_int32_t *, NFSX_UNSIGNED);		\
    340 			*tl = txdr_unsigned(NFSV3SATTRTIME_DONTCHANGE);		\
    341 		}								\
    342 		if ((a)->va_mtime.tv_sec != VNOVAL) {				\
    343 			if ((a)->va_mtime.tv_sec != time.tv_sec) {		\
    344 				nfsm_build(tl, u_int32_t *, 3 * NFSX_UNSIGNED);	\
    345 				*tl++ = txdr_unsigned(NFSV3SATTRTIME_TOCLIENT);	\
    346 				txdr_nfsv3time(&(a)->va_mtime, tl);		\
    347 			} else {						\
    348 				nfsm_build(tl, u_int32_t *, NFSX_UNSIGNED);	\
    349 				*tl = txdr_unsigned(NFSV3SATTRTIME_TOSERVER);	\
    350 			}							\
    351 		} else {							\
    352 			nfsm_build(tl, u_int32_t *, NFSX_UNSIGNED);		\
    353 			*tl = txdr_unsigned(NFSV3SATTRTIME_DONTCHANGE);		\
    354 		}								\
    355 		}
    356 
    357 
    358 #define	nfsm_strsiz(s,m) \
    359 		{ nfsm_dissect(tl,uint32_t *,NFSX_UNSIGNED); \
    360 		if (((s) = fxdr_unsigned(uint32_t,*tl)) > (m)) { \
    361 			m_freem(mrep); \
    362 			error = EBADRPC; \
    363 			goto nfsmout; \
    364 		} }
    365 
    366 #define	nfsm_srvnamesiz(s) \
    367 		{ nfsm_dissect(tl,uint32_t *,NFSX_UNSIGNED); \
    368 		if (((s) = fxdr_unsigned(uint32_t,*tl)) > NFS_MAXNAMLEN) \
    369 			error = NFSERR_NAMETOL; \
    370 		if (error) \
    371 			nfsm_reply(0); \
    372 		}
    373 
    374 #define nfsm_mtouio(p,s) \
    375 		if ((s) > 0 && \
    376 		   (t1 = nfsm_mbuftouio(&md,(p),(s),&dpos)) != 0) { \
    377 			error = t1; \
    378 			m_freem(mrep); \
    379 			goto nfsmout; \
    380 		}
    381 
    382 #define nfsm_uiotom(p,s) \
    383 		if ((t1 = nfsm_uiotombuf((p),&mb,(s),&bpos)) != 0) { \
    384 			error = t1; \
    385 			m_freem(mreq); \
    386 			goto nfsmout; \
    387 		}
    388 
    389 #define	nfsm_reqhead(n,a,s) \
    390 		mb = mreq = nfsm_reqh((n),(a),(s),&bpos)
    391 
    392 #define nfsm_reqdone	m_freem(mrep); \
    393 		nfsmout:
    394 
    395 #define nfsm_rndup(a)	(((a)+3)&(~0x3))
    396 #define nfsm_padlen(a)	(nfsm_rndup(a) - (a))
    397 
    398 #define	nfsm_request(v, t, p, c)	\
    399 		if ((error = nfs_request((v), mreq, (t), (p), \
    400 		   (c), &mrep, &md, &dpos)) != 0) { \
    401 			if (error & NFSERR_RETERR) \
    402 				error &= ~NFSERR_RETERR; \
    403 			else \
    404 				goto nfsmout; \
    405 		}
    406 
    407 #define	nfsm_strtom(a,s,m) \
    408 		if ((s) > (m)) { \
    409 			m_freem(mreq); \
    410 			error = ENAMETOOLONG; \
    411 			goto nfsmout; \
    412 		} \
    413 		t2 = nfsm_rndup(s)+NFSX_UNSIGNED; \
    414 		if (t2 <= M_TRAILINGSPACE(mb)) { \
    415 			nfsm_build(tl,u_int32_t *,t2); \
    416 			*tl++ = txdr_unsigned(s); \
    417 			*(tl+((t2>>2)-2)) = 0; \
    418 			memcpy((caddr_t)tl, (const char *)(a), (s)); \
    419 		} else if ((t2 = nfsm_strtmbuf(&mb, &bpos, (a), (s))) != 0) { \
    420 			error = t2; \
    421 			m_freem(mreq); \
    422 			goto nfsmout; \
    423 		}
    424 
    425 #define	nfsm_srvdone \
    426 		nfsmout: \
    427 		return(error)
    428 
    429 #define	nfsm_reply(s) \
    430 		{ \
    431 		nfsd->nd_repstat = error; \
    432 		if (error && !(nfsd->nd_flag & ND_NFSV3)) \
    433 		   (void) nfs_rephead(0, nfsd, slp, error, cache, &frev, \
    434 			mrq, &mb, &bpos); \
    435 		else \
    436 		   (void) nfs_rephead((s), nfsd, slp, error, cache, &frev, \
    437 			mrq, &mb, &bpos); \
    438 		if (mrep != NULL) { \
    439 			m_freem(mrep); \
    440 			mrep = NULL; \
    441 		} \
    442 		mreq = *mrq; \
    443 		if (error && (!(nfsd->nd_flag & ND_NFSV3) || \
    444 			error == EBADRPC)) \
    445 			return(0); \
    446 		}
    447 
    448 #define	nfsm_writereply(s, v3) \
    449 		{ \
    450 		nfsd->nd_repstat = error; \
    451 		if (error && !(v3)) \
    452 		   (void) nfs_rephead(0, nfsd, slp, error, cache, &frev, \
    453 			&mreq, &mb, &bpos); \
    454 		else \
    455 		   (void) nfs_rephead((s), nfsd, slp, error, cache, &frev, \
    456 			&mreq, &mb, &bpos); \
    457 		}
    458 
    459 #define	nfsm_adv(s) \
    460 		{ t1 = mtod(md, caddr_t)+md->m_len-dpos; \
    461 		if (t1 >= (s)) { \
    462 			dpos += (s); \
    463 		} else if ((t1 = nfs_adv(&md, &dpos, (s), t1)) != 0) { \
    464 			error = t1; \
    465 			m_freem(mrep); \
    466 			goto nfsmout; \
    467 		} }
    468 
    469 #define nfsm_srvmtofh(f) \
    470 	{ int fhlen = NFSX_V3FH; \
    471 		if (nfsd->nd_flag & ND_NFSV3) { \
    472 			nfsm_dissect(tl, u_int32_t *, NFSX_UNSIGNED); \
    473 			fhlen = fxdr_unsigned(int, *tl); \
    474 			if (fhlen == 0) { \
    475 				memset((caddr_t)(f), 0, NFSX_V3FH); \
    476 			} else if (fhlen != NFSX_V3FH) { \
    477 				error = EBADRPC; \
    478 				nfsm_reply(0); \
    479 			} \
    480 		} \
    481 		if (fhlen != 0) { \
    482 			nfsm_dissect(tl, u_int32_t *, NFSX_V3FH); \
    483 			memcpy( (caddr_t)(f), (caddr_t)tl, NFSX_V3FH); \
    484 			if ((nfsd->nd_flag & ND_NFSV3) == 0) \
    485 				nfsm_adv(NFSX_V2FH - NFSX_V3FH); \
    486 		} \
    487 	}
    488 
    489 #define	nfsm_clget \
    490 		if (bp >= be) { \
    491 			if (mp == mb) \
    492 				mp->m_len += bp-bpos; \
    493 			mp = m_get(M_WAIT, MT_DATA); \
    494 			MCLAIM(mp, &nfs_mowner); \
    495 			m_clget(mp, M_WAIT); \
    496 			mp->m_len = NFSMSIZ(mp); \
    497 			mp2->m_next = mp; \
    498 			mp2 = mp; \
    499 			bp = mtod(mp, caddr_t); \
    500 			be = bp+mp->m_len; \
    501 		} \
    502 		tl = (u_int32_t *)bp
    503 
    504 #define	nfsm_srvfillattr(a, f) \
    505 		nfsm_srvfattr(nfsd, (a), (f))
    506 
    507 #define nfsm_srvwcc_data(br, b, ar, a) \
    508 		nfsm_srvwcc(nfsd, (br), (b), (ar), (a), &mb, &bpos)
    509 
    510 #define nfsm_srvpostop_attr(r, a) \
    511 		nfsm_srvpostopattr(nfsd, (r), (a), &mb, &bpos)
    512 
    513 #define nfsm_srvsattr(a) \
    514 		{ nfsm_dissect(tl, u_int32_t *, NFSX_UNSIGNED); \
    515 		if (*tl == nfs_true) { \
    516 			nfsm_dissect(tl, u_int32_t *, NFSX_UNSIGNED); \
    517 			(a)->va_mode = nfstov_mode(*tl); \
    518 		} \
    519 		nfsm_dissect(tl, u_int32_t *, NFSX_UNSIGNED); \
    520 		if (*tl == nfs_true) { \
    521 			nfsm_dissect(tl, u_int32_t *, NFSX_UNSIGNED); \
    522 			(a)->va_uid = fxdr_unsigned(uid_t, *tl); \
    523 		} \
    524 		nfsm_dissect(tl, u_int32_t *, NFSX_UNSIGNED); \
    525 		if (*tl == nfs_true) { \
    526 			nfsm_dissect(tl, u_int32_t *, NFSX_UNSIGNED); \
    527 			(a)->va_gid = fxdr_unsigned(gid_t, *tl); \
    528 		} \
    529 		nfsm_dissect(tl, u_int32_t *, NFSX_UNSIGNED); \
    530 		if (*tl == nfs_true) { \
    531 			nfsm_dissect(tl, u_int32_t *, 2 * NFSX_UNSIGNED); \
    532 			(a)->va_size = fxdr_hyper(tl); \
    533 		} \
    534 		nfsm_dissect(tl, u_int32_t *, NFSX_UNSIGNED); \
    535 		switch (fxdr_unsigned(int, *tl)) { \
    536 		case NFSV3SATTRTIME_TOCLIENT: \
    537 			nfsm_dissect(tl, u_int32_t *, 2 * NFSX_UNSIGNED); \
    538 			fxdr_nfsv3time(tl, &(a)->va_atime); \
    539 			break; \
    540 		case NFSV3SATTRTIME_TOSERVER: \
    541 			(a)->va_atime.tv_sec = time.tv_sec; \
    542 			(a)->va_atime.tv_nsec = time.tv_usec * 1000; \
    543 			(a)->va_vaflags |= VA_UTIMES_NULL; \
    544 			break; \
    545 		}; \
    546 		nfsm_dissect(tl, u_int32_t *, NFSX_UNSIGNED); \
    547 		switch (fxdr_unsigned(int, *tl)) { \
    548 		case NFSV3SATTRTIME_TOCLIENT: \
    549 			nfsm_dissect(tl, u_int32_t *, 2 * NFSX_UNSIGNED); \
    550 			fxdr_nfsv3time(tl, &(a)->va_mtime); \
    551 			(a)->va_vaflags &= ~VA_UTIMES_NULL; \
    552 			break; \
    553 		case NFSV3SATTRTIME_TOSERVER: \
    554 			(a)->va_mtime.tv_sec = time.tv_sec; \
    555 			(a)->va_mtime.tv_nsec = time.tv_usec * 1000; \
    556 			(a)->va_vaflags |= VA_UTIMES_NULL; \
    557 			break; \
    558 		}; }
    559 
    560 #endif
    561