Changeset 1219 in MondoRescue
- Timestamp:
- Feb 28, 2007, 9:36:10 AM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/stable/mondo/src/mondorestore/mondo-rstr-tools.c
r1216 r1219 380 380 int res = 0; 381 381 382 char *tmp = NULL;383 382 char *command = NULL; 384 383 char *mountdir = NULL; 385 384 char *mountpoint = NULL; 386 385 char *additional_parameters = NULL; 387 char *p1 = NULL; 388 char *p2 = NULL; 389 char *p3 = NULL; 390 386 391 387 assert_string_is_neither_NULL_nor_zerolength(device); 392 388 assert_string_is_neither_NULL_nor_zerolength(mpt); 393 389 assert(format != NULL); 394 malloc_string(tmp);395 malloc_string(command);396 malloc_string(mountdir);397 malloc_string(additional_parameters);398 390 399 391 if (!strcmp(mpt, "/1")) { … … 412 404 return (0); 413 405 } 414 sprintf(tmp, "Mounting device %s ", device); 415 mr_msg(1, tmp); 406 mr_msg(1, "Mounting device %s ", device); 416 407 if (writeable) { 417 strcpy(additional_parameters, "-o rw");418 } else { 419 strcpy(additional_parameters, "-o ro");408 mr_asprintf(&additional_parameters, "-o rw"); 409 } else { 410 mr_asprintf(&additional_parameters, "-o ro"); 420 411 } 421 412 if (find_home_of_exe("setfattr")) { 422 strcat(additional_parameters, ",user_xattr");413 mr_strcat(additional_parameters, ",user_xattr"); 423 414 } 424 415 if (find_home_of_exe("setfacl")) { 425 strcat(additional_parameters, ",acl");416 mr_strcat(additional_parameters, ",acl"); 426 417 } 427 418 428 419 if (!strcmp(mountpoint, "swap")) { 429 sprintf(command, "swapon %s", device);420 mr_asprintf(&command, "swapon %s", device); 430 421 } else { 431 422 if (!strcmp(mountpoint, "/")) { 432 strcpy(mountdir, MNT_RESTORING);423 mr_asprintf(&mountdir, MNT_RESTORING); 433 424 } else { 434 sprintf(mountdir, "%s%s", MNT_RESTORING, mountpoint);435 } 436 sprintf(command, "mkdir -p %s", mountdir);425 mr_asprintf(&mountdir, "%s%s", MNT_RESTORING, mountpoint); 426 } 427 mr_asprintf(&command, "mkdir -p %s", mountdir); 437 428 run_program_and_log_output(command, FALSE); 438 sprintf(command, "mount -t %s %s %s %s 2>> %s", format, device, 429 mr_free(command); 430 431 mr_asprintf(&command, "mount -t %s %s %s %s 2>> %s", format, device, 439 432 additional_parameters, mountdir, MONDO_LOGFILE); 440 433 mr_msg(2, "command='%s'", command); 441 434 } 435 mr_free(additional_parameters); 436 442 437 res = run_program_and_log_output(command, TRUE); 443 438 if (res && (strstr(command, "xattr") || strstr(command, "acl"))) { 444 439 mr_msg(1, "Re-trying without the fancy extra parameters"); 445 sprintf(command, "mount -t %s %s %s 2>> %s", format, device, 440 mr_free(command); 441 442 mr_asprintf(&command, "mount -t %s %s %s 2>> %s", format, device, 446 443 mountdir, MONDO_LOGFILE); 447 444 res = run_program_and_log_output(command, TRUE); … … 452 449 mr_msg(1, "command was '%s'", command); 453 450 if (!strcmp(mountpoint, "swap")) { 454 log_to_screen(tmp); 451 log_to_screen("Unable to mount device %s (type %s) at %s", device, 452 format, mountdir); 455 453 } else { 456 454 mr_msg(2, "Retrying w/o the '-t' switch"); 457 sprintf(command, "mount %s %s 2>> %s", device, mountdir, 455 mr_free(command); 456 457 mr_asprintf(&command, "mount %s %s 2>> %s", device, mountdir, 458 458 MONDO_LOGFILE); 459 459 mr_msg(2, "2nd command = '%s'", command); … … 467 467 } 468 468 } 469 mr_free(command); 470 mr_free(mountdir); 471 469 472 if (res && !strcmp(mountpoint, "swap")) { 470 473 mr_msg(2, "That's ok. It's just a swap partition."); … … 472 475 res = 0; 473 476 } 474 475 mr_free(tmp);476 mr_free(command);477 mr_free(mountdir);478 477 mr_free(mountpoint); 479 mr_free(additional_parameters);480 478 481 479 return (res); 482 480 } 483 484 481 /************************************************************************** 485 482 *END_MOUNT_DEVICE * 486 483 **************************************************************************/ 487 488 489 484 490 485 … … 498 493 *p_external_copy_of_mountlist, bool writeable) 499 494 { 500 int retval = 0, lino, res; 501 char *tmp, *these_failed, *format; 502 struct mountlist_itself *mountlist; 503 504 malloc_string(tmp); 505 malloc_string(format); 506 malloc_string(these_failed); 495 int retval = 0; 496 int lino = 0; 497 int res = 0; 498 char *tmp = NULL; 499 char *these_failed = NULL; 500 char *format = NULL; 501 struct mountlist_itself *mountlist = NULL; 502 507 503 assert(p_external_copy_of_mountlist != NULL); 508 504 mountlist = (struct mountlist_itself *)mr_malloc(sizeof(struct mountlist_itself)); … … 511 507 sort_mountlist_by_mountpoint(mountlist, 0); 512 508 513 /** menset **/ 514 these_failed[0] = '\0'; 515 516 mvaddstr_and_log_it(g_currentY, 0, "Mounting devices "); 517 open_progress_form("Mounting devices", 518 "I am now mounting all the drives.", 519 "This should not take long.", 509 mvaddstr_and_log_it(g_currentY, 0, _("Mounting devices ")); 510 open_progress_form(_("Mounting devices"), 511 _("I am now mounting all the drives."), 512 _("This should not take long."), 520 513 "", mountlist->entries); 521 514 … … 525 518 "Again with the /proc - why is this in your mountlist?"); 526 519 } else if (is_this_device_mounted(mountlist->el[lino].device)) { 527 sprintf(tmp, "%s is already mounted",520 log_to_screen(_("%s is already mounted"), 528 521 mountlist->el[lino].device); 529 log_to_screen(tmp);530 522 } else if (strcmp(mountlist->el[lino].mountpoint, "none") 531 523 && strcmp(mountlist->el[lino].mountpoint, "lvm") 532 524 && strcmp(mountlist->el[lino].mountpoint, "raid") 533 525 && strcmp(mountlist->el[lino].mountpoint, "image")) { 534 sprintf(tmp, "Mounting %s", mountlist->el[lino].device);526 mr_asprintf(&tmp, "Mounting %s", mountlist->el[lino].device); 535 527 update_progress_form(tmp); 536 strcpy(format, mountlist->el[lino].format); 528 mr_free(tmp); 529 530 mr_asprintf(&format, mountlist->el[lino].format); 537 531 if (!strcmp(format, "ext3")) { 538 strcpy(format, "ext2"); 532 mr_free(format); 533 mr_asprintf(&format, "ext2"); 539 534 } 540 535 res = mount_device(mountlist->el[lino].device, … … 543 538 retval += res; 544 539 if (res) { 545 strcat(these_failed, mountlist->el[lino].device); 546 strcat(these_failed, " "); 547 } 540 if (these_failed != NULL) { /* not the first time */ 541 mr_strcat(these_failed, " %s", mountlist->el[lino].device); 542 } else { /* The first time */ 543 mr_asprintf(&these_failed, "%s", mountlist->el[lino].device); 544 } 545 } 546 mr_free(format); 548 547 } 549 548 g_current_progress++; … … 554 553 if (g_partition_table_locked_up > 0) { 555 554 log_to_screen 556 ("fdisk's ictol() call to refresh its copy of the partition table causes the kernel to"); 557 log_to_screen 558 ("lock up the partition table. You might have to reboot and use Interactive Mode to"); 559 log_to_screen 560 ("format and restore *without* partitioning first. Sorry for the inconvenience."); 561 } 562 sprintf(tmp, "Could not mount devices %s- shall I abort?", 555 (_ 556 ("fdisk's ioctl() call to refresh its copy of the partition table causes the kernel to")); 557 log_to_screen(_ 558 ("lock up the partition table. You might have to reboot and use Interactive Mode to")); 559 log_to_screen(_ 560 ("format and restore *without* partitioning first. Sorry for the inconvenience.")); 561 } 562 mr_asprintf(&tmp, _("Could not mount devices %s- shall I abort?"), 563 563 these_failed); 564 mr_free(these_failed); 565 564 566 if (!ask_me_yes_or_no(tmp)) { 565 567 retval = 0; 566 568 log_to_screen 567 ("Continuing, although some devices failed to be mounted"); 568 mvaddstr_and_log_it(g_currentY++, 74, "Done."); 569 (_ 570 ("Continuing, although some devices failed to be mounted")); 571 mvaddstr_and_log_it(g_currentY++, 74, _("Done.")); 569 572 } else { 570 mvaddstr_and_log_it(g_currentY++, 74, "Failed.");573 mvaddstr_and_log_it(g_currentY++, 74, _("Failed.")); 571 574 log_to_screen 572 ("Unable to mount some or all of your partitions."); 573 } 574 } else { 575 log_to_screen("All partitions were mounted OK."); 576 mvaddstr_and_log_it(g_currentY++, 74, "Done."); 575 (_("Unable to mount some or all of your partitions.")); 576 } 577 mr_free(tmp); 578 } else { 579 log_to_screen(_("All partitions were mounted OK.")); 580 mvaddstr_and_log_it(g_currentY++, 74, _("Done.")); 577 581 } 578 582 run_program_and_log_output("df -m", 3); 579 583 mr_free(mountlist); 580 mr_free(tmp);581 mr_free(format);582 mr_free(these_failed);583 584 return (retval); 584 585 } 585 586 586 /************************************************************************** 587 587 *END_MOUNT_ALL_DEVICES * … … 600 600 int mount_cdrom(struct s_bkpinfo *bkpinfo) 601 601 { 602 char *mount_cmd ;603 int i , res;602 char *mount_cmd = NULL; 603 int i = 0, res = 0; 604 604 #ifdef __FreeBSD__ 605 char mdd[32]; 606 char *mddev = mdd; 605 char *mddev = NULL; 607 606 #endif 608 607 609 malloc_string(mount_cmd);610 608 assert(bkpinfo != NULL); 611 609 … … 613 611 || bkpinfo->backup_media_type == udev) { 614 612 mr_msg(8, "Tape/udev. Therefore, no need to mount CDROM."); 615 mr_free(mount_cmd);616 613 return 0; 617 614 } … … 619 616 if (!run_program_and_log_output("mount | grep -F " MNT_CDROM, FALSE)) { 620 617 mr_msg(2, "mount_cdrom() - CD already mounted. Fair enough."); 621 mr_free(mount_cmd);622 618 return (0); 623 619 } … … 632 628 } 633 629 #ifdef __FreeBSD__ 634 sprintf(mount_cmd, "/mnt/isodir/%s/%s/%s-%d.iso", bkpinfo->isodir, 635 bkpinfo->nfs_remote_dir, bkpinfo->prefix, g_current_media_number); 630 mr_asprintf(&mount_cmd, "/mnt/isodir/%s/%s/%s-%d.iso", bkpinfo->isodir, 631 bkpinfo->nfs_remote_dir, bkpinfo->prefix, 632 g_current_media_number); 636 633 mddev = make_vn(mount_cmd); 637 sprintf(mount_cmd, "mount_cd9660 -r %s " MNT_CDROM, mddev); 634 mr_free(mount_cmd); 635 636 mr_asprintf(&mount_cmd, "mount_cd9660 -r %s " MNT_CDROM, mddev); 637 mr_free(mddev); 638 638 #else 639 sprintf(mount_cmd, "mount %s/%s/%s-%d.iso -t iso9660 -o loop,ro %s", 640 bkpinfo->isodir, bkpinfo->nfs_remote_dir, 641 bkpinfo->prefix, g_current_media_number, MNT_CDROM); 639 mr_asprintf(&mount_cmd, 640 "mount %s/%s/%s-%d.iso -t iso9660 -o loop,ro %s", 641 bkpinfo->isodir, bkpinfo->nfs_remote_dir, bkpinfo->prefix, 642 g_current_media_number, MNT_CDROM); 642 643 #endif 643 644 644 } else 645 if (bkpinfo->backup_media_type == iso) { 645 } else if (bkpinfo->backup_media_type == iso) { 646 646 #ifdef __FreeBSD__ 647 sprintf(mount_cmd, "%s/%s-%d.iso", bkpinfo->isodir,647 mr_asprintf(&mount_cmd, "%s/%s-%d.iso", bkpinfo->isodir, 648 648 bkpinfo->prefix, g_current_media_number); 649 649 mddev = make_vn(mount_cmd); 650 sprintf(mount_cmd, "mount_cd9660 -r %s %s", mddev, MNT_CDROM); 650 mr_free(mount_cmd); 651 652 mr_asprintf(&mount_cmd, "mount_cd9660 -r %s %s", mddev, MNT_CDROM); 653 mr_free(mddev); 651 654 #else 652 sprintf(mount_cmd, "mount %s/%s-%d.iso -t iso9660 -o loop,ro %s", 653 bkpinfo->isodir, bkpinfo->prefix, g_current_media_number, MNT_CDROM); 655 mr_asprintf(&mount_cmd, "mount %s/%s-%d.iso -t iso9660 -o loop,ro %s", 656 bkpinfo->isodir, bkpinfo->prefix, g_current_media_number, 657 MNT_CDROM); 654 658 #endif 655 659 } else if (strstr(bkpinfo->media_device, "/dev/")) 656 660 #ifdef __FreeBSD__ 657 661 { 658 sprintf(mount_cmd, "mount_cd9660 -r %s %s", bkpinfo->media_device,662 mr_asprintf(&mount_cmd, "mount_cd9660 -r %s %s", bkpinfo->media_device, 659 663 MNT_CDROM); 660 664 } 661 665 #else 662 666 { 663 sprintf(mount_cmd, "mount %s -t iso9660 -o ro %s",667 mr_asprintf(&mount_cmd, "mount %s -t iso9660 -o ro %s", 664 668 bkpinfo->media_device, MNT_CDROM); 665 669 } … … 676 680 677 681 #ifdef __FreeBSD__ 678 sprintf(mount_cmd, "mount_cd9660 -r %s %s", bkpinfo->media_device,682 mr_asprintf(&mount_cmd, "mount_cd9660 -r %s %s", bkpinfo->media_device, 679 683 MNT_CDROM); 680 684 #else 681 sprintf(mount_cmd, "mount %s -t iso9660 -o ro %s",685 mr_asprintf(&mount_cmd, "mount %s -t iso9660 -o ro %s", 682 686 bkpinfo->media_device, MNT_CDROM); 683 687 #endif … … 695 699 } 696 700 } 701 mr_free(mount_cmd); 702 697 703 if (res) { 698 704 mr_msg(2, "Failed, despite %d attempts", i); … … 700 706 mr_msg(2, "Mounted CD-ROM drive OK"); 701 707 } 702 mr_free(mount_cmd);703 708 return (res); 704 709 } 705 706 707 708 709 710 710 /************************************************************************** 711 711 *END_MOUNT_CDROM * … … 739 739 TRUE); 740 740 } 741 742 741 /************************************************************************** 743 742 *END_PROTECT_AGAINST_BRAINDEAD_SYSADMINS * 744 743 **************************************************************************/ 745 746 747 744 748 745 … … 756 753 int read_cfg_file_into_bkpinfo(char *cfgf, struct s_bkpinfo *bkpinfo) 757 754 { 758 /** add mallocs **/759 755 char *value = NULL; 760 756 char *tmp = NULL; … … 765 761 char *iso_path = NULL; 766 762 char *old_isodir = NULL; 767 char cfg_file[100];763 char *cfg_file = NULL; 768 764 t_bkptype media_specified_by_user; 769 765 770 malloc_string(command);771 malloc_string(iso_mnt);772 malloc_string(iso_path);773 malloc_string(old_isodir);774 766 malloc_string(value); 775 malloc_string(tmp);776 // assert_string_is_neither_NULL_nor_zerolength(cfg_file);777 767 assert(bkpinfo != NULL); 778 768 779 769 if (!cfgf) { 780 strcpy(cfg_file, g_mondo_cfg_file);781 } else { 782 strcpy(cfg_file, cfgf);770 cfg_file = g_mondo_cfg_file; 771 } else { 772 cfg_file = cfgf; 783 773 } 784 774 … … 795 785 bkpinfo->backup_media_type = dvd; 796 786 } else if (!strcmp(value, "iso")) { 797 /* 798 if (am_I_in_disaster_recovery_mode() 799 && !run_program_and_log_output("mount /dev/cdrom "MNT_CDROM, 1) 800 && does_file_exist(MNT_CDROM"/archives/filelist.0")) 801 */ 802 803 // Patch by Conor Daly - 2004/07/12 787 // Patch by Conor Daly - 2004/07/12 804 788 bkpinfo->backup_media_type = iso; 805 789 if (am_I_in_disaster_recovery_mode()) { … … 853 837 if (bkpinfo->disaster_recovery) { 854 838 if (bkpinfo->backup_media_type == cdstream) { 855 sprintf(bkpinfo->media_device, "/dev/cdrom"); 856 // bkpinfo->media_size[0] = -1; 839 strcpy(bkpinfo->media_device, "/dev/cdrom"); 857 840 bkpinfo->media_size[0] = 1999 * 1024; 858 841 bkpinfo->media_size[1] = 650; /* good guess */ … … 865 848 read_cfg_var(cfg_file, "media-size", value); 866 849 bkpinfo->media_size[1] = atol(value); 867 sprintf(tmp, "Backup medium is TAPE --- dev=%s",850 mr_msg(2, "Backup medium is TAPE --- dev=%s", 868 851 bkpinfo->media_device); 869 mr_msg(2, tmp);870 852 } else { 871 853 strcpy(bkpinfo->media_device, "/dev/cdrom"); /* we don't really need this var */ … … 995 977 * isodir in disaster recovery mode 996 978 */ 997 strcpy(old_isodir, bkpinfo->isodir);979 mr_asprintf(&old_isodir, bkpinfo->isodir); 998 980 read_cfg_var(g_mondo_cfg_file, "iso-mnt", iso_mnt); 999 981 read_cfg_var(g_mondo_cfg_file, "isodir", iso_path); … … 1010 992 } 1011 993 } 994 mr_free(old_isodir); 995 1012 996 read_cfg_var(g_mondo_cfg_file, "iso-dev", g_isodir_device); 1013 mr_msg(2, "isodir=%s; iso-dev=%s", bkpinfo->isodir, 1014 g_isodir_device); 997 mr_msg(2, "isodir=%s; iso-dev=%s", bkpinfo->isodir, g_isodir_device); 1015 998 if (bkpinfo->disaster_recovery) { 1016 999 if (is_this_device_mounted(g_isodir_device)) { 1017 1000 mr_msg(2, "NB: isodir is already mounted"); 1018 1001 /* Find out where it's mounted */ 1019 sprintf(command,1002 mr_asprintf(&command, 1020 1003 "mount | grep -E '^%s' | tail -n1 | cut -d' ' -f3", 1021 1004 g_isodir_device); 1022 1005 log_it("command = %s", command); 1023 log_it("res of it = %s", 1024 call_program_and_get_last_line_of_output(command)); 1025 sprintf(iso_mnt, "%s", 1006 mr_asprintf(&iso_mnt, "%s", 1026 1007 call_program_and_get_last_line_of_output(command)); 1008 log_it("res of it = %s", iso_mnt); 1027 1009 } else { 1028 sprintf(iso_mnt, "/tmp/isodir");1029 sprintf(tmp, "mkdir -p %s", iso_mnt);1010 mr_asprintf(&iso_mnt, "/tmp/isodir"); 1011 mr_asprintf(&tmp, "mkdir -p %s", iso_mnt); 1030 1012 run_program_and_log_output(tmp, 5); 1031 sprintf(tmp, "mount %s %s", g_isodir_device, iso_mnt); 1013 mr_free(tmp); 1014 1015 mr_asprintf(&tmp, "mount %s %s", g_isodir_device, iso_mnt); 1032 1016 if (run_program_and_log_output(tmp, 3)) { 1033 1017 mr_msg(1, … … 1035 1019 bkpinfo->backup_media_type = cdr; 1036 1020 strcpy(bkpinfo->media_device, "/dev/cdrom"); /* superfluous */ 1037 bkpinfo->isodir[0] = iso_mnt[0] = iso_path[0] = '\0'; 1021 bkpinfo->isodir[0] = '\0'; 1022 mr_free(iso_mnt); 1023 mr_free(iso_path); 1024 mr_asprintf(&iso_mnt, ""); 1025 mr_asprintf(&iso_path, ""); 1038 1026 if (mount_cdrom(bkpinfo)) { 1039 1027 fatal_error … … 1044 1032 } 1045 1033 } 1034 mr_free(tmp); 1046 1035 } 1047 1036 /* bkpinfo->isodir should now be the true path to prefix-1.iso etc... */ … … 1049 1038 sprintf(bkpinfo->isodir, "%s%s", iso_mnt, iso_path); 1050 1039 } 1040 mr_free(iso_mnt); 1041 mr_free(iso_path); 1051 1042 } 1052 1043 } … … 1057 1048 mr_msg(2, 1058 1049 "bkpinfo->backup_media_type != media_specified_by_user, so I'd better ask :)"); 1059 interactively_obtain_media_parameters_from_user(bkpinfo, 1060 FALSE); 1050 interactively_obtain_media_parameters_from_user(bkpinfo, FALSE); 1061 1051 media_specified_by_user = bkpinfo->backup_media_type; 1062 1052 get_cfg_file_from_archive(bkpinfo); 1063 /*1064 if (media_specified_by_user != cdr && media_specified_by_user == cdrw)1065 { g_restoring_live_from_cd = FALSE; }1066 */1067 1053 } 1068 1054 } … … 1070 1056 } 1071 1057 g_backup_media_type = bkpinfo->backup_media_type; 1058 strcpy(bkpinfo->backup_media_string, bkptype_to_string(bkpinfo->backup_media_type)); 1059 strcpy(g_backup_media_string, bkpinfo->backup_media_string); 1072 1060 mr_free(value); 1073 mr_free(tmp);1074 mr_free(command);1075 mr_free(iso_mnt);1076 mr_free(iso_path);1077 mr_free(old_isodir);1078 1061 return (0); 1079 1080 } 1081 1062 } 1082 1063 /************************************************************************** 1083 1064 *END_READ_CFG_FILE_INTO_BKPINFO * 1084 1065 **************************************************************************/ 1085 1086 1087 1066 1088 1067 … … 1100 1079 s_node *process_filelist_and_biggielist(struct s_bkpinfo *bkpinfo) 1101 1080 { 1102 struct s_node *filelist; 1103 1104 /** add mallocs**/ 1105 char *command; 1106 char *tmp; 1081 struct s_node *filelist = NULL; 1082 1083 char *command = NULL; 1084 char *tmp = NULL; 1107 1085 int res = 0; 1086 size_t n = 0; 1108 1087 pid_t pid; 1109 1088 1110 1089 assert(bkpinfo != NULL); 1111 malloc_string(command);1112 1090 malloc_string(tmp); 1113 1091 … … 1127 1105 unlink("/tmp/i-want-my-lvm"); 1128 1106 if (IS_THIS_A_STREAMING_BACKUP(bkpinfo->backup_media_type)) { 1129 sprintf(command,1107 mr_asprintf(&command, 1130 1108 "tar -zxf %s %s %s %s %s %s", 1131 1109 bkpinfo->media_device, … … 1136 1114 mr_msg(1, "tarcommand = %s", command); 1137 1115 run_program_and_log_output(command, 1); 1116 mr_free(command); 1138 1117 } else { 1139 1118 mr_msg(2, … … 1143 1122 mr_msg(2, "Back from iotcn"); 1144 1123 run_program_and_log_output("mount", 1); 1145 sprintf(command,1124 mr_asprintf(&command, 1146 1125 "tar -zxf %s/images/all.tar.gz %s %s %s %s %s", 1147 1126 MNT_CDROM, … … 1153 1132 mr_msg(1, "tarcommand = %s", command); 1154 1133 run_program_and_log_output(command, 1); 1155 // popup_and_OK("Press ENTER to continue"); 1134 mr_free(command); 1135 1156 1136 if (!does_file_exist(BIGGIELIST_TXT_STUB)) { 1157 1137 fatal_error … … 1163 1143 } 1164 1144 } 1165 sprintf(command, "cp -f %s %s", MONDO_CFG_FILE_STUB,1145 mr_asprintf(&command, "cp -f %s %s", MONDO_CFG_FILE_STUB, 1166 1146 g_mondo_cfg_file); 1167 1147 run_program_and_log_output(command, FALSE); 1168 1169 sprintf(command, "cp -f %s/%s %s", bkpinfo->tmpdir, 1148 mr_free(command); 1149 1150 mr_asprintf(&command, "cp -f %s/%s %s", bkpinfo->tmpdir, 1170 1151 BIGGIELIST_TXT_STUB, g_biggielist_txt); 1171 1152 mr_msg(1, "command = %s", command); 1172 1153 paranoid_system(command); 1173 sprintf(command, "ln -sf %s/%s %s", bkpinfo->tmpdir, 1154 mr_free(command); 1155 1156 mr_asprintf(&command, "ln -sf %s/%s %s", bkpinfo->tmpdir, 1174 1157 FILELIST_FULL_STUB, g_filelist_full); 1175 1158 mr_msg(1, "command = %s", command); 1176 1159 paranoid_system(command); 1160 mr_free(command); 1177 1161 } 1178 1162 1179 1163 if (am_I_in_disaster_recovery_mode() 1180 1164 && 1181 ask_me_yes_or_no("Do you want to retrieve the mountlist as well?")) 1165 ask_me_yes_or_no(_ 1166 ("Do you want to retrieve the mountlist as well?"))) 1182 1167 { 1183 // sprintf(command, "cp -f tmp/mountlist.txt /tmp"); 1184 sprintf(command, "ln -sf %s/%s /tmp", MOUNTLIST_FNAME_STUB, 1168 mr_asprintf(&command, "ln -sf %s/%s /tmp", MOUNTLIST_FNAME_STUB, 1185 1169 bkpinfo->tmpdir); 1186 1170 paranoid_system(command); 1171 mr_free(command); 1187 1172 } 1188 1173 1189 1174 chdir(tmp); 1175 mr_free(tmp); 1190 1176 1191 1177 if (!does_file_exist(g_biggielist_txt)) { … … 1195 1181 mr_msg(1, "Warning - %s does not exist", g_filelist_full); 1196 1182 } 1197 // popup_and_OK("Wonderful.");1198 1183 1199 1184 mr_msg(2, "Forking"); … … 1205 1190 1206 1191 case 0: 1207 log_to_screen( "Pre-processing filelist");1192 log_to_screen(_("Pre-processing filelist")); 1208 1193 if (!does_file_exist(g_biggielist_txt)) { 1209 sprintf(command, "> %s", g_biggielist_txt);1194 mr_asprintf(&command, "> %s", g_biggielist_txt); 1210 1195 paranoid_system(command); 1211 } 1212 sprintf(command, "grep -E '^/dev/.*' %s > %s", 1196 mr_free(command); 1197 } 1198 mr_asprintf(&command, "grep -E '^/dev/.*' %s > %s", 1213 1199 g_biggielist_txt, g_filelist_imagedevs); 1214 1200 paranoid_system(command); 1201 mr_free(command); 1215 1202 exit(0); 1216 1203 break; 1217 1204 1218 1205 default: 1219 open_evalcall_form( "Pre-processing filelist");1206 open_evalcall_form(_("Pre-processing filelist")); 1220 1207 while (!waitpid(pid, (int *) 0, WNOHANG)) { 1221 1208 usleep(100000); … … 1230 1217 unlink(g_filelist_full); 1231 1218 if (g_text_mode) { 1232 printf( "Restore which directory? --> ");1233 fgets(tmp, sizeof(tmp), stdin);1219 printf(_("Restore which directory? --> ")); 1220 mr_getline(&tmp, &n, stdin); 1234 1221 toggle_path_selection(filelist, tmp, TRUE); 1235 1222 if (strlen(tmp) == 0) { … … 1238 1225 res = 0; 1239 1226 } 1227 mr_free(tmp); 1240 1228 } else { 1241 1229 res = edit_filelist(filelist); … … 1259 1247 TRUE); 1260 1248 } 1261 1262 mr_free(command);1263 mr_free(tmp);1264 1249 return (filelist); 1265 1250 } 1266 1267 1251 /************************************************************************** 1268 1252 *END_ PROCESS_FILELIST_AND_BIGGIELIST * 1269 1253 **************************************************************************/ 1270 1271 1272 1254 1273 1255 … … 1281 1263 int backup_crucial_file(char *path_root, char *filename) 1282 1264 { 1283 char *tmp; 1284 char *command; 1285 int res; 1286 1287 malloc_string(tmp); 1288 malloc_string(command); 1265 char *command = NULL; 1266 int res = 0; 1267 1289 1268 assert(path_root != NULL); 1290 1269 assert_string_is_neither_NULL_nor_zerolength(filename); 1291 1270 1292 sprintf(tmp, "%s/%s", path_root, filename); 1293 sprintf(command, "cp -f %s %s.pristine", tmp, tmp); 1294 1271 mr_asprintf(&command, "cp -f %s/%s %s/%s.pristine", path_root, filename,path_root, filename); 1295 1272 res = run_program_and_log_output(command, 5); 1296 mr_free(tmp);1297 1273 mr_free(command); 1298 1274 return (res); … … 1308 1284 int run_boot_loader(bool offer_to_hack_scripts) 1309 1285 { 1310 int res ;1286 int res = 0; 1311 1287 int retval = 0; 1312 1288 1313 /** malloc *******/ 1314 char *device; 1315 char *tmp; 1316 char *name; 1289 char *device = NULL; 1290 char *tmp = NULL; 1291 char *name = NULL; 1317 1292 1318 1293 malloc_string(device); 1319 malloc_string(tmp);1320 1294 malloc_string(name); 1321 1295 backup_crucial_file(MNT_RESTORING, "/etc/fstab"); … … 1325 1299 read_cfg_var(g_mondo_cfg_file, "bootloader.device", device); 1326 1300 read_cfg_var(g_mondo_cfg_file, "bootloader.name", name); 1327 sprintf(tmp, "run_boot_loader: device='%s', name='%s'", device, name); 1328 mr_msg(2, tmp); 1329 system("sync"); 1301 mr_msg(2, "run_boot_loader: device='%s', name='%s'", device, name); 1302 sync(); 1330 1303 if (!strcmp(name, "LILO")) { 1331 1304 res = run_lilo(offer_to_hack_scripts); … … 1333 1306 res = run_elilo(offer_to_hack_scripts); 1334 1307 } else if (!strcmp(name, "GRUB")) { 1335 // if ( does_file_exist(DO_MBR_PLEASE) || (offer_to_hack_scripts && ask_me_yes_or_no("Because of bugs in GRUB, you're much better off running mondorestore --mbr after this program terminates. Are you sure you want to install GRUB right now?")))1336 // {1337 1308 res = run_grub(offer_to_hack_scripts, device); 1338 // unlink(DO_MBR_PLEASE);1339 // }1340 // else1341 // {1342 // mr_msg(1, "Not running run_grub(). Was a bad idea anyway.");1343 // res = 1;1344 // }1345 1309 } else if (!strcmp(name, "RAW")) { 1346 1310 res = run_raw_mbr(offer_to_hack_scripts, device); … … 1348 1312 #ifdef __FreeBSD__ 1349 1313 else if (!strcmp(name, "BOOT0")) { 1350 sprintf(tmp, "boot0cfg -B %s", device);1314 mr_asprintf(&tmp, "boot0cfg -B %s", device); 1351 1315 res = run_program_and_log_output(tmp, FALSE); 1352 } else { 1353 sprintf(tmp, "ls /dev | grep -Eq '^%ss[1-4].*'", device); 1316 mr_free(tmp); 1317 } else { 1318 mr_asprintf(&tmp, "ls /dev | grep -Eq '^%ss[1-4].*$'", device); 1354 1319 if (!system(tmp)) { 1355 sprintf(tmp, MNT_RESTORING "/sbin/fdisk -B %s", device); 1320 mr_free(tmp); 1321 mr_asprintf(&tmp, MNT_RESTORING "/sbin/fdisk -B %s", device); 1356 1322 res = run_program_and_log_output(tmp, 3); 1357 1323 } else { … … 1359 1325 "I'm not running any boot loader. You have a DD boot drive. It's already loaded up."); 1360 1326 } 1327 mr_free(tmp); 1361 1328 } 1362 1329 #else 1363 1330 else { 1364 1331 log_to_screen 1365 ("Unable to determine type of boot loader. Defaulting to LILO."); 1332 (_ 1333 ("Unable to determine type of boot loader. Defaulting to LILO.")); 1366 1334 res = run_lilo(offer_to_hack_scripts); 1367 1335 } 1368 1336 #endif 1337 mr_free(device); 1338 mr_free(name); 1339 1369 1340 retval += res; 1370 1341 if (res) { 1371 log_to_screen("Your boot loader returned an error"); 1372 } else { 1373 log_to_screen("Your boot loader ran OK"); 1374 } 1375 mr_free(device); 1376 mr_free(tmp); 1377 mr_free(name); 1342 log_to_screen(_("Your boot loader returned an error")); 1343 } else { 1344 log_to_screen(_("Your boot loader ran OK")); 1345 } 1378 1346 return (retval); 1379 1347 } 1380 1381 1348 /************************************************************************** 1382 1349 *END_ RUN_BOOT_LOADER * … … 1384 1351 1385 1352 1386 1387 1353 /** 1388 1354 * Attempt to find the user's editor. … … 1393 1359 { 1394 1360 static char output[MAX_STR_LEN]; 1361 1395 1362 if (find_home_of_exe("pico")) { 1396 1363 strcpy(output, "pico"); … … 1419 1386 int run_grub(bool offer_to_run_stabgrub, char *bd) 1420 1387 { 1421 /** malloc **/ 1422 char *command; 1423 char *boot_device; 1424 char *rootdev; 1425 char *rootdrive; 1426 char *conffile; 1427 char *tmp; 1428 char *editor; 1429 1430 int res; 1431 int done; 1432 1433 malloc_string(command); 1388 char *command = NULL; 1389 char *boot_device = NULL; 1390 char *tmp = NULL; 1391 char *editor = NULL; 1392 1393 int res = 0; 1394 int done = 0; 1395 1434 1396 malloc_string(boot_device); 1435 malloc_string(tmp); 1436 malloc_string(editor); 1437 malloc_string(rootdev); 1438 malloc_string(rootdrive); 1439 malloc_string(conffile); 1397 strcpy(boot_device, bd); 1440 1398 assert_string_is_neither_NULL_nor_zerolength(bd); 1441 strcpy(editor, "vi"); // find_my_editor() ); 1442 strcpy(boot_device, bd); 1443 1444 if (!run_program_and_log_output("which grub-MR", FALSE)) { 1445 mr_msg(1, "Yay! grub-MR found..."); 1446 sprintf(command, "grub-MR %s /tmp/mountlist.txt", boot_device); 1447 mr_msg(1, "command = %s", command); 1448 } else { 1449 sprintf(command, "chroot " MNT_RESTORING " grub-install %s", 1450 boot_device); 1451 mr_msg(1, "WARNING - grub-MR not found; using grub-install"); 1452 } 1399 mr_asprintf(&editor, find_my_editor()); 1400 1453 1401 if (offer_to_run_stabgrub 1454 && ask_me_yes_or_no( "Did you change the mountlist?"))1402 && ask_me_yes_or_no(_("Did you change the mountlist?"))) 1455 1403 /* interactive mode */ 1456 1404 { 1457 1405 mvaddstr_and_log_it(g_currentY, 1458 1406 0, 1459 "Modifying fstab and grub.conf, and running GRUB... "); 1407 _ 1408 ("Modifying fstab and grub.conf, and running GRUB... ")); 1460 1409 for (done = FALSE; !done;) { 1461 popup_and_get_string("Boot device", 1462 "Please confirm/enter the boot device. If in doubt, try /dev/hda", 1463 boot_device, MAX_STR_LEN / 4); 1464 sprintf(command, "stabgrub-me %s", boot_device); 1410 popup_and_get_string(_("Boot device"), 1411 _("Please confirm/enter the boot device. If in doubt, try /dev/hda"), boot_device, MAX_STR_LEN / 4); 1412 mr_asprintf(&command, "stabgrub-me %s", boot_device); 1465 1413 res = run_program_and_log_output(command, 1); 1414 mr_free(command); 1415 1466 1416 if (res) { 1467 1417 popup_and_OK 1468 ("GRUB installation failed. Please install manually using 'grub-install' or similar command. You are now chroot()'ed to your restored system. Please type 'exit' when you are done."); 1418 (_ 1419 ("GRUB installation failed. Please install manually using 'grub-install' or similar command. You are now chroot()'ed to your restored system. Please type 'exit' when you are done.")); 1469 1420 newtSuspend(); 1470 1421 system("chroot " MNT_RESTORING); 1471 1422 newtResume(); 1472 popup_and_OK( "Thank you.");1423 popup_and_OK(_("Thank you.")); 1473 1424 } else { 1474 1425 done = TRUE; 1475 1426 } 1476 popup_and_OK( "You will now edit fstab and grub.conf");1427 popup_and_OK(_("You will now edit fstab and grub.conf")); 1477 1428 if (!g_text_mode) { 1478 1429 newtSuspend(); 1479 1430 } 1480 sprintf(tmp, "%s " MNT_RESTORING "/etc/fstab", editor);1431 mr_asprintf(&tmp, "%s " MNT_RESTORING "/etc/fstab", editor); 1481 1432 paranoid_system(tmp); 1482 sprintf(tmp, "%s " MNT_RESTORING "/etc/grub.conf", editor); 1433 mr_free(tmp); 1434 1435 mr_asprintf(&tmp, "%s " MNT_RESTORING "/etc/grub.conf", editor); 1483 1436 paranoid_system(tmp); 1437 mr_free(tmp); 1438 1484 1439 if (!g_text_mode) { 1485 1440 newtResume(); 1486 1441 } 1487 1442 } 1488 } else 1443 } else { 1489 1444 /* nuke mode */ 1490 { 1445 if (!run_program_and_log_output("which grub-MR", FALSE)) { 1446 mr_msg(1, "Yay! grub-MR found..."); 1447 mr_asprintf(&command, "grub-MR %s /tmp/mountlist.txt", bd); 1448 mr_msg(1, "command = %s", command); 1449 } else { 1450 mr_asprintf(&command, "chroot " MNT_RESTORING " grub-install %s", bd); 1451 mr_msg(1, "WARNING - grub-MR not found; using grub-install"); 1452 } 1491 1453 mvaddstr_and_log_it(g_currentY, 1492 1454 0, 1493 "Running GRUB... "); 1455 _ 1456 ("Running GRUB... ")); 1494 1457 iamhere(command); 1495 1458 res = run_program_and_log_output(command, 1); 1459 mr_free(command); 1460 1496 1461 if (res) { 1497 1462 popup_and_OK 1498 ("Because of bugs in GRUB's own installer, GRUB was not installed properly. Please install the boot loader manually now, using this chroot()'ed shell prompt. Type 'exit' when you have finished."); 1463 (_ 1464 ("Because of bugs in GRUB's own installer, GRUB was not installed properly. Please install the boot loader manually now, using this chroot()'ed shell prompt. Type 'exit' when you have finished.")); 1499 1465 newtSuspend(); 1500 1466 system("chroot " MNT_RESTORING); 1501 1467 newtResume(); 1502 popup_and_OK( "Thank you.");1468 popup_and_OK(_("Thank you.")); 1503 1469 } 1504 1470 } 1505 1471 if (res) { 1506 mvaddstr_and_log_it(g_currentY++, 74, "Failed.");1472 mvaddstr_and_log_it(g_currentY++, 74, _("Failed.")); 1507 1473 log_to_screen 1508 ("GRUB ran w/error(s). See /tmp/mondo-restore.log for more info."); 1474 (_ 1475 ("GRUB ran w/error(s). See /tmp/mondo-restore.log for more info.")); 1509 1476 mr_msg(1, "Type:-"); 1510 1477 mr_msg(1, " mount-me"); … … 1517 1484 "If you're really stuck, please e-mail the mailing list."); 1518 1485 } else { 1519 mvaddstr_and_log_it(g_currentY++, 74, "Done."); 1520 } 1521 mr_free(rootdev); 1522 mr_free(rootdrive); 1523 mr_free(conffile); 1524 mr_free(command); 1486 mvaddstr_and_log_it(g_currentY++, 74, _("Done.")); 1487 } 1525 1488 mr_free(boot_device); 1526 mr_free(tmp);1527 1489 mr_free(editor); 1528 1529 1490 return (res); 1530 1491 } 1531 1532 1492 /************************************************************************** 1533 1493 *END_RUN_GRUB * … … 1542 1502 int run_elilo(bool offer_to_run_stabelilo) 1543 1503 { 1544 /** malloc **/ 1545 char *command; 1546 char *tmp; 1547 char *editor; 1548 1549 int res; 1550 int done; 1551 1552 malloc_string(command); 1553 malloc_string(tmp); 1554 malloc_string(editor); 1555 strcpy(editor, find_my_editor()); 1504 char *command = NULL; 1505 char *tmp = NULL; 1506 char *editor = NULL; 1507 1508 int res = 0; 1509 int done = 0; 1510 1511 mr_asprintf(&editor, find_my_editor()); 1556 1512 if (offer_to_run_stabelilo 1557 && ask_me_yes_or_no( "Did you change the mountlist?"))1513 && ask_me_yes_or_no(_("Did you change the mountlist?"))) 1558 1514 1559 1515 /* interactive mode */ … … 1561 1517 mvaddstr_and_log_it(g_currentY, 1562 1518 0, 1563 "Modifying fstab and elilo.conf... "); 1564 sprintf(command, "stabelilo-me"); 1519 _ 1520 ("Modifying fstab and elilo.conf... ")); 1521 mr_asprintf(&command, "stabelilo-me"); 1565 1522 res = run_program_and_log_output(command, 3); 1523 mr_free(command); 1524 1566 1525 if (res) { 1567 1526 popup_and_OK 1568 ("You will now edit fstab and elilo.conf, to make sure they match your new mountlist."); 1527 (_ 1528 ("You will now edit fstab and elilo.conf, to make sure they match your new mountlist.")); 1569 1529 for (done = FALSE; !done;) { 1570 1530 if (!g_text_mode) { 1571 1531 newtSuspend(); 1572 1532 } 1573 sprintf(tmp, "%s " MNT_RESTORING "/etc/fstab", editor);1533 mr_asprintf(&tmp, "%s " MNT_RESTORING "/etc/fstab", editor); 1574 1534 paranoid_system(tmp); 1575 sprintf(tmp, "%s " MNT_RESTORING "/etc/elilo.conf", 1576 editor); 1535 mr_free(tmp); 1536 1537 mr_asprintf(&tmp, "%s " MNT_RESTORING "/etc/elilo.conf", editor); 1577 1538 paranoid_system(tmp); 1539 mr_free(tmp); 1540 1578 1541 if (!g_text_mode) { 1579 1542 newtResume(); 1580 1543 } 1581 1544 // newtCls(); 1582 if (ask_me_yes_or_no( "Edit them again?")) {1545 if (ask_me_yes_or_no(_("Edit them again?"))) { 1583 1546 continue; 1584 1547 } … … 1586 1549 } 1587 1550 } else { 1588 log_to_screen( "elilo.conf and fstab were modified OK");1551 log_to_screen(_("elilo.conf and fstab were modified OK")); 1589 1552 } 1590 1553 } else … … 1593 1556 res = TRUE; 1594 1557 } 1595 mr_free(command);1596 mr_free(tmp);1597 1558 mr_free(editor); 1598 1559 return (res); 1599 1560 } 1600 1601 1561 /************************************************************************** 1602 1562 *END_RUN_ELILO * … … 1612 1572 { 1613 1573 /** malloc **/ 1614 char *command ;1615 char *tmp ;1616 char *editor ;1617 1618 int res ;1619 int done ;1574 char *command = NULL; 1575 char *tmp = NULL; 1576 char *editor = NULL; 1577 1578 int res = 0; 1579 int done = 0; 1620 1580 bool run_lilo_M = FALSE; 1621 malloc_string(command);1622 malloc_string(tmp);1623 malloc_string(editor);1624 1581 1625 1582 if (!run_program_and_log_output … … 1628 1585 } 1629 1586 1630 strcpy(editor, find_my_editor());1587 mr_asprintf(&editor, find_my_editor()); 1631 1588 if (offer_to_run_stablilo 1632 && ask_me_yes_or_no("Did you change the mountlist?")) 1633 1589 && ask_me_yes_or_no(_("Did you change the mountlist?"))) { 1634 1590 /* interactive mode */ 1635 {1636 1591 mvaddstr_and_log_it(g_currentY, 1637 1592 0, 1638 "Modifying fstab and lilo.conf, and running LILO... "); 1639 sprintf(command, "stablilo-me"); 1593 _ 1594 ("Modifying fstab and lilo.conf, and running LILO... ")); 1595 mr_asprintf(&command, "stablilo-me"); 1640 1596 res = run_program_and_log_output(command, 3); 1597 mr_free(command); 1598 1641 1599 if (res) { 1642 1600 popup_and_OK 1643 ("You will now edit fstab and lilo.conf, to make sure they match your new mountlist."); 1601 (_ 1602 ("You will now edit fstab and lilo.conf, to make sure they match your new mountlist.")); 1644 1603 for (done = FALSE; !done;) { 1645 1604 if (!g_text_mode) { 1646 1605 newtSuspend(); 1647 1606 } 1648 sprintf(tmp, "%s " MNT_RESTORING "/etc/fstab", editor);1607 mr_asprintf(&tmp, "%s " MNT_RESTORING "/etc/fstab", editor); 1649 1608 paranoid_system(tmp); 1650 sprintf(tmp, "%s " MNT_RESTORING "/etc/lilo.conf", editor); 1609 mr_free(tmp); 1610 1611 mr_asprintf(&tmp, "%s " MNT_RESTORING "/etc/lilo.conf", editor); 1651 1612 paranoid_system(tmp); 1613 mr_free(tmp); 1614 1652 1615 if (!g_text_mode) { 1653 1616 newtResume(); 1654 1617 } 1655 // newtCls(); 1656 if (ask_me_yes_or_no("Edit them again?")) { 1618 if (ask_me_yes_or_no(_("Edit them again?"))) { 1657 1619 continue; 1658 1620 } … … 1668 1630 done = 1669 1631 ask_me_yes_or_no 1670 ( "LILO failed. Re-edit system files?");1632 (_("LILO failed. Re-edit system files?")); 1671 1633 } else { 1672 1634 done = TRUE; … … 1674 1636 } 1675 1637 } else { 1676 log_to_screen( "lilo.conf and fstab were modified OK");1677 } 1678 } else 1638 log_to_screen(_("lilo.conf and fstab were modified OK")); 1639 } 1640 } else { 1679 1641 /* nuke mode */ 1680 {1681 1642 mvaddstr_and_log_it(g_currentY, 1682 1643 0, 1683 "Running LILO... "); 1644 _ 1645 ("Running LILO... ")); 1684 1646 res = 1685 1647 run_program_and_log_output("chroot " MNT_RESTORING " lilo -L", … … 1691 1653 } 1692 1654 if (res) { 1693 mvaddstr_and_log_it(g_currentY++, 74, "Failed.");1655 mvaddstr_and_log_it(g_currentY++, 74, _("Failed.")); 1694 1656 log_to_screen 1695 ("Failed to re-jig fstab and/or lilo. Edit/run manually, please."); 1657 (_ 1658 ("Failed to re-jig fstab and/or lilo. Edit/run manually, please.")); 1696 1659 } else { 1697 mvaddstr_and_log_it(g_currentY++, 74, "Done.");1660 mvaddstr_and_log_it(g_currentY++, 74, _("Done.")); 1698 1661 } 1699 1662 } … … 1704 1667 " lilo -M /dev/sda", 3); 1705 1668 } 1706 mr_free(command);1707 mr_free(tmp);1708 1669 mr_free(editor); 1709 1670 return (res); … … 1723 1684 int run_raw_mbr(bool offer_to_hack_scripts, char *bd) 1724 1685 { 1725 /** malloc **/ 1726 char * command;1727 char * boot_device;1728 char * tmp;1729 char *editor;1730 int res;1731 int done; 1732 1733 malloc_string(command); 1686 char *command = NULL; 1687 char *boot_device = NULL; 1688 char *tmp = NULL; 1689 char *editor = NULL; 1690 int res = 0; 1691 int done = 0; 1692 1693 assert_string_is_neither_NULL_nor_zerolength(bd); 1694 1734 1695 malloc_string(boot_device); 1735 malloc_string(tmp); 1736 malloc_string(editor); 1737 assert_string_is_neither_NULL_nor_zerolength(bd); 1738 1739 strcpy(editor, find_my_editor()); 1696 mr_asprintf(&editor, find_my_editor()); 1740 1697 strcpy(boot_device, bd); 1741 sprintf(command, "raw-MR %s /tmp/mountlist.txt", boot_device);1742 mr_msg(2, "run_raw_mbr() --- command='%s'", command);1743 1744 1698 if (offer_to_hack_scripts 1745 && ask_me_yes_or_no( "Did you change the mountlist?"))1699 && ask_me_yes_or_no(_("Did you change the mountlist?"))) { 1746 1700 /* interactive mode */ 1747 {1748 1701 mvaddstr_and_log_it(g_currentY, 0, 1749 "Modifying fstab and restoring MBR... "); 1702 _ 1703 ("Modifying fstab and restoring MBR... ")); 1750 1704 for (done = FALSE; !done;) { 1751 1705 if (!run_program_and_log_output("which vi", FALSE)) { 1752 popup_and_OK( "You will now edit fstab");1706 popup_and_OK(_("You will now edit fstab")); 1753 1707 if (!g_text_mode) { 1754 1708 newtSuspend(); 1755 1709 } 1756 sprintf(tmp, "%s " MNT_RESTORING "/etc/fstab", editor);1710 mr_asprintf(&tmp, "%s " MNT_RESTORING "/etc/fstab", editor); 1757 1711 paranoid_system(tmp); 1712 mr_free(tmp); 1713 1758 1714 if (!g_text_mode) { 1759 1715 newtResume(); 1760 1716 } 1761 // newtCls(); 1762 } 1763 popup_and_get_string("Boot device", 1764 "Please confirm/enter the boot device. If in doubt, try /dev/hda", 1765 boot_device, MAX_STR_LEN / 4); 1766 sprintf(command, "stabraw-me %s", boot_device); 1717 } 1718 popup_and_get_string(_("Boot device"), 1719 _("Please confirm/enter the boot device. If in doubt, try /dev/hda"), boot_device, MAX_STR_LEN / 4); 1720 mr_asprintf(&command, "stabraw-me %s", boot_device); 1767 1721 res = run_program_and_log_output(command, 3); 1722 mr_free(command); 1723 1768 1724 if (res) { 1769 done = ask_me_yes_or_no("Modifications failed. Re-try?"); 1725 done = 1726 ask_me_yes_or_no(_("Modifications failed. Re-try?")); 1770 1727 } else { 1771 1728 done = TRUE; 1772 1729 } 1773 1730 } 1774 } else 1731 } else { 1775 1732 /* nuke mode */ 1776 {1777 1733 mvaddstr_and_log_it(g_currentY, 0, 1778 "Restoring MBR... "); 1734 _("Restoring MBR... ")); 1735 mr_asprintf(&command, "raw-MR %s /tmp/mountlist.txt", boot_device); 1736 mr_msg(2, "run_raw_mbr() --- command='%s'", command); 1779 1737 res = run_program_and_log_output(command, 3); 1738 mr_free(command); 1780 1739 } 1781 1740 if (res) { 1782 mvaddstr_and_log_it(g_currentY++, 74, "Failed.");1741 mvaddstr_and_log_it(g_currentY++, 74, _("Failed.")); 1783 1742 log_to_screen 1784 ( "MBR+fstab processed w/error(s). See /tmp/mondo-restore.log for more info.");1785 } else {1786 mvaddstr_and_log_it(g_currentY++, 74, "Done.");1787 }1788 mr_free(command);1743 (_ 1744 ("MBR+fstab processed w/error(s). See /tmp/mondo-restore.log for more info.")); 1745 } else { 1746 mvaddstr_and_log_it(g_currentY++, 74, _("Done.")); 1747 } 1789 1748 mr_free(boot_device); 1790 mr_free(tmp);1791 1749 mr_free(editor); 1792 1750 return (res); 1793 1751 } 1794 1795 1752 /************************************************************************** 1796 1753 *END_RUN_RAW_MBR * … … 1798 1755 1799 1756 1800 1801 1802 1803 1757 /** 1804 1758 * Turn signal trapping on or off. … … 1810 1764 int signals[] = 1811 1765 { SIGKILL, SIGPIPE, SIGTERM, SIGHUP, SIGTRAP, SIGABRT, SIGINT, 1812 SIGSTOP, 0 }; 1766 SIGSTOP, 0 1767 }; 1813 1768 int i; 1814 1769 for (i = 0; signals[i]; i++) { … … 1853 1808 sprintf(g_filelist_full, "%s/%s", temppath, FILELIST_FULL_STUB); 1854 1809 sprintf(g_filelist_imagedevs, "%s/tmp/filelist.imagedevs", temppath); 1855 // sprintf(g_imagedevs_pot, "%s/tmp/imagedevs.pot", temppath);1856 1810 sprintf(g_imagedevs_restthese, "%s/tmp/imagedevs.restore-these", 1857 1811 temppath); … … 1881 1835 FILE *fin; 1882 1836 FILE *fout; 1883 /** malloc **/ 1884 char *incoming;1837 char *incoming = NULL; 1838 size_t n = 0; 1885 1839 1886 1840 assert_string_is_neither_NULL_nor_zerolength(output_file); 1887 1841 assert_string_is_neither_NULL_nor_zerolength(input_file); 1888 malloc_string(incoming);1889 1842 1890 1843 if (!(fin = fopen(input_file, "r"))) { … … 1895 1848 fatal_error("cannot open output_file"); 1896 1849 } 1897 for ( fgets(incoming, MAX_STR_LEN - 1, fin); !feof(fin);1898 fgets(incoming, MAX_STR_LEN - 1, fin)) {1850 for (mr_getline(&incoming, &n, fin); !feof(fin); 1851 mr_getline(&incoming, &n, fin)) { 1899 1852 if (strncmp(incoming, "etc/adjtime", 11) 1900 1853 && strncmp(incoming, "etc/mtab", 8) … … 1906 1859 fprintf(fout, "%s", incoming); /* don't need \n here, for some reason.. */ 1907 1860 } 1861 mr_free(incoming); 1908 1862 paranoid_fclose(fout); 1909 1863 paranoid_fclose(fin); 1910 mr_free(incoming); 1911 } 1912 1864 } 1913 1865 /************************************************************************** 1914 1866 *END_STREAMLINE_CHANGES_FILE * … … 1923 1875 { 1924 1876 log_to_screen 1925 ( "Mondorestore is terminating in response to a signal from the OS");1877 (_("Mondorestore is terminating in response to a signal from the OS")); 1926 1878 free_MR_global_filenames(); 1927 1879 finish(254); 1928 1880 } 1929 1930 1881 /************************************************************************** 1931 1882 *END_TERMINATE_DAEMON * … … 1939 1890 { 1940 1891 int i; 1941 /* MALLOC * */ 1942 char *tmp; 1943 1944 malloc_string(tmp); 1892 char *tmp = NULL; 1893 1945 1894 if (does_file_exist("/tmp/NOPAUSE")) { 1946 1895 return; 1947 1896 } 1948 open_progress_form("CAUTION", 1949 "Be advised: I am about to ERASE your hard disk(s)!", 1950 "You may press Ctrl+Alt+Del to abort safely.", 1897 open_progress_form(_("CAUTION"), 1898 _ 1899 ("Be advised: I am about to ERASE your hard disk(s)!"), 1900 _("You may press Ctrl+Alt+Del to abort safely."), 1951 1901 "", 20); 1952 1902 for (i = 0; i < 20; i++) { 1953 1903 g_current_progress = i; 1954 sprintf(tmp, "You have %d seconds left to abort.", 20 - i);1904 mr_asprintf(&tmp, _("You have %d seconds left to abort."), 20 - i); 1955 1905 update_progress_form(tmp); 1906 mr_free(tmp); 1956 1907 sleep(1); 1957 1908 } 1958 1909 close_progress_form(); 1959 mr_free(tmp); 1960 } 1961 1910 } 1962 1911 /************************************************************************** 1963 1912 *END_TWENTY_SECONDS_TIL_YIKES * … … 1965 1914 1966 1915 1967 1968 1969 1970 1916 /** 1971 1917 * Exit due to a signal (no cleanup). … … 1978 1924 pthread_exit(0); 1979 1925 } 1980 1981 1926 /************************************************************************** 1982 1927 *END_TERMINATION_IN_PROGRESS * … … 1984 1929 1985 1930 1986 1987 1931 /** 1988 1932 * Unmount all devices in @p p_external_copy_of_mountlist. … … 1994 1938 { 1995 1939 struct mountlist_itself *mountlist; 1996 int retval = 0, lino, res = 0, i; 1997 char *command; 1998 char *tmp; 1999 2000 malloc_string(command); 2001 malloc_string(tmp); 1940 int retval = 0; 1941 int lino = 0; 1942 int res = 0; 1943 int i = 0; 1944 char *command = NULL; 1945 char *tmp = NULL; 1946 2002 1947 assert(p_external_copy_of_mountlist != NULL); 2003 1948 … … 2008 1953 2009 1954 run_program_and_log_output("df -m", 3); 2010 mvaddstr_and_log_it(g_currentY, 0, "Unmounting devices "); 2011 open_progress_form("Unmounting devices", 2012 "Unmounting all devices that were mounted,", 2013 "in preparation for the post-restoration reboot.", 1955 mvaddstr_and_log_it(g_currentY, 0, _("Unmounting devices ")); 1956 open_progress_form(_("Unmounting devices"), 1957 _("Unmounting all devices that were mounted,"), 1958 _ 1959 ("in preparation for the post-restoration reboot."), 2014 1960 "", mountlist->entries); 2015 1961 chdir("/"); … … 2024 1970 } 2025 1971 2026 paranoid_system("sync");1972 sync(); 2027 1973 2028 1974 if (run_program_and_log_output … … 2044 1990 continue; 2045 1991 } 2046 sprintf(tmp, "Unmounting device %s ", mountlist->el[lino].device); 1992 mr_asprintf(&tmp, _("Unmounting device %s "), 1993 mountlist->el[lino].device); 2047 1994 2048 1995 update_progress_form(tmp); 1996 2049 1997 if (is_this_device_mounted(mountlist->el[lino].device)) { 2050 1998 if (!strcmp(mountlist->el[lino].mountpoint, "swap")) { 2051 sprintf(command, "swapoff %s", mountlist->el[lino].device);1999 mr_asprintf(&command, "swapoff %s", mountlist->el[lino].device); 2052 2000 } else { 2053 2001 if (!strcmp(mountlist->el[lino].mountpoint, "/1")) { 2054 sprintf(command, "umount %s/", MNT_RESTORING);2002 mr_asprintf(&command, "umount %s/", MNT_RESTORING); 2055 2003 mr_msg(3, 2056 2004 "Well, I know a certain kitty-kitty who'll be sleeping with Mommy tonight..."); 2057 2005 } else { 2058 sprintf(command, "umount " MNT_RESTORING "%s",2006 mr_asprintf(&command, "umount " MNT_RESTORING "%s", 2059 2007 mountlist->el[lino].mountpoint); 2060 2008 } … … 2062 2010 mr_msg(10, "The 'umount' command is '%s'", command); 2063 2011 res = run_program_and_log_output(command, 3); 2012 mr_free(command); 2064 2013 } else { 2065 strcat(tmp, "...not mounted anyway :-) OK");2014 mr_strcat(tmp, _("...not mounted anyway :-) OK")); 2066 2015 res = 0; 2067 2016 } 2068 2017 g_current_progress++; 2069 2018 if (res) { 2070 strcat(tmp, "...Failed");2019 mr_strcat(tmp, _("...Failed")); 2071 2020 retval++; 2072 2021 log_to_screen(tmp); … … 2074 2023 mr_msg(2, tmp); 2075 2024 } 2025 mr_free(tmp); 2076 2026 } 2077 2027 close_progress_form(); 2078 2028 if (retval) { 2079 mvaddstr_and_log_it(g_currentY++, 74, "Failed.");2080 } else { 2081 mvaddstr_and_log_it(g_currentY++, 74, "Done.");2029 mvaddstr_and_log_it(g_currentY++, 74, _("Failed.")); 2030 } else { 2031 mvaddstr_and_log_it(g_currentY++, 74, _("Done.")); 2082 2032 } 2083 2033 if (retval) { 2084 log_to_screen( "Unable to unmount some of your partitions.");2085 } else { 2086 log_to_screen( "All partitions were unmounted OK.");2034 log_to_screen(_("Unable to unmount some of your partitions.")); 2035 } else { 2036 log_to_screen(_("All partitions were unmounted OK.")); 2087 2037 } 2088 2038 mr_free(mountlist); 2089 mr_free(command);2090 mr_free(tmp);2091 2039 return (retval); 2092 2040 } 2093 2094 2041 /************************************************************************** 2095 2042 *END_UNMOUNT_ALL_DEVICES * 2096 2043 **************************************************************************/ 2097 2098 2044 2099 2045 … … 2106 2052 int extract_cfg_file_and_mountlist_from_tape_dev(char *dev) 2107 2053 { 2108 char *command ;2054 char *command = NULL; 2109 2055 int res = 0; 2110 // B CO: below 32KB seems to block at least on RHAS 2.1 and MDK 10.02056 // BERLIOS: below 32KB seems to block at least on RHAS 2.1 and MDK 10.0 2111 2057 long tape_block_size = 32768; 2112 2058 2113 malloc_string(command);2114 2115 2059 // tar -zxvf- 2116 sprintf(command,2060 mr_asprintf(&command, 2117 2061 "dd if=%s bs=%ld count=%ld 2> /dev/null | tar -zx %s %s %s %s %s", 2118 2062 dev, … … 2123 2067 mr_msg(2, "command = '%s'", command); 2124 2068 res = run_program_and_log_output(command, -1); 2069 mr_free(command); 2070 2125 2071 if (res != 0 && does_file_exist(MONDO_CFG_FILE_STUB)) { 2126 2072 res = 0; 2127 2073 } 2128 mr_free(command);2129 2074 return (res); 2130 2075 } 2131 2132 2076 2133 2077 … … 2143 2087 { 2144 2088 int retval = 0; 2145 2146 /** malloc *****/ 2147 char *device; 2148 char *command; 2149 char *cfg_file; 2150 char *mounted_cfgf_path; 2151 char *tmp; 2152 char *mountpt; 2153 char *ramdisk_fname; 2154 char *mountlist_file; 2155 int res; 2156 2157 bool try_plan_B; 2089 char *command = NULL; 2090 char *cfg_file = NULL; 2091 char *mounted_cfgf_path = NULL; 2092 char *tmp = NULL; 2093 char *mountpt = NULL; 2094 char *ramdisk_fname = NULL; 2095 char *mountlist_file = NULL; 2096 int res = 0; 2097 2098 bool try_plan_B = FALSE; 2158 2099 2159 2100 assert(bkpinfo != NULL); 2160 malloc_string(cfg_file);2161 malloc_string(mounted_cfgf_path);2162 malloc_string(mountpt);2163 malloc_string(ramdisk_fname);2164 malloc_string(mountlist_file);2165 malloc_string(device);2166 malloc_string(command);2167 malloc_string(tmp);2168 2101 mr_msg(2, "gcffa --- starting"); 2169 log_to_screen("I'm thinking..."); 2170 sprintf(mountpt, "%s/mount.bootdisk", bkpinfo->tmpdir); 2171 device[0] = '\0'; 2102 log_to_screen(_("I'm thinking...")); 2103 mr_asprintf(&mountpt, "%s/mount.bootdisk", bkpinfo->tmpdir); 2172 2104 chdir(bkpinfo->tmpdir); 2173 strcpy(cfg_file, MONDO_CFG_FILE_STUB); 2174 unlink(cfg_file); // cfg_file[] is missing the '/' at the start, FYI, by intent 2105 // MONDO_CFG_FILE_STUB is missing the '/' at the start, FYI, by intent 2106 unlink(MONDO_CFG_FILE_STUB); 2107 2175 2108 unlink(FILELIST_FULL_STUB); 2176 2109 unlink(BIGGIELIST_TXT_STUB); 2177 2110 unlink("tmp/i-want-my-lvm"); 2178 sprintf(command, "mkdir -p %s", mountpt);2111 mr_asprintf(&command, "mkdir -p %s", mountpt); 2179 2112 run_program_and_log_output(command, FALSE); 2180 2181 // unlink( "tmp/mondo-restore.cfg" ); // superfluous, surely? 2182 2183 sprintf(cfg_file, "%s/%s", bkpinfo->tmpdir, MONDO_CFG_FILE_STUB); 2184 sprintf(mountlist_file, "%s/%s", bkpinfo->tmpdir, 2113 mr_free(command); 2114 2115 mr_asprintf(&cfg_file, "%s/%s", bkpinfo->tmpdir, MONDO_CFG_FILE_STUB); 2116 mr_asprintf(&mountlist_file, "%s/%s", bkpinfo->tmpdir, 2185 2117 MOUNTLIST_FNAME_STUB); 2186 // make_hole_for_file( cfg_file );2187 // make_hole_for_file( mountlist_file);2188 2118 mr_msg(2, "mountpt = %s; cfg_file=%s", mountpt, cfg_file); 2189 2119 2190 2120 /* Floppy? */ 2191 sprintf(tmp, "mkdir -p %s", mountpt);2121 mr_asprintf(&tmp, "mkdir -p %s", mountpt); 2192 2122 run_program_and_log_output(tmp, FALSE); 2193 sprintf(tmp, "mkdir -p %s/tmp", bkpinfo->tmpdir); 2123 mr_free(tmp); 2124 2125 mr_asprintf(&tmp, "mkdir -p %s/tmp", bkpinfo->tmpdir); 2194 2126 run_program_and_log_output(tmp, FALSE); 2195 2196 sprintf(command, "mount /dev/fd0u1722 %s", mountpt); 2197 sprintf(tmp, 2127 mr_free(tmp); 2128 2129 mr_asprintf(&command, "mount /dev/fd0u1722 %s", mountpt); 2130 mr_asprintf(&tmp, 2198 2131 "(sleep 15; kill `ps | grep \"%s\" | cut -d' ' -f1` 2> /dev/null) &", 2199 2132 command); 2200 2133 mr_msg(1, "tmp = '%s'", tmp); 2201 2134 system(tmp); 2135 mr_free(tmp); 2136 2202 2137 res = run_program_and_log_output(command, FALSE); 2138 mr_free(command); 2139 2203 2140 if (res) { 2204 sprintf(command, "mount /dev/fd0H1440 %s", mountpt);2141 mr_asprintf(&command, "mount /dev/fd0H1440 %s", mountpt); 2205 2142 res = run_program_and_log_output(command, FALSE); 2143 mr_free(command); 2206 2144 } 2207 2145 if (res) { … … 2211 2149 mr_msg(2, 2212 2150 "Mounted floppy OK but I don't trust it because the archives might contain more up-to-date config file than the floppy does."); 2213 // NB: If busybox does not support 'mount -o loop' then Plan A WILL NOT WORK.2151 // NB: If busybox does not support 'mount -o loop' then Plan A WILL NOT WORK. 2214 2152 mr_msg(2, "Processing floppy (plan A?)"); 2215 sprintf(ramdisk_fname, "%s/mindi.rdz", mountpt);2153 mr_asprintf(&ramdisk_fname, "%s/mindi.rdz", mountpt); 2216 2154 if (!does_file_exist(ramdisk_fname)) { 2217 sprintf(ramdisk_fname, "%s/initrd.img", mountpt); 2155 mr_free(ramdisk_fname); 2156 mr_asprintf(&ramdisk_fname, "%s/initrd.img", mountpt); 2218 2157 } 2219 2158 if (!does_file_exist(ramdisk_fname)) { … … 2226 2165 "Warning - failed to extract config file from ramdisk. I think this boot disk is mangled."); 2227 2166 } 2228 sprintf(command, "umount %s", mountpt);2167 mr_asprintf(&command, "umount %s", mountpt); 2229 2168 run_program_and_log_output(command, 5); 2169 mr_free(command); 2170 2230 2171 unlink(ramdisk_fname); 2172 mr_free(ramdisk_fname); 2231 2173 } 2232 2174 if (!does_file_exist(cfg_file)) { … … 2255 2197 if (strlen(bkpinfo->media_device) == 0) { 2256 2198 strcpy(bkpinfo->media_device, "/dev/st0"); 2257 mr_msg(2, "media_device is blank; assuming %s"); 2258 } 2259 strcpy(tmp, bkpinfo->media_device); 2199 mr_msg(2, "media_device is blank; assuming %s", 2200 bkpinfo->media_device); 2201 } 2202 mr_asprintf(&tmp, bkpinfo->media_device); 2260 2203 if (extract_cfg_file_and_mountlist_from_tape_dev 2261 2204 (bkpinfo->media_device)) { … … 2276 2219 } 2277 2220 } 2221 mr_free(tmp); 2278 2222 2279 2223 if (!does_file_exist("tmp/mondo-restore.cfg")) { 2280 log_to_screen("Cannot find config info on tape/CD/floppy"); 2224 log_to_screen(_ 2225 ("Cannot find config info on tape/CD/floppy")); 2281 2226 return (1); 2282 2227 } … … 2284 2229 mr_msg(2, 2285 2230 "gcffa --- looking at mounted CD for mindi-boot.2880.img"); 2286 sprintf(command, 2231 /* BERLIOS : Useless ? 2232 mr_asprintf(&command, 2287 2233 "mount " MNT_CDROM 2288 2234 "/images/mindi-boot.2880.img -o loop %s", mountpt); 2289 sprintf(mounted_cfgf_path, "%s/%s", mountpt, cfg_file); 2235 */ 2236 mr_asprintf(&mounted_cfgf_path, "%s/%s", mountpt, cfg_file); 2290 2237 if (!does_file_exist(mounted_cfgf_path)) { 2291 2238 mr_msg(2, 2292 2239 "gcffa --- Plan C, a.k.a. untarring some file from all.tar.gz"); 2293 sprintf(command, "tar -zxvf " MNT_CDROM "/images/all.tar.gz %s %s %s %s %s", MOUNTLIST_FNAME_STUB, MONDO_CFG_FILE_STUB, BIGGIELIST_TXT_STUB, FILELIST_FULL_STUB, "tmp/i-want-my-lvm"); // add -b TAPE_BLOCK_SIZE if you _really_ think it's necessary2240 mr_asprintf(&command, "tar -zxvf " MNT_CDROM "/images/all.tar.gz %s %s %s %s %s", MOUNTLIST_FNAME_STUB, MONDO_CFG_FILE_STUB, BIGGIELIST_TXT_STUB, FILELIST_FULL_STUB, "tmp/i-want-my-lvm"); // add -b TAPE_BLOCK_SIZE if you _really_ think it's necessary 2294 2241 run_program_and_log_output(command, TRUE); 2242 mr_free(command); 2243 2295 2244 if (!does_file_exist(MONDO_CFG_FILE_STUB)) { 2296 2245 fatal_error … … 2298 2247 } 2299 2248 } 2300 } 2301 } 2249 mr_free(mounted_cfgf_path); 2250 } 2251 } 2252 mr_free(mountpt); 2253 2302 2254 if (does_file_exist(MONDO_CFG_FILE_STUB)) { 2303 2255 mr_msg(1, "gcffa --- great! We've got the config file"); 2304 sprintf(tmp, "%s/%s",2256 mr_asprintf(&tmp, "%s/%s", 2305 2257 call_program_and_get_last_line_of_output("pwd"), 2306 2258 MONDO_CFG_FILE_STUB); 2307 sprintf(command, "cp -f %s %s", tmp, cfg_file);2259 mr_asprintf(&command, "cp -f %s %s", tmp, cfg_file); 2308 2260 iamhere(command); 2261 2309 2262 if (strcmp(tmp, cfg_file) 2310 2263 && run_program_and_log_output(command, 1)) { … … 2315 2268 mr_msg(1, "... and I moved it successfully to %s", cfg_file); 2316 2269 } 2317 sprintf(command, "cp -f %s/%s %s", 2270 mr_free(command); 2271 2272 mr_asprintf(&command, "cp -f %s/%s %s", 2318 2273 call_program_and_get_last_line_of_output("pwd"), 2319 2274 MOUNTLIST_FNAME_STUB, mountlist_file); … … 2324 2279 } else { 2325 2280 mr_msg(1, "Got mountlist too"); 2326 sprintf(command, "cp -f %s %s", mountlist_file, 2281 mr_free(command); 2282 mr_asprintf(&command, "cp -f %s %s", mountlist_file, 2327 2283 g_mountlist_fname); 2328 2284 if (run_program_and_log_output(command, 1)) { … … 2330 2286 } else { 2331 2287 mr_msg(1, "Copied mountlist to /tmp as well OK"); 2332 sprintf(command, "cp -f tmp/i-want-my-lvm /tmp/"); 2288 mr_free(command); 2289 mr_asprintf(&command, "cp -f tmp/i-want-my-lvm /tmp/"); 2333 2290 run_program_and_log_output(command, 1); 2334 2291 } 2335 2292 } 2293 mr_free(command); 2294 mr_free(tmp); 2336 2295 } 2337 2296 run_program_and_log_output("umount " MNT_CDROM, FALSE); … … 2340 2299 mr_msg(1, "%s not found", cfg_file); 2341 2300 log_to_screen 2342 ("Oh dear. Unable to recover configuration file from boot disk"); 2301 (_ 2302 ("Oh dear. Unable to recover configuration file from boot disk")); 2343 2303 return (1); 2344 2304 } 2345 2305 2346 log_to_screen( "Recovered mondo-restore.cfg");2306 log_to_screen(_("Recovered mondo-restore.cfg")); 2347 2307 if (!does_file_exist(MOUNTLIST_FNAME_STUB)) { 2348 log_to_screen( "...but not mountlist.txt - a pity, really...");2308 log_to_screen(_("...but not mountlist.txt - a pity, really...")); 2349 2309 } 2350 2310 /* start SAH */ 2351 2311 else { 2352 sprintf(command, "cp -f %s %s/%s", MOUNTLIST_FNAME_STUB,2312 mr_asprintf(&command, "cp -f %s %s/%s", MOUNTLIST_FNAME_STUB, 2353 2313 bkpinfo->tmpdir, MOUNTLIST_FNAME_STUB); 2354 2314 run_program_and_log_output(command, FALSE); 2355 } 2356 /*--commented out by SAH 2357 sprintf( command, "cp -f %s %s/%s", cfg_file, bkpinfo->tmpdir, MONDO_CFG_FILE_STUB ); 2358 run_program_and_log_output( command, FALSE ); 2359 sprintf( command, "cp -f %s %s/%s", mountlist_file, bkpinfo->tmpdir, MOUNTLIST_FNAME_STUB ); 2360 run_program_and_log_output( command, FALSE ); 2361 */ 2315 mr_free(command); 2316 } 2362 2317 /* end SAH */ 2363 2318 2364 sprintf(command, "cp -f %s /%s", cfg_file, MONDO_CFG_FILE_STUB); 2319 mr_asprintf(&command, "cp -f %s /%s", cfg_file, MONDO_CFG_FILE_STUB); 2320 mr_free(cfg_file); 2365 2321 run_program_and_log_output(command, FALSE); 2366 sprintf(command, "cp -f %s /%s", mountlist_file, MOUNTLIST_FNAME_STUB); 2322 mr_free(command); 2323 2324 mr_asprintf(&command, "cp -f %s /%s", mountlist_file, MOUNTLIST_FNAME_STUB); 2325 mr_free(mountlist_file); 2367 2326 run_program_and_log_output(command, FALSE); 2368 sprintf(command, "cp -f etc/raidtab /etc/"); 2327 mr_free(command); 2328 2329 mr_asprintf(&command, "cp -f etc/raidtab /etc/"); 2369 2330 run_program_and_log_output(command, FALSE); 2370 sprintf(command, "cp -f tmp/i-want-my-lvm /tmp/"); 2331 mr_free(command); 2332 2333 mr_asprintf(&command, "cp -f tmp/i-want-my-lvm /tmp/"); 2371 2334 run_program_and_log_output(command, FALSE); 2335 mr_free(command); 2336 2372 2337 g_backup_media_type = bkpinfo->backup_media_type; 2373 mr_free(device); 2374 mr_free(command); 2375 mr_free(tmp); 2376 mr_free(cfg_file); 2377 mr_free(mounted_cfgf_path); 2378 mr_free(mountpt); 2379 mr_free(ramdisk_fname); 2380 mr_free(mountlist_file); 2338 bkpinfo->backup_media_string = bkptype_to_string(bkpinfo->backup_media_type); 2339 g_backup_media_string = bkpinfo->backup_media_string; 2381 2340 return (retval); 2382 2341 } 2383 2384 2342 /************************************************************************** 2385 2343 *END_GET_CFG_FILE_FROM_ARCHIVE * 2386 2344 **************************************************************************/ 2387 2388 2345 /* @} - end restoreUtilityGroup */ 2389 2390 2391 /***************************************************************************2392 * F@ *2393 * () -- Hugo Rabson *2394 * *2395 * Purpose: *2396 * *2397 * Called by: *2398 * Params: - - *2399 * Returns: 0=success; nonzero=failure *2400 ***************************************************************************/2401 2402 2346 2403 2347 … … 2405 2349 int wait_for_percentage) 2406 2350 { 2407 struct raidlist_itself *raidlist; 2408 int unfinished_mdstat_devices = 9999, i; 2409 char *screen_message; 2410 2411 malloc_string(screen_message); 2351 struct raidlist_itself *raidlist = NULL; 2352 int unfinished_mdstat_devices = 9999, i = 0; 2353 char *screen_message = NULL; 2354 2412 2355 raidlist = (struct raidlist_itself *)mr_malloc(sizeof(struct raidlist_itself)); 2413 2356 … … 2418 2361 if (parse_mdstat(raidlist, "/dev/")) { 2419 2362 log_to_screen("Sorry, cannot read %s", MDSTAT_FILE); 2420 mr_msg(1, "Sorry, cannot read %s", MDSTAT_FILE);2363 mr_msg(1, "Sorry, cannot read %s", MDSTAT_FILE); 2421 2364 return; 2422 2365 } … … 2429 2372 } 2430 2373 mr_msg(1,"Sync'ing %s (i=%d)", raidlist->el[i].raid_device, i); 2431 sprintf(screen_message, "Sync'ing %s",2374 mr_asprintf(&screen_message, "Sync'ing %s", 2432 2375 raidlist->el[i].raid_device); 2433 2376 open_evalcall_form(screen_message); 2377 mr_free(screen_message); 2378 2434 2379 while (raidlist->el[i].progress < wait_for_percentage) { 2435 2380 mr_msg(1,"Percentage sync'ed: %d", raidlist->el[i].progress); … … 2445 2390 } 2446 2391 } 2447 mr_free(screen_message);2448 2392 mr_free(raidlist); 2449 2393 }
Note:
See TracChangeset
for help on using the changeset viewer.