nfs_common.h revision 36503
11541Srgrimes/*
21541Srgrimes * Copyright (c) 1989, 1993
31541Srgrimes *	The Regents of the University of California.  All rights reserved.
41541Srgrimes *
51541Srgrimes * This code is derived from software contributed to Berkeley by
61541Srgrimes * Rick Macklem at The University of Guelph.
71541Srgrimes *
81541Srgrimes * Redistribution and use in source and binary forms, with or without
91541Srgrimes * modification, are permitted provided that the following conditions
101541Srgrimes * are met:
111541Srgrimes * 1. Redistributions of source code must retain the above copyright
121541Srgrimes *    notice, this list of conditions and the following disclaimer.
131541Srgrimes * 2. Redistributions in binary form must reproduce the above copyright
141541Srgrimes *    notice, this list of conditions and the following disclaimer in the
151541Srgrimes *    documentation and/or other materials provided with the distribution.
161541Srgrimes * 3. All advertising materials mentioning features or use of this software
171541Srgrimes *    must display the following acknowledgement:
181541Srgrimes *	This product includes software developed by the University of
191541Srgrimes *	California, Berkeley and its contributors.
201541Srgrimes * 4. Neither the name of the University nor the names of its contributors
211541Srgrimes *    may be used to endorse or promote products derived from this software
221541Srgrimes *    without specific prior written permission.
231541Srgrimes *
241541Srgrimes * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
251541Srgrimes * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
261541Srgrimes * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
271541Srgrimes * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
281541Srgrimes * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
291541Srgrimes * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
301541Srgrimes * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
311541Srgrimes * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
321541Srgrimes * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
331541Srgrimes * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
341541Srgrimes * SUCH DAMAGE.
351541Srgrimes *
3622521Sdyson *	@(#)nfsm_subs.h	8.2 (Berkeley) 3/30/95
3736503Speter * $Id: nfsm_subs.h,v 1.16 1998/05/16 15:11:24 bde Exp $
381541Srgrimes */
391541Srgrimes
4022521Sdyson
412175Spaul#ifndef _NFS_NFSM_SUBS_H_
422175Spaul#define _NFS_NFSM_SUBS_H_
432175Spaul
4433054Sbdestruct ucred;
4533054Sbdestruct vnode;
469336Sdfr
471541Srgrimes/*
481541Srgrimes * These macros do strange and peculiar things to mbuf chains for
491541Srgrimes * the assistance of the nfs code. To attempt to use them for any
501541Srgrimes * other purpose will be dangerous. (they make weird assumptions)
511541Srgrimes */
521541Srgrimes
531541Srgrimes/*
541541Srgrimes * First define what the actual subs. return
551541Srgrimes */
5610222Sdfrstruct mbuf *nfsm_reqh __P((struct vnode *vp, u_long procid, int hsiz,
5710222Sdfr			    caddr_t *bposp));
5810222Sdfrstruct mbuf *nfsm_rpchead __P((struct ucred *cr, int nmflag, int procid,
5910222Sdfr			       int auth_type, int auth_len, char *auth_str,
6010222Sdfr			       int verf_len, char *verf_str,
6110222Sdfr			       struct mbuf *mrest, int mrest_len,
6210222Sdfr			       struct mbuf **mbp, u_long *xidp));
631541Srgrimes
641541Srgrimes#define	M_HASCL(m)	((m)->m_flags & M_EXT)
651541Srgrimes#define	NFSMINOFF(m) \
661541Srgrimes		if (M_HASCL(m)) \
671541Srgrimes			(m)->m_data = (m)->m_ext.ext_buf; \
681541Srgrimes		else if ((m)->m_flags & M_PKTHDR) \
691541Srgrimes			(m)->m_data = (m)->m_pktdat; \
701541Srgrimes		else \
711541Srgrimes			(m)->m_data = (m)->m_dat
721541Srgrimes#define	NFSMADV(m, s)	(m)->m_data += (s)
731541Srgrimes#define	NFSMSIZ(m)	((M_HASCL(m))?MCLBYTES: \
741541Srgrimes				(((m)->m_flags & M_PKTHDR)?MHLEN:MLEN))
751541Srgrimes
761541Srgrimes/*
771541Srgrimes * Now for the macros that do the simple stuff and call the functions
781541Srgrimes * for the hard stuff.
791541Srgrimes * These macros use several vars. declared in nfsm_reqhead and these
801541Srgrimes * vars. must not be used elsewhere unless you are careful not to corrupt
811541Srgrimes * them. The vars. starting with pN and tN (N=1,2,3,..) are temporaries
821541Srgrimes * that may be used so long as the value is not expected to retained
831541Srgrimes * after a macro.
841541Srgrimes * I know, this is kind of dorkey, but it makes the actual op functions
851541Srgrimes * fairly clean and deals with the mess caused by the xdr discriminating
861541Srgrimes * unions.
871541Srgrimes */
881541Srgrimes
891541Srgrimes#define	nfsm_build(a,c,s) \
901541Srgrimes		{ if ((s) > M_TRAILINGSPACE(mb)) { \
911541Srgrimes			MGET(mb2, M_WAIT, MT_DATA); \
921541Srgrimes			if ((s) > MLEN) \
931541Srgrimes				panic("build > MLEN"); \
941541Srgrimes			mb->m_next = mb2; \
951541Srgrimes			mb = mb2; \
961541Srgrimes			mb->m_len = 0; \
971541Srgrimes			bpos = mtod(mb, caddr_t); \
981541Srgrimes		} \
991541Srgrimes		(a) = (c)(bpos); \
1001541Srgrimes		mb->m_len += (s); \
1011541Srgrimes		bpos += (s); }
1021541Srgrimes
1039336Sdfr#define	nfsm_dissect(a, c, s) \
1041541Srgrimes		{ t1 = mtod(md, caddr_t)+md->m_len-dpos; \
1051541Srgrimes		if (t1 >= (s)) { \
1061541Srgrimes			(a) = (c)(dpos); \
1071541Srgrimes			dpos += (s); \
10836503Speter		} else if ((t1 = nfsm_disct(&md, &dpos, (s), t1, &cp2)) != 0){ \
1099336Sdfr			error = t1; \
1109336Sdfr			m_freem(mrep); \
1119336Sdfr			goto nfsmout; \
1121541Srgrimes		} else { \
1139336Sdfr			(a) = (c)cp2; \
1149336Sdfr		} }
1159336Sdfr
1169336Sdfr#define nfsm_fhtom(v, v3) \
1179336Sdfr	      { if (v3) { \
1189336Sdfr			t2 = nfsm_rndup(VTONFS(v)->n_fhsize) + NFSX_UNSIGNED; \
1199336Sdfr			if (t2 <= M_TRAILINGSPACE(mb)) { \
1209336Sdfr				nfsm_build(tl, u_long *, t2); \
1219336Sdfr				*tl++ = txdr_unsigned(VTONFS(v)->n_fhsize); \
1229336Sdfr				*(tl + ((t2>>2) - 2)) = 0; \
1239336Sdfr				bcopy((caddr_t)VTONFS(v)->n_fhp,(caddr_t)tl, \
1249336Sdfr					VTONFS(v)->n_fhsize); \
12536503Speter			} else if ((t2 = nfsm_strtmbuf(&mb, &bpos, \
12636503Speter				(caddr_t)VTONFS(v)->n_fhp, \
12736503Speter				VTONFS(v)->n_fhsize)) != 0) { \
1289336Sdfr				error = t2; \
1299336Sdfr				m_freem(mreq); \
1303305Sphk				goto nfsmout; \
1313305Sphk			} \
1329336Sdfr		} else { \
1339336Sdfr			nfsm_build(cp, caddr_t, NFSX_V2FH); \
1349336Sdfr			bcopy((caddr_t)VTONFS(v)->n_fhp, cp, NFSX_V2FH); \
1351541Srgrimes		} }
1361541Srgrimes
1379336Sdfr#define nfsm_srvfhtom(f, v3) \
1389336Sdfr		{ if (v3) { \
1399336Sdfr			nfsm_build(tl, u_long *, NFSX_UNSIGNED + NFSX_V3FH); \
1409336Sdfr			*tl++ = txdr_unsigned(NFSX_V3FH); \
1419336Sdfr			bcopy((caddr_t)(f), (caddr_t)tl, NFSX_V3FH); \
1429336Sdfr		} else { \
1439336Sdfr			nfsm_build(cp, caddr_t, NFSX_V2FH); \
1449336Sdfr			bcopy((caddr_t)(f), cp, NFSX_V2FH); \
1459336Sdfr		} }
1461541Srgrimes
1479336Sdfr#define nfsm_srvpostop_fh(f) \
1489336Sdfr		{ nfsm_build(tl, u_long *, 2 * NFSX_UNSIGNED + NFSX_V3FH); \
1499336Sdfr		*tl++ = nfs_true; \
1509336Sdfr		*tl++ = txdr_unsigned(NFSX_V3FH); \
1519336Sdfr		bcopy((caddr_t)(f), (caddr_t)tl, NFSX_V3FH); \
1529336Sdfr		}
1531541Srgrimes
1549336Sdfr#define nfsm_mtofh(d, v, v3, f) \
1559336Sdfr		{ struct nfsnode *ttnp; nfsfh_t *ttfhp; int ttfhsize; \
1569336Sdfr		if (v3) { \
1579336Sdfr			nfsm_dissect(tl, u_long *, NFSX_UNSIGNED); \
1589336Sdfr			(f) = fxdr_unsigned(int, *tl); \
1599336Sdfr		} else \
1609336Sdfr			(f) = 1; \
1619336Sdfr		if (f) { \
1629336Sdfr			nfsm_getfh(ttfhp, ttfhsize, (v3)); \
16336503Speter			if ((t1 = nfs_nget((d)->v_mount, ttfhp, ttfhsize, \
16436503Speter				&ttnp)) != 0) { \
1659336Sdfr				error = t1; \
1669336Sdfr				m_freem(mrep); \
1679336Sdfr				goto nfsmout; \
1689336Sdfr			} \
1699336Sdfr			(v) = NFSTOV(ttnp); \
1701541Srgrimes		} \
1719336Sdfr		if (v3) { \
1729336Sdfr			nfsm_dissect(tl, u_long *, NFSX_UNSIGNED); \
1739336Sdfr			if (f) \
1749336Sdfr				(f) = fxdr_unsigned(int, *tl); \
1759336Sdfr			else if (fxdr_unsigned(int, *tl)) \
1769336Sdfr				nfsm_adv(NFSX_V3FATTR); \
1779336Sdfr		} \
1789336Sdfr		if (f) \
1799336Sdfr			nfsm_loadattr((v), (struct vattr *)0); \
1801541Srgrimes		}
1811541Srgrimes
1829336Sdfr#define nfsm_getfh(f, s, v3) \
1839336Sdfr		{ if (v3) { \
1849336Sdfr			nfsm_dissect(tl, u_long *, NFSX_UNSIGNED); \
1859336Sdfr			if (((s) = fxdr_unsigned(int, *tl)) <= 0 || \
1869336Sdfr				(s) > NFSX_V3FHMAX) { \
1879336Sdfr				m_freem(mrep); \
1889336Sdfr				error = EBADRPC; \
1899336Sdfr				goto nfsmout; \
1909336Sdfr			} \
1919336Sdfr		} else \
1929336Sdfr			(s) = NFSX_V2FH; \
1939336Sdfr		nfsm_dissect((f), nfsfh_t *, nfsm_rndup(s)); }
1949336Sdfr
1959336Sdfr#define	nfsm_loadattr(v, a) \
1969336Sdfr		{ struct vnode *ttvp = (v); \
19736503Speter		if ((t1 = nfs_loadattrcache(&ttvp, &md, &dpos, (a))) != 0) { \
1989336Sdfr			error = t1; \
1991541Srgrimes			m_freem(mrep); \
2001541Srgrimes			goto nfsmout; \
2011541Srgrimes		} \
2029336Sdfr		(v) = ttvp; }
2031541Srgrimes
2049336Sdfr#define	nfsm_postop_attr(v, f) \
2059336Sdfr		{ struct vnode *ttvp = (v); \
2069336Sdfr		nfsm_dissect(tl, u_long *, NFSX_UNSIGNED); \
2079336Sdfr		if ((f) = fxdr_unsigned(int, *tl)) { \
20836503Speter			if ((t1 = nfs_loadattrcache(&ttvp, &md, &dpos, \
20936503Speter				(struct vattr *)0)) != 0) { \
2109336Sdfr				error = t1; \
2119336Sdfr				(f) = 0; \
2129336Sdfr				m_freem(mrep); \
2139336Sdfr				goto nfsmout; \
2149336Sdfr			} \
2159336Sdfr			(v) = ttvp; \
2169336Sdfr		} }
2179336Sdfr
2189336Sdfr/* Used as (f) for nfsm_wcc_data() */
2199336Sdfr#define NFSV3_WCCRATTR	0
2209336Sdfr#define NFSV3_WCCCHK	1
2219336Sdfr
2229336Sdfr#define	nfsm_wcc_data(v, f) \
2239336Sdfr		{ int ttattrf, ttretf = 0; \
2249336Sdfr		nfsm_dissect(tl, u_long *, NFSX_UNSIGNED); \
2259336Sdfr		if (*tl == nfs_true) { \
2269336Sdfr			nfsm_dissect(tl, u_long *, 6 * NFSX_UNSIGNED); \
2279336Sdfr			if (f) \
2289336Sdfr				ttretf = (VTONFS(v)->n_mtime == \
2299336Sdfr					fxdr_unsigned(u_long, *(tl + 2))); \
2309336Sdfr		} \
2319336Sdfr		nfsm_postop_attr((v), ttattrf); \
2329336Sdfr		if (f) { \
2339336Sdfr			(f) = ttretf; \
2349336Sdfr		} else { \
2359336Sdfr			(f) = ttattrf; \
2369336Sdfr		} }
2379336Sdfr
2389336Sdfr#define nfsm_v3sattr(s, a, u, g) \
2399336Sdfr		{ (s)->sa_modetrue = nfs_true; \
2409336Sdfr		(s)->sa_mode = vtonfsv3_mode((a)->va_mode); \
2419336Sdfr		(s)->sa_uidtrue = nfs_true; \
2429336Sdfr		(s)->sa_uid = txdr_unsigned(u); \
2439336Sdfr		(s)->sa_gidtrue = nfs_true; \
2449336Sdfr		(s)->sa_gid = txdr_unsigned(g); \
2459336Sdfr		(s)->sa_sizefalse = nfs_false; \
2469336Sdfr		(s)->sa_atimetype = txdr_unsigned(NFSV3SATTRTIME_TOCLIENT); \
2479336Sdfr		txdr_nfsv3time(&(a)->va_atime, &(s)->sa_atime); \
2489336Sdfr		(s)->sa_mtimetype = txdr_unsigned(NFSV3SATTRTIME_TOCLIENT); \
2499336Sdfr		txdr_nfsv3time(&(a)->va_mtime, &(s)->sa_mtime); \
2509336Sdfr		}
2519336Sdfr
2521541Srgrimes#define	nfsm_strsiz(s,m) \
2531541Srgrimes		{ nfsm_dissect(tl,u_long *,NFSX_UNSIGNED); \
2541541Srgrimes		if (((s) = fxdr_unsigned(long,*tl)) > (m)) { \
2551541Srgrimes			m_freem(mrep); \
2561541Srgrimes			error = EBADRPC; \
2571541Srgrimes			goto nfsmout; \
2581541Srgrimes		} }
2591541Srgrimes
2601541Srgrimes#define	nfsm_srvstrsiz(s,m) \
2611541Srgrimes		{ nfsm_dissect(tl,u_long *,NFSX_UNSIGNED); \
2621541Srgrimes		if (((s) = fxdr_unsigned(long,*tl)) > (m) || (s) <= 0) { \
2631541Srgrimes			error = EBADRPC; \
2641541Srgrimes			nfsm_reply(0); \
2651541Srgrimes		} }
2661541Srgrimes
2679336Sdfr#define	nfsm_srvnamesiz(s) \
2689336Sdfr		{ nfsm_dissect(tl,u_long *,NFSX_UNSIGNED); \
2699336Sdfr		if (((s) = fxdr_unsigned(long,*tl)) > NFS_MAXNAMLEN) \
2709336Sdfr			error = NFSERR_NAMETOL; \
2719336Sdfr		if ((s) <= 0) \
2729336Sdfr			error = EBADRPC; \
2739336Sdfr		if (error) \
2749336Sdfr			nfsm_reply(0); \
2759336Sdfr		}
2769336Sdfr
2771541Srgrimes#define nfsm_mtouio(p,s) \
2781541Srgrimes		if ((s) > 0 && \
27936503Speter		   (t1 = nfsm_mbuftouio(&md,(p),(s),&dpos)) != 0) { \
2809336Sdfr			error = t1; \
2811541Srgrimes			m_freem(mrep); \
2821541Srgrimes			goto nfsmout; \
2831541Srgrimes		}
2841541Srgrimes
2851541Srgrimes#define nfsm_uiotom(p,s) \
28636503Speter		if ((t1 = nfsm_uiotombuf((p),&mb,(s),&bpos)) != 0) { \
2879336Sdfr			error = t1; \
2881541Srgrimes			m_freem(mreq); \
2891541Srgrimes			goto nfsmout; \
2901541Srgrimes		}
2911541Srgrimes
2921541Srgrimes#define	nfsm_reqhead(v,a,s) \
2931541Srgrimes		mb = mreq = nfsm_reqh((v),(a),(s),&bpos)
2941541Srgrimes
2951541Srgrimes#define nfsm_reqdone	m_freem(mrep); \
2968876Srgrimes		nfsmout:
2971541Srgrimes
2981541Srgrimes#define nfsm_rndup(a)	(((a)+3)&(~0x3))
2991541Srgrimes
3001541Srgrimes#define	nfsm_request(v, t, p, c)	\
30136503Speter		if ((error = nfs_request((v), mreq, (t), (p), \
30236503Speter		   (c), &mrep, &md, &dpos)) != 0) { \
3039336Sdfr			if (error & NFSERR_RETERR) \
3049336Sdfr				error &= ~NFSERR_RETERR; \
3059336Sdfr			else \
3069336Sdfr				goto nfsmout; \
3079336Sdfr		}
3081541Srgrimes
3091541Srgrimes#define	nfsm_strtom(a,s,m) \
3101541Srgrimes		if ((s) > (m)) { \
3111541Srgrimes			m_freem(mreq); \
3121541Srgrimes			error = ENAMETOOLONG; \
3131541Srgrimes			goto nfsmout; \
3141541Srgrimes		} \
3151541Srgrimes		t2 = nfsm_rndup(s)+NFSX_UNSIGNED; \
3161541Srgrimes		if (t2 <= M_TRAILINGSPACE(mb)) { \
3171541Srgrimes			nfsm_build(tl,u_long *,t2); \
3181541Srgrimes			*tl++ = txdr_unsigned(s); \
3191541Srgrimes			*(tl+((t2>>2)-2)) = 0; \
3201541Srgrimes			bcopy((caddr_t)(a), (caddr_t)tl, (s)); \
32136503Speter		} else if ((t2 = nfsm_strtmbuf(&mb, &bpos, (a), (s))) != 0) { \
3229336Sdfr			error = t2; \
3239336Sdfr			m_freem(mreq); \
3249336Sdfr			goto nfsmout; \
3251541Srgrimes		}
3261541Srgrimes
3271541Srgrimes#define	nfsm_srvdone \
3281541Srgrimes		nfsmout: \
3291541Srgrimes		return(error)
3301541Srgrimes
3311541Srgrimes#define	nfsm_reply(s) \
3321541Srgrimes		{ \
3331541Srgrimes		nfsd->nd_repstat = error; \
3349336Sdfr		if (error && !(nfsd->nd_flag & ND_NFSV3)) \
3359336Sdfr		   (void) nfs_rephead(0, nfsd, slp, error, cache, &frev, \
3361541Srgrimes			mrq, &mb, &bpos); \
3371541Srgrimes		else \
3389336Sdfr		   (void) nfs_rephead((s), nfsd, slp, error, cache, &frev, \
3391541Srgrimes			mrq, &mb, &bpos); \
3401541Srgrimes		m_freem(mrep); \
3411541Srgrimes		mreq = *mrq; \
3429336Sdfr		if (error && (!(nfsd->nd_flag & ND_NFSV3) || \
3439336Sdfr			error == EBADRPC)) \
3441541Srgrimes			return(0); \
3451541Srgrimes		}
3461541Srgrimes
3479336Sdfr#define	nfsm_writereply(s, v3) \
3489336Sdfr		{ \
3499336Sdfr		nfsd->nd_repstat = error; \
3509336Sdfr		if (error && !(v3)) \
3519336Sdfr		   (void) nfs_rephead(0, nfsd, slp, error, cache, &frev, \
3529336Sdfr			&mreq, &mb, &bpos); \
3539336Sdfr		else \
3549336Sdfr		   (void) nfs_rephead((s), nfsd, slp, error, cache, &frev, \
3559336Sdfr			&mreq, &mb, &bpos); \
3569336Sdfr		}
3579336Sdfr
3581541Srgrimes#define	nfsm_adv(s) \
3599336Sdfr		{ t1 = mtod(md, caddr_t)+md->m_len-dpos; \
3601541Srgrimes		if (t1 >= (s)) { \
3611541Srgrimes			dpos += (s); \
36236503Speter		} else if ((t1 = nfs_adv(&md, &dpos, (s), t1)) != 0) { \
3639336Sdfr			error = t1; \
3649336Sdfr			m_freem(mrep); \
3659336Sdfr			goto nfsmout; \
3669336Sdfr		} }
3679336Sdfr
3689336Sdfr#define nfsm_srvmtofh(f) \
36927446Sdfr	{ int fhlen = NFSX_V3FH; \
37027446Sdfr		if (nfsd->nd_flag & ND_NFSV3) { \
3719336Sdfr			nfsm_dissect(tl, u_long *, NFSX_UNSIGNED); \
37227446Sdfr			fhlen = fxdr_unsigned(int, *tl); \
37327446Sdfr			if (fhlen == 0) { \
37427446Sdfr				bzero((caddr_t)(f), NFSX_V3FH); \
37527446Sdfr			} else if (fhlen != NFSX_V3FH) { \
3769336Sdfr				error = EBADRPC; \
3779336Sdfr				nfsm_reply(0); \
3783305Sphk			} \
3799336Sdfr		} \
38027446Sdfr		if (fhlen != 0) { \
38127446Sdfr			nfsm_dissect(tl, u_long *, NFSX_V3FH); \
38227446Sdfr			bcopy((caddr_t)tl, (caddr_t)(f), NFSX_V3FH); \
38327446Sdfr			if ((nfsd->nd_flag & ND_NFSV3) == 0) \
38427446Sdfr				nfsm_adv(NFSX_V2FH - NFSX_V3FH); \
38527446Sdfr		} \
38627446Sdfr	}
3871541Srgrimes
3881541Srgrimes#define	nfsm_clget \
3891541Srgrimes		if (bp >= be) { \
3901541Srgrimes			if (mp == mb) \
3911541Srgrimes				mp->m_len += bp-bpos; \
3921541Srgrimes			MGET(mp, M_WAIT, MT_DATA); \
3931541Srgrimes			MCLGET(mp, M_WAIT); \
3941541Srgrimes			mp->m_len = NFSMSIZ(mp); \
3951541Srgrimes			mp2->m_next = mp; \
3961541Srgrimes			mp2 = mp; \
3971541Srgrimes			bp = mtod(mp, caddr_t); \
3981541Srgrimes			be = bp+mp->m_len; \
3991541Srgrimes		} \
4001541Srgrimes		tl = (u_long *)bp
4011541Srgrimes
4029336Sdfr#define	nfsm_srvfillattr(a, f) \
4039336Sdfr		nfsm_srvfattr(nfsd, (a), (f))
4041541Srgrimes
4059336Sdfr#define nfsm_srvwcc_data(br, b, ar, a) \
4069336Sdfr		nfsm_srvwcc(nfsd, (br), (b), (ar), (a), &mb, &bpos)
4079336Sdfr
4089336Sdfr#define nfsm_srvpostop_attr(r, a) \
4099336Sdfr		nfsm_srvpostopattr(nfsd, (r), (a), &mb, &bpos)
4109336Sdfr
4119336Sdfr#define nfsm_srvsattr(a) \
4129336Sdfr		{ nfsm_dissect(tl, u_long *, NFSX_UNSIGNED); \
4139336Sdfr		if (*tl == nfs_true) { \
4149336Sdfr			nfsm_dissect(tl, u_long *, NFSX_UNSIGNED); \
4159336Sdfr			(a)->va_mode = nfstov_mode(*tl); \
4169336Sdfr		} \
4179336Sdfr		nfsm_dissect(tl, u_long *, NFSX_UNSIGNED); \
4189336Sdfr		if (*tl == nfs_true) { \
4199336Sdfr			nfsm_dissect(tl, u_long *, NFSX_UNSIGNED); \
4209336Sdfr			(a)->va_uid = fxdr_unsigned(uid_t, *tl); \
4219336Sdfr		} \
4229336Sdfr		nfsm_dissect(tl, u_long *, NFSX_UNSIGNED); \
4239336Sdfr		if (*tl == nfs_true) { \
4249336Sdfr			nfsm_dissect(tl, u_long *, NFSX_UNSIGNED); \
4259336Sdfr			(a)->va_gid = fxdr_unsigned(gid_t, *tl); \
4269336Sdfr		} \
4279336Sdfr		nfsm_dissect(tl, u_long *, NFSX_UNSIGNED); \
4289336Sdfr		if (*tl == nfs_true) { \
4299336Sdfr			nfsm_dissect(tl, u_long *, 2 * NFSX_UNSIGNED); \
4309336Sdfr			fxdr_hyper(tl, &(a)->va_size); \
4319336Sdfr		} \
4329336Sdfr		nfsm_dissect(tl, u_long *, NFSX_UNSIGNED); \
4339336Sdfr		switch (fxdr_unsigned(int, *tl)) { \
4349336Sdfr		case NFSV3SATTRTIME_TOCLIENT: \
4359336Sdfr			nfsm_dissect(tl, u_long *, 2 * NFSX_UNSIGNED); \
4369336Sdfr			fxdr_nfsv3time(tl, &(a)->va_atime); \
4379336Sdfr			break; \
43836097Sbde		case NFSV3SATTRTIME_TOSERVER: \
43936097Sbde			getnanotime(&(a)->va_atime); \
44036097Sbde			break; \
4419336Sdfr		}; \
4429336Sdfr		nfsm_dissect(tl, u_long *, NFSX_UNSIGNED); \
4439336Sdfr		switch (fxdr_unsigned(int, *tl)) { \
4449336Sdfr		case NFSV3SATTRTIME_TOCLIENT: \
4459336Sdfr			nfsm_dissect(tl, u_long *, 2 * NFSX_UNSIGNED); \
4469336Sdfr			fxdr_nfsv3time(tl, &(a)->va_mtime); \
4479336Sdfr			break; \
44836097Sbde		case NFSV3SATTRTIME_TOSERVER: \
44936097Sbde			getnanotime(&(a)->va_mtime); \
45036097Sbde			break; \
4519336Sdfr		}; }
4529336Sdfr
4532175Spaul#endif
454