nfsm_subs.h revision 1.52
1/*	$NetBSD: nfsm_subs.h,v 1.52 2013/09/14 21:48:49 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 * Now for the macros that do the simple stuff and call the functions
59 * for the hard stuff.
60 * These macros use several vars. declared in nfsm_reqhead and these
61 * vars. must not be used elsewhere unless you are careful not to corrupt
62 * them. The vars. starting with pN and tN (N=1,2,3,..) are temporaries
63 * that may be used so long as the value is not expected to retained
64 * after a macro.
65 * I know, this is kind of dorkey, but it makes the actual op functions
66 * fairly clean and deals with the mess caused by the xdr discriminating
67 * unions.
68 */
69
70#define	nfsm_build(a,c,s) \
71		{ if ((s) > M_TRAILINGSPACE(mb)) { \
72			struct mbuf *mb2; \
73			mb2 = m_get(M_WAIT, MT_DATA); \
74			MCLAIM(mb2, &nfs_mowner); \
75			if ((s) > MLEN) \
76				panic("build > MLEN"); \
77			mb->m_next = mb2; \
78			mb = mb2; \
79			mb->m_len = 0; \
80			bpos = mtod(mb, char *); \
81		} \
82		(a) = (c)(bpos); \
83		mb->m_len += (s); \
84		bpos += (s); }
85
86#define nfsm_aligned(p) ALIGNED_POINTER(p,u_int32_t)
87
88#define	nfsm_dissect(a, c, s) \
89		{ t1 = mtod(md, char *) + md->m_len-dpos; \
90		if (t1 >= (s) && nfsm_aligned(dpos)) { \
91			(a) = (c)(dpos); \
92			dpos += (s); \
93		} else if ((t1 = nfsm_disct(&md, &dpos, (s), t1, &cp2)) != 0){ \
94			error = t1; \
95			m_freem(mrep); \
96			goto nfsmout; \
97		} else { \
98			(a) = (c)cp2; \
99		} }
100
101#define nfsm_fhtom(n, v3) \
102	      { if (v3) { \
103			t2 = nfsm_rndup((n)->n_fhsize) + NFSX_UNSIGNED; \
104			if (t2 <= M_TRAILINGSPACE(mb)) { \
105				nfsm_build(tl, u_int32_t *, t2); \
106				*tl++ = txdr_unsigned((n)->n_fhsize); \
107				*(tl + ((t2>>2) - 2)) = 0; \
108				memcpy(tl,(n)->n_fhp, (n)->n_fhsize); \
109			} else if ((t2 = nfsm_strtmbuf(&mb, &bpos, \
110				(void *)(n)->n_fhp, (n)->n_fhsize)) != 0) { \
111				error = t2; \
112				m_freem(mreq); \
113				goto nfsmout; \
114			} \
115		} else { \
116			nfsm_build(cp, void *, NFSX_V2FH); \
117			memcpy(cp, (n)->n_fhp, NFSX_V2FH); \
118		} }
119
120#define nfsm_srvfhtom(f, v3) \
121		{ if (v3) { \
122			nfsm_build(tl, u_int32_t *, NFSX_UNSIGNED + \
123			    NFSRVFH_SIZE(f)); \
124			*tl++ = txdr_unsigned(NFSRVFH_SIZE(f)); \
125			memcpy(tl, NFSRVFH_DATA(f), NFSRVFH_SIZE(f)); \
126		} else { \
127			KASSERT(NFSRVFH_SIZE(f) == NFSX_V2FH); \
128			nfsm_build(cp, void *, NFSX_V2FH); \
129			memcpy(cp, NFSRVFH_DATA(f), NFSX_V2FH); \
130		} }
131
132#define nfsm_srvpostop_fh(f) \
133		{ nfsm_build(tl, u_int32_t *, \
134		    2 * NFSX_UNSIGNED + NFSRVFH_SIZE(f)); \
135		*tl++ = nfs_true; \
136		*tl++ = txdr_unsigned(NFSRVFH_SIZE(f)); \
137		memcpy(tl, NFSRVFH_DATA(f), NFSRVFH_SIZE(f)); \
138		}
139
140/*
141 * nfsm_mtofh: dissect a "resulted obj" part of create-like operations
142 * like mkdir.
143 *
144 * for nfsv3, dissect post_op_fh3 and following post_op_attr.
145 * for nfsv2, dissect fhandle and following fattr.
146 *
147 * d: (IN) the vnode of the parent directry.
148 * v: (OUT) the corresponding vnode (we allocate one if needed)
149 * v3: (IN) true for nfsv3.
150 * f: (OUT) true if we got valid filehandle.  always true for nfsv2.
151 */
152
153#define nfsm_mtofh(d, v, v3, f) \
154		{ struct nfsnode *ttnp; nfsfh_t *ttfhp; int ttfhsize; \
155		int hasattr = 0; \
156		if (v3) { \
157			nfsm_dissect(tl, u_int32_t *, NFSX_UNSIGNED); \
158			(f) = fxdr_unsigned(int, *tl); \
159		} else { \
160			(f) = 1; \
161			hasattr = 1; \
162		} \
163		if (f) { \
164			nfsm_getfh(ttfhp, ttfhsize, (v3)); \
165			if ((t1 = nfs_nget((d)->v_mount, ttfhp, ttfhsize, \
166				&ttnp)) != 0) { \
167				error = t1; \
168				m_freem(mrep); \
169				goto nfsmout; \
170			} \
171			(v) = NFSTOV(ttnp); \
172		} \
173		if (v3) { \
174			nfsm_dissect(tl, u_int32_t *, NFSX_UNSIGNED); \
175			if (f) \
176				hasattr = fxdr_unsigned(int, *tl); \
177			else if (fxdr_unsigned(int, *tl)) \
178				nfsm_adv(NFSX_V3FATTR); \
179		} \
180		if (f && hasattr) \
181			nfsm_loadattr((v), (struct vattr *)0, 0); \
182		}
183
184/*
185 * nfsm_getfh: dissect a filehandle.
186 *
187 * f: (OUT) a filehandle.
188 * s: (OUT) size of the filehandle in bytes.
189 * v3: (IN) true if nfsv3.
190 */
191
192#define nfsm_getfh(f, s, v3) \
193		{ if (v3) { \
194			nfsm_dissect(tl, u_int32_t *, NFSX_UNSIGNED); \
195			if (((s) = fxdr_unsigned(int, *tl)) <= 0 || \
196				(s) > NFSX_V3FHMAX) { \
197				m_freem(mrep); \
198				error = EBADRPC; \
199				goto nfsmout; \
200			} \
201		} else \
202			(s) = NFSX_V2FH; \
203		nfsm_dissect((f), nfsfh_t *, nfsm_rndup(s)); }
204
205#define	nfsm_loadattr(v, a, flags) \
206		{ struct vnode *ttvp = (v); \
207		if ((t1 = nfsm_loadattrcache(&ttvp, &md, &dpos, (a), (flags))) \
208		    != 0) { \
209			error = t1; \
210			m_freem(mrep); \
211			goto nfsmout; \
212		} \
213		(v) = ttvp; }
214
215/*
216 * nfsm_postop_attr: process nfsv3 post_op_attr
217 *
218 * dissect post_op_attr.  if we got a one,
219 * call nfsm_loadattrcache to update attribute cache.
220 *
221 * v: (IN/OUT) the corresponding vnode
222 * f: (OUT) true if we got valid attribute
223 * flags: (IN) flags for nfsm_loadattrcache
224 */
225
226#define	nfsm_postop_attr(v, f, flags) \
227		{ struct vnode *ttvp = (v); \
228		nfsm_dissect(tl, u_int32_t *, NFSX_UNSIGNED); \
229		if (((f) = fxdr_unsigned(int, *tl)) != 0) { \
230			if ((t1 = nfsm_loadattrcache(&ttvp, &md, &dpos, \
231				(struct vattr *)0, (flags))) != 0) { \
232				error = t1; \
233				(f) = 0; \
234				m_freem(mrep); \
235				goto nfsmout; \
236			} \
237			(v) = ttvp; \
238		} }
239
240/*
241 * nfsm_wcc_data: process nfsv3 wcc_data
242 *
243 * dissect pre_op_attr and then let nfsm_postop_attr dissect post_op_attr.
244 *
245 * v: (IN/OUT) the corresponding vnode
246 * f: (IN/OUT)
247 *	NFSV3_WCCRATTR	return true if we got valid post_op_attr.
248 *	NFSV3_WCCCHK	return true if pre_op_attr's mtime is the same
249 *			as our n_mtime.  (ie. our cache isn't stale.)
250 * flags: (IN) flags for nfsm_loadattrcache
251 * docheck: (IN) true if timestamp change is expected
252 */
253
254/* Used as (f) for nfsm_wcc_data() */
255#define NFSV3_WCCRATTR	0
256#define NFSV3_WCCCHK	1
257
258#if __GNUC_PREREQ__(4, 8)
259/*
260 * With all the macros in here, it is hard to track set-but-not-used cases
261 * and avoid them without cluttering the code.
262 */
263_Pragma("GCC diagnostic ignored \"-Wunused-but-set-variable\"")
264#endif
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 (((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 (((s) = fxdr_unsigned(uint32_t,*tl)) > NFS_MAXNAMLEN) \
378			error = NFSERR_NAMETOL; \
379		if (error) \
380			nfsm_reply(0); \
381		}
382
383#define nfsm_mtouio(p,s) \
384		if ((s) > 0 && \
385		   (t1 = nfsm_mbuftouio(&md,(p),(s),&dpos)) != 0) { \
386			error = t1; \
387			m_freem(mrep); \
388			goto nfsmout; \
389		}
390
391#define nfsm_uiotom(p,s) \
392		if ((t1 = nfsm_uiotombuf((p),&mb,(s),&bpos)) != 0) { \
393			error = t1; \
394			m_freem(mreq); \
395			goto nfsmout; \
396		}
397
398#define	nfsm_reqhead(n,a,s) \
399		mb = mreq = nfsm_reqh((n),(a),(s),&bpos)
400
401#define nfsm_reqdone	m_freem(mrep); \
402		nfsmout:
403
404#define nfsm_rndup(a)	(((a)+3)&(~0x3))
405#define nfsm_padlen(a)	(nfsm_rndup(a) - (a))
406
407#define	nfsm_request1(v, t, p, c, rexmitp)	\
408		if ((error = nfs_request((v), mreq, (t), (p), \
409		   (c), &mrep, &md, &dpos, (rexmitp))) != 0) { \
410			if (error & NFSERR_RETERR) \
411				error &= ~NFSERR_RETERR; \
412			else \
413				goto nfsmout; \
414		}
415
416#define	nfsm_request(v, t, p, c)	nfsm_request1((v), (t), (p), (c), NULL)
417
418#define	nfsm_strtom(a,s,m) \
419		if ((s) > (m)) { \
420			m_freem(mreq); \
421			error = ENAMETOOLONG; \
422			goto nfsmout; \
423		} \
424		t2 = nfsm_rndup(s)+NFSX_UNSIGNED; \
425		if (t2 <= M_TRAILINGSPACE(mb)) { \
426			nfsm_build(tl,u_int32_t *,t2); \
427			*tl++ = txdr_unsigned(s); \
428			*(tl+((t2>>2)-2)) = 0; \
429			memcpy(tl, (const char *)(a), (s)); \
430		} else if ((t2 = nfsm_strtmbuf(&mb, &bpos, (a), (s))) != 0) { \
431			error = t2; \
432			m_freem(mreq); \
433			goto nfsmout; \
434		}
435
436#define	nfsm_srvdone \
437		nfsmout: \
438		return(error)
439
440#define	nfsm_reply(s) \
441		{ \
442		nfsd->nd_repstat = error; \
443		if (error && !(nfsd->nd_flag & ND_NFSV3)) \
444		   (void) nfs_rephead(0, nfsd, slp, error, cache, &frev, \
445			mrq, &mb, &bpos); \
446		else \
447		   (void) nfs_rephead((s), nfsd, slp, error, cache, &frev, \
448			mrq, &mb, &bpos); \
449		if (mrep != NULL) { \
450			m_freem(mrep); \
451			mrep = NULL; \
452		} \
453		mreq = *mrq; \
454		if (error && (!(nfsd->nd_flag & ND_NFSV3) || \
455			error == EBADRPC)) {\
456			error = 0; \
457			goto nfsmout; \
458			} \
459		}
460
461#define	nfsm_writereply(s, v3) \
462		{ \
463		nfsd->nd_repstat = error; \
464		if (error && !(v3)) \
465		   (void) nfs_rephead(0, nfsd, slp, error, cache, &frev, \
466			&mreq, &mb, &bpos); \
467		else \
468		   (void) nfs_rephead((s), nfsd, slp, error, cache, &frev, \
469			&mreq, &mb, &bpos); \
470		}
471
472#define	nfsm_adv(s) \
473		{ t1 = mtod(md, char *) + md->m_len - dpos; \
474		if (t1 >= (s)) { \
475			dpos += (s); \
476		} else if ((t1 = nfs_adv(&md, &dpos, (s), t1)) != 0) { \
477			error = t1; \
478			m_freem(mrep); \
479			goto nfsmout; \
480		} }
481
482#define nfsm_srvmtofh(nsfh) \
483	{ int fhlen = NFSX_V3FH; \
484		if (nfsd->nd_flag & ND_NFSV3) { \
485			nfsm_dissect(tl, u_int32_t *, NFSX_UNSIGNED); \
486			fhlen = fxdr_unsigned(int, *tl); \
487			if (fhlen > NFSX_V3FHMAX || \
488			    (fhlen < FHANDLE_SIZE_MIN && fhlen > 0)) { \
489				error = EBADRPC; \
490				nfsm_reply(0); \
491			} \
492		} else { \
493			fhlen = NFSX_V2FH; \
494		} \
495		(nsfh)->nsfh_size = fhlen; \
496		if (fhlen != 0) { \
497			nfsm_dissect(tl, u_int32_t *, fhlen); \
498			memcpy(NFSRVFH_DATA(nsfh), tl, fhlen); \
499		} \
500	}
501
502#define	nfsm_clget \
503		if (bp >= be) { \
504			if (mp == mb) \
505				mp->m_len += bp-bpos; \
506			mp = m_get(M_WAIT, MT_DATA); \
507			MCLAIM(mp, &nfs_mowner); \
508			m_clget(mp, M_WAIT); \
509			mp->m_len = NFSMSIZ(mp); \
510			mp2->m_next = mp; \
511			mp2 = mp; \
512			bp = mtod(mp, char *); \
513			be = bp+mp->m_len; \
514		} \
515		tl = (u_int32_t *)bp
516
517#define	nfsm_srvfillattr(a, f) \
518		nfsm_srvfattr(nfsd, (a), (f))
519
520#define nfsm_srvwcc_data(br, b, ar, a) \
521		nfsm_srvwcc(nfsd, (br), (b), (ar), (a), &mb, &bpos)
522
523#define nfsm_srvpostop_attr(r, a) \
524		nfsm_srvpostopattr(nfsd, (r), (a), &mb, &bpos)
525
526#define nfsm_srvsattr(a) \
527		{ \
528		nfsm_dissect(tl, u_int32_t *, NFSX_UNSIGNED); \
529		if (*tl == nfs_true) { \
530			nfsm_dissect(tl, u_int32_t *, NFSX_UNSIGNED); \
531			(a)->va_mode = nfstov_mode(*tl); \
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_uid = fxdr_unsigned(uid_t, *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_gid = fxdr_unsigned(gid_t, *tl); \
542		} \
543		nfsm_dissect(tl, u_int32_t *, NFSX_UNSIGNED); \
544		if (*tl == nfs_true) { \
545			nfsm_dissect(tl, u_int32_t *, 2 * NFSX_UNSIGNED); \
546			(a)->va_size = fxdr_hyper(tl); \
547		} \
548		nfsm_dissect(tl, u_int32_t *, NFSX_UNSIGNED); \
549		switch (fxdr_unsigned(int, *tl)) { \
550		case NFSV3SATTRTIME_TOCLIENT: \
551			nfsm_dissect(tl, u_int32_t *, 2 * NFSX_UNSIGNED); \
552			fxdr_nfsv3time(tl, &(a)->va_atime); \
553			break; \
554		case NFSV3SATTRTIME_TOSERVER: \
555			getnanotime(&(a)->va_atime); \
556			(a)->va_vaflags |= VA_UTIMES_NULL; \
557			break; \
558		}; \
559		nfsm_dissect(tl, u_int32_t *, NFSX_UNSIGNED); \
560		switch (fxdr_unsigned(int, *tl)) { \
561		case NFSV3SATTRTIME_TOCLIENT: \
562			nfsm_dissect(tl, u_int32_t *, 2 * NFSX_UNSIGNED); \
563			fxdr_nfsv3time(tl, &(a)->va_mtime); \
564			(a)->va_vaflags &= ~VA_UTIMES_NULL; \
565			break; \
566		case NFSV3SATTRTIME_TOSERVER: \
567			getnanotime(&(a)->va_mtime); \
568			(a)->va_vaflags |= VA_UTIMES_NULL; \
569			break; \
570		}; }
571
572#endif
573