b8b1
![]() |
|
|
|
|
|||||||
| FreeBSD Development Kernel development, writing drivers, coding, and questions regarding FreeBSD internals. |
![]() |
|
|
Thread Tools | Display Modes |
|
#1
|
|||
|
|||
|
Hi,
I am a student studying FreeBSD Kernel. I want to ask how to add a system call to FreeBSD. Is there any detailed tutorial to follow? Thanks indeed! Juson Last edited by DutchDaemon; December 24th, 2010 at 17:32. |
|
#2
|
||||
|
||||
|
__________________
FreeBSD Forums: Information for New Members | FreeBSD Forums Rules FreeBSD Resources: The FreeBSD Handbook | Manuals | FAQ | Wiki Before you post: How to ask questions the smart way If you must know .. So, what does an Adminstrator/Moderator do? ---> Do not PM me with FreeBSD questions. I do not work here. <--- |
|
#3
|
|||
|
|||
|
The easiest (and AFAIK, preferred) way is to code a loadable kernel module which contains syscall code.
Search the google and find examples of skeletal, "hello world" style kernel module code, and Makefile example you'll use to compile it, kld skeleton is about 15 lines of code and Makefile is like two-three. Simple to begin with. After you have a skeleton, make a variable definition that will hold your syscall number (don't use one that's already occupied, check /usr/src/sys/kern/syscalls.master), for instance Code:
static int my_syscall_slot = 210; Code:
static int syscall_code(int something, char something_else, void *syscall_args)
{
...
}
Code:
static struct sysent my_syscall_sysent = { 2, syscall_code };
Code:
SYSCALL_MODULE(my_syscall, &my_syscall_slot, &my_syscall_sysent, put_the_name_of_the_module_entry_function_here, NULL); Hope it helps, this is not tested and from the head. Last time i did a grounds up KLD was in days of FreeBSD 5.4, i might have missed something. |
|
#4
|
|||
|
|||
|
You may want to look in /usr/share/examples/kld/syscall/ for example code.
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| curiosity question, source port add or package add? | pgmrdlm | Installation and Maintenance of FreeBSD Ports or Packages | 2 | May 29th, 2010 16:45 |
| dhclient and/or system can't add unroutable gateway | daikichi | Networking | 1 | May 4th, 2010 07:42 |
| [Solved] system call explanation in the book | jronald | FreeBSD Development | 2 | March 21st, 2010 03:53 |
| [Solved] how make a system call module? | MIDOSE | Userland Programming & Scripting | 1 | March 12th, 2010 10:06 |
| SDL_Init() "Bad system call (core dumped)" | Eponasoft | Userland Programming & Scripting | 0 | August 8th, 2009 12:04 |