svn commit: r253420 - head/share/examples/kld/syscall/test
Gleb Smirnoff
glebius at FreeBSD.org
Wed Jul 17 12:28:50 UTC 2013
Author: glebius
Date: Wed Jul 17 12:28:48 2013
New Revision: 253420
URL: http://svnweb.freebsd.org/changeset/base/253420
Log:
Improve example, so that it doesn't dump core when example module
isn't loaded.
Modified:
head/share/examples/kld/syscall/test/call.c
Modified: head/share/examples/kld/syscall/test/call.c
==============================================================================
--- head/share/examples/kld/syscall/test/call.c Wed Jul 17 11:51:24 2013 (r253419)
+++ head/share/examples/kld/syscall/test/call.c Wed Jul 17 12:28:48 2013 (r253420)
@@ -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);
}
More information about the svn-src-head
mailing list