summaryrefslogtreecommitdiff
path: root/kernel.c
diff options
context:
space:
mode:
authorAaron Plattner <aplattner@nvidia.com>2016-10-21 08:05:25 -0700
committerAaron Plattner <aplattner@nvidia.com>2016-10-21 08:05:25 -0700
commitd6190c92db2ffb84e721afe5bf9d4ef41243cc02 (patch)
tree72fbe8daf3e07a8dcf7beb945d74dab44bf239bc /kernel.c
parentf63e032a431b02f86da1e16434566c0f53b74525 (diff)
375.10375.10
Diffstat (limited to 'kernel.c')
-rw-r--r--kernel.c35
1 files changed, 23 insertions, 12 deletions
diff --git a/kernel.c b/kernel.c
index ee8c174..511215b 100644
--- a/kernel.c
+++ b/kernel.c
@@ -1422,7 +1422,7 @@ int test_kernel_modules(Options *op, Package *p)
ret = ignore_load_error(op, p, p->kernel_modules[i].module_filename,
cmd_output, ret);
if (ret) {
- op->load_error_ignored = TRUE;
+ op->skip_module_load = TRUE;
handle_optional_module_failure(op,
p->kernel_modules[i], ui_warn,
"load");
@@ -1491,7 +1491,7 @@ static int modprobe_helper(Options *op, const char *module_name,
int ret = 0, old_loglevel, loglevel_set;
char *cmd, *data;
- if (op->load_error_ignored) {
+ if (op->skip_module_load) {
return TRUE;
}
@@ -1772,7 +1772,7 @@ PrecompiledInfo *find_precompiled_kernel_interface(Options *op, Package *p)
/*
* get_kernel_name() - get the kernel name: this is either what
- * the user specified via the --kernel-name option, or `name -r`.
+ * the user specified via the --kernel-name option, or `uname -r`.
*/
char __kernel_name[256];
@@ -1781,18 +1781,29 @@ char *get_kernel_name(Options *op)
{
struct utsname uname_buf;
- if (op->kernel_name) {
- return op->kernel_name;
+ __kernel_name[0] = '\0';
+
+ if (uname(&uname_buf) == -1) {
+ ui_warn(op, "Unable to determine the version of the running kernel "
+ "(%s).", strerror(errno));
} else {
- if (uname(&uname_buf) == -1) {
- ui_warn(op, "Unable to determine kernel version (%s).",
- strerror(errno));
- return NULL;
- } else {
- strncpy(__kernel_name, uname_buf.release, 256);
- return __kernel_name;
+ strncpy(__kernel_name, uname_buf.release, sizeof(__kernel_name));
+ __kernel_name[sizeof(__kernel_name) - 1] = '\0';
+ }
+
+ if (op->kernel_name) {
+ if (strcmp(op->kernel_name, __kernel_name) != 0) {
+ /* Don't load kernel modules built against a non-running kernel */
+ op->skip_module_load = TRUE;
}
+ return op->kernel_name;
+ }
+
+ if (__kernel_name[0]) {
+ return __kernel_name;
}
+
+ return NULL;
} /* get_kernel_name() */