From brandt@fokus.gmd.de  Thu Dec 13 02:28:14 2001
Return-Path: <brandt@fokus.gmd.de>
Received: from mailhub.fokus.gmd.de (mailhub.fokus.gmd.de [193.174.154.14])
	by hub.freebsd.org (Postfix) with ESMTP id D9D6037B419
	for <FreeBSD-gnats-submit@freebsd.org>; Thu, 13 Dec 2001 02:28:13 -0800 (PST)
Received: from fokus.gmd.de (beagle [193.175.132.100])
	by mailhub.fokus.gmd.de (8.11.6/8.11.6) with ESMTP id fBDASC503682
	for <FreeBSD-gnats-submit@freebsd.org>; Thu, 13 Dec 2001 11:28:12 +0100 (MET)
Received: (from hbb@localhost)
	by fokus.gmd.de (8.11.6/8.11.0) id fBDASCi51711;
	Thu, 13 Dec 2001 11:28:12 +0100 (CET)
	(envelope-from hbb)
Message-Id: <200112131028.fBDASCi51711@fokus.gmd.de>
Date: Thu, 13 Dec 2001 11:28:12 +0100 (CET)
From: Hartmut Brandt <brandt@fokus.gmd.de>
Reply-To: Hartmut Brandt <brandt@fokus.gmd.de>
To: FreeBSD-gnats-submit@freebsd.org
Cc:
Subject: Wrong error named in sysctl man page
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         32793
>Category:       docs
>Synopsis:       Wrong error named in sysctl man page
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    ru
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          doc-bug
>Submitter-Id:   current-users
>Arrival-Date:   Thu Dec 13 02:30:00 PST 2001
>Closed-Date:    Thu Dec 13 03:01:00 PST 2001
>Last-Modified:  Thu Dec 13 03:01:19 PST 2001
>Originator:     Hartmut Brandt
>Release:        FreeBSD 5.0-CURRENT i386
>Organization:
Fhg Fokus
>Environment:
System: FreeBSD beagle.fokus.gmd.de 5.0-CURRENT FreeBSD 5.0-CURRENT #3: Mon Dec 10 11:29:08 CET 2001 hbb@beagle.fokus.gmd.de:/opt/obj/usr/src/sys/BEAGLE i386


	
>Description:
	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.
>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);
}
>Fix:
	Patch for /usr/src/lib/libc/gen/sysctl.3:
Index: sysctl.3
===================================================================
RCS file: /usr/ncvs/src/lib/libc/gen/sysctl.3,v
retrieving revision 1.51
diff -r1.51 sysctl.3
452c452
< .Er EOPNOTSUPP .
---
> .Er ENOENT .
790c790
< .It Bq Er EOPNOTSUPP
---
> .It Bq Er ENOENT


>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->closed 
State-Changed-By: ru 
State-Changed-When: Thu Dec 13 03:01:00 PST 2001 
State-Changed-Why:  
Committed, thanks! 


Responsible-Changed-From-To: freebsd-doc->ru 
Responsible-Changed-By: ru 
Responsible-Changed-When: Thu Dec 13 03:01:00 PST 2001 
Responsible-Changed-Why:  

http://www.FreeBSD.org/cgi/query-pr.cgi?pr=32793 
>Unformatted:
