在FreeBSD-11.0-RELEASE-amd64处添加一个新的系统调用 [英] Add a new system call at FreeBSD-11.0-RELEASE-amd64

查看:99
本文介绍了在FreeBSD-11.0-RELEASE-amd64处添加一个新的系统调用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是FreeBSD的初学者.我在VM上安装了FreeBSD-11.0-RELEASE-amd64. 我要添加第一个新的系统调用.这是我的帖子在上个星期. 现在我要构建内核.我看到了手册. 但是在命令 make buildkernel 中,指示错误!

I am a beginner in FreeBSD. I installed FreeBSD-11.0-RELEASE-amd64 on VM. I want to add first new system call. And this is my post in last week. Now I want to build kernel. I see handbook. But In command make buildkernel, indicates errors!

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中,我将函数编辑为内联:

And in mykern.c I edit function to inline:

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中的其他文件.

System calls should have a name starting with sys_. Look at the other files in /usr/src/sys/kern.

这篇关于在FreeBSD-11.0-RELEASE-amd64处添加一个新的系统调用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