Using userland library in Kernel

Craig Boston cb at severious.net
Wed Aug 8 10:42:47 PDT 2007


On Wed, Aug 08, 2007 at 11:23:25AM -0500, Biks N wrote:
> I am new to FreeBSD kernel programming and I am trying to use userland
> library (zlib) in FreeBSD kernel. But I am not sure if zlib library is
> linkable from the kernel.

Normally, no, you can't just link in a library designed for userland
into the kernel.  Some porting is required to deal with the kernel
environment -- things such as not having a full C library available,
different memory management, etc.

In this case however, there is already a zlib implementation in the
kernel.  IIRC, geom_uzip and the crypto framework both use it.

You may want to check out sys/net/zlib.[ch] and see if it can do what
you're after.  You'll need to make sure to include a dependency on the
zlib module and/or add it to your kernel configuration.

Good luck,
Craig


More information about the freebsd-hackers mailing list