2014-06-04 10:22:48 -04:00
|
|
|
This patch changes 'modprobe' & co. so they honor the 'LINUX_MODULE_DIRECTORY'
|
|
|
|
environment variable, rather than looking for modules exclusively in
|
|
|
|
/lib/modules.
|
|
|
|
|
2014-07-23 12:51:07 -04:00
|
|
|
Original patch by David Guibert, from Nixpkgs; adjusted to use
|
|
|
|
'LINUX_MODULE_DIRECTORY' rather than 'MODULE_DIR' as the variable name.
|
2014-06-04 10:22:48 -04:00
|
|
|
|
|
|
|
diff --git a/depmod.c b/depmod.c
|
2014-07-23 16:27:17 -04:00
|
|
|
index a1d2f8c..ff579c7 100644
|
2014-06-04 10:22:48 -04:00
|
|
|
--- a/depmod.c
|
|
|
|
+++ b/depmod.c
|
|
|
|
@@ -48,9 +48,6 @@
|
|
|
|
|
|
|
|
#include "testing.h"
|
|
|
|
|
|
|
|
-#ifndef MODULE_DIR
|
|
|
|
-#define MODULE_DIR "/lib/modules/"
|
|
|
|
-#endif
|
|
|
|
|
|
|
|
#ifndef MODULE_BUILTIN_KEY
|
|
|
|
#define MODULE_BUILTIN_KEY "built-in"
|
|
|
|
@@ -1516,6 +1513,7 @@ static int parse_config_file(const char *filename,
|
|
|
|
char *line;
|
|
|
|
unsigned int linenum = 0;
|
|
|
|
FILE *cfile;
|
|
|
|
+ char *module_dir;
|
|
|
|
|
|
|
|
cfile = fopen(filename, "r");
|
|
|
|
if (!cfile) {
|
|
|
|
@@ -1525,6 +1523,10 @@ static int parse_config_file(const char *filename,
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
+ if((module_dir = getenv("LINUX_MODULE_DIRECTORY")) == NULL) {
|
2014-07-23 12:51:07 -04:00
|
|
|
+ module_dir = "/lib/modules";
|
2014-06-04 10:22:48 -04:00
|
|
|
+ }
|
|
|
|
+
|
|
|
|
while ((line = getline_wrapped(cfile, &linenum)) != NULL) {
|
|
|
|
char *ptr = line;
|
|
|
|
char *cmd, *modname;
|
2014-07-23 12:51:07 -04:00
|
|
|
@@ -1549,8 +1551,8 @@ static int parse_config_file(const char *filename,
|
|
|
|
0, *search);
|
2014-06-04 10:22:48 -04:00
|
|
|
continue;
|
|
|
|
}
|
2014-07-23 12:51:07 -04:00
|
|
|
- nofail_asprintf(&dirname, "%s%s%s/%s", basedir,
|
2014-06-04 10:22:48 -04:00
|
|
|
- MODULE_DIR, kernelversion, search_path);
|
2014-07-23 12:51:07 -04:00
|
|
|
+ nofail_asprintf(&dirname, "%s%s/%s/%s", basedir,
|
2014-06-04 10:22:48 -04:00
|
|
|
+ module_dir, kernelversion, search_path);
|
|
|
|
len = strlen(dirname);
|
|
|
|
*search = add_search(dirname, len, *search);
|
|
|
|
free(dirname);
|
2014-07-23 12:51:07 -04:00
|
|
|
@@ -1564,8 +1566,8 @@ static int parse_config_file(const char *filename,
|
|
|
|
if (!regex_match(kernelversion, (const char *)version))
|
2014-06-04 10:22:48 -04:00
|
|
|
continue;
|
|
|
|
|
2014-07-23 12:51:07 -04:00
|
|
|
- nofail_asprintf(&pathname, "%s%s%s/%s/%s.ko", basedir,
|
2014-06-04 10:22:48 -04:00
|
|
|
- MODULE_DIR, kernelversion, subdir, modname);
|
2014-07-23 12:51:07 -04:00
|
|
|
+ nofail_asprintf(&pathname, "%s%s/%s/%s/%s.ko", basedir,
|
2014-06-04 10:22:48 -04:00
|
|
|
+ module_dir, kernelversion, subdir, modname);
|
|
|
|
|
|
|
|
*overrides = add_override(pathname, *overrides);
|
|
|
|
free(pathname);
|
|
|
|
@@ -1737,6 +1739,7 @@ int main(int argc, char *argv[])
|
|
|
|
char *basedir = "", *dirname, *version;
|
|
|
|
char *system_map = NULL, *module_symvers = NULL;
|
|
|
|
int i;
|
|
|
|
+ char *module_dir;
|
|
|
|
const char *config = NULL;
|
|
|
|
|
|
|
|
if (native_endianness() == 0)
|
|
|
|
@@ -1832,7 +1835,11 @@ int main(int argc, char *argv[])
|
|
|
|
if (optind == argc)
|
|
|
|
all = 1;
|
|
|
|
|
|
|
|
- nofail_asprintf(&dirname, "%s%s%s", basedir, MODULE_DIR, version);
|
|
|
|
+ if((module_dir = getenv("LINUX_MODULE_DIRECTORY")) == NULL) {
|
2014-07-23 12:51:07 -04:00
|
|
|
+ module_dir = "/lib/modules";
|
2014-06-04 10:22:48 -04:00
|
|
|
+ }
|
|
|
|
+
|
2014-07-23 16:27:17 -04:00
|
|
|
+ nofail_asprintf(&dirname, "%s%s/%s", basedir, module_dir, version);
|
2014-06-04 10:22:48 -04:00
|
|
|
|
|
|
|
if (maybe_all) {
|
|
|
|
if (!doing_stdout && !depfile_out_of_date(dirname))
|
2014-07-23 12:51:07 -04:00
|
|
|
@@ -1849,8 +1856,8 @@ int main(int argc, char *argv[])
|
|
|
|
char *dirname;
|
2014-06-04 10:22:48 -04:00
|
|
|
size_t len;
|
|
|
|
|
2014-07-23 12:51:07 -04:00
|
|
|
- nofail_asprintf(&dirname, "%s%s%s/updates", basedir,
|
2014-06-04 10:22:48 -04:00
|
|
|
- MODULE_DIR, version);
|
2014-07-23 12:51:07 -04:00
|
|
|
+ nofail_asprintf(&dirname, "%s%s/%s/updates", basedir,
|
2014-06-04 10:22:48 -04:00
|
|
|
+ module_dir, version);
|
|
|
|
len = strlen(dirname);
|
|
|
|
search = add_search(dirname, len, search);
|
|
|
|
}
|
|
|
|
diff --git a/modinfo.c b/modinfo.c
|
2014-07-23 12:51:07 -04:00
|
|
|
index 1dd8469..6a1865b 100644
|
2014-06-04 10:22:48 -04:00
|
|
|
--- a/modinfo.c
|
|
|
|
+++ b/modinfo.c
|
|
|
|
@@ -19,9 +19,6 @@
|
|
|
|
#include "zlibsupport.h"
|
|
|
|
#include "testing.h"
|
|
|
|
|
|
|
|
-#ifndef MODULE_DIR
|
|
|
|
-#define MODULE_DIR "/lib/modules"
|
|
|
|
-#endif
|
|
|
|
|
|
|
|
struct param
|
|
|
|
{
|
|
|
|
@@ -193,6 +190,11 @@ static struct elf_file *grab_module(const char *name,
|
|
|
|
struct utsname buf;
|
|
|
|
char *depname, *p, *moddir;
|
|
|
|
struct elf_file *module;
|
|
|
|
+ char *module_dir;
|
|
|
|
+
|
|
|
|
+ if((module_dir = getenv("LINUX_MODULE_DIRECTORY")) == NULL) {
|
2014-07-23 12:51:07 -04:00
|
|
|
+ module_dir = "/lib/modules";
|
2014-06-04 10:22:48 -04:00
|
|
|
+ }
|
|
|
|
|
|
|
|
if (strchr(name, '.') || strchr(name, '/')) {
|
|
|
|
module = grab_elf_file(name);
|
|
|
|
@@ -207,9 +209,9 @@ static struct elf_file *grab_module(const char *name,
|
|
|
|
kernel = buf.release;
|
|
|
|
}
|
|
|
|
if (strlen(basedir))
|
|
|
|
- nofail_asprintf(&moddir, "%s/%s/%s", basedir, MODULE_DIR, kernel);
|
|
|
|
+ nofail_asprintf(&moddir, "%s/%s/%s", basedir, module_dir, kernel);
|
|
|
|
else
|
|
|
|
- nofail_asprintf(&moddir, "%s/%s", MODULE_DIR, kernel);
|
|
|
|
+ nofail_asprintf(&moddir, "%s/%s", module_dir, kernel);
|
|
|
|
|
|
|
|
/* Search for it in modules.dep. */
|
|
|
|
nofail_asprintf(&depname, "%s/%s", moddir, "modules.dep");
|
|
|
|
diff --git a/modprobe.c b/modprobe.c
|
2014-07-23 12:51:07 -04:00
|
|
|
index 5464f45..cb57917 100644
|
2014-06-04 10:22:48 -04:00
|
|
|
--- a/modprobe.c
|
|
|
|
+++ b/modprobe.c
|
|
|
|
@@ -86,10 +86,6 @@ typedef enum
|
|
|
|
|
|
|
|
} modprobe_flags_t;
|
|
|
|
|
|
|
|
-#ifndef MODULE_DIR
|
|
|
|
-#define MODULE_DIR "/lib/modules"
|
|
|
|
-#endif
|
|
|
|
-
|
|
|
|
/**
|
|
|
|
* print_usage - output the prefered program usage
|
|
|
|
*
|
|
|
|
@@ -2136,6 +2132,7 @@ int main(int argc, char *argv[])
|
|
|
|
struct modprobe_conf conf = {};
|
|
|
|
|
|
|
|
recursion_depth = 0;
|
|
|
|
+ char *module_dir = NULL;
|
|
|
|
|
|
|
|
/* Prepend options from environment. */
|
|
|
|
argv = merge_args(getenv("MODPROBE_OPTIONS"), argv, &argc);
|
|
|
|
@@ -2233,7 +2230,11 @@ int main(int argc, char *argv[])
|
|
|
|
if (argc < optind + 1 && !dump_config && !list_only)
|
|
|
|
print_usage(argv[0]);
|
|
|
|
|
|
|
|
- nofail_asprintf(&dirname, "%s%s/%s", basedir, MODULE_DIR, buf.release);
|
|
|
|
+ if((module_dir = getenv("LINUX_MODULE_DIRECTORY")) == NULL) {
|
|
|
|
+ module_dir = "/lib/modules";
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ nofail_asprintf(&dirname, "%s%s/%s", basedir, module_dir, buf.release);
|
|
|
|
|
|
|
|
/* Old-style -t xxx wildcard? Only with -l. */
|
|
|
|
if (list_only) {
|