From owner-freebsd-questions Tue Oct 31 10:53:25 2000 Delivered-To: freebsd-questions@freebsd.org Received: from lennier.cc.vt.edu (lennier.cc.vt.edu [198.82.161.193]) by hub.freebsd.org (Postfix) with ESMTP id 969B437B479 for ; Tue, 31 Oct 2000 10:53:21 -0800 (PST) Received: from mail.vt.edu (gkar.cc.vt.edu [198.82.161.190]) by lennier.cc.vt.edu (8.11.0/8.11.0) with ESMTP id e9VIrDt440856 for ; Tue, 31 Oct 2000 13:53:13 -0500 (EST) Received: from flaw.vt.edu ([198.82.82.148]) by gkar.cc.vt.edu (Sun Internet Mail Server sims.3.5.2000.03.23.18.03.p10) with ESMTP id <0G3B00KPX5SNCG@gkar.cc.vt.edu> for freebsd-questions@freebsd.org; Tue, 31 Oct 2000 13:53:11 -0500 (EST) Date: Tue, 31 Oct 2000 14:08:38 -0500 From: Raymond Law Subject: Re: Add a system call In-reply-to: <39D10614.9ECD8635@yahoo.com> X-Sender: flaw@mail.vt.edu To: freebsd-questions@freebsd.org Message-id: <4.3.0.20001031140540.00d90de0@mail.vt.edu> MIME-version: 1.0 X-Mailer: QUALCOMM Windows Eudora Version 4.3 Content-type: text/plain; format=flowed; charset=us-ascii Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG Can someone list the steps on how to add a system call in FreeBSD 4 please? Thanks. Ray, At 03:24 PM 9/26/00 -0500, you wrote: >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 To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message