Improve example, so that it doesn't dump core when example module
isn't loaded.
This commit is contained in:
parent
b13ce70710
commit
9fd7a1b3dd
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=253420
@ -30,6 +30,7 @@
|
||||
#include <sys/module.h>
|
||||
#include <sys/syscall.h>
|
||||
|
||||
#include <err.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
@ -37,11 +38,14 @@
|
||||
int
|
||||
main(int argc __unused, char **argv __unused)
|
||||
{
|
||||
int syscall_num;
|
||||
int modid, syscall_num;
|
||||
struct module_stat stat;
|
||||
|
||||
stat.version = sizeof(stat);
|
||||
modstat(modfind("sys/syscall"), &stat);
|
||||
if ((modid = modfind("sys/syscall")) == -1)
|
||||
err(1, "modfind");
|
||||
if (modstat(modid, &stat) != 0)
|
||||
err(1, "mostat");
|
||||
syscall_num = stat.data.intval;
|
||||
return syscall (syscall_num);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user