[Midnightbsd-cvs] src [11129] sync with freebsd
laffer1 at midnightbsd.org
laffer1 at midnightbsd.org
Tue Jun 19 16:11:39 EDT 2018
Revision: 11129
http://svnweb.midnightbsd.org/src/?rev=11129
Author: laffer1
Date: 2018-06-19 16:11:38 -0400 (Tue, 19 Jun 2018)
Log Message:
-----------
sync with freebsd
Modified Paths:
--------------
trunk/sbin/kldload/kldload.8
trunk/sbin/kldload/kldload.c
Property Changed:
----------------
trunk/sbin/kldload/kldload.8
Modified: trunk/sbin/kldload/kldload.8
===================================================================
--- trunk/sbin/kldload/kldload.8 2018-06-19 20:11:03 UTC (rev 11128)
+++ trunk/sbin/kldload/kldload.8 2018-06-19 20:11:38 UTC (rev 11129)
@@ -1,3 +1,4 @@
+.\" $MidnightBSD$
.\"
.\" Copyright (c) 1997 Doug Rabson
.\" All rights reserved.
@@ -23,7 +24,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $MidnightBSD$
+.\" $FreeBSD: stable/10/sbin/kldload/kldload.8 307403 2016-10-16 22:02:50Z sevan $
.\"
.Dd March 18, 2012
.Dt KLDLOAD 8
@@ -63,7 +64,7 @@
The following options are available:
.Bl -tag -width indent
.It Fl n
-Don't try to load module if already loaded.
+Do not try to load module if already loaded.
.It Fl v
Be more verbose.
.It Fl q
@@ -70,7 +71,6 @@
Silence any extraneous warnings.
.El
.Sh NOTES
-.Pp
The kernel security level settings may prevent a module from being
loaded or unloaded by giving
.Em "Operation not permitted" .
@@ -127,4 +127,4 @@
.Nm lkm
interface.
.Sh AUTHORS
-.An Doug Rabson Aq dfr at FreeBSD.org
+.An Doug Rabson Aq Mt dfr at FreeBSD.org
Property changes on: trunk/sbin/kldload/kldload.8
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Modified: trunk/sbin/kldload/kldload.c
===================================================================
--- trunk/sbin/kldload/kldload.c 2018-06-19 20:11:03 UTC (rev 11128)
+++ trunk/sbin/kldload/kldload.c 2018-06-19 20:11:38 UTC (rev 11129)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*-
* Copyright (c) 1997 Doug Rabson
* All rights reserved.
@@ -25,7 +26,7 @@
*/
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/sbin/kldload/kldload.c 313682 2017-02-12 09:27:34Z ngie $");
#include <sys/types.h>
#include <sys/param.h>
@@ -41,9 +42,6 @@
#define PATHCTL "kern.module_path"
-static int path_check(const char *, int);
-static void usage(void);
-
/*
* Check to see if the requested module is specified as a filename with no
* path. If so and if a file by the same name exists in the module path,
@@ -52,23 +50,21 @@
static int
path_check(const char *kldname, int quiet)
{
- int mib[5], found;
- size_t miblen, pathlen;
- char kldpath[MAXPATHLEN];
char *path, *tmppath, *element;
struct stat sb;
+ int mib[5];
+ char kldpath[MAXPATHLEN];
+ size_t miblen, pathlen;
dev_t dev;
ino_t ino;
+ int found;
- if (strchr(kldname, '/') != NULL) {
+ if (strchr(kldname, '/') != NULL)
return (0);
- }
- if (strstr(kldname, ".ko") == NULL) {
+ if (strstr(kldname, ".ko") == NULL)
return (0);
- }
- if (stat(kldname, &sb) != 0) {
+ if (stat(kldname, &sb) != 0)
return (0);
- }
found = 0;
dev = sb.st_dev;
@@ -75,20 +71,16 @@
ino = sb.st_ino;
miblen = sizeof(mib) / sizeof(mib[0]);
- if (sysctlnametomib(PATHCTL, mib, &miblen) != 0) {
+ if (sysctlnametomib(PATHCTL, mib, &miblen) != 0)
err(1, "sysctlnametomib(%s)", PATHCTL);
- }
- if (sysctl(mib, miblen, NULL, &pathlen, NULL, 0) == -1) {
+ if (sysctl(mib, miblen, NULL, &pathlen, NULL, 0) == -1)
err(1, "getting path: sysctl(%s) - size only", PATHCTL);
- }
path = malloc(pathlen + 1);
- if (path == NULL) {
+ if (path == NULL)
err(1, "allocating %lu bytes for the path",
(unsigned long)pathlen + 1);
- }
- if (sysctl(mib, miblen, path, &pathlen, NULL, 0) == -1) {
+ if (sysctl(mib, miblen, path, &pathlen, NULL, 0) == -1)
err(1, "getting path: sysctl(%s)", PATHCTL);
- }
tmppath = path;
while ((element = strsep(&tmppath, ";")) != NULL) {
@@ -97,33 +89,29 @@
strlcat(kldpath, "/", MAXPATHLEN);
}
strlcat(kldpath, kldname, MAXPATHLEN);
-
- if (stat(kldpath, &sb) == -1) {
+
+ if (stat(kldpath, &sb) == -1)
continue;
- }
found = 1;
if (sb.st_dev != dev || sb.st_ino != ino) {
- if (!quiet) {
+ if (!quiet)
warnx("%s will be loaded from %s, not the "
"current directory", kldname, element);
- }
break;
- } else if (sb.st_dev == dev && sb.st_ino == ino) {
+ } else if (sb.st_dev == dev && sb.st_ino == ino)
break;
- }
}
free(path);
-
+
if (!found) {
- if (!quiet) {
+ if (!quiet)
warnx("%s is not in the module path", kldname);
- }
return (-1);
}
-
+
return (0);
}
@@ -130,6 +118,7 @@
static void
usage(void)
{
+
fprintf(stderr, "usage: kldload [-nqv] file ...\n");
exit(1);
}
@@ -138,17 +127,17 @@
main(int argc, char** argv)
{
int c;
+ int check_loaded;
int errors;
int fileid;
+ int quiet;
int verbose;
- int quiet;
- int check_loaded;
errors = 0;
verbose = 0;
quiet = 0;
check_loaded = 0;
-
+
while ((c = getopt(argc, argv, "nqv")) != -1) {
switch (c) {
case 'q':
@@ -181,7 +170,22 @@
printf("%s is already "
"loaded\n", argv[0]);
} else {
- warn("can't load %s", argv[0]);
+ switch (errno) {
+ case EEXIST:
+ warnx("can't load %s: module "
+ "already loaded or "
+ "in kernel", argv[0]);
+ break;
+ case ENOEXEC:
+ warnx("an error occurred while "
+ "loading the module. "
+ "Please check dmesg(8) for "
+ "more details.");
+ break;
+ default:
+ warn("can't load %s", argv[0]);
+ break;
+ }
errors++;
}
} else {
@@ -189,9 +193,8 @@
printf("Loaded %s, id=%d\n", argv[0],
fileid);
}
- } else {
+ } else
errors++;
- }
argv++;
}
More information about the Midnightbsd-cvs
mailing list