From owner-freebsd-current Sun Feb 21 3:50:46 1999 Delivered-To: freebsd-current@freebsd.org Received: from herring.nlsystems.com (nlsys.demon.co.uk [158.152.125.33]) by hub.freebsd.org (Postfix) with ESMTP id 88CBF11804; Sun, 21 Feb 1999 03:50:43 -0800 (PST) (envelope-from dfr@nlsystems.com) Received: from localhost (dfr@localhost) by herring.nlsystems.com (8.9.3/8.8.8) with ESMTP id LAA55454; Sun, 21 Feb 1999 11:49:13 GMT (envelope-from dfr@nlsystems.com) Date: Sun, 21 Feb 1999 11:49:13 +0000 (GMT) From: Doug Rabson To: Bruce Evans Cc: current@FreeBSD.ORG, romanp@wuppy.rcs.ru, dfr@FreeBSD.ORG Subject: Re: Problems with nfsstat and dynamic OID In-Reply-To: <199902210358.OAA07200@godzilla.zeta.org.au> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-freebsd-current@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG On Sun, 21 Feb 1999, Bruce Evans wrote: > >Hello! Five minutes ago I type 'nfsstat' and got: > > > >nfsstat: sysctl: No such file or directory > > > >I take a look at the source and that's what I found: > >Nfsstat gets statistic via sysctl(3). name[0]=CTL_VFS, name[2]=NFS_NFSSTATS, > >but name[1] has a value of vfc.vfc_typenum, returned by getvfsbyname(3). > >And it is very bad, 'cause vfc_typenum contains fs type number assigned > >by kernel, not sysctl OID! As we can see in nfs_vfsops.c NFS sysctl node > >declared with OID_AUTO (on my system it becomes 119, not 4 as returned by > >getvfsbyname). > > 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"); } } -- Doug Rabson Mail: dfr@nlsystems.com Nonlinear Systems Ltd. Phone: +44 181 442 9037 To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-current" in the body of the message