Date: Tue, 26 Sep 2000 15:24:52 -0500 From: "Yonny Cardenas B." <ycardena@yahoo.com> To: questions@freebsd.org Subject: Add a system call Message-ID: <39D10614.9ECD8635@yahoo.com>
next in thread | raw e-mail | index | archive | help
Hi, I have been trying to insert a new system call (very simple), I have used the steps in the bottom without problems, but I don't understand the behavior of the program: :::::::::::::: mysyscall.c :::::::::::::: int mysyscall( int *n ) { printf("In the kernel!\n"); *n = ( *n + 1000); return 0; } :::::::::::::: myprog.c :::::::::::::: int mysyscall (int * ); int main (void){ int x = 500; mysyscall(&x); printf("x= %i\n",x); } The kernel syscall apparently run but it doesn't modify the variable. $cc -o miprog miprog.c $ ./miprog x= 500 In the kernel! <--- is showed in the console. If I compile with the function (syscall), it works apparently correctly. $cc -o miprog miprog.c mysyscall.c $ ./miprog In the kernel! x= 1500 Thanks for your help. Yonny Cardenas B. -------------------------------------------------------------------------- In Mon, 17 May 1999 Zhihui Zhang <zzhang@cs.binghamton.edu> wrote: I have used the following steps to add system calls to FreeBSD 3.1 several times. Suppose you want to add a system call: int mysys(int a, int b, int c). You can do the following steps: (1) # cd /usr/src/sys/kern (2) # vi syscalls.master to add your system call into the file: 172 STD BSD { int mysys(int a, int b, int c); } (3) # sh makesyscalls.sh syscalls.master This creates three files: syscall.h, syscall-hide.h, and sysproto.h. (4) # vi mysys.c Edit your file to implement your mysys(). You can follow the file kern/vfs_syscalls.c. (6) # vi /sys/conf/files to add you file mysys.c into it. (7) Make a new kernel and install it (see FreeBSD handbook) The following steps update the libc library: (8) copy syscall.h, syscall-hide.h, and sysproto.h to /usr/include/sys (9) # cd /usr/src/lib/libc (10) # make obj (11) # make depend (12) # make all (13) # make insall Now you can reboot your machine and write a program that uses your mysys(). -------------------------------------------------------------------------- +-------------------------------------------------------------------------+ | YONNY CARDENAS B. | Tels: +57 1 3451543, 3451554 | | | 3451565, 2176251 ext. 16 | | Opus Ingenieria | Fax : +57 1 3458343 | | Calle 61 # 5-44 Piso 3 | E-mail: y-carden@uniandes.edu.co | | Santafe de Bogota D.C.,Colombia | ycardena@yahoo.com | +-------------------------------------------------------------------------+ To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?39D10614.9ECD8635>