Date: Wed, 23 Jan 2002 02:51:35 -0800 From: "Crist J . Clark" <cristjc@earthlink.net> To: hackers@freebsd.org Subject: sysctl(3) errnos wrong? Message-ID: <20020123025135.E83184@blossom.cjclark.org>
next in thread | raw e-mail | index | archive | help
Here is a quick, broken, program, #include <sys/types.h> #include <sys/sysctl.h> #include <sys/time.h> #include <sys/socket.h> #include <net/if.h> #include <net/route.h> #include <sysexits.h> /* #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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20020123025135.E83184>