Skip to content

Instantly share code, notes, and snippets.

@mogigoma
Created May 3, 2011 02:25
Show Gist options
  • Save mogigoma/952710 to your computer and use it in GitHub Desktop.
Save mogigoma/952710 to your computer and use it in GitHub Desktop.
KMOD= badgermonkey
SRCS= syscall.c
.include <bsd.kmod.mk>
#include <sys/param.h>
#include <sys/proc.h>
#include <sys/module.h>
#include <sys/sysproto.h>
#include <sys/sysent.h>
#include <sys/kernel.h>
#include <sys/systm.h>
static int
badgers(struct thread *td, void *arg)
{
printf("Badgers\n");
return (0);
}
static int
monkeys(struct thread *td, void *arg)
{
printf("Monkeys\n");
return (0);
}
static struct sysent badgers_sysent = {
0, /* sy_narg */
badgers /* sy_call */
};
static struct sysent monkeys_sysent = {
0, /* sy_narg */
monkeys /* sy_call */
};
static int badgers_offset = NO_SYSCALL;
static int monkeys_offset = NO_SYSCALL;
static int
badgers_load(struct module *module, int cmd, void *arg)
{
int error = 0;
switch (cmd) {
case MOD_LOAD :
printf("badgers syscall loaded at %d\n", badgers_offset);
break;
case MOD_UNLOAD :
printf("badgers syscall unloaded from %d\n", badgers_offset);
break;
default :
error = EOPNOTSUPP;
break;
}
return (error);
}
static int
monkeys_load(struct module *module, int cmd, void *arg)
{
int error = 0;
switch (cmd) {
case MOD_LOAD :
printf("monkeys syscall loaded at %d\n", monkeys_offset);
break;
case MOD_UNLOAD :
printf("monkeys syscall unloaded from %d\n", monkeys_offset);
break;
default :
error = EOPNOTSUPP;
break;
}
return (error);
}
SYSCALL_MODULE(syscall_badgers, &badgers_offset, &badgers_sysent, badgers_load, NULL);
SYSCALL_MODULE(syscall_monkeys, &monkeys_offset, &monkeys_sysent, monkeys_load, NULL);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment