···
1
-
diff -ru -x '*~' kmod-17-orig/libkmod/libkmod.c kmod-17/libkmod/libkmod.c
2
-
--- kmod-17-orig/libkmod/libkmod.c 2014-04-01 12:40:37.161940089 +0200
3
-
+++ kmod-17/libkmod/libkmod.c 2014-04-17 13:47:15.871441987 +0200
1
+
diff --git a/Makefile.am b/Makefile.am
2
+
index d4eeb7e..5c9f603 100644
5
+
@@ -19,6 +19,7 @@ AM_CPPFLAGS = \
6
+
-include $(top_builddir)/config.h \
8
+
-DSYSCONFDIR=\""$(sysconfdir)"\" \
9
+
+ -DMODULESDIRS=\""$(shell echo $(modulesdirs) | $(SED) 's|:|\\",\\"|g')"\" \
12
+
AM_CFLAGS = $(OUR_CFLAGS)
13
+
diff --git a/configure.ac b/configure.ac
14
+
index 23510c8..66490cf 100644
17
+
@@ -202,6 +202,12 @@ GTK_DOC_CHECK([1.14],[--flavour no-tmpl-flat])
19
+
AM_CONDITIONAL([ENABLE_GTK_DOC], false)])
21
+
+AC_ARG_WITH([modulesdirs],
22
+
+ AS_HELP_STRING([--with-modulesdirs=DIRS], [Kernel modules directories, separated by :]),
24
+
+ [with_modulesdirs=/lib/modules])
25
+
+AC_SUBST([modulesdirs], [$with_modulesdirs])
28
+
#####################################################################
29
+
# Default CFLAGS and LDFLAGS
30
+
diff --git a/libkmod/libkmod.c b/libkmod/libkmod.c
31
+
index 69fe431..d37da32 100644
32
+
--- a/libkmod/libkmod.c
33
+
+++ b/libkmod/libkmod.c
34
+
@@ -206,12 +206,15 @@ static int log_priority(const char *priority)
38
+
-static const char *dirname_default_prefix = "/lib/modules";
39
+
+static const char *dirname_default_prefixes[] = {
static char *get_kernel_release(const char *dirname)
···
return path_make_absolute_cwd(dirname);
13
-
@@ -209,7 +209,10 @@
52
+
@@ -219,8 +222,42 @@ static char *get_kernel_release(const char *dirname)
- if (asprintf(&p, "%s/%s", dirname_default_prefix, u.release) < 0)
18
-
+ if ((dirname_prefix = getenv("MODULE_DIR")) == NULL)
19
-
+ dirname_prefix = dirname_default_prefix;
58
+
+ if ((dirname_prefix = getenv("MODULE_DIR")) != NULL) {
59
+
+ if(asprintf(&p, "%s/%s", dirname_prefix, u.release) < 0)
63
+
+ char buf[PATH_MAX];
65
+
+ for (i = 0; dirname_default_prefixes[i] != NULL; i++) {
67
+
+ struct stat dirstat;
69
+
+ plen = snprintf(buf, sizeof(buf), "%s/%s", dirname_default_prefixes[i], u.release);
72
+
+ else if (plen >= PATH_MAX)
75
+
+ if (dirname_default_prefixes[i + 1] != NULL) {
76
+
+ if (stat(buf, &dirstat) < 0) {
77
+
+ if (errno == ENOENT)
83
+
+ if (!S_ISDIR(dirstat.st_mode))
21
-
+ if (asprintf(&p, "%s/%s", dirname_prefix, u.release) < 0)
87
+
+ p = malloc(plen + 1);
90
+
+ memcpy(p, buf, plen + 1);
25
-
diff -ru -x '*~' kmod-17-orig/tools/static-nodes.c kmod-17/tools/static-nodes.c
26
-
--- kmod-17-orig/tools/static-nodes.c 2013-12-17 22:05:42.159047316 +0100
27
-
+++ kmod-17/tools/static-nodes.c 2014-04-17 13:51:17.945974320 +0200
97
+
diff --git a/tools/static-nodes.c b/tools/static-nodes.c
98
+
index 8d2356d..2ed306d 100644
99
+
--- a/tools/static-nodes.c
100
+
+++ b/tools/static-nodes.c
101
+
@@ -29,10 +29,11 @@
102
+
#include <unistd.h>
103
+
#include <sys/stat.h>
104
+
#include <sys/types.h>
105
+
-#include <sys/utsname.h>
107
+
#include <shared/util.h>
109
+
+#include <libkmod/libkmod.h>
113
+
struct static_nodes_format {
114
+
@@ -154,8 +155,8 @@ static void help(void)
116
+
static int do_static_nodes(int argc, char *argv[])
118
+
- struct utsname kernel;
119
+
char modules[PATH_MAX], buf[4096];
120
+
+ struct kmod_ctx *ctx;
121
+
const char *output = "/dev/stdout";
FILE *in = NULL, *out = NULL;
const struct static_nodes_format *format = &static_nodes_format_human;
31
-
int r, ret = EXIT_SUCCESS;
32
-
+ char *dirname_prefix;
124
+
@@ -206,22 +207,25 @@ static int do_static_nodes(int argc, char *argv[])
35
-
int c, idx = 0, valid;
36
-
@@ -211,16 +212,19 @@
128
+
- if (uname(&kernel) < 0) {
129
+
- fputs("Error: uname failed!\n", stderr);
130
+
+ ctx = kmod_new(NULL, NULL);
131
+
+ if (ctx == NULL) {
132
+
+ fprintf(stderr, "Error: failed to create kmod context\n");
133
+
ret = EXIT_FAILURE;
- snprintf(modules, sizeof(modules), "/lib/modules/%s/modules.devname", kernel.release);
41
-
+ if ((dirname_prefix = getenv("MODULE_DIR")) == NULL)
42
-
+ dirname_prefix = "/lib/modules";
44
-
+ snprintf(modules, sizeof(modules), "%s/%s/modules.devname", dirname_prefix, kernel.release);
138
+
+ if (snprintf(modules, sizeof(modules), "%s/modules.devname", kmod_get_dirname(ctx)) < 0) {
139
+
+ fprintf(stderr, "Error: path to modules.devname is too long\n");
140
+
+ ret = EXIT_FAILURE;
in = fopen(modules, "re");
- fprintf(stderr, "Warning: /lib/modules/%s/modules.devname not found - ignoring\n",
50
-
+ fprintf(stderr, "Warning: %s/%s/modules.devname not found - ignoring\n",
51
-
+ dirname_prefix, kernel.release);
149
+
+ fprintf(stderr, "Warning: %s not found - ignoring\n", modules);
- fprintf(stderr, "Error: could not open /lib/modules/%s/modules.devname - %m\n",
56
-
+ fprintf(stderr, "Error: could not open %s/%s/modules.devname - %m\n",
57
-
+ dirname_prefix, kernel.release);
154
+
+ fprintf(stderr, "Error: could not open %s - %m\n", modules);