<!DOCTYPE html>
<html lang='en'>
<head>
<title>srfi - guix - Wojtek's customized Guix</title>
<meta name='generator' content='cgit v1.2.3'/>
<meta name='robots' content='noindex, nofollow'/>
<link rel='stylesheet' type='text/css' href='/cgit-static/cgit.css'/>
<link rel='stylesheet' type='text/css' href='/cgit-static/better-cgit-markdown-heading-color.css'/>
<link rel='shortcut icon' href='/cgit-static/favicon.ico'/>
<link rel='alternate' title='Atom feed' href='https://git.koszko.org/guix/atom/srfi?h=koszko' type='application/atom+xml'/>
</head>
<body>
<div id='cgit'><table id='header'>
<tr>
<td class='logo' rowspan='2'><a href='/'><img src='https://git.koszko.org/cgit-static/cgit.png' alt='cgit logo'/></a></td>
<td class='main'><a href='/'>index</a> : <a href='/guix/'>guix</a></td><td class='form'><form method='get'>
<input type='hidden' name='id' value='3440f12a7ee65692c809a8fa867c25c317e1e4e6'/><select name='h' onchange='this.form.submit();'>
<option value='koszko' selected='selected'>koszko</option>
<option value='koszko-scripts'>koszko-scripts</option>
</select> <input type='submit' value='switch'/></form></td></tr>
<tr><td class='sub'>Wojtek's customized Guix</td><td class='sub right'></td></tr></table>
<table class='tabs'><tr><td>
<a href='/guix/about/'>about</a><a href='/guix/'>summary</a><a href='/guix/refs/?id=3440f12a7ee65692c809a8fa867c25c317e1e4e6'>refs</a><a href='/guix/log/srfi'>log</a><a class='active' href='/guix/tree/srfi?id=3440f12a7ee65692c809a8fa867c25c317e1e4e6'>tree</a><a href='/guix/commit/srfi?id=3440f12a7ee65692c809a8fa867c25c317e1e4e6'>commit</a><a href='/guix/diff/srfi?id=3440f12a7ee65692c809a8fa867c25c317e1e4e6'>diff</a></td><td class='form'><form class='right' method='get' action='/guix/log/srfi'>
<input type='hidden' name='id' value='3440f12a7ee65692c809a8fa867c25c317e1e4e6'/><select name='qt'>
<option value='grep'>log msg</option>
<option value='author'>author</option>
<option value='committer'>committer</option>
<option value='range'>range</option>
</select>
<input class='txt' type='search' size='10' name='q' value=''/>
<input type='submit' value='search'/>
</form>
</td></tr></table>
<div class='path'>path: <a href='/guix/tree/?id=3440f12a7ee<pre>
This patch changes &apos;modprobe&apos; &amp; co. so they honor the &apos;LINUX_MODULE_DIRECTORY&apos;
environment variable, rather than looking for modules exclusively in
/lib/modules.

Original patch by David Guibert, from Nixpkgs; adjusted to use
&apos;LINUX_MODULE_DIRECTORY&apos; rather than &apos;MODULE_DIR&apos; as the variable name.

diff --git a/depmod.c b/depmod.c
index a1d2f8c..ff579c7 100644
--- a/depmod.c
+++ b/depmod.c
@@ -48,9 +48,6 @@
 
 #include &quot;testing.h&quot;
 
-#ifndef MODULE_DIR
-#define MODULE_DIR &quot;/lib/modules/&quot;
-#endif
 
 #ifndef MODULE_BUILTIN_KEY
 #define MODULE_BUILTIN_KEY &quot;built-in&quot;
