nfsm_subs.h revision 1.9 1 1.9 fvdl /* $NetBSD: nfsm_subs.h,v 1.9 1996/02/18 11:54:01 fvdl Exp $ */
2 1.5 cgd
3 1.1 mycroft /*
4 1.4 mycroft * Copyright (c) 1989, 1993
5 1.4 mycroft * The Regents of the University of California. All rights reserved.
6 1.1 mycroft *
7 1.1 mycroft * This code is derived from software contributed to Berkeley by
8 1.1 mycroft * Rick Macklem at The University of Guelph.
9 1.1 mycroft *
10 1.1 mycroft * Redistribution and use in source and binary forms, with or without
11 1.1 mycroft * modification, are permitted provided that the following conditions
12 1.1 mycroft * are met:
13 1.1 mycroft * 1. Redistributions of source code must retain the above copyright
14 1.1 mycroft * notice, this list of conditions and the following disclaimer.
15 1.1 mycroft * 2. Redistributions in binary form must reproduce the above copyright
16 1.1 mycroft * notice, this list of conditions and the following disclaimer in the
17 1.1 mycroft * documentation and/or other materials provided with the distribution.
18 1.1 mycroft * 3. All advertising materials mentioning features or use of this software
19 1.1 mycroft * must display the following acknowledgement:
20 1.1 mycroft * This product includes software developed by the University of
21 1.1 mycroft * California, Berkeley and its contributors.
22 1.1 mycroft * 4. Neither the name of the University nor the names of its contributors
23 1.1 mycroft * may be used to endorse or promote products derived from this software
24 1.1 mycroft * without specific prior written permission.
25 1.1 mycroft *
26 1.1 mycroft * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
27 1.1 mycroft * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
28 1.1 mycroft * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
29 1.1 mycroft * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
30 1.1 mycroft * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
31 1.1 mycroft * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
32 1.1 mycroft * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
33 1.1 mycroft * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
34 1.1 mycroft * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
35 1.1 mycroft * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
36 1.1 mycroft * SUCH DAMAGE.
37 1.1 mycroft *
38 1.9 fvdl * @(#)nfsm_subs.h 8.2 (Berkeley) 3/30/95
39 1.1 mycroft */
40 1.1 mycroft
41 1.9 fvdl
42 1.9 fvdl #ifndef _NFS_NFSM_SUBS_H_
43 1.9 fvdl #define _NFS_NFSM_SUBS_H_
44 1.9 fvdl
45 1.9 fvdl
46 1.1 mycroft /*
47 1.1 mycroft * These macros do strange and peculiar things to mbuf chains for
48 1.1 mycroft * the assistance of the nfs code. To attempt to use them for any
49 1.1 mycroft * other purpose will be dangerous. (they make weird assumptions)
50 1.1 mycroft */
51 1.1 mycroft
52 1.1 mycroft /*
53 1.1 mycroft * First define what the actual subs. return
54 1.1 mycroft */
55 1.9 fvdl
56 1.1 mycroft #define M_HASCL(m) ((m)->m_flags & M_EXT)
57 1.1 mycroft #define NFSMINOFF(m) \
58 1.1 mycroft if (M_HASCL(m)) \
59 1.1 mycroft (m)->m_data = (m)->m_ext.ext_buf; \
60 1.4 mycroft else if ((m)->m_flags & M_PKTHDR) \
61 1.4 mycroft (m)->m_data = (m)->m_pktdat; \
62 1.1 mycroft else \
63 1.1 mycroft (m)->m_data = (m)->m_dat
64 1.1 mycroft #define NFSMADV(m, s) (m)->m_data += (s)
65 1.1 mycroft #define NFSMSIZ(m) ((M_HASCL(m))?MCLBYTES: \
66 1.1 mycroft (((m)->m_flags & M_PKTHDR)?MHLEN:MLEN))
67 1.1 mycroft
68 1.1 mycroft /*
69 1.1 mycroft * Now for the macros that do the simple stuff and call the functions
70 1.1 mycroft * for the hard stuff.
71 1.1 mycroft * These macros use several vars. declared in nfsm_reqhead and these
72 1.1 mycroft * vars. must not be used elsewhere unless you are careful not to corrupt
73 1.1 mycroft * them. The vars. starting with pN and tN (N=1,2,3,..) are temporaries
74 1.1 mycroft * that may be used so long as the value is not expected to retained
75 1.1 mycroft * after a macro.
76 1.1 mycroft * I know, this is kind of dorkey, but it makes the actual op functions
77 1.1 mycroft * fairly clean and deals with the mess caused by the xdr discriminating
78 1.1 mycroft * unions.
79 1.1 mycroft */
80 1.1 mycroft
81 1.1 mycroft #define nfsm_build(a,c,s) \
82 1.4 mycroft { if ((s) > M_TRAILINGSPACE(mb)) { \
83 1.1 mycroft MGET(mb2, M_WAIT, MT_DATA); \
84 1.1 mycroft if ((s) > MLEN) \
85 1.1 mycroft panic("build > MLEN"); \
86 1.1 mycroft mb->m_next = mb2; \
87 1.1 mycroft mb = mb2; \
88 1.1 mycroft mb->m_len = 0; \
89 1.1 mycroft bpos = mtod(mb, caddr_t); \
90 1.1 mycroft } \
91 1.1 mycroft (a) = (c)(bpos); \
92 1.1 mycroft mb->m_len += (s); \
93 1.4 mycroft bpos += (s); }
94 1.1 mycroft
95 1.9 fvdl #define nfsm_dissect(a, c, s) \
96 1.4 mycroft { t1 = mtod(md, caddr_t)+md->m_len-dpos; \
97 1.1 mycroft if (t1 >= (s)) { \
98 1.1 mycroft (a) = (c)(dpos); \
99 1.1 mycroft dpos += (s); \
100 1.9 fvdl } else if ((t1 = nfsm_disct(&md, &dpos, (s), t1, &cp2)) != 0){ \
101 1.9 fvdl error = t1; \
102 1.1 mycroft m_freem(mrep); \
103 1.1 mycroft goto nfsmout; \
104 1.1 mycroft } else { \
105 1.1 mycroft (a) = (c)cp2; \
106 1.4 mycroft } }
107 1.1 mycroft
108 1.9 fvdl #define nfsm_fhtom(v, v3) \
109 1.9 fvdl { if (v3) { \
110 1.9 fvdl t2 = nfsm_rndup(VTONFS(v)->n_fhsize) + NFSX_UNSIGNED; \
111 1.9 fvdl if (t2 <= M_TRAILINGSPACE(mb)) { \
112 1.9 fvdl nfsm_build(tl, u_int32_t *, t2); \
113 1.9 fvdl *tl++ = txdr_unsigned(VTONFS(v)->n_fhsize); \
114 1.9 fvdl *(tl + ((t2>>2) - 2)) = 0; \
115 1.9 fvdl bcopy((caddr_t)VTONFS(v)->n_fhp,(caddr_t)tl, \
116 1.9 fvdl VTONFS(v)->n_fhsize); \
117 1.9 fvdl } else if ((t2 = nfsm_strtmbuf(&mb, &bpos, \
118 1.9 fvdl (caddr_t)VTONFS(v)->n_fhp, \
119 1.9 fvdl VTONFS(v)->n_fhsize)) != 0) { \
120 1.9 fvdl error = t2; \
121 1.9 fvdl m_freem(mreq); \
122 1.9 fvdl goto nfsmout; \
123 1.9 fvdl } \
124 1.9 fvdl } else { \
125 1.9 fvdl nfsm_build(cp, caddr_t, NFSX_V2FH); \
126 1.9 fvdl bcopy((caddr_t)VTONFS(v)->n_fhp, cp, NFSX_V2FH); \
127 1.9 fvdl } }
128 1.9 fvdl
129 1.9 fvdl #define nfsm_srvfhtom(f, v3) \
130 1.9 fvdl { if (v3) { \
131 1.9 fvdl nfsm_build(tl, u_int32_t *, NFSX_UNSIGNED + NFSX_V3FH); \
132 1.9 fvdl *tl++ = txdr_unsigned(NFSX_V3FH); \
133 1.9 fvdl bcopy((caddr_t)(f), (caddr_t)tl, NFSX_V3FH); \
134 1.9 fvdl } else { \
135 1.9 fvdl nfsm_build(cp, caddr_t, NFSX_V2FH); \
136 1.9 fvdl bcopy((caddr_t)(f), cp, NFSX_V2FH); \
137 1.9 fvdl } }
138 1.9 fvdl
139 1.9 fvdl #define nfsm_srvpostop_fh(f) \
140 1.9 fvdl { nfsm_build(tl, u_int32_t *, 2 * NFSX_UNSIGNED + NFSX_V3FH); \
141 1.9 fvdl *tl++ = nfs_true; \
142 1.9 fvdl *tl++ = txdr_unsigned(NFSX_V3FH); \
143 1.9 fvdl bcopy((caddr_t)(f), (caddr_t)tl, NFSX_V3FH); \
144 1.9 fvdl }
145 1.9 fvdl
146 1.9 fvdl #define nfsm_mtofh(d, v, v3, f) \
147 1.9 fvdl { struct nfsnode *ttnp; nfsfh_t *ttfhp; int ttfhsize; \
148 1.9 fvdl if (v3) { \
149 1.9 fvdl nfsm_dissect(tl, u_int32_t *, NFSX_UNSIGNED); \
150 1.9 fvdl (f) = fxdr_unsigned(int, *tl); \
151 1.9 fvdl } else \
152 1.9 fvdl (f) = 1; \
153 1.9 fvdl if (f) { \
154 1.9 fvdl nfsm_getfh(ttfhp, ttfhsize, (v3)); \
155 1.9 fvdl if ((t1 = nfs_nget((d)->v_mount, ttfhp, ttfhsize, \
156 1.9 fvdl &ttnp)) != 0) { \
157 1.9 fvdl error = t1; \
158 1.9 fvdl m_freem(mrep); \
159 1.9 fvdl goto nfsmout; \
160 1.9 fvdl } \
161 1.9 fvdl (v) = NFSTOV(ttnp); \
162 1.9 fvdl } \
163 1.9 fvdl if (v3) { \
164 1.9 fvdl nfsm_dissect(tl, u_int32_t *, NFSX_UNSIGNED); \
165 1.9 fvdl if (f) \
166 1.9 fvdl (f) = fxdr_unsigned(int, *tl); \
167 1.9 fvdl else if (fxdr_unsigned(int, *tl)) \
168 1.9 fvdl nfsm_adv(NFSX_V3FATTR); \
169 1.1 mycroft } \
170 1.9 fvdl if (f) \
171 1.9 fvdl nfsm_loadattr((v), (struct vattr *)0); \
172 1.1 mycroft }
173 1.1 mycroft
174 1.9 fvdl #define nfsm_getfh(f, s, v3) \
175 1.9 fvdl { if (v3) { \
176 1.9 fvdl nfsm_dissect(tl, u_int32_t *, NFSX_UNSIGNED); \
177 1.9 fvdl if (((s) = fxdr_unsigned(int, *tl)) <= 0 || \
178 1.9 fvdl (s) > NFSX_V3FHMAX) { \
179 1.9 fvdl m_freem(mrep); \
180 1.9 fvdl error = EBADRPC; \
181 1.9 fvdl goto nfsmout; \
182 1.9 fvdl } \
183 1.9 fvdl } else \
184 1.9 fvdl (s) = NFSX_V2FH; \
185 1.9 fvdl nfsm_dissect((f), nfsfh_t *, nfsm_rndup(s)); }
186 1.9 fvdl
187 1.9 fvdl #define nfsm_loadattr(v, a) \
188 1.9 fvdl { struct vnode *ttvp = (v); \
189 1.9 fvdl if ((t1 = nfs_loadattrcache(&ttvp, &md, &dpos, (a))) != 0) { \
190 1.9 fvdl error = t1; \
191 1.1 mycroft m_freem(mrep); \
192 1.1 mycroft goto nfsmout; \
193 1.1 mycroft } \
194 1.9 fvdl (v) = ttvp; }
195 1.9 fvdl
196 1.9 fvdl #define nfsm_postop_attr(v, f) \
197 1.9 fvdl { struct vnode *ttvp = (v); \
198 1.9 fvdl nfsm_dissect(tl, u_int32_t *, NFSX_UNSIGNED); \
199 1.9 fvdl if (((f) = fxdr_unsigned(int, *tl)) != 0) { \
200 1.9 fvdl if ((t1 = nfs_loadattrcache(&ttvp, &md, &dpos, \
201 1.9 fvdl (struct vattr *)0)) != 0) { \
202 1.9 fvdl error = t1; \
203 1.9 fvdl (f) = 0; \
204 1.9 fvdl m_freem(mrep); \
205 1.9 fvdl goto nfsmout; \
206 1.9 fvdl } \
207 1.9 fvdl (v) = ttvp; \
208 1.9 fvdl } }
209 1.9 fvdl
210 1.9 fvdl /* Used as (f) for nfsm_wcc_data() */
211 1.9 fvdl #define NFSV3_WCCRATTR 0
212 1.9 fvdl #define NFSV3_WCCCHK 1
213 1.9 fvdl
214 1.9 fvdl #define nfsm_wcc_data(v, f) \
215 1.9 fvdl { int ttattrf, ttretf = 0; \
216 1.9 fvdl nfsm_dissect(tl, u_int32_t *, NFSX_UNSIGNED); \
217 1.9 fvdl if (*tl == nfs_true) { \
218 1.9 fvdl nfsm_dissect(tl, u_int32_t *, 6 * NFSX_UNSIGNED); \
219 1.9 fvdl if (f) \
220 1.9 fvdl ttretf = (VTONFS(v)->n_mtime == \
221 1.9 fvdl fxdr_unsigned(u_int32_t, *(tl + 2))); \
222 1.9 fvdl } \
223 1.9 fvdl nfsm_postop_attr((v), ttattrf); \
224 1.9 fvdl if (f) { \
225 1.9 fvdl (f) = ttretf; \
226 1.9 fvdl } else { \
227 1.9 fvdl (f) = ttattrf; \
228 1.9 fvdl } }
229 1.9 fvdl
230 1.9 fvdl #define nfsm_v3sattr(s, a) \
231 1.9 fvdl { (s)->sa_modetrue = nfs_true; \
232 1.9 fvdl (s)->sa_mode = vtonfsv3_mode((a)->va_mode); \
233 1.9 fvdl (s)->sa_uidfalse = nfs_false; \
234 1.9 fvdl (s)->sa_gidfalse = nfs_false; \
235 1.9 fvdl (s)->sa_sizefalse = nfs_false; \
236 1.9 fvdl (s)->sa_atimetype = txdr_unsigned(NFSV3SATTRTIME_TOCLIENT); \
237 1.9 fvdl txdr_nfsv3time(&(a)->va_atime, &(s)->sa_atime); \
238 1.9 fvdl (s)->sa_mtimetype = txdr_unsigned(NFSV3SATTRTIME_TOCLIENT); \
239 1.9 fvdl txdr_nfsv3time(&(a)->va_mtime, &(s)->sa_mtime); \
240 1.9 fvdl }
241 1.1 mycroft
242 1.1 mycroft #define nfsm_strsiz(s,m) \
243 1.7 cgd { nfsm_dissect(tl,u_int32_t *,NFSX_UNSIGNED); \
244 1.7 cgd if (((s) = fxdr_unsigned(int32_t,*tl)) > (m)) { \
245 1.1 mycroft m_freem(mrep); \
246 1.1 mycroft error = EBADRPC; \
247 1.1 mycroft goto nfsmout; \
248 1.4 mycroft } }
249 1.1 mycroft
250 1.1 mycroft #define nfsm_srvstrsiz(s,m) \
251 1.7 cgd { nfsm_dissect(tl,u_int32_t *,NFSX_UNSIGNED); \
252 1.7 cgd if (((s) = fxdr_unsigned(int32_t,*tl)) > (m) || (s) <= 0) { \
253 1.1 mycroft error = EBADRPC; \
254 1.1 mycroft nfsm_reply(0); \
255 1.4 mycroft } }
256 1.1 mycroft
257 1.9 fvdl #define nfsm_srvnamesiz(s) \
258 1.9 fvdl { nfsm_dissect(tl,u_int32_t *,NFSX_UNSIGNED); \
259 1.9 fvdl if (((s) = fxdr_unsigned(int32_t,*tl)) > NFS_MAXNAMLEN) \
260 1.9 fvdl error = NFSERR_NAMETOL; \
261 1.9 fvdl if ((s) <= 0) \
262 1.9 fvdl error = EBADRPC; \
263 1.9 fvdl if (error) \
264 1.9 fvdl nfsm_reply(0); \
265 1.9 fvdl }
266 1.9 fvdl
267 1.1 mycroft #define nfsm_mtouio(p,s) \
268 1.1 mycroft if ((s) > 0 && \
269 1.9 fvdl (t1 = nfsm_mbuftouio(&md,(p),(s),&dpos)) != 0) { \
270 1.9 fvdl error = t1; \
271 1.1 mycroft m_freem(mrep); \
272 1.1 mycroft goto nfsmout; \
273 1.1 mycroft }
274 1.1 mycroft
275 1.1 mycroft #define nfsm_uiotom(p,s) \
276 1.9 fvdl if ((t1 = nfsm_uiotombuf((p),&mb,(s),&bpos)) != 0) { \
277 1.9 fvdl error = t1; \
278 1.1 mycroft m_freem(mreq); \
279 1.1 mycroft goto nfsmout; \
280 1.1 mycroft }
281 1.1 mycroft
282 1.4 mycroft #define nfsm_reqhead(v,a,s) \
283 1.4 mycroft mb = mreq = nfsm_reqh((v),(a),(s),&bpos)
284 1.1 mycroft
285 1.1 mycroft #define nfsm_reqdone m_freem(mrep); \
286 1.1 mycroft nfsmout:
287 1.1 mycroft
288 1.1 mycroft #define nfsm_rndup(a) (((a)+3)&(~0x3))
289 1.1 mycroft
290 1.4 mycroft #define nfsm_request(v, t, p, c) \
291 1.8 christos if ((error = nfs_request((v), mreq, (t), (p), \
292 1.9 fvdl (c), &mrep, &md, &dpos)) != 0) { \
293 1.9 fvdl if (error & NFSERR_RETERR) \
294 1.9 fvdl error &= ~NFSERR_RETERR; \
295 1.9 fvdl else \
296 1.9 fvdl goto nfsmout; \
297 1.9 fvdl }
298 1.1 mycroft
299 1.1 mycroft #define nfsm_strtom(a,s,m) \
300 1.1 mycroft if ((s) > (m)) { \
301 1.1 mycroft m_freem(mreq); \
302 1.1 mycroft error = ENAMETOOLONG; \
303 1.1 mycroft goto nfsmout; \
304 1.1 mycroft } \
305 1.1 mycroft t2 = nfsm_rndup(s)+NFSX_UNSIGNED; \
306 1.4 mycroft if (t2 <= M_TRAILINGSPACE(mb)) { \
307 1.7 cgd nfsm_build(tl,u_int32_t *,t2); \
308 1.1 mycroft *tl++ = txdr_unsigned(s); \
309 1.1 mycroft *(tl+((t2>>2)-2)) = 0; \
310 1.1 mycroft bcopy((caddr_t)(a), (caddr_t)tl, (s)); \
311 1.9 fvdl } else if ((t2 = nfsm_strtmbuf(&mb, &bpos, (a), (s))) != 0) { \
312 1.9 fvdl error = t2; \
313 1.1 mycroft m_freem(mreq); \
314 1.1 mycroft goto nfsmout; \
315 1.1 mycroft }
316 1.1 mycroft
317 1.1 mycroft #define nfsm_srvdone \
318 1.1 mycroft nfsmout: \
319 1.1 mycroft return(error)
320 1.1 mycroft
321 1.1 mycroft #define nfsm_reply(s) \
322 1.1 mycroft { \
323 1.4 mycroft nfsd->nd_repstat = error; \
324 1.9 fvdl if (error && !(nfsd->nd_flag & ND_NFSV3)) \
325 1.9 fvdl (void) nfs_rephead(0, nfsd, slp, error, cache, &frev, \
326 1.4 mycroft mrq, &mb, &bpos); \
327 1.1 mycroft else \
328 1.9 fvdl (void) nfs_rephead((s), nfsd, slp, error, cache, &frev, \
329 1.4 mycroft mrq, &mb, &bpos); \
330 1.1 mycroft m_freem(mrep); \
331 1.1 mycroft mreq = *mrq; \
332 1.9 fvdl if (error && (!(nfsd->nd_flag & ND_NFSV3) || \
333 1.9 fvdl error == EBADRPC)) \
334 1.1 mycroft return(0); \
335 1.1 mycroft }
336 1.1 mycroft
337 1.9 fvdl #define nfsm_writereply(s, v3) \
338 1.9 fvdl { \
339 1.9 fvdl nfsd->nd_repstat = error; \
340 1.9 fvdl if (error && !(v3)) \
341 1.9 fvdl (void) nfs_rephead(0, nfsd, slp, error, cache, &frev, \
342 1.9 fvdl &mreq, &mb, &bpos); \
343 1.9 fvdl else \
344 1.9 fvdl (void) nfs_rephead((s), nfsd, slp, error, cache, &frev, \
345 1.9 fvdl &mreq, &mb, &bpos); \
346 1.9 fvdl }
347 1.9 fvdl
348 1.1 mycroft #define nfsm_adv(s) \
349 1.9 fvdl { t1 = mtod(md, caddr_t)+md->m_len-dpos; \
350 1.1 mycroft if (t1 >= (s)) { \
351 1.1 mycroft dpos += (s); \
352 1.9 fvdl } else if ((t1 = nfs_adv(&md, &dpos, (s), t1)) != 0) { \
353 1.9 fvdl error = t1; \
354 1.1 mycroft m_freem(mrep); \
355 1.1 mycroft goto nfsmout; \
356 1.9 fvdl } }
357 1.1 mycroft
358 1.1 mycroft #define nfsm_srvmtofh(f) \
359 1.9 fvdl { if (nfsd->nd_flag & ND_NFSV3) { \
360 1.9 fvdl nfsm_dissect(tl, u_int32_t *, NFSX_UNSIGNED); \
361 1.9 fvdl if (fxdr_unsigned(int, *tl) != NFSX_V3FH) { \
362 1.9 fvdl error = EBADRPC; \
363 1.9 fvdl nfsm_reply(0); \
364 1.9 fvdl } \
365 1.9 fvdl } \
366 1.9 fvdl nfsm_dissect(tl, u_int32_t *, NFSX_V3FH); \
367 1.9 fvdl bcopy((caddr_t)tl, (caddr_t)(f), NFSX_V3FH); \
368 1.9 fvdl if ((nfsd->nd_flag & ND_NFSV3) == 0) \
369 1.9 fvdl nfsm_adv(NFSX_V2FH - NFSX_V3FH); \
370 1.9 fvdl }
371 1.1 mycroft
372 1.1 mycroft #define nfsm_clget \
373 1.1 mycroft if (bp >= be) { \
374 1.4 mycroft if (mp == mb) \
375 1.4 mycroft mp->m_len += bp-bpos; \
376 1.1 mycroft MGET(mp, M_WAIT, MT_DATA); \
377 1.1 mycroft MCLGET(mp, M_WAIT); \
378 1.1 mycroft mp->m_len = NFSMSIZ(mp); \
379 1.4 mycroft mp2->m_next = mp; \
380 1.4 mycroft mp2 = mp; \
381 1.1 mycroft bp = mtod(mp, caddr_t); \
382 1.1 mycroft be = bp+mp->m_len; \
383 1.1 mycroft } \
384 1.7 cgd tl = (u_int32_t *)bp
385 1.1 mycroft
386 1.9 fvdl #define nfsm_srvfillattr(a, f) \
387 1.9 fvdl nfsm_srvfattr(nfsd, (a), (f))
388 1.9 fvdl
389 1.9 fvdl #define nfsm_srvwcc_data(br, b, ar, a) \
390 1.9 fvdl nfsm_srvwcc(nfsd, (br), (b), (ar), (a), &mb, &bpos)
391 1.9 fvdl
392 1.9 fvdl #define nfsm_srvpostop_attr(r, a) \
393 1.9 fvdl nfsm_srvpostopattr(nfsd, (r), (a), &mb, &bpos)
394 1.9 fvdl
395 1.9 fvdl #define nfsm_srvsattr(a) \
396 1.9 fvdl { nfsm_dissect(tl, u_int32_t *, NFSX_UNSIGNED); \
397 1.9 fvdl if (*tl == nfs_true) { \
398 1.9 fvdl nfsm_dissect(tl, u_int32_t *, NFSX_UNSIGNED); \
399 1.9 fvdl (a)->va_mode = nfstov_mode(*tl); \
400 1.9 fvdl } \
401 1.9 fvdl nfsm_dissect(tl, u_int32_t *, NFSX_UNSIGNED); \
402 1.9 fvdl if (*tl == nfs_true) { \
403 1.9 fvdl nfsm_dissect(tl, u_int32_t *, NFSX_UNSIGNED); \
404 1.9 fvdl (a)->va_uid = fxdr_unsigned(uid_t, *tl); \
405 1.9 fvdl } \
406 1.9 fvdl nfsm_dissect(tl, u_int32_t *, NFSX_UNSIGNED); \
407 1.9 fvdl if (*tl == nfs_true) { \
408 1.9 fvdl nfsm_dissect(tl, u_int32_t *, NFSX_UNSIGNED); \
409 1.9 fvdl (a)->va_gid = fxdr_unsigned(gid_t, *tl); \
410 1.9 fvdl } \
411 1.9 fvdl nfsm_dissect(tl, u_int32_t *, NFSX_UNSIGNED); \
412 1.9 fvdl if (*tl == nfs_true) { \
413 1.9 fvdl nfsm_dissect(tl, u_int32_t *, 2 * NFSX_UNSIGNED); \
414 1.9 fvdl fxdr_hyper(tl, &(a)->va_size); \
415 1.9 fvdl } \
416 1.9 fvdl nfsm_dissect(tl, u_int32_t *, NFSX_UNSIGNED); \
417 1.9 fvdl switch (fxdr_unsigned(int, *tl)) { \
418 1.9 fvdl case NFSV3SATTRTIME_TOCLIENT: \
419 1.9 fvdl nfsm_dissect(tl, u_int32_t *, 2 * NFSX_UNSIGNED); \
420 1.9 fvdl fxdr_nfsv3time(tl, &(a)->va_atime); \
421 1.9 fvdl break; \
422 1.9 fvdl case NFSV3SATTRTIME_TOSERVER: \
423 1.9 fvdl (a)->va_atime.tv_sec = time.tv_sec; \
424 1.9 fvdl (a)->va_atime.tv_nsec = time.tv_usec * 1000; \
425 1.9 fvdl break; \
426 1.9 fvdl }; \
427 1.9 fvdl nfsm_dissect(tl, u_int32_t *, NFSX_UNSIGNED); \
428 1.9 fvdl switch (fxdr_unsigned(int, *tl)) { \
429 1.9 fvdl case NFSV3SATTRTIME_TOCLIENT: \
430 1.9 fvdl nfsm_dissect(tl, u_int32_t *, 2 * NFSX_UNSIGNED); \
431 1.9 fvdl fxdr_nfsv3time(tl, &(a)->va_mtime); \
432 1.9 fvdl break; \
433 1.9 fvdl case NFSV3SATTRTIME_TOSERVER: \
434 1.9 fvdl (a)->va_mtime.tv_sec = time.tv_sec; \
435 1.9 fvdl (a)->va_mtime.tv_nsec = time.tv_usec * 1000; \
436 1.9 fvdl break; \
437 1.9 fvdl }; }
438 1.1 mycroft
439 1.9 fvdl #endif
440