]> git.saurik.com Git - apple/xnu.git/blob - bsd/nfs/nfsm_subs.h
xnu-792.13.8.tar.gz
[apple/xnu.git] / bsd / nfs / nfsm_subs.h
1 /*
2 * Copyright (c) 2000-2005 Apple Computer, Inc. All rights reserved.
3 *
4 * @APPLE_LICENSE_OSREFERENCE_HEADER_START@
5 *
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. The rights granted to you under the
10 * License may not be used to create, or enable the creation or
11 * redistribution of, unlawful or unlicensed copies of an Apple operating
12 * system, or to circumvent, violate, or enable the circumvention or
13 * violation of, any terms of an Apple operating system software license
14 * agreement.
15 *
16 * Please obtain a copy of the License at
17 * http://www.opensource.apple.com/apsl/ and read it before using this
18 * file.
19 *
20 * The Original Code and all software distributed under the License are
21 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
22 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
23 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
24 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
25 * Please see the License for the specific language governing rights and
26 * limitations under the License.
27 *
28 * @APPLE_LICENSE_OSREFERENCE_HEADER_END@
29 */
30 /* Copyright (c) 1995 NeXT Computer, Inc. All Rights Reserved */
31 /*
32 * Copyright (c) 1989, 1993
33 * The Regents of the University of California. All rights reserved.
34 *
35 * This code is derived from software contributed to Berkeley by
36 * Rick Macklem at The University of Guelph.
37 *
38 * Redistribution and use in source and binary forms, with or without
39 * modification, are permitted provided that the following conditions
40 * are met:
41 * 1. Redistributions of source code must retain the above copyright
42 * notice, this list of conditions and the following disclaimer.
43 * 2. Redistributions in binary form must reproduce the above copyright
44 * notice, this list of conditions and the following disclaimer in the
45 * documentation and/or other materials provided with the distribution.
46 * 3. All advertising materials mentioning features or use of this software
47 * must display the following acknowledgement:
48 * This product includes software developed by the University of
49 * California, Berkeley and its contributors.
50 * 4. Neither the name of the University nor the names of its contributors
51 * may be used to endorse or promote products derived from this software
52 * without specific prior written permission.
53 *
54 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
55 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
56 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
57 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
58 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
59 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
60 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
61 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
62 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
63 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
64 * SUCH DAMAGE.
65 *
66 * @(#)nfsm_subs.h 8.2 (Berkeley) 3/30/95
67 * FreeBSD-Id: nfsm_subs.h,v 1.13 1997/07/16 09:06:30 dfr Exp $
68 */
69
70
71 #ifndef _NFS_NFSM_SUBS_H_
72 #define _NFS_NFSM_SUBS_H_
73
74 #include <sys/appleapiopts.h>
75
76 #ifdef __APPLE_API_PRIVATE
77 /*
78 * These macros do strange and peculiar things to mbuf chains for
79 * the assistance of the nfs code. To attempt to use them for any
80 * other purpose will be dangerous. (they make weird assumptions)
81 */
82
83 /*
84 * First define what the actual subs. return
85 */
86 int nfsm_reqh(int hsiz, caddr_t *bposp, mbuf_t *mbp);
87 int nfsm_rpchead(struct ucred *cr, int nmflag, int procid,
88 int auth_type, int auth_len, char *auth_str,
89 int verf_len, char *verf_str,
90 mbuf_t mrest, int mrest_len,
91 mbuf_t *mbp, u_long *xidp, mbuf_t *mreqp);
92
93 /*
94 * Now for the macros that do the simple stuff and call the functions
95 * for the hard stuff.
96 * These macros use several vars. declared in nfsm_reqhead and these
97 * vars. must not be used elsewhere unless you are careful not to corrupt
98 * them. The vars. starting with pN and tN (N=1,2,3,..) are temporaries
99 * that may be used so long as the value is not expected to retained
100 * after a macro.
101 * I know, this is kind of dorkey, but it makes the actual op functions
102 * fairly clean and deals with the mess caused by the xdr discriminating
103 * unions.
104 */
105
106 #define nfsm_build(a,c,s) \
107 { if ((s) > mbuf_trailingspace(mb)) { \
108 int __nfsm_error; \
109 __nfsm_error = mbuf_get(MBUF_WAITOK, MBUF_TYPE_DATA, &mb2); \
110 if (__nfsm_error) \
111 panic("nfsm_build mbuf_get error %d", __nfsm_error); \
112 if ((s) > mbuf_maxlen(mb2)) \
113 panic("nfsm_build size error"); \
114 __nfsm_error = mbuf_setnext(mb, mb2); \
115 if (__nfsm_error) \
116 panic("nfsm_build mbuf_setnext error %d", __nfsm_error); \
117 mb = mb2; \
118 bpos = mbuf_data(mb); \
119 } \
120 (a) = (c)(bpos); \
121 mbuf_setlen(mb, (mbuf_len(mb) + (s))); \
122 bpos += (s); }
123
124 #define nfsm_dissect(a, c, s) \
125 { t1 = ((caddr_t)mbuf_data(md)) + mbuf_len(md) - dpos; \
126 if (t1 >= (s)) { \
127 (a) = (c)(dpos); \
128 dpos += (s); \
129 } else if ((t1 = nfsm_disct(&md, &dpos, (s), t1, &cp2))) { \
130 error = t1; \
131 mbuf_freem(mrep); \
132 goto nfsmout; \
133 } else { \
134 (a) = (c)cp2; \
135 } }
136
137 #define nfsm_fhtom(v, v3) \
138 { if (v3) { \
139 t2 = nfsm_rndup(VTONFS(v)->n_fhsize) + NFSX_UNSIGNED; \
140 if (t2 <= mbuf_trailingspace(mb)) { \
141 nfsm_build(tl, u_long *, t2); \
142 *tl++ = txdr_unsigned(VTONFS(v)->n_fhsize); \
143 *(tl + ((t2>>2) - 2)) = 0; \
144 bcopy((caddr_t)VTONFS(v)->n_fhp,(caddr_t)tl, \
145 VTONFS(v)->n_fhsize); \
146 } else if ((t2 = nfsm_strtmbuf(&mb, &bpos, \
147 (caddr_t)VTONFS(v)->n_fhp, VTONFS(v)->n_fhsize))) { \
148 error = t2; \
149 mbuf_freem(mreq); \
150 goto nfsmout; \
151 } \
152 } else { \
153 nfsm_build(cp, caddr_t, NFSX_V2FH); \
154 bcopy((caddr_t)VTONFS(v)->n_fhp, cp, NFSX_V2FH); \
155 } }
156
157 #define nfsm_srvfhtom(f, v3) \
158 { if (v3) { \
159 nfsm_build(tl, u_long *, NFSX_UNSIGNED + (unsigned)(f)->nfh_len); \
160 *tl++ = txdr_unsigned((f)->nfh_len); \
161 bcopy((caddr_t)&(f)->nfh_xh, (caddr_t)tl, (f)->nfh_len); \
162 } else { \
163 nfsm_build(cp, caddr_t, NFSX_V2FH); \
164 bcopy((caddr_t)&(f)->nfh_xh, cp, NFSX_V2FH); \
165 } }
166
167 #define nfsm_srvpostop_fh(f) \
168 { nfsm_build(tl, u_long *, 2 * NFSX_UNSIGNED + (unsigned)(f)->nfh_len); \
169 *tl++ = nfs_true; \
170 *tl++ = txdr_unsigned((f)->nfh_len); \
171 bcopy((caddr_t)&(f)->nfh_xh, (caddr_t)tl, (f)->nfh_len); \
172 }
173
174 #define nfsm_mtofh(d, cnp, v, v3, xp, f) \
175 { \
176 struct nfsnode *ttnp; u_char *ttfhp = NULL; \
177 int ttfhsize = 0, ttgotfh = 1, ttgotattr = 1, ttgotnode = 0; \
178 struct nfs_vattr ttvattr; \
179 (v) = NULL; \
180 /* XXX would be nice to not bail to nfsmout on error */ \
181 if (v3) { /* check for file handle */ \
182 nfsm_dissect(tl, u_long *, NFSX_UNSIGNED); \
183 ttgotfh = fxdr_unsigned(int, *tl); \
184 } \
185 if (ttgotfh) { \
186 /* get file handle */ \
187 nfsm_getfh(ttfhp, ttfhsize, (v3)); \
188 } \
189 if (v3) { /* check for attributes */ \
190 nfsm_dissect(tl, u_long *, NFSX_UNSIGNED); \
191 ttgotattr = fxdr_unsigned(int, *tl); \
192 } \
193 /* get attributes */ \
194 if (ttgotattr) { \
195 if (!ttgotfh) { \
196 nfsm_adv(NFSX_V3FATTR); \
197 } else { \
198 nfsm_attr_get(v3, &ttvattr); \
199 } \
200 } else if (ttgotfh) { \
201 /* We need valid attributes in order */ \
202 /* to call nfs_nget/vnode_create(). */ \
203 t1 = nfs_getattr_no_vnode(vnode_mount(d), \
204 ttfhp, ttfhsize, cred, p, &ttvattr, xp); \
205 if (t1) \
206 ttgotattr = 0; \
207 } \
208 if (ttgotfh && ttgotattr) { \
209 int ttngflags = NG_MAKEENTRY; \
210 if ((t1 = nfs_nget(vnode_mount(d), d, cnp, ttfhp, ttfhsize, \
211 &ttvattr, xp, ttngflags, &ttnp))) { \
212 error = t1; \
213 ttgotnode = 0; \
214 } else { \
215 ttgotnode = 1; \
216 (v) = NFSTOV(ttnp); \
217 } \
218 } \
219 (f) = ttgotnode; \
220 }
221
222 #define nfsm_getfh(f, s, v3) \
223 { if (v3) { \
224 nfsm_dissect(tl, u_long *, NFSX_UNSIGNED); \
225 if (((s) = fxdr_unsigned(int, *tl)) <= 0 || \
226 (s) > NFSX_V3FHMAX) { \
227 mbuf_freem(mrep); \
228 error = EBADRPC; \
229 goto nfsmout; \
230 } \
231 } else { \
232 (s) = NFSX_V2FH; \
233 } \
234 nfsm_dissect((f), u_char *, nfsm_rndup(s)); }
235
236 #define nfsm_loadattr(v, v3, a, x) \
237 { struct nfs_vattr ttvattr; \
238 if ((t1 = nfs_parsefattr(&md, &dpos, v3, &ttvattr))) { \
239 error = t1; \
240 mbuf_freem(mrep); \
241 goto nfsmout; \
242 } \
243 if ((t1 = nfs_loadattrcache(VTONFS(v), &ttvattr, (x), 0))) { \
244 error = t1; \
245 mbuf_freem(mrep); \
246 goto nfsmout; \
247 } \
248 if (a) { \
249 bcopy(&ttvattr, (a), sizeof(ttvattr)); \
250 } \
251 }
252
253 #define nfsm_attr_get(v3, vap) \
254 { \
255 if ((t1 = nfs_parsefattr(&md, &dpos, v3, vap))) { \
256 error = t1; \
257 mbuf_freem(mrep); \
258 goto nfsmout; \
259 } \
260 }
261
262 #define nfsm_postop_attr_get(v3, f, vap) \
263 { \
264 nfsm_dissect(tl, u_long *, NFSX_UNSIGNED); \
265 if (((f) = fxdr_unsigned(int, *tl))) { \
266 if ((t1 = nfs_parsefattr(&md, &dpos, v3, vap))) { \
267 error = t1; \
268 (f) = 0; \
269 mbuf_freem(mrep); \
270 goto nfsmout; \
271 } \
272 } }
273
274 #define nfsm_postop_attr_update(v, v3, f, x) \
275 { \
276 nfsm_dissect(tl, u_long *, NFSX_UNSIGNED); \
277 if (((f) = fxdr_unsigned(int, *tl))) { \
278 struct nfs_vattr ttvattr; \
279 if ((t1 = nfs_parsefattr(&md, &dpos, v3, &ttvattr))) { \
280 error = t1; \
281 (f) = 0; \
282 mbuf_freem(mrep); \
283 goto nfsmout; \
284 } \
285 if ((t1 = nfs_loadattrcache(VTONFS(v), &ttvattr, (x), 1))) { \
286 error = t1; \
287 (f) = 0; \
288 mbuf_freem(mrep); \
289 goto nfsmout; \
290 } \
291 if (*(x) == 0) \
292 (f) = 0; \
293 } }
294
295 #define nfsm_wcc_data(v, premtime, newpostattr, x) \
296 { \
297 nfsm_dissect(tl, u_long *, NFSX_UNSIGNED); \
298 if (*tl == nfs_true) { \
299 nfsm_dissect(tl, u_long *, 6 * NFSX_UNSIGNED); \
300 (premtime)->tv_sec = fxdr_unsigned(time_t, *(tl + 2)); \
301 (premtime)->tv_nsec = fxdr_unsigned(time_t, *(tl + 3)); \
302 } else { \
303 (premtime)->tv_sec = 0; \
304 (premtime)->tv_nsec = 0; \
305 } \
306 nfsm_postop_attr_update((v), 1, (newpostattr), (x)); \
307 }
308
309 #define nfsm_v3sattr(vap) \
310 {\
311 struct timeval now; \
312 if (VATTR_IS_ACTIVE(vap, va_mode)) { \
313 nfsm_build(tl, u_long *, 2 * NFSX_UNSIGNED); \
314 *tl++ = nfs_true; \
315 *tl = txdr_unsigned(vap->va_mode); \
316 } else { \
317 nfsm_build(tl, u_long *, NFSX_UNSIGNED); \
318 *tl = nfs_false; \
319 } \
320 if (VATTR_IS_ACTIVE(vap, va_uid)) { \
321 nfsm_build(tl, u_long *, 2 * NFSX_UNSIGNED); \
322 *tl++ = nfs_true; \
323 *tl = txdr_unsigned(vap->va_uid); \
324 } else { \
325 nfsm_build(tl, u_long *, NFSX_UNSIGNED); \
326 *tl = nfs_false; \
327 } \
328 if (VATTR_IS_ACTIVE(vap, va_gid)) { \
329 nfsm_build(tl, u_long *, 2 * NFSX_UNSIGNED); \
330 *tl++ = nfs_true; \
331 *tl = txdr_unsigned(vap->va_gid); \
332 } else { \
333 nfsm_build(tl, u_long *, NFSX_UNSIGNED); \
334 *tl = nfs_false; \
335 } \
336 if (VATTR_IS_ACTIVE(vap, va_data_size)) { \
337 nfsm_build(tl, u_long *, 3 * NFSX_UNSIGNED); \
338 *tl++ = nfs_true; \
339 txdr_hyper(&vap->va_data_size, tl); \
340 } else { \
341 nfsm_build(tl, u_long *, NFSX_UNSIGNED); \
342 *tl = nfs_false; \
343 } \
344 microtime(&now); \
345 if (VATTR_IS_ACTIVE(vap, va_access_time)) { \
346 if (vap->va_access_time.tv_sec != now.tv_sec) { \
347 nfsm_build(tl, u_long *, 3 * NFSX_UNSIGNED); \
348 *tl++ = txdr_unsigned(NFSV3SATTRTIME_TOCLIENT); \
349 txdr_nfsv3time(&vap->va_access_time, tl); \
350 } else { \
351 nfsm_build(tl, u_long *, NFSX_UNSIGNED); \
352 *tl = txdr_unsigned(NFSV3SATTRTIME_TOSERVER); \
353 } \
354 } else { \
355 nfsm_build(tl, u_long *, NFSX_UNSIGNED); \
356 *tl = txdr_unsigned(NFSV3SATTRTIME_DONTCHANGE); \
357 } \
358 if (VATTR_IS_ACTIVE(vap, va_modify_time)) { \
359 if (vap->va_modify_time.tv_sec != now.tv_sec) { \
360 nfsm_build(tl, u_long *, 3 * NFSX_UNSIGNED); \
361 *tl++ = txdr_unsigned(NFSV3SATTRTIME_TOCLIENT); \
362 txdr_nfsv3time(&vap->va_modify_time, tl); \
363 } else { \
364 nfsm_build(tl, u_long *, NFSX_UNSIGNED); \
365 *tl = txdr_unsigned(NFSV3SATTRTIME_TOSERVER); \
366 } \
367 } else { \
368 nfsm_build(tl, u_long *, NFSX_UNSIGNED); \
369 *tl = txdr_unsigned(NFSV3SATTRTIME_DONTCHANGE); \
370 } \
371 }
372
373 #define nfsm_strsiz(s,m,v3) \
374 { nfsm_dissect(tl,u_long *,NFSX_UNSIGNED); \
375 (s) = fxdr_unsigned(long,*tl); \
376 if (!(v3) && ((s) > (m))) { \
377 mbuf_freem(mrep); \
378 error = EBADRPC; \
379 goto nfsmout; \
380 } }
381
382 #define nfsm_srvstrsiz(s,m) \
383 { nfsm_dissect(tl,u_long *,NFSX_UNSIGNED); \
384 if (((s) = fxdr_unsigned(long,*tl)) > (m) || (s) <= 0) { \
385 error = EBADRPC; \
386 nfsm_reply(0); \
387 } }
388
389 #define nfsm_srvnamesiz(s,v3) \
390 { nfsm_dissect(tl,u_long *,NFSX_UNSIGNED); \
391 (s) = fxdr_unsigned(long,*tl); \
392 if (!(v3) && ((s) > NFS_MAXNAMLEN)) \
393 error = NFSERR_NAMETOL; \
394 if ((s) <= 0) \
395 error = EBADRPC; \
396 if (error) \
397 nfsm_reply(0); \
398 }
399
400 #define nfsm_mtouio(p,s) \
401 if ((s) > 0 && \
402 (t1 = nfsm_mbuftouio(&md,(p),(s),&dpos))) { \
403 error = t1; \
404 mbuf_freem(mrep); \
405 goto nfsmout; \
406 }
407
408 #define nfsm_uiotom(p,s) \
409 if ((t1 = nfsm_uiotombuf((p),&mb,(s),&bpos))) { \
410 error = t1; \
411 mbuf_freem(mreq); \
412 goto nfsmout; \
413 }
414
415 #define nfsm_reqhead(s) \
416 error = nfsm_reqh((s), &bpos, &mreq); \
417 mb = mreq;
418
419 #define nfsm_reqdone mbuf_freem(mrep); \
420 nfsmout:
421
422 #define nfsm_rndup(a) (((a)+3)&(~0x3))
423
424 #define nfsm_request(v, t, p, c, x) \
425 if ((error = nfs_request((v), vnode_mount(v), mreq, (t), (p), \
426 (c), &mrep, &md, &dpos, (x)))) { \
427 if (error & NFSERR_RETERR) \
428 error &= ~NFSERR_RETERR; \
429 else \
430 goto nfsmout; \
431 }
432
433 #define nfsm_strtom(a,s,m,v3) \
434 if (!(v3) && ((s) > (m))) { \
435 mbuf_freem(mreq); \
436 error = ENAMETOOLONG; \
437 goto nfsmout; \
438 } \
439 t2 = nfsm_rndup(s)+NFSX_UNSIGNED; \
440 if (t2 <= mbuf_trailingspace(mb)) { \
441 nfsm_build(tl,u_long *,t2); \
442 *tl++ = txdr_unsigned(s); \
443 *(tl+((t2>>2)-2)) = 0; \
444 bcopy((caddr_t)(a), (caddr_t)tl, (s)); \
445 } else if ((t2 = nfsm_strtmbuf(&mb, &bpos, (a), (s)))) { \
446 error = t2; \
447 mbuf_freem(mreq); \
448 goto nfsmout; \
449 }
450
451 #define nfsm_srvdone \
452 nfsmout: \
453 return(error)
454
455 #define nfsm_reply(s) \
456 { \
457 nfsd->nd_repstat = error; \
458 if (error && !(nfsd->nd_flag & ND_NFSV3)) \
459 nfs_rephead(0, nfsd, slp, error, mrq, &mb, &bpos); \
460 else \
461 nfs_rephead((s), nfsd, slp, error, mrq, &mb, &bpos); \
462 mbuf_freem(mrep); \
463 mrep = NULL; \
464 mreq = *mrq; \
465 if (error && (!(nfsd->nd_flag & ND_NFSV3) || \
466 error == EBADRPC)) { \
467 error = 0; \
468 goto nfsmout; \
469 } \
470 }
471
472 #define nfsm_writereply(s, v3) \
473 { \
474 nfsd->nd_repstat = error; \
475 if (error && !(v3)) \
476 nfs_rephead(0, nfsd, slp, error, &mreq, &mb, &bpos); \
477 else \
478 nfs_rephead((s), nfsd, slp, error, &mreq, &mb, &bpos); \
479 }
480
481 #define nfsm_adv(s) \
482 { t1 = ((caddr_t)mbuf_data(md)) + mbuf_len(md) - dpos; \
483 if (t1 >= (s)) { \
484 dpos += (s); \
485 } else if ((t1 = nfs_adv(&md, &dpos, (s), t1))) { \
486 error = t1; \
487 mbuf_freem(mrep); \
488 goto nfsmout; \
489 } }
490
491 #define nfsm_srvmtofh(f) \
492 { \
493 if (nfsd->nd_flag & ND_NFSV3) { \
494 nfsm_dissect(tl, u_long *, NFSX_UNSIGNED); \
495 (f)->nfh_len = fxdr_unsigned(int, *tl); \
496 if (((f)->nfh_len < (int)sizeof(struct nfs_exphandle)) || \
497 ((f)->nfh_len > NFSX_V3FHMAX)) { \
498 error = EBADRPC; \
499 nfsm_reply(0); \
500 } \
501 } else { \
502 (f)->nfh_len = NFSX_V2FH; \
503 } \
504 nfsm_dissect(tl, u_long *, (f)->nfh_len); \
505 bcopy((caddr_t)tl, (caddr_t)&(f)->nfh_xh, (f)->nfh_len); \
506 }
507
508 #define nfsm_clget \
509 if (bp >= be) { \
510 int __nfsm_error, __nfsm_len; \
511 if (mp == mb) \
512 mbuf_setlen(mp, mbuf_len(mp) + bp - bpos); \
513 mp = NULL; \
514 __nfsm_error = mbuf_mclget(MBUF_WAITOK, MBUF_TYPE_DATA, &mp); \
515 if (__nfsm_error) \
516 panic("nfsm_clget: mbuf_mclget error %d", __nfsm_error); \
517 __nfsm_len = mbuf_maxlen(mp); \
518 mbuf_setlen(mp, __nfsm_len); \
519 __nfsm_error = mbuf_setnext(mp2, mp); \
520 if (__nfsm_error) \
521 panic("nfsm_clget: mbuf_setnext error %d", __nfsm_error); \
522 mp2 = mp; \
523 bp = mbuf_data(mp); \
524 be = bp + __nfsm_len; \
525 } \
526 tl = (u_long *)bp
527
528 #define nfsm_srv_vattr_init(vap, v3) \
529 { \
530 VATTR_INIT(vap); \
531 VATTR_WANTED((vap), va_type); \
532 VATTR_WANTED((vap), va_mode); \
533 VATTR_WANTED((vap), va_nlink); \
534 VATTR_WANTED((vap), va_uid); \
535 VATTR_WANTED((vap), va_gid); \
536 VATTR_WANTED((vap), va_data_size); \
537 VATTR_WANTED((vap), va_data_alloc); \
538 VATTR_WANTED((vap), va_rdev); \
539 VATTR_WANTED((vap), va_fsid); \
540 VATTR_WANTED((vap), va_fileid); \
541 VATTR_WANTED((vap), va_access_time); \
542 VATTR_WANTED((vap), va_modify_time); \
543 VATTR_WANTED((vap), va_change_time); \
544 if (!v3) VATTR_WANTED((vap), va_iosize); \
545 }
546
547 #define nfsm_srv_pre_vattr_init(vap, v3) \
548 { \
549 VATTR_INIT(vap); \
550 VATTR_WANTED((vap), va_data_size); \
551 VATTR_WANTED((vap), va_modify_time); \
552 VATTR_WANTED((vap), va_change_time); \
553 }
554
555 #define nfsm_srvfillattr(a, f) \
556 nfsm_srvfattr(nfsd, (a), (f))
557
558 #define nfsm_srvwcc_data(br, b, ar, a) \
559 nfsm_srvwcc(nfsd, (br), (b), (ar), (a), &mb, &bpos)
560
561 #define nfsm_srvpostop_attr(r, a) \
562 nfsm_srvpostopattr(nfsd, (r), (a), &mb, &bpos)
563
564 #define nfsm_srvsattr(a) \
565 { \
566 struct timespec now; \
567 nfsm_dissect(tl, u_long *, NFSX_UNSIGNED); \
568 if (*tl == nfs_true) { \
569 nfsm_dissect(tl, u_long *, NFSX_UNSIGNED); \
570 VATTR_SET(a, va_mode, nfstov_mode(*tl)); \
571 } \
572 nfsm_dissect(tl, u_long *, NFSX_UNSIGNED); \
573 if (*tl == nfs_true) { \
574 nfsm_dissect(tl, u_long *, NFSX_UNSIGNED); \
575 VATTR_SET(a, va_uid, fxdr_unsigned(uid_t, *tl)); \
576 } \
577 nfsm_dissect(tl, u_long *, NFSX_UNSIGNED); \
578 if (*tl == nfs_true) { \
579 nfsm_dissect(tl, u_long *, NFSX_UNSIGNED); \
580 VATTR_SET(a, va_gid, fxdr_unsigned(gid_t, *tl)); \
581 } \
582 nfsm_dissect(tl, u_long *, NFSX_UNSIGNED); \
583 if (*tl == nfs_true) { \
584 nfsm_dissect(tl, u_long *, 2 * NFSX_UNSIGNED); \
585 fxdr_hyper(tl, &(a)->va_data_size); \
586 VATTR_SET_ACTIVE(a, va_data_size); \
587 } \
588 nfsm_dissect(tl, u_long *, NFSX_UNSIGNED); \
589 nanotime(&now); \
590 switch (fxdr_unsigned(int, *tl)) { \
591 case NFSV3SATTRTIME_TOCLIENT: \
592 nfsm_dissect(tl, u_long *, 2 * NFSX_UNSIGNED); \
593 fxdr_nfsv3time(tl, &(a)->va_access_time); \
594 VATTR_SET_ACTIVE(a, va_access_time); \
595 break; \
596 case NFSV3SATTRTIME_TOSERVER: \
597 VATTR_SET(a, va_access_time, now); \
598 break; \
599 }; \
600 nfsm_dissect(tl, u_long *, NFSX_UNSIGNED); \
601 switch (fxdr_unsigned(int, *tl)) { \
602 case NFSV3SATTRTIME_TOCLIENT: \
603 nfsm_dissect(tl, u_long *, 2 * NFSX_UNSIGNED); \
604 fxdr_nfsv3time(tl, &(a)->va_modify_time); \
605 VATTR_SET_ACTIVE(a, va_modify_time); \
606 break; \
607 case NFSV3SATTRTIME_TOSERVER: \
608 VATTR_SET(a, va_modify_time, now); \
609 break; \
610 }; }
611
612 #endif /* __APPLE_API_PRIVATE */
613 #endif /* _NFS_NFSM_SUBS_H_ */