1 This patch changes libkmod so it honors the 'LINUX_MODULE_DIRECTORY'
2 environment variable, rather than looking for modules exclusively in
5 Patch by Shea Levy and Eelco Dolstra, from Nixpkgs; adjusted to
6 use 'LINUX_MODULE_DIRECTORY' rather than 'MODULE_DIR' as the variable
10 --- kmod-7/libkmod/libkmod.c 2012-03-15 08:19:16.750010226 -0400
11 +++ kmod-7/libkmod/libkmod.c 2012-04-04 15:21:29.532074313 -0400
13 static char *get_kernel_release(const char *dirname)
17 + char *p, *dirname_prefix;
20 return path_make_absolute_cwd(dirname);
25 - if (asprintf(&p, "%s/%s", dirname_default_prefix, u.release) < 0)
26 + if ((dirname_prefix = getenv("LINUX_MODULE_DIRECTORY")) == NULL)
27 + dirname_prefix = dirname_default_prefix;
29 + if (asprintf(&p, "%s/%s", dirname_prefix, u.release) < 0)
34 --- kmod-17/tools/static-nodes.c 2013-12-17 22:05:42.159047316 +0100
35 +++ kmod-17/tools/static-nodes.c 2014-04-17 13:51:17.945974320 +0200
37 FILE *in = NULL, *out = NULL;
38 const struct static_nodes_format *format = &static_nodes_format_human;
39 int r, ret = EXIT_SUCCESS;
40 + char *dirname_prefix;
43 int c, idx = 0, valid;
48 - snprintf(modules, sizeof(modules), "/lib/modules/%s/modules.devname", kernel.release);
49 + if ((dirname_prefix = getenv("LINUX_MODULE_DIRECTORY")) == NULL)
50 + dirname_prefix = "/lib/modules";
52 + snprintf(modules, sizeof(modules), "%s/%s/modules.devname", dirname_prefix, kernel.release);
53 in = fopen(modules, "re");
55 if (errno == ENOENT) {
56 - fprintf(stderr, "Warning: /lib/modules/%s/modules.devname not found - ignoring\n",
58 + fprintf(stderr, "Warning: %s/%s/modules.devname not found - ignoring\n",
59 + dirname_prefix, kernel.release);
62 - fprintf(stderr, "Error: could not open /lib/modules/%s/modules.devname - %m\n",
64 + fprintf(stderr, "Error: could not open %s/%s/modules.devname - %m\n",
65 + dirname_prefix, kernel.release);