Changeset 1199 in MondoRescue
- Timestamp:
- Feb 25, 2007, 12:43:27 AM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/stable/mondo/src/mondorestore/mondorestore.c
r1193 r1199 12 12 * #include statements * 13 13 **************************************************************************/ 14 #include <pthread.h> 14 #include <unistd.h> 15 15 16 #include "my-stuff.h" 16 17 #include "mr_mem.h" … … 74 75 * The device to mount to get at the ISO images. Ignored unless @p g_ISO_restore_mode. 75 76 */ 76 char *g_isodir_device ;77 char *g_isodir_device = NULL; 77 78 78 79 /** 79 80 * The format of @p g_isodir_device. Ignored unless @p g_ISO_restore_mode. 80 81 */ 81 char *g_isodir_format ;82 char *g_isodir_format = NULL; 82 83 83 84 /** 84 85 * The location of 'biggielist.txt', containing the biggiefiles on the current archive set. 85 86 */ 86 char *g_biggielist_txt ;87 char *g_biggielist_txt = NULL; 87 88 88 89 /** … … 90 91 * the current archive set. 91 92 */ 92 char *g_filelist_full ;93 char *g_filelist_full = NULL; 93 94 94 95 /** … … 96 97 * as images, not as individual files. 97 98 */ 98 char *g_filelist_imagedevs ;99 char *g_filelist_imagedevs = NULL; 99 100 100 101 /** … … 102 103 * @see g_filelist_imagedevs 103 104 */ 104 char *g_imagedevs_restthese ;105 char *g_imagedevs_restthese = NULL; 105 106 106 107 /** … … 108 109 * information for this backup. 109 110 */ 110 char *g_mondo_cfg_file ;111 char *g_mondo_cfg_file = NULL; 111 112 112 113 /** … … 114 115 * user's partitions and hard drives. 115 116 */ 116 char *g_mountlist_fname ;117 char *g_mountlist_fname = NULL; 117 118 118 119 /** … … 120 121 * to avoid link errors. 121 122 */ 122 char *g_mondo_home ;123 char *g_mondo_home = NULL; 123 124 124 125 /* Busybox ps has no option and PID in first pos */ … … 131 132 /* @} - end of "Restore-Time Globals" in globalGroup */ 132 133 133 134 135 134 extern int copy_from_src_to_dest(FILE * f_orig, FILE * f_archived, 136 135 char direction); 137 138 139 136 140 137 /************************************************************************** … … 145 142 * The message to display if we detect that the user is using a Compaq Proliant. 146 143 */ 147 #define COMPAQ_PROLIANTS_SUCK "Partition and format your disk using Compaq's disaster recovery CD. After you've done that, please reboot with your Mondo CD/floppy in Interactive Mode." 148 149 144 #define COMPAQ_PROLIANTS_SUCK _("Partition and format your disk using Compaq's disaster recovery CD. After you've done that, please reboot with your Mondo CD/floppy in Interactive Mode.") 150 145 151 146 … … 175 170 if (!does_file_exist(g_mountlist_fname)) { 176 171 log_to_screen(g_mountlist_fname); 177 log_to_screen( "does not exist");172 log_to_screen(_("does not exist")); 178 173 return (1); 179 174 } … … 183 178 if (retval) { 184 179 log_to_screen 185 ( "Warning - load_raidtab_into_raidlist returned an error");180 (_("Warning - load_raidtab_into_raidlist returned an error")); 186 181 } 187 182 res = edit_mountlist(g_mountlist_fname, mountlist, raidlist); … … 193 188 save_raidlist_to_raidtab(raidlist, RAIDTAB_FNAME); 194 189 195 log_to_screen( "I have finished editing the mountlist for you.");190 log_to_screen(_("I have finished editing the mountlist for you.")); 196 191 197 192 return (retval); 198 193 } 199 200 201 202 194 203 195 … … 242 234 popup_and_OK(COMPAQ_PROLIANTS_SUCK); 243 235 if (ask_me_yes_or_no 244 ("Would you like to reboot and use your Compaq CD to prep your hard drive?")) 236 (_ 237 ("Would you like to reboot and use your Compaq CD to prep your hard drive?"))) 245 238 { 246 fatal_error 247 ("Aborting. Please reboot and prep your hard drive with your Compaq CD.");239 fatal_error(_ 240 ("Aborting. Please reboot and prep your hard drive with your Compaq CD.")); 248 241 } 249 242 } … … 252 245 *END_OFFER_TO_ABORT_BECAUSE_COMPAQ_PROLIANTS_SUCK * 253 246 **************************************************************************/ 254 255 247 256 248 … … 275 267 assert(mountlist != NULL); 276 268 assert(raidlist != NULL); 277 malloc_string(tmp);278 269 iamhere("pre wrm"); 279 270 c = which_restore_mode(); … … 282 273 interactively_obtain_media_parameters_from_user(bkpinfo, FALSE); 283 274 } else { 284 popup_and_OK("No restoring or comparing will take place today."); 275 popup_and_OK(_ 276 ("No restoring or comparing will take place today.")); 285 277 if (is_this_device_mounted("/mnt/cdrom")) { 286 278 run_program_and_log_output("umount /mnt/cdrom", FALSE); 287 279 } 288 280 if (g_ISO_restore_mode) { 289 sprintf(tmp, "umount %s", bkpinfo->isodir);281 mr_asprintf(&tmp, "umount %s", bkpinfo->isodir); 290 282 run_program_and_log_output(tmp, FALSE); 283 mr_free(tmp); 291 284 } 292 285 paranoid_MR_finish(0); … … 315 308 retval += compare_mode(bkpinfo, mountlist, raidlist); 316 309 } 317 mr_free(tmp);318 310 return (retval); 319 311 } … … 326 318 *END_ EXTRACT_CONFIG_FILE_FROM_RAMDISK * 327 319 **************************************************************************/ 328 329 330 /**331 * Locate an executable in the directory structure rooted at @p restg.332 * @param out_path Where to put the executable.333 * @param fname The basename of the executable.334 * @param restg The directory structure to look in.335 * @note If it could not be found in @p restg then @p fname is put in @p out_path.336 * @ingroup restoreUtilityGroup337 */338 void339 find_pathname_of_executable_preferably_in_RESTORING(char *out_path,340 char *fname,341 char *restg)342 {343 assert(out_path != NULL);344 assert_string_is_neither_NULL_nor_zerolength(fname);345 346 sprintf(out_path, "%s/sbin/%s", restg, fname);347 if (does_file_exist(out_path)) {348 sprintf(out_path, "%s/usr/sbin/%s", restg, fname);349 if (does_file_exist(out_path)) {350 sprintf(out_path, "%s/bin/%s", restg, fname);351 if (does_file_exist(out_path)) {352 sprintf(out_path, "%s/usr/bin/%s", restg, fname);353 if (does_file_exist(out_path)) {354 strcpy(out_path, fname);355 }356 }357 }358 }359 }360 361 /**************************************************************************362 *END_FIND_PATHNAME_OF_EXECUTABLE_PREFERABLY_IN_RESTORING *363 **************************************************************************/364 365 366 320 367 321 … … 392 346 bool restore_all; 393 347 394 /** needs malloc **********/ 395 char *tmp ;396 char *fstab_fname ;397 char *old_restpath ;398 399 struct s_node *filelist ;348 char *tmp = NULL; 349 char *tmp1 = NULL; 350 char *fstab_fname = NULL; 351 char *old_restpath = NULL; 352 353 struct s_node *filelist = NULL; 400 354 401 355 /* try to partition and format */ … … 403 357 mr_msg(2, "interactive_mode --- starting (great, assertions OK)"); 404 358 405 malloc_string(tmp);406 malloc_string(fstab_fname);407 malloc_string(old_restpath);408 359 assert(bkpinfo != NULL); 409 360 assert(mountlist != NULL); … … 414 365 if (g_text_mode) { 415 366 if (!ask_me_yes_or_no 416 ("Interactive Mode + textonly = experimental! Proceed anyway?")) 367 (_ 368 ("Interactive Mode + textonly = experimental! Proceed anyway?"))) 417 369 { 418 370 fatal_error("Wise move."); … … 442 394 if (g_text_mode) { 443 395 save_mountlist_to_disk(mountlist, g_mountlist_fname); 444 sprintf(tmp, "%s %s", find_my_editor(), g_mountlist_fname);396 mr_asprintf(&tmp, "%s %s", find_my_editor(), g_mountlist_fname); 445 397 res = system(tmp); 398 mr_free(tmp); 446 399 load_mountlist(mountlist, g_mountlist_fname); 447 400 } else { … … 455 408 save_mountlist_to_disk(mountlist, g_mountlist_fname); 456 409 save_raidlist_to_raidtab(raidlist, RAIDTAB_FNAME); 457 mvaddstr_and_log_it(1, 30, "Restoring Interactively");410 mvaddstr_and_log_it(1, 30, _("Restoring Interactively")); 458 411 if (bkpinfo->differential) { 459 log_to_screen("Because this is a differential backup, disk"); 460 log_to_screen 461 (" partitioning and formatting will not take place."); 412 log_to_screen(_ 413 ("Because this is a differential backup, disk")); 414 log_to_screen(_ 415 (" partitioning and formatting will not take place.")); 462 416 done = TRUE; 463 417 } else { 464 418 if (ask_me_yes_or_no 465 ("Do you want to erase and partition your hard drives?")) { 419 (_ 420 ("Do you want to erase and partition your hard drives?"))) 421 { 466 422 if (partition_table_contains_Compaq_diagnostic_partition 467 423 (mountlist)) { … … 474 430 if (ptn_errs) { 475 431 log_to_screen 476 ("Warning. Errors occurred during disk partitioning."); 432 (_ 433 ("Warning. Errors occurred during disk partitioning.")); 477 434 } 478 435 … … 480 437 if (!fmt_errs) { 481 438 log_to_screen 482 ("Errors during disk partitioning were handled OK."); 483 log_to_screen 484 ("Partitions were formatted OK despite those errors."); 439 (_ 440 ("Errors during disk partitioning were handled OK.")); 441 log_to_screen(_ 442 ("Partitions were formatted OK despite those errors.")); 485 443 ptn_errs = 0; 486 444 } … … 492 450 } else { 493 451 mvaddstr_and_log_it(g_currentY++, 0, 494 "User opted not to partition the devices"); 452 _ 453 ("User opted not to partition the devices")); 495 454 if (ask_me_yes_or_no 496 ("Do you want to format your hard drives?")) { 497 fmt_errs = format_everything(mountlist, TRUE, raidlist); 455 (_("Do you want to format your hard drives?"))) { 456 fmt_errs = 457 format_everything(mountlist, TRUE, raidlist); 498 458 if (!fmt_errs) { 499 459 done = TRUE; … … 507 467 mvaddstr_and_log_it(g_currentY++, 508 468 0, 509 "Errors occurred. Please repartition and format drives manually."); 469 _ 470 ("Errors occurred. Please repartition and format drives manually.")); 510 471 done = FALSE; 511 472 } … … 513 474 mvaddstr_and_log_it(g_currentY++, 514 475 0, 515 "Errors occurred during partitioning. Formatting, however, went OK."); 476 _ 477 ("Errors occurred during partitioning. Formatting, however, went OK.")); 516 478 done = TRUE; 517 479 } 518 480 if (!done) { 519 if (!ask_me_yes_or_no( "Re-edit the mountlist?")) {481 if (!ask_me_yes_or_no(_("Re-edit the mountlist?"))) { 520 482 retval++; 521 goto end_of_func; 483 iamhere("Leaving interactive_mode()"); 484 return (retval); 522 485 } 523 486 } … … 529 492 unmount_all_devices(mountlist); 530 493 retval++; 531 goto end_of_func; 494 iamhere("Leaving interactive_mode()"); 495 return (retval); 532 496 } 533 497 /* restore */ 534 498 if ((restore_all = 535 ask_me_yes_or_no("Do you want me to restore all of your data?"))) 499 ask_me_yes_or_no(_ 500 ("Do you want me to restore all of your data?")))) 536 501 { 537 502 mr_msg(1, "Restoring all data"); 538 503 retval += restore_everything(bkpinfo, NULL); 539 } else 540 if ((restore_all = 504 } else if ((restore_all = 541 505 ask_me_yes_or_no 542 ( "Do you want me to restore _some_ of your data?"))) {543 strcpy(old_restpath,bkpinfo->restore_path);506 (_("Do you want me to restore _some_ of your data?")))) { 507 mr_asprintf(&old_restpath,bkpinfo->restore_path); 544 508 for (done = FALSE; !done;) { 545 509 unlink("/tmp/filelist.full"); … … 549 513 */ 550 514 if (filelist) { 515 malloc_string(tmp1); 551 516 gotos_suck: 552 strcpy(tmp , old_restpath);553 // (NB: %s is where your filesystem is mounted now, by default)", MNT_RESTORING); 517 strcpy(tmp1, old_restpath); 518 // (NB: MNT_RESTORING is where your filesystem is mounted now, by default) 554 519 if (popup_and_get_string 555 ( "Restore path", "Restore files to where?", tmp,520 (_("Restore path"), _("Restore files to where?"), tmp1, 556 521 MAX_STR_LEN / 4)) { 557 if (!strcmp(tmp , "/")) {558 if (!ask_me_yes_or_no( "Are you sure?")) {522 if (!strcmp(tmp1, "/")) { 523 if (!ask_me_yes_or_no(_("Are you sure?"))) { 559 524 goto gotos_suck; 560 525 } 561 tmp [0] = '\0'; // so we restore to [blank]/file/name :)526 tmp1[0] = '\0'; // so we restore to [blank]/file/name :) 562 527 } 563 strcpy(bkpinfo->restore_path, tmp );528 strcpy(bkpinfo->restore_path, tmp1); 564 529 mr_msg(1, "Restoring subset"); 565 530 retval += restore_everything(bkpinfo, filelist); … … 570 535 } 571 536 if (!ask_me_yes_or_no 572 ( "Restore another subset of your backup?")) {537 (_("Restore another subset of your backup?"))) { 573 538 done = TRUE; 574 539 } 540 mr_free(tmp1); 575 541 } else { 576 542 done = TRUE; 577 543 } 578 544 } 579 strcpy(old_restpath, bkpinfo->restore_path);545 mr_free(old_restpath); 580 546 } else { 581 547 mvaddstr_and_log_it(g_currentY++, 582 548 0, 583 "User opted not to restore any data. "); 549 _ 550 ("User opted not to restore any data. ")); 584 551 } 585 552 if (retval) { 586 553 mvaddstr_and_log_it(g_currentY++, 587 554 0, 588 "Errors occurred during the restore phase. "); 589 } 590 591 if (ask_me_yes_or_no("Initialize the boot loader?")) { 555 _ 556 ("Errors occurred during the restore phase. ")); 557 } 558 559 if (ask_me_yes_or_no(_("Initialize the boot loader?"))) { 592 560 run_boot_loader(TRUE); 593 561 } else { 594 562 mvaddstr_and_log_it(g_currentY++, 595 563 0, 596 "User opted not to initialize the boot loader.");597 }598 599 // run_program_and_log_output("cp -af /etc/lvm " MNT_RESTORING "/etc/", 1); 564 _ 565 ("User opted not to initialize the boot loader.")); 566 } 567 600 568 protect_against_braindead_sysadmins(); 601 // modify_rclocal_one_time( MNT_RESTORING "/etc" );602 569 retval += unmount_all_devices(mountlist); 603 570 /* if (restore_some || restore_all || */ 604 571 if (ask_me_yes_or_no 605 ( "Label your ext2 and ext3 partitions if necessary?")) {572 (_("Label your ext2 and ext3 partitions if necessary?"))) { 606 573 mvaddstr_and_log_it(g_currentY, 0, 607 "Using e2label to label your ext2,3 partitions"); 574 _ 575 ("Using e2label to label your ext2,3 partitions")); 608 576 if (does_file_exist("/tmp/fstab.new")) { 609 strcpy(fstab_fname, "/tmp/fstab.new");577 mr_asprintf(&fstab_fname, "/tmp/fstab.new"); 610 578 } else { 611 strcpy(fstab_fname, "/tmp/fstab");612 } 613 sprintf(tmp,579 mr_asprintf(&fstab_fname, "/tmp/fstab"); 580 } 581 mr_asprintf(&tmp, 614 582 "label-partitions-as-necessary %s < %s >> %s 2>> %s", 615 583 g_mountlist_fname, fstab_fname, MONDO_LOGFILE, 616 584 MONDO_LOGFILE); 585 mr_free(fstab_fname); 586 617 587 res = system(tmp); 588 mr_free(tmp); 618 589 if (res) { 619 590 log_to_screen 620 ( "label-partitions-as-necessary returned an error");621 mvaddstr_and_log_it(g_currentY++, 74, "Failed.");591 (_("label-partitions-as-necessary returned an error")); 592 mvaddstr_and_log_it(g_currentY++, 74, _("Failed.")); 622 593 } else { 623 mvaddstr_and_log_it(g_currentY++, 74, "Done.");594 mvaddstr_and_log_it(g_currentY++, 74, _("Done.")); 624 595 } 625 596 retval += res; … … 630 601 mvaddstr_and_log_it(g_currentY++, 631 602 0, 632 "Warning - errors occurred during the restore phase."); 633 } 634 end_of_func: 635 mr_free(tmp); 636 mr_free(fstab_fname); 637 mr_free(old_restpath); 603 _ 604 ("Warning - errors occurred during the restore phase.")); 605 } 638 606 iamhere("Leaving interactive_mode()"); 639 return 607 return(retval); 640 608 } 641 609 … … 643 611 *END_INTERACTIVE_MODE * 644 612 **************************************************************************/ 645 646 613 647 614 … … 660 627 struct raidlist_itself *raidlist, bool nuke_me_please) 661 628 { 662 char c ;629 char c = ' '; 663 630 int retval = 0; 664 631 … … 682 649 retval += compare_mode(bkpinfo, mountlist, raidlist); 683 650 } else { 684 log_to_screen( "OK, I shan't restore/compare any files.");651 log_to_screen(_("OK, I shan't restore/compare any files.")); 685 652 } 686 653 } … … 688 655 paranoid_system("umount " MNT_CDROM); 689 656 } 690 // if (! already_mounted)691 // {692 657 if (system("umount /tmp/isodir 2> /dev/null")) { 693 658 log_to_screen 694 ( "WARNING - unable to unmount device where the ISO files are stored.");695 }696 //}659 (_ 660 ("WARNING - unable to unmount device where the ISO files are stored.")); 661 } 697 662 return (retval); 698 663 } … … 701 666 *END_ISO_MODE * 702 667 **************************************************************************/ 703 704 705 /* MONDO - saving your a$$ since Feb 18th, 2000 */ 706 707 668 static void call_me_after_the_nuke(int retval) { 669 670 char *tmp = NULL; 671 char *tmp1 = NULL; 672 673 if (retval) { 674 log_to_screen(_("Errors occurred during the nuke phase.")); 675 log_to_screen(_("Please visit our website at http://www.mondores 676 cue.org for more information.")); 677 } else { 678 #ifdef __FreeBSD__ 679 tmp1 = call_program_and_get_last_line_of_output("cat /tmp/cmdline"); 680 #else 681 tmp1 = call_program_and_get_last_line_of_output("cat /proc/cmdline"); 682 #endif 683 if ((strstr(tmp1,"restore") == NULL) || 684 (strstr(tmp1,"RESTORE") == NULL)) { 685 /* -H option */ 686 mr_asprintf(&tmp, 687 _ 688 (" Mondo has restored your system. Please remove the backup media and reboot.\n\nPlease visit our website at http://www. 689 mondorescue.org for more information.")); 690 popup_and_OK(tmp); 691 mr_free(tmp); 692 } 693 694 log_to_screen(_ 695 ("Mondo has restored your system. Please remove the backup media and reboot.")); 696 log_to_screen(_ 697 ("Thank you for using Mondo Rescue.")); 698 log_to_screen(_ 699 ("Please visit our website at http://www.mondorescue.org for more information.")); 700 } 701 g_I_have_just_nuked = TRUE; 702 return; 703 } 708 704 709 705 … … 725 721 int res = 0; 726 722 bool boot_loader_installed = FALSE; 727 /** malloc **/ 728 char tmp [MAX_STR_LEN], tmpA[MAX_STR_LEN], tmpB[MAX_STR_LEN],723 char *tmp = NULL; 724 char tmpA[MAX_STR_LEN], tmpB[MAX_STR_LEN], 729 725 tmpC[MAX_STR_LEN]; 730 726 … … 738 734 load_mountlist(mountlist, g_mountlist_fname); // in case read_cfg_file_into_bkpinfo updated the mountlist 739 735 #ifdef __FreeBSD__ 740 if (strstr 741 (call_program_and_get_last_line_of_output("cat /tmp/cmdline"), 742 "noresize")) 736 tmp = call_program_and_get_last_line_of_output("cat /tmp/cmdline"); 743 737 #else 744 if (strstr 745 (call_program_and_get_last_line_of_output("cat /proc/cmdline"), 746 "noresize")) 738 tmp = call_program_and_get_last_line_of_output("cat /proc/cmdline"); 747 739 #endif 748 {740 if (strstr(tmp,"noresize")) { 749 741 mr_msg(2, "Not resizing mountlist."); 750 742 } else { … … 752 744 } 753 745 if (!evaluate_mountlist(mountlist, tmpA, tmpB, tmpC)) { 754 sprintf(tmp, 755 "Mountlist analyzed. Result: \"%s %s %s\" Switch to Interactive Mode?", 746 mr_asprintf(&tmp, 747 _ 748 ("Mountlist analyzed. Result: \"%s %s %s\" Switch to Interactive Mode?"), 756 749 tmpA, tmpB, tmpC); 757 750 if (ask_me_yes_or_no(tmp)) { 751 mr_free(tmp); 758 752 retval = interactive_mode(bkpinfo, mountlist, raidlist); 759 goto after_the_nuke; 753 call_me_after_the_nuke(retval); 754 return(retval); 760 755 } else { 756 mr_free(tmp); 761 757 fatal_error("Nuke Mode aborted. "); 762 758 } 763 759 } 764 760 save_mountlist_to_disk(mountlist, g_mountlist_fname); 765 mvaddstr_and_log_it(1, 30, "Restoring Automatically");761 mvaddstr_and_log_it(1, 30, _("Restoring Automatically")); 766 762 if (bkpinfo->differential) { 767 log_to_screen("Because this is a differential backup, disk"); 768 log_to_screen("partitioning and formatting will not take place."); 763 log_to_screen(_("Because this is a differential backup, disk")); 764 log_to_screen(_ 765 ("partitioning and formatting will not take place.")); 769 766 res = 0; 770 767 } else { … … 776 773 g_fprep = fopen("/tmp/prep.sh", "w"); 777 774 #ifdef __FreeBSD__ 778 if (strstr 779 (call_program_and_get_last_line_of_output 780 ("cat /tmp/cmdline"), "nopart")) 775 tmp = call_program_and_get_last_line_of_output("cat /tmp/cmdline"); 781 776 #else 782 if (strstr 783 (call_program_and_get_last_line_of_output 784 ("cat /proc/cmdline"), "nopart")) 777 tmp = call_program_and_get_last_line_of_output("cat /proc/cmdline"); 785 778 #endif 786 {779 if (strstr(tmp,"nopart")) { 787 780 mr_msg(2, 788 781 "Not partitioning drives due to 'nopart' option."); … … 792 785 if (res) { 793 786 log_to_screen 794 ("Warning. Errors occurred during partitioning."); 787 (_ 788 ("Warning. Errors occurred during partitioning.")); 795 789 res = 0; 796 790 } … … 798 792 retval += res; 799 793 if (!res) { 800 log_to_screen( "Preparing to format your disk(s)");794 log_to_screen(_("Preparing to format your disk(s)")); 801 795 sleep(1); 802 system("sync"); 803 log_to_screen("Please wait. This may take a few minutes."); 796 sync(); 797 log_to_screen(_ 798 ("Please wait. This may take a few minutes.")); 804 799 res += format_everything(mountlist, FALSE, raidlist); 805 800 } … … 811 806 mvaddstr_and_log_it(g_currentY++, 812 807 0, 813 "Failed to partition and/or format your hard drives."); 814 815 if (ask_me_yes_or_no("Try in interactive mode instead?")) { 808 _ 809 ("Failed to partition and/or format your hard drives.")); 810 811 if (ask_me_yes_or_no(_("Try in interactive mode instead?"))) { 816 812 retval = interactive_mode(bkpinfo, mountlist, raidlist); 817 goto after_the_nuke; 813 call_me_after_the_nuke(retval); 814 return(retval); 818 815 } else 819 816 if (!ask_me_yes_or_no 820 ( "Would you like to try to proceed anyway?")) {821 return(retval);817 (_("Would you like to try to proceed anyway?"))) { 818 return(retval); 822 819 } 823 820 } … … 826 823 unmount_all_devices(mountlist); 827 824 log_to_screen 828 ("Unable to mount all partitions. Sorry, I cannot proceed."); 825 (_ 826 ("Unable to mount all partitions. Sorry, I cannot proceed.")); 829 827 return (retval); 830 828 } … … 837 835 } 838 836 protect_against_braindead_sysadmins(); 839 // run_program_and_log_output("cp -af /etc/lvm " MNT_RESTORING "/etc/", 1);840 // modify_rclocal_one_time( MNT_RESTORING "/etc" );841 837 retval += unmount_all_devices(mountlist); 842 838 mvaddstr_and_log_it(g_currentY, 843 839 0, 844 "Using e2label to label your ext2,3 partitions"); 845 846 sprintf(tmp, "label-partitions-as-necessary %s < /tmp/fstab", 840 _ 841 ("Using e2label to label your ext2,3 partitions")); 842 843 mr_asprintf(&tmp, "label-partitions-as-necessary %s < /tmp/fstab", 847 844 g_mountlist_fname); 848 845 res = run_program_and_log_output(tmp, TRUE); 846 mr_free(tmp); 847 849 848 if (res) { 850 log_to_screen("label-partitions-as-necessary returned an error"); 851 mvaddstr_and_log_it(g_currentY++, 74, "Failed."); 849 log_to_screen(_ 850 ("label-partitions-as-necessary returned an error")); 851 mvaddstr_and_log_it(g_currentY++, 74, _("Failed.")); 852 852 } else { 853 mvaddstr_and_log_it(g_currentY++, 74, "Done.");853 mvaddstr_and_log_it(g_currentY++, 74, _("Done.")); 854 854 } 855 855 retval += res; 856 856 857 after_the_nuke: 858 if (retval) { 859 log_to_screen("Errors occurred during the nuke phase."); 860 } else if (strstr(call_program_and_get_last_line_of_output("cat /proc/cmdline"), "RESTORE")) // Bruno's thing 861 { 862 log_to_screen 863 ("PC was restored successfully. Thank you for using Mondo Rescue."); 864 log_to_screen 865 ("Please visit our website at http://www.mondorescue.org for more information."); 866 } else { 867 strcpy(tmp,"Mondo has restored your system.\n\nPlease wait for the command prompt. Then remove the backup media and reboot.\n\nPlease visit our website at http://www.mondorescue.org for more information."); 868 if (strstr(call_program_and_get_last_line_of_output("cat /proc/cmdline"), "restore") == NULL) { 869 popup_and_OK(tmp); 870 } 871 log_to_screen 872 ("Mondo has restored your system. Please wait for the command prompt."); 873 log_to_screen 874 ("Then remove the backup media and reboot."); 875 log_to_screen 876 ("Please visit our website at http://www.mondorescue.org for more information."); 877 } 878 g_I_have_just_nuked = TRUE; 879 /* 880 if (!boot_loader_installed && !does_file_exist(DO_MBR_PLEASE)) 881 { 882 log_to_screen("PLEASE RUN 'mondorestore --mbr' NOW TO INITIALIZE YOUR BOOT SECTOR"); 883 write_one_liner_data_file(DO_MBR_PLEASE, "mondorestore --mbr"); 884 } 885 */ 857 call_me_after_the_nuke(retval); 886 858 return (retval); 887 859 } … … 890 862 *END_NUKE_MODE * 891 863 **************************************************************************/ 892 893 864 894 865 … … 903 874 int retval = 0; 904 875 905 /** malloc **/ 906 char *old_restpath; 907 908 struct mountlist_itself *mountlist; 909 // static 910 struct raidlist_itself *raidlist; 911 struct s_node *filelist; 876 char *old_restpath = NULL; 877 878 struct mountlist_itself *mountlist = NULL; 879 struct raidlist_itself *raidlist = NULL; 880 struct s_node *filelist = NULL; 912 881 913 882 mr_msg(1, "restore_to_live_filesystem() - starting"); 914 883 assert(bkpinfo != NULL); 915 malloc_string(old_restpath); 884 916 885 mountlist = mr_malloc(sizeof(struct mountlist_itself)); 917 886 raidlist = mr_malloc(sizeof(struct raidlist_itself)); … … 920 889 if (!g_restoring_live_from_cd) { 921 890 popup_and_OK 922 ("Please insert tape/CD/boot floppy, then hit 'OK' to continue."); 891 (_ 892 ("Please insert tape/CD/boot floppy, then hit 'OK' to continue.")); 923 893 sleep(1); 924 894 } 925 895 interactively_obtain_media_parameters_from_user(bkpinfo, FALSE); 926 mr_msg(2, "bkpinfo->media_device = %s", bkpinfo->media_device);927 896 if (!bkpinfo->media_device[0]) { 928 897 mr_msg(2, "Warning - failed to find media dev"); 898 } else { 899 mr_msg(2, "bkpinfo->media_device = %s", bkpinfo->media_device); 929 900 } 930 901 … … 932 903 mr_msg(2, "bkpinfo->isodir = %s", bkpinfo->isodir); 933 904 934 open_evalcall_form( "Thinking...");905 open_evalcall_form(_("Thinking...")); 935 906 936 907 get_cfg_file_from_archive_or_bust(bkpinfo); … … 944 915 if (filelist) { 945 916 save_filelist(filelist, "/tmp/selected-files.txt"); 946 strcpy(old_restpath,bkpinfo->restore_path);947 if (popup_and_get_string( "Restore path",948 "Restore files to where? )",949 bkpinfo->restore_path , MAX_STR_LEN / 4)) {917 mr_asprintf(&old_restpath,bkpinfo->restore_path); 918 if (popup_and_get_string(_("Restore path"), 919 _("Restore files to where? )"), 920 bkpinfo->restore_path)) { 950 921 iamhere("Restoring everything"); 951 922 retval += restore_everything(bkpinfo, filelist); 952 free_filelist(filelist); 953 strcpy(bkpinfo->restore_path, old_restpath); 954 } else { 955 free_filelist(filelist); 956 } 923 } 924 free_filelist(filelist); 957 925 strcpy(bkpinfo->restore_path, old_restpath); 926 mr_free(old_restpath); 958 927 } 959 928 if (IS_THIS_A_STREAMING_BACKUP(bkpinfo->backup_media_type)) { … … 962 931 } 963 932 run_program_and_log_output("umount " MNT_CDROM, FALSE); 964 if ( !bkpinfo->please_dont_eject) {933 if ((!bkpinfo->please_dont_eject) && (bkpinfo->media_device != NULL)) { 965 934 eject_device(bkpinfo->media_device); 966 935 } 967 mr_free(old_restpath);968 936 mr_free(mountlist); 969 937 mr_free(raidlist); … … 1000 968 char *pathname_of_last_file_restored) 1001 969 { 1002 FILE *fin; 1003 FILE *fout; 1004 FILE *fbzip2; 1005 1006 /** malloc ***/ 1007 char *checksum, *outfile_fname, *tmp, *bzip2_command, 1008 *ntfsprog_command, *suffix, *sz_devfile; 1009 char *bigblk; 1010 char *p; 970 FILE *fin = NULL; 971 FILE *fout = NULL; 972 FILE *fbzip2 = NULL; 973 974 char *checksum = NULL; 975 char *outfile_fname = NULL; 976 char *tmp = NULL; 977 char *bzip2_command = NULL; 978 char *suffix = NULL; 979 char *bigblk = NULL; 1011 980 int retval = 0; 1012 981 int finished = FALSE; 1013 long sliceno ;982 long sliceno = 0L; 1014 983 long siz; 1015 char ntfsprog_fifo[MAX_STR_LEN];984 char *ntfsprog_fifo = NULL; 1016 985 char *file_to_openout = NULL; 1017 986 struct s_filename_and_lstat_info biggiestruct; 1018 struct utimbuf the_utime_buf, *ubuf ;987 struct utimbuf the_utime_buf, *ubuf = NULL; 1019 988 bool use_ntfsprog_hack = FALSE; 1020 989 pid_t pid; 1021 990 int res = 0; 1022 991 int old_loglevel; 1023 char sz_msg[MAX_STR_LEN];1024 struct s_node *node ;992 char *sz_msg = NULL; 993 struct s_node *node = NULL; 1025 994 1026 995 old_loglevel = g_loglevel; 1027 996 ubuf = &the_utime_buf; 1028 997 assert(bkpinfo != NULL); 1029 1030 malloc_string(checksum);1031 malloc_string(outfile_fname);1032 malloc_string(tmp);1033 malloc_string(bzip2_command);1034 malloc_string(ntfsprog_command);1035 malloc_string(suffix);1036 malloc_string(sz_devfile);1037 998 1038 999 pathname_of_last_file_restored[0] = '\0'; … … 1052 1013 paranoid_fclose(fin); 1053 1014 1054 strcpy(checksum, biggiestruct.checksum);1015 mr_asprintf(&checksum, biggiestruct.checksum); 1055 1016 1056 1017 if (!checksum[0]) { 1057 sprintf(tmp, "Warning - bigfile %ld does not have a checksum",1018 mr_msg(3, "Warning - bigfile %ld does not have a checksum", 1058 1019 bigfileno + 1); 1059 mr_msg(3, tmp); 1060 p = checksum; 1061 } 1020 } 1021 mr_free(checksum); 1062 1022 1063 1023 if (!strncmp(biggiestruct.filename, "/dev/", 5)) // Whether NTFS or not :) 1064 1024 { 1065 strcpy(outfile_fname, biggiestruct.filename);1025 mr_asprintf(&outfile_fname, biggiestruct.filename); 1066 1026 } else { 1067 sprintf(outfile_fname, "%s/%s", bkpinfo->restore_path,1027 mr_asprintf(&outfile_fname, "%s/%s", bkpinfo->restore_path, 1068 1028 biggiestruct.filename); 1069 1029 } … … 1075 1035 mr_msg(0, "Skipping %s (name isn't in filelist)", 1076 1036 biggiestruct.filename); 1077 pathname_of_last_file_restored[0] = '\0';1078 1037 return (0); 1079 1038 } else if (!(node->selected)) { 1080 1039 mr_msg(1, "Skipping %s (name isn't in biggielist subset)", 1081 1040 biggiestruct.filename); 1082 pathname_of_last_file_restored[0] = '\0';1083 1041 return (0); 1084 1042 } … … 1097 1055 1098 1056 if (biggiestruct.use_ntfsprog) // if it's an NTFS device 1099 // if (!strncmp ( biggiestruct.filename, "/dev/", 5))1100 1057 { 1101 1058 g_loglevel = 4; … … 1104 1061 "Calling ntfsclone in background because %s is an NTFS /dev entry", 1105 1062 outfile_fname); 1106 sprintf(sz_devfile, "/tmp/%d.%d.000", (int) (random() % 32768),1063 mr_asprintf(&ntfsprog_fifo, "/tmp/%d.%d.000", (int) (random() % 32768), 1107 1064 (int) (random() % 32768)); 1108 mkfifo( sz_devfile, 0x770);1109 strcpy(ntfsprog_fifo, sz_devfile); 1065 mkfifo(ntfsprog_fifo, 0x770); 1066 1110 1067 file_to_openout = ntfsprog_fifo; 1111 1068 switch (pid = fork()) { … … 1118 1075 res = 1119 1076 feed_outfrom_ntfsprog(biggiestruct.filename, 1120 ntfsprog_fifo); 1121 // mr_msg(3, "CHILD - fip - exiting"); 1077 ntfsprog_fifo); 1122 1078 exit(res); 1123 1079 break; … … 1129 1085 } else { 1130 1086 use_ntfsprog_hack = FALSE; 1131 ntfsprog_fifo[0] = '\0';1132 1087 file_to_openout = outfile_fname; 1133 1088 if (!does_file_exist(outfile_fname)) // yes, it looks weird with the '!' but it's correct that way … … 1137 1092 } 1138 1093 1139 sprintf(tmp, "Reassembling big file %ld (%s)", bigfileno + 1,1094 mr_msg(2, "Reassembling big file %ld (%s)", bigfileno + 1, 1140 1095 outfile_fname); 1141 mr_msg(2, tmp);1142 1096 1143 1097 /* … … 1153 1107 mr_msg(3, "file_to_openout = %s", file_to_openout); 1154 1108 if (!(fout = fopen(file_to_openout, "w"))) { 1155 log_to_screen( "Cannot openout outfile_fname - hard disk full?");1109 log_to_screen(_("Cannot openout file_to_openout - hard disk full?")); 1156 1110 return (1); 1157 1111 } 1112 1113 mr_free(ntfsprog_fifo); 1158 1114 mr_msg(3, "Opened out to %s", outfile_fname); // CD/DVD --> mondorestore --> ntfsclone --> hard disk itself 1159 1115 … … 1174 1130 g_current_media_number); 1175 1131 g_current_media_number++; 1176 sprintf(tmp, 1177 "Asking for %s #%d so that I may read slice #%ld\n", 1132 mr_msg(2, "Asking for %s #%d so that I may read slice #%ld\n", 1178 1133 media_descriptor_string(bkpinfo->backup_media_type), 1179 1134 g_current_media_number, sliceno); 1180 mr_msg(2, tmp); 1181 sprintf(tmp, "Restoring from %s #%d", 1182 media_descriptor_string(bkpinfo->backup_media_type), 1135 log_to_screen(_("Restoring from %s #%d"), 1136 bkpinfo->backup_media_string, 1183 1137 g_current_media_number); 1184 log_to_screen(tmp);1185 1138 insist_on_this_cd_number(bkpinfo, g_current_media_number); 1186 log_to_screen( "Continuing to restore.");1139 log_to_screen(_("Continuing to restore.")); 1187 1140 } else { 1188 strcpy(tmp,1141 mr_asprintf(&tmp, 1189 1142 slice_fname(bigfileno, sliceno, ARCHIVES_PATH, "")); 1190 1143 if (does_file_exist(tmp) && length_of_file(tmp) == 0) { … … 1193 1146 bigfileno + 1, sliceno); 1194 1147 finished = TRUE; 1148 mr_free(tmp); 1195 1149 continue; 1196 1150 } else { 1151 mr_free(tmp); 1197 1152 if (does_file_exist 1198 1153 (slice_fname 1199 1154 (bigfileno, sliceno, ARCHIVES_PATH, "lzo"))) { 1200 strcpy(bzip2_command, "lzop");1201 strcpy(suffix, "lzo");1155 mr_asprintf(&bzip2_command, "lzop"); 1156 mr_asprintf(&suffix, "lzo"); 1202 1157 } else 1203 1158 if (does_file_exist 1204 1159 (slice_fname 1205 1160 (bigfileno, sliceno, ARCHIVES_PATH, "gz"))) { 1206 strcpy(bzip2_command, "gzip");1207 strcpy(suffix, "gz");1161 mr_asprintf(&bzip2_command, "gzip"); 1162 mr_asprintf(&suffix, "gz"); 1208 1163 } else 1209 1164 if (does_file_exist 1210 1165 (slice_fname 1211 1166 (bigfileno, sliceno, ARCHIVES_PATH, "bz2"))) { 1212 strcpy(bzip2_command, "bzip2");1213 strcpy(suffix, "bz2");1167 mr_asprintf(&bzip2_command, "bzip2"); 1168 mr_asprintf(&suffix, "bz2"); 1214 1169 } else 1215 1170 if (does_file_exist 1216 1171 (slice_fname 1217 1172 (bigfileno, sliceno, ARCHIVES_PATH, ""))) { 1218 strcpy(bzip2_command, "");1219 strcpy(suffix, "");1173 mr_asprintf(&bzip2_command, ""); 1174 mr_asprintf(&suffix, ""); 1220 1175 } else { 1221 log_to_screen( "OK, that's pretty fsck0red...");1176 log_to_screen(_("OK, that's pretty fsck0red...")); 1222 1177 return (1); 1223 1178 } 1224 1179 } 1225 1180 if (bzip2_command[0] != '\0') { 1226 sprintf(bzip2_command + strlen(bzip2_command),1181 mr_strcat(bzip2_command, 1227 1182 " -dc %s 2>> %s", 1228 1183 slice_fname(bigfileno, sliceno, ARCHIVES_PATH, 1229 1184 suffix), MONDO_LOGFILE); 1230 1185 } else { 1231 sprintf(bzip2_command, "cat %s 2>> %s", 1186 mr_free(bzip2_command); 1187 mr_asprintf(&bzip2_command, "cat %s 2>> %s", 1232 1188 slice_fname(bigfileno, sliceno, ARCHIVES_PATH, 1233 1189 suffix), MONDO_LOGFILE); 1234 1190 } 1235 sprintf(tmp, "Working on %s #%d, file #%ld, slice #%ld",1236 media_descriptor_string(bkpinfo->backup_media_type),1191 mr_asprintf(&tmp, "Working on %s #%d, file #%ld, slice #%ld", 1192 bkpinfo->backup_media_string, 1237 1193 g_current_media_number, bigfileno + 1, sliceno); 1238 1194 mr_msg(2, tmp); 1239 1240 1195 if (!g_text_mode) { 1241 1196 newtDrawRootText(0, g_noof_rows - 2, tmp); 1242 1197 newtRefresh(); 1243 mr_strip_spaces(tmp);1244 1198 update_progress_form(tmp); 1245 1199 } 1200 mr_free(tmp); 1201 1246 1202 if (!(fbzip2 = popen(bzip2_command, "r"))) { 1203 mr_free(bzip2_command); 1204 mr_free(suffix); 1247 1205 fatal_error("Can't run popen command"); 1248 1206 } 1207 mr_free(bzip2_command); 1208 mr_free(suffix); 1209 1249 1210 while (!feof(fbzip2)) { 1250 1211 siz = fread(bigblk, 1, TAPE_BLOCK_SIZE, fbzip2); 1251 1212 if (siz > 0) { 1252 sprintf(sz_msg, "Read %ld from fbzip2", siz);1253 1213 siz = fwrite(bigblk, 1, siz, fout); 1254 sprintf(sz_msg + strlen(sz_msg),1255 "; written %ld to fout", siz);1256 // mr_msg(2. sz_msg);1257 1214 } 1258 1215 } 1259 1216 paranoid_pclose(fbzip2); 1260 1261 1217 1262 1218 sliceno++; … … 1264 1220 } 1265 1221 } 1266 /*1267 memset(bigblk, TAPE_BLOCK_SIZE, 1); // This all looks very fishy...1268 fwrite( bigblk, 1, TAPE_BLOCK_SIZE, fout);1269 fwrite( bigblk, 1, TAPE_BLOCK_SIZE, fout);1270 fwrite( bigblk, 1, TAPE_BLOCK_SIZE, fout);1271 fwrite( bigblk, 1, TAPE_BLOCK_SIZE, fout);1272 */1273 1222 paranoid_fclose(fout); 1274 1223 g_loglevel = old_loglevel; … … 1276 1225 if (use_ntfsprog_hack) { 1277 1226 mr_msg(3, "Waiting for ntfsclone to finish"); 1278 sprintf(tmp,1227 mr_asprintf(&tmp, 1279 1228 " ps | grep \" ntfsclone \" | grep -v grep > /dev/null 2> /dev/null"); 1280 1229 while (system(tmp) == 0) { 1281 1230 sleep(1); 1282 1231 } 1232 mr_free(tmp); 1283 1233 log_it("OK, ntfsclone has really finished"); 1284 1234 } … … 1292 1242 utime(outfile_fname, ubuf); 1293 1243 } 1244 mr_free(outfile_fname); 1294 1245 mr_free(bigblk); 1295 mr_free(checksum);1296 mr_free(outfile_fname);1297 mr_free(tmp);1298 mr_free(bzip2_command);1299 mr_free(ntfsprog_command);1300 mr_free(suffix);1301 mr_free(sz_devfile);1302 1246 1303 1247 return (retval); 1304 1248 } 1249 1305 1250 1306 1251 /************************************************************************** 1307 1252 *END_ RESTORE_A_BIGGIEFILE_FROM_CD * 1308 1253 **************************************************************************/ 1309 1310 1254 1311 1255 … … 1317 1261 * @param orig_bf_fname The original filename of the biggiefile. 1318 1262 * @param biggiefile_number The number of the biggiefile (starting from 0). 1319 * @param orig_checksum Unused.1320 * @param biggiefile_size Unused.1321 1263 * @param filelist The node structure containing the list of files to be restored. 1322 1264 * If @p orig_bf_fname is not in the list, it will be ignored. 1323 1265 * @return 0 for success (or skip), nonzero for failure. 1324 * @bug orig_checksum and biggiefile_size are unused (except to check that they are non-NULL).1325 1266 */ 1326 1267 int restore_a_biggiefile_from_stream(struct s_bkpinfo *bkpinfo, char *orig_bf_fname, long biggiefile_number, char *orig_checksum, //UNUSED … … 1330 1271 char *pathname_of_last_file_restored) 1331 1272 { 1332 FILE *pout ;1333 FILE *fin ;1273 FILE *pout = NULL; 1274 FILE *fin = NULL; 1334 1275 1335 1276 /** mallocs ********/ 1336 char *tmp; 1337 char *command; 1338 char *outfile_fname; 1339 char *ntfsprog_command; 1340 char *sz_devfile; 1341 char *ntfsprog_fifo; 1277 char *tmp = NULL; 1278 char *tmp1 = NULL; 1279 char *command = NULL; 1280 char *outfile_fname = NULL; 1281 char *ntfsprog_fifo = NULL; 1342 1282 char *file_to_openout = NULL; 1343 1283 1344 struct s_node *node ;1345 1346 int old_loglevel ;1284 struct s_node *node = NULL; 1285 1286 int old_loglevel = 0; 1347 1287 long current_slice_number = 0; 1348 1288 int retval = 0; 1349 1289 int res = 0; 1350 1290 int ctrl_chr = '\0'; 1351 long long slice_siz ;1291 long long slice_siz = 0L; 1352 1292 bool dummy_restore = FALSE; 1353 1293 bool use_ntfsprog_hack = FALSE; 1354 1294 pid_t pid; 1355 1295 struct s_filename_and_lstat_info biggiestruct; 1356 struct utimbuf the_utime_buf, *ubuf ;1296 struct utimbuf the_utime_buf, *ubuf = NULL; 1357 1297 ubuf = &the_utime_buf; 1358 1298 1359 malloc_string(tmp);1360 malloc_string(ntfsprog_fifo);1361 malloc_string(outfile_fname);1362 malloc_string(command);1363 malloc_string(sz_devfile);1364 malloc_string(ntfsprog_command);1365 1299 old_loglevel = g_loglevel; 1366 1300 assert(bkpinfo != NULL); … … 1404 1338 if (use_ntfsprog) { 1405 1339 if (strncmp(orig_bf_fname, "/dev/", 5)) { 1406 mr_msg(1, 1407 "I was in error when I set use_ntfsprog to TRUE."); 1340 mr_msg(1, "I was in error when I set use_ntfsprog to TRUE."); 1408 1341 mr_msg(1, "%s isn't even in /dev", orig_bf_fname); 1409 1342 use_ntfsprog = FALSE; … … 1413 1346 if (use_ntfsprog) { 1414 1347 g_loglevel = 4; 1415 strcpy(outfile_fname, orig_bf_fname);1348 mr_asprintf(&outfile_fname, orig_bf_fname); 1416 1349 use_ntfsprog_hack = TRUE; 1417 1350 mr_msg(2, 1418 1351 "Calling ntfsclone in background because %s is a /dev entry", 1419 1352 outfile_fname); 1420 sprintf(sz_devfile, "%s/%d.%d.000",1353 mr_asprintf(&ntfsprog_fifo, "%s/%d.%d.000", 1421 1354 bkpinfo->tmpdir, 1422 1355 (int) (random() % 32768), 1423 1356 (int) (random() % 32768)); 1424 mkfifo( sz_devfile, 0x770);1425 strcpy(ntfsprog_fifo, sz_devfile); 1357 mkfifo(ntfsprog_fifo, 0x770); 1358 1426 1359 file_to_openout = ntfsprog_fifo; 1427 1360 switch (pid = fork()) { … … 1432 1365 "CHILD - fip - calling feed_outfrom_ntfsprog(%s, %s)", 1433 1366 outfile_fname, ntfsprog_fifo); 1434 res = 1435 feed_outfrom_ntfsprog(outfile_fname, ntfsprog_fifo); 1436 // mr_msg(3, "CHILD - fip - exiting"); 1367 res = feed_outfrom_ntfsprog(outfile_fname, ntfsprog_fifo); 1437 1368 exit(res); 1438 1369 break; … … 1445 1376 if (!strncmp(orig_bf_fname, "/dev/", 5)) // non-NTFS partition 1446 1377 { 1447 strcpy(outfile_fname, orig_bf_fname);1378 mr_asprintf(&outfile_fname, orig_bf_fname); 1448 1379 } else // biggiefile 1449 1380 { 1450 sprintf(outfile_fname, "%s/%s", bkpinfo->restore_path,1381 mr_asprintf(&outfile_fname, "%s/%s", bkpinfo->restore_path, 1451 1382 orig_bf_fname); 1452 1383 } 1453 1384 use_ntfsprog_hack = FALSE; 1454 ntfsprog_fifo[0] = '\0';1455 1385 file_to_openout = outfile_fname; 1456 1386 if (!does_file_exist(outfile_fname)) // yes, it looks weird with the '!' but it's correct that way … … 1458 1388 make_hole_for_file(outfile_fname); 1459 1389 } 1460 sprintf(tmp, "Reassembling big file %ld (%s)",1390 mr_msg(2, "Reassembling big file %ld (%s)", 1461 1391 biggiefile_number + 1, orig_bf_fname); 1462 mr_msg(2, tmp);1463 1392 } 1464 1393 1465 1394 if (dummy_restore) { 1466 sprintf(outfile_fname, "/dev/null"); 1395 mr_free(outfile_fname); 1396 mr_asprintf(&outfile_fname, "/dev/null"); 1467 1397 } 1468 1398 1469 1399 if (!bkpinfo->zip_exe[0]) { 1470 sprintf(command, "cat > \"%s\"", file_to_openout);1400 mr_asprintf(&command, "cat > \"%s\"", file_to_openout); 1471 1401 } else { 1472 sprintf(command, "%s -dc > \"%s\" 2>> %s", bkpinfo->zip_exe,1402 mr_asprintf(&command, "%s -dc > \"%s\" 2>> %s", bkpinfo->zip_exe, 1473 1403 file_to_openout, MONDO_LOGFILE); 1474 1404 } 1475 sprintf(tmp, "Pipe command = '%s'", command); 1476 mr_msg(3, tmp); 1405 mr_msg(3, "Pipe command = '%s'", command); 1406 mr_free(outfile_fname); 1407 mr_free(ntfsprog_fifo); 1477 1408 1478 1409 /* restore biggiefile, one slice at a time */ … … 1480 1411 fatal_error("Cannot pipe out"); 1481 1412 } 1482 for (res = read_header_block_from_stream(&slice_siz, tmp, &ctrl_chr); 1413 mr_free(command); 1414 1415 malloc_string(tmp1); 1416 for (res = read_header_block_from_stream(&slice_siz, tmp1, &ctrl_chr); 1483 1417 ctrl_chr != BLK_STOP_A_BIGGIE; 1484 res = read_header_block_from_stream(&slice_siz, tmp , &ctrl_chr)) {1418 res = read_header_block_from_stream(&slice_siz, tmp1, &ctrl_chr)) { 1485 1419 if (ctrl_chr != BLK_START_AN_AFIO_OR_SLICE) { 1486 1420 wrong_marker(BLK_START_AN_AFIO_OR_SLICE, ctrl_chr); 1487 1421 } 1488 sprintf(tmp, "Working on file #%ld, slice #%ld ",1422 mr_asprintf(&tmp, "Working on file #%ld, slice #%ld ", 1489 1423 biggiefile_number + 1, current_slice_number); 1490 1424 mr_msg(2, tmp); … … 1495 1429 mr_strip_spaces(tmp); 1496 1430 update_progress_form(tmp); 1431 mr_free(tmp); 1497 1432 if (current_slice_number == 0) { 1498 1433 res = … … 1517 1452 } 1518 1453 retval += res; 1519 res = read_header_block_from_stream(&slice_siz, tmp , &ctrl_chr);1454 res = read_header_block_from_stream(&slice_siz, tmp1, &ctrl_chr); 1520 1455 if (ctrl_chr != BLK_STOP_AN_AFIO_OR_SLICE) { 1521 1456 wrong_marker(BLK_STOP_AN_AFIO_OR_SLICE, ctrl_chr); … … 1524 1459 g_current_progress++; 1525 1460 } 1461 mr_free(tmp1); 1526 1462 paranoid_pclose(pout); 1527 1463 … … 1531 1467 if (use_ntfsprog_hack) { 1532 1468 mr_msg(3, "Waiting for ntfsclone to finish"); 1533 sprintf(tmp,1469 mr_asprintf(&tmp, 1534 1470 " ps | grep \" ntfsclone \" | grep -v grep > /dev/null 2> /dev/null"); 1535 1471 while (system(tmp) == 0) { 1536 1472 sleep(1); 1537 } 1473 } 1474 mr_free(tmp); 1538 1475 mr_msg(3, "OK, ntfsclone has really finished"); 1539 1476 } … … 1550 1487 } 1551 1488 1552 mr_free(tmp);1553 mr_free(outfile_fname);1554 mr_free(command);1555 mr_free(ntfsprog_command);1556 mr_free(sz_devfile);1557 mr_free(ntfsprog_fifo);1558 1489 g_loglevel = old_loglevel; 1559 1490 return (retval); … … 1563 1494 *END_RESTORE_A_BIGGIEFILE_FROM_STREAM * 1564 1495 **************************************************************************/ 1565 1566 1496 1567 1497 … … 1583 1513 { 1584 1514 int retval = 0; 1585 int res ;1586 char *p ;1515 int res = 0; 1516 char *p = NULL; 1587 1517 1588 1518 /** malloc **/ 1589 char *command; 1590 char *tmp; 1591 char *filelist_name; 1592 char *filelist_subset_fname; 1593 char *executable; 1594 char *temp_log; 1595 char screen_message[100]; 1519 char *command = NULL; 1520 char *tmp = NULL; 1521 char *filelist_name = NULL; 1522 char *filelist_subset_fname = NULL; 1523 char *executable = NULL; 1524 char *temp_log = NULL; 1596 1525 long matches = 0; 1597 bool use_star; 1598 char *xattr_fname; 1599 char *acl_fname; 1600 // char files_to_restore_this_time_fname[MAX_STR_LEN]; 1526 bool use_star = FALSE; 1527 char *xattr_fname = NULL; 1528 char *acl_fname = NULL; 1601 1529 1602 1530 assert_string_is_neither_NULL_nor_zerolength(tarball_fname); 1603 malloc_string(command);1604 malloc_string(tmp);1605 malloc_string(filelist_name);1606 malloc_string(filelist_subset_fname);1607 malloc_string(executable);1608 malloc_string(temp_log);1609 malloc_string(xattr_fname);1610 malloc_string(acl_fname);1611 1531 1612 1532 mr_msg(5, "Entering"); 1613 filelist_subset_fname[0] = '\0';1614 1533 use_star = (strstr(tarball_fname, ".star")) ? TRUE : FALSE; 1615 // sprintf(files_to_restore_this_time_fname, "/tmp/ftrttf.%d.%d", (int)getpid(), (int)random()); 1616 sprintf(command, "mkdir -p %s/tmp", MNT_RESTORING); 1534 mr_asprintf(&command, "mkdir -p %s/tmp", MNT_RESTORING); 1617 1535 run_program_and_log_output(command, 9); 1618 sprintf(temp_log, "/tmp/%d.%d", (int) (random() % 32768), 1619 (int) (random() % 32768)); 1620 1621 sprintf(filelist_name, MNT_CDROM "/archives/filelist.%ld", 1536 mr_free(command); 1537 1538 mr_asprintf(&filelist_name, MNT_CDROM "/archives/filelist.%ld", 1622 1539 current_tarball_number); 1623 1540 if (length_of_file(filelist_name) <= 2) { … … 1629 1546 "but it's non-critical. It's cosmetic. Don't worry about it."); 1630 1547 retval = 0; 1631 goto leave_sub; 1548 mr_msg(5, "Leaving"); 1549 mr_free(filelist_name); 1550 return (retval); 1632 1551 } 1633 1552 if (count_lines_in_file(filelist_name) <= 0 … … 1635 1554 mr_msg(3, "length_of_file(%s) = %llu", tarball_fname, 1636 1555 length_of_file(tarball_fname)); 1637 sprintf(tmp, "Unable to restore fileset #%ld (CD I/O error)",1556 log_to_screen(_("Unable to restore fileset #%ld (CD I/O error)"), 1638 1557 current_tarball_number); 1639 log_to_screen(tmp);1640 1558 retval = 1; 1641 goto leave_sub; 1559 mr_msg(5, "Leaving"); 1560 mr_free(filelist_name); 1561 return (retval); 1642 1562 } 1643 1563 1644 1564 if (filelist) { 1645 sprintf(filelist_subset_fname, "/tmp/filelist-subset-%ld.tmp",1565 mr_asprintf(&filelist_subset_fname, "/tmp/filelist-subset-%ld.tmp", 1646 1566 current_tarball_number); 1647 1567 if ((matches = … … 1650 1570 use_star)) 1651 1571 <= 0) { 1652 sprintf(tmp, "Skipping fileset %ld", current_tarball_number); 1653 mr_msg(1, tmp); 1572 mr_msg(1, "Skipping fileset %ld", current_tarball_number); 1654 1573 } else { 1655 1574 mr_msg(3, "Saved fileset %ld's subset to %s", 1656 1575 current_tarball_number, filelist_subset_fname); 1657 1576 } 1658 sprintf(screen_message,"Tarball #%ld --- %ld matches",1577 log_to_screen("Tarball #%ld --- %ld matches", 1659 1578 current_tarball_number, matches); 1660 log_to_screen(screen_message); 1661 } else { 1662 filelist_subset_fname[0] = '\0'; 1663 } 1579 } 1580 mr_free(filelist_name); 1664 1581 1665 1582 if (filelist == NULL || matches > 0) { 1666 1583 if (g_getfattr) { 1667 sprintf(xattr_fname, XATTR_LIST_FNAME_RAW_SZ,1584 mr_asprintf(&xattr_fname, XATTR_LIST_FNAME_RAW_SZ, 1668 1585 MNT_CDROM "/archives", current_tarball_number); 1669 1586 } 1670 1587 if (g_getfacl) { 1671 sprintf(acl_fname, ACL_LIST_FNAME_RAW_SZ, MNT_CDROM "/archives",1588 mr_asprintf(&acl_fname, ACL_LIST_FNAME_RAW_SZ, MNT_CDROM "/archives", 1672 1589 current_tarball_number); 1673 1590 } 1674 1591 if (strstr(tarball_fname, ".bz2")) { 1675 strcpy(executable, "bzip2");1592 mr_asprintf(&executable, "-P bzip2 -Z"); 1676 1593 } else if (strstr(tarball_fname, ".gz")) { 1677 strcpy(executable, "gzip");1594 mr_asprintf(&executable, "-P gzip -Z"); 1678 1595 } else if (strstr(tarball_fname, ".lzo")) { 1679 strcpy(executable, "lzop"); 1680 } else { 1681 executable[0] = '\0'; 1682 } 1683 if (executable[0]) { 1684 sprintf(tmp, "which %s > /dev/null 2> /dev/null", executable); 1596 mr_asprintf(&executable, "-P lzop -Z"); 1597 } 1598 1599 if (executable == NULL) { 1600 mr_asprintf(&tmp, "which %s > /dev/null 2> /dev/null", executable); 1685 1601 if (run_program_and_log_output(tmp, FALSE)) { 1686 1602 log_to_screen 1687 ("(compare_a_tarball) Compression program not found - oh no!"); 1603 (_ 1604 ("(compare_a_tarball) Compression program not found - oh no!")); 1605 mr_free(tmp); 1606 mr_free(executable); 1607 mr_free(acl_fname); 1608 mr_free(xattr_fname); 1609 mr_free(filelist_subset_fname); 1688 1610 paranoid_MR_finish(1); 1689 1611 } 1690 strcpy(tmp, executable); 1691 sprintf(executable, "-P %s -Z", tmp); 1612 mr_free(tmp); 1692 1613 } 1693 1614 #ifdef __FreeBSD__ … … 1697 1618 #endif 1698 1619 1699 // if (strstr(tarball_fname, ".star."))1700 1620 if (use_star) { 1701 sprintf(command,1621 mr_sprintf(&command, 1702 1622 "star -x -force-remove -U " STAR_ACL_SZ 1703 1623 " errctl= file=%s", tarball_fname); 1704 1624 if (strstr(tarball_fname, ".bz2")) { 1705 strcat(command, " -bz");1625 mr_strcat(command, " -bz"); 1706 1626 } 1707 1627 } else { 1708 if (filelist_subset_fname [0] != '\0') {1709 sprintf(command,1628 if (filelist_subset_fname != NULL) { 1629 mr_asprintf(&command, 1710 1630 "afio -i -M 8m -b %ld -c %ld %s -w '%s' %s", 1711 1631 TAPE_BLOCK_SIZE, 1712 1632 BUFSIZE, executable, filelist_subset_fname, 1713 // files_to_restore_this_time_fname,1714 1633 tarball_fname); 1715 1634 } else { 1716 sprintf(command,1635 mr_asprintf(&command, 1717 1636 "afio -i -b %ld -c %ld -M 8m %s %s", 1718 1637 TAPE_BLOCK_SIZE, … … 1720 1639 } 1721 1640 } 1641 mr_free(executable); 1642 1722 1643 #undef BUFSIZE 1723 sprintf(command + strlen(command), " 2>> %s >> %s", temp_log, 1724 temp_log); 1644 mr_asprintf(&temp_log, "/tmp/%d.%d", (int) (random() % 32768), 1645 (int) (random() % 32768)); 1646 1647 mr_strcat(command, " 2>> %s >> %s", temp_log, temp_log); 1725 1648 mr_msg(1, "command = '%s'", command); 1726 1649 unlink(temp_log); … … 1734 1657 } 1735 1658 } 1659 mr_free(command); 1660 1736 1661 if (res && length_of_file(temp_log) < 5) { 1737 1662 res = 0; … … 1765 1690 } 1766 1691 if (retval) { 1767 sprintf(command, "cat %s >> %s", temp_log, MONDO_LOGFILE);1692 mr_asprintf(&command, "cat %s >> %s", temp_log, MONDO_LOGFILE); 1768 1693 system(command); 1694 mr_free(command); 1769 1695 mr_msg(2, "Errors occurred while processing fileset #%d", 1770 1696 current_tarball_number); … … 1772 1698 mr_msg(2, "Fileset #%d processed OK", current_tarball_number); 1773 1699 } 1700 unlink(xattr_fname); 1701 mr_free(xattr_fname); 1702 unlink(acl_fname); 1703 mr_free(acl_fname); 1704 unlink(temp_log); 1705 mr_free(temp_log); 1774 1706 } 1775 1707 if (does_file_exist("/PAUSE")) { 1776 1708 popup_and_OK 1777 ("Press ENTER to go on. Delete /PAUSE to stop these pauses."); 1709 (_ 1710 ("Press ENTER to go on. Delete /PAUSE to stop these pauses.")); 1778 1711 } 1779 1712 unlink(filelist_subset_fname); 1780 unlink(xattr_fname);1781 unlink(acl_fname);1782 unlink(temp_log);1783 1784 leave_sub:1785 mr_free(command);1786 mr_free(tmp);1787 mr_free(filelist_name);1788 1713 mr_free(filelist_subset_fname); 1789 mr_free(executable);1790 mr_free(temp_log);1791 mr_free(xattr_fname);1792 mr_free(acl_fname);1793 1714 mr_msg(5, "Leaving"); 1794 1715 return (retval); … … 1827 1748 1828 1749 /** malloc add ***/ 1829 char *tmp ;1830 char *command ;1831 char *afio_fname ;1832 char *filelist_fname ;1833 char *filelist_subset_fname ;1834 char *executable ;1750 char *tmp = NULL; 1751 char *command = NULL; 1752 char *afio_fname = NULL; 1753 char *filelist_fname = NULL; 1754 char *filelist_subset_fname = NULL; 1755 char *executable = NULL; 1835 1756 long matches = 0; 1836 1757 bool restore_this_fileset = FALSE; 1837 bool use_star ;1758 bool use_star = FALSE; 1838 1759 1839 1760 assert(bkpinfo != NULL); 1840 1761 assert_string_is_neither_NULL_nor_zerolength(tarball_fname); 1841 malloc_string(filelist_subset_fname);1842 malloc_string(filelist_fname);1843 malloc_string(afio_fname);1844 malloc_string(executable);1845 malloc_string(command);1846 malloc_string(tmp);1847 filelist_subset_fname[0] = '\0';1848 1762 /* to do it with a file... */ 1849 1763 use_star = (strstr(tarball_fname, ".star")) ? TRUE : FALSE; 1850 sprintf(tmp, 1851 "Restoring from fileset #%ld (%ld KB) on %s #%d", 1764 mr_msg(2, "Restoring from fileset #%ld (%ld KB) on %s #%d", 1852 1765 current_tarball_number, (long) size >> 10, 1853 media_descriptor_string(bkpinfo->backup_media_type),1766 bkpinfo->backup_media_string, 1854 1767 g_current_media_number); 1855 mr_msg(2, tmp);1856 1768 run_program_and_log_output("mkdir -p " MNT_RESTORING "/tmp", FALSE); 1857 1769 … … 1861 1773 * in afio or someting; oh darn.. OK, use tmpfs :-) * 1862 1774 ****************************************************************************/ 1863 filelist_fname[0] = filelist_subset_fname[0] = '\0'; 1864 sprintf(afio_fname, "/tmp/tmpfs/archive.tmp.%ld", 1775 mr_asprintf(&afio_fname, "/tmp/tmpfs/archive.tmp.%ld", 1865 1776 current_tarball_number); 1866 sprintf(filelist_fname, "%s/filelist.%ld", bkpinfo->tmpdir,1777 mr_asprintf(&filelist_fname, "%s/filelist.%ld", bkpinfo->tmpdir, 1867 1778 current_tarball_number); 1868 sprintf(filelist_subset_fname, "%s/filelist-subset-%ld.tmp",1779 mr_asprintf(&filelist_subset_fname, "%s/filelist-subset-%ld.tmp", 1869 1780 bkpinfo->tmpdir, current_tarball_number); 1870 // sprintf(filelist_fname, "/tmp/tmpfs/temp-filelist.%ld", current_tarball_number);1871 1781 res = read_file_from_stream_to_file(bkpinfo, afio_fname, size); 1872 1782 if (strstr(tarball_fname, ".star")) { … … 1876 1786 mr_msg(1, "Warning - error reading afioball from tape"); 1877 1787 } 1878 if (bkpinfo->compression_level == 0) { 1879 executable[0] = '\0'; 1880 } else { 1788 if (bkpinfo->compression_level != 0) { 1881 1789 if (bkpinfo->use_star) { 1882 strcpy(executable, " -bz");1790 mr_asprintf(&executable, " -bz"); 1883 1791 } else { 1884 sprintf(executable, "-P %s -Z", bkpinfo->zip_exe);1792 mr_asprintf(&executable, "-P %s -Z", bkpinfo->zip_exe); 1885 1793 } 1886 1794 } … … 1893 1801 if (strstr(tarball_fname, ".star.")) { 1894 1802 use_star = TRUE; 1895 sprintf(command, "star -t file=%s %s", afio_fname, executable);1803 mr_asprintf(&command, "star -t file=%s %s", afio_fname, executable); 1896 1804 } else { 1897 1805 use_star = FALSE; 1898 sprintf(command, "afio -t -M 8m -b %ld %s %s", TAPE_BLOCK_SIZE,1806 mr_asprintf(&command, "afio -t -M 8m -b %ld %s %s", TAPE_BLOCK_SIZE, 1899 1807 executable, afio_fname); 1900 1808 } 1901 sprintf(command + strlen(command), " > %s 2>> %s", filelist_fname, 1902 MONDO_LOGFILE); 1809 mr_strcat(command, " > %s 2>> %s", filelist_fname, MONDO_LOGFILE); 1903 1810 mr_msg(1, "command = %s", command); 1904 1811 if (system(command)) { 1905 1812 mr_msg(4, "Warning - error occurred while retrieving TOC"); 1906 1813 } 1814 mr_free(command); 1815 1907 1816 if ((matches = 1908 1817 save_filelist_entries_in_common(filelist_fname, filelist, … … 1914 1823 current_tarball_number); 1915 1824 } 1916 sprintf(tmp, "Skipping fileset %ld", current_tarball_number); 1917 mr_msg(2, tmp); 1825 mr_msg(2, "Skipping fileset %ld", current_tarball_number); 1918 1826 restore_this_fileset = FALSE; 1919 1827 } else { … … 1924 1832 } 1925 1833 } 1834 unlink(filelist_fname); 1835 mr_free(filelist_fname); 1926 1836 1927 1837 // Concoct the call to star/afio to restore files 1928 if (strstr(tarball_fname, ".star.")) // star 1929 { 1930 sprintf(command, "star -x file=%s %s", afio_fname, executable); 1838 if (strstr(tarball_fname, ".star.")) { 1839 // star 1931 1840 if (filelist) { 1932 sprintf(command + strlen(command), " list=%s", 1933 filelist_subset_fname); 1934 } 1935 } else // afio 1936 { 1937 sprintf(command, "afio -i -M 8m -b %ld %s", TAPE_BLOCK_SIZE, 1938 executable); 1841 mr_asprintf(&command, "star -x file=%s %s list=%s 2>> %s", afio_fname, executable, filelist_subset_fname, MONDO_LOGFILE); 1842 } else { 1843 mr_asprintf(&command, "star -x file=%s %s 2>> %s", afio_fname, executable, MONDO_LOGFILE); 1844 } 1845 } else { 1846 // afio 1939 1847 if (filelist) { 1940 sprintf(command + strlen(command), " -w %s",1941 filelist_subset_fname);1942 }1943 sprintf(command + strlen(command), " %s", afio_fname);1944 } 1945 sprintf(command + strlen(command), " 2>> %s", MONDO_LOGFILE);1946 1947 // Call if IF there are files to restore (selectively/unconditionally)1848 mr_asprintf(&command, "afio -i -M 8m -b %ld %s -w %s %s 2>> %s", TAPE_BLOCK_SIZE, executable, filelist_subset_fname, afio_fname, MONDO_LOGFILE); 1849 } else { 1850 mr_asprintf(&command, "afio -i -M 8m -b %ld %s %s 2>> %s", TAPE_BLOCK_SIZE, executable, afio_fname, MONDO_LOGFILE); 1851 } 1852 } 1853 mr_free(executable); 1854 1855 // Call if IF there are files to restore (selectively/unconditionally) 1948 1856 if (restore_this_fileset) { 1949 1857 mr_msg(1, "Calling command='%s'", command); … … 1975 1883 mr_msg(1, "NOT CALLING '%s'", command); 1976 1884 } 1885 mr_free(command); 1977 1886 1978 1887 if (does_file_exist("/PAUSE") && current_tarball_number >= 50) { 1979 log_to_screen( "Paused after set %ld", current_tarball_number);1980 popup_and_OK( "Pausing. Press ENTER to continue.");1888 log_to_screen(_("Paused after set %ld"), current_tarball_number); 1889 popup_and_OK(_("Pausing. Press ENTER to continue.")); 1981 1890 } 1982 1891 1983 1892 unlink(filelist_subset_fname); 1984 unlink(filelist_fname);1985 1893 unlink(afio_fname); 1986 1894 1987 1895 mr_free(filelist_subset_fname); 1988 mr_free(filelist_fname);1989 1896 mr_free(afio_fname); 1990 mr_free(command);1991 mr_free(tmp);1992 1897 return (retval); 1993 1898 } … … 1996 1901 *END_RESTORE_A_TARBALL_FROM_STREAM * 1997 1902 **************************************************************************/ 1998 1999 2000 1903 2001 1904 … … 2014 1917 { 2015 1918 int retval = 0; 2016 int res ;2017 long noof_biggiefiles , bigfileno = 0, total_slices;2018 /** malloc **/ 2019 char *tmp ;2020 bool just_changed_cds = FALSE, finished ;2021 char *xattr_fname ;2022 char *acl_fname ;2023 char *biggies_whose_EXATs_we_should_set ; // EXtended ATtributes2024 char *pathname_of_last_biggie_restored ;1919 int res = 0; 1920 long noof_biggiefiles = 0L, bigfileno = 0L, total_slices = 0L; 1921 char *tmp = NULL; 1922 char *tmp1 = NULL; 1923 bool just_changed_cds = FALSE, finished = FALSE; 1924 char *xattr_fname = NULL; 1925 char *acl_fname = NULL; 1926 char *biggies_whose_EXATs_we_should_set = NULL; // EXtended ATtributes 1927 char *pathname_of_last_biggie_restored = NULL; 2025 1928 FILE *fbw = NULL; 2026 1929 2027 malloc_string(xattr_fname); 2028 malloc_string(acl_fname); 2029 malloc_string(tmp); 2030 malloc_string(biggies_whose_EXATs_we_should_set); 1930 malloc_string(tmp1); 2031 1931 malloc_string(pathname_of_last_biggie_restored); 2032 1932 assert(bkpinfo != NULL); 2033 1933 2034 sprintf(biggies_whose_EXATs_we_should_set,1934 mr_asprintf(&biggies_whose_EXATs_we_should_set, 2035 1935 "%s/biggies-whose-EXATs-we-should-set", bkpinfo->tmpdir); 2036 1936 if (!(fbw = fopen(biggies_whose_EXATs_we_should_set, "w"))) { … … 2039 1939 } 2040 1940 2041 read_cfg_var(g_mondo_cfg_file, "total-slices", tmp); 2042 total_slices = atol(tmp); 2043 sprintf(tmp, "Reassembling large files "); 1941 read_cfg_var(g_mondo_cfg_file, "total-slices", tmp1); 1942 total_slices = atol(tmp1); 1943 mr_free(tmp1); 1944 1945 mr_asprintf(&tmp, _("Reassembling large files ")); 2044 1946 mvaddstr_and_log_it(g_currentY, 0, tmp); 1947 mr_free(tmp); 1948 2045 1949 if (length_of_file(BIGGIELIST) < 6) { 2046 1950 mr_msg(1, "OK, no biggielist; not restoring biggiefiles"); … … 2053 1957 return (0); 2054 1958 } 2055 sprintf(tmp, "OK, there are %ld biggiefiles in the archives", 2056 noof_biggiefiles); 2057 mr_msg(2, tmp); 2058 2059 open_progress_form("Reassembling large files", 2060 "I am now reassembling all the large files.", 2061 "Please wait. This may take some time.", 1959 mr_msg(2, "OK, there are %ld biggiefiles in the archives", noof_biggiefiles); 1960 1961 open_progress_form(_("Reassembling large files"), 1962 _("I am now reassembling all the large files."), 1963 _("Please wait. This may take some time."), 2062 1964 "", total_slices); 2063 1965 for (bigfileno = 0, finished = FALSE; !finished;) { … … 2068 1970 mr_msg(3, "Cannot find bigfile #%ld 's first slice on %s #%d", 2069 1971 bigfileno + 1, 2070 media_descriptor_string(bkpinfo->backup_media_type),1972 bkpinfo->backup_media_string, 2071 1973 g_current_media_number); 2072 1974 mr_msg(3, "Slicename would have been %s", … … 2080 1982 insist_on_this_cd_number(bkpinfo, 2081 1983 ++g_current_media_number); 2082 sprintf(tmp, "Restoring from %s #%d", 2083 media_descriptor_string(bkpinfo-> 2084 backup_media_type), 1984 log_to_screen(_("Restoring from %s #%d"), 1985 bkpinfo->backup_media_string, 2085 1986 g_current_media_number); 2086 log_to_screen(tmp);2087 1987 just_changed_cds = TRUE; 2088 1988 } else { … … 2094 1994 } else { 2095 1995 just_changed_cds = FALSE; 2096 sprintf(tmp, "Restoring big file %ld", bigfileno + 1);1996 mr_asprintf(&tmp, _("Restoring big file %ld"), bigfileno + 1); 2097 1997 update_progress_form(tmp); 1998 mr_free(tmp); 1999 2098 2000 res = 2099 2001 restore_a_biggiefile_from_CD(bkpinfo, bigfileno, filelist, … … 2105 2007 retval += res; 2106 2008 bigfileno++; 2107 2108 2009 } 2109 2010 } … … 2112 2013 fclose(fbw); 2113 2014 if (g_getfattr) { 2114 sprintf(xattr_fname, XATTR_BIGGLST_FNAME_RAW_SZ, ARCHIVES_PATH);2015 mr_asprintf(&xattr_fname, XATTR_BIGGLST_FNAME_RAW_SZ, ARCHIVES_PATH); 2115 2016 if (length_of_file(xattr_fname) > 0) { 2116 2017 set_fattr_list(biggies_whose_EXATs_we_should_set, xattr_fname); … … 2118 2019 } 2119 2020 if (g_getfacl) { 2120 sprintf(acl_fname, ACL_BIGGLST_FNAME_RAW_SZ, ARCHIVES_PATH);2021 mr_asprintf(&acl_fname, ACL_BIGGLST_FNAME_RAW_SZ, ARCHIVES_PATH); 2121 2022 if (length_of_file(acl_fname) > 0) { 2122 2023 set_acl_list(biggies_whose_EXATs_we_should_set, acl_fname); 2123 2024 } 2124 2025 } 2125 } 2026 mr_free(acl_fname); 2027 mr_free(xattr_fname); 2028 } 2029 mr_free(biggies_whose_EXATs_we_should_set); 2030 2126 2031 if (does_file_exist("/PAUSE")) { 2127 2032 popup_and_OK 2128 ("Press ENTER to go on. Delete /PAUSE to stop these pauses."); 2033 (_ 2034 ("Press ENTER to go on. Delete /PAUSE to stop these pauses.")); 2129 2035 } 2130 2036 close_progress_form(); 2131 2037 if (retval) { 2132 mvaddstr_and_log_it(g_currentY++, 74, "Errors.");2038 mvaddstr_and_log_it(g_currentY++, 74, _("Errors.")); 2133 2039 } else { 2134 mvaddstr_and_log_it(g_currentY++, 74, "Done."); 2135 } 2136 mr_free(xattr_fname); 2137 mr_free(acl_fname); 2138 mr_free(tmp); 2139 mr_free(biggies_whose_EXATs_we_should_set); 2040 mvaddstr_and_log_it(g_currentY++, 74, _("Done.")); 2041 } 2140 2042 mr_free(pathname_of_last_biggie_restored); 2141 2043 return (retval); … … 2145 2047 *END_RESTORE_ALL_BIGGIFILES_FROM_CD * 2146 2048 **************************************************************************/ 2147 2148 2049 2149 2050 … … 2163 2064 { 2164 2065 int retval = 0; 2165 int res ;2166 int attempts ;2066 int res = 0; 2067 int attempts = 0; 2167 2068 long current_tarball_number = 0; 2168 long max_val ;2069 long max_val = 0L; 2169 2070 /**malloc ***/ 2170 char *tmp; 2171 char *tarball_fname; 2172 char *progress_str; 2173 char *comment; 2174 2175 malloc_string(tmp); 2071 char *tmp = NULL; 2072 char *tmp1 = NULL; 2073 char *tarball_fname = NULL; 2074 char *progress_str = NULL; 2075 char *comment = NULL; 2076 2077 malloc_string(tmp1); 2176 2078 malloc_string(tarball_fname); 2177 2079 malloc_string(progress_str); … … 2180 2082 assert(bkpinfo != NULL); 2181 2083 2182 mvaddstr_and_log_it(g_currentY, 0, "Restoring from archives");2084 mvaddstr_and_log_it(g_currentY, 0, _("Restoring from archives")); 2183 2085 mr_msg(2, 2184 2086 "Insisting on 1st CD, so that I can have a look at LAST-FILELIST-NUMBER"); … … 2188 2090 } 2189 2091 insist_on_this_cd_number(bkpinfo, g_current_media_number); 2190 read_cfg_var(g_mondo_cfg_file, "last-filelist-number", tmp); 2191 max_val = atol(tmp) + 1; 2192 sprintf(progress_str, "Restoring from %s #%d", 2193 media_descriptor_string(bkpinfo->backup_media_type), 2092 read_cfg_var(g_mondo_cfg_file, "last-filelist-number", tmp1); 2093 max_val = atol(tmp1) + 1; 2094 mr_free(tmp1); 2095 2096 mr_asprintf(&progress_str, _("Restoring from %s #%d"), 2097 bkpinfo->backup_media_string, 2194 2098 g_current_media_number); 2195 2099 log_to_screen(progress_str); 2196 open_progress_form( "Restoring from archives",2197 "Restoring data from the archives.",2198 "Please wait. This may take some time.",2100 open_progress_form(_("Restoring from archives"), 2101 _("Restoring data from the archives."), 2102 _("Please wait. This may take some time."), 2199 2103 progress_str, max_val); 2200 2104 for (;;) { 2201 2105 insist_on_this_cd_number(bkpinfo, g_current_media_number); 2202 2106 update_progress_form(progress_str); 2203 sprintf(tarball_fname, MNT_CDROM "/archives/%ld.afio.bz2",2107 mr_asprintf(&tarball_fname, MNT_CDROM "/archives/%ld.afio.bz2", 2204 2108 current_tarball_number); 2205 2109 if (!does_file_exist(tarball_fname)) { 2206 sprintf(tarball_fname, MNT_CDROM "/archives/%ld.afio.gz", 2110 mr_free(tarball_fname); 2111 mr_asprintf(&tarball_fname, MNT_CDROM "/archives/%ld.afio.lzo", 2207 2112 current_tarball_number); 2208 2113 } 2209 2114 if (!does_file_exist(tarball_fname)) { 2210 sprintf(tarball_fname, MNT_CDROM "/archives/%ld.afio.lzo", 2115 mr_free(tarball_fname); 2116 mr_asprintf(&tarball_fname, MNT_CDROM "/archives/%ld.afio.gz", 2211 2117 current_tarball_number); 2212 2118 } 2213 2119 if (!does_file_exist(tarball_fname)) { 2214 sprintf(tarball_fname, MNT_CDROM "/archives/%ld.afio.", 2120 mr_free(tarball_fname); 2121 mr_asprintf(&tarball_fname, MNT_CDROM "/archives/%ld.afio.", 2215 2122 current_tarball_number); 2216 2123 } 2217 2124 if (!does_file_exist(tarball_fname)) { 2218 sprintf(tarball_fname, MNT_CDROM "/archives/%ld.star.bz2", 2125 mr_free(tarball_fname); 2126 mr_asprintf(&tarball_fname, MNT_CDROM "/archives/%ld.star.bz2", 2219 2127 current_tarball_number); 2220 2128 } 2221 2129 if (!does_file_exist(tarball_fname)) { 2222 sprintf(tarball_fname, MNT_CDROM "/archives/%ld.star.", 2130 mr_free(tarball_fname); 2131 mr_asprintf(&tarball_fname, MNT_CDROM "/archives/%ld.star.", 2223 2132 current_tarball_number); 2224 2133 } 2225 2134 if (!does_file_exist(tarball_fname)) { 2135 mr_free(tarball_fname); 2226 2136 if (current_tarball_number == 0) { 2227 2137 log_to_screen 2228 ("No tarballs. Strange. Maybe you only backed up freakin' big files?"); 2138 (_ 2139 ("No tarballs. Strange. Maybe you only backed up freakin' big files?")); 2140 mr_free(progress_str); 2229 2141 return (0); 2230 2142 } … … 2233 2145 "/archives/slice* > /dev/null 2> /dev/null") == 2234 2146 0) { 2147 mr_free(tarball_fname); 2148 mr_free(progress_str); 2235 2149 break; 2236 2150 } 2237 2151 g_current_media_number++; 2238 sprintf(progress_str, "Restoring from %s #%d", 2239 media_descriptor_string(bkpinfo->backup_media_type), 2152 mr_free(progress_str); 2153 2154 mr_asprintf(&progress_str, _("Restoring from %s #%d"), 2155 bkpinfo->backup_media_string, 2240 2156 g_current_media_number); 2241 2157 log_to_screen(progress_str); 2242 2158 } else { 2243 sprintf(progress_str, "Restoring from fileset #%ld on %s #%d", 2159 mr_free(progress_str); 2160 mr_asprintf(&progress_str, 2161 _("Restoring from fileset #%ld on %s #%d"), 2244 2162 current_tarball_number, 2245 media_descriptor_string(bkpinfo->backup_media_type),2163 bkpinfo->backup_media_string, 2246 2164 g_current_media_number); 2247 // mr_msg(3, "progress_str = %s", progress_str);2248 2165 for (res = 999, attempts = 0; attempts < 3 && res != 0; 2249 2166 attempts++) { … … 2253 2170 filelist, bkpinfo); 2254 2171 } 2255 sprintf(tmp, "%s #%d, fileset #%ld - restore ",2172 mr_asprintf(&tmp, _("%s #%d, fileset #%ld - restore "), 2256 2173 media_descriptor_string(bkpinfo->backup_media_type), 2257 2174 g_current_media_number, current_tarball_number); 2258 2175 if (res) { 2259 strcat(tmp, "reported errors"); 2260 } else if (attempts > 1) { 2261 strcat(tmp, "succeeded"); 2176 mr_strcat(tmp, _("reported errors")); 2262 2177 } else { 2263 strcat(tmp, "succeeded");2178 mr_strcat(tmp, _("succeeded")); 2264 2179 } 2265 2180 if (attempts > 1) { 2266 sprintf(tmp + strlen(tmp), " (%d attempts) - review logs", 2267 attempts); 2268 } 2269 strcpy(comment, tmp); 2181 mr_strcat(tmp, _(" (%d attempts) - review logs"), attempts); 2182 } 2270 2183 if (attempts > 1) { 2271 log_to_screen(comment); 2272 } 2184 log_to_screen(tmp); 2185 } 2186 mr_free(tmp); 2273 2187 2274 2188 retval += res; … … 2276 2190 g_current_progress++; 2277 2191 } 2278 } 2192 mr_free(tarball_fname); 2193 } 2194 mr_free(progress_str); 2279 2195 close_progress_form(); 2196 2280 2197 if (retval) { 2281 mvaddstr_and_log_it(g_currentY++, 74, "Errors.");2198 mvaddstr_and_log_it(g_currentY++, 74, _("Errors.")); 2282 2199 } else { 2283 mvaddstr_and_log_it(g_currentY++, 74, "Done."); 2284 } 2285 mr_free(tmp); 2286 mr_free(tarball_fname); 2287 mr_free(progress_str); 2288 mr_free(comment); 2289 2200 mvaddstr_and_log_it(g_currentY++, 74, _("Done.")); 2201 } 2290 2202 return (retval); 2291 2203 } … … 2294 2206 *END_RESTORE_ALL_TARBALLS_FROM_CD * 2295 2207 **************************************************************************/ 2296 2297 2208 2298 2209 … … 2308 2219 struct s_node *filelist) 2309 2220 { 2310 long noof_biggiefiles ;2311 long current_bigfile_number = 0 ;2312 long total_slices ;2221 long noof_biggiefiles = 0L; 2222 long current_bigfile_number = 0L; 2223 long total_slices = 0L; 2313 2224 2314 2225 int retval = 0; 2315 2226 int res = 0; 2316 int ctrl_chr ;2227 int ctrl_chr = 0; 2317 2228 2318 2229 /** malloc add ****/ 2319 char *tmp; 2320 char *biggie_fname; 2321 char *biggie_cksum; 2322 char *xattr_fname; 2323 char *acl_fname; 2324 char *p; 2325 char *pathname_of_last_biggie_restored; 2326 char *biggies_whose_EXATs_we_should_set; // EXtended ATtributes 2327 long long biggie_size; 2328 FILE *fbw = NULL; 2230 char *tmp = NULL; 2231 char *biggie_fname = NULL; 2232 char *biggie_cksum = NULL; 2233 char *xattr_fname = NULL; 2234 char *acl_fname = NULL; 2235 char *pathname_of_last_biggie_restored = NULL; 2236 char *biggies_whose_EXATs_we_should_set = NULL; // EXtended ATtributes 2237 long long biggie_size = (long long)0; 2238 FILE *fbw; 2239 2240 assert(bkpinfo != NULL); 2329 2241 2330 2242 malloc_string(tmp); 2331 2243 malloc_string(biggie_fname); 2332 2244 malloc_string(biggie_cksum); 2333 malloc_string(xattr_fname);2334 malloc_string(acl_fname);2335 malloc_string(biggies_whose_EXATs_we_should_set);2336 2245 malloc_string(pathname_of_last_biggie_restored); 2337 assert(bkpinfo != NULL);2338 2339 2246 read_cfg_var(g_mondo_cfg_file, "total-slices", tmp); 2340 2341 2247 total_slices = atol(tmp); 2342 sprintf(tmp, "Reassembling large files "); 2248 mr_free(tmp); 2249 2250 mr_asprintf(&tmp, "Reassembling large files "); 2343 2251 if (g_getfattr) { 2344 sprintf(xattr_fname, XATTR_BIGGLST_FNAME_RAW_SZ, bkpinfo->tmpdir);2252 mr_asprintf(&xattr_fname, XATTR_BIGGLST_FNAME_RAW_SZ, bkpinfo->tmpdir); 2345 2253 } 2346 2254 if (g_getfacl) { 2347 sprintf(acl_fname, ACL_BIGGLST_FNAME_RAW_SZ, bkpinfo->tmpdir);2255 mr_asprintf(&acl_fname, ACL_BIGGLST_FNAME_RAW_SZ, bkpinfo->tmpdir); 2348 2256 } 2349 2257 mvaddstr_and_log_it(g_currentY, 0, tmp); 2350 sprintf(biggies_whose_EXATs_we_should_set, 2258 mr_free(tmp); 2259 2260 mr_asprintf(&biggies_whose_EXATs_we_should_set, 2351 2261 "%s/biggies-whose-EXATs-we-should-set", bkpinfo->tmpdir); 2352 2262 if (!(fbw = fopen(biggies_whose_EXATs_we_should_set, "w"))) { … … 2354 2264 biggies_whose_EXATs_we_should_set); 2355 2265 } 2356 // get xattr and acl files if they're there2266 // get xattr and acl files if they're there 2357 2267 res = 2358 2268 read_header_block_from_stream(&biggie_size, biggie_fname, … … 2365 2275 2366 2276 noof_biggiefiles = atol(biggie_fname); 2367 sprintf(tmp, "OK, there are %ld biggiefiles in the archives",2277 mr_msg(2, "OK, there are %ld biggiefiles in the archives", 2368 2278 noof_biggiefiles); 2369 mr_msg(2, tmp); 2370 open_progress_form("Reassembling large files", 2371 "I am now reassembling all the large files.", 2372 "Please wait. This may take some time.", 2279 open_progress_form(_("Reassembling large files"), 2280 _("I am now reassembling all the large files."), 2281 _("Please wait. This may take some time."), 2373 2282 "", total_slices); 2374 2283 … … 2384 2293 wrong_marker(BLK_START_A_NORMBIGGIE, ctrl_chr); 2385 2294 } 2295 /* BERLIOS: useless 2386 2296 p = strrchr(biggie_fname, '/'); 2387 2297 if (!p) { … … 2390 2300 p++; 2391 2301 } 2392 sprintf(tmp, "Restoring big file %ld (%lld K)", 2302 */ 2303 mr_asprintf(&tmp, _("Restoring big file %ld (%lld K)"), 2393 2304 current_bigfile_number + 1, biggie_size / 1024); 2394 2305 update_progress_form(tmp); 2306 mr_free(tmp); 2307 2395 2308 res = restore_a_biggiefile_from_stream(bkpinfo, biggie_fname, 2396 2309 current_bigfile_number, … … 2404 2317 fprintf(fbw, "%s\n", pathname_of_last_biggie_restored); 2405 2318 } 2319 mr_free(pathname_of_last_biggie_restored); 2320 2406 2321 retval += res; 2407 2322 current_bigfile_number++; … … 2410 2325 if (current_bigfile_number != noof_biggiefiles 2411 2326 && noof_biggiefiles != 0) { 2412 sprintf(tmp, "Warning - bigfileno=%ld but noof_biggiefiles=%ld\n",2327 mr_msg(1, "Warning - bigfileno=%ld but noof_biggiefiles=%ld\n", 2413 2328 current_bigfile_number, noof_biggiefiles); 2414 2329 } else { 2415 sprintf(tmp, 2416 "%ld biggiefiles in biggielist.txt; %ld biggiefiles processed today.", 2330 mr_msg(1, "%ld biggiefiles in biggielist.txt; %ld biggiefiles processed today.", 2417 2331 noof_biggiefiles, current_bigfile_number); 2418 2332 } 2419 mr_msg(1, tmp);2420 2333 2421 2334 if (fbw) { … … 2443 2356 } 2444 2357 } 2358 mr_free(xattr_fname); 2359 mr_free(acl_fname); 2360 mr_free(biggies_whose_EXATs_we_should_set); 2361 2445 2362 if (does_file_exist("/PAUSE")) { 2446 2363 popup_and_OK 2447 ("Press ENTER to go on. Delete /PAUSE to stop these pauses."); 2364 (_ 2365 ("Press ENTER to go on. Delete /PAUSE to stop these pauses.")); 2448 2366 } 2449 2367 2450 2368 close_progress_form(); 2451 2369 if (retval) { 2452 mvaddstr_and_log_it(g_currentY++, 74, "Errors.");2370 mvaddstr_and_log_it(g_currentY++, 74, _("Errors.")); 2453 2371 } else { 2454 mvaddstr_and_log_it(g_currentY++, 74, "Done."); 2455 } 2456 mr_free(biggies_whose_EXATs_we_should_set); 2457 mr_free(pathname_of_last_biggie_restored); 2372 mvaddstr_and_log_it(g_currentY++, 74, _("Done.")); 2373 } 2458 2374 mr_free(biggie_fname); 2459 2375 mr_free(biggie_cksum); 2460 mr_free(xattr_fname);2461 mr_free(acl_fname);2462 mr_free(tmp);2463 2376 return (retval); 2464 2377 } … … 2467 2380 *END_RESTORE_ALL_BIGGIEFILES_FROM_STREAM * 2468 2381 **************************************************************************/ 2469 2470 2471 2472 2473 2382 2474 2383 … … 2488 2397 { 2489 2398 int retval = 0; 2490 int res ;2399 int res = 0; 2491 2400 long current_afioball_number = 0; 2492 int ctrl_chr ;2493 long max_val /*, total_noof_files */ ;2401 int ctrl_chr = 0; 2402 long max_val = 0L /*, total_noof_files */ ; 2494 2403 2495 2404 /** malloc **/ 2496 char *tmp; 2497 char *progress_str; 2498 char *tmp_fname; 2499 char *xattr_fname; 2500 char *acl_fname; 2501 2502 long long tmp_size; 2503 2405 char *tmp = NULL; 2406 char *progress_str = NULL; 2407 char *tmp_fname = NULL; 2408 char *xattr_fname = NULL; 2409 char *acl_fname = NULL; 2410 2411 long long tmp_size = 0L; 2412 2413 malloc_string(tmp_fname); 2504 2414 malloc_string(tmp); 2505 malloc_string(progress_str);2506 malloc_string(tmp_fname);2507 2415 assert(bkpinfo != NULL); 2508 malloc_string(xattr_fname); 2509 malloc_string(acl_fname); 2510 mvaddstr_and_log_it(g_currentY, 0, "Restoring from archives"); 2416 mvaddstr_and_log_it(g_currentY, 0, _("Restoring from archives")); 2511 2417 read_cfg_var(g_mondo_cfg_file, "last-filelist-number", tmp); 2512 2418 max_val = atol(tmp) + 1; 2419 mr_free(tmp); 2513 2420 2514 2421 chdir(bkpinfo->restore_path); /* I don't know why this is needed _here_ but it seems to be. -HR, 02/04/2002 */ … … 2516 2423 run_program_and_log_output("pwd", 5); 2517 2424 2518 sprintf(progress_str, "Restoring from media #%d",2425 mr_asprintf(&progress_str, _("Restoring from media #%d"), 2519 2426 g_current_media_number); 2520 2427 log_to_screen(progress_str); 2521 open_progress_form( "Restoring from archives",2522 "Restoring data from the archives.",2523 "Please wait. This may take some time.",2428 open_progress_form(_("Restoring from archives"), 2429 _("Restoring data from the archives."), 2430 _("Please wait. This may take some time."), 2524 2431 progress_str, max_val); 2525 2432 … … 2539 2446 update_progress_form(progress_str); 2540 2447 if (g_getfattr) { 2541 sprintf(xattr_fname, "%s/xattr-subset-%ld.tmp", bkpinfo->tmpdir,2448 mr_asprintf(&xattr_fname, "%s/xattr-subset-%ld.tmp", bkpinfo->tmpdir, 2542 2449 current_afioball_number); 2543 2450 unlink(xattr_fname); 2544 2451 } 2545 2452 if (g_getfacl) { 2546 sprintf(acl_fname, "%s/acl-subset-%ld.tmp", bkpinfo->tmpdir,2453 mr_asprintf(&acl_fname, "%s/acl-subset-%ld.tmp", bkpinfo->tmpdir, 2547 2454 current_afioball_number); 2548 2455 unlink(acl_fname); … … 2558 2465 wrong_marker(BLK_START_AN_AFIO_OR_SLICE, ctrl_chr); 2559 2466 } 2560 sprintf(tmp, 2561 "Restoring from fileset #%ld (name=%s, size=%ld K)", 2467 /* BERLIOS: useless ? 2468 mr_asprintf(&tmp, 2469 _("Restoring from fileset #%ld (name=%s, size=%ld K)"), 2562 2470 current_afioball_number, tmp_fname, (long) tmp_size >> 10); 2471 */ 2563 2472 res = 2564 2473 restore_a_tarball_from_stream(bkpinfo, tmp_fname, … … 2568 2477 retval += res; 2569 2478 if (res) { 2570 sprintf(tmp,"Fileset %ld - errors occurred",2479 log_to_screen("Fileset %ld - errors occurred", 2571 2480 current_afioball_number); 2572 log_to_screen(tmp);2573 2481 } 2574 2482 res = … … 2580 2488 current_afioball_number++; 2581 2489 g_current_progress++; 2582 sprintf(progress_str, "Restoring from fileset #%ld on %s #%d", 2490 2491 mr_free(progress_str); 2492 mr_asprintf(&progress_str, _("Restoring from fileset #%ld on %s #%d"), 2583 2493 current_afioball_number, 2584 media_descriptor_string(bkpinfo->backup_media_type),2494 bkpinfo->backup_media_string, 2585 2495 g_current_media_number); 2586 2496 res = … … 2592 2502 unlink(acl_fname); 2593 2503 } 2504 mr_free(xattr_fname); 2505 mr_free(acl_fname); 2594 2506 } // next 2507 mr_free(progress_str); 2508 mr_free(tmp_fname); 2509 2595 2510 mr_msg(1, "All done with afioballs"); 2596 2511 close_progress_form(); 2597 2512 if (retval) { 2598 mvaddstr_and_log_it(g_currentY++, 74, "Errors.");2513 mvaddstr_and_log_it(g_currentY++, 74, _("Errors.")); 2599 2514 } else { 2600 mvaddstr_and_log_it(g_currentY++, 74, "Done."); 2601 } 2602 mr_free(tmp); 2603 mr_free(progress_str); 2604 mr_free(tmp_fname); 2605 mr_free(xattr_fname); 2606 mr_free(acl_fname); 2515 mvaddstr_and_log_it(g_currentY++, 74, _("Done.")); 2516 } 2607 2517 return (retval); 2608 2518 } … … 2629 2539 2630 2540 /** mallco ***/ 2631 char *cwd ;2632 char *newpath ;2633 char *tmp ;2541 char *cwd = NULL; 2542 char *newpath = NULL; 2543 char *tmp = NULL; 2634 2544 assert(bkpinfo != NULL); 2635 2545 2636 2546 malloc_string(cwd); 2637 2547 malloc_string(newpath); 2638 malloc_string(tmp);2639 2548 mr_msg(2, "restore_everything() --- starting"); 2640 2549 g_current_media_number = 1; 2550 /* BERLIOS: should test return value, or better change the function */ 2641 2551 getcwd(cwd, MAX_STR_LEN - 1); 2642 sprintf(tmp, "mkdir -p %s", bkpinfo->restore_path);2552 mr_asprintf(&tmp, "mkdir -p %s", bkpinfo->restore_path); 2643 2553 run_program_and_log_output(tmp, FALSE); 2554 mr_free(tmp); 2555 2644 2556 mr_msg(1, "Changing dir to %s", bkpinfo->restore_path); 2645 2557 chdir(bkpinfo->restore_path); 2558 /* BERLIOS: should test return value, or better change the function */ 2646 2559 getcwd(newpath, MAX_STR_LEN - 1); 2647 2560 mr_msg(1, "path is now %s", newpath); … … 2649 2562 if (!find_home_of_exe("petris") && !g_text_mode) { 2650 2563 newtDrawRootText(0, g_noof_rows - 2, 2651 "Press ALT-<left cursor> twice to play Petris :-) "); 2564 _ 2565 ("Press ALT-<left cursor> twice to play Petris :-) ")); 2652 2566 newtRefresh(); 2653 2567 } 2654 mvaddstr_and_log_it(g_currentY, 0, "Preparing to read your archives");2568 mvaddstr_and_log_it(g_currentY, 0, _("Preparing to read your archives")); 2655 2569 if (IS_THIS_A_STREAMING_BACKUP(bkpinfo->backup_media_type)) { 2656 2570 mount_cdrom(bkpinfo); 2657 2571 mvaddstr_and_log_it(g_currentY++, 0, 2658 "Restoring OS and data from streaming media"); 2572 _ 2573 ("Restoring OS and data from streaming media")); 2659 2574 if (bkpinfo->backup_media_type == cdstream) { 2660 2575 openin_cdstream(bkpinfo); … … 2673 2588 } else { 2674 2589 mvaddstr_and_log_it(g_currentY++, 0, 2675 "Restoring OS and data from CD ");2590 _("Restoring OS and data from CD ")); 2676 2591 mount_cdrom(bkpinfo); 2677 2592 resA = restore_all_tarballs_from_CD(bkpinfo, filelist); … … 2680 2595 chdir(cwd); 2681 2596 if (resA + resB) { 2682 log_to_screen( "Errors occurred while data was being restored.");2597 log_to_screen(_("Errors occurred while data was being restored.")); 2683 2598 } 2684 2599 if (length_of_file("/etc/raidtab") > 0) { … … 2691 2606 mr_free(cwd); 2692 2607 mr_free(newpath); 2693 mr_free(tmp);2694 2608 return (resA + resB); 2695 2609 } … … 2698 2612 *END_RESTORE_EVERYTHING * 2699 2613 **************************************************************************/ 2700 2701 2614 2702 2615 … … 2820 2733 extern void wait_until_software_raids_are_prepped(char *, int); 2821 2734 2822 2823 2735 char which_restore_mode(void); 2824 2736 … … 2853 2765 "stopped for some reason, chances are it's detailed here. "); 2854 2766 mr_msg(0, 2855 "More than likely there's a message at the very end of this");2767 "More than likely there's a message near the end of this "); 2856 2768 mr_msg(0, 2857 2769 "log that will tell you what is wrong. Please read it! "); … … 2861 2773 2862 2774 2863 2864 2775 /** 2865 2776 * Restore the user's data. … … 2868 2779 int main(int argc, char *argv[]) 2869 2780 { 2870 FILE *fin ;2871 FILE *fout ;2781 FILE *fin = NULL; 2782 FILE *fout = NULL; 2872 2783 int retval = 0; 2873 int res; 2874 // int c; 2875 char *tmp; 2876 2877 struct mountlist_itself *mountlist; 2878 struct raidlist_itself *raidlist; 2879 struct s_bkpinfo *bkpinfo; 2880 struct s_node *filelist; 2881 char *a, *b; 2784 int res = 0; 2785 char *tmp = NULL; 2786 2787 struct mountlist_itself *mountlist = NULL; 2788 struct raidlist_itself *raidlist = NULL; 2789 struct s_bkpinfo *bkpinfo = NULL; 2790 struct s_node *filelist = NULL; 2791 char *a = NULL, *b = NULL; 2882 2792 bool run_postnuke = FALSE; 2883 2793 2884 /************************************************************************** 2885 * hugo- * 2886 * busy stuff here - it needs some comments -stan * 2887 * * 2888 **************************************************************************/ 2794 #ifdef ENABLE_NLS 2795 setlocale(LC_ALL, ""); 2796 (void) textdomain("mondo"); 2797 #endif 2798 2889 2799 if (getuid() != 0) { 2890 fprintf(stderr, "Please run as root.\n");2800 fprintf(stderr, _("Please run as root.\n")); 2891 2801 exit(127); 2892 2802 } 2893 2803 2894 2804 g_loglevel = DEFAULT_MR_LOGLEVEL; 2895 malloc_string(tmp);2896 2805 2897 2806 /* Configure global variables */ … … 2926 2835 run_program_and_log_output("mkdir -p /mnt/floppy", FALSE); 2927 2836 2928 malloc_string(tmp);2929 2837 malloc_string(a); 2930 2838 malloc_string(b); … … 2932 2840 reset_bkpinfo(bkpinfo); 2933 2841 bkpinfo->backup_media_type = none; // in case boot disk was made for one backup type but user wants to restore from another backup type 2842 bkpinfo->backup_media_string = NULL; 2934 2843 bkpinfo->restore_data = TRUE; // Well, yeah :-) 2935 2844 if (am_I_in_disaster_recovery_mode()) { … … 2950 2859 2951 2860 /* Backup original mountlist.txt */ 2952 sprintf(tmp, "%s.orig", g_mountlist_fname);2861 mr_asprintf(&tmp, "%s.orig", g_mountlist_fname); 2953 2862 if (!does_file_exist(g_mountlist_fname)) { 2954 2863 mr_msg(2, … … 2956 2865 __LINE__, g_mountlist_fname); 2957 2866 } else if (!does_file_exist(tmp)) { 2958 sprintf(tmp, "cp -f %s %s.orig", g_mountlist_fname, 2867 mr_free(tmp); 2868 mr_asprintf(&tmp, "cp -f %s %s.orig", g_mountlist_fname, 2959 2869 g_mountlist_fname); 2960 2870 run_program_and_log_output(tmp, FALSE); 2961 2871 } 2872 mr_free(tmp); 2962 2873 2963 2874 /* Init directories */ 2964 2875 make_hole_for_dir(bkpinfo->tmpdir); 2965 sprintf(tmp, "mkdir -p %s", bkpinfo->tmpdir);2876 mr_asprintf(&tmp, "mkdir -p %s", bkpinfo->tmpdir); 2966 2877 run_program_and_log_output(tmp, FALSE); 2878 mr_free(tmp); 2879 2967 2880 make_hole_for_dir("/var/log"); 2968 2881 make_hole_for_dir("/tmp/tmpfs"); /* just in case... */ … … 2974 2887 run_program_and_log_output("rm -Rf /tmp/tmpfs/mondo.tmp.*", FALSE); 2975 2888 2976 /* Init GUI */2889 /* Init GUI */ 2977 2890 malloc_libmondo_global_strings(); 2978 2891 setup_newt_stuff(); /* call newtInit and setup screen log */ … … 2986 2899 iamhere("what time is it"); 2987 2900 2988 /* Process command-line parameters */2901 /* Process command-line parameters */ 2989 2902 if (argc == 2 && strcmp(argv[1], "--edit-mountlist") == 0) { 2990 2903 #ifdef __FreeBSD__ … … 3024 2937 strcpy(bkpinfo->restore_path, "/tmp/TESTING"); 3025 2938 bkpinfo->backup_media_type = dvd; 3026 open_progress_form( "Reassembling /dev/hda1",3027 "Shark is a bit of a silly person.",3028 "Please wait. This may take some time.",2939 open_progress_form(_("Reassembling /dev/hda1"), 2940 _("Shark is a bit of a silly person."), 2941 _("Please wait. This may take some time."), 3029 2942 "", 1999); 3030 2943 system("rm -Rf /tmp/*pih*"); 3031 2944 2945 malloc_string(tmp); 3032 2946 restore_a_biggiefile_from_CD(bkpinfo, 42, NULL, tmp); 2947 mr_free(tmp); 3033 2948 } 3034 2949 … … 3043 2958 // BERLIOS: /usr/lib ??? 3044 2959 toggle_path_selection(filelist, "/usr/share", TRUE); 3045 // show_filelist(filelist);3046 2960 save_filelist(filelist, "/tmp/out.txt"); 3047 // finish(0); 3048 // toggle_path_selection (filelist, "/root/stuff", TRUE); 3049 strcpy(a, argv[3]); 3050 strcpy(b, argv[4]); 2961 mr_asprintf(&a, argv[3]); 2962 mr_asprintf(&b, argv[4]); 3051 2963 3052 2964 res = save_filelist_entries_in_common(a, filelist, b, FALSE); 3053 2965 free_filelist(filelist); 2966 mr_free(a); 2967 mr_free(b); 3054 2968 printf("res = %d", res); 3055 2969 finish(0); … … 3102 3016 retval = run_grub(FALSE, "/dev/hda"); 3103 3017 if (retval) { 3104 log_to_screen( "Failed to write Master Boot Record");3018 log_to_screen(_("Failed to write Master Boot Record")); 3105 3019 } 3106 3020 paranoid_MR_finish(0); … … 3113 3027 if (argc != 1) { 3114 3028 popup_and_OK 3115 ("Live mode doesn't support command-line parameters yet."); 3029 (_ 3030 ("Live mode doesn't support command-line parameters yet.")); 3116 3031 paranoid_MR_finish(1); 3117 // return(1);3118 3032 } 3119 3033 mr_msg(1, "I am in normal, live mode."); … … 3135 3049 mr_msg(2, "Still here. Yay."); 3136 3050 if (strlen(bkpinfo->tmpdir) > 0) { 3137 sprintf(tmp, "rm -Rf %s/*", bkpinfo->tmpdir);3051 mr_asprintf(&tmp, "rm -Rf %s/*", bkpinfo->tmpdir); 3138 3052 run_program_and_log_output(tmp, FALSE); 3053 mr_free(tmp); 3139 3054 } 3140 3055 unmount_boot_if_necessary(); /* for Gentoo users */ … … 3145 3060 mr_msg(2, "FYI, MOUNTLIST_FNAME = %s ", g_mountlist_fname); 3146 3061 if (argc == 3 && strcmp(argv[1], "--monitas-memorex") == 0) { 3147 log_to_screen( "Uh, that hasn't been implemented yet.");3062 log_to_screen(_("Uh, that hasn't been implemented yet.")); 3148 3063 paranoid_MR_finish(1); 3149 3064 } … … 3165 3080 sprintf(bkpinfo->isodir, "/tmp/isodir"); 3166 3081 run_program_and_log_output("mkdir -p /tmp/isodir", 5); 3167 sprintf(tmp, "mount %s -t nfs -o nolock /tmp/isodir",3082 mr_asprintf(&tmp, "mount %s -t nfs -o nolock /tmp/isodir", 3168 3083 bkpinfo->nfs_mount); 3169 3084 run_program_and_log_output(tmp, 1); 3085 mr_free(tmp); 3170 3086 } 3171 3087 } … … 3174 3090 if (retval) { 3175 3091 log_to_screen 3176 ("Warning - load_raidtab_into_raidlist returned an error"); 3092 (_ 3093 ("Warning - load_raidtab_into_raidlist returned an error")); 3177 3094 } 3178 3095 … … 3228 3145 } 3229 3146 if (retval) { 3230 log_to_screen( "Failed to write Master Boot Record");3147 log_to_screen(_("Failed to write Master Boot Record")); 3231 3148 } 3232 3149 } else if (argc == 2 && strcmp(argv[1], "--isonuke") == 0) { … … 3234 3151 retval = iso_mode(bkpinfo, mountlist, raidlist, TRUE); 3235 3152 } else if (argc != 1) { 3236 log_to_screen( "Invalid paremeters");3153 log_to_screen(_("Invalid paremeters")); 3237 3154 paranoid_MR_finish(1); 3238 3155 } else { … … 3246 3163 if (does_file_exist("/tmp/changed.files")) { 3247 3164 log_to_screen 3248 ("See /tmp/changed.files for list of files that have changed."); 3165 (_ 3166 ("See /tmp/changed.files for list of files that have changed.")); 3249 3167 } 3250 3168 mvaddstr_and_log_it(g_currentY++, 3251 3169 0, 3252 "Run complete. Errors were reported. Please review the logfile."); 3170 _ 3171 ("Run complete. Errors were reported. Please review the logfile.")); 3253 3172 } else { 3254 3173 if (IS_THIS_A_STREAMING_BACKUP(bkpinfo->backup_media_type)) { 3255 3174 mvaddstr_and_log_it(g_currentY++, 3256 3175 0, 3257 "Run complete. Please remove floppy/CD/media and reboot."); 3176 _ 3177 ("Run complete. Please remove floppy/CD/media and reboot.")); 3258 3178 } else { 3259 3179 run_program_and_log_output("sync", FALSE); … … 3267 3187 if (!bkpinfo->please_dont_eject) { 3268 3188 res = eject_device("/dev/cdrom"); 3269 /*3270 if (res)3271 {3272 log_to_screen( "WARNING - failed to eject CD-ROM disk" );3273 }3274 */3275 3189 } 3276 3190 mvaddstr_and_log_it(g_currentY++, 3277 3191 0, 3278 "Run complete. Please remove media and reboot."); 3279 } 3280 } 3281 3282 // g_I_have_just_nuked is set true by nuke_mode() just before it returns 3192 _ 3193 ("Run complete. Please remove media and reboot.")); 3194 } 3195 } 3196 3197 // g_I_have_just_nuked is set true by nuke_mode() just before it returns 3283 3198 if (!system("which post-nuke > /dev/null 2> /dev/null")) { 3284 3199 mr_msg(1, "post-nuke found; find out whether we should run it..."); … … 3303 3218 } else { 3304 3219 mr_msg(1, "Re-mounted partitions for post-nuke stuff"); 3305 sprintf(tmp, "post-nuke %s %d", bkpinfo->restore_path,3220 mr_asprintf(&tmp, "post-nuke %s %d", bkpinfo->restore_path, 3306 3221 retval); 3307 3222 mr_msg(2, "Calling '%s'", tmp); … … 3309 3224 log_OS_error(tmp); 3310 3225 } 3226 mr_free(tmp); 3311 3227 mr_msg(1, "post-nuke returned w/ res=%d", res); 3312 3228 } … … 3315 3231 } 3316 3232 3317 /*3318 log_to_screen("If you are REALLY in a hurry, hit Ctrl-Alt-Del now.");3319 log_to_screen("Otherwise, please wait until the RAID disks are done.");3320 wait_until_software_raids_are_prepped("/proc/mdstat", 100);3321 log_to_screen("Thank you.");3322 */3323 3233 unlink("/tmp/mondo-run-prog.tmp"); 3324 3234 set_signals(FALSE); 3325 sprintf(tmp, "rm -Rf %s", bkpinfo->tmpdir);3235 mr_asprintf(&tmp, "rm -Rf %s", bkpinfo->tmpdir); 3326 3236 run_program_and_log_output(tmp, FALSE); 3237 mr_free(tmp); 3238 3327 3239 log_to_screen 3328 ("Restore log copied to /tmp/mondo-restore.log on your hard disk"); 3329 sprintf(tmp, 3330 "Mondo-restore is exiting (retval=%d) ", 3331 retval); 3332 log_to_screen(tmp); 3333 sprintf(tmp, "umount %s", bkpinfo->isodir); 3240 (_ 3241 ("Restore log copied to /tmp/mondo-restore.log on your hard disk")); 3242 log_to_screen(_("Mondo-restore is exiting (retval=%d)"), retval); 3243 3244 mr_asprintf(&tmp, "umount %s", bkpinfo->isodir); 3334 3245 run_program_and_log_output(tmp, 5); 3246 mr_free(tmp); 3247 3335 3248 mr_free(mountlist); 3336 3249 mr_free(raidlist); … … 3340 3253 paranoid_MR_finish(retval); // frees global stuff plus bkpinfo 3341 3254 free_libmondo_global_strings(); // it's fine to have this here :) really :) 3342 mr_free(a);3343 mr_free(b);3344 mr_free(tmp);3345 3255 3346 3256 unlink("/tmp/filelist.full"); … … 3355 3265 3356 3266 3357 3358 3359 3360 3267 /************************************************************************** 3361 3268 *END_MONDO-RESTORE.C *
Note:
See TracChangeset
for help on using the changeset viewer.