summary refs log tree commit diff
path: root/gnu/packages/patches/kmod-module-directory.patch
blob: b4b1a3b3dbc495ab87b5a03622483b4cc797ae8b (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
This patch changes libkmod so it honors the 'LINUX_MODULE_DIRECTORY'
environment variable, rather than looking for modules exclusively in
/lib/modules.

Patch by Shea Levy, from Nixpkgs; adjusted to use 'LINUX_MODULE_DIRECTORY'
rather than 'MODULE_DIR' as the variable name.


--- kmod-7/libkmod/libkmod.c	2012-03-15 08:19:16.750010226 -0400
+++ kmod-7/libkmod/libkmod.c	2012-04-04 15:21:29.532074313 -0400
@@ -200,7 +200,7 @@
 static char *get_kernel_release(const char *dirname)
 {
 	struct utsname u;
-	char *p;
+	char *p, *dirname_prefix;
 
 	if (dirname != NULL)
 		return path_make_absolute_cwd(dirname);
@@ -208,7 +208,10 @@
 	if (uname(&u) < 0)
 		return NULL;
 
-	if (asprintf(&p, "%s/%s", dirname_default_prefix, u.release) < 0)
+	if ((dirname_prefix = getenv("LINUX_MODULE_DIRECTORY")) == NULL)
+		dirname_prefix = dirname_default_prefix;
+
+	if (asprintf(&p, "%s/%s", dirname_prefix, u.release) < 0)
 		return NULL;
 
 	return p;