Bug 32793

Summary: Wrong error named in sysctl man page
Product: Documentation Reporter: brandt <brandt>
Component: Books & ArticlesAssignee: ru <ru>
Status: Closed FIXED    
Severity: Affects Only Me    
Priority: Normal    
Version: Latest   
Hardware: Any   
OS: Any   
Attachments:
Description Flags
file.diff none

Description brandt 2001-12-13 10:30:00 UTC
	The sysctl.3 man page describes sysctl() returning EOPNOTSUPP
	in the case the named variable is not found. This is obviously wrong
	because sysctl() returns ENOENT. There is only one instance of
	EOPNOTSUPP in kern_sysctl.c and this is for the BSDI 1.0 getkerninfo.

Fix: Patch for /usr/src/lib/libc/gen/sysctl.3:
How-To-Repeat: 	Compile and run the following test program which tries to access an
	non-existing variable. See it printing an errno of 2 (ENOENT).

#include <sys/types.h>
#include <sys/sysctl.h>
#include <sys/socket.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <net/if.h>
#include <net/if_mib.h>

int
main(int argc, char *argv[])
{
	u_int ifnum;
	int name[6];
	size_t len = sizeof(ifnum);

	name[0] = CTL_NET;
	name[1] = PF_LINK;
	name[2] = NETLINK_GENERIC;
	name[3] = IFMIB_SYSTEM;
	name[4] = 17;

	if (sysctl(name, 5, &ifnum, &len, NULL, 0) == -1)
		err(1, "sysctl %d", errno);

	return (0);
}
Comment 1 ru freebsd_committer freebsd_triage 2001-12-13 11:01:00 UTC
State Changed
From-To: open->closed

Committed, thanks! 


Comment 2 ru freebsd_committer freebsd_triage 2001-12-13 11:01:00 UTC
Responsible Changed
From-To: freebsd-doc->ru