Changeset 2296 in MondoRescue for branches/2.2.10/mondo/src/mondorestore
- Timestamp:
- Jul 23, 2009, 2:53:30 PM (16 years ago)
- Location:
- branches/2.2.10/mondo/src/mondorestore
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2.2.10/mondo/src/mondorestore/mondo-prep.c
r2291 r2296 79 79 make_list_of_drives_in_mountlist(mountlist, drivelist); 80 80 for (lino = 0; lino < drivelist->entries; lino++) { 81 mr_asprintf(&command, 82 "dd if=%s bs=512 count=1 2> /dev/null | grep \"%s\"", 83 drivelist->el[lino].device, MONDO_WAS_HERE); 81 mr_asprintf(&command, "dd if=%s bs=512 count=1 2> /dev/null | grep \"%s\"", drivelist->el[lino].device, MONDO_WAS_HERE); 84 82 res = run_program_and_log_output(command, 1); 85 83 mr_free(command); … … 260 258 strcpy(vgremove_sz, "vgremove"); 261 259 } 262 mr_asprintf(&tmp1, 263 "for i in `%s | cut -d\"'\" -f2 | sort -r` ; do echo \"Shutting down lv $i\" >> %s ; %s -f $i; done", lvscan_sz, MONDO_LOGFILE, lvremove_sz); 260 mr_asprintf(&tmp1, "for i in `%s | cut -d\"'\" -f2 | sort -r` ; do echo \"Shutting down lv $i\" >> %s ; %s -f $i; done", lvscan_sz, MONDO_LOGFILE, lvremove_sz); 264 261 run_program_and_log_output(tmp1, 5); 265 262 mr_free(tmp1); … … 521 518 new_mountlist->entries++; 522 519 } else { 523 mr_asprintf(&tmp, 524 "Not adding %s to mountlist: it's already there", 525 p); 520 mr_asprintf(&tmp, "Not adding %s to mountlist: it's already there", p); 526 521 log_it(tmp); 527 522 mr_free(tmp); … … 647 642 mr_asprintf(&strtmp, "%s", program); 648 643 paranoid_free(program); 649 mr_asprintf(&program, "%s --spare-devices=%d", strtmp, 650 raidlist->el[i].spare_disks.entries); 644 mr_asprintf(&program, "%s --spare-devices=%d", strtmp, raidlist->el[i].spare_disks.entries); 651 645 paranoid_free(strtmp); 652 646 } … … 747 741 748 742 /* format raid partition */ 749 mr_asprintf(&program, 750 "for plex in `vinum lv -r %s | grep '^P' | tr '\t' ' ' | tr -s ' ' | cut -d' ' -f2`; do echo $plex; done > /tmp/plexes", basename(device)); 743 mr_asprintf(&program, "for plex in `vinum lv -r %s | grep '^P' | tr '\t' ' ' | tr -s ' ' | cut -d' ' -f2`; do echo $plex; done > /tmp/plexes", basename(device)); 751 744 system(program); 752 745 if (g_fprep) { … … 914 907 915 908 assert(mountlist != NULL); 916 mr_asprintf(&tmp, "format_everything (mountlist, interactively = %s", 917 (interactively) ? "true" : "false"); 909 mr_asprintf(&tmp, "format_everything (mountlist, interactively = %s", (interactively) ? "true" : "false"); 918 910 log_it(tmp); 919 911 mr_free(tmp); … … 943 935 if (interactively) { 944 936 // ask user if we should format the current device 945 mr_asprintf(&tmp, "Shall I format %s (%s) ?", me->device, 946 me->mountpoint); 937 mr_asprintf(&tmp, "Shall I format %s (%s) ?", me->device, me->mountpoint); 947 938 do_it = ask_me_yes_or_no(tmp); 948 939 mr_free(tmp); … … 1425 1416 mr_free(command); 1426 1417 1427 mr_asprintf(&command, "disklabel -R %s /tmp/disklabel", 1428 canonical_name(drivename)); 1418 mr_asprintf(&command, "disklabel -R %s /tmp/disklabel", canonical_name(drivename)); 1429 1419 retval += run_program_and_log_output(command, TRUE); 1430 1420 mr_free(command); … … 1571 1561 file = open(drivename, O_WRONLY); 1572 1562 if (file != -1) { 1573 mr_asprintf(&tmp, 1574 "Warning - unable to open %s for wiping it's partition table", 1575 drivename); 1563 mr_asprintf(&tmp, "Warning - unable to open %s for wiping it's partition table", drivename); 1576 1564 log_to_screen(tmp); 1577 1565 mr_free(tmp); … … 1580 1568 for (i = 0; i < 512; i++) { 1581 1569 if (!write(file, "\0", 1)) { 1582 mr_asprintf(&tmp, "Warning - unable to write to %s", 1583 drivename); 1570 mr_asprintf(&tmp, "Warning - unable to write to %s", drivename); 1584 1571 log_to_screen(tmp); 1585 1572 mr_free(tmp); … … 1642 1629 if (pout_to_fdisk) { 1643 1630 // mark relevant partition as bootable 1644 mr_asprintf(&tmp, "a\n%s\n", 1645 call_program_and_get_last_line_of_output 1646 ("make-me-bootable /tmp/mountlist.txt dummy")); 1631 mr_asprintf(&tmp, "a\n%s\n", call_program_and_get_last_line_of_output("make-me-bootable /tmp/mountlist.txt dummy")); 1647 1632 fput_string_one_char_at_a_time(pout_to_fdisk, tmp); 1648 1633 mr_free(tmp); … … 1739 1724 1740 1725 if (is_this_device_mounted(partition_name)) { 1741 mr_asprintf(&tmp, "%s is mounted, and should not be partitioned", 1742 partition_name); 1726 mr_asprintf(&tmp, "%s is mounted, and should not be partitioned", partition_name); 1743 1727 log_to_screen(tmp); 1744 1728 mr_free(tmp); … … 2050 2034 } else { 2051 2035 /* probably an image */ 2052 mr_asprintf(&tmp, 2053 "Unknown format ('%s') - using supplied string anyway", 2054 format); 2036 mr_asprintf(&tmp, "Unknown format ('%s') - using supplied string anyway", format); 2055 2037 mvaddstr_and_log_it(g_currentY++, 0, tmp); 2056 2038 mr_free(tmp); -
branches/2.2.10/mondo/src/mondorestore/mondo-rstr-compare.c
r2291 r2296 47 47 char *bigfile_fname_ptr; 48 48 char *tmp_ptr = NULL; 49 char *command_ptr ;49 char *command_ptr = NULL; 50 50 51 51 char *checksum, *original_cksum, *bigfile_fname, *tmp, *command; … … 65 65 malloc_string(original_cksum_ptr); 66 66 malloc_string(bigfile_fname_ptr); 67 malloc_string(command_ptr);68 67 69 68 /********************************************************************* … … 74 73 memset(original_cksum_ptr, '\0', sizeof(original_cksum)); 75 74 memset(bigfile_fname_ptr, '\0', sizeof(bigfile_fname)); 76 memset(command_ptr, '\0', sizeof(command));77 75 /** end **/ 78 76 … … 113 111 if (!strncmp(bigfile_fname_ptr, "/dev/", 5)) { 114 112 strcpy(original_cksum_ptr, "IGNORE"); 115 } else {116 sprintf(command_ptr,117 "md5sum \"%s%s\" > /tmp/md5sum.txt 2> /tmp/errors",118 MNT_RESTORING, bigfile_fname_ptr); 119 }113 log_msg(2, "IGNORING %s as begining with /dev", bigfile_fname_ptr); 114 return (1); 115 } 116 117 mr_asprintf(&command_ptr, "md5sum \"%s%s\" > /tmp/md5sum.txt 2> /tmp/errors", MNT_RESTORING, bigfile_fname_ptr); 120 118 log_msg(2, command_ptr); 119 i = system(command_ptr); 120 mr_free(command_ptr); 121 121 122 mr_asprintf(&tmp_ptr, "cat /tmp/errors >> %s 2> /dev/null", MONDO_LOGFILE); 122 123 paranoid_system(tmp_ptr); 123 124 paranoid_free(tmp_ptr); 124 125 125 if ( system(command_ptr)) {126 if (i) { 126 127 log_OS_error("Warning - command failed"); 127 128 original_cksum[0] = '\0'; … … 169 170 paranoid_free(checksum_ptr); 170 171 paranoid_free(checksum); 171 paranoid_free(command_ptr);172 172 paranoid_free(command); 173 173 paranoid_free(tmp); … … 190 190 int res; 191 191 long noof_biggiefiles, bigfileno = 0; 192 char tmp[MAX_STR_LEN];192 char *tmp = NULL; 193 193 194 194 log_msg(1, "Comparing biggiefiles"); … … 211 211 noof_biggiefiles); 212 212 for (bigfileno = 0; bigfileno < noof_biggiefiles; bigfileno++) { 213 sprintf(tmp, "Comparing big file #%ld", bigfileno + 1);213 mr_asprintf(&tmp, "Comparing big file #%ld", bigfileno + 1); 214 214 log_msg(1, tmp); 215 215 update_progress_form(tmp); 216 mr_free(tmp); 217 216 218 res = compare_a_biggiefile(bigfileno); 217 219 retval += res; … … 250 252 251 253 /*** needs malloc *********/ 252 char *command , *tmp, *filelist_name, *logfile,253 *compressor_exe;254 char *command = NULL; 255 char *tmp = NULL; 254 256 char *archiver_exe = NULL; 255 256 malloc_string(command); 257 malloc_string(tmp); 258 malloc_string(filelist_name); 259 malloc_string(logfile); 260 malloc_string(compressor_exe); 257 char *filelist_name = NULL; 258 char *logfile = NULL; 259 char *compressor_exe = NULL; 261 260 262 261 use_star = (strstr(tarball_fname, ".star")) ? TRUE : FALSE; 263 262 assert_string_is_neither_NULL_nor_zerolength(tarball_fname); 264 sprintf(logfile, "/tmp/afio.log.%d", current_tarball_number); 265 sprintf(filelist_name, MNT_CDROM "/archives/filelist.%d", 266 current_tarball_number); 267 263 mr_asprintf(&filelist_name, MNT_CDROM "/archives/filelist.%d", current_tarball_number); 268 264 noof_lines = count_lines_in_file(filelist_name); 265 mr_free(filelist_name); 269 266 270 267 if (strstr(tarball_fname, ".bz2")) { 271 strcpy(compressor_exe, "bzip2");268 mr_asprintf(&compressor_exe, "bzip2"); 272 269 } else if (strstr(tarball_fname, ".gz")) { 273 strcpy(compressor_exe, "gzip");270 mr_asprintf(&compressor_exe, "gzip"); 274 271 } else if (strstr(tarball_fname, ".lzo")) { 275 strcpy(compressor_exe, "lzop"); 276 } else { 277 compressor_exe[0] = '\0'; 272 mr_asprintf(&compressor_exe, "lzop"); 278 273 } 279 274 … … 284 279 } 285 280 286 if (compressor_exe[0]) { 287 strcpy(tmp, compressor_exe); 288 if (!find_home_of_exe(tmp)) { 281 if (compressor_exe) { 282 if (!find_home_of_exe(compressor_exe)) { 283 mr_free(compressor_exe); 284 mr_free(archiver_exe); 289 285 fatal_error("(compare_a_tarball) Compression program missing"); 290 286 } 291 if (use_star) // star 292 { 287 if (use_star) { 293 288 if (!strcmp(compressor_exe, "bzip2")) { 294 289 mr_strcat(archiver_exe, " -bz"); 295 290 } else { 296 fatal_error 297 ("(compare_a_tarball) Please use only bzip2 with star"); 291 mr_free(compressor_exe); 292 mr_free(archiver_exe); 293 fatal_error("(compare_a_tarball) Please use only bzip2 with star"); 298 294 } 299 } else // afio 300 { 301 sprintf(compressor_exe, "-P %s -Z", tmp); 302 } 303 } 304 // star -diff H=star -bz file=.... 295 } else { 296 // afio 297 mr_free(compressor_exe); 298 mr_asprintf(&tmp, "%s", compressor_exe); 299 mr_asprintf(&compressor_exe, "-P %s -Z", tmp); 300 mr_free(tmp); 301 } 302 } 305 303 306 304 #ifdef __FreeBSD__ … … 309 307 #define BUFSIZE (1024L*1024L)/TAPE_BLOCK_SIZE 310 308 #endif 311 if (use_star) // doesn't use compressor_exe 312 { 313 sprintf(command, 314 "%s -diff H=star file=%s >> %s 2>> %s", 315 archiver_exe, tarball_fname, logfile, logfile); 316 } else { 317 sprintf(command, 318 "%s -r -b %ld -M 16m -c %ld %s %s >> %s 2>> %s", 319 archiver_exe, 320 TAPE_BLOCK_SIZE, 321 BUFSIZE, compressor_exe, tarball_fname, logfile, logfile); 322 } 309 mr_asprintf(&logfile, "/tmp/afio.log.%d", current_tarball_number); 310 311 if (use_star) { 312 // doesn't use compressor_exe 313 mr_asprintf(&command, "%s -diff H=star file=%s >> %s 2>> %s", archiver_exe, tarball_fname, logfile, logfile); 314 } else { 315 mr_asprintf(&command, "%s -r -b %ld -M 16m -c %ld %s %s >> %s 2>> %s", archiver_exe, TAPE_BLOCK_SIZE, BUFSIZE, compressor_exe, tarball_fname, logfile, logfile); 316 } 317 mr_free(compressor_exe); 323 318 paranoid_free(archiver_exe); 324 319 … … 329 324 if (res) { 330 325 log_OS_error(command); 331 sprintf(tmp, "Warning - afio returned error = %d", res); 332 log_msg(2, tmp); 333 } 326 log_msg(2, "Warning - afio returned error = %d", res); 327 } 328 mr_free(command); 329 334 330 if (length_of_file(logfile) > 5) { 335 sprintf(command, 336 "sed s/': \\\"'/\\|/ %s | sed s/'\\\": '/\\|/ | cut -d'|' -f2 | sort -u | grep -vE \"^dev/.*\" >> "MONDO_CACHE"/changed.txt", 337 logfile); 331 mr_asprintf(&command, "sed s/': \\\"'/\\|/ %s | sed s/'\\\": '/\\|/ | cut -d'|' -f2 | sort -u | grep -vE \"^dev/.*\" >> "MONDO_CACHE"/changed.txt", logfile); 338 332 system(command); 333 mr_free(command); 334 339 335 archiver_errors = count_lines_in_file(logfile); 340 336 } else { 341 337 archiver_errors = 0; 342 338 } 343 sprintf(tmp, "%ld difference%c in fileset #%d ",344 archiver_errors, (archiver_errors != 1) ? 's' : ' ',345 current_tarball_number);346 339 if (archiver_errors) { 347 sprintf(tmp, 348 "Differences found while processing fileset #%d ", 349 current_tarball_number); 350 log_msg(1, tmp); 340 log_msg(1, "%ld difference%c in fileset #%d ", archiver_errors, (archiver_errors != 1) ? 's' : ' ', current_tarball_number); 351 341 } 352 342 unlink(logfile); 353 paranoid_free(command); 354 paranoid_free(tmp); 355 paranoid_free(filelist_name); 356 paranoid_free(logfile); 357 paranoid_free(compressor_exe); 343 mr_free(logfile); 344 358 345 return (retval); 359 346 } … … 377 364 /** needs malloc **********/ 378 365 379 char *tarball_fname, *progress_str, *tmp; 366 char *tarball_fname = NULL; 367 char *progress_str = NULL; 368 char *tmp = NULL; 380 369 char *mds = NULL; 381 370 long max_val; 382 371 383 malloc_string(tarball_fname);384 malloc_string(progress_str);385 malloc_string(tmp);386 372 387 373 assert(bkpinfo != NULL); 388 374 mvaddstr_and_log_it(g_currentY, 0, "Comparing archives"); 375 376 malloc_string(tmp); 389 377 read_cfg_var(g_mondo_cfg_file, "last-filelist-number", tmp); 390 391 378 max_val = atol(tmp); 379 paranoid_free(tmp); 380 392 381 mds = media_descriptor_string(bkpinfo->backup_media_type); 393 sprintf(progress_str, "Comparing with %s #%d ", mds, g_current_media_number);382 mr_asprintf(&progress_str, "Comparing with %s #%d ", mds, g_current_media_number); 394 383 395 384 open_progress_form("Comparing files", … … 403 392 insist_on_this_cd_number(g_current_media_number); 404 393 update_progress_form(progress_str); 405 sprintf(tarball_fname, 406 MNT_CDROM "/archives/%d.afio.bz2", current_tarball_number); 394 mr_asprintf(&tarball_fname, MNT_CDROM "/archives/%d.afio.bz2", current_tarball_number); 407 395 408 396 if (!does_file_exist(tarball_fname)) { 409 sprintf(tarball_fname, MNT_CDROM "/archives/%d.afio.lzo",410 397 mr_free(tarball_fname); 398 mr_asprintf(&tarball_fname, MNT_CDROM "/archives/%d.afio.lzo", current_tarball_number); 411 399 } 412 400 if (!does_file_exist(tarball_fname)) { 413 sprintf(tarball_fname, MNT_CDROM "/archives/%d.afio.gz",414 401 mr_free(tarball_fname); 402 mr_asprintf(&tarball_fname, MNT_CDROM "/archives/%d.afio.gz", current_tarball_number); 415 403 } 416 404 if (!does_file_exist(tarball_fname)) { 417 sprintf(tarball_fname, MNT_CDROM "/archives/%d.afio.",418 405 mr_free(tarball_fname); 406 mr_asprintf(&tarball_fname, MNT_CDROM "/archives/%d.afio.", current_tarball_number); 419 407 } 420 408 if (!does_file_exist(tarball_fname)) { 421 sprintf(tarball_fname, MNT_CDROM "/archives/%d.star.bz2",422 409 mr_free(tarball_fname); 410 mr_asprintf(&tarball_fname, MNT_CDROM "/archives/%d.star.bz2", current_tarball_number); 423 411 } 424 412 if (!does_file_exist(tarball_fname)) { 425 sprintf(tarball_fname, MNT_CDROM "/archives/%d.star.",426 413 mr_free(tarball_fname); 414 mr_asprintf(&tarball_fname, MNT_CDROM "/archives/%d.star.", current_tarball_number); 427 415 } 428 416 if (!does_file_exist(tarball_fname)) { … … 432 420 == 0) { 433 421 log_msg(2, "OK, I think I'm done with tarballs..."); 422 mr_free(tarball_fname); 434 423 break; 435 424 } 436 425 log_msg(2, "OK, I think it's time for another CD..."); 437 426 g_current_media_number++; 438 sprintf(progress_str, "Comparing with %s #%d ", mds, g_current_media_number); 427 428 mr_free(progress_str); 429 mr_asprintf(&progress_str, "Comparing with %s #%d ", mds, g_current_media_number); 439 430 log_to_screen(progress_str); 440 431 } else { … … 444 435 current_tarball_number++; 445 436 } 446 } 437 mr_free(tarball_fname); 438 } 439 mr_free(progress_str); 447 440 mr_free(mds); 448 441 … … 453 446 mvaddstr_and_log_it(g_currentY++, 74, "Done."); 454 447 } 455 paranoid_free(tarball_fname);456 paranoid_free(progress_str);457 paranoid_free(tmp);458 448 return (retval); 459 449 } … … 478 468 { 479 469 /** needs malloc *********/ 480 char *tmp, *cwd, *new, *command; 470 char *tmp = NULL; 471 char *cwd, *new; 472 char *command = NULL; 481 473 int resA = 0; 482 474 int resB = 0; 483 475 long noof_changed_files; 484 476 485 malloc_string(tmp);486 477 malloc_string(cwd); 487 478 malloc_string(new); 488 malloc_string(command);489 479 490 480 assert(bkpinfo != NULL); … … 501 491 noof_changed_files = count_lines_in_file(MONDO_CACHE"/changed.txt"); 502 492 if (noof_changed_files) { 503 sprintf(tmp, "%ld files do not match the backup ", 504 noof_changed_files); 505 // mvaddstr_and_log_it( g_currentY++, 0, tmp ); 493 mr_asprintf(&tmp, "%ld files do not match the backup ", noof_changed_files); 506 494 log_to_screen(tmp); 507 sprintf(command, "cat "MONDO_CACHE"/changed.txt >> %s", MONDO_LOGFILE); 495 mr_free(tmp); 496 497 mr_asprintf(&command, "cat "MONDO_CACHE"/changed.txt >> %s", MONDO_LOGFILE); 508 498 paranoid_system(command); 509 } else { 510 sprintf(tmp, "All files match the backup "); 499 mr_free(command); 500 } else { 501 mr_asprintf(&tmp, "All files match the backup "); 511 502 mvaddstr_and_log_it(g_currentY++, 0, tmp); 512 503 log_to_screen(tmp); 513 }514 515 paranoid_free(tmp); 504 mr_free(tmp); 505 } 506 516 507 paranoid_free(cwd); 517 508 paranoid_free(new); 518 paranoid_free(command);519 509 520 510 return (resA + resB); … … 544 534 int res = 0; 545 535 long q; 546 char *tmp ;536 char *tmp = NULL; 547 537 char *new; 548 538 char *cwd; 549 539 550 malloc_string(tmp);551 540 malloc_string(new); 552 541 malloc_string(cwd); … … 575 564 if (g_text_mode) { 576 565 save_mountlist_to_disk(mountlist, g_mountlist_fname); 577 sprintf(tmp, "%s %s", find_my_editor(), g_mountlist_fname);566 mr_asprintf(&tmp, "%s %s", find_my_editor(), g_mountlist_fname); 578 567 res = system(tmp); 568 mr_free(tmp); 569 579 570 load_mountlist(mountlist, g_mountlist_fname); 580 571 } else { … … 622 613 } else { 623 614 q = count_lines_in_file(MONDO_CACHE"/changed.files"); 624 sprintf(tmp, "%ld significant difference%s found.", q, 625 (q != 1) ? "s" : ""); 615 mr_asprintf(&tmp, "%ld significant difference%s found.", q, (q != 1) ? "s" : ""); 626 616 mvaddstr_and_log_it(g_currentY++, 0, tmp); 627 617 log_to_screen(tmp); 628 629 strcpy(tmp, 630 618 mr_free(tmp); 619 620 mr_asprintf(&tmp, "Type 'less /tmp/changed.files' for a list of non-matching files"); 631 621 mvaddstr_and_log_it(g_currentY++, 0, tmp); 632 622 log_to_screen(tmp); 623 mr_free(tmp); 633 624 634 625 log_msg(2, "calling popup_changelist_from_file()"); … … 647 638 648 639 kill_petris(); 649 paranoid_free(tmp);650 640 paranoid_free(new); 651 641 paranoid_free(cwd); … … 670 660 671 661 /** needs malloc **/ 672 char *dir, *command; 662 char *dir; 663 char *command = NULL; 673 664 674 665 assert(bkpinfo != NULL); 675 666 malloc_string(dir); 676 malloc_string(command);677 667 getcwd(dir, MAX_STR_LEN); 678 668 chdir(bkpinfo->restore_path); 679 669 680 sprintf(command, "cp -f /tmp/LAST-FILELIST-NUMBER %s/tmp", 681 bkpinfo->restore_path); 670 mr_asprintf(&command, "cp -f /tmp/LAST-FILELIST-NUMBER %s/tmp", bkpinfo->restore_path); 682 671 run_program_and_log_output(command, FALSE); 672 mr_free(command); 673 683 674 mvaddstr_and_log_it(g_currentY, 684 675 0, "Verifying archives against filesystem"); … … 704 695 mvaddstr_and_log_it(g_currentY++, 74, "Done."); 705 696 paranoid_free(dir); 706 paranoid_free(command);707 697 return (res); 708 698 } … … 727 717 { 728 718 int res; 729 char *dir, *command; 719 char *dir; 720 char *command = NULL; 730 721 731 722 assert(bkpinfo != NULL); 732 723 malloc_string(dir); 733 malloc_string(command);734 724 735 725 getcwd(dir, MAX_STR_LEN); 736 726 chdir(bkpinfo->restore_path); 737 sprintf(command, "cp -f /tmp/LAST-FILELIST-NUMBER %s/tmp", 738 bkpinfo->restore_path); 727 mr_asprintf(&command, "cp -f /tmp/LAST-FILELIST-NUMBER %s/tmp", bkpinfo->restore_path); 739 728 run_program_and_log_output(command, FALSE); 729 mr_free(command); 730 740 731 mvaddstr_and_log_it(g_currentY, 741 732 0, "Verifying archives against filesystem"); … … 748 739 } 749 740 paranoid_free(dir); 750 paranoid_free(command);751 741 return (res); 752 742 } -
branches/2.2.10/mondo/src/mondorestore/mondo-rstr-tools.c
r2287 r2296 368 368 log_msg(3, "Mommm! SME is being a dildo!"); 369 369 } else { 370 mr_asprintf(&mountpoint, mpt);370 mr_asprintf(&mountpoint, "%s", mpt); 371 371 } 372 372 … … 408 408 mr_free(command); 409 409 410 mr_asprintf(&command, "mount -t %s %s %s %s 2>> %s", format, device, 411 additional_parameters, mountdir, MONDO_LOGFILE); 410 mr_asprintf(&command, "mount -t %s %s %s %s 2>> %s", format, device, additional_parameters, mountdir, MONDO_LOGFILE); 412 411 log_msg(2, "command='%s'", command); 413 412 } … … 418 417 log_msg(1, "Re-trying without the fancy extra parameters"); 419 418 mr_free(command); 420 mr_asprintf(&command, "mount -t %s %s %s 2>> %s", format, device, 421 mountdir, MONDO_LOGFILE); 419 mr_asprintf(&command, "mount -t %s %s %s 2>> %s", format, device, mountdir, MONDO_LOGFILE); 422 420 res = run_program_and_log_output(command, TRUE); 423 421 } … … 497 495 "Again with the /proc - why is this in your mountlist?"); 498 496 } else if (is_this_device_mounted(mountlist->el[lino].device)) { 499 mr_asprintf(&tmp, "%s is already mounted", 500 mountlist->el[lino].device); 497 mr_asprintf(&tmp, "%s is already mounted", mountlist->el[lino].device); 501 498 log_to_screen(tmp); 502 499 mr_free(tmp); … … 607 604 mr_asprintf(&mount_cmd, "mount_cd9660 -r %s " MNT_CDROM, mddev); 608 605 #else 609 mr_asprintf(&mount_cmd, "mount %s/%s/%s-%d.iso -t iso9660 -o loop,ro %s", bkpinfo->isodir, bkpinfo->nfs_remote_dir, 610 bkpinfo->prefix, g_current_media_number, MNT_CDROM); 606 mr_asprintf(&mount_cmd, "mount %s/%s/%s-%d.iso -t iso9660 -o loop,ro %s", bkpinfo->isodir, bkpinfo->nfs_remote_dir, bkpinfo->prefix, g_current_media_number, MNT_CDROM); 611 607 #endif 612 608 … … 619 615 mr_asprintf(&mount_cmd, "mount_cd9660 -r %s %s", mddev, MNT_CDROM); 620 616 #else 621 mr_asprintf(&mount_cmd, "mount %s/%s-%d.iso -t iso9660 -o loop,ro %s", 622 bkpinfo->isodir, bkpinfo->prefix, g_current_media_number, MNT_CDROM); 617 mr_asprintf(&mount_cmd, "mount %s/%s-%d.iso -t iso9660 -o loop,ro %s", bkpinfo->isodir, bkpinfo->prefix, g_current_media_number, MNT_CDROM); 623 618 #endif 624 619 } else if (bkpinfo->backup_media_type == usb) { … … 1101 1096 unlink(FILELIST_FULL_STUB); 1102 1097 if (IS_THIS_A_STREAMING_BACKUP(bkpinfo->backup_media_type)) { 1103 mr_asprintf(&command, "tar -b %ld -zxf %s ./%s ./%s ./%s ./%s ./%s", 1104 bkpinfo->internal_tape_block_size, 1105 bkpinfo->media_device, 1106 MOUNTLIST_FNAME_STUB, 1107 BIGGIELIST_TXT_STUB, 1108 FILELIST_FULL_STUB, 1109 IWANTMYLVM_STUB, 1110 MONDO_CFG_FILE_STUB); 1098 mr_asprintf(&command, "tar -b %ld -zxf %s ./%s ./%s ./%s ./%s ./%s", bkpinfo->internal_tape_block_size, bkpinfo->media_device, MOUNTLIST_FNAME_STUB, BIGGIELIST_TXT_STUB, FILELIST_FULL_STUB, IWANTMYLVM_STUB, MONDO_CFG_FILE_STUB); 1111 1099 log_msg(1, "tarcommand = %s", command); 1112 1100 run_program_and_log_output(command, 1); … … 1116 1104 /* Doing that allow us to remain compatible with pre-2.2.5 versions */ 1117 1105 log_msg(2, "pre-2.2.4 compatible mode on"); 1118 mr_asprintf(&command, 1119 "tar -b %ld -zxf %s %s %s %s %s %s", 1120 bkpinfo->internal_tape_block_size, 1121 bkpinfo->media_device, 1122 MOUNTLIST_FNAME_STUB, 1123 BIGGIELIST_TXT_STUB, 1124 FILELIST_FULL_STUB, 1125 IWANTMYLVM_STUB, 1126 MONDO_CFG_FILE_STUB); 1106 mr_asprintf(&command, "tar -b %ld -zxf %s %s %s %s %s %s", bkpinfo->internal_tape_block_size, bkpinfo->media_device, MOUNTLIST_FNAME_STUB, BIGGIELIST_TXT_STUB, FILELIST_FULL_STUB, IWANTMYLVM_STUB, MONDO_CFG_FILE_STUB); 1127 1107 log_msg(1, "tarcommand = %s", command); 1128 1108 run_program_and_log_output(command, 1); … … 1136 1116 log_msg(2, "Back from iotcn"); 1137 1117 run_program_and_log_output("mount", 1); 1138 mr_asprintf(&command, 1139 "tar -zxf %s/images/all.tar.gz ./%s ./%s ./%s ./%s ./%s", 1140 MNT_CDROM, 1141 MOUNTLIST_FNAME_STUB, 1142 BIGGIELIST_TXT_STUB, 1143 FILELIST_FULL_STUB, 1144 IWANTMYLVM_STUB, 1145 MONDO_CFG_FILE_STUB); 1118 mr_asprintf(&command, "tar -zxf %s/images/all.tar.gz ./%s ./%s ./%s ./%s ./%s", MNT_CDROM, MOUNTLIST_FNAME_STUB, BIGGIELIST_TXT_STUB, FILELIST_FULL_STUB, IWANTMYLVM_STUB, MONDO_CFG_FILE_STUB); 1146 1119 1147 1120 log_msg(1, "tarcommand = %s", command); … … 1152 1125 /* Doing that allow us to remain compatible with pre-2.2.5 versions */ 1153 1126 log_msg(2, "pre-2.2.4 compatible mode on"); 1154 mr_asprintf(&command, 1155 "tar -zxf %s/images/all.tar.gz %s %s %s %s %s", 1156 MNT_CDROM, 1157 MOUNTLIST_FNAME_STUB, 1158 BIGGIELIST_TXT_STUB, 1159 FILELIST_FULL_STUB, 1160 IWANTMYLVM_STUB, 1161 MONDO_CFG_FILE_STUB); 1127 mr_asprintf(&command, "tar -zxf %s/images/all.tar.gz %s %s %s %s %s", MNT_CDROM, MOUNTLIST_FNAME_STUB, BIGGIELIST_TXT_STUB, FILELIST_FULL_STUB, IWANTMYLVM_STUB, MONDO_CFG_FILE_STUB); 1162 1128 1163 1129 log_msg(1, "tarcommand = %s", command); … … 1195 1161 && 1196 1162 ask_me_yes_or_no("Do you want to retrieve the mountlist as well?")) { 1197 mr_asprintf(&command, "ln -sf %s/%s /tmp", MOUNTLIST_FNAME_STUB, 1198 bkpinfo->tmpdir); 1163 mr_asprintf(&command, "ln -sf %s/%s /tmp", MOUNTLIST_FNAME_STUB, bkpinfo->tmpdir); 1199 1164 paranoid_system(command); 1200 1165 mr_free(command); … … 1225 1190 mr_free(command); 1226 1191 } 1227 mr_asprintf(&command, "grep -E '^/dev/.*' %s > %s", 1228 g_biggielist_txt, g_filelist_imagedevs); 1192 mr_asprintf(&command, "grep -E '^/dev/.*' %s > %s", g_biggielist_txt, g_filelist_imagedevs); 1229 1193 paranoid_system(command); 1230 1194 mr_free(command); … … 2044 2008 "Well, I know a certain kitty-kitty who'll be sleeping with Mommy tonight..."); 2045 2009 } else { 2046 mr_asprintf(&command, "umount " MNT_RESTORING "%s", 2047 mountlist->el[lino].mountpoint); 2010 mr_asprintf(&command, "umount " MNT_RESTORING "%s", mountlist->el[lino].mountpoint); 2048 2011 2049 2012 /* To support latest Ubuntu where /var is a separate FS … … 2112 2075 } 2113 2076 2114 mr_asprintf(&command, 2115 "dd if=%s bs=%ld count=%ld 2> /dev/null | tar -zx ./%s ./%s ./%s ./%s ./%s", 2116 dev, 2117 bkpinfo->internal_tape_block_size, 2118 1024L * 1024 * 32 / bkpinfo->internal_tape_block_size, 2119 MOUNTLIST_FNAME_STUB, MONDO_CFG_FILE_STUB, 2120 BIGGIELIST_TXT_STUB, FILELIST_FULL_STUB, IWANTMYLVM_STUB); 2077 mr_asprintf(&command, "dd if=%s bs=%ld count=%ld 2> /dev/null | tar -zx ./%s ./%s ./%s ./%s ./%s", dev, bkpinfo->internal_tape_block_size, 1024L * 1024 * 32 / bkpinfo->internal_tape_block_size, MOUNTLIST_FNAME_STUB, MONDO_CFG_FILE_STUB, BIGGIELIST_TXT_STUB, FILELIST_FULL_STUB, IWANTMYLVM_STUB); 2121 2078 log_msg(2, "command = '%s'", command); 2122 2079 res = run_program_and_log_output(command, -1); … … 2129 2086 /* Doing that allow us to remain compatible with pre-2.2.5 versions */ 2130 2087 log_msg(2, "pre-2.2.4 compatible mode on"); 2131 mr_asprintf(&command, 2132 "dd if=%s bs=%ld count=%ld 2> /dev/null | tar -zx %s %s %s %s %s", 2133 dev, 2134 bkpinfo->internal_tape_block_size, 2135 1024L * 1024 * 32 / bkpinfo->internal_tape_block_size, 2136 MOUNTLIST_FNAME_STUB, MONDO_CFG_FILE_STUB, 2137 BIGGIELIST_TXT_STUB, FILELIST_FULL_STUB, IWANTMYLVM_STUB); 2088 mr_asprintf(&command, "dd if=%s bs=%ld count=%ld 2> /dev/null | tar -zx %s %s %s %s %s", dev, bkpinfo->internal_tape_block_size, 1024L * 1024 * 32 / bkpinfo->internal_tape_block_size, MOUNTLIST_FNAME_STUB, MONDO_CFG_FILE_STUB, BIGGIELIST_TXT_STUB, FILELIST_FULL_STUB, IWANTMYLVM_STUB); 2138 2089 log_msg(2, "command = '%s'", command); 2139 2090 res = run_program_and_log_output(command, -1); … … 2226 2177 log_msg(2, "media_device is blank; assuming %s"); 2227 2178 } 2228 mr_asprintf(&tmp, bkpinfo->media_device);2179 mr_asprintf(&tmp, "%s", bkpinfo->media_device); 2229 2180 if (extract_cfg_file_and_mountlist_from_tape_dev 2230 2181 (bkpinfo->media_device)) { … … 2335 2286 /* Is this code really useful ??? */ 2336 2287 if (extract_mountlist_stub) { 2337 mr_asprintf(&command, "cp -f %s %s/%s", MOUNTLIST_FNAME_STUB, 2338 bkpinfo->tmpdir, MOUNTLIST_FNAME_STUB); 2288 mr_asprintf(&command, "cp -f %s %s/%s", MOUNTLIST_FNAME_STUB, bkpinfo->tmpdir, MOUNTLIST_FNAME_STUB); 2339 2289 run_program_and_log_output(command, FALSE); 2340 2290 mr_free(command); -
branches/2.2.10/mondo/src/mondorestore/mondorestore.c
r2291 r2296 668 668 strcpy(fstab_fname, "/tmp/fstab"); 669 669 } 670 mr_asprintf(&tmp1, 671 "label-partitions-as-necessary %s < %s >> %s 2>> %s", 672 g_mountlist_fname, fstab_fname, MONDO_LOGFILE, 673 MONDO_LOGFILE); 670 mr_asprintf(&tmp1, "label-partitions-as-necessary %s < %s >> %s 2>> %s", g_mountlist_fname, fstab_fname, MONDO_LOGFILE, MONDO_LOGFILE); 674 671 res = system(tmp1); 675 672 mr_free(tmp1); … … 811 808 } 812 809 if (!evaluate_mountlist(mountlist, tmpA, tmpB, tmpC)) { 813 mr_asprintf(&tmp, 814 "Mountlist analyzed. Result: \"%s %s %s\" Switch to Interactive Mode?", 815 tmpA, tmpB, tmpC); 810 mr_asprintf(&tmp, "Mountlist analyzed. Result: \"%s %s %s\" Switch to Interactive Mode?", tmpA, tmpB, tmpC); 816 811 res = ask_me_yes_or_no(tmp); 817 812 mr_free(tmp); … … 1293 1288 } 1294 1289 mds = media_descriptor_string(bkpinfo->backup_media_type); 1295 mr_asprintf(&tmp, "Working on %s #%d, file #%ld, slice #%ld ", mds, 1296 g_current_media_number, bigfileno + 1, sliceno); 1290 mr_asprintf(&tmp, "Working on %s #%d, file #%ld, slice #%ld ", mds, g_current_media_number, bigfileno + 1, sliceno); 1297 1291 mr_free(mds); 1298 1292 log_msg(2, tmp); … … 1329 1323 if (use_ntfsprog_hack) { 1330 1324 log_msg(3, "Waiting for ntfsclone to finish"); 1331 mr_asprintf(&tmp, 1332 " ps | grep \" ntfsclone \" | grep -v grep > /dev/null 2> /dev/null"); 1325 mr_asprintf(&tmp, " ps | grep \" ntfsclone \" | grep -v grep > /dev/null 2> /dev/null"); 1333 1326 while (system(tmp) == 0) { 1334 1327 sleep(1); … … 1464 1457 use_ntfsprog_hack = TRUE; 1465 1458 log_msg(2, "Calling ntfsclone in background because %s is a /dev entry", outfile_fname); 1466 mr_asprintf(&sz_devfile, "%s/%d.%d.000", 1467 bkpinfo->tmpdir, 1468 (int) (random() % 32768), 1469 (int) (random() % 32768)); 1459 mr_asprintf(&sz_devfile, "%s/%d.%d.000", bkpinfo->tmpdir, (int) (random() % 32768), (int) (random() % 32768)); 1470 1460 mkfifo(sz_devfile, 0x770); 1471 1461 strcpy(ntfsprog_fifo, sz_devfile); … … 1684 1674 log_msg(3, "Saved fileset %ld's subset to %s", current_tarball_number, filelist_subset_fname); 1685 1675 } 1686 mr_asprintf(&screen_message, "Tarball #%ld --- %ld matches", 1687 current_tarball_number, matches); 1676 mr_asprintf(&screen_message, "Tarball #%ld --- %ld matches", current_tarball_number, matches); 1688 1677 log_to_screen(screen_message); 1689 1678 mr_free(screen_message); … … 2237 2226 } 2238 2227 g_current_media_number++; 2239 mr_asprintf(&progress_str, "Restoring from %s #%d", 2240 media_descriptor_string(bkpinfo->backup_media_type), 2241 g_current_media_number); 2228 mr_asprintf(&progress_str, "Restoring from %s #%d", media_descriptor_string(bkpinfo->backup_media_type), g_current_media_number); 2242 2229 log_to_screen(progress_str); 2243 2230 } else { 2244 mr_asprintf(&progress_str, "Restoring from fileset #%ld on %s #%d", 2245 current_tarball_number, mds, g_current_media_number); 2231 mr_asprintf(&progress_str, "Restoring from fileset #%ld on %s #%d", current_tarball_number, mds, g_current_media_number); 2246 2232 for (res = 999, attempts = 0; attempts < 3 && res != 0; 2247 2233 attempts++) { … … 2251 2237 filelist); 2252 2238 } 2253 mr_asprintf(&tmp1, "%s #%d, fileset #%ld - restore ", 2254 mds, g_current_media_number, current_tarball_number); 2239 mr_asprintf(&tmp1, "%s #%d, fileset #%ld - restore ", mds, g_current_media_number, current_tarball_number); 2255 2240 if (res) { 2256 2241 mr_strcat(tmp1, "reported errors"); … … 2381 2366 p++; 2382 2367 } 2383 mr_asprintf(&tmp1, "Restoring big file %ld (%lld K)", 2384 current_bigfile_number + 1, biggie_size / 1024); 2368 mr_asprintf(&tmp1, "Restoring big file %ld (%lld K)", current_bigfile_number + 1, biggie_size / 1024); 2385 2369 update_progress_form(tmp1); 2386 2370 mr_free(tmp1); … … 2519 2503 update_progress_form(progress_str); 2520 2504 if (g_getfattr) { 2521 mr_asprintf(&xattr_fname, "%s/xattr-subset-%ld.tmp", bkpinfo->tmpdir, 2522 current_afioball_number); 2505 mr_asprintf(&xattr_fname, "%s/xattr-subset-%ld.tmp", bkpinfo->tmpdir, current_afioball_number); 2523 2506 unlink(xattr_fname); 2524 2507 }
Note:
See TracChangeset
for help on using the changeset viewer.