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,
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;
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 {
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",
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*/
}
}
|| 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 */
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 */
}
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)
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*/
"enter, ^D to finish reading tapes\n");
}
fflush(prompt_out);
- if((input = agets(stdin)) == NULL)
+ if((input = agets(prompt_in)) == NULL)
ret = -1;
}
void
search_tapes(
FILE * prompt_out,
+ FILE *prompt_in,
int use_changer,
tapelist_t * tapelist,
match_list_t * match_list,
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)
/* 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;
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);
}
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) {