diff options
author | Bret Lambert <blambert@cvs.openbsd.org> | 2007-12-13 18:32:56 +0000 |
---|---|---|
committer | Bret Lambert <blambert@cvs.openbsd.org> | 2007-12-13 18:32:56 +0000 |
commit | fd41d40029b4b6318c4f7ed90f9d2251ab04bc22 (patch) | |
tree | f806d9c3632e0c92ee75a114ae6b2b731f83de8e | |
parent | 8b1f655711238b3be5f4adbb79082fd84dfe7da8 (diff) |
convert massive (expanded to 150+ lines) nfsm_v3attr macro to a function
shaves an insane (~8K) amount from an i386 kernel
ok thib@
-rw-r--r-- | sys/nfs/nfs_subs.c | 78 | ||||
-rw-r--r-- | sys/nfs/nfs_var.h | 3 | ||||
-rw-r--r-- | sys/nfs/nfs_vnops.c | 12 | ||||
-rw-r--r-- | sys/nfs/nfsm_subs.h | 65 |
4 files changed, 86 insertions, 72 deletions
diff --git a/sys/nfs/nfs_subs.c b/sys/nfs/nfs_subs.c index 8f97da63297..4360cc05054 100644 --- a/sys/nfs/nfs_subs.c +++ b/sys/nfs/nfs_subs.c @@ -1,4 +1,4 @@ -/* $OpenBSD: nfs_subs.c,v 1.67 2007/11/28 19:27:43 thib Exp $ */ +/* $OpenBSD: nfs_subs.c,v 1.68 2007/12/13 18:32:55 blambert Exp $ */ /* $NetBSD: nfs_subs.c,v 1.27.4.3 1996/07/08 20:34:24 jtc Exp $ */ /* @@ -1920,3 +1920,79 @@ nfsrv_setcred(incred, outcred) outcred->cr_groups[i] = incred->cr_groups[i]; nfsrvw_sort(outcred->cr_groups, outcred->cr_ngroups); } + +/* + * If full is true, set all fields, otherwise just set mode and time fields + */ +void +nfsm_v3attrbuild(struct mbuf **mp, struct vattr *a, int full, caddr_t *bposp) +{ + struct mbuf *mb, *mb2; + u_int32_t *tl; + caddr_t bpos; + + mb = *mp; + bpos = *bposp; + + if (a->va_mode != (mode_t)VNOVAL) { + nfsm_build(tl, u_int32_t *, 2 * NFSX_UNSIGNED); + *tl++ = nfs_true; + *tl = txdr_unsigned(a->va_mode); + } else { + nfsm_build(tl, u_int32_t *, NFSX_UNSIGNED); + *tl = nfs_false; + } + if (full && a->va_uid != (uid_t)VNOVAL) { + nfsm_build(tl, u_int32_t *, 2 * NFSX_UNSIGNED); + *tl++ = nfs_true; + *tl = txdr_unsigned(a->va_uid); + } else { + nfsm_build(tl, u_int32_t *, NFSX_UNSIGNED); + *tl = nfs_false; + } + if (full && a->va_gid != (gid_t)VNOVAL) { + nfsm_build(tl, u_int32_t *, 2 * NFSX_UNSIGNED); + *tl++ = nfs_true; + *tl = txdr_unsigned((a)->va_gid); + } else { + nfsm_build(tl, u_int32_t *, NFSX_UNSIGNED); + *tl = nfs_false; + } + if (full && a->va_size != VNOVAL) { + nfsm_build(tl, u_int32_t *, 3 * NFSX_UNSIGNED); + *tl++ = nfs_true; + txdr_hyper(a->va_size, tl); + } else { + nfsm_build(tl, u_int32_t *, NFSX_UNSIGNED); + *tl = nfs_false; + } + if (a->va_atime.tv_sec != VNOVAL) { + if (a->va_atime.tv_sec != time_second) { + nfsm_build(tl, u_int32_t *, 3 * NFSX_UNSIGNED); + *tl++ = txdr_unsigned(NFSV3SATTRTIME_TOCLIENT); + txdr_nfsv3time(&a->va_atime, tl); + } else { + nfsm_build(tl, u_int32_t *, NFSX_UNSIGNED); + *tl = txdr_unsigned(NFSV3SATTRTIME_TOSERVER); + } + } else { + nfsm_build(tl, u_int32_t *, NFSX_UNSIGNED); + *tl = txdr_unsigned(NFSV3SATTRTIME_DONTCHANGE); + } + if (a->va_mtime.tv_sec != VNOVAL) { + if (a->va_mtime.tv_sec != time_second) { + nfsm_build(tl, u_int32_t *, 3 * NFSX_UNSIGNED); + *tl++ = txdr_unsigned(NFSV3SATTRTIME_TOCLIENT); + txdr_nfsv3time(&a->va_mtime, tl); + } else { + nfsm_build(tl, u_int32_t *, NFSX_UNSIGNED); + *tl = txdr_unsigned(NFSV3SATTRTIME_TOSERVER); + } + } else { + nfsm_build(tl, u_int32_t *, NFSX_UNSIGNED); + *tl = txdr_unsigned(NFSV3SATTRTIME_DONTCHANGE); + } + + *bposp = bpos; + *mp = mb; +} diff --git a/sys/nfs/nfs_var.h b/sys/nfs/nfs_var.h index 14adc66a120..f4e03432923 100644 --- a/sys/nfs/nfs_var.h +++ b/sys/nfs/nfs_var.h @@ -1,4 +1,4 @@ -/* $OpenBSD: nfs_var.h,v 1.31 2007/10/28 14:12:41 thib Exp $ */ +/* $OpenBSD: nfs_var.h,v 1.32 2007/12/13 18:32:55 blambert Exp $ */ /* $NetBSD: nfs_var.h,v 1.3 1996/02/18 11:53:54 fvdl Exp $ */ /* @@ -252,6 +252,7 @@ int nfs_getattrcache(struct vnode *, struct vattr *); int nfs_namei(struct nameidata *, fhandle_t *, int, struct nfssvc_sock *, struct mbuf *, struct mbuf **, caddr_t *, struct vnode **, struct proc *, int); +void nfsm_v3attrbuild(struct mbuf **, struct vattr *, int, caddr_t *); void nfsm_adj(struct mbuf *, int, int); void nfsm_srvwcc(struct nfsrv_descript *, int, struct vattr *, int, struct vattr *, struct mbuf **, char **); diff --git a/sys/nfs/nfs_vnops.c b/sys/nfs/nfs_vnops.c index 3711b0b999a..d182cbed411 100644 --- a/sys/nfs/nfs_vnops.c +++ b/sys/nfs/nfs_vnops.c @@ -1,4 +1,4 @@ -/* $OpenBSD: nfs_vnops.c,v 1.78 2007/09/26 16:00:55 blambert Exp $ */ +/* $OpenBSD: nfs_vnops.c,v 1.79 2007/12/13 18:32:55 blambert Exp $ */ /* $NetBSD: nfs_vnops.c,v 1.62.4.1 1996/07/08 20:26:52 jtc Exp $ */ /* @@ -563,7 +563,7 @@ nfs_setattrrpc(vp, vap, cred, procp) nfsm_reqhead(vp, NFSPROC_SETATTR, NFSX_FH(v3) + NFSX_SATTR(v3)); nfsm_fhtom(vp, v3); if (v3) { - nfsm_v3attrbuild(vap, TRUE); + nfsm_v3attrbuild(&mb, vap, TRUE, &bpos); nfsm_build(tl, u_int32_t *, NFSX_UNSIGNED); *tl = nfs_false; } else { @@ -1137,7 +1137,7 @@ nfs_mknodrpc(dvp, vpp, cnp, vap) if (v3) { nfsm_build(tl, u_int32_t *, NFSX_UNSIGNED); *tl++ = vtonfsv3_type(vap->va_type); - nfsm_v3attrbuild(vap, FALSE); + nfsm_v3attrbuild(&mb, vap, FALSE, &bpos); if (vap->va_type == VCHR || vap->va_type == VBLK) { nfsm_build(tl, u_int32_t *, 2 * NFSX_UNSIGNED); *tl++ = txdr_unsigned(major(vap->va_rdev)); @@ -1259,7 +1259,7 @@ again: *tl = ++create_verf; } else { *tl = txdr_unsigned(NFSV3CREATE_UNCHECKED); - nfsm_v3attrbuild(vap, FALSE); + nfsm_v3attrbuild(&mb, vap, FALSE, &bpos); } } else { nfsm_build(sp, struct nfsv2_sattr *, NFSX_V2SATTR); @@ -1652,7 +1652,7 @@ nfs_symlink(v) nfsm_fhtom(dvp, v3); nfsm_strtom(cnp->cn_nameptr, cnp->cn_namelen, NFS_MAXNAMLEN); if (v3) - nfsm_v3attrbuild(vap, FALSE); + nfsm_v3attrbuild(&mb, vap, FALSE, &bpos); nfsm_strtom(ap->a_target, slen, NFS_MAXPATHLEN); if (!v3) { nfsm_build(sp, struct nfsv2_sattr *, NFSX_V2SATTR); @@ -1718,7 +1718,7 @@ nfs_mkdir(v) nfsm_fhtom(dvp, v3); nfsm_strtom(cnp->cn_nameptr, len, NFS_MAXNAMLEN); if (v3) { - nfsm_v3attrbuild(vap, FALSE); + nfsm_v3attrbuild(&mb, vap, FALSE, &bpos); } else { nfsm_build(sp, struct nfsv2_sattr *, NFSX_V2SATTR); sp->sa_mode = vtonfsv2_mode(VDIR, vap->va_mode); diff --git a/sys/nfs/nfsm_subs.h b/sys/nfs/nfsm_subs.h index 587b5cda6d4..86a567a6fbe 100644 --- a/sys/nfs/nfsm_subs.h +++ b/sys/nfs/nfsm_subs.h @@ -1,4 +1,4 @@ -/* $OpenBSD: nfsm_subs.h,v 1.22 2007/11/07 23:40:52 thib Exp $ */ +/* $OpenBSD: nfsm_subs.h,v 1.23 2007/12/13 18:32:55 blambert Exp $ */ /* $NetBSD: nfsm_subs.h,v 1.10 1996/03/20 21:59:56 fvdl Exp $ */ /* @@ -217,69 +217,6 @@ (f) = ttattrf; \ } } -/* If full is true, set all fields, otherwise just set mode and time fields */ -#define nfsm_v3attrbuild(a, full) \ - { if ((a)->va_mode != (mode_t)VNOVAL) { \ - nfsm_build(tl, u_int32_t *, 2 * NFSX_UNSIGNED); \ - *tl++ = nfs_true; \ - *tl = txdr_unsigned((a)->va_mode); \ - } else { \ - nfsm_build(tl, u_int32_t *, NFSX_UNSIGNED); \ - *tl = nfs_false; \ - } \ - if ((full) && (a)->va_uid != (uid_t)VNOVAL) { \ - nfsm_build(tl, u_int32_t *, 2 * NFSX_UNSIGNED); \ - *tl++ = nfs_true; \ - *tl = txdr_unsigned((a)->va_uid); \ - } else { \ - nfsm_build(tl, u_int32_t *, NFSX_UNSIGNED); \ - *tl = nfs_false; \ - } \ - if ((full) && (a)->va_gid != (gid_t)VNOVAL) { \ - nfsm_build(tl, u_int32_t *, 2 * NFSX_UNSIGNED); \ - *tl++ = nfs_true; \ - *tl = txdr_unsigned((a)->va_gid); \ - } else { \ - nfsm_build(tl, u_int32_t *, NFSX_UNSIGNED); \ - *tl = nfs_false; \ - } \ - if ((full) && (a)->va_size != VNOVAL) { \ - nfsm_build(tl, u_int32_t *, 3 * NFSX_UNSIGNED); \ - *tl++ = nfs_true; \ - txdr_hyper((a)->va_size, tl); \ - } else { \ - nfsm_build(tl, u_int32_t *, NFSX_UNSIGNED); \ - *tl = nfs_false; \ - } \ - if ((a)->va_atime.tv_sec != VNOVAL) { \ - if ((a)->va_atime.tv_sec != time_second) { \ - nfsm_build(tl, u_int32_t *, 3 * NFSX_UNSIGNED); \ - *tl++ = txdr_unsigned(NFSV3SATTRTIME_TOCLIENT); \ - txdr_nfsv3time(&(a)->va_atime, tl); \ - } else { \ - nfsm_build(tl, u_int32_t *, NFSX_UNSIGNED); \ - *tl = txdr_unsigned(NFSV3SATTRTIME_TOSERVER); \ - } \ - } else { \ - nfsm_build(tl, u_int32_t *, NFSX_UNSIGNED); \ - *tl = txdr_unsigned(NFSV3SATTRTIME_DONTCHANGE); \ - } \ - if ((a)->va_mtime.tv_sec != VNOVAL) { \ - if ((a)->va_mtime.tv_sec != time_second) { \ - nfsm_build(tl, u_int32_t *, 3 * NFSX_UNSIGNED); \ - *tl++ = txdr_unsigned(NFSV3SATTRTIME_TOCLIENT); \ - txdr_nfsv3time(&(a)->va_mtime, tl); \ - } else { \ - nfsm_build(tl, u_int32_t *, NFSX_UNSIGNED); \ - *tl = txdr_unsigned(NFSV3SATTRTIME_TOSERVER); \ - } \ - } else { \ - nfsm_build(tl, u_int32_t *, NFSX_UNSIGNED); \ - *tl = txdr_unsigned(NFSV3SATTRTIME_DONTCHANGE); \ - } \ - } - - #define nfsm_strsiz(s,m) \ { nfsm_dissect(tl,u_int32_t *,NFSX_UNSIGNED); \ if (((s) = fxdr_unsigned(int32_t,*tl)) > (m)) { \ |