Date: Sun, 06 Jul 2003 09:01:54 -0700 From: Terry Lambert <tlambert2@mindspring.com> To: zhuyi <zhuyi@jstvu.edu.cn> Cc: freebsd-hackers@freebsd.org Subject: Re: how to call a syscall in a kernel module? Message-ID: <3F0847F2.8A985E5@mindspring.com> References: <20030704171430.68CE.ZHUYI@jstvu.edu.cn>
next in thread | previous in thread | raw e-mail | index | archive | help
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 <linux/unistd.h> 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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?3F0847F2.8A985E5>