Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 21 Feb 1999 23:32:15 +1100
From:      Bruce Evans <bde@zeta.org.au>
To:        bde@zeta.org.au, dfr@nlsystems.com
Cc:        current@FreeBSD.ORG, dfr@FreeBSD.ORG, romanp@wuppy.rcs.ru
Subject:   Re: Problems with nfsstat and dynamic OID
Message-ID:  <199902211232.XAA05724@godzilla.zeta.org.au>

next in thread | raw e-mail | index | archive | help
>> Now that it is possible to change the sysctl tree at runtime, the changes
>> are not actually (completely) made for vfs sysctls.  Special code for
>> making "impossible" changes for vfs sysctls went away.
>
>Oh.  Thats nasty.  I don't want to allocate special oids for 'privileged'
>nodes.  I think the userland code should use sysctlbyname() instead.
>This patch seems to fix it for me:
>
>Index: nfsstat.c
>===================================================================
>RCS file: /home/ncvs/src/usr.bin/nfsstat/nfsstat.c,v
>retrieving revision 1.12
>diff -u -r1.12 nfsstat.c
>--- nfsstat.c	1998/10/25 10:59:44	1.12
>+++ nfsstat.c	1999/02/21 11:47:08
>@@ -162,16 +162,9 @@
> 			err(1, "kvm_read");
> 		}
> 	} else {
>-		int name[3];
> 		size_t buflen = sizeof *stp;
>-		struct vfsconf vfc;
> 
>-		if (getvfsbyname("nfs", &vfc) < 0)
>-			err(1, "getvfsbyname: NFS not compiled into kernel");
>-		name[0] = CTL_VFS;
>-		name[1] = vfc.vfc_typenum;
>-		name[2] = NFS_NFSSTATS;
>-		if (sysctl(name, 3, stp, &buflen, (void *)0, (size_t)0) < 0) {
>+		if (sysctlbyname("vfs.nfs.nfsstats", stp, &buflen, (void *)0, (size_t)0) < 0) {
> 			err(1, "sysctl");
> 		}
> 	}

The old interface is the standard one (although the above code shows how
inconvenient it is).  mountd uses it too.

Perhaps the sysctl oid could be assigned to the vfs type number instead of
vice versa.  The type number namespace can already have holes, although
it can't be very sparse because getvfsbyname(3) has to do an O(n) search
of it.

Bruce


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-current" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199902211232.XAA05724>