From owner-freebsd-hackers Thu Jan 24 4:13:17 2002 Delivered-To: freebsd-hackers@freebsd.org Received: from whale.sunbay.crimea.ua (whale.sunbay.crimea.ua [212.110.138.65]) by hub.freebsd.org (Postfix) with ESMTP id A4D4037B41A; Thu, 24 Jan 2002 04:13:01 -0800 (PST) Received: (from ru@localhost) by whale.sunbay.crimea.ua (8.11.6/8.11.2) id g0OCCqs40554; Thu, 24 Jan 2002 14:12:52 +0200 (EET) (envelope-from ru) Date: Thu, 24 Jan 2002 14:12:52 +0200 From: Ruslan Ermilov To: "Crist J. Clark" Cc: net@FreeBSD.org Subject: Re: sysctl(3) errnos wrong? Message-ID: <20020124141252.A38822@sunbay.com> References: <20020123025135.E83184@blossom.cjclark.org> <20020124115209.B16972@sunbay.com> <20020124022742.F87663@blossom.cjclark.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20020124022742.F87663@blossom.cjclark.org> User-Agent: Mutt/1.3.23i Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG [Redirected to -net] On Thu, Jan 24, 2002 at 02:27:42AM -0800, Crist J. Clark wrote: > On Thu, Jan 24, 2002 at 11:52:09AM +0200, Ruslan Ermilov wrote: > > Sounds like that, but changing it now would be too backwards incompatible. > > Then shouldn't we fix the documentation to reflect reality? > Hmm, I've looked at the OpenBSD and NetBSD code but didn't look at the BSD/OS code before. BSD/OS has fixed the issue exactly as you suggest. I withdraw my objection. Please commit this patch: Index: rtsock.c =================================================================== RCS file: /home/ncvs/src/sys/net/rtsock.c,v retrieving revision 1.64 diff -u -p -r1.64 rtsock.c --- rtsock.c 2002/01/18 14:33:03 1.64 +++ rtsock.c 2002/01/24 12:11:30 @@ -1008,7 +1008,7 @@ sysctl_rtsock(SYSCTL_HANDLER_ARGS) if (req->newptr) return (EPERM); if (namelen != 3) - return (EINVAL); + return ((namelen < 3) ? EISDIR : ENOTDIR); af = name[0]; Bzero(&w, sizeof(w)); w.w_op = name[1]; > > On Wed, Jan 23, 2002 at 02:51:35AM -0800, Crist J . Clark wrote: > > > Here is a quick, broken, program, > > > > > > #include > > > #include > > > #include > > > #include > > > #include > > > #include > > > > > > #include > > > > > > /* #define MIB_LEN 6 */ > > > #define MIB_LEN 5 > > > > > > int main(int argc, char *argv[]) > > > { > > > int mib[MIB_LEN]; > > > size_t rttsize; > > > > > > mib[0] = CTL_NET; > > > mib[1] = PF_ROUTE; > > > mib[2] = 0; > > > mib[3] = AF_INET; > > > mib[4] = NET_RT_DUMP; > > > /* mib[5] = 0; */ > > > > > > if (sysctl(mib, MIB_LEN, NULL, &rttsize, NULL, 0) != 0) > > > err(EX_OSERR, "sysctl(3) for table size failed"); > > > > > > return 0; > > > } > > > > > > This broken version will return, > > > > > > $ ./sysctlerr > > > sysctlerr: sysctl(3) for table size failed: Invalid argument > > > > > > However, if we look at the errno descriptions in the sysctl(3) > > > manpage, an EINVAL is returned when, > > > > > > [EINVAL] The name array is less than two or greater than > > > CTL_MAXNAME. > > > > > > [EINVAL] A non-null newp is given and its specified length in > > > newlen is too large or too small. > > > > > > Neither of which is the case here. I think it should be returning one > > > of these, > > > > > > [ENOTDIR] The name array specifies an intermediate rather than > > > terminal name. > > > > > > [EISDIR] The name array specifies a terminal name, but the > > > actual name is not terminal. > > > > > > But "terminal" or "intermediate" names are not defined anywhere else > > > in the manpage. Cheers, -- Ruslan Ermilov Oracle Developer/DBA, ru@sunbay.com Sunbay Software AG, ru@FreeBSD.org FreeBSD committer, +380.652.512.251 Simferopol, Ukraine http://www.FreeBSD.org The Power To Serve http://www.oracle.com Enabling The Information Age To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message