-static void errexit P((void));
-static void usage P((void));
-int main P((int argc, char **argv));
+static void errexit(void);
+static void usage(void);
+int main(int argc, char **argv);
- error("Usage: amrestore [-b blocksize] [-r|-c] [-p] [-h] [-f fileno] [-l label] tape-device|holdingfile [hostname [diskname [datestamp [hostname [diskname [datestamp ... ]]]]]]");
+ error("Usage: amrestore [-b blocksize] [-r|-c] [-p] [-h] [-f fileno] "
+ "[-l label] tape-device|holdingfile [hostname [diskname [datestamp "
+ "[hostname [diskname [datestamp ... ]]]]]]");
+ /*NOTREACHED*/
/*
* Parses command line, then loops through all files on tape, restoring
* files that match the command line criteria.
*/
/*
* Parses command line, then loops through all files on tape, restoring
* files that match the command line criteria.
*/
/* Don't die when child closes pipe */
signal(SIGPIPE, SIG_IGN);
/* Don't die when child closes pipe */
signal(SIGPIPE, SIG_IGN);
- rst_flags->blocksize = strtol(optarg, &e, 10);
+ tmplong = strtol(optarg, &e, 10);
+ rst_flags->blocksize = (ssize_t)tmplong;
if(*e == 'k' || *e == 'K') {
rst_flags->blocksize *= 1024;
} else if(*e == 'm' || *e == 'M') {
rst_flags->blocksize *= 1024 * 1024;
} else if(*e != '\0') {
error("invalid rst_flags->blocksize value \"%s\"", optarg);
if(*e == 'k' || *e == 'K') {
rst_flags->blocksize *= 1024;
} else if(*e == 'm' || *e == 'M') {
rst_flags->blocksize *= 1024 * 1024;
} else if(*e != '\0') {
error("invalid rst_flags->blocksize value \"%s\"", optarg);
}
if(rst_flags->blocksize < DISK_BLOCK_BYTES) {
error("minimum block size is %dk", DISK_BLOCK_BYTES / 1024);
}
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) {
+ fprintf(stderr,"maximum block size is %dk, using it\n",
+ MAX_TAPE_BLOCK_KB);
+ rst_flags->blocksize = MAX_TAPE_BLOCK_KB * 1024;
+ /*NOTREACHED*/
match_list->hostname = "";
match_list->diskname = "";
match_list->datestamp = "";
match_list->hostname = "";
match_list->diskname = "";
match_list->datestamp = "";
if(tape_stat(tapename,&stat_tape)!=0) {
error("could not stat %s: %s", tapename, strerror(errno));
if(tape_stat(tapename,&stat_tape)!=0) {
error("could not stat %s: %s", tapename, strerror(errno));
else {
if((err = tape_rewind(tapename)) != NULL) {
error("Could not rewind device '%s': %s", tapename, err);
else {
if((err = tape_rewind(tapename)) != NULL) {
error("Could not rewind device '%s': %s", tapename, err);
}
if ((tapedev = tape_open(tapename, 0)) == -1) {;
error("Could not open device '%s': %s", tapename, err);
}
if ((tapedev = tape_open(tapename, 0)) == -1) {;
error("Could not open device '%s': %s", tapename, err);
}
read_file_header(&file, tapedev, isafile, rst_flags);
if(file.type != F_TAPESTART) {
}
read_file_header(&file, tapedev, isafile, rst_flags);
if(file.type != F_TAPESTART) {
tapefd_close(tapedev);
if((err = tape_rewind(tapename)) != NULL) {
error("Could not rewind device '%s': %s", tapename, err);
tapefd_close(tapedev);
if((err = tape_rewind(tapename)) != NULL) {
error("Could not rewind device '%s': %s", tapename, err);
else {
if((err = tape_rewind(tapename)) != NULL) {
error("Could not rewind device '%s': %s", tapename, err);
else {
if((err = tape_rewind(tapename)) != NULL) {
error("Could not rewind device '%s': %s", tapename, err);
- read_file_header(&file, tapedev, isafile, rst_flags);
-
- if(file.type != F_TAPESTART && !isafile && filefsf == -1) {
+ read_result = read_file_header(&file, tapedev, isafile, rst_flags);
+ if(file.type != F_TAPESTART && !isafile && filefsf == (off_t)-1) {
fprintf(stderr, "%s: WARNING: not at start of tape, file numbers will be offset\n",
get_pname());
}
fprintf(stderr, "%s: WARNING: not at start of tape, file numbers will be offset\n",
get_pname());
}
found_match ? "restoring" : "skipping");
if(file.type != F_DUMPFILE && file.type != F_SPLIT_DUMPFILE) {
print_header(stderr, &file);
found_match ? "restoring" : "skipping");
if(file.type != F_DUMPFILE && file.type != F_SPLIT_DUMPFILE) {
print_header(stderr, &file);
tapefd_close(tapedev);
if((tapedev = tape_open(tapename, 0)) < 0) {
error("could not open %s: %s", tapename, strerror(errno));
tapefd_close(tapedev);
if((tapedev = tape_open(tapename, 0)) < 0) {
error("could not open %s: %s", tapename, strerror(errno));
* If the last read got something (even an error), we can
* do an fsf to get to the next file.
*/
* If the last read got something (even an error), we can
* do an fsf to get to the next file.
*/
- read_file_header(&file, tapedev, isafile, rst_flags);
+ read_result = read_file_header(&file, tapedev, isafile, rst_flags);
tapefd_close(tapedev);
if((tapedev = tape_open(tapename, 0)) < 0) {
error("could not open %s: %s", tapename, strerror(errno));
tapefd_close(tapedev);
if((tapedev = tape_open(tapename, 0)) < 0) {
error("could not open %s: %s", tapename, strerror(errno));
- fprintf(stderr, "%s: %3d: reached ", get_pname(), file_number);
+ fprintf(stderr, "%s: " OFF_T_FMT ": reached ",
+ get_pname(), (OFF_T_FMT_TYPE)file_number);