modfind() returns -1

Mark Johnston markjdb at gmail.com
Tue Jan 20 03:38:22 UTC 2015


On Tue, Jan 20, 2015 at 05:27:16AM +0200, Ivan "Rambius" Ivanov wrote:
> Hello,
> 
> On 1/20/15, Mark Johnston <markjdb at gmail.com> wrote:
> > On Mon, Jan 19, 2015 at 06:17:10AM +0200, Ivan "Rambius" Ivanov wrote:
> >> Hello,
> >>
> >> I am trying to implement a simple system call module, but after I
> >> install it and try to find its offset with modfind, I somehow get -1.
> >>
> >> [...]
> >> Here is the code that tries to invoke that system call:
> >>
> >> $ cat interface.c
> >> #include <stdio.h>
> >> #include <stdlib.h>
> >> #include <unistd.h>
> >> #include <sys/syscall.h>
> >> #include <sys/types.h>
> >> #include <sys/module.h>
> >>
> >> int main(int argc, char *argv[]) {
> >>   int syscall_num;
> >>   struct module_stat stat;
> >>   int mod_id;
> >>
> >>   stat.version = sizeof(stat);
> >>   mod_id = modfind("sc_example_no_args");
> >
> > Does it work if you instead look up "sys/sc_example_no_args"?
> >
> 
> Yes, it works with
> 
>   mod_id = modfind("sys/sc_example_no_args");
> 
> Thank you very much for your help. Can you explain though why prefixed
> with sys/ ?

I just looked at the SYSCALL_MODULE(9) definition - it prepends "sys/"
to the module name. This doesn't appear to be documented though, which
is a bug.


More information about the freebsd-questions mailing list