Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 28 Aug 2004 13:40:50 -0700 (PDT)
From:      Brian O'Shea <b_oshea@yahoo.com>
To:        FreeBSD_Hackers <freebsd-hackers@freebsd.org>
Subject:   Re: Library (ab)use in kernel land
Message-ID:  <20040828204050.77238.qmail@web50903.mail.yahoo.com>
In-Reply-To: <20040827182358.GA2114@tin.it>

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

--- Paolo Pisati <flag@oltrelinux.com> wrote:
> 
> As a general rule of thumb, 
> which are the safe libraries we can link against 
> while developing a kernel module?

The standard C libraries that we have all come to know and
love can only be used from user space.  This is mainly because
many library functions call into the kernel (via the system
call interface), and this is not necessary or appropriate
from the perspective of kernel code (such as the kernel module
that you are writing).  Also, the assumptions that a programmer
makes when writing kernel code with respect to memory allocation
and efficiency of algorithms are different from those of an
application programmer.  For example, you wouldn't want to link
an XML DOM parser into the kernel! :-O  (however, grepping
through the GEOM code reveals that apparently it can be made to
dump its configuration information in XML format, presumablly to
be parsed by a user-space configuratoin utility... sweet!)

That being said, there are a few analogs of the standard C
library functions in the kernel, such as printf, strcpy, bcmp,
qsort, etc.  You can find sources for them in src/sys/libkern/
with prototypes in the src/sys/sys/libkern.h and src/sys/sys/systm.h
header files.

Cheers,
-brian


=====



		
_______________________________
Do you Yahoo!?
Win 1 of 4,000 free domain names from Yahoo! Enter now.
http://promotions.yahoo.com/goldrush


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