Re: Functions in Library versus in Kernel

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Jul 30, 2002 at 04:36:30PM +0200, Torsten Schlabach wrote:
> So my question is: Do I have to avoid using functions that are in the
> C library when writing kernel modules or is there a special trick that
> I need to now.

Movement, could you please add this question and my answer to the FAQ?
(Feel free to modify as you wish; for legal whatnot, I hearby grant this
to the public domain for use in whatever fashion one might desire.)
This question seems to be coming up more and more frequently...

System libraries (such as glibc, libreadline, libproplist, whatever)
that are typically available to userspace programmers are unavailable to
kernel programmers. When a processes is being loaded the loader will
automatically load any dependant libraries into the address space of the
process. None of this mechanism is available to kernel programmers:
forget about ISO C libraries, the only things available is what is
already implemented (and exported) in the kernel and what you can
implement yourself.

Note that it _is_ possible to "convert" libraries to work in the kernel;
however, they won't fit well, the process is tedious and error-prone,
and there might be significant problems with stack handling (the kernel
is limited to a small amount of stack space, while userspace programs
don't have this limitation) causing random memory corruption.

Many of the commonly requested functions have already been implemented
in the kernel, sometimes in "lightweight" versions that aren't as
featureful as their userland counterparts. Be sure to grep the headers
for any functions you might be able to use before writing your own
version from scratch. Some of the most commonly used ones are in
include/linux/string.h.



-- 
Outlook users: please do not put my email address in your address book.
This way, when you get infected with a virus, my address won't appear in
the From: header. Thanks.

Attachment: pgp00137.pgp
Description: PGP signature


[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux