summaryrefslogtreecommitdiffstats
path: root/sbin/kldload
diff options
context:
space:
mode:
authorhselasky <hselasky@FreeBSD.org>2012-03-18 09:45:43 +0000
committerhselasky <hselasky@FreeBSD.org>2012-03-18 09:45:43 +0000
commit8be9a344bda9803ea7c8ffc87c0310fad97adda9 (patch)
tree86560ef77dbc7f0cf7b4eac02eae9029261c129a /sbin/kldload
parentc2c7ad8aeb41d28c7f9ffb14150e892d723adcea (diff)
downloadFreeBSD-src-8be9a344bda9803ea7c8ffc87c0310fad97adda9.zip
FreeBSD-src-8be9a344bda9803ea7c8ffc87c0310fad97adda9.tar.gz
Add option to ignore error codes if the module specified is already loaded.
MFC after: 1 week
Diffstat (limited to 'sbin/kldload')
-rw-r--r--sbin/kldload/kldload.86
-rw-r--r--sbin/kldload/kldload.c20
2 files changed, 20 insertions, 6 deletions
diff --git a/sbin/kldload/kldload.8 b/sbin/kldload/kldload.8
index 91b0c86..1adbe52 100644
--- a/sbin/kldload/kldload.8
+++ b/sbin/kldload/kldload.8
@@ -25,7 +25,7 @@
.\"
.\" $FreeBSD$
.\"
-.Dd June 5, 2009
+.Dd March 18, 2012
.Dt KLDLOAD 8
.Os
.Sh NAME
@@ -33,7 +33,7 @@
.Nd load a file into the kernel
.Sh SYNOPSIS
.Nm
-.Op Fl qv
+.Op Fl nqv
.Ar
.Sh DESCRIPTION
The
@@ -62,6 +62,8 @@ in the current directory.
.Pp
The following options are available:
.Bl -tag -width indent
+.It Fl n
+Don't try to load module if already loaded.
.It Fl v
Be more verbose.
.It Fl q
diff --git a/sbin/kldload/kldload.c b/sbin/kldload/kldload.c
index 4d8d20a..84589eb 100644
--- a/sbin/kldload/kldload.c
+++ b/sbin/kldload/kldload.c
@@ -37,6 +37,7 @@ __FBSDID("$FreeBSD$");
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
+#include <errno.h>
#define PATHCTL "kern.module_path"
@@ -129,7 +130,7 @@ path_check(const char *kldname, int quiet)
static void
usage(void)
{
- fprintf(stderr, "usage: kldload [-qv] file ...\n");
+ fprintf(stderr, "usage: kldload [-nqv] file ...\n");
exit(1);
}
@@ -141,12 +142,14 @@ main(int argc, char** argv)
int fileid;
int verbose;
int quiet;
+ int check_loaded;
errors = 0;
verbose = 0;
quiet = 0;
+ check_loaded = 0;
- while ((c = getopt(argc, argv, "qv")) != -1) {
+ while ((c = getopt(argc, argv, "nqv")) != -1) {
switch (c) {
case 'q':
quiet = 1;
@@ -156,6 +159,9 @@ main(int argc, char** argv)
verbose = 1;
quiet = 0;
break;
+ case 'n':
+ check_loaded = 1;
+ break;
default:
usage();
}
@@ -170,8 +176,14 @@ main(int argc, char** argv)
if (path_check(argv[0], quiet) == 0) {
fileid = kldload(argv[0]);
if (fileid < 0) {
- warn("can't load %s", argv[0]);
- errors++;
+ if (check_loaded != 0 && errno == EEXIST) {
+ if (verbose)
+ printf("%s is already "
+ "loaded\n", argv[0]);
+ } else {
+ warn("can't load %s", argv[0]);
+ errors++;
+ }
} else {
if (verbose)
printf("Loaded %s, id=%d\n", argv[0],
OpenPOWER on IntegriCloud