]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
isosize: simplify some error messages
authorFrancesco Cosoleto <cosoleto@gmail.com>
Fri, 8 Apr 2011 13:51:48 +0000 (15:51 +0200)
committerKarel Zak <kzak@redhat.com>
Tue, 12 Apr 2011 10:31:15 +0000 (12:31 +0200)
perror() and fprintf() are replaced with err() calls

Signed-off-by: Francesco Cosoleto <cosoleto@gmail.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
disk-utils/isosize.c

index 5f0358e51497c34d73aa300ef0b05076db8385ae..d00e4f0e068c88b06c59abb819bc01f0b6ce0b29 100644 (file)
@@ -26,6 +26,7 @@
 #include <string.h>
 
 #include "nls.h"
+#include "c.h"
 
 #define ISODCL(from, to) (to - from + 1)
 
@@ -124,24 +125,14 @@ isosize(char *filenamep) {
        int fd, nsecs, ssize;
        struct iso_primary_descriptor ipd;
 
-       if ((fd = open(filenamep, O_RDONLY)) < 0) {
-               perror(filenamep);
-               fprintf(stderr, _("%s: failed to open: %s\n"),
-                       progname, filenamep);
-               exit(1);
-       }
-       if (lseek(fd, 16 << 11, 0) == (off_t)-1) {
-               perror("lseek");
-               fprintf(stderr, _("%s: seek error on %s\n"),
-                       progname, filenamep);
-               exit(1);
-       }
-       if (read(fd, &ipd, sizeof(ipd)) < 0) {
-               perror("read");
-               fprintf(stderr, _("%s: read error on %s\n"),
-                       progname, filenamep);
-               exit(1);
-       }
+       if ((fd = open(filenamep, O_RDONLY)) < 0)
+               err(EXIT_FAILURE, _("failed to open %s"), filenamep);
+
+       if (lseek(fd, 16 << 11, 0) == (off_t)-1)
+               err(EXIT_FAILURE, _("seek error on %s"), filenamep);
+
+       if (read(fd, &ipd, sizeof(ipd)) < 0)
+               err(EXIT_FAILURE, _("read error on %s"), filenamep);
 
        nsecs = isonum_733(ipd.volume_space_size);
        ssize = isonum_723(ipd.logical_block_size); /* nowadays always 2048 */