@@ -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, &quot;r&quot;);
 	if (!cfile) {
@@ -1525,6 +1523,10 @@ static int parse_config_file(const char *filename,
 		return 0;
 	}
 
+        if((module_dir = getenv(&quot;LINUX_MODULE_DIRECTORY&quot;)) == NULL) {
+                module_dir = &quot;/lib/modules&quot;;
+        }
+
 	while ((line = getline_wrapped(cfile, &amp;linenum)) != NULL) {
 		char *ptr = line;
 		char *cmd, *modname;
@@ -1549,8 +1551,8 @@ static int parse_config_file(const char *filename,
 							     0, *search);
 					continue;
 				}
-				nofail_asprintf(&amp;dirname, &quot;%s%s%s/%s&quot;, basedir,
-					MODULE_DIR, kernelversion, search_path);
+				nofail_asprintf(&amp;dirname, &quot;%s%s/%s/%s&quot;, basedir,
+					module_dir, kernelversion, search_path);
 				len = strlen(dirname);
 				*search = add_search(dirname, len, *search);
 				free(dirname);
@@ -1564,8 +1566,8 @@ static int parse_config_file(const char *filename,
 			if (!regex_match(kernelversion, (const char *)version))
 				continue;
 
-			nofail_asprintf(&amp;pathname, &quot;%s%s%s/%s/%s.ko&quot;, basedir,
-				MODULE_DIR, kernelversion, subdir, modname);
+			nofail_asprintf(&amp;pathname, &quot;%s%s/%s/%s/%s.ko&quot;, basedir,
+				module_dir, kernelversion, subdir, modname);
 
 			*overrides = add_override(pathname, *overrides);
 			free(pathname);
@@ -1737,6 +1739,7 @@ int main(int argc, char *argv[])
 	char *basedir = &quot;&quot;, *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(&amp;dirname, &quot;%s%s%s&quot;, basedir, MODULE_DIR, version);
+        if((module_dir = getenv(&quot;LINUX_MODULE_DIRECTORY&quot;)) == NULL) {
+                module_dir = &quot;/lib/modules&quot;;
+        }
+
+	nofail_asprintf(&amp;dirname, &quot;%s%s/%s&quot;, basedir, module_dir, version);
 
 	if (maybe_all) {
 		if (!doing_stdout &amp;&amp; !depfile_out_of_date(dirname))
@@ -1849,8 +1856,8 @@ int main(int argc, char *argv[])
 		char *dirname;
 		size_t len;
 
-		nofail_asprintf(&amp;dirname, &quot;%s%s%s/updates&quot;, basedir,
-				MODULE_DIR, version);
+		nofail_asprintf(&amp;dirname, &quot;%s%s/%s/updates&quot;, basedir,
+				module_dir, version);
 		len = strlen(dirname);
 		search = add_search(dirname, len, search);
 	}
diff --git a/modinfo.c b/modinfo.c
index 1dd8469..6a1865b 100644
--- a/modinfo.c
+++ b/modinfo.c
@@ -19,9 +19,6 @@
 #include &quot;zlibsupport.h&quot;
 #include &quot;testing.h&quot;
 
-#ifndef MODULE_DIR
-#define MODULE_DIR &quot;/lib/modules&quot;
-#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(&quot;LINUX_MODULE_DIRECTORY&quot;)) == NULL) {
+                module_dir = &quot;/lib/modules&quot;;
+        }
 
 	if (strchr(name, &apos;.&apos;) || strchr(name, &apos;/&apos;)) {
 		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(&amp;moddir, &quot;%s/%s/%s&quot;, basedir, MODULE_DIR, kernel);
+		nofail_asprintf(&amp;moddir, &quot;%s/%s/%s&quot;, basedir, module_dir, kernel);
 	else
-		nofail_asprintf(&amp;moddir, &quot;%s/%s&quot;, MODULE_DIR, kernel);
+		nofail_asprintf(&amp;moddir, &quot;%s/%s&quot;, module_dir, kernel);
 
 	/* Search for it in modules.dep. */
 	nofail_asprintf(&amp;depname, &quot;%s/%s&quot;, moddir, &quot;modules.dep&quot;);
diff --git a/modprobe.c b/modprobe.c
index 5464f45..cb57917 100644
--- a/modprobe.c
+++ b/modprobe.c
@@ -86,10 +86,6 @@ typedef enum
 
 } modprobe_flags_t;
 
-#ifndef MODULE_DIR
-#define MODULE_DIR &quot;/lib/modules&quot;
-#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(&quot;MODPROBE_OPTIONS&quot;), argv, &amp;argc);
@@ -2233,7 +2230,11 @@ int main(int argc, char *argv[])
 	if (argc &lt; optind + 1 &amp;&amp; !dump_config &amp;&amp; !list_only)
 		print_usage(argv[0]);
 
-	nofail_asprintf(&amp;dirname, &quot;%s%s/%s&quot;, basedir, MODULE_DIR, buf.release);
+	if((module_dir = getenv(&quot;LINUX_MODULE_DIRECTORY&quot;)) == NULL) {
+		module_dir = &quot;/lib/modules&quot;;
+	}
+
+	nofail_asprintf(&amp;dirname, &quot;%s%s/%s&quot;, basedir, module_dir, buf.release);
 
 	/* Old-style -t xxx wildcard?  Only with -l. */
 	if (list_only) {
</pre>
</div></div> <!-- class=content -->
                         <div class=footer>generated by
                             <a href="https://git.zx2c4.com/cgit/about/">
                                 cgit
                             </a>
                         </div>
                        </div> <!-- id=cgit -->
</body>
</html>
