]>
Commit | Line | Data |
---|---|---|
1c79356b | 1 | /* |
9bccf70c | 2 | * Copyright (c) 2000-2002 Apple Computer, Inc. All rights reserved. |
1c79356b A |
3 | * |
4 | * @APPLE_LICENSE_HEADER_START@ | |
5 | * | |
43866e37 | 6 | * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. |
1c79356b | 7 | * |
43866e37 A |
8 | * This file contains Original Code and/or Modifications of Original Code |
9 | * as defined in and that are subject to the Apple Public Source License | |
10 | * Version 2.0 (the 'License'). You may not use this file except in | |
11 | * compliance with the License. Please obtain a copy of the License at | |
12 | * http://www.opensource.apple.com/apsl/ and read it before using this | |
13 | * file. | |
14 | * | |
15 | * The Original Code and all software distributed under the License are | |
16 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER | |
1c79356b A |
17 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, |
18 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, | |
43866e37 A |
19 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. |
20 | * Please see the License for the specific language governing rights and | |
21 | * limitations under the License. | |
1c79356b A |
22 | * |
23 | * @APPLE_LICENSE_HEADER_END@ | |
24 | */ | |
25 | /* Copyright (c) 1995 NeXT Computer, Inc. All Rights Reserved */ | |
26 | /* | |
27 | * Copyright (c) 1989, 1993 | |
28 | * The Regents of the University of California. All rights reserved. | |
29 | * | |
30 | * This code is derived from software contributed to Berkeley by | |
31 | * Rick Macklem at The University of Guelph. | |
32 | * | |
33 | * Redistribution and use in source and binary forms, with or without | |
34 | * modification, are permitted provided that the following conditions | |
35 | * are met: | |
36 | * 1. Redistributions of source code must retain the above copyright | |
37 | * notice, this list of conditions and the following disclaimer. | |
38 | * 2. Redistributions in binary form must reproduce the above copyright | |
39 | * notice, this list of conditions and the following disclaimer in the | |
40 | * documentation and/or other materials provided with the distribution. | |
41 | * 3. All advertising materials mentioning features or use of this software | |
42 | * must display the following acknowledgement: | |
43 | * This product includes software developed by the University of | |
44 | * California, Berkeley and its contributors. | |
45 | * 4. Neither the name of the University nor the names of its contributors | |
46 | * may be used to endorse or promote products derived from this software | |
47 | * without specific prior written permission. | |
48 | * | |
49 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND | |
50 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |
51 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | |
52 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | |
53 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | |
54 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | |
55 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | |
56 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | |
57 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | |
58 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |
59 | * SUCH DAMAGE. | |
60 | * | |
61 | * @(#)nfsm_subs.h 8.2 (Berkeley) 3/30/95 | |
62 | * FreeBSD-Id: nfsm_subs.h,v 1.13 1997/07/16 09:06:30 dfr Exp $ | |
63 | */ | |
64 | ||
65 | ||
66 | #ifndef _NFS_NFSM_SUBS_H_ | |
67 | #define _NFS_NFSM_SUBS_H_ | |
68 | ||
9bccf70c | 69 | #include <sys/appleapiopts.h> |
1c79356b | 70 | |
9bccf70c | 71 | #ifdef __APPLE_API_PRIVATE |
1c79356b A |
72 | /* |
73 | * These macros do strange and peculiar things to mbuf chains for | |
74 | * the assistance of the nfs code. To attempt to use them for any | |
75 | * other purpose will be dangerous. (they make weird assumptions) | |
76 | */ | |
77 | ||
78 | /* | |
79 | * First define what the actual subs. return | |
80 | */ | |
81 | struct mbuf *nfsm_reqh __P((struct vnode *vp, u_long procid, int hsiz, | |
82 | caddr_t *bposp)); | |
83 | struct mbuf *nfsm_rpchead __P((struct ucred *cr, int nmflag, int procid, | |
84 | int auth_type, int auth_len, char *auth_str, | |
85 | int verf_len, char *verf_str, | |
86 | struct mbuf *mrest, int mrest_len, | |
87 | struct mbuf **mbp, u_long *xidp)); | |
88 | ||
89 | #define M_HASCL(m) ((m)->m_flags & M_EXT) | |
90 | #define NFSMINOFF(m) \ | |
91 | if (M_HASCL(m)) \ | |
92 | (m)->m_data = (m)->m_ext.ext_buf; \ | |
93 | else if ((m)->m_flags & M_PKTHDR) \ | |
94 | (m)->m_data = (m)->m_pktdat; \ | |
95 | else \ | |
96 | (m)->m_data = (m)->m_dat | |
97 | #define NFSMADV(m, s) (m)->m_data += (s) | |
98 | #define NFSMSIZ(m) ((M_HASCL(m))?MCLBYTES: \ | |
99 | (((m)->m_flags & M_PKTHDR)?MHLEN:MLEN)) | |
100 | ||
101 | /* | |
102 | * Now for the macros that do the simple stuff and call the functions | |
103 | * for the hard stuff. | |
104 | * These macros use several vars. declared in nfsm_reqhead and these | |
105 | * vars. must not be used elsewhere unless you are careful not to corrupt | |
106 | * them. The vars. starting with pN and tN (N=1,2,3,..) are temporaries | |
107 | * that may be used so long as the value is not expected to retained | |
108 | * after a macro. | |
109 | * I know, this is kind of dorkey, but it makes the actual op functions | |
110 | * fairly clean and deals with the mess caused by the xdr discriminating | |
111 | * unions. | |
112 | */ | |
113 | ||
114 | #define nfsm_build(a,c,s) \ | |
115 | { if ((s) > M_TRAILINGSPACE(mb)) { \ | |
116 | MGET(mb2, M_WAIT, MT_DATA); \ | |
117 | if ((s) > MLEN) \ | |
118 | panic("build > MLEN"); \ | |
119 | mb->m_next = mb2; \ | |
120 | mb = mb2; \ | |
121 | mb->m_len = 0; \ | |
122 | bpos = mtod(mb, caddr_t); \ | |
123 | } \ | |
124 | (a) = (c)(bpos); \ | |
125 | mb->m_len += (s); \ | |
126 | bpos += (s); } | |
127 | ||
128 | #define nfsm_dissect(a, c, s) \ | |
129 | { t1 = mtod(md, caddr_t)+md->m_len-dpos; \ | |
130 | if (t1 >= (s)) { \ | |
131 | (a) = (c)(dpos); \ | |
132 | dpos += (s); \ | |
133 | } else if ((t1 = nfsm_disct(&md, &dpos, (s), t1, &cp2))) { \ | |
134 | error = t1; \ | |
135 | m_freem(mrep); \ | |
136 | goto nfsmout; \ | |
137 | } else { \ | |
138 | (a) = (c)cp2; \ | |
139 | } } | |
140 | ||
141 | #define nfsm_fhtom(v, v3) \ | |
142 | { if (v3) { \ | |
143 | t2 = nfsm_rndup(VTONFS(v)->n_fhsize) + NFSX_UNSIGNED; \ | |
144 | if (t2 <= M_TRAILINGSPACE(mb)) { \ | |
145 | nfsm_build(tl, u_long *, t2); \ | |
146 | *tl++ = txdr_unsigned(VTONFS(v)->n_fhsize); \ | |
147 | *(tl + ((t2>>2) - 2)) = 0; \ | |
148 | bcopy((caddr_t)VTONFS(v)->n_fhp,(caddr_t)tl, \ | |
149 | VTONFS(v)->n_fhsize); \ | |
150 | } else if ((t2 = nfsm_strtmbuf(&mb, &bpos, \ | |
151 | (caddr_t)VTONFS(v)->n_fhp, VTONFS(v)->n_fhsize))) { \ | |
152 | error = t2; \ | |
153 | m_freem(mreq); \ | |
154 | goto nfsmout; \ | |
155 | } \ | |
156 | } else { \ | |
157 | nfsm_build(cp, caddr_t, NFSX_V2FH); \ | |
158 | bcopy((caddr_t)VTONFS(v)->n_fhp, cp, NFSX_V2FH); \ | |
159 | } } | |
160 | ||
161 | #define nfsm_srvfhtom(f, v3) \ | |
162 | { if (v3) { \ | |
163 | nfsm_build(tl, u_long *, NFSX_UNSIGNED + NFSX_V3FH); \ | |
164 | *tl++ = txdr_unsigned(NFSX_V3FH); \ | |
165 | bcopy((caddr_t)(f), (caddr_t)tl, NFSX_V3FH); \ | |
166 | } else { \ | |
167 | nfsm_build(cp, caddr_t, NFSX_V2FH); \ | |
168 | bcopy((caddr_t)(f), cp, NFSX_V2FH); \ | |
169 | } } | |
170 | ||
171 | #define nfsm_srvpostop_fh(f) \ | |
172 | { nfsm_build(tl, u_long *, 2 * NFSX_UNSIGNED + NFSX_V3FH); \ | |
173 | *tl++ = nfs_true; \ | |
174 | *tl++ = txdr_unsigned(NFSX_V3FH); \ | |
175 | bcopy((caddr_t)(f), (caddr_t)tl, NFSX_V3FH); \ | |
176 | } | |
177 | ||
fa4905b1 | 178 | #define nfsm_mtofh(d, v, v3, f, x) \ |
1c79356b A |
179 | { struct nfsnode *ttnp; nfsfh_t *ttfhp; int ttfhsize; \ |
180 | if (v3) { \ | |
181 | nfsm_dissect(tl, u_long *, NFSX_UNSIGNED); \ | |
182 | (f) = fxdr_unsigned(int, *tl); \ | |
183 | } else \ | |
184 | (f) = 1; \ | |
185 | if (f) { \ | |
186 | nfsm_getfh(ttfhp, ttfhsize, (v3)); \ | |
187 | if ((t1 = nfs_nget((d)->v_mount, ttfhp, ttfhsize, \ | |
188 | &ttnp))) { \ | |
189 | error = t1; \ | |
190 | m_freem(mrep); \ | |
191 | goto nfsmout; \ | |
192 | } \ | |
193 | (v) = NFSTOV(ttnp); \ | |
194 | } \ | |
195 | if (v3) { \ | |
196 | nfsm_dissect(tl, u_long *, NFSX_UNSIGNED); \ | |
197 | if (f) \ | |
198 | (f) = fxdr_unsigned(int, *tl); \ | |
199 | else if (fxdr_unsigned(int, *tl)) \ | |
200 | nfsm_adv(NFSX_V3FATTR); \ | |
201 | } \ | |
202 | if (f) \ | |
fa4905b1 | 203 | nfsm_loadattr((v), (struct vattr *)0, (x)); \ |
1c79356b A |
204 | } |
205 | ||
206 | #define nfsm_getfh(f, s, v3) \ | |
207 | { if (v3) { \ | |
208 | nfsm_dissect(tl, u_long *, NFSX_UNSIGNED); \ | |
209 | if (((s) = fxdr_unsigned(int, *tl)) <= 0 || \ | |
210 | (s) > NFSX_V3FHMAX) { \ | |
211 | m_freem(mrep); \ | |
212 | error = EBADRPC; \ | |
213 | goto nfsmout; \ | |
214 | } \ | |
215 | } else \ | |
216 | (s) = NFSX_V2FH; \ | |
217 | nfsm_dissect((f), nfsfh_t *, nfsm_rndup(s)); } | |
218 | ||
fa4905b1 | 219 | #define nfsm_loadattr(v, a, x) \ |
1c79356b | 220 | { struct vnode *ttvp = (v); \ |
fa4905b1 A |
221 | if ((t1 = nfs_loadattrcache(&ttvp, &md, &dpos, (a), 0, \ |
222 | (x)))) { \ | |
1c79356b A |
223 | error = t1; \ |
224 | m_freem(mrep); \ | |
225 | goto nfsmout; \ | |
226 | } \ | |
227 | (v) = ttvp; } | |
228 | ||
fa4905b1 | 229 | #define nfsm_postop_attr(v, f, x) \ |
1c79356b A |
230 | { struct vnode *ttvp = (v); \ |
231 | nfsm_dissect(tl, u_long *, NFSX_UNSIGNED); \ | |
232 | if (((f) = fxdr_unsigned(int, *tl))) { \ | |
233 | if ((t1 = nfs_loadattrcache(&ttvp, &md, &dpos, \ | |
fa4905b1 | 234 | (struct vattr *)0, 1, (x)))) { \ |
1c79356b A |
235 | error = t1; \ |
236 | (f) = 0; \ | |
237 | m_freem(mrep); \ | |
238 | goto nfsmout; \ | |
239 | } \ | |
fa4905b1 A |
240 | if (*(x) == 0) \ |
241 | (f) = 0; \ | |
1c79356b A |
242 | (v) = ttvp; \ |
243 | } } | |
244 | ||
245 | /* Used as (f) for nfsm_wcc_data() */ | |
246 | #define NFSV3_WCCRATTR 0 | |
247 | #define NFSV3_WCCCHK 1 | |
248 | ||
fa4905b1 | 249 | #define nfsm_wcc_data(v, f, x) \ |
1c79356b A |
250 | { int ttattrf, ttretf = 0; \ |
251 | nfsm_dissect(tl, u_long *, NFSX_UNSIGNED); \ | |
252 | if (*tl == nfs_true) { \ | |
253 | nfsm_dissect(tl, u_long *, 6 * NFSX_UNSIGNED); \ | |
254 | if (f) \ | |
255 | ttretf = (VTONFS(v)->n_mtime == \ | |
256 | fxdr_unsigned(u_long, *(tl + 2))); \ | |
257 | } \ | |
fa4905b1 | 258 | nfsm_postop_attr((v), ttattrf, (x)); \ |
1c79356b A |
259 | if (f) { \ |
260 | (f) = ttretf; \ | |
261 | } else { \ | |
262 | (f) = ttattrf; \ | |
263 | } } | |
264 | ||
265 | #define nfsm_v3sattr(s, a, u, g) \ | |
266 | { (s)->sa_modetrue = nfs_true; \ | |
267 | (s)->sa_mode = vtonfsv3_mode((a)->va_mode); \ | |
268 | (s)->sa_uidtrue = nfs_true; \ | |
269 | (s)->sa_uid = txdr_unsigned(u); \ | |
270 | (s)->sa_gidtrue = nfs_true; \ | |
271 | (s)->sa_gid = txdr_unsigned(g); \ | |
272 | (s)->sa_sizefalse = nfs_false; \ | |
273 | (s)->sa_atimetype = txdr_unsigned(NFSV3SATTRTIME_TOSERVER); \ | |
274 | (s)->sa_mtimetype = txdr_unsigned(NFSV3SATTRTIME_TOSERVER); \ | |
275 | } | |
276 | ||
277 | #define nfsm_strsiz(s,m) \ | |
278 | { nfsm_dissect(tl,u_long *,NFSX_UNSIGNED); \ | |
279 | if (((s) = fxdr_unsigned(long,*tl)) > (m)) { \ | |
280 | m_freem(mrep); \ | |
281 | error = EBADRPC; \ | |
282 | goto nfsmout; \ | |
283 | } } | |
284 | ||
285 | #define nfsm_srvstrsiz(s,m) \ | |
286 | { nfsm_dissect(tl,u_long *,NFSX_UNSIGNED); \ | |
287 | if (((s) = fxdr_unsigned(long,*tl)) > (m) || (s) <= 0) { \ | |
288 | error = EBADRPC; \ | |
289 | nfsm_reply(0); \ | |
290 | } } | |
291 | ||
292 | #define nfsm_srvnamesiz(s) \ | |
293 | { nfsm_dissect(tl,u_long *,NFSX_UNSIGNED); \ | |
294 | if (((s) = fxdr_unsigned(long,*tl)) > NFS_MAXNAMLEN) \ | |
295 | error = NFSERR_NAMETOL; \ | |
296 | if ((s) <= 0) \ | |
297 | error = EBADRPC; \ | |
298 | if (error) \ | |
299 | nfsm_reply(0); \ | |
300 | } | |
301 | ||
302 | #define nfsm_mtouio(p,s) \ | |
303 | if ((s) > 0 && \ | |
304 | (t1 = nfsm_mbuftouio(&md,(p),(s),&dpos))) { \ | |
305 | error = t1; \ | |
306 | m_freem(mrep); \ | |
307 | goto nfsmout; \ | |
308 | } | |
309 | ||
310 | #define nfsm_uiotom(p,s) \ | |
311 | if ((t1 = nfsm_uiotombuf((p),&mb,(s),&bpos))) { \ | |
312 | error = t1; \ | |
313 | m_freem(mreq); \ | |
314 | goto nfsmout; \ | |
315 | } | |
316 | ||
317 | #define nfsm_reqhead(v,a,s) \ | |
318 | mb = mreq = nfsm_reqh((v),(a),(s),&bpos) | |
319 | ||
320 | #define nfsm_reqdone m_freem(mrep); \ | |
321 | nfsmout: | |
322 | ||
323 | #define nfsm_rndup(a) (((a)+3)&(~0x3)) | |
324 | ||
325 | /* | |
326 | * We seem to see cases mainly on shutdown where the vnode got recycled | |
327 | * on use while waiting on server. Maybe nfs vnode locking will help if | |
328 | * we implement that, but for now, check for bad vnodes and return an | |
329 | * error. This call spot should catch most of them. Note that NFSv2 | |
330 | * just goes to nfsmout here, while nfsV3 goes back to caller's next | |
331 | * line for post-processing. It will do a nfsm_reqdone also making | |
332 | * m_freem(mrep). Wondering if some of our freeing problems could be | |
333 | * due to nfsv3 calling nfsm_reqdone unlike nfsv2. Separate problem. | |
334 | */ | |
fa4905b1 | 335 | #define nfsm_request(v, t, p, c, x) \ |
1c79356b | 336 | { \ |
55e303ae A |
337 | int nfsv3; \ |
338 | if (!VFSTONFS((v)->v_mount)) { \ | |
339 | error = ENXIO; \ | |
340 | goto nfsmout; \ | |
341 | } \ | |
342 | nfsv3 = (VFSTONFS((v)->v_mount))->nm_flag & NFSMNT_NFSV3; \ | |
1c79356b | 343 | if ((error = nfs_request((v), mreq, (t), (p), \ |
fa4905b1 | 344 | (c), &mrep, &md, &dpos, (x)))) { \ |
1c79356b A |
345 | if (error & NFSERR_RETERR) \ |
346 | error &= ~NFSERR_RETERR; \ | |
347 | else \ | |
348 | goto nfsmout; \ | |
349 | } \ | |
1c79356b A |
350 | } |
351 | ||
352 | #define nfsm_strtom(a,s,m) \ | |
353 | if ((s) > (m)) { \ | |
354 | m_freem(mreq); \ | |
355 | error = ENAMETOOLONG; \ | |
356 | goto nfsmout; \ | |
357 | } \ | |
358 | t2 = nfsm_rndup(s)+NFSX_UNSIGNED; \ | |
359 | if (t2 <= M_TRAILINGSPACE(mb)) { \ | |
360 | nfsm_build(tl,u_long *,t2); \ | |
361 | *tl++ = txdr_unsigned(s); \ | |
362 | *(tl+((t2>>2)-2)) = 0; \ | |
363 | bcopy((caddr_t)(a), (caddr_t)tl, (s)); \ | |
364 | } else if ((t2 = nfsm_strtmbuf(&mb, &bpos, (a), (s)))) { \ | |
365 | error = t2; \ | |
366 | m_freem(mreq); \ | |
367 | goto nfsmout; \ | |
368 | } | |
369 | ||
370 | #define nfsm_srvdone \ | |
371 | nfsmout: \ | |
372 | return(error) | |
373 | ||
374 | #define nfsm_reply(s) \ | |
375 | { \ | |
376 | nfsd->nd_repstat = error; \ | |
377 | if (error && !(nfsd->nd_flag & ND_NFSV3)) \ | |
378 | (void) nfs_rephead(0, nfsd, slp, error, cache, &frev, \ | |
379 | mrq, &mb, &bpos); \ | |
380 | else \ | |
381 | (void) nfs_rephead((s), nfsd, slp, error, cache, &frev, \ | |
382 | mrq, &mb, &bpos); \ | |
383 | m_freem(mrep); \ | |
384 | mreq = *mrq; \ | |
385 | if (error && (!(nfsd->nd_flag & ND_NFSV3) || \ | |
386 | error == EBADRPC)) \ | |
387 | return(0); \ | |
388 | } | |
389 | ||
390 | #define nfsm_writereply(s, v3) \ | |
391 | { \ | |
392 | nfsd->nd_repstat = error; \ | |
393 | if (error && !(v3)) \ | |
394 | (void) nfs_rephead(0, nfsd, slp, error, cache, &frev, \ | |
395 | &mreq, &mb, &bpos); \ | |
396 | else \ | |
397 | (void) nfs_rephead((s), nfsd, slp, error, cache, &frev, \ | |
398 | &mreq, &mb, &bpos); \ | |
399 | } | |
400 | ||
401 | #define nfsm_adv(s) \ | |
402 | { t1 = mtod(md, caddr_t)+md->m_len-dpos; \ | |
403 | if (t1 >= (s)) { \ | |
404 | dpos += (s); \ | |
405 | } else if ((t1 = nfs_adv(&md, &dpos, (s), t1))) { \ | |
406 | error = t1; \ | |
407 | m_freem(mrep); \ | |
408 | goto nfsmout; \ | |
409 | } } | |
410 | ||
411 | #define nfsm_srvmtofh(f) \ | |
412 | { if (nfsd->nd_flag & ND_NFSV3) { \ | |
413 | nfsm_dissect(tl, u_long *, NFSX_UNSIGNED); \ | |
414 | if (fxdr_unsigned(int, *tl) != NFSX_V3FH) { \ | |
415 | error = EBADRPC; \ | |
416 | nfsm_reply(0); \ | |
417 | } \ | |
418 | } \ | |
419 | nfsm_dissect(tl, u_long *, NFSX_V3FH); \ | |
420 | bcopy((caddr_t)tl, (caddr_t)(f), NFSX_V3FH); \ | |
421 | if ((nfsd->nd_flag & ND_NFSV3) == 0) \ | |
422 | nfsm_adv(NFSX_V2FH - NFSX_V3FH); \ | |
423 | } | |
424 | ||
425 | #define nfsm_clget \ | |
426 | if (bp >= be) { \ | |
427 | if (mp == mb) \ | |
428 | mp->m_len += bp-bpos; \ | |
429 | MGET(mp, M_WAIT, MT_DATA); \ | |
430 | MCLGET(mp, M_WAIT); \ | |
431 | mp->m_len = NFSMSIZ(mp); \ | |
432 | mp2->m_next = mp; \ | |
433 | mp2 = mp; \ | |
434 | bp = mtod(mp, caddr_t); \ | |
435 | be = bp+mp->m_len; \ | |
436 | } \ | |
437 | tl = (u_long *)bp | |
438 | ||
439 | #define nfsm_srvfillattr(a, f) \ | |
440 | nfsm_srvfattr(nfsd, (a), (f)) | |
441 | ||
442 | #define nfsm_srvwcc_data(br, b, ar, a) \ | |
443 | nfsm_srvwcc(nfsd, (br), (b), (ar), (a), &mb, &bpos) | |
444 | ||
445 | #define nfsm_srvpostop_attr(r, a) \ | |
446 | nfsm_srvpostopattr(nfsd, (r), (a), &mb, &bpos) | |
447 | ||
448 | #define nfsm_srvsattr(a) \ | |
55e303ae A |
449 | { \ |
450 | struct timeval now; \ | |
451 | nfsm_dissect(tl, u_long *, NFSX_UNSIGNED); \ | |
1c79356b A |
452 | if (*tl == nfs_true) { \ |
453 | nfsm_dissect(tl, u_long *, NFSX_UNSIGNED); \ | |
454 | (a)->va_mode = nfstov_mode(*tl); \ | |
455 | } \ | |
456 | nfsm_dissect(tl, u_long *, NFSX_UNSIGNED); \ | |
457 | if (*tl == nfs_true) { \ | |
458 | nfsm_dissect(tl, u_long *, NFSX_UNSIGNED); \ | |
459 | (a)->va_uid = fxdr_unsigned(uid_t, *tl); \ | |
460 | } \ | |
461 | nfsm_dissect(tl, u_long *, NFSX_UNSIGNED); \ | |
462 | if (*tl == nfs_true) { \ | |
463 | nfsm_dissect(tl, u_long *, NFSX_UNSIGNED); \ | |
464 | (a)->va_gid = fxdr_unsigned(gid_t, *tl); \ | |
465 | } \ | |
466 | nfsm_dissect(tl, u_long *, NFSX_UNSIGNED); \ | |
467 | if (*tl == nfs_true) { \ | |
468 | nfsm_dissect(tl, u_long *, 2 * NFSX_UNSIGNED); \ | |
469 | fxdr_hyper(tl, &(a)->va_size); \ | |
470 | } \ | |
471 | nfsm_dissect(tl, u_long *, NFSX_UNSIGNED); \ | |
55e303ae | 472 | microtime(&now); \ |
1c79356b A |
473 | switch (fxdr_unsigned(int, *tl)) { \ |
474 | case NFSV3SATTRTIME_TOCLIENT: \ | |
475 | nfsm_dissect(tl, u_long *, 2 * NFSX_UNSIGNED); \ | |
476 | fxdr_nfsv3time(tl, &(a)->va_atime); \ | |
477 | break; \ | |
478 | case NFSV3SATTRTIME_TOSERVER: \ | |
55e303ae A |
479 | (a)->va_atime.tv_sec = now.tv_sec; \ |
480 | (a)->va_atime.tv_nsec = now.tv_usec * 1000; \ | |
1c79356b A |
481 | break; \ |
482 | }; \ | |
483 | nfsm_dissect(tl, u_long *, NFSX_UNSIGNED); \ | |
484 | switch (fxdr_unsigned(int, *tl)) { \ | |
485 | case NFSV3SATTRTIME_TOCLIENT: \ | |
486 | nfsm_dissect(tl, u_long *, 2 * NFSX_UNSIGNED); \ | |
487 | fxdr_nfsv3time(tl, &(a)->va_mtime); \ | |
488 | break; \ | |
489 | case NFSV3SATTRTIME_TOSERVER: \ | |
55e303ae A |
490 | (a)->va_mtime.tv_sec = now.tv_sec; \ |
491 | (a)->va_mtime.tv_nsec = now.tv_usec * 1000; \ | |
1c79356b A |
492 | break; \ |
493 | }; } | |
494 | ||
9bccf70c A |
495 | #endif /* __APPLE_API_PRIVATE */ |
496 | #endif /* _NFS_NFSM_SUBS_H_ */ |