I’m extending a FreeBSD module, and I need to be able to call 2 system call functions that I wrote (using KLD). I know that the system call functions themselves are working fine, since I have a separate test program for them that calls them and returns the correct values just fine.
However, when I tried plugging in the appropriate parts of that test program into the real program, I get
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
I have all of the includes of the (working) test program in the real thing, so I don’t understand why it can’t find the modfind and modstat functions.
#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;
}
Be sure to
(after sys/param.h). modfind(2) manual page says so.
(Why is this question tagged with “linux” beats me…)