summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormikeb <mikeb@openbsd.org>2007-11-25 19:21:37 +0000
committermikeb <mikeb@openbsd.org>2007-11-25 19:21:37 +0000
commite3e5c8d46c69daacfbcd091061f7430563db5550 (patch)
tree0a0acc25fce3185cae08464227eada562c06c540
parentIF_Gbps(2.5) is wrong. (diff)
downloadwireguard-openbsd-e3e5c8d46c69daacfbcd091061f7430563db5550.tar.xz
wireguard-openbsd-e3e5c8d46c69daacfbcd091061f7430563db5550.zip
Make modload use /dev/ksyms as a kernel file by default.
Idea from form@, suggestions from miod@. ok miod
-rw-r--r--sbin/modload/modload.86
-rw-r--r--sbin/modload/modload.c39
2 files changed, 18 insertions, 27 deletions
diff --git a/sbin/modload/modload.8 b/sbin/modload/modload.8
index 92eb61aeddd..7deaf9fd7c3 100644
--- a/sbin/modload/modload.8
+++ b/sbin/modload/modload.8
@@ -1,4 +1,4 @@
-.\" $OpenBSD: modload.8,v 1.23 2007/05/31 19:19:45 jmc Exp $
+.\" $OpenBSD: modload.8,v 1.24 2007/11/25 19:21:37 mikeb Exp $
.\" $NetBSD: modload.8,v 1.17 2001/11/16 11:57:16 wiz Exp $
.\"
.\" Copyright (c) 1993 Christopher G. Demetriou
@@ -33,7 +33,7 @@
.\"
.\" <<Id: LICENSE,v 1.2 2000/06/14 15:57:33 cgd Exp>>
.\"
-.Dd $Mdocdate: May 31 2007 $
+.Dd $Mdocdate: November 25 2007 $
.Dt MODLOAD 8
.Os
.Sh NAME
@@ -105,7 +105,7 @@ Print comments about the loading process.
.El
.Sh FILES
.Bl -tag -width /usr/include/sys/lkm.h -compact
-.It Pa /bsd
+.It Pa /dev/ksyms
default file passed to the linker to resolve external
references in the module
.It Pa /usr/include/sys/lkm.h
diff --git a/sbin/modload/modload.c b/sbin/modload/modload.c
index f081e7418a2..5461a6fa861 100644
--- a/sbin/modload/modload.c
+++ b/sbin/modload/modload.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: modload.c,v 1.42 2007/02/20 14:01:15 jmc Exp $ */
+/* $OpenBSD: modload.c,v 1.43 2007/11/25 19:21:37 mikeb Exp $ */
/* $NetBSD: modload.c,v 1.30 2001/11/08 15:33:15 christos Exp $ */
/*
@@ -68,6 +68,8 @@ char *out = NULL;
int symtab = 1;
int Sflag;
+extern char *__progname;
+
static void cleanup(void);
/* prelink the module */
@@ -76,7 +78,7 @@ prelink(const char *kernel, const char *entry, const char *outfile,
const void *address, const char *object)
{
char cmdbuf[1024];
- int error = 0;
+ int fd;
linkcmd(cmdbuf, sizeof(cmdbuf),
kernel, entry, outfile, address, object);
@@ -84,32 +86,21 @@ prelink(const char *kernel, const char *entry, const char *outfile,
if (debug)
fprintf(stderr, "%s\n", cmdbuf);
- switch (system(cmdbuf)) {
- case 0: /* SUCCESS! */
- break;
- case 1: /* uninformitive error */
- /*
- * Someone needs to fix the return values from the NetBSD
- * ld program -- it's totally uninformative.
- *
- * No such file (4 on SunOS)
- * Can't write output (2 on SunOS)
- * Undefined symbol (1 on SunOS)
- * etc.
- */
- case 127: /* can't load shell */
- case 32512:
- default:
- error = 1;
- break;
- }
- return error;
+ if ((fd = open(kernel, O_RDONLY)) == -1)
+ errx(1, "can't open %s\n%s: please specify alternative kernel "
+ "executable with -A option", kernel, __progname);
+ else
+ close(fd);
+
+ if (system(cmdbuf) != 0)
+ return (1);
+
+ return (0);
}
static void
usage(void)
{
- extern char *__progname;
fprintf(stderr, "usage: %s [-dnSsv] [-A kernel] [-e entry]\n",
__progname);
@@ -235,7 +226,7 @@ int
main(int argc, char *argv[])
{
int strtablen, c, noready = 0, old = 0;
- const char *kname = _PATH_UNIX;
+ const char *kname = _PATH_KSYMS;
char *entry = DFLT_ENTRY;
char *post = NULL;
char *modobj;