summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Härdeman <david@hardeman.nu>2007-05-20 00:03:46 +0200
committerDavid Härdeman <david@hardeman.nu>2007-05-20 00:03:46 +0200
commitd8cf23b54d7c6e9883f6a823bde87f3ab3c844d0 (patch)
treea286e6fdbd89c4e571cd1d981da9ea83ef90c5af
parente435c45fe0f3eac66f564a3f5815191a2fbc05cf (diff)
Improve some error messages.
-rw-r--r--metaentry.c9
-rw-r--r--utils.c4
2 files changed, 9 insertions, 4 deletions
diff --git a/metaentry.c b/metaentry.c
index 257f86d..ac2960a 100644
--- a/metaentry.c
+++ b/metaentry.c
@@ -352,7 +352,8 @@ mentries_tofile(const struct metaentry *mlist, const char *path)
to = fopen(path, "w");
if (!to) {
- perror("fopen");
+ msg(MSG_CRITICAL, "Failed to open %s: %s\n",
+ path, strerror(errno));
exit(EXIT_FAILURE);
}
@@ -392,12 +393,14 @@ mentries_fromfile(struct metaentry **mlist, const char *path)
fd = open(path, O_RDONLY);
if (fd < 0) {
- perror("open");
+ msg(MSG_CRITICAL, "Failed to open %s: %s\n",
+ path, strerror(errno));
exit(EXIT_FAILURE);
}
if (fstat(fd, &sbuf)) {
- perror("fstat");
+ msg(MSG_CRITICAL, "Failed to stat %s: %s\n",
+ path, strerror(errno));
exit(EXIT_FAILURE);
}
diff --git a/utils.c b/utils.c
index de4993e..7b8e784 100644
--- a/utils.c
+++ b/utils.c
@@ -25,6 +25,7 @@
#include <stdint.h>
#include <stdarg.h>
#include <unistd.h>
+#include <errno.h>
#include "utils.h"
@@ -105,7 +106,8 @@ void
xfwrite(const void *ptr, size_t size, FILE *stream)
{
if (fwrite(ptr, size, 1, stream) != 1) {
- perror("fwrite");
+ msg(MSG_CRITICAL, "Failed to write to file: %s\n",
+ strerror(errno));
exit(EXIT_FAILURE);
}
}