}
void fatal(enum failure why) {
- char error[LINE_LENGTH],
- *message = error;
- int rc = EXIT_FAILURE;
if (listing) {
close(fd);
switch (why) {
case unable_to_open:
- snprintf(error, sizeof(error),
- _("Unable to open %s\n"), disk_device);
- break;
+ err(EXIT_FAILURE, _("unable to open %s"), disk_device);
+
case unable_to_read:
- snprintf(error, sizeof(error),
- _("Unable to read %s\n"), disk_device);
- break;
+ err(EXIT_FAILURE, _("unable to read %s"), disk_device);
+
case unable_to_seek:
- snprintf(error, sizeof(error),
- _("Unable to seek on %s\n"),disk_device);
- break;
+ err(EXIT_FAILURE, _("unable to seek on %s"), disk_device);
+
case unable_to_write:
- snprintf(error, sizeof(error),
- _("Unable to write %s\n"), disk_device);
- break;
+ err(EXIT_FAILURE, _("unable to write %s"), disk_device);
+
case ioctl_error:
- snprintf(error, sizeof(error),
- _("BLKGETSIZE ioctl failed on %s\n"),
- disk_device);
- break;
+ err(EXIT_FAILURE, _("BLKGETSIZE ioctl failed on %s"), disk_device);
+
default:
- message = _("Fatal error\n");
+ err(EXIT_FAILURE, _("fatal error"));
}
-
- fputc('\n', stderr);
- fputs(message, stderr);
- exit(rc);
}
static void