Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 7 Feb 1996 22:28:37 +0900
From:      Hong Hunsoo <>
Message-ID:  <>

Next in thread | Raw E-Mail | Index | Archive | Help
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.
	printf("The open(2) system call has been called %d times.\n",

My new system call, my_new_system_call(2) maybe be something like this.

[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] cat /usr/src/sys/kern/b_file.c

#include <a_file.h>
my_new_system_call(p, dummy, retval)
struct proc *p;
int dummy;
int *retval;
	*retval = open_count;
	return (0);

[FreeBSD] cat /usr/src/kern/vfs_syscalls.c
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..

Want to link to this message? Use this URL: <>