From 9e8563ebc33bbae323eead47a41b9d6333fca065 Mon Sep 17 00:00:00 2001 From: Miod Vallat Date: Sun, 16 Jun 2002 16:54:30 +0000 Subject: When processing the KERN_VNODE sysctl, the kernel builds a packed structure, while pstat(8) expects a C structure abiding the regular structure packing rules. This caused pstat -v to break on powerpc. Unbreak the confusion by defining the structure in a common header file, and having the kernel use it. ok millert@ deraadt@ --- sys/kern/vfs_subr.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) (limited to 'sys/kern') diff --git a/sys/kern/vfs_subr.c b/sys/kern/vfs_subr.c index 0b7a3ac78e1..4d899a48ce5 100644 --- a/sys/kern/vfs_subr.c +++ b/sys/kern/vfs_subr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: vfs_subr.c,v 1.85 2002/06/08 18:36:45 art Exp $ */ +/* $OpenBSD: vfs_subr.c,v 1.86 2002/06/16 16:54:25 miod Exp $ */ /* $NetBSD: vfs_subr.c,v 1.53 1996/04/22 01:39:13 christos Exp $ */ /* @@ -1433,10 +1433,8 @@ sysctl_vnode(where, sizep, p) char *ewhere; int error; -#define VPTRSZ sizeof (struct vnode *) -#define VNODESZ sizeof (struct vnode) if (where == NULL) { - *sizep = (numvnodes + KINFO_VNODESLOP) * (VPTRSZ + VNODESZ); + *sizep = (numvnodes + KINFO_VNODESLOP) * sizeof(struct e_vnode); return (0); } ewhere = where + *sizep; @@ -1465,15 +1463,19 @@ again: goto again; } nvp = vp->v_mntvnodes.le_next; - if (bp + VPTRSZ + VNODESZ > ewhere) { + if (bp + sizeof(struct e_vnode) > ewhere) { simple_unlock(&mntvnode_slock); *sizep = bp - where; return (ENOMEM); } - if ((error = copyout((caddr_t)&vp, bp, VPTRSZ)) || - (error = copyout((caddr_t)vp, bp + VPTRSZ, VNODESZ))) + if ((error = copyout((caddr_t)&vp, + &((struct e_vnode *)bp)->vptr, + sizeof(struct vnode *))) || + (error = copyout((caddr_t)vp, + &((struct e_vnode *)bp)->vnode, + sizeof(struct vnode)))) return (error); - bp += VPTRSZ + VNODESZ; + bp += sizeof(struct e_vnode); simple_lock(&mntvnode_slock); } -- cgit v1.2.3