Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 7 Feb 1996 13:57:21 -0700 (MST)
From:      Terry Lambert <terry@lambert.org>
To:        hunsoo@thebard.kci.co.kr (Hong Hunsoo)
Cc:        questions@freebsd.org
Subject:   Re: your mail
Message-ID:  <199602072057.NAA06368@phaeton.artisoft.com>
In-Reply-To: <199602071328.WAA11822@thebard.kci.co.kr> from "Hong Hunsoo" at Feb 7, 96 10:28:37 pm

next in thread | previous in thread | raw e-mail | index | archive | help
> 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....) 


The system call "number" is an index into the sysent[] array.

The correct way to deal with this is to modify /sys/kern/syscalls.master
and config yourself a new kernel.  That file is post-processed by the
config process to build init_sysent.c, syscalls.c and syscall.h.

It is incorrect to modify syscall.h, since it is a machine-generated
file.


Probably what you want to do instead is to use an LKM to add a vendor
private system call.  You can then query the /dev/lkm via ioctl to
find your system call slot number, and then use the syscall(2) system
call with that number and the normal call arguments to make the call
to your new call from your vendor-suppied application.

Actual modifications to the default system call list in syscalls.master
are jealously guarded: they have to be.  What you are suggesting is a
permananet ABI change for what is, effectively, your personal call that
perhaps no one else will ever use.


[ ... simple call count statistics ... ]

If this is for a profiling facility rather than for a ongoing
hysterisis/AI mechanism for auto-tuning system resources, then you
probably want to simply enable kernel profiling.  Given a sufficiently
large bucket size, it will cover all your system calls, as well as give
you useful statistics, like "average time in call" and so on.


					Terry Lambert
					terry@lambert.org
---
Any opinions in this posting are my own and not those of my present
or previous employers.



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199602072057.NAA06368>