From owner-freebsd-hackers Mon Aug 2 12:44:55 1999 Delivered-To: freebsd-hackers@freebsd.org Received: from dingo.cdrom.com (dingo.cdrom.com [204.216.28.145]) by hub.freebsd.org (Postfix) with ESMTP id A436314C48 for ; Mon, 2 Aug 1999 12:44:52 -0700 (PDT) (envelope-from mike@dingo.cdrom.com) Received: from dingo.cdrom.com (localhost.cdrom.com [127.0.0.1]) by dingo.cdrom.com (8.9.3/8.8.8) with ESMTP id MAA00862; Mon, 2 Aug 1999 12:38:40 -0700 (PDT) (envelope-from mike@dingo.cdrom.com) Message-Id: <199908021938.MAA00862@dingo.cdrom.com> X-Mailer: exmh version 2.0.2 2/24/98 To: Alfred Perlstein Cc: hackers@freebsd.org Subject: Re: confusion about nfsm_srvmtofh bad behavior? In-reply-to: Your message of "Mon, 02 Aug 1999 07:18:36 EDT." Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Date: Mon, 02 Aug 1999 12:38:40 -0700 From: Mike Smith Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG > > ok: > > #define nfsm_srvmtofh(f) \ > { int fhlen = NFSX_V3FH; \ > if (nfsd->nd_flag & ND_NFSV3) { \ > nfsm_dissect(tl, u_int32_t *, NFSX_UNSIGNED); \ > fhlen = fxdr_unsigned(int, *tl); \ > if (fhlen == 0) { \ > bzero((caddr_t)(f), NFSX_V3FH); \ > } else if (fhlen != NFSX_V3FH) { \ > error = EBADRPC; \ > nfsm_reply(0); \ > } \ > } \ > if (fhlen != 0) { \ > nfsm_dissect(tl, u_int32_t *, NFSX_V3FH); \ > bcopy((caddr_t)tl, (caddr_t)(f), NFSX_V3FH); \ > if ((nfsd->nd_flag & ND_NFSV3) == 0) \ > nfsm_adv(NFSX_V2FH - NFSX_V3FH); \ > } \ > } > > notice the bcopy? i don't really understand why we always > seem to copy 64 bytes (NFSX_V3FH), isn't this a bug? Yeah, you could probably rewrite as: #define nfsm_srvmtofh(f) \ { int fhlen; \ if (nfsd->nd_flag & ND_NFSV3) { \ nfsm_dissect(tl, u_int32_t *, NFSX_UNSIGNED); \ fhlen = fxdr_unsigned(int, *tl); \ if (fhlen == 0) { \ bzero((caddr_t)(f), NFSX_V3FH); \ } else if (fhlen != NFSX_V3FH) { \ error = EBADRPC; \ nfsm_reply(0); \ } else { \ nfsm_dissect(tl, u_int32_t *, NFSX_V3FH); \ bcopy((caddr_t)tl, (caddr_t)(f), NFSX_V3FH); \ }\ } else { nfsm_dissect(tl, u_int32_t *, NFSX_V2FH); \ bcopy((caddr_t)tl, (caddr_t)(f), NFSX_V2FH); \ } \ } which avoids using fhlen as an argument to anything (speed) and limits the bcopy size appropriately by protocol. -- \\ The mind's the standard \\ Mike Smith \\ of the man. \\ msmith@freebsd.org \\ -- Joseph Merrick \\ msmith@cdrom.com To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message