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/

Reply via email to