On 8/2/07, Gavin Maltby <[EMAIL PROTECTED]> wrote:
> On 08/02/07 14:18, Aubrey Li wrote:
> > Hi all,
> >
> > I can access a Global structure by mdb-> Global_struct=X, it prints
> > the address of that structure. Now I want to access it from user
> > space, so I wrote a driver and put it in the read op.
> >  cmn_err(CE_NOTE, "Global structure = 0x%x\n", (unsigned 
> > int)&Global_struct);
> >
> > The driver build successful but report error( undefined symbol) when
> > issue "add_drv mydriver".
> > It's wired for me. Can't the driver access the global variable of the 
> > kernel?
>
> Yes there are restrictions.
>
> The 'mem' driver already exists for this purpose - it supplies /dev/zero,
> /dev/mem, /dev/physmem, /dev/kmem, /dev/allkmem etc.   Together with
> /dev/ksyms (see manpage) they provide the infrastructure on top
> of which libkvm builds, and mdb just uses those interfaces.
> So you can lookup a symbol or symbols using kvm_nlist and then
> read out the structure with kvm_read.  Those are supplied
> by libkvm and you can use that to build standalone applications.
> Alternatively, work within the friendlier mdb api but accept
> living in a dcmd or walker.
>
> Cheers
>
> Gavin
>
>
Hi Gavin,

Thanks for your quick reply.
I don't think a standalone application is my purpose, but I'm not
familiar with kvm_read.
I wanna dump a kernel global structure from user space, even using
kvm_read, I think I can only get an address? So I need type-casting to
convert the address to an structure pointer, here I need the structure
define, where kernel header is needed.
So Is the driver still a better choice?

Thanks.
-Aubrey
_______________________________________________
opensolaris-code mailing list
[email protected]
http://mail.opensolaris.org/mailman/listinfo/opensolaris-code

Reply via email to