From owner-freebsd-questions Tue Sep 26 13:21:58 2000 Delivered-To: freebsd-questions@freebsd.org Received: from trauco.colomsat.net.co (trauco.colomsat.net.co [200.13.195.2]) by hub.freebsd.org (Postfix) with ESMTP id C7BEB37B424 for ; Tue, 26 Sep 2000 13:21:45 -0700 (PDT) Received: from yahoo.com (200.13.215.172) by trauco.colomsat.net.co (NPlex 4.0.068) id 39CBBB7000015453 for questions@freebsd.org; Tue, 26 Sep 2000 15:16:24 -0500 Message-ID: <39D10614.9ECD8635@yahoo.com> Date: Tue, 26 Sep 2000 15:24:52 -0500 From: "Yonny Cardenas B." Organization: Ingenieria Integral Ltda. X-Mailer: Mozilla 4.61 [en] (Win98; I) X-Accept-Language: en MIME-Version: 1.0 To: questions@freebsd.org Subject: Add a system call Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG 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 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