作者热门文章
- iOS/Objective-C 元类和类别
- objective-c - -1001 错误,当 NSURLSession 通过 httpproxy 和/etc/hosts
- java - 使用网络类获取 url 地址
- ios - 推送通知中不播放声音
我正在扩展一个 FreeBSD 模块,我需要能够调用我编写的 2 个系统调用函数(使用 KLD)。我知道系统调用函数本身工作正常,因为我有一个单独的测试程序可以调用它们并返回正确的值。
但是,当我尝试将该测试程序的适当部分插入到真实程序中时,我得到了
vnode.c: In function 'getSyscall':
vnode.c:1014: warning: implicit declaration of function 'modfind'
vnode.c:1022: warning: implicit declaration of function 'modstat'
*** Error code 1
我有真实的(工作)测试程序的所有包含,所以我不明白为什么它找不到 modfind 和 modstat 函数。
#include <stdio.h>
#include <sys/syscall.h>
#include <sys/types.h>
#include <sys/module.h>
#include <unistd.h>
#include <errno.h>
#include <sys/param.h>
// Lots of other unrelated functions here
/*
*
* returns a syscall number or -1 for error
*/
int getSyscall
(char *str)
{
struct module_stat stat;
int modid;
int syscallnum;
modid = modfind(str);
if (modid == -1)
{
perror("modfind: ");
return -1;
}
stat.version = sizeof(stat);
if (modstat(modid, &stat) == -1)
{
perror("modstat: ");
return -1;
}
syscallnum = stat.data.intval;
return syscallnum;
}
最佳答案
关于c - C 中的 FreeBSD SysCall -> 函数的隐式声明 'modfind',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8373222/
我正在扩展一个 FreeBSD 模块,我需要能够调用我编写的 2 个系统调用函数(使用 KLD)。我知道系统调用函数本身工作正常,因为我有一个单独的测试程序可以调用它们并返回正确的值。 但是,当我尝试
我是一名优秀的程序员,十分优秀!