Changeset 2009 in MondoRescue for trunk/mondo/src/mondorestore/mondorestore.c
- Timestamp:
- Aug 11, 2008, 3:05:15 AM (16 years ago)
- File:
-
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
trunk/mondo/src/mondorestore/mondorestore.c
r1176 r2009 15 15 16 16 #include "my-stuff.h" 17 #include "../common/mondostructures.h" 18 #include "../common/libmondo.h" 17 #include "mr_mem.h" 18 #include "mr_msg.h" 19 #include "mr_str.h" 20 21 #include "mondostructures.h" 22 #include "libmondo.h" 19 23 #include "mr-externs.h" 20 24 #include "mondo-restore.h" … … 24 28 #include <pthread.h> 25 29 #endif 26 #include "mr_mem.h"27 30 28 31 extern void twenty_seconds_til_yikes(void); … … 41 44 **************************************************************************/ 42 45 extern char *g_tmpfs_mountpt; // declared in libmondo-tools.c 43 extern struct s_bkpinfo *g_bkpinfo_DONTUSETHIS; // used by finish() to free44 // up global bkpinfo struct45 46 extern bool g_text_mode; 46 47 extern FILE *g_fprep; … … 429 430 } 430 431 431 fmt_errs = 432 format_everything(mountlist, FALSE, raidlist); 432 fmt_errs = format_everything(mountlist, FALSE, raidlist); 433 433 if (!fmt_errs) { 434 434 log_to_screen … … 510 510 if (filelist) { 511 511 gotos_suck: 512 // (NB: %s is where your filesystem is mounted now, by default)", MNT_RESTORING); 512 // (NB: MNT_RESTORING is where your filesystem is mounted now, by default) 513 513 if (popup_and_get_string 514 514 (_("Restore path"), _("Restore files to where?"), bkpinfo->restore_path)) { … … 558 558 } 559 559 560 // run_program_and_log_output("cp -af /etc/lvm " MNT_RESTORING "/etc/", 1);561 560 protect_against_braindead_sysadmins(); 562 561 retval += unmount_all_devices(mountlist); … … 585 584 mvaddstr_and_log_it(g_currentY++, 74, _("Failed.")); 586 585 } else { 587 mvaddstr_and_log_it(g_currentY++, 74, "Done.");586 mvaddstr_and_log_it(g_currentY++, 74, _("Done.")); 588 587 } 589 588 retval += res; … … 597 596 ("Warning - errors occurred during the restore phase.")); 598 597 } 598 iamhere("Leaving interactive_mode()"); 599 599 return(retval); 600 600 } … … 619 619 struct raidlist_itself *raidlist, bool nuke_me_please) 620 620 { 621 char c ;621 char c = ' '; 622 622 int retval = 0; 623 623 … … 647 647 paranoid_system("umount " MNT_CDROM); 648 648 } 649 // if (! already_mounted)650 // {651 649 if (system("umount /tmp/isodir 2> /dev/null")) { 652 650 log_to_screen … … 654 652 ("WARNING - unable to unmount device where the ISO files are stored.")); 655 653 } 656 // }657 654 return (retval); 658 655 } … … 661 658 *END_ISO_MODE * 662 659 **************************************************************************/ 663 664 665 660 static void call_me_after_the_nuke(int retval) { 666 661 … … 670 665 if (retval) { 671 666 log_to_screen(_("Errors occurred during the nuke phase.")); 672 log_to_screen(_("Please visit our website at http://www.mondorescue.org for more information.")); 667 log_to_screen(_("Please visit our website at http://www.mondores 668 cue.org for more information.")); 673 669 } else { 674 670 #ifdef __FreeBSD__ 675 671 tmp1 = call_program_and_get_last_line_of_output("cat /tmp/cmdline"); 676 672 #else 677 673 tmp1 = call_program_and_get_last_line_of_output("cat /proc/cmdline"); 678 674 #endif 679 675 if ((strstr(tmp1,"restore") == NULL) || 680 (strstr(tmp1,"RESTORE") == NULL)) { 681 /* -H option */ 682 mr_asprintf(&tmp, 683 _ 684 (" Mondo has restored your system. Please remove the backup media and reboot.\n\nPlease visit our website at http://www.mondorescue.org for more information.")); 685 popup_and_OK(tmp); 686 mr_free(tmp); 676 (strstr(tmp1,"RESTORE") == NULL)) { 677 /* -H option */ 678 mr_asprintf(&tmp, 679 _ 680 (" Mondo has restored your system. Please remove the backup media and reboot.\n\nPlease visit our website at http://www. 681 mondorescue.org for more information.")); 682 popup_and_OK(tmp); 683 mr_free(tmp); 687 684 } 688 685 mr_free(tmp1); 689 686 690 687 log_to_screen(_ 691 688 ("Mondo has restored your system. Please remove the backup media and reboot.")); 692 689 log_to_screen(_ 693 690 ("Thank you for using Mondo Rescue.")); 694 691 log_to_screen(_ 695 692 ("Please visit our website at http://www.mondorescue.org for more information.")); 696 693 } 697 694 g_I_have_just_nuked = TRUE; … … 750 747 mr_free(tmp); 751 748 retval = interactive_mode(bkpinfo, mountlist, raidlist); 752 goto after_the_nuke; 749 call_me_after_the_nuke(retval); 750 return(retval); 753 751 } else { 754 752 mr_free(tmp); … … 812 810 retval = interactive_mode(bkpinfo, mountlist, raidlist); 813 811 call_me_after_the_nuke(retval); 812 return(retval); 814 813 } else 815 814 if (!ask_me_yes_or_no 816 815 (_("Would you like to try to proceed anyway?"))) { 817 }818 return(retval);816 return(retval); 817 } 819 818 } 820 819 retval = mount_all_devices(mountlist, TRUE); … … 834 833 } 835 834 protect_against_braindead_sysadmins(); 836 // run_program_and_log_output("cp -af /etc/lvm " MNT_RESTORING "/etc/", 1);837 835 retval += unmount_all_devices(mountlist); 838 836 mvaddstr_and_log_it(g_currentY, … … 855 853 retval += res; 856 854 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 */ 855 call_me_after_the_nuke(retval); 886 856 return (retval); 887 857 } 858 888 859 /************************************************************************** 889 860 *END_NUKE_MODE * … … 996 967 FILE *fout = NULL; 997 968 FILE *fbzip2 = NULL; 969 998 970 char *checksum = NULL; 999 1000 971 char *outfile_fname = NULL; 972 char *tmp = NULL; 1001 973 char *tmp0 = NULL; 1002 974 char *tmp1 = NULL; 1003 975 char *tmp2 = NULL; 1004 976 char *tmp3 = NULL; 1005 977 char *bzip2_command = NULL; 1006 978 char *bigblk = NULL; 1007 979 char *pathname_of_last_file_restored = NULL; 1008 980 int finished = FALSE; 1009 long sliceno ;981 long sliceno = 0L; 1010 982 long siz; 1011 983 long siz1; … … 1018 990 int res = 0; 1019 991 int old_loglevel; 1020 char *sz_msg ;992 char *sz_msg = NULL; 1021 993 struct s_node *node = NULL; 1022 994 … … 1046 1018 1047 1019 if (!checksum[0]) { 1048 mr_ asprintf(&tmp, "Warning - bigfile %ld does not have a checksum",1020 mr_msg(3, "Warning - bigfile %ld does not have a checksum", 1049 1021 bigfileno + 1); 1050 mr_msg(3, tmp);1051 mr_free(tmp);1052 /* BERLIOS : Useless ???1053 p = checksum;1054 */1055 1022 } 1056 1023 mr_free(checksum); … … 1090 1057 1091 1058 if (biggiestruct.use_ntfsprog) // if it's an NTFS device 1092 // if (!strncmp ( biggiestruct.filename, "/dev/", 5))1093 1059 { 1094 1060 g_loglevel = 4; … … 1112 1078 feed_outfrom_ntfsprog(biggiestruct.filename, 1113 1079 ntfsprog_fifo); 1114 // mr_msg(3, "CHILD - fip - exiting");1115 1080 exit(res); 1116 1081 break; … … 1120 1085 (long int) (pid)); 1121 1086 } 1122 // BERLIOS: Is it the right place ??1123 mr_free(ntfsprog_fifo);1124 1087 } else { 1125 1088 use_ntfsprog_hack = FALSE; … … 1131 1094 } 1132 1095 1133 mr_ asprintf(&tmp, "Reassembling big file %ld (%s)", bigfileno + 1,1096 mr_msg(2, "Reassembling big file %ld (%s)", bigfileno + 1, 1134 1097 outfile_fname); 1135 mr_msg(2, tmp);1136 mr_free(tmp);1137 1098 1138 1099 /* … … 1146 1107 mr_msg(3, "file_to_openout = %s", file_to_openout); 1147 1108 if (!(fout = fopen(file_to_openout, "w"))) { 1148 log_to_screen(_("Cannot openout outfile_fname- hard disk full?"));1109 log_to_screen(_("Cannot openout file_to_openout - hard disk full?")); 1149 1110 return (pathname_of_last_file_restored); 1150 1111 } 1112 mr_free(ntfsprog_fifo); 1151 1113 mr_msg(3, "Opened out to %s", outfile_fname); // CD/DVD --> mondorestore --> ntfsclone --> hard disk itself 1152 1114 … … 1164 1126 g_current_media_number); 1165 1127 g_current_media_number++; 1166 mr_asprintf(&tmp3, 1167 "Asking for %s #%d so that I may read slice #%ld\n", 1168 bkpinfo->backup_media_string, 1128 mr_msg(2, "Asking for %s #%d so that I may read slice #%ld\n", 1129 media_descriptor_string(bkpinfo->backup_media_type), 1169 1130 g_current_media_number, sliceno); 1170 mr_msg(2, tmp3); 1171 mr_free(tmp3); 1172 1173 mr_asprintf(&tmp3, _("Restoring from %s #%d"), 1131 log_to_screen(_("Restoring from %s #%d"), 1174 1132 bkpinfo->backup_media_string, 1175 1133 g_current_media_number); 1176 log_to_screen(tmp3);1177 mr_free(tmp3);1178 1179 1134 insist_on_this_cd_number(bkpinfo, g_current_media_number); 1180 1135 log_to_screen(_("Continuing to restore.")); … … 1194 1149 mr_asprintf(&bzip2_command, "bzip2 -dc %s 2>> %s",tmp2, MONDO_LOGFILE); 1195 1150 } else if (does_file_exist(tmp)) { 1196 mr_asprintf(&bzip2_command, " %s", "");1151 mr_asprintf(&bzip2_command, ""); 1197 1152 } else { 1198 1153 log_to_screen(_("OK, that's pretty fsck0red...")); … … 1204 1159 mr_asprintf(&bzip2_command, "cat %s 2>> %s", tmp, MONDO_LOGFILE); 1205 1160 } 1206 mr_asprintf(&tmp3, "Working on %s #%d, file #%ld, slice #%ld 1161 mr_asprintf(&tmp3, "Working on %s #%d, file #%ld, slice #%ld", 1207 1162 bkpinfo->backup_media_string, 1208 1163 g_current_media_number, bigfileno + 1, sliceno); … … 1216 1171 1217 1172 if (!(fbzip2 = popen(bzip2_command, "r"))) { 1173 mr_free(bzip2_command); 1218 1174 fatal_error("Can't run popen command"); 1219 1175 } … … 1224 1180 if (siz > 0) { 1225 1181 siz1 = fwrite(bigblk, 1, siz, fout); 1226 mr_asprintf(&sz_msg, "Read %ld from fbzip2; written %ld to fout", siz, siz1);1227 log_it(sz_msg);1228 mr_free(sz_msg);1229 1182 } 1230 1183 } 1231 1184 paranoid_pclose(fbzip2); 1232 1233 1185 1234 1186 sliceno++; … … 1288 1240 int use_ntfsprog) 1289 1241 { 1290 FILE *pout ;1291 FILE *fin ;1242 FILE *pout = NULL; 1243 FILE *fin = NULL; 1292 1244 1293 1245 /** mallocs ********/ … … 1300 1252 char *pathname_of_last_file_restored = NULL; 1301 1253 1302 struct s_node *node ;1303 1304 int old_loglevel ;1254 struct s_node *node = NULL; 1255 1256 int old_loglevel = 0; 1305 1257 long current_slice_number = 0; 1306 1258 int retval = 0; 1307 1259 int res = 0; 1308 1260 int ctrl_chr = '\0'; 1309 long long slice_siz ;1261 long long slice_siz = 0L; 1310 1262 bool dummy_restore = FALSE; 1311 1263 bool use_ntfsprog_hack = FALSE; 1312 1264 pid_t pid; 1313 1265 struct s_filename_and_lstat_info biggiestruct; 1314 struct utimbuf the_utime_buf, *ubuf ;1266 struct utimbuf the_utime_buf, *ubuf = NULL; 1315 1267 ubuf = &the_utime_buf; 1316 1268 … … 1380 1332 outfile_fname, ntfsprog_fifo); 1381 1333 res = feed_outfrom_ntfsprog(outfile_fname, ntfsprog_fifo); 1382 // mr_msg(3, "CHILD - fip - exiting");1383 1334 exit(res); 1384 1335 break; … … 1388 1339 (long int) (pid)); 1389 1340 } 1390 mr_free(ntfsprog_fifo);1391 1341 } else { 1392 1342 if (!strncmp(orig_bf_fname, "/dev/", 5)) // non-NTFS partition … … 1404 1354 make_hole_for_file(outfile_fname); 1405 1355 } 1406 mr_ asprintf(&tmp1, "Reassembling big file %ld (%s)",1356 mr_msg(2, "Reassembling big file %ld (%s)", 1407 1357 biggiefile_number + 1, orig_bf_fname); 1408 mr_msg(2, tmp1);1409 mr_free(tmp1);1410 1358 } 1411 1359 … … 1421 1369 file_to_openout, MONDO_LOGFILE); 1422 1370 } 1423 mr_ asprintf(&tmp1, "Pipe command = '%s'", command);1424 mr_ msg(3, tmp1);1425 mr_free( tmp1);1371 mr_msg(3, "Pipe command = '%s'", command); 1372 mr_free(outfile_fname); 1373 mr_free(ntfsprog_fifo); 1426 1374 1427 1375 /* restore biggiefile, one slice at a time */ … … 1445 1393 newtRefresh(); 1446 1394 } 1447 strip_spaces(tmp1);1395 mr_strip_spaces(tmp1); 1448 1396 update_progress_form(tmp1); 1449 1397 mr_free(tmp1); … … 1506 1454 } 1507 1455 1508 mr_free(outfile_fname);1509 1456 g_loglevel = old_loglevel; 1510 1457 return (pathname_of_last_file_restored); … … 1533 1480 { 1534 1481 int retval = 0; 1535 int res ;1536 char *p ;1482 int res = 0; 1483 char *p = NULL; 1537 1484 1538 1485 /** malloc **/ 1539 char *command ;1486 char *command = NULL; 1540 1487 char *tmp = NULL; 1541 char *filelist_name ;1488 char *filelist_name = NULL; 1542 1489 char *filelist_subset_fname = NULL; 1543 1490 char *executable = NULL; 1544 1491 char *temp_log = NULL; 1545 1492 long matches = 0; 1546 bool use_star ;1493 bool use_star = FALSE; 1547 1494 char *xattr_fname = NULL; 1548 1495 char *acl_fname = NULL; … … 1567 1514 retval = 0; 1568 1515 mr_msg(5, "Leaving"); 1516 mr_free(filelist_name); 1569 1517 return (retval); 1570 1518 } … … 1573 1521 mr_msg(3, "length_of_file(%s) = %llu", tarball_fname, 1574 1522 length_of_file(tarball_fname)); 1575 mr_asprintf(&tmp, "Unable to restore fileset #%ld (CD I/O error)",1523 log_to_screen(_("Unable to restore fileset #%ld (CD I/O error)"), 1576 1524 current_tarball_number); 1577 log_to_screen(tmp);1578 mr_free(tmp);1579 1525 retval = 1; 1580 1526 mr_msg(5, "Leaving"); 1527 mr_free(filelist_name); 1581 1528 return (retval); 1582 1529 } … … 1590 1537 use_star)) 1591 1538 <= 0) { 1592 mr_asprintf(&tmp, "Skipping fileset %ld", current_tarball_number); 1593 mr_msg(1, tmp); 1594 mr_free(tmp); 1539 mr_msg(1, "Skipping fileset %ld", current_tarball_number); 1595 1540 } else { 1596 1541 mr_msg(3, "Saved fileset %ld's subset to %s", 1597 1542 current_tarball_number, filelist_subset_fname); 1598 1543 } 1599 mr_asprintf(&tmp,"Tarball #%ld --- %ld matches",1544 log_to_screen("Tarball #%ld --- %ld matches", 1600 1545 current_tarball_number, matches); 1601 log_to_screen(tmp);1602 mr_free(tmp);1603 } else {1604 filelist_subset_fname = NULL;1605 1546 } 1606 1547 mr_free(filelist_name); … … 1616 1557 } 1617 1558 if (strstr(tarball_fname, ".bz2")) { 1618 mr_asprintf(&executable, " bzip2");1559 mr_asprintf(&executable, "-P bzip2 -Z"); 1619 1560 } else if (strstr(tarball_fname, ".gz")) { 1620 strcpy(executable, "gzip"); 1621 } else if (strstr(tarball_fname, ".gz")) { 1622 strcpy(executable, "gzip"); 1561 mr_asprintf(&executable, "-P gzip -Z"); 1623 1562 } else if (strstr(tarball_fname, ".lzo")) { 1624 mr_asprintf(&executable, "lzop"); 1625 } else { 1626 executable = NULL; 1563 mr_asprintf(&executable, "-P lzop -Z"); 1627 1564 } 1628 1565 … … 1633 1570 (_ 1634 1571 ("(compare_a_tarball) Compression program not found - oh no!")); 1572 mr_free(tmp); 1573 mr_free(executable); 1574 mr_free(acl_fname); 1575 mr_free(xattr_fname); 1576 mr_free(filelist_subset_fname); 1635 1577 paranoid_MR_finish(1); 1636 1578 } 1637 mr_free(tmp);1638 1639 mr_asprintf(&tmp, executable);1640 mr_asprintf(&executable, "-P %s -Z", tmp);1641 1579 mr_free(tmp); 1642 1580 } … … 1647 1585 #endif 1648 1586 1649 mr_asprintf(&temp_log, "/tmp/%d.%d", (int) (random() % 32768),1650 (int) (random() % 32768));1651 1652 1587 if (use_star) { 1588 mr_sprintf(&command, 1589 "star -x -force-remove -U " STAR_ACL_SZ 1590 " errctl= file=%s", tarball_fname); 1653 1591 if (strstr(tarball_fname, ".bz2")) { 1654 mr_asprintf(&tmp, " -bz"); 1655 } else { 1656 mr_asprintf(&tmp, "%s", ""); 1657 } 1658 mr_asprintf(&command, 1659 "star -x -force-remove -U " STAR_ACL_SZ 1660 " errctl= file=%s %s 2>> %s >> %s", tarball_fname, tmp, temp_log, temp_log); 1661 mr_free(tmp); 1592 mr_strcat(command, " -bz"); 1593 } 1662 1594 } else { 1663 1595 if (filelist_subset_fname != NULL) { 1664 1596 mr_asprintf(&command, 1665 "afio -i -M 8m -b %ld -c %ld %s -w '%s' %s 2>> %s >> %s",1597 "afio -i -M 8m -b %ld -c %ld %s -w '%s' %s", 1666 1598 TAPE_BLOCK_SIZE, 1667 1599 BUFSIZE, executable, filelist_subset_fname, 1668 // files_to_restore_this_time_fname, 1669 tarball_fname, temp_log, temp_log); 1600 tarball_fname); 1670 1601 } else { 1671 1602 mr_asprintf(&command, 1672 "afio -i -b %ld -c %ld -M 8m %s %s 2>> %s >> %s",1603 "afio -i -b %ld -c %ld -M 8m %s %s", 1673 1604 TAPE_BLOCK_SIZE, 1674 BUFSIZE, executable, tarball_fname , temp_log, temp_log);1605 BUFSIZE, executable, tarball_fname); 1675 1606 } 1676 1607 } … … 1678 1609 1679 1610 #undef BUFSIZE 1611 mr_asprintf(&temp_log, "/tmp/%d.%d", (int) (random() % 32768), 1612 (int) (random() % 32768)); 1613 1614 mr_strcat(command, " 2>> %s >> %s", temp_log, temp_log); 1680 1615 mr_msg(1, "command = '%s'", command); 1681 1616 unlink(temp_log); … … 1732 1667 unlink(xattr_fname); 1733 1668 mr_free(xattr_fname); 1669 unlink(acl_fname); 1670 mr_free(acl_fname); 1671 unlink(temp_log); 1672 mr_free(temp_log); 1734 1673 } 1735 1674 if (does_file_exist("/PAUSE")) { … … 1739 1678 } 1740 1679 unlink(filelist_subset_fname); 1741 unlink(acl_fname);1742 unlink(temp_log);1743 1744 1680 mr_free(filelist_subset_fname); 1745 mr_free(acl_fname);1746 mr_free(temp_log);1747 1681 mr_msg(5, "Leaving"); 1748 1682 return (retval); … … 1789 1723 long matches = 0; 1790 1724 bool restore_this_fileset = FALSE; 1791 bool use_star ;1725 bool use_star = FALSE; 1792 1726 1793 1727 assert(bkpinfo != NULL); … … 1795 1729 /* to do it with a file... */ 1796 1730 use_star = (strstr(tarball_fname, ".star")) ? TRUE : FALSE; 1797 mr_asprintf(&tmp, 1798 "Restoring from fileset #%ld (%ld KB) on %s #%d", 1731 mr_msg(2, "Restoring from fileset #%ld (%ld KB) on %s #%d", 1799 1732 current_tarball_number, (long) size >> 10, 1800 1733 bkpinfo->backup_media_string, 1801 1734 g_current_media_number); 1802 mr_msg(2, tmp);1803 mr_free(tmp);1804 1735 run_program_and_log_output("mkdir -p " MNT_RESTORING "/tmp", FALSE); 1805 1736 … … 1837 1768 if (strstr(tarball_fname, ".star.")) { 1838 1769 use_star = TRUE; 1839 mr_asprintf(&command, "star -t file=%s %s > %s 2>> %s", afio_fname, executable, filelist_fname, MONDO_LOGFILE);1770 mr_asprintf(&command, "star -t file=%s %s", afio_fname, executable); 1840 1771 } else { 1841 1772 use_star = FALSE; 1842 mr_asprintf(&command, "afio -t -M 8m -b %ld %s %s > %s 2>> %s", TAPE_BLOCK_SIZE, 1843 executable, afio_fname, filelist_fname, MONDO_LOGFILE); 1844 } 1773 mr_asprintf(&command, "afio -t -M 8m -b %ld %s %s", TAPE_BLOCK_SIZE, 1774 executable, afio_fname); 1775 } 1776 mr_strcat(command, " > %s 2>> %s", filelist_fname, MONDO_LOGFILE); 1845 1777 mr_msg(1, "command = %s", command); 1846 1778 if (system(command)) { … … 1848 1780 } 1849 1781 mr_free(command); 1782 1850 1783 if ((matches = 1851 1784 save_filelist_entries_in_common(filelist_fname, filelist, … … 1857 1790 current_tarball_number); 1858 1791 } 1859 mr_asprintf(&tmp, "Skipping fileset %ld", current_tarball_number); 1860 mr_msg(2, tmp); 1861 mr_free(tmp); 1792 mr_msg(2, "Skipping fileset %ld", current_tarball_number); 1862 1793 restore_this_fileset = FALSE; 1863 1794 } else { … … 1875 1806 // star 1876 1807 if (filelist) { 1877 mr_asprintf(&command, "star -x file=%s %s list=%s 2>> %s", afio_fname, executable, 1878 filelist_subset_fname,MONDO_LOGFILE); 1808 mr_asprintf(&command, "star -x file=%s %s list=%s 2>> %s", afio_fname, executable, filelist_subset_fname, MONDO_LOGFILE); 1879 1809 } else { 1880 mr_asprintf(&command, "star -x file=%s %s 2>> %s", afio_fname, executable,MONDO_LOGFILE);1810 mr_asprintf(&command, "star -x file=%s %s 2>> %s", afio_fname, executable, MONDO_LOGFILE); 1881 1811 } 1882 1812 } else { 1883 1813 // afio 1884 1814 if (filelist) { 1885 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);1815 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); 1886 1816 } else { 1887 mr_asprintf(&command, "afio -i -M 8m -b %ld %s %s 2>> %s", TAPE_BLOCK_SIZE, executable, afio_fname,MONDO_LOGFILE);1817 mr_asprintf(&command, "afio -i -M 8m -b %ld %s %s 2>> %s", TAPE_BLOCK_SIZE, executable, afio_fname, MONDO_LOGFILE); 1888 1818 } 1889 1819 } … … 1992 1922 return (0); 1993 1923 } 1994 mr_asprintf(&tmp, "OK, there are %ld biggiefiles in the archives", 1995 noof_biggiefiles); 1996 mr_msg(2, tmp); 1997 mr_free(tmp); 1924 mr_msg(2, "OK, there are %ld biggiefiles in the archives", noof_biggiefiles); 1998 1925 1999 1926 open_progress_form(_("Reassembling large files"), … … 2023 1950 insist_on_this_cd_number(bkpinfo, 2024 1951 ++g_current_media_number); 2025 mr_asprintf(&tmp,_("Restoring from %s #%d"),1952 log_to_screen(_("Restoring from %s #%d"), 2026 1953 bkpinfo->backup_media_string, 2027 1954 g_current_media_number); 2028 log_to_screen(tmp);2029 mr_free(tmp);2030 2031 1955 just_changed_cds = TRUE; 2032 1956 } else { … … 2051 1975 retval += res; 2052 1976 bigfileno++; 2053 2054 } 2055 mr_free(tmp); 1977 } 2056 1978 } 2057 1979 … … 2088 2010 return (retval); 2089 2011 } 2012 2090 2013 /************************************************************************** 2091 2014 *END_RESTORE_ALL_BIGGIFILES_FROM_CD * … … 2108 2031 { 2109 2032 int retval = 0; 2110 int res ;2111 int attempts ;2033 int res = 0; 2034 int attempts = 0; 2112 2035 long current_tarball_number = 0; 2113 long max_val ;2036 long max_val = 0L; 2114 2037 /**malloc ***/ 2115 char *tmp ;2116 char *tmp1 ;2117 char *tarball_fname ;2118 char *progress_str ;2119 char *comment ;2038 char *tmp = NULL; 2039 char *tmp1 = NULL; 2040 char *tarball_fname = NULL; 2041 char *progress_str = NULL; 2042 char *comment = NULL; 2120 2043 2121 2044 assert(bkpinfo != NULL); … … 2144 2067 insist_on_this_cd_number(bkpinfo, g_current_media_number); 2145 2068 update_progress_form(progress_str); 2146 2147 2069 mr_asprintf(&tarball_fname, MNT_CDROM "/archives/%ld.afio.bz2", 2148 2070 current_tarball_number); … … 2178 2100 (_ 2179 2101 ("No tarballs. Strange. Maybe you only backed up freakin' big files?")); 2102 mr_free(progress_str); 2180 2103 return (0); 2181 2104 } … … 2184 2107 "/archives/slice* > /dev/null 2> /dev/null") == 2185 2108 0) { 2109 mr_free(tarball_fname); 2110 mr_free(progress_str); 2186 2111 break; 2187 2112 } 2188 2113 g_current_media_number++; 2189 2114 mr_free(progress_str); 2115 2190 2116 mr_asprintf(&progress_str, _("Restoring from %s #%d"), 2191 2117 bkpinfo->backup_media_string, … … 2199 2125 bkpinfo->backup_media_string, 2200 2126 g_current_media_number); 2201 // mr_msg(3, "progress_str = %s", progress_str);2202 2127 for (res = 999, attempts = 0; attempts < 3 && res != 0; 2203 2128 attempts++) { … … 2207 2132 filelist); 2208 2133 } 2134 mr_asprintf(&tmp, _("%s #%d, fileset #%ld - restore "), 2135 media_descriptor_string(bkpinfo->backup_media_type), 2136 g_current_media_number, current_tarball_number); 2209 2137 if (res) { 2210 mr_ asprintf(&tmp1, _("reported errors"));2138 mr_strcat(tmp, _("reported errors")); 2211 2139 } else { 2212 mr_asprintf(&tmp1, _("succeeded")); 2213 } 2214 mr_asprintf(&tmp, _("%s #%d, fileset #%ld - restore %s"), 2215 bkpinfo->backup_media_string, 2216 g_current_media_number, current_tarball_number,tmp1); 2217 mr_free(tmp1); 2218 2140 mr_strcat(tmp, _("succeeded")); 2141 } 2219 2142 if (attempts > 1) { 2220 mr_asprintf(&tmp1, _(" (%d attempts) - review logs"), attempts); 2221 } 2222 mr_asprintf(&comment, "%s%s", tmp, tmp1); 2143 mr_strcat(tmp, _(" (%d attempts) - review logs"), attempts); 2144 } 2145 if (attempts > 1) { 2146 log_to_screen(tmp); 2147 } 2223 2148 mr_free(tmp); 2224 mr_free(tmp1);2225 if (attempts > 1) {2226 log_to_screen(comment);2227 }2228 mr_free(comment);2229 2149 2230 2150 retval += res; … … 2242 2162 mvaddstr_and_log_it(g_currentY++, 74, _("Done.")); 2243 2163 } 2244 2245 2164 return (retval); 2246 2165 } … … 2262 2181 struct s_node *filelist) 2263 2182 { 2264 long noof_biggiefiles ;2265 long current_bigfile_number = 0 ;2266 long total_slices ;2183 long noof_biggiefiles = 0L; 2184 long current_bigfile_number = 0L; 2185 long total_slices = 0L; 2267 2186 2268 2187 int retval = 0; 2269 2188 int res = 0; 2270 int ctrl_chr ;2189 int ctrl_chr = 0; 2271 2190 2272 2191 /** malloc add ****/ … … 2302 2221 biggies_whose_EXATs_we_should_set); 2303 2222 } 2304 // get xattr and acl files if they're there2223 // get xattr and acl files if they're there 2305 2224 res = 2306 2225 read_header_block_from_stream(&biggie_size, biggie_fname, … … 2313 2232 2314 2233 noof_biggiefiles = atol(biggie_fname); 2315 mr_ asprintf(&tmp, "OK, there are %ld biggiefiles in the archives",2234 mr_msg(2, "OK, there are %ld biggiefiles in the archives", 2316 2235 noof_biggiefiles); 2317 mr_msg(2, tmp);2318 mr_free(tmp);2319 2320 2236 open_progress_form(_("Reassembling large files"), 2321 2237 _("I am now reassembling all the large files."), … … 2363 2279 if (current_bigfile_number != noof_biggiefiles 2364 2280 && noof_biggiefiles != 0) { 2365 mr_ asprintf(&tmp, "Warning - bigfileno=%ld but noof_biggiefiles=%ld\n",2281 mr_msg(1, "Warning - bigfileno=%ld but noof_biggiefiles=%ld\n", 2366 2282 current_bigfile_number, noof_biggiefiles); 2367 2283 } else { 2368 mr_asprintf(&tmp, 2369 "%ld biggiefiles in biggielist.txt; %ld biggiefiles processed today.", 2284 mr_msg(1, "%ld biggiefiles in biggielist.txt; %ld biggiefiles processed today.", 2370 2285 noof_biggiefiles, current_bigfile_number); 2371 2286 } 2372 mr_msg(1, tmp);2373 mr_free(tmp);2374 2287 2375 2288 if (fbw) { … … 2437 2350 { 2438 2351 int retval = 0; 2439 int res ;2352 int res = 0; 2440 2353 long current_afioball_number = 0; 2441 int ctrl_chr ;2442 long max_val /*, total_noof_files */ ;2354 int ctrl_chr = 0; 2355 long max_val = 0L /*, total_noof_files */ ; 2443 2356 2444 2357 /** malloc **/ … … 2449 2362 char *acl_fname = NULL; 2450 2363 2451 long long tmp_size ;2364 long long tmp_size = 0L; 2452 2365 2453 2366 assert(bkpinfo != NULL); … … 2515 2428 retval += res; 2516 2429 if (res) { 2517 mr_asprintf(&tmp, _("Fileset %ld - errors occurred"),2430 log_to_screen("Fileset %ld - errors occurred", 2518 2431 current_afioball_number); 2519 log_to_screen(tmp);2520 mr_free(tmp);2521 2432 } 2522 2433 res = … … 2609 2520 mr_free(tmp); 2610 2521 2611 mvaddstr_and_log_it(g_currentY, 0, 2612 _("Preparing to read your archives")); 2522 mvaddstr_and_log_it(g_currentY, 0, _("Preparing to read your archives")); 2613 2523 if (IS_THIS_A_STREAMING_BACKUP(bkpinfo->backup_media_type)) { 2614 2524 mount_cdrom(bkpinfo); … … 2785 2695 void welcome_to_mondorestore() 2786 2696 { 2787 mr_msg(0, "-------------- Mondo Restore v%s -------------", 2788 PACKAGE_VERSION); 2697 mr_msg(0, "-------------- Mondo Restore v%s -------------", PACKAGE_VERSION); 2789 2698 mr_msg(0, 2790 2699 "DON'T PANIC! Mondorestore logs almost everything, so please "); … … 2837 2746 bool run_postnuke = FALSE; 2838 2747 2839 /**************************************************************************2840 * hugo- *2841 * busy stuff here - it needs some comments -stan *2842 * *2843 **************************************************************************/2844 2845 2748 #ifdef ENABLE_NLS 2846 2749 setlocale(LC_ALL, ""); … … 2869 2772 mr_free(tmp); 2870 2773 2871 bkpinfo = g_bkpinfo_DONTUSETHIS =mr_malloc(sizeof(struct s_bkpinfo));2774 bkpinfo = mr_malloc(sizeof(struct s_bkpinfo)); 2872 2775 mountlist = mr_malloc(sizeof(struct mountlist_itself)); 2873 2776 raidlist = mr_malloc(sizeof(struct raidlist_itself)); … … 2927 2830 run_program_and_log_output("rm -Rf /tmp/tmpfs/mondo.tmp.*", FALSE); 2928 2831 2929 /* Init GUI */2832 /* Init GUI */ 2930 2833 malloc_libmondo_global_strings(); 2931 2834 setup_newt_stuff(); /* call newtInit and setup screen log */ … … 2939 2842 iamhere("what time is it"); 2940 2843 2941 /* Process command-line parameters */2844 /* Process command-line parameters */ 2942 2845 if (argc == 2 && strcmp(argv[1], "--edit-mountlist") == 0) { 2943 2846 #ifdef __FreeBSD__ … … 2998 2901 // BERLIOS: /usr/lib ??? 2999 2902 toggle_path_selection(filelist, "/usr/share", TRUE); 3000 // show_filelist(filelist);3001 2903 save_filelist(filelist, "/tmp/out.txt"); 3002 // finish(0);3003 // toggle_path_selection (filelist, "/root/stuff", TRUE);3004 2904 mr_asprintf(&a, argv[3]); 3005 2905 mr_asprintf(&b, argv[4]); … … 3073 2973 ("Live mode doesn't support command-line parameters yet.")); 3074 2974 paranoid_MR_finish(1); 3075 // return(1);3076 2975 } 3077 2976 mr_msg(1, "I am in normal, live mode."); … … 3225 3124 if (!bkpinfo->please_dont_eject) { 3226 3125 res = eject_device("/dev/cdrom"); 3227 /*3228 if (res)3229 {3230 log_to_screen( "WARNING - failed to eject CD-ROM disk" );3231 }3232 */3233 3126 } 3234 3127 mvaddstr_and_log_it(g_currentY++, … … 3239 3132 } 3240 3133 3241 // g_I_have_just_nuked is set true by nuke_mode() just before it returns3134 // g_I_have_just_nuked is set true by nuke_mode() just before it returns 3242 3135 if (!system("which post-nuke > /dev/null 2> /dev/null")) { 3243 3136 mr_msg(1, "post-nuke found; find out whether we should run it..."); … … 3262 3155 } else { 3263 3156 mr_msg(1, "Re-mounted partitions for post-nuke stuff"); 3264 sprintf(tmp, "post-nuke %s %d", bkpinfo->restore_path,3157 mr_asprintf(&tmp, "post-nuke %s %d", bkpinfo->restore_path, 3265 3158 retval); 3266 3159 mr_msg(2, "Calling '%s'", tmp); … … 3268 3161 log_OS_error(tmp); 3269 3162 } 3163 mr_free(tmp); 3270 3164 mr_msg(1, "post-nuke returned w/ res=%d", res); 3271 3165 } … … 3274 3168 } 3275 3169 3276 /*3277 log_to_screen("If you are REALLY in a hurry, hit Ctrl-Alt-Del now.");3278 log_to_screen("Otherwise, please wait until the RAID disks are done.");3279 wait_until_software_raids_are_prepped("/proc/mdstat", 100);3280 log_to_screen("Thank you.");3281 */3282 3170 unlink("/tmp/mondo-run-prog.tmp"); 3283 3171 set_signals(FALSE); … … 3289 3177 (_ 3290 3178 ("Restore log copied to /tmp/mondo-restore.log on your hard disk")); 3291 mr_asprintf(&tmp, 3292 _ 3293 ("Mondo-restore is exiting (retval=%d) "), 3294 retval); 3295 log_to_screen(tmp); 3296 mr_free(tmp); 3179 log_to_screen(_("Mondo-restore is exiting (retval=%d)"), retval); 3297 3180 3298 3181 mr_asprintf(&tmp, "umount %s", bkpinfo->isodir);
Note:
See TracChangeset
for help on using the changeset viewer.