master
  1/*	$NetBSD: nfsm_subs.h,v 1.55.4.1 2023/03/30 11:57:26 martin 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	NFSMADV(m, s)	(m)->m_data += (s)
 54#define	NFSMSIZ(m)	((M_HASCL(m)) ? (m)->m_ext.ext_size : \
 55				(((m)->m_flags & M_PKTHDR) ? MHLEN : MLEN))
 56
 57/*
 58 * NFSv2 can only handle signed 32bit quantities and some clients
 59 * get confused by larger than 16bit block sizes. Limit values
 60 * for better compatibility.
 61 */
 62#define NFS_V2CLAMP32(x) ((x) > INT32_MAX ? INT32_MAX : (int32_t)(x))
 63#define NFS_V2CLAMP16(x) ((x) > INT16_MAX ? INT16_MAX : (int32_t)(x))
 64
 65/*
 66 * Now for the macros that do the simple stuff and call the functions
 67 * for the hard stuff.
 68 * These macros use several vars. declared in nfsm_reqhead and these
 69 * vars. must not be used elsewhere unless you are careful not to corrupt
 70 * them. The vars. starting with pN and tN (N=1,2,3,..) are temporaries
 71 * that may be used so long as the value is not expected to retained
 72 * after a macro.
 73 * I know, this is kind of dorkey, but it makes the actual op functions
 74 * fairly clean and deals with the mess caused by the xdr discriminating
 75 * unions.
 76 */
 77
 78#define	nfsm_build(a,c,s) \
 79		{ if ((s) > M_TRAILINGSPACE(mb)) { \
 80			struct mbuf *mb2; \
 81			mb2 = m_get(M_WAIT, MT_DATA); \
 82			MCLAIM(mb2, &nfs_mowner); \
 83			if ((s) > MLEN) \
 84				panic("build > MLEN"); \
 85			mb->m_next = mb2; \
 86			mb = mb2; \
 87			mb->m_len = 0; \
 88			bpos = mtod(mb, char *); \
 89		} \
 90		(a) = (c)(bpos); \
 91		mb->m_len += (s); \
 92		bpos += (s); }
 93
 94#define nfsm_aligned(p) ALIGNED_POINTER(p,u_int32_t)
 95
 96#define	nfsm_dissect(a, c, s) \
 97		{ t1 = mtod(md, char *) + md->m_len-dpos; \
 98		if (t1 >= (s) && nfsm_aligned(dpos)) { \
 99			(a) = (c)(dpos); \
100			dpos += (s); \
101		} else if ((t1 = nfsm_disct(&md, &dpos, (s), t1, &cp2)) != 0){ \
102			error = t1; \
103			m_freem(mrep); \
104			goto nfsmout; \
105		} else { \
106			(a) = (c)cp2; \
107		} }
108
109#define nfsm_fhtom(n, v3) \
110	      { if (v3) { \
111			t2 = nfsm_rndup((n)->n_fhsize) + NFSX_UNSIGNED; \
112			if (t2 <= M_TRAILINGSPACE(mb)) { \
113				nfsm_build(tl, u_int32_t *, t2); \
114				*tl++ = txdr_unsigned((n)->n_fhsize); \
115				*(tl + ((t2>>2) - 2)) = 0; \
116				memcpy(tl,(n)->n_fhp, (n)->n_fhsize); \
117			} else if ((t2 = nfsm_strtmbuf(&mb, &bpos, \
118				(void *)(n)->n_fhp, (n)->n_fhsize)) != 0) { \
119				error = t2; \
120				m_freem(mreq); \
121				goto nfsmout; \
122			} \
123		} else { \
124			nfsm_build(cp, void *, NFSX_V2FH); \
125			memcpy(cp, (n)->n_fhp, NFSX_V2FH); \
126		} }
127
128#define nfsm_srvfhtom(f, v3) \
129		{ if (v3) { \
130			nfsm_build(tl, u_int32_t *, NFSX_UNSIGNED + \
131			    NFSRVFH_SIZE(f)); \
132			*tl++ = txdr_unsigned(NFSRVFH_SIZE(f)); \
133			memcpy(tl, NFSRVFH_DATA(f), NFSRVFH_SIZE(f)); \
134		} else { \
135			KASSERT(NFSRVFH_SIZE(f) == NFSX_V2FH); \
136			nfsm_build(cp, void *, NFSX_V2FH); \
137			memcpy(cp, NFSRVFH_DATA(f), NFSX_V2FH); \
138		} }
139
140#define nfsm_srvpostop_fh(f) \
141		{ nfsm_build(tl, u_int32_t *, \
142		    2 * NFSX_UNSIGNED + NFSRVFH_SIZE(f)); \
143		*tl++ = nfs_true; \
144		*tl++ = txdr_unsigned(NFSRVFH_SIZE(f)); \
145		memcpy(tl, NFSRVFH_DATA(f), NFSRVFH_SIZE(f)); \
146		}
147
148/*
149 * nfsm_mtofh: dissect a "resulted obj" part of create-like operations
150 * like mkdir.
151 *
152 * for nfsv3, dissect post_op_fh3 and following post_op_attr.
153 * for nfsv2, dissect fhandle and following fattr.
154 *
155 * d: (IN) the vnode of the parent directory.
156 * v: (OUT) the corresponding vnode (we allocate one if needed)
157 * v3: (IN) true for nfsv3.
158 * f: (OUT) true if we got valid filehandle.  always true for nfsv2.
159 */
160
161#define nfsm_mtofh(d, v, v3, f) \
162		{ struct nfsnode *ttnp; nfsfh_t *ttfhp; int ttfhsize; \
163		int hasattr = 0; \
164		if (v3) { \
165			nfsm_dissect(tl, u_int32_t *, NFSX_UNSIGNED); \
166			(f) = fxdr_unsigned(int, *tl); \
167		} else { \
168			(f) = 1; \
169			hasattr = 1; \
170		} \
171		if (f) { \
172			nfsm_getfh(ttfhp, ttfhsize, (v3)); \
173			if ((t1 = nfs_nget((d)->v_mount, ttfhp, ttfhsize, \
174				&ttnp)) != 0) { \
175				error = t1; \
176				m_freem(mrep); \
177				goto nfsmout; \
178			} \
179			(v) = NFSTOV(ttnp); \
180		} \
181		if (v3) { \
182			nfsm_dissect(tl, u_int32_t *, NFSX_UNSIGNED); \
183			if (f) \
184				hasattr = fxdr_unsigned(int, *tl); \
185			else if (fxdr_unsigned(int, *tl)) \
186				nfsm_adv(NFSX_V3FATTR); \
187		} \
188		if (f && hasattr) \
189			nfsm_loadattr((v), (struct vattr *)0, 0); \
190		}
191
192/*
193 * nfsm_getfh: dissect a filehandle.
194 *
195 * f: (OUT) a filehandle.
196 * s: (OUT) size of the filehandle in bytes.
197 * v3: (IN) true if nfsv3.
198 */
199
200#define nfsm_getfh(f, s, v3) \
201		{ if (v3) { \
202			nfsm_dissect(tl, u_int32_t *, NFSX_UNSIGNED); \
203			if (((s) = fxdr_unsigned(int, *tl)) <= 0 || \
204				(s) > NFSX_V3FHMAX) { \
205				m_freem(mrep); \
206				error = EBADRPC; \
207				goto nfsmout; \
208			} \
209		} else \
210			(s) = NFSX_V2FH; \
211		nfsm_dissect((f), nfsfh_t *, nfsm_rndup(s)); }
212
213#define	nfsm_loadattr(v, a, flags) \
214		{ struct vnode *ttvp = (v); \
215		if ((t1 = nfsm_loadattrcache(&ttvp, &md, &dpos, (a), (flags))) \
216		    != 0) { \
217			error = t1; \
218			m_freem(mrep); \
219			goto nfsmout; \
220		} \
221		(v) = ttvp; }
222
223/*
224 * nfsm_postop_attr: process nfsv3 post_op_attr
225 *
226 * dissect post_op_attr.  if we got a one,
227 * call nfsm_loadattrcache to update attribute cache.
228 *
229 * v: (IN/OUT) the corresponding vnode
230 * f: (OUT) true if we got valid attribute
231 * flags: (IN) flags for nfsm_loadattrcache
232 */
233
234#define	nfsm_postop_attr(v, f, flags) \
235		{ struct vnode *ttvp = (v); \
236		nfsm_dissect(tl, u_int32_t *, NFSX_UNSIGNED); \
237		if (((f) = fxdr_unsigned(int, *tl)) != 0) { \
238			if ((t1 = nfsm_loadattrcache(&ttvp, &md, &dpos, \
239				(struct vattr *)0, (flags))) != 0) { \
240				error = t1; \
241				(f) = 0; \
242				m_freem(mrep); \
243				goto nfsmout; \
244			} \
245			(v) = ttvp; \
246		} }
247
248/*
249 * nfsm_wcc_data: process nfsv3 wcc_data
250 *
251 * dissect pre_op_attr and then let nfsm_postop_attr dissect post_op_attr.
252 *
253 * v: (IN/OUT) the corresponding vnode
254 * f: (IN/OUT)
255 *	NFSV3_WCCRATTR	return true if we got valid post_op_attr.
256 *	NFSV3_WCCCHK	return true if pre_op_attr's mtime is the same
257 *			as our n_mtime.  (ie. our cache isn't stale.)
258 * flags: (IN) flags for nfsm_loadattrcache
259 * docheck: (IN) true if timestamp change is expected
260 */
261
262/* Used as (f) for nfsm_wcc_data() */
263#define NFSV3_WCCRATTR	0
264#define NFSV3_WCCCHK	1
265
266#define	nfsm_wcc_data(v, f, flags, docheck) \
267		{ int ttattrf, ttretf = 0, renewctime = 0, renewnctime = 0; \
268		struct timespec ctime, mtime; \
269		struct nfsnode *nfsp = VTONFS(v); \
270		bool haspreopattr = false; \
271		nfsm_dissect(tl, u_int32_t *, NFSX_UNSIGNED); \
272		if (*tl == nfs_true) { \
273			haspreopattr = true; \
274			nfsm_dissect(tl, u_int32_t *, 6 * NFSX_UNSIGNED); \
275			fxdr_nfsv3time(tl + 2, &mtime); \
276			fxdr_nfsv3time(tl + 4, &ctime); \
277			if (nfsp->n_ctime == ctime.tv_sec) \
278				renewctime = 1; \
279			if ((v)->v_type == VDIR) { \
280				if (timespeccmp(&nfsp->n_nctime, &ctime, ==)) \
281					renewnctime = 1; \
282			} \
283			if (f) { \
284				ttretf = timespeccmp(&nfsp->n_mtime, &mtime, ==);\
285			} \
286		} \
287		nfsm_postop_attr((v), ttattrf, (flags)); \
288		nfsp = VTONFS(v); \
289		if (ttattrf) { \
290			if (haspreopattr && \
291			    nfs_check_wccdata(nfsp, &ctime, &mtime, (docheck))) \
292				renewctime = renewnctime = ttretf = 0; \
293			if (renewctime) \
294				nfsp->n_ctime = nfsp->n_vattr->va_ctime.tv_sec; \
295			if (renewnctime) \
296				nfsp->n_nctime = nfsp->n_vattr->va_ctime; \
297		} \
298		if (f) { \
299			(f) = ttretf; \
300		} else { \
301			(f) = ttattrf; \
302		} }
303
304/* If full is true, set all fields, otherwise just set mode and time fields */
305#define nfsm_v3attrbuild(a, full)						\
306		{ if ((a)->va_mode != (mode_t)VNOVAL) {				\
307			nfsm_build(tl, u_int32_t *, 2 * NFSX_UNSIGNED);		\
308			*tl++ = nfs_true;					\
309			*tl = txdr_unsigned((a)->va_mode);			\
310		} else {							\
311			nfsm_build(tl, u_int32_t *, NFSX_UNSIGNED);		\
312			*tl = nfs_false;					\
313		}								\
314		if ((full) && (a)->va_uid != (uid_t)VNOVAL) {			\
315			nfsm_build(tl, u_int32_t *, 2 * NFSX_UNSIGNED);		\
316			*tl++ = nfs_true;					\
317			*tl = txdr_unsigned((a)->va_uid);			\
318		} else {							\
319			nfsm_build(tl, u_int32_t *, NFSX_UNSIGNED);		\
320			*tl = nfs_false;					\
321		}								\
322		if ((full) && (a)->va_gid != (gid_t)VNOVAL) {			\
323			nfsm_build(tl, u_int32_t *, 2 * NFSX_UNSIGNED);		\
324			*tl++ = nfs_true;					\
325			*tl = txdr_unsigned((a)->va_gid);			\
326		} else {							\
327			nfsm_build(tl, u_int32_t *, NFSX_UNSIGNED);		\
328			*tl = nfs_false;					\
329		}								\
330		if ((full) && (a)->va_size != VNOVAL) {				\
331			nfsm_build(tl, u_int32_t *, 3 * NFSX_UNSIGNED);		\
332			*tl++ = nfs_true;					\
333			txdr_hyper((a)->va_size, tl);				\
334		} else {							\
335			nfsm_build(tl, u_int32_t *, NFSX_UNSIGNED);		\
336			*tl = nfs_false;					\
337		}								\
338		if ((a)->va_atime.tv_sec != VNOVAL) {				\
339			if ((a)->va_atime.tv_sec != time_second) {		\
340				nfsm_build(tl, u_int32_t *, 3 * NFSX_UNSIGNED);	\
341				*tl++ = txdr_unsigned(NFSV3SATTRTIME_TOCLIENT);	\
342				txdr_nfsv3time(&(a)->va_atime, tl);		\
343			} else {						\
344				nfsm_build(tl, u_int32_t *, NFSX_UNSIGNED);	\
345				*tl = txdr_unsigned(NFSV3SATTRTIME_TOSERVER);	\
346			}							\
347		} else {							\
348			nfsm_build(tl, u_int32_t *, NFSX_UNSIGNED);		\
349			*tl = txdr_unsigned(NFSV3SATTRTIME_DONTCHANGE);		\
350		}								\
351		if ((a)->va_mtime.tv_sec != VNOVAL) {				\
352			if ((a)->va_mtime.tv_sec != time_second) {		\
353				nfsm_build(tl, u_int32_t *, 3 * NFSX_UNSIGNED);	\
354				*tl++ = txdr_unsigned(NFSV3SATTRTIME_TOCLIENT);	\
355				txdr_nfsv3time(&(a)->va_mtime, tl);		\
356			} else {						\
357				nfsm_build(tl, u_int32_t *, NFSX_UNSIGNED);	\
358				*tl = txdr_unsigned(NFSV3SATTRTIME_TOSERVER);	\
359			}							\
360		} else {							\
361			nfsm_build(tl, u_int32_t *, NFSX_UNSIGNED);		\
362			*tl = txdr_unsigned(NFSV3SATTRTIME_DONTCHANGE);		\
363		}								\
364		}
365
366
367#define	nfsm_strsiz(s,m) \
368		{ nfsm_dissect(tl,uint32_t *,NFSX_UNSIGNED); \
369		if ((uint32_t)((s) = fxdr_unsigned(uint32_t,*tl)) > (m)) { \
370			m_freem(mrep); \
371			error = EBADRPC; \
372			goto nfsmout; \
373		} }
374
375#define	nfsm_srvnamesiz(s) \
376		{ nfsm_dissect(tl,uint32_t *,NFSX_UNSIGNED); \
377		if ((uint32_t)((s) = fxdr_unsigned(uint32_t,*tl)) > \
378		    NFS_MAXNAMLEN) \
379			error = NFSERR_NAMETOL; \
380		if (error) \
381			nfsm_reply(0); \
382		}
383
384#define nfsm_mtouio(p,s) \
385		if ((s) > 0 && \
386		   (t1 = nfsm_mbuftouio(&md,(p),(s),&dpos)) != 0) { \
387			error = t1; \
388			m_freem(mrep); \
389			goto nfsmout; \
390		}
391
392#define nfsm_uiotom(p,s) \
393		if ((t1 = nfsm_uiotombuf((p),&mb,(s),&bpos)) != 0) { \
394			error = t1; \
395			m_freem(mreq); \
396			goto nfsmout; \
397		}
398
399#define	nfsm_reqhead(n,a,s) \
400		mb = mreq = nfsm_reqh((n),(a),(s),&bpos)
401
402#define nfsm_reqdone	m_freem(mrep); \
403		nfsmout:
404
405#define nfsm_rndup(a)	(((a)+3)&(~0x3))
406#define nfsm_padlen(a)	(nfsm_rndup(a) - (a))
407
408#define	nfsm_request1(v, t, p, c, rexmitp)	\
409		if ((error = nfs_request((v), mreq, (t), (p), \
410		   (c), &mrep, &md, &dpos, (rexmitp))) != 0) { \
411			if (error & NFSERR_RETERR) \
412				error &= ~NFSERR_RETERR; \
413			else \
414				goto nfsmout; \
415		}
416
417#define	nfsm_request(v, t, p, c)	nfsm_request1((v), (t), (p), (c), NULL)
418
419#define	nfsm_strtom(a,s,m) \
420		if ((s) > (m)) { \
421			m_freem(mreq); \
422			error = ENAMETOOLONG; \
423			goto nfsmout; \
424		} \
425		t2 = nfsm_rndup(s)+NFSX_UNSIGNED; \
426		if (t2 <= M_TRAILINGSPACE(mb)) { \
427			nfsm_build(tl,u_int32_t *,t2); \
428			*tl++ = txdr_unsigned(s); \
429			*(tl+((t2>>2)-2)) = 0; \
430			memcpy(tl, (const char *)(a), (s)); \
431		} else if ((t2 = nfsm_strtmbuf(&mb, &bpos, (a), (s))) != 0) { \
432			error = t2; \
433			m_freem(mreq); \
434			goto nfsmout; \
435		}
436
437#define	nfsm_srvdone \
438		nfsmout: \
439		return(error)
440
441#define	nfsm_reply(s) \
442		{ \
443		nfsd->nd_repstat = error; \
444		if (error && !(nfsd->nd_flag & ND_NFSV3)) \
445		   (void) nfs_rephead(0, nfsd, slp, error, cache, &frev, \
446			mrq, &mb, &bpos); \
447		else \
448		   (void) nfs_rephead((s), nfsd, slp, error, cache, &frev, \
449			mrq, &mb, &bpos); \
450		if (mrep != NULL) { \
451			m_freem(mrep); \
452			mrep = NULL; \
453		} \
454		mreq = *mrq; \
455		if (error && (!(nfsd->nd_flag & ND_NFSV3) || \
456			error == EBADRPC)) {\
457			error = 0; \
458			goto nfsmout; \
459			} \
460		}
461
462#define	nfsm_writereply(s, v3) \
463		{ \
464		nfsd->nd_repstat = error; \
465		if (error && !(v3)) \
466		   (void) nfs_rephead(0, nfsd, slp, error, cache, &frev, \
467			&mreq, &mb, &bpos); \
468		else \
469		   (void) nfs_rephead((s), nfsd, slp, error, cache, &frev, \
470			&mreq, &mb, &bpos); \
471		}
472
473#define	nfsm_adv(s) \
474		{ t1 = mtod(md, char *) + md->m_len - dpos; \
475		if (t1 >= (s)) { \
476			dpos += (s); \
477		} else if ((t1 = nfs_adv(&md, &dpos, (s), t1)) != 0) { \
478			error = t1; \
479			m_freem(mrep); \
480			goto nfsmout; \
481		} }
482
483#define nfsm_srvmtofh(nsfh) \
484	{ uint32_t fhlen = NFSX_V3FH; \
485		if (nfsd->nd_flag & ND_NFSV3) { \
486			nfsm_dissect(tl, uint32_t *, NFSX_UNSIGNED); \
487			fhlen = fxdr_unsigned(uint32_t, *tl); \
488			CTASSERT(NFSX_V3FHMAX <= FHANDLE_SIZE_MAX); \
489			if (fhlen > NFSX_V3FHMAX || \
490			    (fhlen < FHANDLE_SIZE_MIN && fhlen > 0)) { \
491				error = EBADRPC; \
492				nfsm_reply(0); \
493			} \
494		} else { \
495			CTASSERT(NFSX_V2FH >= FHANDLE_SIZE_MIN); \
496			fhlen = NFSX_V2FH; \
497		} \
498		(nsfh)->nsfh_size = fhlen; \
499		if (fhlen != 0) { \
500			KASSERT(fhlen >= FHANDLE_SIZE_MIN); \
501			KASSERT(fhlen <= FHANDLE_SIZE_MAX); \
502			nfsm_dissect(tl, u_int32_t *, fhlen); \
503			memcpy(NFSRVFH_DATA(nsfh), tl, fhlen); \
504		} \
505	}
506
507#define	nfsm_clget \
508		if (bp >= be) { \
509			if (mp == mb) \
510				mp->m_len += bp-bpos; \
511			mp = m_get(M_WAIT, MT_DATA); \
512			MCLAIM(mp, &nfs_mowner); \
513			m_clget(mp, M_WAIT); \
514			mp->m_len = NFSMSIZ(mp); \
515			mp2->m_next = mp; \
516			mp2 = mp; \
517			bp = mtod(mp, char *); \
518			be = bp+mp->m_len; \
519		} \
520		tl = (u_int32_t *)bp
521
522#define	nfsm_srvfillattr(a, f) \
523		nfsm_srvfattr(nfsd, (a), (f))
524
525#define nfsm_srvwcc_data(br, b, ar, a) \
526		nfsm_srvwcc(nfsd, (br), (b), (ar), (a), &mb, &bpos)
527
528#define nfsm_srvpostop_attr(r, a) \
529		nfsm_srvpostopattr(nfsd, (r), (a), &mb, &bpos)
530
531#define nfsm_srvsattr(a) \
532		{ \
533		nfsm_dissect(tl, u_int32_t *, NFSX_UNSIGNED); \
534		if (*tl == nfs_true) { \
535			nfsm_dissect(tl, u_int32_t *, NFSX_UNSIGNED); \
536			(a)->va_mode = nfstov_mode(*tl); \
537		} \
538		nfsm_dissect(tl, u_int32_t *, NFSX_UNSIGNED); \
539		if (*tl == nfs_true) { \
540			nfsm_dissect(tl, u_int32_t *, NFSX_UNSIGNED); \
541			(a)->va_uid = fxdr_unsigned(uid_t, *tl); \
542		} \
543		nfsm_dissect(tl, u_int32_t *, NFSX_UNSIGNED); \
544		if (*tl == nfs_true) { \
545			nfsm_dissect(tl, u_int32_t *, NFSX_UNSIGNED); \
546			(a)->va_gid = fxdr_unsigned(gid_t, *tl); \
547		} \
548		nfsm_dissect(tl, u_int32_t *, NFSX_UNSIGNED); \
549		if (*tl == nfs_true) { \
550			nfsm_dissect(tl, u_int32_t *, 2 * NFSX_UNSIGNED); \
551			(a)->va_size = fxdr_hyper(tl); \
552		} \
553		nfsm_dissect(tl, u_int32_t *, NFSX_UNSIGNED); \
554		switch (fxdr_unsigned(int, *tl)) { \
555		case NFSV3SATTRTIME_TOCLIENT: \
556			nfsm_dissect(tl, u_int32_t *, 2 * NFSX_UNSIGNED); \
557			fxdr_nfsv3time(tl, &(a)->va_atime); \
558			break; \
559		case NFSV3SATTRTIME_TOSERVER: \
560			getnanotime(&(a)->va_atime); \
561			(a)->va_vaflags |= VA_UTIMES_NULL; \
562			break; \
563		}; \
564		nfsm_dissect(tl, u_int32_t *, NFSX_UNSIGNED); \
565		switch (fxdr_unsigned(int, *tl)) { \
566		case NFSV3SATTRTIME_TOCLIENT: \
567			nfsm_dissect(tl, u_int32_t *, 2 * NFSX_UNSIGNED); \
568			fxdr_nfsv3time(tl, &(a)->va_mtime); \
569			(a)->va_vaflags &= ~VA_UTIMES_NULL; \
570			break; \
571		case NFSV3SATTRTIME_TOSERVER: \
572			getnanotime(&(a)->va_mtime); \
573			(a)->va_vaflags |= VA_UTIMES_NULL; \
574			break; \
575		}; }
576
577#endif