Home | History | Annotate | Line # | Download | only in nfs
nfsm_subs.h revision 1.35
      1 /*	$NetBSD: nfsm_subs.h,v 1.35 2004/04/05 10:28:23 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 		if (v3) { \
    162 			nfsm_dissect(tl, u_int32_t *, NFSX_UNSIGNED); \
    163 			(f) = fxdr_unsigned(int, *tl); \
    164 		} else \
    165 			(f) = 1; \
    166 		if (f) { \
    167 			nfsm_getfh(ttfhp, ttfhsize, (v3)); \
    168 			if ((t1 = nfs_nget((d)->v_mount, ttfhp, ttfhsize, \
    169 				&ttnp)) != 0) { \
    170 				error = t1; \
    171 				m_freem(mrep); \
    172 				goto nfsmout; \
    173 			} \
    174 			(v) = NFSTOV(ttnp); \
    175 		} \
    176 		if (v3) { \
    177 			nfsm_dissect(tl, u_int32_t *, NFSX_UNSIGNED); \
    178 			if (f) \
    179 				(f) = fxdr_unsigned(int, *tl); \
    180 			else if (fxdr_unsigned(int, *tl)) \
    181 				nfsm_adv(NFSX_V3FATTR); \
    182 		} \
    183 		if (f) \
    184 			nfsm_loadattr((v), (struct vattr *)0, 0); \
    185 		}
    186 
    187 /*
    188  * nfsm_getfh: dissect a filehandle.
    189  *
    190  * f: (OUT) a filehandle.
    191  * s: (OUT) size of the filehandle in bytes.
    192  * v3: (IN) true if nfsv3.
    193  */
    194 
    195 #define nfsm_getfh(f, s, v3) \
    196 		{ if (v3) { \
    197 			nfsm_dissect(tl, u_int32_t *, NFSX_UNSIGNED); \
    198 			if (((s) = fxdr_unsigned(int, *tl)) <= 0 || \
    199 				(s) > NFSX_V3FHMAX) { \
    200 				m_freem(mrep); \
    201 				error = EBADRPC; \
    202 				goto nfsmout; \
    203 			} \
    204 		} else \
    205 			(s) = NFSX_V2FH; \
    206 		nfsm_dissect((f), nfsfh_t *, nfsm_rndup(s)); }
    207 
    208 #define	nfsm_loadattr(v, a, flags) \
    209 		{ struct vnode *ttvp = (v); \
    210 		if ((t1 = nfsm_loadattrcache(&ttvp, &md, &dpos, (a), (flags))) \
    211 		    != 0) { \
    212 			error = t1; \
    213 			m_freem(mrep); \
    214 			goto nfsmout; \
    215 		} \
    216 		(v) = ttvp; }
    217 
    218 /*
    219  * nfsm_postop_attr: process nfsv3 post_op_attr
    220  *
    221  * dissect post_op_attr.  if we got a one,
    222  * call nfsm_loadattrcache to update attribute cache.
    223  *
    224  * v: (IN/OUT) the corresponding vnode
    225  * f: (OUT) true if we got valid attribute
    226  * flags: (IN) flags for nfsm_loadattrcache
    227  */
    228 
    229 #define	nfsm_postop_attr(v, f, flags) \
    230 		{ struct vnode *ttvp = (v); \
    231 		nfsm_dissect(tl, u_int32_t *, NFSX_UNSIGNED); \
    232 		if (((f) = fxdr_unsigned(int, *tl)) != 0) { \
    233 			if ((t1 = nfsm_loadattrcache(&ttvp, &md, &dpos, \
    234 				(struct vattr *)0, (flags))) != 0) { \
    235 				error = t1; \
    236 				(f) = 0; \
    237 				m_freem(mrep); \
    238 				goto nfsmout; \
    239 			} \
    240 			(v) = ttvp; \
    241 		} }
    242 
    243 /*
    244  * nfsm_wcc_data: process nfsv3 wcc_data
    245  *
    246  * dissect pre_op_attr and then let nfsm_postop_attr dissect post_op_attr.
    247  *
    248  * v: (IN/OUT) the corresponding vnode
    249  * f: (IN/OUT)
    250  *	NFSV3_WCCRATTR	return true if we got valid post_op_attr.
    251  *	NFSV3_WCCCHK	return true if pre_op_attr's mtime is the same
    252  *			as our n_mtime.  (ie. our cache isn't stale.)
    253  * flags: (IN) flags for nfsm_loadattrcache
    254  */
    255 
    256 /* Used as (f) for nfsm_wcc_data() */
    257 #define NFSV3_WCCRATTR	0
    258 #define NFSV3_WCCCHK	1
    259 
    260 #define	nfsm_wcc_data(v, f, flags) \
    261 		{ int ttattrf, ttretf = 0, renewctime = 0, renewnctime = 0; \
    262 		nfsm_dissect(tl, u_int32_t *, NFSX_UNSIGNED); \
    263 		if (*tl == nfs_true) { \
    264 			struct timespec ctime; \
    265 			nfsm_dissect(tl, u_int32_t *, 6 * NFSX_UNSIGNED); \
    266 			fxdr_nfsv3time(tl + 4, &ctime); \
    267 			if (VTONFS(v)->n_ctime == ctime.tv_sec) \
    268 				renewctime = 1; \
    269 			if ((v)->v_type == VDIR) { \
    270 				if (timespeccmp(&VTONFS(v)->n_nctime, \
    271 				    &ctime, ==)) \
    272 					renewnctime = 1; \
    273 			} \
    274 			if (f) { \
    275 				struct timespec mtime; \
    276 				fxdr_nfsv3time(tl + 2, &mtime); \
    277 				ttretf = timespeccmp(&VTONFS(v)->n_mtime, \
    278 				    &mtime, ==); \
    279 			} \
    280 		} \
    281 		nfsm_postop_attr((v), ttattrf, (flags)); \
    282 		if (renewctime && ttattrf) \
    283 			VTONFS(v)->n_ctime = VTONFS(v)->n_vattr->va_ctime.tv_sec; \
    284 		if (renewnctime && ttattrf) \
    285 			VTONFS(v)->n_nctime = VTONFS(v)->n_vattr->va_ctime; \
    286 		if (f) { \
    287 			(f) = ttretf; \
    288 		} else { \
    289 			(f) = ttattrf; \
    290 		} }
    291 
    292 /* If full is true, set all fields, otherwise just set mode and time fields */
    293 #define nfsm_v3attrbuild(a, full)						\
    294 		{ if ((a)->va_mode != (mode_t)VNOVAL) {				\
    295 			nfsm_build(tl, u_int32_t *, 2 * NFSX_UNSIGNED);		\
    296 			*tl++ = nfs_true;					\
    297 			*tl = txdr_unsigned((a)->va_mode);			\
    298 		} else {							\
    299 			nfsm_build(tl, u_int32_t *, NFSX_UNSIGNED);		\
    300 			*tl = nfs_false;					\
    301 		}								\
    302 		if ((full) && (a)->va_uid != (uid_t)VNOVAL) {			\
    303 			nfsm_build(tl, u_int32_t *, 2 * NFSX_UNSIGNED);		\
    304 			*tl++ = nfs_true;					\
    305 			*tl = txdr_unsigned((a)->va_uid);			\
    306 		} else {							\
    307 			nfsm_build(tl, u_int32_t *, NFSX_UNSIGNED);		\
    308 			*tl = nfs_false;					\
    309 		}								\
    310 		if ((full) && (a)->va_gid != (gid_t)VNOVAL) {			\
    311 			nfsm_build(tl, u_int32_t *, 2 * NFSX_UNSIGNED);		\
    312 			*tl++ = nfs_true;					\
    313 			*tl = txdr_unsigned((a)->va_gid);			\
    314 		} else {							\
    315 			nfsm_build(tl, u_int32_t *, NFSX_UNSIGNED);		\
    316 			*tl = nfs_false;					\
    317 		}								\
    318 		if ((full) && (a)->va_size != VNOVAL) {				\
    319 			nfsm_build(tl, u_int32_t *, 3 * NFSX_UNSIGNED);		\
    320 			*tl++ = nfs_true;					\
    321 			txdr_hyper((a)->va_size, tl);				\
    322 		} else {							\
    323 			nfsm_build(tl, u_int32_t *, NFSX_UNSIGNED);		\
    324 			*tl = nfs_false;					\
    325 		}								\
    326 		if ((a)->va_atime.tv_sec != VNOVAL) {				\
    327 			if ((a)->va_atime.tv_sec != time.tv_sec) {		\
    328 				nfsm_build(tl, u_int32_t *, 3 * NFSX_UNSIGNED);	\
    329 				*tl++ = txdr_unsigned(NFSV3SATTRTIME_TOCLIENT);	\
    330 				txdr_nfsv3time(&(a)->va_atime, tl);		\
    331 			} else {						\
    332 				nfsm_build(tl, u_int32_t *, NFSX_UNSIGNED);	\
    333 				*tl = txdr_unsigned(NFSV3SATTRTIME_TOSERVER);	\
    334 			}							\
    335 		} else {							\
    336 			nfsm_build(tl, u_int32_t *, NFSX_UNSIGNED);		\
    337 			*tl = txdr_unsigned(NFSV3SATTRTIME_DONTCHANGE);		\
    338 		}								\
    339 		if ((a)->va_mtime.tv_sec != VNOVAL) {				\
    340 			if ((a)->va_mtime.tv_sec != time.tv_sec) {		\
    341 				nfsm_build(tl, u_int32_t *, 3 * NFSX_UNSIGNED);	\
    342 				*tl++ = txdr_unsigned(NFSV3SATTRTIME_TOCLIENT);	\
    343 				txdr_nfsv3time(&(a)->va_mtime, tl);		\
    344 			} else {						\
    345 				nfsm_build(tl, u_int32_t *, NFSX_UNSIGNED);	\
    346 				*tl = txdr_unsigned(NFSV3SATTRTIME_TOSERVER);	\
    347 			}							\
    348 		} else {							\
    349 			nfsm_build(tl, u_int32_t *, NFSX_UNSIGNED);		\
    350 			*tl = txdr_unsigned(NFSV3SATTRTIME_DONTCHANGE);		\
    351 		}								\
    352 		}
    353 
    354 
    355 #define	nfsm_strsiz(s,m) \
    356 		{ nfsm_dissect(tl,uint32_t *,NFSX_UNSIGNED); \
    357 		if (((s) = fxdr_unsigned(uint32_t,*tl)) > (m)) { \
    358 			m_freem(mrep); \
    359 			error = EBADRPC; \
    360 			goto nfsmout; \
    361 		} }
    362 
    363 #define	nfsm_srvnamesiz(s) \
    364 		{ nfsm_dissect(tl,uint32_t *,NFSX_UNSIGNED); \
    365 		if (((s) = fxdr_unsigned(uint32_t,*tl)) > NFS_MAXNAMLEN) \
    366 			error = NFSERR_NAMETOL; \
    367 		if (error) \
    368 			nfsm_reply(0); \
    369 		}
    370 
    371 #define nfsm_mtouio(p,s) \
    372 		if ((s) > 0 && \
    373 		   (t1 = nfsm_mbuftouio(&md,(p),(s),&dpos)) != 0) { \
    374 			error = t1; \
    375 			m_freem(mrep); \
    376 			goto nfsmout; \
    377 		}
    378 
    379 #define nfsm_uiotom(p,s) \
    380 		if ((t1 = nfsm_uiotombuf((p),&mb,(s),&bpos)) != 0) { \
    381 			error = t1; \
    382 			m_freem(mreq); \
    383 			goto nfsmout; \
    384 		}
    385 
    386 #define	nfsm_reqhead(n,a,s) \
    387 		mb = mreq = nfsm_reqh((n),(a),(s),&bpos)
    388 
    389 #define nfsm_reqdone	m_freem(mrep); \
    390 		nfsmout:
    391 
    392 #define nfsm_rndup(a)	(((a)+3)&(~0x3))
    393 #define nfsm_padlen(a)	(nfsm_rndup(a) - (a))
    394 
    395 #define	nfsm_request(v, t, p, c)	\
    396 		if ((error = nfs_request((v), mreq, (t), (p), \
    397 		   (c), &mrep, &md, &dpos)) != 0) { \
    398 			if (error & NFSERR_RETERR) \
    399 				error &= ~NFSERR_RETERR; \
    400 			else \
    401 				goto nfsmout; \
    402 		}
    403 
    404 #define	nfsm_strtom(a,s,m) \
    405 		if ((s) > (m)) { \
    406 			m_freem(mreq); \
    407 			error = ENAMETOOLONG; \
    408 			goto nfsmout; \
    409 		} \
    410 		t2 = nfsm_rndup(s)+NFSX_UNSIGNED; \
    411 		if (t2 <= M_TRAILINGSPACE(mb)) { \
    412 			nfsm_build(tl,u_int32_t *,t2); \
    413 			*tl++ = txdr_unsigned(s); \
    414 			*(tl+((t2>>2)-2)) = 0; \
    415 			memcpy((caddr_t)tl, (const char *)(a), (s)); \
    416 		} else if ((t2 = nfsm_strtmbuf(&mb, &bpos, (a), (s))) != 0) { \
    417 			error = t2; \
    418 			m_freem(mreq); \
    419 			goto nfsmout; \
    420 		}
    421 
    422 #define	nfsm_srvdone \
    423 		nfsmout: \
    424 		return(error)
    425 
    426 #define	nfsm_reply(s) \
    427 		{ \
    428 		nfsd->nd_repstat = error; \
    429 		if (error && !(nfsd->nd_flag & ND_NFSV3)) \
    430 		   (void) nfs_rephead(0, nfsd, slp, error, cache, &frev, \
    431 			mrq, &mb, &bpos); \
    432 		else \
    433 		   (void) nfs_rephead((s), nfsd, slp, error, cache, &frev, \
    434 			mrq, &mb, &bpos); \
    435 		if (mrep != NULL) { \
    436 			m_freem(mrep); \
    437 			mrep = NULL; \
    438 		} \
    439 		mreq = *mrq; \
    440 		if (error && (!(nfsd->nd_flag & ND_NFSV3) || \
    441 			error == EBADRPC)) \
    442 			return(0); \
    443 		}
    444 
    445 #define	nfsm_writereply(s, v3) \
    446 		{ \
    447 		nfsd->nd_repstat = error; \
    448 		if (error && !(v3)) \
    449 		   (void) nfs_rephead(0, nfsd, slp, error, cache, &frev, \
    450 			&mreq, &mb, &bpos); \
    451 		else \
    452 		   (void) nfs_rephead((s), nfsd, slp, error, cache, &frev, \
    453 			&mreq, &mb, &bpos); \
    454 		}
    455 
    456 #define	nfsm_adv(s) \
    457 		{ t1 = mtod(md, caddr_t)+md->m_len-dpos; \
    458 		if (t1 >= (s)) { \
    459 			dpos += (s); \
    460 		} else if ((t1 = nfs_adv(&md, &dpos, (s), t1)) != 0) { \
    461 			error = t1; \
    462 			m_freem(mrep); \
    463 			goto nfsmout; \
    464 		} }
    465 
    466 #define nfsm_srvmtofh(f) \
    467 	{ int fhlen = NFSX_V3FH; \
    468 		if (nfsd->nd_flag & ND_NFSV3) { \
    469 			nfsm_dissect(tl, u_int32_t *, NFSX_UNSIGNED); \
    470 			fhlen = fxdr_unsigned(int, *tl); \
    471 			if (fhlen == 0) { \
    472 				memset((caddr_t)(f), 0, NFSX_V3FH); \
    473 			} else if (fhlen != NFSX_V3FH) { \
    474 				error = EBADRPC; \
    475 				nfsm_reply(0); \
    476 			} \
    477 		} \
    478 		if (fhlen != 0) { \
    479 			nfsm_dissect(tl, u_int32_t *, NFSX_V3FH); \
    480 			memcpy( (caddr_t)(f), (caddr_t)tl, NFSX_V3FH); \
    481 			if ((nfsd->nd_flag & ND_NFSV3) == 0) \
    482 				nfsm_adv(NFSX_V2FH - NFSX_V3FH); \
    483 		} \
    484 	}
    485 
    486 #define	nfsm_clget \
    487 		if (bp >= be) { \
    488 			if (mp == mb) \
    489 				mp->m_len += bp-bpos; \
    490 			mp = m_get(M_WAIT, MT_DATA); \
    491 			MCLAIM(mp, &nfs_mowner); \
    492 			m_clget(mp, M_WAIT); \
    493 			mp->m_len = NFSMSIZ(mp); \
    494 			mp2->m_next = mp; \
    495 			mp2 = mp; \
    496 			bp = mtod(mp, caddr_t); \
    497 			be = bp+mp->m_len; \
    498 		} \
    499 		tl = (u_int32_t *)bp
    500 
    501 #define	nfsm_srvfillattr(a, f) \
    502 		nfsm_srvfattr(nfsd, (a), (f))
    503 
    504 #define nfsm_srvwcc_data(br, b, ar, a) \
    505 		nfsm_srvwcc(nfsd, (br), (b), (ar), (a), &mb, &bpos)
    506 
    507 #define nfsm_srvpostop_attr(r, a) \
    508 		nfsm_srvpostopattr(nfsd, (r), (a), &mb, &bpos)
    509 
    510 #define nfsm_srvsattr(a) \
    511 		{ nfsm_dissect(tl, u_int32_t *, NFSX_UNSIGNED); \
    512 		if (*tl == nfs_true) { \
    513 			nfsm_dissect(tl, u_int32_t *, NFSX_UNSIGNED); \
    514 			(a)->va_mode = nfstov_mode(*tl); \
    515 		} \
    516 		nfsm_dissect(tl, u_int32_t *, NFSX_UNSIGNED); \
    517 		if (*tl == nfs_true) { \
    518 			nfsm_dissect(tl, u_int32_t *, NFSX_UNSIGNED); \
    519 			(a)->va_uid = fxdr_unsigned(uid_t, *tl); \
    520 		} \
    521 		nfsm_dissect(tl, u_int32_t *, NFSX_UNSIGNED); \
    522 		if (*tl == nfs_true) { \
    523 			nfsm_dissect(tl, u_int32_t *, NFSX_UNSIGNED); \
    524 			(a)->va_gid = fxdr_unsigned(gid_t, *tl); \
    525 		} \
    526 		nfsm_dissect(tl, u_int32_t *, NFSX_UNSIGNED); \
    527 		if (*tl == nfs_true) { \
    528 			nfsm_dissect(tl, u_int32_t *, 2 * NFSX_UNSIGNED); \
    529 			(a)->va_size = fxdr_hyper(tl); \
    530 		} \
    531 		nfsm_dissect(tl, u_int32_t *, NFSX_UNSIGNED); \
    532 		switch (fxdr_unsigned(int, *tl)) { \
    533 		case NFSV3SATTRTIME_TOCLIENT: \
    534 			nfsm_dissect(tl, u_int32_t *, 2 * NFSX_UNSIGNED); \
    535 			fxdr_nfsv3time(tl, &(a)->va_atime); \
    536 			break; \
    537 		case NFSV3SATTRTIME_TOSERVER: \
    538 			(a)->va_atime.tv_sec = time.tv_sec; \
    539 			(a)->va_atime.tv_nsec = time.tv_usec * 1000; \
    540 			(a)->va_vaflags |= VA_UTIMES_NULL; \
    541 			break; \
    542 		}; \
    543 		nfsm_dissect(tl, u_int32_t *, NFSX_UNSIGNED); \
    544 		switch (fxdr_unsigned(int, *tl)) { \
    545 		case NFSV3SATTRTIME_TOCLIENT: \
    546 			nfsm_dissect(tl, u_int32_t *, 2 * NFSX_UNSIGNED); \
    547 			fxdr_nfsv3time(tl, &(a)->va_mtime); \
    548 			(a)->va_vaflags &= ~VA_UTIMES_NULL; \
    549 			break; \
    550 		case NFSV3SATTRTIME_TOSERVER: \
    551 			(a)->va_mtime.tv_sec = time.tv_sec; \
    552 			(a)->va_mtime.tv_nsec = time.tv_usec * 1000; \
    553 			(a)->va_vaflags |= VA_UTIMES_NULL; \
    554 			break; \
    555 		}; }
    556 
    557 #endif
    558