From 279b177de62cd9778ed6b111a11d93d8e18fa169 Mon Sep 17 00:00:00 2001 From: Lucas De Marchi Date: Wed, 17 Apr 2013 00:54:17 -0300 Subject: [PATCH] kmod: It's an error not to have modules.devname 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 | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tools/static-nodes.c b/tools/static-nodes.c index 94a48c6..65a36fc 100644 --- a/tools/static-nodes.c +++ b/tools/static-nodes.c @@ -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; } -- 2.7.4