diff options
-rw-r--r-- | lib/libc/gen/sysctl.3 | 15 | ||||
-rw-r--r-- | sbin/sysctl/sysctl.c | 7 | ||||
-rw-r--r-- | sys/kern/kern_sysctl.c | 4 | ||||
-rw-r--r-- | sys/kern/vfs_subr.c | 66 | ||||
-rw-r--r-- | sys/sys/sysctl.h | 18 | ||||
-rw-r--r-- | sys/sys/vnode.h | 10 | ||||
-rw-r--r-- | usr.sbin/pstat/pstat.c | 42 |
7 files changed, 24 insertions, 138 deletions
diff --git a/lib/libc/gen/sysctl.3 b/lib/libc/gen/sysctl.3 index 9b181f1dc9d..62d8e7c698a 100644 --- a/lib/libc/gen/sysctl.3 +++ b/lib/libc/gen/sysctl.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: sysctl.3,v 1.242 2014/08/27 14:04:15 florian Exp $ +.\" $OpenBSD: sysctl.3,v 1.243 2014/11/19 18:04:54 tedu Exp $ .\" .\" Copyright (c) 1993 .\" The Regents of the University of California. All rights reserved. @@ -27,7 +27,7 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.Dd $Mdocdate: August 27 2014 $ +.Dd $Mdocdate: November 19 2014 $ .Dt SYSCTL 3 .Os .Sh NAME @@ -463,7 +463,6 @@ information. .It Dv KERN_TTYCOUNT Ta "integer" Ta "no" .It Dv KERN_USERMOUNT Ta "integer" Ta "yes" .It Dv KERN_VERSION Ta "string" Ta "no" -.It Dv KERN_VNODE Ta "struct e_vnode" Ta "no" .It Dv KERN_WATCHDOG Ta "node" Ta "not applicable" .El .Bl -tag -width "123456" @@ -1033,16 +1032,6 @@ requests. The default value is 0. .It Dv KERN_VERSION The system version string. -.It Dv KERN_VNODE -Return the entire vnode table. -Note, the vnode table is not necessarily a consistent snapshot of -the system. -The returned data consists of an array whose size depends on the -current number of such objects in the system. -Each element of the array contains the kernel address of a vnode -.Pq Li struct vnode * -followed by the vnode itself -.Pq Li struct vnode . .It Dv KERN_WATCHDOG Return information on hardware watchdog timers. If the kernel does not support a hardware watchdog timer, diff --git a/sbin/sysctl/sysctl.c b/sbin/sysctl/sysctl.c index d5836a66612..0616c788217 100644 --- a/sbin/sysctl/sysctl.c +++ b/sbin/sysctl/sysctl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sysctl.c,v 1.206 2014/10/26 03:45:29 brad Exp $ */ +/* $OpenBSD: sysctl.c,v 1.207 2014/11/19 18:04:54 tedu Exp $ */ /* $NetBSD: sysctl.c,v 1.9 1995/09/30 07:12:50 thorpej Exp $ */ /* @@ -388,11 +388,6 @@ parse(char *string, int flags) return; warnx("use dmesg to view %s", string); return; - case KERN_VNODE: - if (flags == 0) - return; - warnx("use pstat to view %s information", string); - return; case KERN_PROC: if (flags == 0) return; diff --git a/sys/kern/kern_sysctl.c b/sys/kern/kern_sysctl.c index 3d43b2f944e..0cde7805c31 100644 --- a/sys/kern/kern_sysctl.c +++ b/sys/kern/kern_sysctl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kern_sysctl.c,v 1.270 2014/11/16 12:31:00 deraadt Exp $ */ +/* $OpenBSD: kern_sysctl.c,v 1.271 2014/11/19 18:04:54 tedu Exp $ */ /* $NetBSD: kern_sysctl.c,v 1.17 1996/05/20 17:49:05 mrg Exp $ */ /*- @@ -355,8 +355,6 @@ kern_sysctl(int *name, u_int namelen, void *oldp, size_t *oldlenp, void *newp, TIMESPEC_TO_TIMEVAL(&bt, &boottime); return (sysctl_rdstruct(oldp, oldlenp, newp, &bt, sizeof bt)); } - case KERN_VNODE: - return (sysctl_vnode(oldp, oldlenp, p)); #ifndef SMALL_KERNEL case KERN_PROC: return (sysctl_doproc(name + 1, namelen - 1, oldp, oldlenp)); diff --git a/sys/kern/vfs_subr.c b/sys/kern/vfs_subr.c index ccb43716fc4..8824ef6724c 100644 --- a/sys/kern/vfs_subr.c +++ b/sys/kern/vfs_subr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: vfs_subr.c,v 1.221 2014/11/14 23:26:48 tedu Exp $ */ +/* $OpenBSD: vfs_subr.c,v 1.222 2014/11/19 18:04:54 tedu Exp $ */ /* $NetBSD: vfs_subr.c,v 1.53 1996/04/22 01:39:13 christos Exp $ */ /* @@ -1291,70 +1291,6 @@ vfs_sysctl(int *name, u_int namelen, void *oldp, size_t *oldlenp, void *newp, return (EOPNOTSUPP); } -int kinfo_vdebug = 1; -#define KINFO_VNODESLOP 10 -/* - * Dump vnode list (via sysctl). - * Copyout address of vnode followed by vnode. - */ -/* ARGSUSED */ -int -sysctl_vnode(char *where, size_t *sizep, struct proc *p) -{ - struct mount *mp, *nmp; - struct vnode *vp, *nvp; - char *bp = where, *savebp; - char *ewhere; - int error; - - if (where == NULL) { - *sizep = (numvnodes + KINFO_VNODESLOP) * sizeof(struct e_vnode); - return (0); - } - ewhere = where + *sizep; - - TAILQ_FOREACH_SAFE(mp, &mountlist, mnt_list, nmp) { - if (vfs_busy(mp, VB_READ|VB_NOWAIT)) - continue; - savebp = bp; -again: - LIST_FOREACH_SAFE(vp, &mp->mnt_vnodelist, v_mntvnodes, nvp) { - /* - * Check that the vp is still associated with - * this filesystem. RACE: could have been - * recycled onto the same filesystem. - */ - if (vp->v_mount != mp) { - if (kinfo_vdebug) - printf("kinfo: vp changed\n"); - bp = savebp; - goto again; - } - if (bp + sizeof(struct e_vnode) > ewhere) { - *sizep = bp - where; - vfs_unbusy(mp); - return (ENOMEM); - } - if ((error = copyout(&vp, - &((struct e_vnode *)bp)->vptr, - sizeof(struct vnode *))) || - (error = copyout(vp, - &((struct e_vnode *)bp)->vnode, - sizeof(struct vnode)))) { - vfs_unbusy(mp); - return (error); - } - bp += sizeof(struct e_vnode); - } - - vfs_unbusy(mp); - } - - *sizep = bp - where; - - return (0); -} - /* * Check to see if a filesystem is mounted on a block device. */ diff --git a/sys/sys/sysctl.h b/sys/sys/sysctl.h index 665aae654c6..52b3d2ca096 100644 --- a/sys/sys/sysctl.h +++ b/sys/sys/sysctl.h @@ -1,4 +1,4 @@ -/* $OpenBSD: sysctl.h,v 1.150 2014/10/17 01:51:39 tedu Exp $ */ +/* $OpenBSD: sysctl.h,v 1.151 2014/11/19 18:04:54 tedu Exp $ */ /* $NetBSD: sysctl.h,v 1.16 1996/04/09 20:55:36 cgd Exp $ */ /* @@ -113,9 +113,9 @@ struct ctlname { #define KERN_HOSTNAME 10 /* string: hostname */ #define KERN_HOSTID 11 /* int: host identifier */ #define KERN_CLOCKRATE 12 /* struct: struct clockinfo */ -#define KERN_VNODE 13 /* struct: vnode structures */ -/*define gap: was KERN_PROC 14 */ -/*define gap: was KERN_FILE 15 */ +/* was KERN_VNODE 13 */ +/* was KERN_PROC 14 */ +/* was KERN_FILE 15 */ #define KERN_PROF 16 /* node: kernel profiling info */ #define KERN_POSIX1 17 /* int: POSIX.1 version */ #define KERN_NGROUPS 18 /* int: # of supplemental group ids */ @@ -152,15 +152,15 @@ struct ctlname { #define KERN_POOL 49 /* struct: pool information */ #define KERN_STACKGAPRANDOM 50 /* int: stackgap_random */ #define KERN_SYSVIPC_INFO 51 /* struct: SysV sem/shm/msg info */ -/* was define KERN_USERCRYPTO 52 */ -/* was define KERN_CRYPTODEVALLOWSOFT 53 */ +/* was KERN_USERCRYPTO 52 */ +/* was KERN_CRYPTODEVALLOWSOFT 53 */ #define KERN_SPLASSERT 54 /* int: splassert */ #define KERN_PROC_ARGS 55 /* node: proc args and env */ #define KERN_NFILES 56 /* int: number of open files */ #define KERN_TTYCOUNT 57 /* int: number of tty devices */ #define KERN_NUMVNODES 58 /* int: number of vnodes in use */ #define KERN_MBSTAT 59 /* struct: mbuf statistics */ -/* was define KERN_USERASYMCRYPTO 60 */ +/* was KERN_USERASYMCRYPTO 60 */ #define KERN_SEMINFO 61 /* struct: SysV struct seminfo */ #define KERN_SHMINFO 62 /* struct: SysV struct shminfo */ #define KERN_INTRCNT 63 /* node: interrupt counters */ @@ -174,7 +174,7 @@ struct ctlname { #define KERN_CPTIME2 71 /* array: cp_time2 */ #define KERN_CACHEPCT 72 /* buffer cache % of physmem */ #define KERN_FILE 73 /* struct: file entries */ -/* was define KERN_RTHREADS 74 */ +/* was KERN_RTHREADS 74 */ #define KERN_CONSDEV 75 /* dev_t: console terminal device */ #define KERN_NETLIVELOCKS 76 /* int: number of network livelocks */ #define KERN_POOL_DEBUG 77 /* int: enable pool_debug */ @@ -196,7 +196,7 @@ struct ctlname { { "hostname", CTLTYPE_STRING }, \ { "hostid", CTLTYPE_INT }, \ { "clockrate", CTLTYPE_STRUCT }, \ - { "vnode", CTLTYPE_STRUCT }, \ + { "gap", 0 }, \ { "gap", 0 }, \ { "gap", 0 }, \ { "profiling", CTLTYPE_NODE }, \ diff --git a/sys/sys/vnode.h b/sys/sys/vnode.h index f993a02617f..df5b211e943 100644 --- a/sys/sys/vnode.h +++ b/sys/sys/vnode.h @@ -1,4 +1,4 @@ -/* $OpenBSD: vnode.h,v 1.126 2014/11/17 16:49:04 tedu Exp $ */ +/* $OpenBSD: vnode.h,v 1.127 2014/11/19 18:04:54 tedu Exp $ */ /* $NetBSD: vnode.h,v 1.38 1996/02/29 20:59:05 cgd Exp $ */ /* @@ -207,14 +207,6 @@ struct vattr { */ #define VNOVAL (-1) -/* - * Structure returned by the KERN_VNODE sysctl - */ -struct e_vnode { - struct vnode *vptr; - struct vnode vnode; -}; - #ifdef _KERNEL /* * Convert between vnode types and inode formats (since POSIX.1 diff --git a/usr.sbin/pstat/pstat.c b/usr.sbin/pstat/pstat.c index 6e860bbb6fd..1ce2e6caa4d 100644 --- a/usr.sbin/pstat/pstat.c +++ b/usr.sbin/pstat/pstat.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pstat.c,v 1.92 2014/10/08 04:52:54 deraadt Exp $ */ +/* $OpenBSD: pstat.c,v 1.93 2014/11/19 18:04:54 tedu Exp $ */ /* $NetBSD: pstat.c,v 1.27 1996/10/23 22:50:06 cgd Exp $ */ /*- @@ -83,6 +83,11 @@ struct nlist vnodenl[] = { struct nlist *globalnl; +struct e_vnode { + struct vnode *vptr; + struct vnode vnode; +}; + int usenumflag; int totalflag; int kflag; @@ -109,8 +114,6 @@ struct mount * getmnt(struct mount *); struct e_vnode * kinfo_vnodes(int *); -struct e_vnode * - loadvnodes(int *); void mount_print(struct mount *); void nfs_header(void); int nfs_print(struct vnode *); @@ -334,7 +337,7 @@ vnodemode(void) globalnl = vnodenl; - e_vnodebase = loadvnodes(&numvnodes); + e_vnodebase = kinfo_vnodes(&numvnodes); if (totalflag) { (void)printf("%7d vnodes\n", numvnodes); return; @@ -777,34 +780,6 @@ mount_print(struct mount *mp) (void)printf("\n"); } -struct e_vnode * -loadvnodes(int *avnodes) -{ - int mib[2]; - size_t copysize; - struct e_vnode *vnodebase; - - if (memf != NULL) { - /* - * do it by hand - */ - return (kinfo_vnodes(avnodes)); - } - mib[0] = CTL_KERN; - mib[1] = KERN_VNODE; - if (sysctl(mib, 2, NULL, ©size, NULL, 0) == -1) - err(1, "sysctl: KERN_VNODE"); - if ((vnodebase = malloc(copysize)) == NULL) - err(1, "malloc: vnode table"); - if (sysctl(mib, 2, vnodebase, ©size, NULL, 0) == -1) - err(1, "sysctl: KERN_VNODE"); - if (copysize % sizeof(struct e_vnode)) - errx(1, "vnode size mismatch"); - *avnodes = copysize / sizeof(struct e_vnode); - - return (vnodebase); -} - /* * simulate what a running kernel does in kinfo_vnode */ @@ -834,7 +809,8 @@ kinfo_vnodes(int *avnodes) (sizeof(struct vnode *) + sizeof(struct vnode)); KGET(V_MOUNTLIST, kvm_mountlist); num = 0; - TAILQ_FOREACH(mp, &kvm_mountlist, mnt_list) { + for (mp = TAILQ_FIRST(&kvm_mountlist); mp != NULL; + mp = TAILQ_NEXT(&mount, mnt_list)) { KGET2(mp, &mount, sizeof(mount), "mount entry"); for (vp = LIST_FIRST(&mount.mnt_vnodelist); vp != NULL; vp = LIST_NEXT(&vnode, v_mntvnodes)) { |