From owner-freebsd-hackers@FreeBSD.ORG Sat Aug 28 20:40:52 2004 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id F225616A4CE for ; Sat, 28 Aug 2004 20:40:51 +0000 (GMT) Received: from web50903.mail.yahoo.com (web50903.mail.yahoo.com [206.190.38.123]) by mx1.FreeBSD.org (Postfix) with SMTP id 7AE6843D2D for ; Sat, 28 Aug 2004 20:40:51 +0000 (GMT) (envelope-from b_oshea@yahoo.com) Message-ID: <20040828204050.77238.qmail@web50903.mail.yahoo.com> Received: from [24.6.211.166] by web50903.mail.yahoo.com via HTTP; Sat, 28 Aug 2004 13:40:50 PDT Date: Sat, 28 Aug 2004 13:40:50 -0700 (PDT) From: Brian O'Shea To: FreeBSD_Hackers In-Reply-To: <20040827182358.GA2114@tin.it> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Subject: Re: Library (ab)use in kernel land X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 28 Aug 2004 20:40:52 -0000 Hello Paolo, --- Paolo Pisati 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