Proper way to add vendor-specific syscalls? [Correct answer] :-)
Julian Elischer
julian at freebsd.org
Tue Oct 4 02:29:11 UTC 2016
On 3/10/2016 10:48 AM, Alan Somers wrote:
> What's the proper way to add a vendor-specific syscall? The comments
> in kern/syscalls.master suggest that they should be put in the range
> from 151-180, but most of that range is actually occupied. Only five
> nosys slots are available. If I add syscalls to the end of the list,
> they'll likely collide with future standard syscalls. Should I just
> added ~100 nosys syscalls to the end of the list, and put my custom
> syscalls afterwards? Is there any penalty to lengthening the list?
>
> -Alan
> _______________________________________________
> freebsd-hackers at freebsd.org mailing list
> https://lists.freebsd.org/mailman/listinfo/freebsd-hackers
> To unsubscribe, send any mail to "freebsd-hackers-unsubscribe at freebsd.org"
the correct way is to allow them to dynamically allocate a syscall,
(assuming they are in a module)
see man modstat(2) the syscall number is in the modspecfic data.
also see the SYSCALL_MODULE(2) man page
read /usr/share/examples/kld/syscall
and
read both the module and the test program.
key parts are:
(in the module:
the module needs something like:
static int ddfenabled_offset = NO_SYSCALL;
static struct sysent ddfenabled_sysent = {
AS(ddfenabled_args),
(sy_call_t *)ddfenabled,
AUE_NULL,
NULL,
0,
0,
0
};
SYSCALL_MODULE(ddfenabled, &ddfenabled_offset, &ddfenabled_sysent,
ddload, NULL);
the user code needs something like:
static int ddfenabled_sysno = 0;
/*
* Module init
*/
int rlu_init(void)
{
struct module_stat mstat;
int modid;
/* Find some dedup-related syscalls */
if (ddfenabled_sysno == 0) {
mstat.version = sizeof(mstat);
if ((modid = modfind("ddfenabled")) == -1 || modstat(modid,
&mstat) == -1) {
return -1;
}
ddfenabled_sysno = mstat.data.intval;
}
return 0;
}
More information about the freebsd-hackers
mailing list