私は 1 年前のようにいくつかの freebsd カーネル モジュールを書きましたが、その時点では問題なく動作していました。しかし、今はコンパイルできません。
私がやろうとしているのは、sysent テーブルを変更して既存のシステム コールをフックすることです。
static int
mkdir_hook (struct proc *p, struct mkdir_args *ua)
{
printf("Making dir: %s\n", ua->path);
return mkdir(p, ua);
}
static int
load (struct module *module, int cmd, void *arg)
{
int error = 0;
switch (cmd) {
case MOD_LOAD :
sysent[SYS_mkdir]=mkdir_hook_sysent;
break;
case MOD_UNLOAD :
sysent[SYS_mkdir].sy_call=(sy_call_t*)mkdir;
break;
default :
error = EINVAL;
break;
}
return error;
}
次のエラーが表示されます
test.c:21: warning: implicit declaration of function 'mkdir'
test.c:21: warning: nested extern declaration of 'mkdir' [-Wnested-externs]
test.c:49: error: 'mkdir' undeclared (first use in this function)
test.c:49: error: (Each undeclared identifier is reported only once
test.c:49: error: for each function it appears in.)
したがって、ライブラリが不足している可能性があると思います。これが私のインクルードです
#include <sys/types.h>
#include <sys/param.h>
#include <sys/proc.h>
#include <sys/module.h>
#include <sys/sysent.h>
#include <sys/kernel.h>
#include <sys/systm.h>
#include <sys/linker.h>
#include <sys/sysproto.h>
#include <sys/sysent.h>
#include <sys/proc.h>
#include <sys/syscall.h>
を読みましたがman 2 mkdir
、まだ手がかりがありません。カーネル モジュール内から別のシステム コールを呼び出すことはサポートされなくなったようですか、それとも追加の構成が必要ですか?
助けてください、どうもありがとう。