Я хочу добавить системный вызов с помощью KLD в FreeBSD 8.2, который имеет некоторые аргументы (здесь 1 аргумент). Я сделал следующее (фактически я изменил файл syscall.c в /usr/share/examples/kld/syscalls/ модуль/syscall.c)
#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>
struct hellomet_args{
int a;
};
static int
hellomet(struct thread *td, struct hellomet_args *arg)
{
int a = arg->a;
printf("hello secondish kernel %d \n",a);
return (0);
}
static struct sysent hellomet_sysent = {
1,
hellomet
};
static int offset = NO_SYSCALL;
static int
load(struct module *module, int cmd, void *arg)
{
int error = 0;
switch (cmd) {
case MOD_LOAD :
printf("syscall loaded at %d\n", offset);
break;
case MOD_UNLOAD :
printf("syscall unloaded from %d\n", offset);
break;
default :
error = EOPNOTSUPP;
break;
}
return (error);
}
SYSCALL_MODULE(hellomet, &offset, &hellomet_sysent, load, NULL);
Когда я создаю этот файл, используя предоставленный Makefile в каталоге модуля, я получаю:
cc1: warnings being treated as errors syscall.c:56: warning: initialization from incompatible pointer type
*** Error code 1
Stop in /usr/share/examples/kld/syscall/module.
*** Error code 1
В чем проблема с этим кодом?
syscall.c:56
? FreeBSD компилирует файлы с-Werror
, поэтому такие предупреждения рассматриваются как ошибки. - person cnicutar   schedule 31.10.2011