mirror of
https://git.FreeBSD.org/src.git
synced 2024-12-03 09:00:21 +00:00
Add option to ignore error codes if the module specified is already loaded.
MFC after: 1 week
This commit is contained in:
parent
61ad92ef03
commit
56d3acc16c
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=233109
@ -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
|
||||
|
@ -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],
|
||||
|
Loading…
Reference in New Issue
Block a user