Changeset 1645 in MondoRescue for branches/2.2.5/mondo/src/mondorestore/mondo-restore.c
- Timestamp:
- Sep 24, 2007, 3:04:43 AM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2.2.5/mondo/src/mondorestore/mondo-restore.c
r1644 r1645 24 24 extern void twenty_seconds_til_yikes(void); 25 25 26 /* Reference to global bkpinfo */ 27 struct s_bkpinfo *bkpinfo; 28 26 29 27 30 /* For use in other programs (ex. XMondo) */ … … 153 156 * @ingroup restoreGuiGroup 154 157 */ 155 int let_user_edit_the_mountlist(struct s_bkpinfo *bkpinfo, 156 struct mountlist_itself *mountlist, 158 int let_user_edit_the_mountlist(struct mountlist_itself *mountlist, 157 159 struct raidlist_itself *raidlist) 158 160 { … … 259 261 */ 260 262 int 261 catchall_mode(struct s_bkpinfo *bkpinfo, 262 struct mountlist_itself *mountlist, 263 catchall_mode(struct mountlist_itself *mountlist, 263 264 struct raidlist_itself *raidlist) 264 265 { … … 275 276 iamhere("post wrm"); 276 277 if (c == 'I' || c == 'N' || c == 'C') { 277 interactively_obtain_media_parameters_from_user( bkpinfo,FALSE);278 interactively_obtain_media_parameters_from_user(FALSE); 278 279 } else { 279 280 popup_and_OK("No restoring or comparing will take place today."); … … 302 303 if (c == 'I') { 303 304 log_msg(2, "IM selected"); 304 retval += interactive_mode( bkpinfo,mountlist, raidlist);305 retval += interactive_mode(mountlist, raidlist); 305 306 } else if (c == 'N') { 306 307 log_msg(2, "NM selected"); 307 retval += nuke_mode( bkpinfo,mountlist, raidlist);308 retval += nuke_mode(mountlist, raidlist); 308 309 } else if (c == 'C') { 309 310 log_msg(2, "CM selected"); 310 retval += compare_mode( bkpinfo,mountlist, raidlist);311 retval += compare_mode(mountlist, raidlist); 311 312 } 312 313 paranoid_free(tmp); … … 358 359 **************************************************************************/ 359 360 360 static void clean_blkid( struct s_bkpinfo *bkpinfo) {361 static void clean_blkid() { 361 362 362 363 char *tmp1 = NULL; … … 388 389 */ 389 390 int 390 interactive_mode(struct s_bkpinfo *bkpinfo, 391 struct mountlist_itself *mountlist, 391 interactive_mode(struct mountlist_itself *mountlist, 392 392 struct raidlist_itself *raidlist) 393 393 { … … 429 429 430 430 iamhere("About to load config file"); 431 get_cfg_file_from_archive_or_bust( bkpinfo);432 read_cfg_file_into_bkpinfo(g_mondo_cfg_file , bkpinfo);431 get_cfg_file_from_archive_or_bust(); 432 read_cfg_file_into_bkpinfo(g_mondo_cfg_file); 433 433 iamhere("Done loading config file; resizing ML"); 434 434 strcpy(tmp, bkpinfo->prefix); … … 551 551 { 552 552 log_msg(1, "Restoring all data"); 553 retval += restore_everything( bkpinfo,NULL);553 retval += restore_everything(NULL); 554 554 } else 555 555 if ((restore_all = … … 559 559 for (done = FALSE; !done;) { 560 560 unlink("/tmp/filelist.full"); 561 filelist = process_filelist_and_biggielist( bkpinfo);561 filelist = process_filelist_and_biggielist(); 562 562 /* Now you have /tmp/tmpfs/filelist.restore-these and /tmp/tmpfs/biggielist.restore-these; 563 563 the former is a list of regular files; the latter, biggiefiles and imagedevs. … … 578 578 strcpy(bkpinfo->restore_path, tmp); 579 579 log_msg(1, "Restoring subset"); 580 retval += restore_everything( bkpinfo,filelist);580 retval += restore_everything(filelist); 581 581 free_filelist(filelist); 582 582 } else { … … 612 612 } 613 613 614 clean_blkid( bkpinfo);614 clean_blkid(); 615 615 protect_against_braindead_sysadmins(); 616 616 retval += unmount_all_devices(mountlist); … … 663 663 * Run an arbitrary restore mode (prompt the user), but from ISO images 664 664 * instead of real media. 665 * @param bkpinfo The backup information structure. Most fields are used.666 665 * @param mountlist The mountlist containing information about the user's partitions. 667 666 * @param raidlist The raidlist that goes with @p mountlist. … … 670 669 */ 671 670 int 672 iso_mode(struct s_bkpinfo *bkpinfo, 673 struct mountlist_itself *mountlist, 671 iso_mode(struct mountlist_itself *mountlist, 674 672 struct raidlist_itself *raidlist, bool nuke_me_please) 675 673 { … … 677 675 int retval = 0; 678 676 679 assert(bkpinfo != NULL);680 677 assert(mountlist != NULL); 681 678 assert(raidlist != NULL); 682 if (iso_fiddly_bits( bkpinfo,nuke_me_please)) {679 if (iso_fiddly_bits(nuke_me_please)) { 683 680 log_msg(1, "iso_mode --- returning w/ error"); 684 681 return (1); … … 686 683 c = which_restore_mode(); 687 684 if (c == 'I' || c == 'N' || c == 'C') { 688 interactively_obtain_media_parameters_from_user(bkpinfo, 689 FALSE); 685 interactively_obtain_media_parameters_from_user(FALSE); 690 686 } 691 687 if (c == 'I') { 692 retval += interactive_mode( bkpinfo,mountlist, raidlist);688 retval += interactive_mode(mountlist, raidlist); 693 689 } else if (c == 'N') { 694 retval += nuke_mode( bkpinfo,mountlist, raidlist);690 retval += nuke_mode(mountlist, raidlist); 695 691 } else if (c == 'C') { 696 retval += compare_mode( bkpinfo,mountlist, raidlist);692 retval += compare_mode(mountlist, raidlist); 697 693 } else { 698 694 log_to_screen("OK, I shan't restore/compare any files."); … … 732 728 */ 733 729 int 734 nuke_mode(struct s_bkpinfo *bkpinfo, 735 struct mountlist_itself *mountlist, 730 nuke_mode(struct mountlist_itself *mountlist, 736 731 struct raidlist_itself *raidlist) 737 732 { … … 749 744 log_msg(2, "nuke_mode --- starting"); 750 745 751 get_cfg_file_from_archive_or_bust( bkpinfo);746 get_cfg_file_from_archive_or_bust(); 752 747 load_mountlist(mountlist, g_mountlist_fname); // in case read_cfg_file_into_bkpinfo updated the mountlist 753 748 #ifdef __FreeBSD__ … … 770 765 tmpA, tmpB, tmpC); 771 766 if (ask_me_yes_or_no(tmp)) { 772 retval = interactive_mode( bkpinfo,mountlist, raidlist);767 retval = interactive_mode(mountlist, raidlist); 773 768 goto after_the_nuke; 774 769 } else { … … 828 823 829 824 if (ask_me_yes_or_no("Try in interactive mode instead?")) { 830 retval = interactive_mode( bkpinfo,mountlist, raidlist);825 retval = interactive_mode(mountlist, raidlist); 831 826 goto after_the_nuke; 832 827 } else … … 844 839 } 845 840 iamhere("Restoring everything"); 846 retval += restore_everything( bkpinfo,NULL);841 retval += restore_everything(NULL); 847 842 if (!run_boot_loader(FALSE)) { 848 843 log_msg(1, … … 850 845 boot_loader_installed = TRUE; 851 846 } 852 clean_blkid( bkpinfo);847 clean_blkid(); 853 848 protect_against_braindead_sysadmins(); 854 849 retval += unmount_all_devices(mountlist); … … 910 905 * @return 0 for success, or the number of errors encountered. 911 906 */ 912 int restore_to_live_filesystem( struct s_bkpinfo *bkpinfo)907 int restore_to_live_filesystem() 913 908 { 914 909 int retval = 0; … … 937 932 sleep(1); 938 933 } 939 interactively_obtain_media_parameters_from_user( bkpinfo,FALSE);934 interactively_obtain_media_parameters_from_user(FALSE); 940 935 log_msg(2, "bkpinfo->media_device = %s", bkpinfo->media_device); 941 936 if (!bkpinfo->media_device[0]) { … … 948 943 open_evalcall_form("Thinking..."); 949 944 950 get_cfg_file_from_archive_or_bust( bkpinfo);951 read_cfg_file_into_bkpinfo(g_mondo_cfg_file , bkpinfo);945 get_cfg_file_from_archive_or_bust(); 946 read_cfg_file_into_bkpinfo(g_mondo_cfg_file); 952 947 load_mountlist(mountlist, g_mountlist_fname); // in case read_cfg_file_into_bkpinfo 953 948 … … 955 950 retval = load_mountlist(mountlist, g_mountlist_fname); 956 951 load_raidtab_into_raidlist(raidlist, RAIDTAB_FNAME); 957 filelist = process_filelist_and_biggielist( bkpinfo);952 filelist = process_filelist_and_biggielist(); 958 953 if (filelist) { 959 954 save_filelist(filelist, "/tmp/selected-files.txt"); … … 963 958 bkpinfo->restore_path, MAX_STR_LEN / 4)) { 964 959 iamhere("Restoring everything"); 965 retval += restore_everything( bkpinfo,filelist);960 retval += restore_everything(filelist); 966 961 free_filelist(filelist); 967 962 strcpy(bkpinfo->restore_path, old_restpath); … … 1014 1009 */ 1015 1010 int 1016 restore_a_biggiefile_from_CD(struct s_bkpinfo *bkpinfo, 1017 long bigfileno, 1011 restore_a_biggiefile_from_CD(long bigfileno, 1018 1012 struct s_node *filelist, 1019 1013 char *pathname_of_last_file_restored) … … 1204 1198 g_current_media_number); 1205 1199 log_to_screen(tmp); 1206 insist_on_this_cd_number( bkpinfo,g_current_media_number);1200 insist_on_this_cd_number(g_current_media_number); 1207 1201 log_to_screen("Continuing to restore."); 1208 1202 } else { … … 1345 1339 * @bug orig_checksum and biggiefile_size are unused (except to check that they are non-NULL). 1346 1340 */ 1347 int restore_a_biggiefile_from_stream( struct s_bkpinfo *bkpinfo,char *orig_bf_fname, long biggiefile_number, char *orig_checksum, //UNUSED1341 int restore_a_biggiefile_from_stream(char *orig_bf_fname, long biggiefile_number, char *orig_checksum, //UNUSED 1348 1342 long long biggiefile_size, //UNUSED 1349 1343 struct s_node *filelist, … … 1518 1512 if (current_slice_number == 0) { 1519 1513 res = 1520 read_file_from_stream_to_file(bkpinfo, 1521 "/tmp/biggie-blah.txt", 1514 read_file_from_stream_to_file("/tmp/biggie-blah.txt", 1522 1515 slice_siz); 1523 1516 if (!(fin = fopen("/tmp/biggie-blah.txt", "r"))) { … … 1535 1528 } else { 1536 1529 res = 1537 read_file_from_stream_to_stream( bkpinfo,pout, slice_siz);1530 read_file_from_stream_to_stream(pout, slice_siz); 1538 1531 } 1539 1532 retval += res; … … 1837 1830 */ 1838 1831 int 1839 restore_a_tarball_from_stream(struct s_bkpinfo *bkpinfo, 1840 char *tarball_fname, 1832 restore_a_tarball_from_stream(char *tarball_fname, 1841 1833 long current_tarball_number, 1842 1834 struct s_node *filelist, … … 1890 1882 bkpinfo->tmpdir, current_tarball_number); 1891 1883 // sprintf(filelist_fname, "/tmp/tmpfs/temp-filelist.%ld", current_tarball_number); 1892 res = read_file_from_stream_to_file( bkpinfo,afio_fname, size);1884 res = read_file_from_stream_to_file(afio_fname, size); 1893 1885 if (strstr(tarball_fname, ".star")) { 1894 1886 bkpinfo->use_star = TRUE; … … 2031 2023 */ 2032 2024 int 2033 restore_all_biggiefiles_from_CD(struct s_bkpinfo *bkpinfo, 2034 struct s_node *filelist) 2025 restore_all_biggiefiles_from_CD(struct s_node *filelist) 2035 2026 { 2036 2027 int retval = 0; … … 2099 2090 "I'll continue to scan this CD for bigfiles to be restored."); 2100 2091 } else if (does_file_exist(MNT_CDROM "/archives/NOT-THE-LAST")) { 2101 insist_on_this_cd_number(bkpinfo, 2102 ++g_current_media_number); 2092 insist_on_this_cd_number(++g_current_media_number); 2103 2093 sprintf(tmp, "Restoring from %s #%d", 2104 media_descriptor_string(bkpinfo-> 2105 backup_media_type), 2094 media_descriptor_string(bkpinfo->backup_media_type), 2106 2095 g_current_media_number); 2107 2096 log_to_screen(tmp); … … 2118 2107 update_progress_form(tmp); 2119 2108 res = 2120 restore_a_biggiefile_from_CD(bkpinfo, bigfileno, filelist, 2121 pathname_of_last_biggie_restored); 2109 restore_a_biggiefile_from_CD(bigfileno, filelist, pathname_of_last_biggie_restored); 2122 2110 iamhere(pathname_of_last_biggie_restored); 2123 2111 if (fbw && pathname_of_last_biggie_restored[0]) { … … 2180 2168 */ 2181 2169 int 2182 restore_all_tarballs_from_CD(struct s_bkpinfo *bkpinfo, 2183 struct s_node *filelist) 2170 restore_all_tarballs_from_CD(struct s_node *filelist) 2184 2171 { 2185 2172 int retval = 0; … … 2208 2195 g_current_media_number = 1; 2209 2196 } 2210 insist_on_this_cd_number( bkpinfo,g_current_media_number);2197 insist_on_this_cd_number(g_current_media_number); 2211 2198 read_cfg_var(g_mondo_cfg_file, "last-filelist-number", tmp); 2212 2199 max_val = atol(tmp) + 1; … … 2220 2207 progress_str, max_val); 2221 2208 for (;;) { 2222 insist_on_this_cd_number( bkpinfo,g_current_media_number);2209 insist_on_this_cd_number(g_current_media_number); 2223 2210 update_progress_form(progress_str); 2224 2211 sprintf(tarball_fname, MNT_CDROM "/archives/%ld.afio.bz2", … … 2326 2313 */ 2327 2314 int 2328 restore_all_biggiefiles_from_stream(struct s_bkpinfo *bkpinfo, 2329 struct s_node *filelist) 2315 restore_all_biggiefiles_from_stream(struct s_node *filelist) 2330 2316 { 2331 2317 long noof_biggiefiles; … … 2381 2367 if (ctrl_chr == BLK_START_EXTENDED_ATTRIBUTES) { 2382 2368 res = 2383 read_EXAT_files_from_tape( bkpinfo,&biggie_size, biggie_fname,2369 read_EXAT_files_from_tape(&biggie_size, biggie_fname, 2384 2370 &ctrl_chr, xattr_fname, acl_fname); 2385 2371 } … … 2414 2400 current_bigfile_number + 1, biggie_size / 1024); 2415 2401 update_progress_form(tmp); 2416 res = restore_a_biggiefile_from_stream(b kpinfo, biggie_fname,2402 res = restore_a_biggiefile_from_stream(biggie_fname, 2417 2403 current_bigfile_number, 2418 2404 biggie_cksum, … … 2505 2491 */ 2506 2492 int 2507 restore_all_tarballs_from_stream(struct s_bkpinfo *bkpinfo, 2508 struct s_node *filelist) 2493 restore_all_tarballs_from_stream(struct s_node *filelist) 2509 2494 { 2510 2495 int retval = 0; … … 2572 2557 iamhere("Reading EXAT files from tape"); 2573 2558 res = 2574 read_EXAT_files_from_tape( bkpinfo,&tmp_size, tmp_fname,2559 read_EXAT_files_from_tape(&tmp_size, tmp_fname, 2575 2560 &ctrl_chr, xattr_fname, 2576 2561 acl_fname); … … 2583 2568 current_afioball_number, tmp_fname, (long) tmp_size >> 10); 2584 2569 res = 2585 restore_a_tarball_from_stream( bkpinfo,tmp_fname,2570 restore_a_tarball_from_stream(tmp_fname, 2586 2571 current_afioball_number, 2587 2572 filelist, tmp_size, xattr_fname, … … 2644 2629 * @ingroup restoreGroup 2645 2630 */ 2646 int restore_everything(struct s_ bkpinfo *bkpinfo, struct s_node *filelist)2631 int restore_everything(struct s_node *filelist) 2647 2632 { 2648 2633 int resA; … … 2675 2660 mvaddstr_and_log_it(g_currentY, 0, "Preparing to read your archives"); 2676 2661 if (IS_THIS_A_STREAMING_BACKUP(bkpinfo->backup_media_type)) { 2677 mount_cdrom( bkpinfo);2662 mount_cdrom(); 2678 2663 mvaddstr_and_log_it(g_currentY++, 0, 2679 2664 "Restoring OS and data from streaming media"); 2680 2665 if (bkpinfo->backup_media_type == cdstream) { 2681 openin_cdstream( bkpinfo);2666 openin_cdstream(); 2682 2667 } else { 2683 assert_string_is_neither_NULL_nor_zerolength(bkpinfo-> 2684 media_device); 2685 openin_tape(bkpinfo); 2686 } 2687 resA = restore_all_tarballs_from_stream(bkpinfo, filelist); 2688 resB = restore_all_biggiefiles_from_stream(bkpinfo, filelist); 2668 assert_string_is_neither_NULL_nor_zerolength(bkpinfo->media_device); 2669 openin_tape(); 2670 } 2671 resA = restore_all_tarballs_from_stream(filelist); 2672 resB = restore_all_biggiefiles_from_stream(filelist); 2689 2673 if (bkpinfo->backup_media_type == cdstream) { 2690 closein_cdstream( bkpinfo);2674 closein_cdstream(); 2691 2675 } else { 2692 closein_tape( bkpinfo);2676 closein_tape(); 2693 2677 } 2694 2678 } else { 2695 2679 mvaddstr_and_log_it(g_currentY++, 0, 2696 2680 "Restoring OS and data from CD "); 2697 mount_cdrom( bkpinfo);2698 resA = restore_all_tarballs_from_CD( bkpinfo,filelist);2699 resB = restore_all_biggiefiles_from_CD( bkpinfo,filelist);2681 mount_cdrom(); 2682 resA = restore_all_tarballs_from_CD(filelist); 2683 resB = restore_all_biggiefiles_from_CD(filelist); 2700 2684 } 2701 2685 chdir(cwd); … … 2726 2710 */ 2727 2711 int 2728 restore_live_from_monitas_server(struct s_bkpinfo *bkpinfo, 2729 char *monitas_device, 2712 restore_live_from_monitas_server(char *monitas_device, 2730 2713 char *restore_this_directory, 2731 2714 char *restore_here) … … 2799 2782 2800 2783 unlink(datadisks_fname); 2801 read_cfg_file_into_bkpinfo(g_mondo_cfg_file , bkpinfo);2784 read_cfg_file_into_bkpinfo(g_mondo_cfg_file); 2802 2785 retval = load_mountlist(&the_mountlist, g_mountlist_fname); // in case read_cfg_file_into_bkpinfo strcpy(bkpinfo->media_device, monitas_device); 2803 2786 … … 2826 2809 run_program_and_log_output(command, FALSE); 2827 2810 // filelist = load_filelist(g_filelist_restthese); // FIXME --- this probably doesn't work because it doesn't include the biggiefiles 2828 retval += restore_everything( bkpinfo,filelist);2811 retval += restore_everything(filelist); 2829 2812 free_filelist(filelist); 2830 2813 log_msg(2, "--------End of restore_live_from_monitas_server--------"); … … 2898 2881 struct mountlist_itself *mountlist; 2899 2882 struct raidlist_itself *raidlist; 2900 struct s_bkpinfo *bkpinfo;2901 2883 struct s_node *filelist; 2902 2884 char *a, *b; … … 2958 2940 malloc_string(a); 2959 2941 malloc_string(b); 2960 setup_MR_global_filenames( bkpinfo); // malloc() and set globals, using bkpinfo->tmpdir etc.2961 reset_bkpinfo( bkpinfo);2942 setup_MR_global_filenames(); // malloc() and set globals, using bkpinfo->tmpdir etc. 2943 reset_bkpinfo(); 2962 2944 bkpinfo->backup_media_type = none; // in case boot disk was made for one backup type but user wants to restore from another backup type 2963 2945 bkpinfo->restore_data = TRUE; // Well, yeah :-) … … 3027 3009 strcpy(g_mountlist_fname, "/tmp/mountlist.txt"); 3028 3010 } 3029 res = let_user_edit_the_mountlist( bkpinfo,mountlist, raidlist);3011 res = let_user_edit_the_mountlist(mountlist, raidlist); 3030 3012 #ifdef __FreeBSD__ 3031 3013 system("mv -f /etc/raidtab /tmp/raidconf.txt"); … … 3060 3042 system("rm -Rf /tmp/*pih*"); 3061 3043 3062 restore_a_biggiefile_from_CD( bkpinfo,42, NULL, tmp);3044 restore_a_biggiefile_from_CD(42, NULL, tmp); 3063 3045 } 3064 3046 … … 3161 3143 if (argc == 5 && strcmp(argv[1], "--monitas-live") == 0) { 3162 3144 retval = 3163 restore_live_from_monitas_server(bkpinfo, 3164 argv[2], 3145 restore_live_from_monitas_server(argv[2], 3165 3146 argv[3], argv[4]); 3166 3147 } else { 3167 3148 log_msg(2, "Calling restore_to_live_filesystem()"); 3168 retval = restore_to_live_filesystem( bkpinfo);3149 retval = restore_to_live_filesystem(); 3169 3150 } 3170 3151 log_msg(2, "Still here. Yay."); … … 3186 3167 iamhere("About to call load_mountlist and load_raidtab"); 3187 3168 strcpy(bkpinfo->restore_path, MNT_RESTORING); 3188 read_cfg_file_into_bkpinfo(g_mondo_cfg_file , bkpinfo);3169 read_cfg_file_into_bkpinfo(g_mondo_cfg_file); 3189 3170 retval = load_mountlist(mountlist, g_mountlist_fname); 3190 3171 retval += load_raidtab_into_raidlist(raidlist, RAIDTAB_FNAME); … … 3245 3226 if (argc == 2 && strcmp(argv[1], "--nuke") == 0) { 3246 3227 iamhere("nuking"); 3247 retval += nuke_mode( bkpinfo,mountlist, raidlist);3228 retval += nuke_mode(mountlist, raidlist); 3248 3229 } else if (argc == 2 && strcmp(argv[1], "--interactive") == 0) { 3249 3230 iamhere("catchall"); 3250 retval += catchall_mode( bkpinfo,mountlist, raidlist);3231 retval += catchall_mode(mountlist, raidlist); 3251 3232 } else if (argc == 2 && strcmp(argv[1], "--compare") == 0) { 3252 3233 iamhere("compare"); 3253 retval += compare_mode( bkpinfo,mountlist, raidlist);3234 retval += compare_mode(mountlist, raidlist); 3254 3235 } else if (argc == 2 && strcmp(argv[1], "--iso") == 0) { 3255 3236 iamhere("iso"); 3256 retval = iso_mode( bkpinfo,mountlist, raidlist, FALSE);3237 retval = iso_mode(mountlist, raidlist, FALSE); 3257 3238 } else if (argc == 2 && strcmp(argv[1], "--mbr") == 0) { 3258 3239 iamhere("mbr"); … … 3267 3248 } else if (argc == 2 && strcmp(argv[1], "--isonuke") == 0) { 3268 3249 iamhere("isonuke"); 3269 retval = iso_mode( bkpinfo,mountlist, raidlist, TRUE);3250 retval = iso_mode(mountlist, raidlist, TRUE); 3270 3251 } else if (argc != 1) { 3271 3252 log_to_screen("Invalid paremeters"); … … 3273 3254 } else { 3274 3255 iamhere("catchall (no mode specified in command-line call"); 3275 retval += catchall_mode( bkpinfo,mountlist, raidlist);3256 retval += catchall_mode(mountlist, raidlist); 3276 3257 } 3277 3258 }
Note:
See TracChangeset
for help on using the changeset viewer.