From owner-freebsd-hackers@FreeBSD.ORG Sun Jul 6 09:03:13 2003 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 A886537B401 for ; Sun, 6 Jul 2003 09:03:13 -0700 (PDT) Received: from bluejay.mail.pas.earthlink.net (bluejay.mail.pas.earthlink.net [207.217.120.218]) by mx1.FreeBSD.org (Postfix) with ESMTP id 26ACC44020 for ; Sun, 6 Jul 2003 09:03:13 -0700 (PDT) (envelope-from tlambert2@mindspring.com) Received: from user-2ivfmrb.dialup.mindspring.com ([165.247.219.107] helo=mindspring.com) by bluejay.mail.pas.earthlink.net with asmtp (SSLv3:RC4-MD5:128) (Exim 3.33 #1) id 19ZByf-0000Xu-00; Sun, 06 Jul 2003 09:03:02 -0700 Message-ID: <3F0847F2.8A985E5@mindspring.com> Date: Sun, 06 Jul 2003 09:01:54 -0700 From: Terry Lambert X-Mailer: Mozilla 4.79 [en] (Win98; U) X-Accept-Language: en MIME-Version: 1.0 To: zhuyi References: <20030704171430.68CE.ZHUYI@jstvu.edu.cn> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-ELNK-Trace: b1a02af9316fbb217a47c185c03b154d40683398e744b8a4cd6f194732abf36809acc0be4ecdd4b8350badd9bab72f9c350badd9bab72f9c350badd9bab72f9c cc: freebsd-hackers@freebsd.org Subject: Re: how to call a syscall in a kernel module? 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: Sun, 06 Jul 2003 16:03:14 -0000 zhuyi wrote: > Dear all: > How to call a syscall in a kernel module? In Linux, you can add two > line into your source code. > > #define __KERNEL_SYSCALLS__ > #include Most system calls call "copyin" or "copyinstr" or "uiomove", which assumes that the data is in the user process that is active at the time of the system call. This basically boils down to UIO_SYSSPACE vs. UIO_USERSPACE. Because of this, it's generally not possible to call system calls from within the kernel. It's probably reasonable to turn all the system calls into wrappers; there would be an additional function call worth of overhead for all system calls, but the benefit would be to enable calling of all calls from kernel space. The overhead is probably worth it (AIX works this way, and it doesn't seem to hurt them at all). -- Terry