nfsm_subs.h (70254) | nfsm_subs.h (83651) |
---|---|
1/* 2 * Copyright (c) 1989, 1993 3 * The Regents of the University of California. All rights reserved. 4 * 5 * This code is derived from software contributed to Berkeley by 6 * Rick Macklem at The University of Guelph. 7 * 8 * Redistribution and use in source and binary forms, with or without --- 20 unchanged lines hidden (view full) --- 29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 30 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 31 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 34 * SUCH DAMAGE. 35 * 36 * @(#)nfsm_subs.h 8.2 (Berkeley) 3/30/95 | 1/* 2 * Copyright (c) 1989, 1993 3 * The Regents of the University of California. All rights reserved. 4 * 5 * This code is derived from software contributed to Berkeley by 6 * Rick Macklem at The University of Guelph. 7 * 8 * Redistribution and use in source and binary forms, with or without --- 20 unchanged lines hidden (view full) --- 29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 30 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 31 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 34 * SUCH DAMAGE. 35 * 36 * @(#)nfsm_subs.h 8.2 (Berkeley) 3/30/95 |
37 * $FreeBSD: head/sys/nfsclient/nfsm_subs.h 70254 2000-12-21 21:44:31Z bmilekic $ | 37 * $FreeBSD: head/sys/nfsclient/nfsm_subs.h 83651 2001-09-18 23:32:09Z peter $ |
38 */ 39 | 38 */ 39 |
40#ifndef _NFSCLIENT_NFSM_SUBS_H_ 41#define _NFSCLIENT_NFSM_SUBS_H_ |
|
40 | 42 |
41#ifndef _NFS_NFSM_SUBS_H_ 42#define _NFS_NFSM_SUBS_H_ | 43#include <nfs/nfs_common.h> |
43 | 44 |
45#define nfsv2tov_type(a) nv2tov_type[fxdr_unsigned(u_int32_t,(a))&0x7] 46 |
|
44struct ucred; 45struct vnode; 46 47/* 48 * These macros do strange and peculiar things to mbuf chains for 49 * the assistance of the nfs code. To attempt to use them for any 50 * other purpose will be dangerous. (they make weird assumptions) 51 */ 52 53/* 54 * First define what the actual subs. return 55 */ | 47struct ucred; 48struct vnode; 49 50/* 51 * These macros do strange and peculiar things to mbuf chains for 52 * the assistance of the nfs code. To attempt to use them for any 53 * other purpose will be dangerous. (they make weird assumptions) 54 */ 55 56/* 57 * First define what the actual subs. return 58 */ |
56struct mbuf *nfsm_reqh __P((struct vnode *vp, u_long procid, int hsiz, 57 caddr_t *bposp)); 58struct mbuf *nfsm_rpchead __P((struct ucred *cr, int nmflag, int procid, 59 int auth_type, int auth_len, char *auth_str, 60 int verf_len, char *verf_str, 61 struct mbuf *mrest, int mrest_len, 62 struct mbuf **mbp, u_int32_t *xidp)); | 59struct mbuf *nfsm_reqhead(struct vnode *vp, u_long procid, int hsiz); 60struct mbuf *nfsm_rpchead(struct ucred *cr, int nmflag, int procid, 61 int auth_type, int auth_len, 62 struct mbuf *mrest, int mrest_len, 63 struct mbuf **mbp, u_int32_t *xidp); |
63 64#define M_HASCL(m) ((m)->m_flags & M_EXT) 65#define NFSMINOFF(m) \ 66 do { \ 67 if (M_HASCL(m)) \ 68 (m)->m_data = (m)->m_ext.ext_buf; \ 69 else if ((m)->m_flags & M_PKTHDR) \ 70 (m)->m_data = (m)->m_pktdat; \ 71 else \ 72 (m)->m_data = (m)->m_dat; \ 73 } while (0) | 64 65#define M_HASCL(m) ((m)->m_flags & M_EXT) 66#define NFSMINOFF(m) \ 67 do { \ 68 if (M_HASCL(m)) \ 69 (m)->m_data = (m)->m_ext.ext_buf; \ 70 else if ((m)->m_flags & M_PKTHDR) \ 71 (m)->m_data = (m)->m_pktdat; \ 72 else \ 73 (m)->m_data = (m)->m_dat; \ 74 } while (0) |
74#define NFSMADV(m, s) \ 75 do { \ 76 (m)->m_data += (s); \ 77 } while (0) | |
78#define NFSMSIZ(m) ((M_HASCL(m))?MCLBYTES: \ 79 (((m)->m_flags & M_PKTHDR)?MHLEN:MLEN)) 80 81/* 82 * Now for the macros that do the simple stuff and call the functions 83 * for the hard stuff. 84 * These macros use several vars. declared in nfsm_reqhead and these 85 * vars. must not be used elsewhere unless you are careful not to corrupt 86 * them. The vars. starting with pN and tN (N=1,2,3,..) are temporaries 87 * that may be used so long as the value is not expected to retained 88 * after a macro. 89 * I know, this is kind of dorkey, but it makes the actual op functions 90 * fairly clean and deals with the mess caused by the xdr discriminating 91 * unions. 92 */ 93 | 75#define NFSMSIZ(m) ((M_HASCL(m))?MCLBYTES: \ 76 (((m)->m_flags & M_PKTHDR)?MHLEN:MLEN)) 77 78/* 79 * Now for the macros that do the simple stuff and call the functions 80 * for the hard stuff. 81 * These macros use several vars. declared in nfsm_reqhead and these 82 * vars. must not be used elsewhere unless you are careful not to corrupt 83 * them. The vars. starting with pN and tN (N=1,2,3,..) are temporaries 84 * that may be used so long as the value is not expected to retained 85 * after a macro. 86 * I know, this is kind of dorkey, but it makes the actual op functions 87 * fairly clean and deals with the mess caused by the xdr discriminating 88 * unions. 89 */ 90 |
94#define nfsm_build(a,c,s) \ 95 do { \ 96 if ((s) > M_TRAILINGSPACE(mb)) { \ 97 MGET(mb2, M_TRYWAIT, MT_DATA); \ 98 if ((s) > MLEN) \ 99 panic("build > MLEN"); \ 100 mb->m_next = mb2; \ 101 mb = mb2; \ 102 mb->m_len = 0; \ 103 bpos = mtod(mb, caddr_t); \ 104 } \ 105 (a) = (c)(bpos); \ 106 mb->m_len += (s); \ 107 bpos += (s); \ 108 } while (0) | 91int nfsm_fhtom_xx(struct vnode *v, int v3, u_int32_t **tl, 92 struct mbuf **mb, caddr_t *bpos); 93int nfsm_mtofh_xx(struct vnode *d, struct vnode **v, int v3, int *f, 94 u_int32_t **tl, struct mbuf **md, caddr_t *dpos); 95int nfsm_getfh_xx(nfsfh_t **f, int *s, int v3, u_int32_t **tl, 96 struct mbuf **md, caddr_t *dpos); 97void nfsm_v3attrbuild_xx(struct vattr *va, int full, u_int32_t **tl, 98 struct mbuf **mb, caddr_t *bpos); 99int nfsm_loadattr_xx(struct vnode **v, struct vattr *va, u_int32_t **tl, 100 struct mbuf **md, caddr_t *dpos); 101int nfsm_postop_attr_xx(struct vnode **v, int *f, u_int32_t **tl, 102 struct mbuf **md, caddr_t *dpos); 103int nfsm_wcc_data_xx(struct vnode **v, int *f, u_int32_t **tl, 104 struct mbuf **md, caddr_t *dpos); 105int nfsm_strtom_xx(const char *a, int s, int m, u_int32_t **tl, 106 struct mbuf **mb, caddr_t *bpos); |
109 | 107 |
110#define nfsm_dissect(a, c, s) \ 111 do { \ 112 t1 = mtod(md, caddr_t)+md->m_len-dpos; \ 113 if (t1 >= (s)) { \ 114 (a) = (c)(dpos); \ 115 dpos += (s); \ 116 } else if ((t1 = nfsm_disct(&md, &dpos, (s), t1, &cp2)) != 0){ \ 117 error = t1; \ 118 m_freem(mrep); \ 119 goto nfsmout; \ 120 } else { \ 121 (a) = (c)cp2; \ 122 } \ 123 } while (0) 124 | |
125#define nfsm_fhtom(v, v3) \ | 108#define nfsm_fhtom(v, v3) \ |
126 do { \ 127 if (v3) { \ 128 t2 = nfsm_rndup(VTONFS(v)->n_fhsize) + NFSX_UNSIGNED; \ 129 if (t2 <= M_TRAILINGSPACE(mb)) { \ 130 nfsm_build(tl, u_int32_t *, t2); \ 131 *tl++ = txdr_unsigned(VTONFS(v)->n_fhsize); \ 132 *(tl + ((t2>>2) - 2)) = 0; \ 133 bcopy((caddr_t)VTONFS(v)->n_fhp,(caddr_t)tl, \ 134 VTONFS(v)->n_fhsize); \ 135 } else if ((t2 = nfsm_strtmbuf(&mb, &bpos, \ 136 (caddr_t)VTONFS(v)->n_fhp, \ 137 VTONFS(v)->n_fhsize)) != 0) { \ 138 error = t2; \ 139 m_freem(mreq); \ 140 goto nfsmout; \ 141 } \ 142 } else { \ 143 nfsm_build(cp, caddr_t, NFSX_V2FH); \ 144 bcopy((caddr_t)VTONFS(v)->n_fhp, cp, NFSX_V2FH); \ 145 } \ 146 } while (0) | 109do { \ 110 int32_t t1; \ 111 t1 = nfsm_fhtom_xx((v), (v3), &tl, &mb, &bpos); \ 112 if (t1) { \ 113 error = t1; \ 114 m_freem(mreq); \ 115 goto nfsmout; \ 116 } \ 117} while (0) |
147 | 118 |
148#define nfsm_srvfhtom(f, v3) \ 149 do { \ 150 if (v3) { \ 151 nfsm_build(tl, u_int32_t *, NFSX_UNSIGNED + NFSX_V3FH);\ 152 *tl++ = txdr_unsigned(NFSX_V3FH); \ 153 bcopy((caddr_t)(f), (caddr_t)tl, NFSX_V3FH); \ 154 } else { \ 155 nfsm_build(cp, caddr_t, NFSX_V2FH); \ 156 bcopy((caddr_t)(f), cp, NFSX_V2FH); \ 157 } \ 158 } while (0) 159 160#define nfsm_srvpostop_fh(f) \ 161 do { \ 162 nfsm_build(tl, u_int32_t *, 2 * NFSX_UNSIGNED + NFSX_V3FH); \ 163 *tl++ = nfs_true; \ 164 *tl++ = txdr_unsigned(NFSX_V3FH); \ 165 bcopy((caddr_t)(f), (caddr_t)tl, NFSX_V3FH); \ 166 } while (0) 167 | |
168#define nfsm_mtofh(d, v, v3, f) \ | 119#define nfsm_mtofh(d, v, v3, f) \ |
169 do { \ 170 struct nfsnode *ttnp; nfsfh_t *ttfhp; int ttfhsize; \ 171 if (v3) { \ 172 nfsm_dissect(tl, u_int32_t *, NFSX_UNSIGNED); \ 173 (f) = fxdr_unsigned(int, *tl); \ 174 } else \ 175 (f) = 1; \ 176 if (f) { \ 177 nfsm_getfh(ttfhp, ttfhsize, (v3)); \ 178 if ((t1 = nfs_nget((d)->v_mount, ttfhp, ttfhsize, \ 179 &ttnp)) != 0) { \ 180 error = t1; \ 181 m_freem(mrep); \ 182 goto nfsmout; \ 183 } \ 184 (v) = NFSTOV(ttnp); \ 185 } \ 186 if (v3) { \ 187 nfsm_dissect(tl, u_int32_t *, NFSX_UNSIGNED); \ 188 if (f) \ 189 (f) = fxdr_unsigned(int, *tl); \ 190 else if (fxdr_unsigned(int, *tl)) \ 191 nfsm_adv(NFSX_V3FATTR); \ 192 } \ 193 if (f) \ 194 nfsm_loadattr((v), (struct vattr *)0); \ 195 } while (0) | 120do { \ 121 int32_t t1; \ 122 t1 = nfsm_mtofh_xx((d), &(v), (v3), &(f), &tl, &md, &dpos); \ 123 if (t1) { \ 124 error = t1; \ 125 m_freem(mrep); \ 126 goto nfsmout; \ 127 } \ 128} while (0) |
196 197#define nfsm_getfh(f, s, v3) \ | 129 130#define nfsm_getfh(f, s, v3) \ |
198 do { \ 199 if (v3) { \ 200 nfsm_dissect(tl, u_int32_t *, NFSX_UNSIGNED); \ 201 if (((s) = fxdr_unsigned(int, *tl)) <= 0 || \ 202 (s) > NFSX_V3FHMAX) { \ 203 m_freem(mrep); \ 204 error = EBADRPC; \ 205 goto nfsmout; \ 206 } \ 207 } else \ 208 (s) = NFSX_V2FH; \ 209 nfsm_dissect((f), nfsfh_t *, nfsm_rndup(s)); \ 210 } while (0) | 131do { \ 132 int32_t t1; \ 133 t1 = nfsm_getfh_xx(&(f), &(s), (v3), &tl, &md, &dpos); \ 134 if (t1) { \ 135 error = t1; \ 136 m_freem(mrep); \ 137 goto nfsmout; \ 138 } \ 139} while (0) |
211 212#define nfsm_loadattr(v, a) \ | 140 141#define nfsm_loadattr(v, a) \ |
213 do { \ 214 struct vnode *ttvp = (v); \ 215 if ((t1 = nfs_loadattrcache(&ttvp, &md, &dpos, (a), 0)) != 0) { \ 216 error = t1; \ 217 m_freem(mrep); \ 218 goto nfsmout; \ 219 } \ 220 (v) = ttvp; \ 221 } while (0) | 142do { \ 143 int32_t t1; \ 144 t1 = nfsm_loadattr_xx(&v, a, &tl, &md, &dpos); \ 145 if (t1 != 0) { \ 146 error = t1; \ 147 m_freem(mrep); \ 148 goto nfsmout; \ 149 } \ 150} while (0) |
222 223#define nfsm_postop_attr(v, f) \ | 151 152#define nfsm_postop_attr(v, f) \ |
224 do { \ 225 struct vnode *ttvp = (v); \ 226 nfsm_dissect(tl, u_int32_t *, NFSX_UNSIGNED); \ 227 if (((f) = fxdr_unsigned(int, *tl)) != 0) { \ 228 if ((t1 = nfs_loadattrcache(&ttvp, &md, &dpos, \ 229 (struct vattr *)0, 1)) != 0) { \ 230 error = t1; \ 231 (f) = 0; \ 232 m_freem(mrep); \ 233 goto nfsmout; \ 234 } \ 235 (v) = ttvp; \ 236 } \ 237 } while (0) | 153do { \ 154 int32_t t1; \ 155 t1 = nfsm_postop_attr_xx(&v, &f, &tl, &md, &dpos); \ 156 if (t1 != 0) { \ 157 error = t1; \ 158 m_freem(mrep); \ 159 goto nfsmout; \ 160 } \ 161} while (0) |
238 239/* Used as (f) for nfsm_wcc_data() */ 240#define NFSV3_WCCRATTR 0 241#define NFSV3_WCCCHK 1 242 243#define nfsm_wcc_data(v, f) \ | 162 163/* Used as (f) for nfsm_wcc_data() */ 164#define NFSV3_WCCRATTR 0 165#define NFSV3_WCCCHK 1 166 167#define nfsm_wcc_data(v, f) \ |
244 do { \ 245 int ttattrf, ttretf = 0; \ 246 nfsm_dissect(tl, u_int32_t *, NFSX_UNSIGNED); \ 247 if (*tl == nfs_true) { \ 248 nfsm_dissect(tl, u_int32_t *, 6 * NFSX_UNSIGNED); \ 249 if (f) \ 250 ttretf = (VTONFS(v)->n_mtime == \ 251 fxdr_unsigned(u_int32_t, *(tl + 2))); \ 252 } \ 253 nfsm_postop_attr((v), ttattrf); \ 254 if (f) { \ 255 (f) = ttretf; \ 256 } else { \ 257 (f) = ttattrf; \ 258 } \ 259 } while (0) | 168do { \ 169 int32_t t1; \ 170 t1 = nfsm_wcc_data_xx(&v, &f, &tl, &md, &dpos); \ 171 if (t1 != 0) { \ 172 error = t1; \ 173 m_freem(mrep); \ 174 goto nfsmout; \ 175 } \ 176} while (0) |
260 261/* If full is true, set all fields, otherwise just set mode and time fields */ 262#define nfsm_v3attrbuild(a, full) \ | 177 178/* If full is true, set all fields, otherwise just set mode and time fields */ 179#define nfsm_v3attrbuild(a, full) \ |
263 do { \ 264 if ((a)->va_mode != (mode_t)VNOVAL) { \ 265 nfsm_build(tl, u_int32_t *, 2 * NFSX_UNSIGNED); \ 266 *tl++ = nfs_true; \ 267 *tl = txdr_unsigned((a)->va_mode); \ 268 } else { \ 269 nfsm_build(tl, u_int32_t *, NFSX_UNSIGNED); \ 270 *tl = nfs_false; \ 271 } \ 272 if ((full) && (a)->va_uid != (uid_t)VNOVAL) { \ 273 nfsm_build(tl, u_int32_t *, 2 * NFSX_UNSIGNED); \ 274 *tl++ = nfs_true; \ 275 *tl = txdr_unsigned((a)->va_uid); \ 276 } else { \ 277 nfsm_build(tl, u_int32_t *, NFSX_UNSIGNED); \ 278 *tl = nfs_false; \ 279 } \ 280 if ((full) && (a)->va_gid != (gid_t)VNOVAL) { \ 281 nfsm_build(tl, u_int32_t *, 2 * NFSX_UNSIGNED); \ 282 *tl++ = nfs_true; \ 283 *tl = txdr_unsigned((a)->va_gid); \ 284 } else { \ 285 nfsm_build(tl, u_int32_t *, NFSX_UNSIGNED); \ 286 *tl = nfs_false; \ 287 } \ 288 if ((full) && (a)->va_size != VNOVAL) { \ 289 nfsm_build(tl, u_int32_t *, 3 * NFSX_UNSIGNED); \ 290 *tl++ = nfs_true; \ 291 txdr_hyper((a)->va_size, tl); \ 292 } else { \ 293 nfsm_build(tl, u_int32_t *, NFSX_UNSIGNED); \ 294 *tl = nfs_false; \ 295 } \ 296 if ((a)->va_atime.tv_sec != VNOVAL) { \ 297 if ((a)->va_atime.tv_sec != time_second) { \ 298 nfsm_build(tl, u_int32_t *, 3 * NFSX_UNSIGNED);\ 299 *tl++ = txdr_unsigned(NFSV3SATTRTIME_TOCLIENT);\ 300 txdr_nfsv3time(&(a)->va_atime, tl); \ 301 } else { \ 302 nfsm_build(tl, u_int32_t *, NFSX_UNSIGNED); \ 303 *tl = txdr_unsigned(NFSV3SATTRTIME_TOSERVER); \ 304 } \ 305 } else { \ 306 nfsm_build(tl, u_int32_t *, NFSX_UNSIGNED); \ 307 *tl = txdr_unsigned(NFSV3SATTRTIME_DONTCHANGE); \ 308 } \ 309 if ((a)->va_mtime.tv_sec != VNOVAL) { \ 310 if ((a)->va_mtime.tv_sec != time_second) { \ 311 nfsm_build(tl, u_int32_t *, 3 * NFSX_UNSIGNED);\ 312 *tl++ = txdr_unsigned(NFSV3SATTRTIME_TOCLIENT);\ 313 txdr_nfsv3time(&(a)->va_mtime, tl); \ 314 } else { \ 315 nfsm_build(tl, u_int32_t *, NFSX_UNSIGNED); \ 316 *tl = txdr_unsigned(NFSV3SATTRTIME_TOSERVER); \ 317 } \ 318 } else { \ 319 nfsm_build(tl, u_int32_t *, NFSX_UNSIGNED); \ 320 *tl = txdr_unsigned(NFSV3SATTRTIME_DONTCHANGE); \ 321 } \ 322 } while (0) 323 | 180do { \ 181 nfsm_v3attrbuild_xx(a, full, &tl, &mb, &bpos); \ 182} while(0) |
324 | 183 |
325#define nfsm_strsiz(s,m) \ 326 do { \ 327 nfsm_dissect(tl,u_int32_t *,NFSX_UNSIGNED); \ 328 if (((s) = fxdr_unsigned(int32_t,*tl)) > (m)) { \ 329 m_freem(mrep); \ 330 error = EBADRPC; \ 331 goto nfsmout; \ 332 } \ 333 } while (0) | 184#define nfsm_uiotom(p, s) \ 185do { \ 186 int t1; \ 187 t1 = nfsm_uiotombuf((p), &mb, (s), &bpos); \ 188 if (t1 != 0) { \ 189 error = t1; \ 190 m_freem(mreq); \ 191 goto nfsmout; \ 192 } \ 193} while (0) |
334 | 194 |
335#define nfsm_srvstrsiz(s,m) \ 336 do { \ 337 nfsm_dissect(tl,u_int32_t *,NFSX_UNSIGNED); \ 338 if (((s) = fxdr_unsigned(int32_t,*tl)) > (m) || (s) <= 0) { \ 339 error = EBADRPC; \ 340 nfsm_reply(0); \ 341 } \ 342 } while (0) 343 344#define nfsm_srvnamesiz(s) \ 345 do { \ 346 nfsm_dissect(tl,u_int32_t *,NFSX_UNSIGNED); \ 347 if (((s) = fxdr_unsigned(int32_t,*tl)) > NFS_MAXNAMLEN) \ 348 error = NFSERR_NAMETOL; \ 349 if ((s) <= 0) \ 350 error = EBADRPC; \ 351 if (error) \ 352 nfsm_reply(0); \ 353 } while (0) 354 355#define nfsm_mtouio(p,s) \ 356 do {\ 357 if ((s) > 0 && \ 358 (t1 = nfsm_mbuftouio(&md,(p),(s),&dpos)) != 0) { \ 359 error = t1; \ 360 m_freem(mrep); \ 361 goto nfsmout; \ 362 } \ 363 } while (0) 364 365#define nfsm_uiotom(p,s) \ 366 do { \ 367 if ((t1 = nfsm_uiotombuf((p),&mb,(s),&bpos)) != 0) { \ 368 error = t1; \ 369 m_freem(mreq); \ 370 goto nfsmout; \ 371 } \ 372 } while (0) 373 374#define nfsm_reqhead(v,a,s) \ 375 do { \ 376 mb = mreq = nfsm_reqh((v),(a),(s),&bpos); \ 377 } while (0) 378 379#define nfsm_reqdone \ 380 do { \ 381 m_freem(mrep); \ 382 nfsmout: \ 383 } while (0) 384 385#define nfsm_rndup(a) (((a)+3)&(~0x3)) 386 | |
387#define nfsm_request(v, t, p, c) \ | 195#define nfsm_request(v, t, p, c) \ |
388 do { \ 389 if ((error = nfs_request((v), mreq, (t), (p), \ 390 (c), &mrep, &md, &dpos)) != 0) { \ 391 if (error & NFSERR_RETERR) \ 392 error &= ~NFSERR_RETERR; \ 393 else \ 394 goto nfsmout; \ 395 } \ 396 } while (0) 397 398#define nfsm_strtom(a,s,m) \ 399 do {\ 400 if ((s) > (m)) { \ 401 m_freem(mreq); \ 402 error = ENAMETOOLONG; \ 403 goto nfsmout; \ 404 } \ 405 t2 = nfsm_rndup(s)+NFSX_UNSIGNED; \ 406 if (t2 <= M_TRAILINGSPACE(mb)) { \ 407 nfsm_build(tl,u_int32_t *,t2); \ 408 *tl++ = txdr_unsigned(s); \ 409 *(tl+((t2>>2)-2)) = 0; \ 410 bcopy((const char *)(a), (caddr_t)tl, (s)); \ 411 } else if ((t2 = nfsm_strtmbuf(&mb, &bpos, (a), (s))) != 0) { \ 412 error = t2; \ 413 m_freem(mreq); \ 414 goto nfsmout; \ 415 } \ 416 } while (0) 417 418#define nfsm_srvdone \ 419 do { \ 420 nfsmout: \ 421 return (error); \ 422 } while (0) 423 424#define nfsm_reply(s) \ 425 do { \ 426 nfsd->nd_repstat = error; \ 427 if (error && !(nfsd->nd_flag & ND_NFSV3)) \ 428 (void) nfs_rephead(0, nfsd, slp, error, cache, &frev, \ 429 mrq, &mb, &bpos); \ | 196do { \ 197 error = nfs_request((v), mreq, (t), (p), (c), &mrep, &md, &dpos); \ 198 if (error != 0) { \ 199 if (error & NFSERR_RETERR) \ 200 error &= ~NFSERR_RETERR; \ |
430 else \ | 201 else \ |
431 (void) nfs_rephead((s), nfsd, slp, error, cache, &frev, \ 432 mrq, &mb, &bpos); \ 433 if (mrep != NULL) { \ 434 m_freem(mrep); \ 435 mrep = NULL; \ 436 } \ 437 mreq = *mrq; \ 438 if (error && (!(nfsd->nd_flag & ND_NFSV3) || \ 439 error == EBADRPC)) { \ 440 error = 0; \ | |
441 goto nfsmout; \ | 202 goto nfsmout; \ |
442 } \ 443 } while (0) | 203 } \ 204} while (0) |
444 | 205 |
445#define nfsm_writereply(s, v3) \ 446 do { \ 447 nfsd->nd_repstat = error; \ 448 if (error && !(v3)) \ 449 (void) nfs_rephead(0, nfsd, slp, error, cache, &frev, \ 450 &mreq, &mb, &bpos); \ 451 else \ 452 (void) nfs_rephead((s), nfsd, slp, error, cache, &frev, \ 453 &mreq, &mb, &bpos); \ 454 } while (0) | 206#define nfsm_strtom(a, s, m) \ 207do { \ 208 int t1; \ 209 t1 = nfsm_strtom_xx((a), (s), (m), &tl, &mb, &bpos); \ 210 if (t1 != 0) { \ 211 error = t1; \ 212 m_freem(mreq); \ 213 goto nfsmout; \ 214 } \ 215} while (0) |
455 | 216 |
456#define nfsm_adv(s) \ 457 do { \ 458 t1 = mtod(md, caddr_t)+md->m_len-dpos; \ 459 if (t1 >= (s)) { \ 460 dpos += (s); \ 461 } else if ((t1 = nfs_adv(&md, &dpos, (s), t1)) != 0) { \ 462 error = t1; \ 463 m_freem(mrep); \ 464 goto nfsmout; \ 465 } \ 466 } while (0) 467 468#define nfsm_srvmtofh(f) \ 469 do { \ 470 int fhlen; \ 471 if (nfsd->nd_flag & ND_NFSV3) { \ 472 nfsm_dissect(tl, u_int32_t *, NFSX_UNSIGNED); \ 473 fhlen = fxdr_unsigned(int, *tl); \ 474 if (fhlen != 0 && fhlen != NFSX_V3FH) { \ 475 error = EBADRPC; \ 476 nfsm_reply(0); \ 477 } \ 478 } else { \ 479 fhlen = NFSX_V2FH; \ 480 } \ 481 if (fhlen != 0) { \ 482 nfsm_dissect(tl, u_int32_t *, fhlen); \ 483 bcopy((caddr_t)tl, (caddr_t)(f), fhlen); \ 484 } else {\ 485 bzero((caddr_t)(f), NFSX_V3FH); \ 486 } \ 487 } while (0) 488 489#define nfsm_clget \ 490 do { \ 491 if (bp >= be) { \ 492 if (mp == mb) \ 493 mp->m_len += bp-bpos; \ 494 MGET(mp, M_TRYWAIT, MT_DATA); \ 495 MCLGET(mp, M_TRYWAIT); \ 496 mp->m_len = NFSMSIZ(mp); \ 497 mp2->m_next = mp; \ 498 mp2 = mp; \ 499 bp = mtod(mp, caddr_t); \ 500 be = bp+mp->m_len; \ 501 } \ 502 tl = (u_int32_t *)bp; \ 503 } while (0) 504 505#define nfsm_srvfillattr(a, f) \ 506 do { \ 507 nfsm_srvfattr(nfsd, (a), (f)); \ 508 } while (0) 509 510#define nfsm_srvwcc_data(br, b, ar, a) \ 511 do { \ 512 nfsm_srvwcc(nfsd, (br), (b), (ar), (a), &mb, &bpos); \ 513 } while (0) 514 515#define nfsm_srvpostop_attr(r, a) \ 516 do { \ 517 nfsm_srvpostopattr(nfsd, (r), (a), &mb, &bpos); \ 518 } while (0) 519 520#define nfsm_srvsattr(a) \ 521 do { \ 522 nfsm_dissect(tl, u_int32_t *, NFSX_UNSIGNED); \ 523 if (*tl == nfs_true) { \ 524 nfsm_dissect(tl, u_int32_t *, NFSX_UNSIGNED); \ 525 (a)->va_mode = nfstov_mode(*tl); \ 526 } \ 527 nfsm_dissect(tl, u_int32_t *, NFSX_UNSIGNED); \ 528 if (*tl == nfs_true) { \ 529 nfsm_dissect(tl, u_int32_t *, NFSX_UNSIGNED); \ 530 (a)->va_uid = fxdr_unsigned(uid_t, *tl); \ 531 } \ 532 nfsm_dissect(tl, u_int32_t *, NFSX_UNSIGNED); \ 533 if (*tl == nfs_true) { \ 534 nfsm_dissect(tl, u_int32_t *, NFSX_UNSIGNED); \ 535 (a)->va_gid = fxdr_unsigned(gid_t, *tl); \ 536 } \ 537 nfsm_dissect(tl, u_int32_t *, NFSX_UNSIGNED); \ 538 if (*tl == nfs_true) { \ 539 nfsm_dissect(tl, u_int32_t *, 2 * NFSX_UNSIGNED); \ 540 (a)->va_size = fxdr_hyper(tl); \ 541 } \ 542 nfsm_dissect(tl, u_int32_t *, NFSX_UNSIGNED); \ 543 switch (fxdr_unsigned(int, *tl)) { \ 544 case NFSV3SATTRTIME_TOCLIENT: \ 545 nfsm_dissect(tl, u_int32_t *, 2 * NFSX_UNSIGNED); \ 546 fxdr_nfsv3time(tl, &(a)->va_atime); \ 547 break; \ 548 case NFSV3SATTRTIME_TOSERVER: \ 549 getnanotime(&(a)->va_atime); \ 550 break; \ 551 }; \ 552 nfsm_dissect(tl, u_int32_t *, NFSX_UNSIGNED); \ 553 switch (fxdr_unsigned(int, *tl)) { \ 554 case NFSV3SATTRTIME_TOCLIENT: \ 555 nfsm_dissect(tl, u_int32_t *, 2 * NFSX_UNSIGNED); \ 556 fxdr_nfsv3time(tl, &(a)->va_mtime); \ 557 break; \ 558 case NFSV3SATTRTIME_TOSERVER: \ 559 getnanotime(&(a)->va_mtime); \ 560 break; \ 561 } \ 562 } while (0) 563 | |
564#endif | 217#endif |