From bb98388557c7e68067b103c6654baa6a1614b392 Mon Sep 17 00:00:00 2001 From: James Youngman Date: Sun, 6 Apr 2008 11:45:57 +0100 Subject: [PATCH] fsck.minix: correct the error message given when we can't open the device Don't actually print %s in the error message, print the device name, as was obviously intended. Also, print the error message corresponding to the errno value. [kzak@redhat.com: add __attribute__, coding style cleanups] Signed-off-by: James Youngman Signed-off-by: Karel Zak --- disk-utils/fsck.minix.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/disk-utils/fsck.minix.c b/disk-utils/fsck.minix.c index cd41d795..bbe80b42 100644 --- a/disk-utils/fsck.minix.c +++ b/disk-utils/fsck.minix.c @@ -86,6 +86,7 @@ */ #include +#include #include #include #include @@ -188,9 +189,18 @@ usage(void) { leave(16); } +static void die(const char *fmt, ...) + __attribute__ ((__format__ (__printf__, 1, 2))); + static void -die(const char *str) { - fprintf(stderr, "%s: %s\n", program_name, str); +die(const char *fmt, ...) { + va_list ap; + + fprintf(stderr, "%s: ", program_name); + va_start(ap, fmt); + vfprintf(stderr, fmt, ap); + va_end (ap); + fputc('\n', stderr); leave(8); } @@ -1283,7 +1293,7 @@ main(int argc, char ** argv) { } IN = open(device_name,repair?O_RDWR:O_RDONLY); if (IN < 0) - die(_("unable to open '%s'")); + die(_("unable to open '%s': %s"), device_name, strerror(errno)); for (count=0 ; count<3 ; count++) sync(); read_superblock(); -- 2.39.5