On Wed, 31 Oct 2001, A V wrote:

>
> Yes really it is nice information. But in my case
> though i am calling system call query_module i am
> getting same problem. I hope we can use system calls

Ok, system calls, for all intents and purposes, you should consider
equivalent to user-space library routines.  They are not designed to be
called from kernel space.  I briefly hinted that *some* system calls may
be usable from kernel space under limited circumstances, but I may be
wrong about this.  It very likely may be the case that you can never call
any system calls from kernel space, since they may all somehow assume they
are dealing with 'far' pointers into user memory or, a lot of system calls
depend on the currently running thread context.  Here's where my knowledge
about the kernel gets fuzzy, but real-time kernel threads may have
inconsitent/nonexistant information, since they aren't really user threads
and thus may lack things such as a table of file descriptors, etc.

At any rate, system calls such as query_module are called SYS_query_module
in the kernel and really aren't exported (ie you can't link to them from
modules).  In order to use such system calls from the kernel, you would
have to get to the system call table and invoke the correct function
pointer for that system call.  Not pretty, but theoretically possible.

Anyway, don't use system calls from the kernel. If you really need
user-space functionality from your module, then maybe write a user-space
counterpart to your module and if it has to be realtime use things like
RTF's and maybe the real-time mbuff driver.  I am assuming maybe you need
information about other loaded modules, that's why you wanted to call
query_module?  Well there are some macros such as THIS_MODULE or
_THIS_MODULE which are pointers to the current module in the module
linked-list.  You can probably traverse that list to get information about
other running modules.

> in realtime programs.
> I am getting same error wherever the query_module
> systems call is ( i.e in init_module as well as real
> time thread).
>
> Can u please clarify my doubt..
>
> Advanced Thanks
> Venkat
>
>
>
> --- "Calin A. Culianu" <[EMAIL PROTECTED]> wrote:
> >
> > Time and again, someone on this mailing list asks a
> > question like this.
> > I call it the fundamental kernel attribution error.
> > :)
> >
> > Ok.. here's a brief explanation as to why you are
> > having this trouble:
> >
> > The kernel != user space.  period.  For a more
> > complete explanation on why
> > this is, please start with the OS book by
> > Tannenbaum, and work your way up
> > from there.  fopen() is a user space library
> > function that ultimately
> > talks to the kernel via more 'primitive' system
> > calls such as read() and
> > write().
> >
> > When you are writing a module, you ARE the kernel.
> > As such, you cannot
> > ever ever ever EVER use any libraries.  You can't
> > even use system calls!
> > (At least not easily and/or really elegantly).  No
> > libraries... at least
> > not user libraries.  The kernel has it's own UNIQUE
> > and DISTINCT set of
> > 'library' functions that are sort of compiled into
> > it.  Things for
> > managing memory, working with strings, abusing its
> > own data structures,
> > dealing with user space, fennagling interrupts,
> > etc...  Some of these
> > library routines have the same name as the
> > conventional c library
> > routines.. (strncpy() is one example that comes to
> > mind, there are
> > others). However, that's where the similarities end.
> >  The kernel is it's
> > own programming environment.  Apart from the fact
> > that you are using C,
> > forget everything you ever knew about using C and
> > the C library when you
> > are solving programmatic problems in the kernel
> > (ok.. that's a bit
> > strong.. a lot of the kernel library resembles the
> > user-space library
> > stuff so yeah, it helps to have the background just
> > so you can quickly
> > learn the way the kernel does things). But the main
> > reason for the above
> > rant is this: Open yourself up to learning the
> > kernel's library.
> >
> > Since the above paragraph is true, whenever you
> > create modules, you need
> > to use KERNEL header files.  You used user header
> > files which explains
> >  how you were able to create the unlinked .o kernel
> > modules, but upon
> > linking it into the kernel (loading the module has
> > the all-too-important
> > side-effect of linking to the kernel, too) you got
> > that undefined symbol
> > error.
> >
> > The kernel header files are found most likely either
> > in your
> > /usr/src/linux/include directory or maybe in
> > /usr/include/linux (but the
> > latter isn't as reliable for many reasons). Also, to
> > use these header
> > files effectively, you need to define some
> > preprocessor symbols like
> > __KERNEL__ and MODULE.
> >
> >
> >
> > On Tue, 30 Oct 2001, [iso-8859-1] Peter Gr�ssinger
> > wrote:
> >
> > > hello,
> > >
> > > i am running rtlinux 2.3  on a PC104. i was trying
> > to use the
> > > function fopen() within the init_module of my
> > kernel module. when
> > > inserting the module i unfortunately get the error
> > "unresolved symbol
> > > fopen".
> > >
> > > would sombody know how to  upgrade the c lib in
> > order so be able to load
> > > my module ?
> > >
> > > thank you very much in advance !
> > >
> > >
> > > kindest regards,
> > > peter
> > >
> > >
> >
> _____________________________________________________
> > >
> > > Peter Groessinger
> > > Software Development
> > > TTTech Computertechnik AG
> > > Schoenbrunner Strasse 7, A-1040 Vienna, Austria
> > > http://www.tttech.com
> > >
> > > Phone: +43(1)585 34 34-42, Fax: +43(1)585 34 34-90
> > > mailto: [EMAIL PROTECTED]
> > >
> >
> _____________________________________________________
> > >
> > >
> > > -- [rtl] ---
> > > To unsubscribe:
> > > echo "unsubscribe rtl" | mail
> > [EMAIL PROTECTED] OR
> > > echo "unsubscribe rtl <Your_email>" | mail
> > [EMAIL PROTECTED]
> > > --
> > > For more information on Real-Time Linux see:
> > > http://www.rtlinux.org/
> > >
> >
> > -- [rtl] ---
> > To unsubscribe:
> > echo "unsubscribe rtl" | mail [EMAIL PROTECTED]
> > OR
> > echo "unsubscribe rtl <Your_email>" | mail
> > [EMAIL PROTECTED]
> > --
> > For more information on Real-Time Linux see:
> > http://www.rtlinux.org/
> >
>
>
> __________________________________________________
> Do You Yahoo!?
> Make a great connection at Yahoo! Personals.
> http://personals.yahoo.com
> -- [rtl] ---
> To unsubscribe:
> echo "unsubscribe rtl" | mail [EMAIL PROTECTED] OR
> echo "unsubscribe rtl <Your_email>" | mail [EMAIL PROTECTED]
> --
> For more information on Real-Time Linux see:
> http://www.rtlinux.org/
>

-- [rtl] ---
To unsubscribe:
echo "unsubscribe rtl" | mail [EMAIL PROTECTED] OR
echo "unsubscribe rtl <Your_email>" | mail [EMAIL PROTECTED]
--
For more information on Real-Time Linux see:
http://www.rtlinux.org/

Reply via email to