kmod: It's an error not to have modules.devname
authorLucas De Marchi <lucas.de.marchi@gmail.com>
Wed, 17 Apr 2013 03:54:17 +0000 (00:54 -0300)
committerLucas De Marchi <lucas.de.marchi@gmail.com>
Wed, 17 Apr 2013 03:57:11 +0000 (00:57 -0300)
This file is created by depmod even if there's no node. In this case it
will be empty.

Previously 'kmod static-nodes' was segfaulting due to passing in==NULL
to fgets.

Also show the error message with %m.

tools/static-nodes.c

index 94a48c6..65a36fc 100644 (file)
@@ -203,10 +203,11 @@ static int do_static_nodes(int argc, char *argv[])
                 ret = EXIT_FAILURE;
                 goto finish;
         }
+
         snprintf(modules, sizeof(modules), "/lib/modules/%s/modules.devname", kernel.release);
         in = fopen(modules, "re");
-        if (in == NULL && errno != ENOENT) {
-                fprintf(stderr, "Error: could not open /lib/modules/%s/modules.devname!\n", kernel.release);
+        if (in == NULL) {
+                fprintf(stderr, "Error: could not open /lib/modules/%s/modules.devname - %m\n", kernel.release);
                 ret = EXIT_FAILURE;
                 goto finish;
         }