X-Git-Url: https://git.gag.com/?a=blobdiff_plain;ds=sidebyside;f=restore-src%2Famrestore.c;h=aef4bafda198f8936f54f31ce99c05ec842394d5;hb=2627875b7d18858bc1f9f7652811e4d8c15a23eb;hp=d9f285bce6474b4e8020d8a9a07be00a5f87a818;hpb=94a044f90357edefa6f4ae9f0b1d5885b0e34aee;p=debian%2Famanda diff --git a/restore-src/amrestore.c b/restore-src/amrestore.c index d9f285b..aef4baf 100644 --- a/restore-src/amrestore.c +++ b/restore-src/amrestore.c @@ -96,29 +96,33 @@ static void handle_holding_disk_restore(char * filename, rst_flags_t * flags, static void handle_tape_restore(char * device_name, rst_flags_t * flags, GSList * dumpspecs, char * check_label) { Device * device; - ReadLabelStatusFlags read_label_status; + DeviceStatusFlags device_status; + + dumpfile_t first_restored_file; device_api_init(); + + fh_init(&first_restored_file); device = device_open(device_name); - if (device == NULL) { - error("Could not open device.\n"); + g_assert(device != NULL); + if (device->status != DEVICE_STATUS_SUCCESS) { + error("Could not open device %s: %s.\n", device_name, device_error(device)); } - device_set_startup_properties_from_config(device); - read_label_status = device_read_label(device); - if (read_label_status != READ_LABEL_STATUS_SUCCESS) { - char * errstr = - g_english_strjoinv_and_free - (g_flags_nick_to_strv(read_label_status, - READ_LABEL_STATUS_FLAGS_TYPE), "or"); - error("Error reading volume label: %s.\n", errstr); + if (!set_restore_device_read_buffer_size(device, flags)) { + error("Error setting read block size: %s.\n", device_error_or_status(device)); + } + device_status = device_read_label(device); + if (device_status != DEVICE_STATUS_SUCCESS) { + error("Error reading volume label: %s.\n", device_error_or_status(device)); } g_assert(device->volume_label != NULL); if (!device_start(device, ACCESS_READ, NULL, NULL)) { - error("Could not open device %s for reading.\n", device_name); + error("Could not open device %s for reading: %s.\n", device_name, + device_error(device)); } if (check_label != NULL && strcmp(check_label, @@ -128,7 +132,7 @@ static void handle_tape_restore(char * device_name, rst_flags_t * flags, } search_a_tape(device, stderr, flags, NULL, NULL, dumpspecs, - NULL, NULL, 0, NULL); + NULL, &first_restored_file, 0, NULL); } /* @@ -188,17 +192,7 @@ main( } else if(*e == 'm' || *e == 'M') { rst_flags->blocksize *= 1024 * 1024; } else if(*e != '\0') { - error(_("invalid rst_flags->blocksize value \"%s\""), optarg); - /*NOTREACHED*/ - } - if(rst_flags->blocksize < DISK_BLOCK_BYTES) { - error(_("minimum block size is %dk"), DISK_BLOCK_BYTES / 1024); - /*NOTREACHED*/ - } - if(rst_flags->blocksize > MAX_TAPE_BLOCK_KB * 1024) { - g_fprintf(stderr,_("maximum block size is %dk, using it\n"), - MAX_TAPE_BLOCK_KB); - rst_flags->blocksize = MAX_TAPE_BLOCK_KB * 1024; + error(_("invalid blocksize value \"%s\""), optarg); /*NOTREACHED*/ } break; @@ -222,6 +216,9 @@ main( /*@end@*/ break; case 'l': + if (label) { + error(_("Cannot specify multiple labels.\n")); + } label = stralloc(optarg); break; default: @@ -230,9 +227,16 @@ main( } /* initialize a generic configuration without reading anything */ - config_init(CONFIG_INIT_CLIENT, NULL); + config_init(0, NULL); apply_config_overwrites(cfg_ovr); + if (config_errors(NULL) >= CFGERR_WARNINGS) { + config_print_errors(); + if (config_errors(NULL) >= CFGERR_ERRORS) { + g_critical(_("errors processing config file")); + } + } + if(rst_flags->compress && rst_flags->raw) { g_fprintf(stderr, _("Cannot specify both -r (raw) and -c (compressed) output.\n"));