Changeset 3185 in MondoRescue for branches/3.0/mondo/src/common/libmondo-stream.c
- Timestamp:
- Sep 20, 2013, 2:29:57 PM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/3.0/mondo/src/common/libmondo-stream.c
r3150 r3185 242 242 int res; 243 243 244 mr_asprintf( &command, "mt -f %s status", dev);244 mr_asprintf(command, "mt -f %s status", dev); 245 245 res = run_program_and_log_output(command, 1); 246 246 mr_free(command); … … 276 276 strcpy(cdr_exe, "dvdrecord"); 277 277 } 278 mr_asprintf( &command, "%s -scanbus 2> /dev/null | grep -i tape | wc -l",278 mr_asprintf(command, "%s -scanbus 2> /dev/null | grep -i tape | wc -l", 279 279 cdr_exe); 280 280 strcpy(tmp, call_program_and_get_last_line_of_output(command)); … … 287 287 return 1; 288 288 } 289 mr_asprintf( &command,289 mr_asprintf(command, 290 290 "%s -scanbus 2> /dev/null | tr -s '\t' ' ' | grep \"[0-9]*,[0-9]*,[0-9]*\" | grep -v \"[0-9]*) \\*\" | grep -i TAPE | cut -d' ' -f2 | head -n1", 291 291 cdr_exe); … … 297 297 return 1; 298 298 } 299 mr_asprintf( &command,299 mr_asprintf(command, 300 300 "%s -scanbus 2> /dev/null | tr -s '\t' ' ' | grep \"[0-9]*,[0-9]*,[0-9]*\" | grep -v \"[0-9]*) \\*\" | grep -i TAPE | cut -d' ' -f3 | cut -d')' -f1 | head -n1", 301 301 cdr_exe); … … 383 383 } 384 384 if (strstr(fname, "xattr") == NULL) { 385 mr_asprintf( &tmp,"Wrong order expected xattr, got %s, sunshine.", fname);385 mr_asprintf(tmp,"Wrong order expected xattr, got %s, sunshine.", fname); 386 386 fatal_error(tmp); 387 387 } … … 413 413 } 414 414 if (strstr(fname, "acl") == NULL) { 415 mr_asprintf( &tmp,"Wrong order expected acl, got %s, sunshine.", fname);415 mr_asprintf(tmp,"Wrong order expected acl, got %s, sunshine.", fname); 416 416 fatal_error(tmp); 417 417 } … … 479 479 log_it("Insisting on tape #%d", tapeno); 480 480 if (g_current_media_number != tapeno) { 481 mr_asprintf( &tmp,481 mr_asprintf(tmp, 482 482 "When the tape drive goes quiet, please insert volume %d in this series.", 483 483 tapeno); … … 549 549 suffix[0] = '\0'; 550 550 } 551 mr_asprintf( &tmpdir, "%s/tmpfs/backcatalog", td);551 mr_asprintf(tmpdir, "%s/tmpfs/backcatalog", td); 552 552 mkdir(tmpdir, 0x700); 553 mr_asprintf( &command, "cp -f %s %s", latest_fname, tmpdir);553 mr_asprintf(command, "cp -f %s %s", latest_fname, tmpdir); 554 554 if (run_program_and_log_output(command, 6)) { 555 555 log_it("Warning - failed to copy %s to backcatalog at %s", … … 579 579 580 580 for (i = curr - 1; i >= 0 && curr - i < 10; i--) { 581 mr_asprintf( &old_fname, "%s/%s", tmpdir, g_tapecatalog->el[i].fname);581 mr_asprintf(old_fname, "%s/%s", tmpdir, g_tapecatalog->el[i].fname); 582 582 unlink(old_fname); 583 583 mr_free(old_fname); … … 619 619 return (0); 620 620 } 621 mr_asprintf( &tmp, "mt -f %s setblk %ld", bkpinfo->media_device, internal_tape_block_size);621 mr_asprintf(tmp, "mt -f %s setblk %ld", bkpinfo->media_device, internal_tape_block_size); 622 622 res = run_program_and_log_output(tmp, 3); 623 623 mr_free(tmp); … … 688 688 689 689 log_it("Skipping OBDR headers"); 690 mr_asprintf( &command, "mt -f %s rewind",bkpinfo->media_device);690 mr_asprintf(command, "mt -f %s rewind",bkpinfo->media_device); 691 691 res = run_program_and_log_output(command, 1); 692 692 paranoid_free(command); 693 693 694 mr_asprintf( &command, "mt -f %s fsf 2",bkpinfo->media_device);694 mr_asprintf(command, "mt -f %s fsf 2",bkpinfo->media_device); 695 695 res = run_program_and_log_output(command, 1); 696 696 paranoid_free(command); … … 715 715 log_it("Creating OBDR headers"); 716 716 /* OBDR: First block 10 kB of zero bs = 512 */ 717 mr_asprintf( &command, "mt -f %s compression off",bkpinfo->media_device);717 mr_asprintf(command, "mt -f %s compression off",bkpinfo->media_device); 718 718 res = run_program_and_log_output(command, 1); 719 719 paranoid_free(command); 720 720 721 mr_asprintf( &command, "mt -f %s rewind",bkpinfo->media_device);721 mr_asprintf(command, "mt -f %s rewind",bkpinfo->media_device); 722 722 res += run_program_and_log_output(command, 1); 723 723 paranoid_free(command); … … 725 725 set_tape_block_size_with_mt(512); 726 726 727 mr_asprintf( &command, "dd if=/dev/zero of=%s bs=512 count=20",bkpinfo->media_device);727 mr_asprintf(command, "dd if=/dev/zero of=%s bs=512 count=20",bkpinfo->media_device); 728 728 res += run_program_and_log_output(command, 1); 729 729 paranoid_free(command); … … 732 732 set_tape_block_size_with_mt(2048); 733 733 734 mr_asprintf( &command, "dd if=%s of=%s bs=2048",MINDI_CACHE"/mondorescue.iso",bkpinfo->media_device);734 mr_asprintf(command, "dd if=%s of=%s bs=2048",MINDI_CACHE"/mondorescue.iso",bkpinfo->media_device); 735 735 res += run_program_and_log_output(command, 1); 736 736 paranoid_free(command); … … 739 739 740 740 /* restore compression mode on */ 741 mr_asprintf( &command, "mt -f %s compression on",bkpinfo->media_device);741 mr_asprintf(command, "mt -f %s compression on",bkpinfo->media_device); 742 742 res = run_program_and_log_output(command, 1); 743 743 paranoid_free(command); … … 805 805 806 806 insist_on_this_tape_number(1); 807 mr_asprintf( &outfname, "%s/tmp/all.tar.gz", bkpinfo->tmpdir);807 mr_asprintf(outfname, "%s/tmp/all.tar.gz", bkpinfo->tmpdir); 808 808 make_hole_for_file(outfname); 809 809 … … 874 874 // FIXME 875 875 } 876 mr_asprintf( &tmp, "tar -zxf %s ./tmp/mondo-restore.cfg 2> /dev/null",876 mr_asprintf(tmp, "tar -zxf %s ./tmp/mondo-restore.cfg 2> /dev/null", 877 877 outfname); 878 878 paranoid_system(tmp); … … 904 904 905 905 /* add 'dummy' if testing */ 906 mr_asprintf( &command, "cdrecord -eject dev=%s speed=%d fs=24m -waiti - >> %s 2>> %s", cddev, speed, MONDO_LOGFILE, MONDO_LOGFILE);906 mr_asprintf(command, "cdrecord -eject dev=%s speed=%d fs=24m -waiti - >> %s 2>> %s", cddev, speed, MONDO_LOGFILE, MONDO_LOGFILE); 907 907 /* initialise the catalog */ 908 908 g_current_media_number = 1; … … 1078 1078 } 1079 1079 if (orig_size != temp_size && orig_size != -1) { 1080 mr_asprintf( &tmp, "output file's size should be %ld K but is apparently %ld K", (long) size >> 10, (long) temp_size >> 10);1080 mr_asprintf(tmp, "output file's size should be %ld K but is apparently %ld K", (long) size >> 10, (long) temp_size >> 10); 1081 1081 log_to_screen(tmp); 1082 1082 mr_free(tmp); … … 1141 1141 log_msg(6, ".......................... Should be %lld", orig_size); 1142 1142 g_tape_posK += total_read_from_tape_for_this_file / 1024; 1143 mr_asprintf( &actual_cksum, "%04x%04x", crc16, crctt);1143 mr_asprintf(actual_cksum, "%04x%04x", crc16, crctt); 1144 1144 if (foutstream) { /*log_it("Finished writing to foutstream"); */ 1145 1145 } else { … … 1151 1151 } 1152 1152 if (strcmp(temp_cksum, actual_cksum)) { 1153 mr_asprintf( &tmp, "actual cksum=%s; recorded cksum=%s", actual_cksum,1153 mr_asprintf(tmp, "actual cksum=%s; recorded cksum=%s", actual_cksum, 1154 1154 temp_cksum); 1155 1155 log_to_screen(tmp); 1156 1156 mr_free(tmp); 1157 1157 1158 mr_asprintf( &tmp, "%s (%ld K) is corrupt on tape", temp_fname,1158 mr_asprintf(tmp, "%s (%ld K) is corrupt on tape", temp_fname, 1159 1159 (long) orig_size >> 10); 1160 1160 log_to_screen(tmp); … … 1494 1494 insist_on_this_tape_number(g_current_media_number + 1); // will increment g_current_media, too 1495 1495 if (bkpinfo->backup_media_type == cdstream) { 1496 mr_asprintf( &command,1496 mr_asprintf(command, 1497 1497 "cdrecord -eject dev=%s speed=%d fs=24m -waiti - >> %s 2>> %s", 1498 1498 bkpinfo->media_device, bkpinfo->cdrw_speed, MONDO_LOGFILE, … … 1549 1549 last = g_tapecatalog->entries - 1; 1550 1550 for (i = 0; i <= last; i++) { 1551 mr_asprintf( &fname, "%s/tmpfs/backcatalog/%s", bkpinfo->tmpdir, g_tapecatalog->el[i].fname);1551 mr_asprintf(fname, "%s/tmpfs/backcatalog/%s", bkpinfo->tmpdir, g_tapecatalog->el[i].fname); 1552 1552 if (!does_file_exist(fname)) { 1553 1553 log_msg(6, "Can't write %s - it doesn't exist.", fname); … … 1602 1602 log_it("Data disks = %s", fname); 1603 1603 if (!does_file_exist(fname)) { 1604 mr_asprintf( &tmp, "Cannot find %s", fname);1604 mr_asprintf(tmp, "Cannot find %s", fname); 1605 1605 log_to_screen(tmp); 1606 1606 mr_free(tmp); … … 1700 1700 p++; 1701 1701 } 1702 mr_asprintf( &tmp, "Writing file '%s' to tape (%ld KB)", p,1702 mr_asprintf(tmp, "Writing file '%s' to tape (%ld KB)", p, 1703 1703 (long) filesize >> 10); 1704 1704 log_it(tmp); … … 1745 1745 } 1746 1746 paranoid_fclose(fin); 1747 mr_asprintf( &checksum, "%04x%04x", crc16, crctt);1747 mr_asprintf(checksum, "%04x%04x", crc16, crctt); 1748 1748 /* BERLIOS: what does it do ??? */ 1749 1749 write_header_block_to_stream((off_t)g_current_media_number, checksum, BLK_STOP_FILE); … … 1808 1808 fwrite(tempblock, 1, (size_t) TAPE_BLOCK_SIZE, 1809 1809 g_tape_stream) / 1024; 1810 mr_asprintf( &tmp, "%s (fname=%s, size=%ld K)",1810 mr_asprintf(tmp, "%s (fname=%s, size=%ld K)", 1811 1811 marker_to_string(control_char), p, 1812 1812 (long) length_of_incoming_file >> 10); … … 1837 1837 1838 1838 /*@ end vars *************************************************** */ 1839 mr_asprintf( &tmp, "Wrong marker! (Should be %s, is actually %s)", marker_to_string(should_be), marker_to_string(it_is));1839 mr_asprintf(tmp, "Wrong marker! (Should be %s, is actually %s)", marker_to_string(should_be), marker_to_string(it_is)); 1840 1840 log_to_screen(tmp); 1841 1841 mr_free(tmp);
Note:
See TracChangeset
for help on using the changeset viewer.