From owner-freebsd-current Fri Oct 25 11:15: 9 2002 Delivered-To: freebsd-current@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 0FC3D37B401 for ; Fri, 25 Oct 2002 11:15:07 -0700 (PDT) Received: from mail.speakeasy.net (mail13.speakeasy.net [216.254.0.213]) by mx1.FreeBSD.org (Postfix) with ESMTP id 6A81843E42 for ; Fri, 25 Oct 2002 11:15:06 -0700 (PDT) (envelope-from jhb@FreeBSD.org) Received: (qmail 12532 invoked from network); 25 Oct 2002 18:15:11 -0000 Received: from unknown (HELO server.baldwin.cx) ([216.27.160.63]) (envelope-sender ) by mail13.speakeasy.net (qmail-ldap-1.03) with DES-CBC3-SHA encrypted SMTP for ; 25 Oct 2002 18:15:11 -0000 Received: from laptop.baldwin.cx (gw1.twc.weather.com [216.133.140.1]) by server.baldwin.cx (8.12.6/8.12.6) with ESMTP id g9PIF4n5075942; Fri, 25 Oct 2002 14:15:04 -0400 (EDT) (envelope-from jhb@FreeBSD.org) Message-ID: X-Mailer: XFMail 1.5.2 on FreeBSD X-Priority: 3 (Normal) Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 8bit MIME-Version: 1.0 In-Reply-To: <20021025123724.X78655-101000@shumai.marcuscom.com> Date: Fri, 25 Oct 2002 14:15:08 -0400 (EDT) From: John Baldwin To: Joe Marcus Clarke Subject: Re: libgtop port and v_tag changes Cc: Nate Lawson , current@FreeBSD.org Sender: owner-freebsd-current@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG On 25-Oct-2002 Joe Marcus Clarke wrote: > On Fri, 25 Oct 2002, John Baldwin wrote: > >> >> On 25-Oct-2002 Joe Marcus Clarke wrote: >> > On Thu, 2002-10-24 at 19:13, Nate Lawson wrote: >> >> On Thu, 24 Oct 2002, John Baldwin wrote: >> >> > Speaking of v_tag, can you fix the devel/libgtop port on current? >> >> > This is the patch I used to get it building the other day: >> >> > >> >> > > cat patch-sysdeps_freebsd_procmap.c >> >> > --- sysdeps/freebsd/procmap.c.orig Tue Oct 15 20:00:35 2002 >> >> > +++ sysdeps/freebsd/procmap.c Tue Oct 15 20:05:54 2002 >> >> > @@ -251,6 +251,7 @@ >> >> > &vnode, sizeof (vnode)) != sizeof (vnode)) >> >> > glibtop_error_io_r (server, "kvm_read (vnode)"); >> >> > >> >> > +#if __FreeBSD_version < 500000 >> >> > if ((vnode.v_type != VREG) || (vnode.v_tag != VT_UFS) || >> >> > !vnode.v_data) continue; >> >> > >> >> > @@ -261,6 +262,7 @@ >> >> > >> >> > maps [i-1].inode = inode.i_number; >> >> > maps [i-1].device = inode.i_dev; >> >> > +#endif >> >> > #endif >> >> > } while (entry.next != first); >> >> > >> >> > -- >> >> > >> >> > John Baldwin <>< http://www.FreeBSD.org/~jhb/ >> >> > "Power Users Use the Power to Serve!" - http://www.FreeBSD.org/ >> >> >> >> I assume Joe has a better version he planned to commit as referenced by >> >> this email: >> >> >> >> <1033747570.319.16.camel@gyros.marcuscom.com> >> >> >> >> I like his patch better because it still handles the non CURRENT case. >> >> Joe? >> > >> > I committed my patch to libgtop and libgtop2 a while ago. It should >> > work on both -CURRENT, not so -CURRENT, and -stable. Checkout patch-ah >> > in libgtop/files. Works like a champ on -CURRENT from Monday. >> >> It does?! v_tag is a pointer to kernel memory, you can't read that >> from userland! You would get a SIGSEGV and die as soon as you do the >> 'strcmp()'. That's why I #ifdef'd the whole chunk out. Also, just for >> the record, my code didn't break the non CURRENT case. :) > > Gak! If Julian didn't pound kvm_read into my head before, I've got it > now. Sure, it compiles, buth then what :-}. Thanks for the pointer. > Attached is a patch to libgtop2, but should be similar if not identical to > what's needed for libgtop. Let me know if this looks a little better. > Thanks. Well, here's the thing. If libgtop is intended to be used only with live kernels then it might be a better idea to use xvnode's that you get with from the kernel. Alternatively, you could grab the inode and dev number the same way the sysctl handler does: switch (vp->v_type) { case VREG: case VDIR: case VLNK: xvn[n].xv_dev = vp->v_cachedfs; xvn[n].xv_ino = vp->v_cachedid; i.e., you could look at those members of struct vnode instead of trying to dig into the details of a UFS inode structure in v_data. This would remove the need to look at v_tag at all. -- John Baldwin <>< http://www.FreeBSD.org/~jhb/ "Power Users Use the Power to Serve!" - http://www.FreeBSD.org/ To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-current" in the body of the message