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 /sys/nfs/nfs_subs.c | |
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@
Diffstat (limited to 'sys/nfs/nfs_subs.c')
-rw-r--r-- | sys/nfs/nfs_subs.c | 78 |
1 files changed, 77 insertions, 1 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; +} |