From: Shea Levy <redacted>
It is used as a path if this environment variable is set, and `uname -r` is
appended to the end. Otherwise, default /lib/modules/`uname -r` is used as
usual.
---
libkmod/libkmod.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/libkmod/libkmod.c b/libkmod/libkmod.c
index 69fe431..7b0247f 100644
--- a/libkmod/libkmod.c
+++ b/libkmod/libkmod.c
@@ -211,7 +211,7 @@ static const char *dirname_default_prefix = "/lib/modules";
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);@@ -219,7 +219,10 @@ static char *get_kernel_release(const char *dirname)
if (uname(&u) < 0)
return NULL;
- if (asprintf(&p, "%s/%s", dirname_default_prefix, u.release) < 0)
+ if ((dirname_prefix = getenv("MODULE_DIR")) == NULL)
+ dirname_prefix = dirname_default_prefix;
+
+ if (asprintf(&p, "%s/%s", dirname_prefix, u.release) < 0)
return NULL;
return p;--
2.9.2