Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 25 Oct 2002 14:15:08 -0400 (EDT)
From:      John Baldwin <jhb@FreeBSD.org>
To:        Joe Marcus Clarke <marcus@marcuscom.com>
Cc:        Nate Lawson <nate@root.org>, current@FreeBSD.org
Subject:   Re: libgtop port and v_tag changes
Message-ID:  <XFMail.20021025141508.jhb@FreeBSD.org>
In-Reply-To: <20021025123724.X78655-101000@shumai.marcuscom.com>

next in thread | previous in thread | raw e-mail | index | archive | help

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 <jhb@FreeBSD.org>  <><  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 <jhb@FreeBSD.org>  <><  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




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