From owner-freebsd-hackers Thu Jan 24 2:28: 4 2002 Delivered-To: freebsd-hackers@freebsd.org Received: from albatross.prod.itd.earthlink.net (albatross.mail.pas.earthlink.net [207.217.120.120]) by hub.freebsd.org (Postfix) with ESMTP id CE2B137B417; Thu, 24 Jan 2002 02:27:46 -0800 (PST) Received: from dialup-209.244.107.7.dial1.sanjose1.level3.net ([209.244.107.7] helo=blossom.cjclark.org) by albatross.prod.itd.earthlink.net with esmtp (Exim 3.33 #1) id 16Th6f-0003RA-00; Thu, 24 Jan 2002 02:27:46 -0800 Received: (from cjc@localhost) by blossom.cjclark.org (8.11.6/8.11.3) id g0OARhr89549; Thu, 24 Jan 2002 02:27:43 -0800 (PST) (envelope-from cjc) Date: Thu, 24 Jan 2002 02:27:42 -0800 From: "Crist J. Clark" To: Ruslan Ermilov Cc: hackers@FreeBSD.ORG Subject: Re: sysctl(3) errnos wrong? Message-ID: <20020124022742.F87663@blossom.cjclark.org> References: <20020123025135.E83184@blossom.cjclark.org> <20020124115209.B16972@sunbay.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5i In-Reply-To: <20020124115209.B16972@sunbay.com>; from ru@FreeBSD.ORG on Thu, Jan 24, 2002 at 11:52:09AM +0200 X-URL: http://people.freebsd.org/~cjc/ 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 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? > 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. -- Crist J. Clark | cjclark@alum.mit.edu | cjclark@jhu.edu http://people.freebsd.org/~cjc/ | cjc@freebsd.org To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message