aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLucas De Marchi <lucas.de.marchi@gmail.com>2012-06-15 01:08:17 -0300
committerLucas De Marchi <lucas.de.marchi@gmail.com>2012-06-15 02:42:39 -0300
commit80e49ad9883b596310b6b2240e810511bd89d790 (patch)
tree77890c741ae3bc820fd351dac2b15f1c1ecf13e3
parentc5db1a3fd21a53a4592ee4e8c25efde01e6e2286 (diff)
downloadkmod-80e49ad9883b596310b6b2240e810511bd89d790.tar.gz
depmod: fail if any index could not be created
-rw-r--r--tools/depmod.c22
1 files changed, 14 insertions, 8 deletions
diff --git a/tools/depmod.c b/tools/depmod.c
index d8dded6..d8bfc2b 100644
--- a/tools/depmod.c
+++ b/tools/depmod.c
@@ -2266,19 +2266,25 @@ static int depmod_output(struct depmod *depmod, FILE *out)
if (r < 0) {
if (unlinkat(dfd, tmp, 0) != 0)
ERR("unlinkat(%s, %s): %m\n", dname, tmp);
- } else {
- unlinkat(dfd, itr->name, 0);
- if (renameat(dfd, tmp, dfd, itr->name) != 0) {
- err = -errno;
- CRIT("renameat(%s, %s, %s, %s): %m\n",
- dname, tmp, dname, itr->name);
- break;
- }
+
+ ERR("Could not write index '%s': %s\n", itr->name,
+ strerror(-r));
+ err = -errno;
+ break;
+ }
+
+ unlinkat(dfd, itr->name, 0);
+ if (renameat(dfd, tmp, dfd, itr->name) != 0) {
+ err = -errno;
+ CRIT("renameat(%s, %s, %s, %s): %m\n",
+ dname, tmp, dname, itr->name);
+ break;
}
}
if (dfd >= 0)
close(dfd);
+
return err;
}