在 FreeBSD-11.0-RELEASE-amd64 添加一个新的系统调用
Add a new system call at FreeBSD-11.0-RELEASE-amd64
我是 FreeBSD 的初学者。我在 VM 上安装了 FreeBSD-11.0-RELEASE-amd64。
我想添加第一个新的系统调用。这是上周的 my post。
现在我想构建内核。我看到 handbook。
但是在命令make buildkernel
中,提示错误!
mykern.c
#include <sys/sysproto.h>
#include <sys/param.h>
#include <sys/types.h>
#include <sys/systm.h>
#include <sys/module.h>
#include <sys/kernel.h>
#include <sys/proc.h>
#include <sys/sysent.h>
#ifndef _SYS_SYSPROTO_H_
struct myargs {
unsigned int k0;
unsigned int k1;
};
#endif
int func (struct thread *td, void *args)
{
struct myargs *uap;
uap = (struct myargs *)args;
printf("Hello");
return (0);
}
第一个错误是
/usr/src/sys/kern/mykern.c:12:5: error:no previous prototype for function 'func' [-Werror, -Wmissing-prototypes]
int func(struct thread *p, struct myargs *uap)
然后在 mykern.c 中我将函数编辑为内联:
inline int func (struct thread *td, void *args)
现在出现新错误:
init sysent.o:(.data 0xg720): undefined refrence to 'sys_func'
当我输入命令时
make init_sysent.c
'init_sysent.c' is up to date
系统调用的名称应以 sys_
开头。
查看 /usr/src/sys/kern
.
中的其他文件
我是 FreeBSD 的初学者。我在 VM 上安装了 FreeBSD-11.0-RELEASE-amd64。
我想添加第一个新的系统调用。这是上周的 my post。
现在我想构建内核。我看到 handbook。
但是在命令make buildkernel
中,提示错误!
mykern.c
#include <sys/sysproto.h>
#include <sys/param.h>
#include <sys/types.h>
#include <sys/systm.h>
#include <sys/module.h>
#include <sys/kernel.h>
#include <sys/proc.h>
#include <sys/sysent.h>
#ifndef _SYS_SYSPROTO_H_
struct myargs {
unsigned int k0;
unsigned int k1;
};
#endif
int func (struct thread *td, void *args)
{
struct myargs *uap;
uap = (struct myargs *)args;
printf("Hello");
return (0);
}
第一个错误是
/usr/src/sys/kern/mykern.c:12:5: error:no previous prototype for function 'func' [-Werror, -Wmissing-prototypes]
int func(struct thread *p, struct myargs *uap)
然后在 mykern.c 中我将函数编辑为内联:
inline int func (struct thread *td, void *args)
现在出现新错误:
init sysent.o:(.data 0xg720): undefined refrence to 'sys_func'
当我输入命令时
make init_sysent.c
'init_sysent.c' is up to date
系统调用的名称应以 sys_
开头。
查看 /usr/src/sys/kern
.