下面是我用我的示例系統調用setkey取得兩個無符號整數的方法。 我說我的系統調用/kern/syscalls.master
546 AUE_NULL STD { int setkey(unsigned int k0, unsigned int k1);}
然後我做了
cd /usr/src
sudo make -C /sys/kern/ sysent
接下來年底,我加入了文件/ SYS/conf目錄/文件
kern/sys_setkey.c standard
我的sys_setkey.c如下
#include <sys/sysproto.h>
#include <sys/proc.h>
//required for printf
#include <sys/types.h>
#include <sys/systm.h>
#ifndef _SYS_SYSPROTO_H_
struct setkey_args {
unsigned int k0;
unsigned int k1;
};
#endif
/* ARGSUSED */
int sys_setkey(struct thread *td, struct setkey_args *args)
{
printf("Hello, Kernel!\n");
return 0;
}
另外,我加入系統調用/kern/capabilities.conf
##
## Allow associating SHA1 key with user
##
setkey
最後,雖然在/ usr/SRC/I運行的命令
sudo make -j8 kernel
sudo reboot
這是運行的程序系統調用
#include <sys/syscall.h>
#include <unistd.h>
#include <stdio.h>
int main(){
//syscall takes syscall.master offset,and the system call arguments
printf("out = %d\n",syscall(546,1,1));
return 0;
}
我的代碼是否正確? – user3228884
你能編輯你的問題,包括代碼和錯誤作爲純文本,而不是包括截圖? – ajshort
@ajshort是的,我改變它:) – user3228884