【发布时间】:2011-12-18 12:04:17
【问题描述】:
我想在 FreeBSD 8.2 中使用 KLD 添加一个系统调用,它有一些参数(这里有 1 个参数) 我已经完成了以下操作(实际上我已经更改了 /usr/share/examples/kld/syscalls/module/syscall.c 中的 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的东西,所以像这样的警告被视为错误。
标签: kernel freebsd system-calls