X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=restore-src%2Frestore.c;h=9cede42df06a317c68eb7c37853bb8a55be83139;hb=6184f063dbd574df9013211bfb9b4ffaeacb5e85;hp=da4e5f7aef50ca616b779d541a1510e5d8c5d641;hpb=cdbbeef9cde260e429854dd313bc0bf7560e1e24;p=debian%2Famanda diff --git a/restore-src/restore.c b/restore-src/restore.c index da4e5f7..9cede42 100644 --- a/restore-src/restore.c +++ b/restore-src/restore.c @@ -98,7 +98,7 @@ char *label_of_current_slot(char *cur_tapedev, FILE *prompt_out, int load_next_tape(char **cur_tapedev, FILE *prompt_out, int backwards, rst_flags_t *flags, am_feature_t *their_features, tapelist_t *desired_tape); -int load_manual_tape(char **cur_tapedev, FILE *prompt_out, +int load_manual_tape(char **cur_tapedev, FILE *prompt_out, FILE *prompt_in, rst_flags_t *flags, am_feature_t *their_features, tapelist_t *desired_tape); void search_a_tape(char *cur_tapedev, FILE *prompt_out, rst_flags_t *flags, @@ -231,7 +231,7 @@ append_file_to_fd( error("restore: write error = %s", strerror(errno)); /*NOTREACHED*/ } - error("Short write: wrote %d bytes expected %d.", s, bytes_read); + error("Short write: wrote " SSIZE_T_FMT " bytes expected " SSIZE_T_FMT ".", s, bytes_read); /*NOTREACHCED*/ } wc += (off_t)bytes_read; @@ -647,7 +647,7 @@ read_file_header( fprintf(stderr, "%s: error reading file header: %s\n", get_pname(), strerror(errno)); file->type = F_UNKNOWN; - } else if((size_t)bytes_read < blocksize) { + } else if((size_t)bytes_read < DISK_BLOCK_BYTES) { if(bytes_read == 0) { fprintf(stderr, "%s: missing file header block\n", get_pname()); } else { @@ -819,8 +819,8 @@ restore( amfree(tmp_filename); tmp_filename = tmpstr; } - final_filename = stralloc(tmp_filename); - tmp_filename = newvstralloc(tmp_filename, ".tmp", NULL); + final_filename = tmp_filename; + tmp_filename = vstralloc(final_filename, ".tmp", NULL); if((dest = open(tmp_filename, (O_CREAT | O_RDWR | O_TRUNC), CREAT_MODE)) < 0) { error("could not create output file %s: %s", @@ -882,7 +882,7 @@ restore( error("write error: %s", strerror(errno)); /*NOTREACHED*/ } else { - error("write error: %d instead of %d", w, DISK_BLOCK_BYTES); + error("write error: " SSIZE_T_FMT " instead of %d", w, DISK_BLOCK_BYTES); /*NOTREACHED*/ } } @@ -902,7 +902,8 @@ restore( || file->type != F_SPLIT_DUMPFILE)) need_uncompress=1; - if(!flags->raw && file->encrypted) + if(!flags->raw && file->encrypted && !is_continuation + && (flags->inline_assemble || file->type != F_SPLIT_DUMPFILE)) need_decrypt=1; /* Setup pipes for decryption / compression / uncompression */ @@ -1093,7 +1094,7 @@ restore( error("restore: write error: %s", strerror(errno)); /* NOTREACHED */ } else if (s < bytes_read) { - error("restore: wrote %d of %d bytes: %s", + error("restore: wrote " SSIZE_T_FMT " of " SSIZE_T_FMT " bytes: %s", s, bytes_read, strerror(errno)); /* NOTREACHED */ } @@ -1349,6 +1350,7 @@ int load_manual_tape( char **cur_tapedev, FILE *prompt_out, + FILE *prompt_in, rst_flags_t *flags, am_feature_t *their_features, tapelist_t *desired_tape) @@ -1363,7 +1365,7 @@ load_manual_tape( fprintf(prompt_out, "FEEDME %s\r\n", desired_tape->label); fflush(prompt_out); - input = agets(stdin);/* Strips \n but not \r */ + input = agets(prompt_in);/* Strips \n but not \r */ if(!input) { error("Connection lost with amrecover"); /*NOTREACHED*/ @@ -1399,7 +1401,7 @@ load_manual_tape( "enter, ^D to finish reading tapes\n"); } fflush(prompt_out); - if((input = agets(stdin)) == NULL) + if((input = agets(prompt_in)) == NULL) ret = -1; } @@ -1672,6 +1674,7 @@ search_a_tape( void search_tapes( FILE * prompt_out, + FILE *prompt_in, int use_changer, tapelist_t * tapelist, match_list_t * match_list, @@ -1690,13 +1693,14 @@ search_tapes( seentapes_t *seentapes = NULL; int ret; - dbprintf(("search_tapes(prompt=%p, use_changer=%d, tapelist=%p, " - "match_list=%p, flags=%p, features=%p)\n", - prompt_out, use_changer, tapelist, match_list, - flags, their_features)); - if(!prompt_out) prompt_out = stderr; + dbprintf(("search_tapes(prompt_out=%d, prompt_in=%d, use_changer=%d, " + "tapelist=%p, " + "match_list=%p, flags=%p, features=%p)\n", + fileno(prompt_out), fileno(prompt_in), use_changer, tapelist, + match_list, flags, their_features)); + if(flags->blocksize) blocksize = (size_t)flags->blocksize; else if(blocksize == (size_t)SSIZE_MAX) @@ -1728,8 +1732,14 @@ search_tapes( /* Suss what tape device we're using, whether there's a changer, etc. */ if(!use_changer || (have_changer = changer_init()) == 0) { - if(flags->alt_tapedev) cur_tapedev = stralloc(flags->alt_tapedev); - else if(!cur_tapedev) cur_tapedev = getconf_str(CNF_TAPEDEV); + if (flags->alt_tapedev) { + cur_tapedev = stralloc(flags->alt_tapedev); + } else if(!cur_tapedev) { + cur_tapedev = getconf_str(CNF_TAPEDEV); + if (cur_tapedev == NULL) { + error("No tapedev specified"); + } + } /* XXX oughta complain if no config is loaded */ fprintf(stderr, "%s: Using tapedev %s\n", get_pname(), cur_tapedev); have_changer = 0; @@ -1759,7 +1769,7 @@ search_tapes( char *input = NULL; fprintf(prompt_out,"Press enter when ready\n"); fflush(prompt_out); - input = agets(stdin); + input = agets(prompt_in); amfree(input); fprintf(prompt_out, "\n"); fflush(prompt_out); @@ -1841,7 +1851,7 @@ search_tapes( } if (label == NULL) { - ret = load_manual_tape(&cur_tapedev, prompt_out, + ret = load_manual_tape(&cur_tapedev, prompt_out, prompt_in, flags, their_features, desired_tape); if (ret == 0) {