Subject: Re: how to add system call with variable arg list
To: None <tech-kern@netbsd.org>
From: der Mouse <mouse@Rodents.Montreal.QC.CA>
List: tech-kern
Date: 08/28/2001 11:56:30
>> I want to add system call with variable arg list.
>> (e.g int mysyscall( int a, int b, ...) ). How do I access the
>> arguments in the function?
> If you want to do this kind of thing, you'll have to pass a pointer
> to the arguments, so you can copyin them yourself. You might be able
> to hide this behind a veneer in libc if it's possible to work out the
> number of arguments without being the kernel.
An example of this that may be instructive is execl(), which is a libc
shim that passes a pointer to a vector of arguments to the real syscall
(which in the case of execl() is one that also exists as a call in its
own right, called execve()).
It also occurs to me that it may be possible to do a varargs syscall
with MD callbacks to fetch the arguments. Indeed, as a quick hack you
could even put the implementation in MD code, though unless the syscall
itself is MD, this obviously is suitable only for early development
hackery, not for anything production-ready.
/~\ The ASCII der Mouse
\ / Ribbon Campaign
X Against HTML mouse@rodents.montreal.qc.ca
/ \ Email! 7D C8 61 52 5D E7 2D 39 4E F1 31 3E E8 B3 27 4B