Merge branch 'master' into staging
[jackhill/guix/guix.git] / gnu / packages / patches / kmod-module-directory.patch
1 This patch changes libkmod so it honors the 'LINUX_MODULE_DIRECTORY'
2 environment variable, rather than looking for modules exclusively in
3 /lib/modules.
4
5 Patch by Shea Levy and Eelco Dolstra, from Nixpkgs; adjusted to
6 use 'LINUX_MODULE_DIRECTORY' rather than 'MODULE_DIR' as the variable
7 name.
8
9
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
12 @@ -200,7 +200,7 @@
13 static char *get_kernel_release(const char *dirname)
14 {
15 struct utsname u;
16 - char *p;
17 + char *p, *dirname_prefix;
18
19 if (dirname != NULL)
20 return path_make_absolute_cwd(dirname);
21 @@ -208,7 +208,10 @@
22 if (uname(&u) < 0)
23 return NULL;
24
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;
28 +
29 + if (asprintf(&p, "%s/%s", dirname_prefix, u.release) < 0)
30 return NULL;
31
32 return p;
33
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
36 @@ -159,6 +159,7 @@
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;
41
42 for (;;) {
43 int c, idx = 0, valid;
44 @@ -211,16 +212,19 @@
45 goto finish;
46 }
47
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";
51 +
52 + snprintf(modules, sizeof(modules), "%s/%s/modules.devname", dirname_prefix, kernel.release);
53 in = fopen(modules, "re");
54 if (in == NULL) {
55 if (errno == ENOENT) {
56 - fprintf(stderr, "Warning: /lib/modules/%s/modules.devname not found - ignoring\n",
57 - kernel.release);
58 + fprintf(stderr, "Warning: %s/%s/modules.devname not found - ignoring\n",
59 + dirname_prefix, kernel.release);
60 ret = EXIT_SUCCESS;
61 } else {
62 - fprintf(stderr, "Error: could not open /lib/modules/%s/modules.devname - %m\n",
63 - kernel.release);
64 + fprintf(stderr, "Error: could not open %s/%s/modules.devname - %m\n",
65 + dirname_prefix, kernel.release);
66 ret = EXIT_FAILURE;
67 }
68 goto finish;