From owner-freebsd-questions Wed Feb 7 05:29:12 1996 Return-Path: owner-questions Received: (from root@localhost) by freefall.freebsd.org (8.7.3/8.7.3) id FAA28430 for questions-outgoing; Wed, 7 Feb 1996 05:29:12 -0800 (PST) Received: from thebard.kci.co.kr (thebard.kci.co.kr [203.250.160.2]) by freefall.freebsd.org (8.7.3/8.7.3) with SMTP id FAA28424 for ; Wed, 7 Feb 1996 05:29:03 -0800 (PST) Received: (from hunsoo@localhost) by thebard.kci.co.kr (8.6.12H1/8.6.9) id WAA11822 for questions@freebsd.org; Wed, 7 Feb 1996 22:28:37 +0900 Date: Wed, 7 Feb 1996 22:28:37 +0900 From: Hong Hunsoo Message-Id: <199602071328.WAA11822@thebard.kci.co.kr> To: questions@freebsd.org Sender: owner-questions@freebsd.org Precedence: bulk Hi! all. Currently I am using FreeBSD 2.0.5-RELEASE pleasantly. I have some questions about kernel source codes. The followings are my stupid questions. 1) Is it possible for me to insert a new system call without resulting any trouble? That is, I want to know whether it is possible to insert a line in /usr/src/sys/sys/syscall.h in my pleasure. #define SYS_my_new_system_call 8 /* * Here I selected 8 by the reason that /usr/src/sys/sys/syscall.h has a * comment that ... 8 is old creat... */ I was always curious about the number, like 8 above, of a system call. I think the only occurance of the number of a system call was through the syscall(2). Is there anybody to explain me the significant role of the number?(in the case of exit, 1; in the case of fork, 2; in the case of read, 3....) 2) If above is possible, what files should I re-edit? I want to know how many times the each system call has been called from the time the system start to operate. I want to program something like this. main() { printf("The open(2) system call has been called %d times.\n", my_new_system_call()); } My new system call, my_new_system_call(2) maybe be something like this. [FreeBSD] [FreeBSD] cat /usr/src/sys/kern/a_file.h /* * this file should be #include'd a lot of times, if I want to know * the occurence of all the system calls. Maybe structure is more appropriate. */ int open_count; /* int exit_count; int fork_count; int read_count; int write_count; ... something like that.. */ [FreeBSD] [FreeBSD] cat /usr/src/sys/kern/b_file.c #include int my_new_system_call(p, dummy, retval) struct proc *p; int dummy; int *retval; { *retval = open_count; return (0); } [FreeBSD] [FreeBSD] cat /usr/src/kern/vfs_syscalls.c ....... int open(p, uap, retval) struct proc *p; register struct open_args *uap; int *retval; { register struct filedesc *fdp = p->p_fd; register struct file *fp; register struct vnode *vp; int flags, cmode; struct file *nfp; int type, indx, error; struct flock lf; struct nameidata nd; extern struct fileops vnops; open_count++; /* !!!!!!!!!! */ error = falloc(p, &nfp, &indx); if (error) return (error); fp = nfp; ........................... } Is the above revision correct? Thank you..