Changeset 2623 in MondoRescue for branches/2.2.10/mondo/src
- Timestamp:
- Apr 12, 2010, 3:23:24 PM (15 years ago)
- Location:
- branches/2.2.10/mondo/src
- Files:
-
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2.2.10/mondo/src/common/libmondo-archive.c
r2606 r2623 2203 2203 } 2204 2204 2205 mr_asprintf(command, "cp %s/biggielist.txt %s", bkpinfo->tmpdir,2206 biggielist);2207 paranoid_system(command);2208 mr_free(command);2209 2210 2205 mr_asprintf(blah, "biggielist = %s", biggielist); 2211 2206 log_msg(2, blah); -
branches/2.2.10/mondo/src/common/libmondo-devices.c
r2588 r2623 54 54 * @ingroup globalGroup 55 55 */ 56 bool g_restoring_live_from_cd = FALSE;57 bool g_restoring_live_from_netfs = FALSE;58 59 56 extern t_bkptype g_backup_media_type; // set by main() 60 57 … … 2561 2558 // Tape, CD, NETFS, ...? 2562 2559 srandom(getpid()); 2563 bkpinfo->backup_media_type = 2564 (g_restoring_live_from_cd) ? cdr : 2565 which_backup_media_type(bkpinfo->restore_data); 2560 bkpinfo->backup_media_type = which_backup_media_type(bkpinfo->restore_data); 2566 2561 if (bkpinfo->backup_media_type == none) { 2567 2562 log_to_screen("User has chosen not to backup the PC"); -
branches/2.2.10/mondo/src/common/libmondo-filelist.c
r2576 r2623 104 104 estimate_noof_media_required(noof_sets); // for cosmetic purposes 105 105 106 mr_asprintf(tempfile, "%s/biggielist.txt", bkpinfo-> tmpdir);106 mr_asprintf(tempfile, "%s/biggielist.txt", bkpinfo->scratchdir); 107 107 if (!(fout = fopen(tempfile, "a"))) { 108 108 log_OS_error("Cannot append to biggielist"); … … 237 237 curr_set_size = 0; 238 238 mr_asprintf(outfname, "%s/filelist.%ld", bkpinfo->tmpdir, curr_set_no); 239 mr_asprintf(biggie_fname, "%s/biggielist.txt", bkpinfo-> tmpdir);239 mr_asprintf(biggie_fname, "%s/biggielist.txt", bkpinfo->scratchdir); 240 240 log_it("outfname=%s; biggie_fname=%s", outfname, biggie_fname); 241 241 if (!(fbig = fopen(biggie_fname, "w"))) { … … 261 261 i = 0; 262 262 } 263 /* Now that we dyn. alloc is truncating needed ?264 if (i > MAX_STR_LEN - 1) {265 incoming[MAX_STR_LEN - 30] = '\0';266 log_msg(1, "Warning - truncating file %s's name", incoming);267 err++;268 }269 */270 263 if (incoming[i] < 32) { 271 264 incoming[i] = '\0'; -
branches/2.2.10/mondo/src/common/libmondo-files.c
r2569 r2623 754 754 755 755 log_it("Calculating size of all biggiefiles (in total)"); 756 mr_asprintf(biggielist, "%s/biggielist.txt", bkpinfo-> tmpdir);756 mr_asprintf(biggielist, "%s/biggielist.txt", bkpinfo->scratchdir); 757 757 log_it("biggielist = %s", biggielist); 758 758 fin = fopen(biggielist, "r"); -
branches/2.2.10/mondo/src/mondorestore/mondo-prep.c
r2603 r2623 35 35 //static char cvsid[] = "$Id$"; 36 36 37 extern char *g_mountlist_fname;38 37 extern long g_current_progress, g_maximum_progress; 39 38 … … 72 71 // then zero & insist on reboot. 73 72 buf = malloc(blocksize); 74 if (does_file_exist( "/tmp/i-want-my-lvm")) // FIXME - cheating :)73 if (does_file_exist(MINDI_CACHE"/i-want-my-lvm")) // FIXME - cheating :) 75 74 { 76 75 drivelist = malloc(sizeof(struct list_of_disks)); … … 172 171 */ 173 172 /** 174 * Execute the commands in /tmp/i-want-my-lvm.173 * Execute the commands in MINDI_CACHE"i-want-my-lvm. 175 174 * These should probably be commands to set up LVM. 176 175 * @return The number of errors encountered (0 for success). … … 221 220 mr_free(tmp); 222 221 223 if (!(fin = fopen( "/tmp/i-want-my-lvm", "r"))) {224 log_OS_error( "/tmp/i-want-my-lvm");222 if (!(fin = fopen(MINDI_CACHE"/i-want-my-lvm", "r"))) { 223 log_OS_error(MINDI_CACHE"/i-want-my-lvm"); 225 224 return (1); 226 225 } … … 937 936 // do LVMs now 938 937 log_msg(1, "Creating LVMs"); 939 if (does_file_exist( "/tmp/i-want-my-lvm")) {938 if (does_file_exist(MINDI_CACHE"/i-want-my-lvm")) { 940 939 wait_until_software_raids_are_prepped("/proc/mdstat", 100); 941 940 log_to_screen("Configuring LVM"); … … 1861 1860 log_msg(0, "Done."); 1862 1861 1863 /*1864 if (does_file_exist("/tmp/i-want-my-lvm"))1865 {1866 wipe_MBRs_and_reboot_if_necessary(mountlist); // i.e. if it wasn't done recently1867 }1868 */1869 1870 1862 open_progress_form("Partitioning devices", 1871 1863 "I am now going to partition all your drives.", … … 2425 2417 assert(mountlist != NULL); 2426 2418 2427 if (g_mountlist_fname[0] == '\0') {2428 log_it2429 ("resize_mountlist_prop...() - warning - mountlist fname is blank");2430 log_it("That does NOT affect the functioning of this subroutine.");2431 log_it("--- Hugo, 2002/11/20");2432 }2433 2419 log_it("Resizing mountlist"); 2434 2420 make_list_of_drives_in_mountlist(mountlist, drivelist); -
branches/2.2.10/mondo/src/mondorestore/mondo-restore-EXT.h
r2048 r2623 10 10 extern char *g_isodir_format; 11 11 12 extern char *g_biggielist_txt;13 12 extern char *g_filelist_full; 14 13 extern char *g_biggielist_pot; … … 18 17 extern char *g_biggielist_restthese; 19 18 extern char *g_imagedevs_restthese; 20 extern char *g_mondo_cfg_file;21 extern char *g_mountlist_fname;22 19 extern char *g_mondo_home; 23 20 -
branches/2.2.10/mondo/src/mondorestore/mondo-rstr-compare.c
r2508 r2623 18 18 /* Reference to global bkpinfo */ 19 19 extern struct s_bkpinfo *bkpinfo; 20 21 extern char *g_mountlist_fname;22 20 23 21 //static char cvsid[] = "$Id$"; … … 352 350 assert(bkpinfo != NULL); 353 351 mvaddstr_and_log_it(g_currentY, 0, "Comparing archives"); 354 tmp = read_cfg_var( g_mondo_cfg_file, "last-filelist-number");352 tmp = read_cfg_var(MINDI_CACHE"/mondorestore.cfg", "last-filelist-number"); 355 353 max_val = atol(tmp); 356 354 mr_free(tmp); … … 523 521 524 522 /************************************************************************** 525 * also deletes tmp/filelist.full & tmp/biggielist.txt _and_ tries to *523 * also deletes tmp/filelist.full & biggielist.txt _and_ tries to * 526 524 * restore them from start of tape, if available * 527 525 **************************************************************************/ … … 530 528 assert(raidlist != NULL); 531 529 532 while (get_cfg_file_from_archive()) { 533 if (!ask_me_yes_or_no 534 ("Failed to find config file/archives. Choose another source?")) 535 { 536 fatal_error("Unable to find config file/archives. Aborting."); 537 } 538 interactively_obtain_media_parameters_from_user(FALSE); 539 } 540 541 read_cfg_file_into_bkpinfo(g_mondo_cfg_file); 530 read_cfg_file_into_bkpinfo(MINDI_CACHE"/mondorestore.cfg"); 542 531 543 532 /* edit_mountlist if wanted */ 544 533 log_it("About to edit mountlist"); 545 534 if (g_text_mode) { 546 save_mountlist_to_disk(mountlist, g_mountlist_fname);547 mr_asprintf(tmp, "%s %s", find_my_editor(), g_mountlist_fname);535 save_mountlist_to_disk(mountlist, MINDI_CACHE"/mountlist.txt"); 536 mr_asprintf(tmp, "%s %s", find_my_editor(), MINDI_CACHE"/mountlist.txt"); 548 537 res = system(tmp); 549 538 mr_free(tmp); 550 539 551 load_mountlist(mountlist, g_mountlist_fname);552 } else { 553 res = edit_mountlist( g_mountlist_fname, mountlist, raidlist);540 load_mountlist(mountlist, MINDI_CACHE"/mountlist.txt"); 541 } else { 542 res = edit_mountlist(MINDI_CACHE"/mountlist.txt", mountlist, raidlist); 554 543 } 555 544 log_it("Finished editing mountlist"); … … 557 546 paranoid_MR_finish(1); 558 547 } 559 save_mountlist_to_disk(mountlist, g_mountlist_fname);548 save_mountlist_to_disk(mountlist, MINDI_CACHE"/mountlist.txt"); 560 549 save_raidlist_to_raidtab(raidlist, RAIDTAB_FNAME); 561 550 -
branches/2.2.10/mondo/src/mondorestore/mondo-rstr-tools-EXT.h
r2049 r2623 4 4 5 5 extern void free_MR_global_filenames(); 6 extern void get_cfg_file_from_archive_or_bust();7 6 extern bool is_file_in_list(char *, char *, char *); /* needle, haystack, preamble */ 8 7 extern int iso_fiddly_bits(bool nuke_me_please); … … 28 27 extern void termination_in_progress(int); 29 28 extern int unmount_all_devices(struct mountlist_itself *); 30 extern int get_cfg_file_from_archive();31 29 extern void ask_about_these_imagedevs(char *infname, char *outfname); 32 30 -
branches/2.2.10/mondo/src/mondorestore/mondo-rstr-tools.c
r2607 r2623 13 13 #include "mondo-rstr-tools.h" 14 14 15 /**16 * The biggielist stub (appended to the directory where all.tar.gz was unpacked).17 */18 #define BIGGIELIST_TXT_STUB "tmp/biggielist.txt"19 20 /**21 * The filelist stub (appended to the directory where all.tar.gz was unpacked).22 */23 #define FILELIST_FULL_STUB "tmp/filelist.full.gz"24 25 /**26 * The mountlist stub (appended to the directory where all.tar.gz was unpacked).27 */28 #define MOUNTLIST_FNAME_STUB MINDI_CACHE_REL"/mountlist.txt"29 30 /**31 * The mondorestore.cfg stub (appended to the directory where all.tar.gz was unpacked).32 */33 #define MONDO_CFG_FILE_STUB MINDI_CACHE_REL"/mondorestore.cfg"34 /**35 * The i-want-my-lvm stub36 */37 #define IWANTMYLVM_STUB "tmp/i-want-my-lvm"38 39 15 extern bool g_ISO_restore_mode; /* are we in Iso Mode? */ 40 16 extern bool g_I_have_just_nuked; … … 44 20 extern char *g_isodir_device; 45 21 extern long g_current_progress, g_maximum_progress; 46 extern char *g_biggielist_txt; // where 'biggielist.txt' is stored, on ramdisk / tempdir;47 // biggielist.txt is the list of big files stored on the48 // backup media set in question49 extern char *g_filelist_full; // filelist.full.gz is the list of all regular files50 // (excluding big files) stored on the backup media set51 22 extern char *g_biggielist_pot; // list of big files which _could_ be restored, if the 52 23 // user chooses them … … 56 27 extern char *g_imagedevs_restthese; // of the imagedevs listed in FILELIST_IMAGEDEVS, 57 28 // restore only these 58 extern char *g_mondo_cfg_file; // where m*ndo-restore.cfg (the config file) is stored59 extern char *g_mountlist_fname; // where mountlist.txt (the mountlist file) is stored60 29 extern char *g_mondo_home; // homedir of Mondo; usually /usr/local/share/mondo 61 30 … … 85 54 void free_MR_global_filenames(void) 86 55 { 87 paranoid_free(g_biggielist_txt);88 paranoid_free(g_filelist_full);89 56 paranoid_free(g_filelist_imagedevs); 90 57 paranoid_free(g_imagedevs_restthese); 91 paranoid_free(g_mondo_cfg_file);92 paranoid_free(g_mountlist_fname);93 58 paranoid_free(g_mondo_home); 94 59 /* … … 148 113 *ASK_ABOUT_THESE_IMAGEDEVS * 149 114 **************************************************************************/ 150 151 152 153 154 155 156 157 158 /**159 * Extract @c mondorestore.cfg and @c mountlist.txt from @p ramdisk_fname.160 * @param bkpinfo The backup information structure. @c tmpdir is the only field used.161 * @param ramdisk_fname The filename of the @b compressed ramdisk to look in.162 * @param output_cfg_file Where to put the configuration file extracted.163 * @param output_mountlist_file Where to put the mountlist file extracted.164 * @return 0 for success, nonzero for failure.165 * @ingroup restoreUtilityGroup166 */167 168 /**169 * Keep trying to get mondorestore.cfg from the archive, until the user gives up.170 */171 void get_cfg_file_from_archive_or_bust()172 {173 while (get_cfg_file_from_archive()) {174 if (!ask_me_yes_or_no175 ("Failed to find config file/archives. Choose another source?"))176 {177 fatal_error("Could not find config file/archives. Aborting.");178 }179 interactively_obtain_media_parameters_from_user(FALSE);180 }181 }182 183 115 184 116 /** … … 252 184 g_ISO_restore_mode = TRUE; 253 185 mr_free(g_isodir_device); 254 g_isodir_device = read_cfg_var( g_mondo_cfg_file, "iso-dev");186 g_isodir_device = read_cfg_var(MINDI_CACHE"/mondorestore.cfg", "iso-dev"); 255 187 if (bkpinfo->disaster_recovery) { 256 188 /* Patch Conor Daly 26-june-2004 … … 272 204 return (1); 273 205 } 274 paranoid_system("umount " MNT_CDROM" 2> /dev/null"); /* just in case */206 paranoid_system("umount "MNT_CDROM" 2> /dev/null"); /* just in case */ 275 207 276 208 if (is_this_device_mounted(g_isodir_device)) { … … 554 486 } 555 487 556 if (!run_program_and_log_output("mount | grep -F " 488 if (!run_program_and_log_output("mount | grep -F "MNT_CDROM, FALSE)) { 557 489 log_msg(2, "mount_media() - media already mounted. Fair enough."); 558 490 return (0); … … 579 511 mr_free(mount_cmd); 580 512 581 mr_asprintf(mount_cmd, "mount_cd9660 -r %s " 513 mr_asprintf(mount_cmd, "mount_cd9660 -r %s "MNT_CDROM, mddev); 582 514 #else 583 515 mr_asprintf(mount_cmd, "mount %s/%s/%s-%d.iso -t iso9660 -o loop,ro %s", bkpinfo->isodir, bkpinfo->netfs_remote_dir, bkpinfo->prefix, g_current_media_number, MNT_CDROM); … … 673 605 **************************************************************************/ 674 606 607 608 /** 609 * Extract mondorestore.cfg and the mountlist from the tape inserted 610 * to the ./tmp/ directory. 611 * @param dev The tape device to read from. 612 * @return 0 for success, nonzero for failure. 613 */ 614 int extract_cfg_file_and_mountlist_from_tape_dev(char *dev) 615 { 616 char *command = NULL; 617 int res = 0; 618 619 if (bkpinfo->use_obdr) { 620 skip_obdr(); 621 } else { 622 // BCO: below 32KB seems to block at least on RHAS 2.1 and MDK 10.0 623 set_tape_block_size_with_mt(bkpinfo->internal_tape_block_size); 624 } 625 626 mr_asprintf(command, "dd if=%s bs=%ld count=%ld 2> /dev/null | tar -zx ."MINDI_CACHE"/biggielist.txt ."MINDI_CACHE"/filelist.full.gz ."MINDI_CACHE"/i-want-my-lvm", dev, bkpinfo->internal_tape_block_size, 1024L * 1024 * 32 / bkpinfo->internal_tape_block_size); 627 log_msg(2, "command = '%s'", command); 628 res = run_program_and_log_output(command, -1); 629 mr_free(command); 630 631 return (res); 632 } 633 634 635 636 /** 637 * Get the configuration file from the initrd of the backup media 638 * case when calling mondorestore live 639 * @param bkpinfo The backup information structure. Fields used: 640 * - @c bkpinfo->backup_media_type 641 * - @c bkpinfo->media_device 642 * - @c bkpinfo->tmpdir 643 * @return 0 for success, nonzero for failure. 644 */ 645 int get_cfg_file_from_initrd() 646 { 647 /** malloc *****/ 648 char *command = NULL; 649 char *cfg_file = NULL; 650 char *tmp = NULL; 651 char *mountpt = NULL; 652 653 bool try_plan_B; 654 655 assert(bkpinfo != NULL); 656 log_msg(2, "gcffa --- starting"); 657 log_to_screen("I'm thinking..."); 658 mr_asprintf(mountpt, "%s/mount.bootdisk", bkpinfo->tmpdir); 659 mr_asprintf(command, "mkdir -p %s", mountpt); 660 run_program_and_log_output(command, FALSE); 661 log_msg(2, "mountpt = %s; ", mountpt); 662 mr_free(command); 663 664 chdir(bkpinfo->tmpdir); 665 666 mr_free(mountpt); 667 668 if (!does_file_exist(cfg_file)) { 669 log_msg(2, "gcffa --- we don't have cfg file yet."); 670 if (IS_THIS_A_STREAMING_BACKUP(bkpinfo->backup_media_type)) { 671 try_plan_B = TRUE; 672 } else { 673 log_msg(2, "gcffa --- calling mount_media now :)"); 674 if (!mount_media()) { 675 log_msg(2, 676 "gcffa --- managed to mount CD; so, no need for Plan B"); 677 try_plan_B = FALSE; 678 } else { 679 try_plan_B = TRUE; 680 } 681 if (what_number_cd_is_this() > 1) { 682 insist_on_this_cd_number((g_current_media_number = 1)); 683 } 684 } 685 if (try_plan_B) { 686 log_msg(2, "gcffa --- OK, switching to Plan B"); 687 chdir(bkpinfo->tmpdir); 688 run_program_and_log_output("mkdir -p tmp", FALSE); 689 690 if (! bkpinfo->media_device) { 691 mr_asprintf(bkpinfo->media_device, "/dev/st0"); 692 log_msg(2, "media_device is blank; assuming %s", bkpinfo->media_device); 693 } 694 mr_asprintf(tmp, "%s", bkpinfo->media_device); 695 if (extract_cfg_file_and_mountlist_from_tape_dev (bkpinfo->media_device)) { 696 mr_free(bkpinfo->media_device); 697 mr_asprintf(bkpinfo->media_device, "/dev/st0"); 698 if (extract_cfg_file_and_mountlist_from_tape_dev (bkpinfo->media_device)) { 699 mr_free(bkpinfo->media_device); 700 mr_asprintf(bkpinfo->media_device, "/dev/osst0"); 701 if (extract_cfg_file_and_mountlist_from_tape_dev (bkpinfo->media_device)) { 702 mr_free(bkpinfo->media_device); 703 mr_asprintf(bkpinfo->media_device, "/dev/ht0"); 704 if (extract_cfg_file_and_mountlist_from_tape_dev (bkpinfo->media_device)) { 705 log_msg(3, "I tried lots of devices but none worked."); 706 mr_free(bkpinfo->media_device); 707 mr_asprintf(bkpinfo->media_device, "%s", tmp); 708 } 709 } 710 } 711 } 712 mr_free(tmp); 713 714 if (!does_file_exist(MINDI_CACHE_REL"/mondorestore.cfg")) { 715 log_to_screen("Cannot find config info on media"); 716 return (1); 717 } 718 } else { 719 log_msg(2, "gcffa --- Plan B, a.k.a. untarring some file from all.tar.gz"); 720 mr_asprintf(command, "tar -zxvf "MNT_CDROM"/images/all.tar.gz ."MINDI_CACHE"/biggielist.txt ."MINDI_CACHE"/filelist.full.gz ."MINDI_CACHE"/i-want-my-lvm"); // add -b TAPE_BLOCK_SIZE if you _really_ think it's necessary 721 run_program_and_log_output(command, TRUE); 722 mr_free(command); 723 } 724 } 725 run_program_and_log_output("umount "MNT_CDROM, FALSE); 726 if (!does_file_exist(cfg_file)) { 727 log_it("%s",cfg_file); 728 log_msg(1, "%s not found", cfg_file); 729 log_to_screen("Oh dear. Unable to recover configuration file from boot disk"); 730 return (1); 731 } 732 733 log_to_screen("Recovered mondorestore.cfg"); 734 735 run_program_and_log_output(command, FALSE); 736 mr_free(command); 737 738 mr_asprintf(command, "cp -f etc/raidtab /etc/"); 739 run_program_and_log_output(command, FALSE); 740 mr_free(command); 741 742 g_backup_media_type = bkpinfo->backup_media_type; 743 return (retval); 744 } 675 745 676 746 … … 700 770 // assert_string_is_neither_NULL_nor_zerolength(cfg_file); 701 771 assert(bkpinfo != NULL); 702 703 if (!cfgf) { 704 cfg_file = g_mondo_cfg_file; 705 } else { 706 cfg_file = cfgf; 707 } 772 assert(cfgf != NULL); 708 773 709 774 media_specified_by_user = bkpinfo->backup_media_type; // or 'none', if not specified … … 728 793 if (!is_this_device_mounted("/dev/cdrom")) { 729 794 log_msg(2, "NB: CDROM device not mounted, mounting..."); 730 run_program_and_log_output("mount /dev/cdrom " 731 } 732 if (does_file_exist(MNT_CDROM 795 run_program_and_log_output("mount /dev/cdrom "MNT_CDROM, 1); 796 } 797 if (does_file_exist(MNT_CDROM"/archives/filelist.0")) { 733 798 bkpinfo->backup_media_type = cdr; 734 run_program_and_log_output("umount " 799 run_program_and_log_output("umount "MNT_CDROM, 1); 735 800 log_it 736 801 ("Re-jigging configuration AGAIN. CD-R, not ISO."); … … 951 1016 } 952 1017 953 tmp = read_cfg_var( g_mondo_cfg_file, "please-dont-eject");1018 tmp = read_cfg_var(MINDI_CACHE"/mondorestore.cfg", "please-dont-eject"); 954 1019 tmp1 = call_program_and_get_last_line_of_output("cat " CMDLINE); 955 1020 if (tmp || strstr(tmp1, "donteject")) { … … 971 1036 } else { 972 1037 mr_free(bkpinfo->netfs_mount); 973 bkpinfo->netfs_mount = read_cfg_var( g_mondo_cfg_file, "netfs-server-mount");1038 bkpinfo->netfs_mount = read_cfg_var(MINDI_CACHE"/mondorestore.cfg", "netfs-server-mount"); 974 1039 975 1040 mr_free(bkpinfo->netfs_remote_dir); 976 bkpinfo->netfs_remote_dir = read_cfg_var( g_mondo_cfg_file, "netfs-server-path");1041 bkpinfo->netfs_remote_dir = read_cfg_var(MINDI_CACHE"/mondorestore.cfg", "netfs-server-path"); 977 1042 978 1043 if (bkpinfo->netfs_mount != NULL) { … … 1014 1079 */ 1015 1080 mr_asprintf(old_isodir, "%s", bkpinfo->isodir); 1016 iso_mnt = read_cfg_var( g_mondo_cfg_file, "iso-mnt");1017 iso_path = read_cfg_var( g_mondo_cfg_file, "isodir");1081 iso_mnt = read_cfg_var(MINDI_CACHE"/mondorestore.cfg", "iso-mnt"); 1082 iso_path = read_cfg_var(MINDI_CACHE"/mondorestore.cfg", "isodir"); 1018 1083 mr_free(bkpinfo->isodir); 1019 1084 mr_asprintf(bkpinfo->isodir, "%s%s", iso_mnt, iso_path); … … 1036 1101 } 1037 1102 mr_free(g_isodir_device); 1038 g_isodir_device = read_cfg_var( g_mondo_cfg_file, "iso-dev");1103 g_isodir_device = read_cfg_var(MINDI_CACHE"/mondorestore.cfg", "iso-dev"); 1039 1104 log_msg(2, "isodir=%s; iso-dev=%s", bkpinfo->isodir, g_isodir_device); 1040 1105 … … 1081 1146 1082 1147 if (media_specified_by_user != none) { 1083 if ( g_restoring_live_from_cd) {1148 if (! bkpinfo->disaster_recovery) { 1084 1149 if (bkpinfo->backup_media_type != media_specified_by_user) { 1085 1150 log_msg(2, … … 1087 1152 interactively_obtain_media_parameters_from_user(FALSE); 1088 1153 media_specified_by_user = bkpinfo->backup_media_type; 1089 get_cfg_file_from_archive(); 1090 /* 1091 if (media_specified_by_user != cdr && media_specified_by_user == cdrw) 1092 { g_restoring_live_from_cd = FALSE; } 1093 */ 1154 get_cfg_file_from_initrd(); 1094 1155 } 1095 1156 } … … 1124 1185 struct s_node *filelist; 1125 1186 1126 /** add mallocs**/1127 1187 char *command = NULL; 1128 1188 char *tmp; … … 1130 1190 int res = 0; 1131 1191 pid_t pid; 1132 bool extract_mountlist_stub = FALSE;1133 1192 1134 1193 assert(bkpinfo != NULL); 1135 1194 malloc_string(tmp); 1136 1195 1137 /* If those files already exist, do not overwrite them later on */1138 if (does_file_exist("/"MOUNTLIST_FNAME_STUB)) {1139 extract_mountlist_stub = FALSE;1140 } else {1141 extract_mountlist_stub = TRUE;1142 }1143 1144 if (does_file_exist(g_filelist_full)1145 && does_file_exist(g_biggielist_txt)) {1146 log_msg(1, "%s exists", g_filelist_full);1147 log_msg(1, "%s exists", g_biggielist_txt);1148 log_msg(2,1149 "Filelist and biggielist already recovered from media. Yay!");1150 } else {1151 1196 getcwd(tmp, MAX_STR_LEN); 1152 1197 chdir(bkpinfo->tmpdir); 1153 1198 log_msg(1, "chdir(%s)", bkpinfo->tmpdir); 1154 1199 log_to_screen("Extracting filelist and biggielist from media..."); 1155 unlink("/tmp/filelist.full");1156 unlink(FILELIST_FULL_STUB);1157 1200 if (IS_THIS_A_STREAMING_BACKUP(bkpinfo->backup_media_type)) { 1158 mr_asprintf(command, "tar -b %ld -zxf %s . /%s ./%s ./%s ./%s ./%s", bkpinfo->internal_tape_block_size, bkpinfo->media_device, MOUNTLIST_FNAME_STUB, BIGGIELIST_TXT_STUB, FILELIST_FULL_STUB, IWANTMYLVM_STUB, MONDO_CFG_FILE_STUB);1201 mr_asprintf(command, "tar -b %ld -zxf %s ."MINDI_CACHE"/biggielist.txt ."MINDI_CACHE"/filelist.full.gz ."MINDI_CACHE"/i-want-my-lvm", bkpinfo->internal_tape_block_size, bkpinfo->media_device); 1159 1202 log_msg(1, "tarcommand = %s", command); 1160 1203 run_program_and_log_output(command, 1); 1161 1204 mr_free(command); 1162 1205 1163 if (!does_file_exist(FILELIST_FULL_STUB)) {1164 /* Doing that allow us to remain compatible with pre-2.2.5 versions */1165 log_msg(2, "pre-2.2.4 compatible mode on");1166 mr_asprintf(command, "tar -b %ld -zxf %s %s %s %s %s %s", bkpinfo->internal_tape_block_size, bkpinfo->media_device, MOUNTLIST_FNAME_STUB, BIGGIELIST_TXT_STUB, FILELIST_FULL_STUB, IWANTMYLVM_STUB, MONDO_CFG_FILE_STUB);1167 log_msg(1, "tarcommand = %s", command);1168 run_program_and_log_output(command, 1);1169 mr_free(command);1170 }1171 1206 } else { 1172 1207 log_msg(2, "Calling insist_on_this_cd_number; bkpinfo->isodir=%s", bkpinfo->isodir); … … 1174 1209 log_msg(2, "Back from iotcn"); 1175 1210 run_program_and_log_output("mount", 1); 1176 mr_asprintf(command, "tar -zxf %s/images/all.tar.gz ./%s ./%s ./%s ./%s ./%s", MNT_CDROM, MOUNTLIST_FNAME_STUB, BIGGIELIST_TXT_STUB, FILELIST_FULL_STUB, IWANTMYLVM_STUB, MONDO_CFG_FILE_STUB);1211 mr_asprintf(command, "tar -zxf "MNT_CDROM"/images/all.tar.gz ."MINDI_CACHE"/biggielist.txt ."MINDI_CACHE"/filelist.full.gz ."MINDI_CACHE"/i-want-my-lvm"); 1177 1212 1178 1213 log_msg(1, "tarcommand = %s", command); … … 1180 1215 mr_free(command); 1181 1216 1182 if (!does_file_exist(FILELIST_FULL_STUB)) { 1183 /* Doing that allow us to remain compatible with pre-2.2.5 versions */ 1184 log_msg(2, "pre-2.2.4 compatible mode on"); 1185 mr_asprintf(command, "tar -zxf %s/images/all.tar.gz %s %s %s %s %s", MNT_CDROM, MOUNTLIST_FNAME_STUB, BIGGIELIST_TXT_STUB, FILELIST_FULL_STUB, IWANTMYLVM_STUB, MONDO_CFG_FILE_STUB); 1186 1187 log_msg(1, "tarcommand = %s", command); 1188 run_program_and_log_output(command, 1); 1189 mr_free(command); 1190 } 1191 if (!does_file_exist(BIGGIELIST_TXT_STUB)) { 1192 fatal_error 1193 ("all.tar.gz did not include " BIGGIELIST_TXT_STUB); 1194 } 1195 if (!does_file_exist(FILELIST_FULL_STUB)) { 1196 fatal_error 1197 ("all.tar.gz did not include " FILELIST_FULL_STUB); 1198 } 1199 } 1200 mr_asprintf(command, "cp -f %s %s", MONDO_CFG_FILE_STUB, g_mondo_cfg_file); 1201 run_program_and_log_output(command, FALSE); 1202 mr_free(command); 1203 1204 mr_asprintf(command, "cp -f %s/%s %s", bkpinfo->tmpdir, BIGGIELIST_TXT_STUB, g_biggielist_txt); 1205 log_msg(1, "command = %s", command); 1206 paranoid_system(command); 1207 mr_free(command); 1208 1209 mr_asprintf(command, "ln -sf %s/%s %s", bkpinfo->tmpdir, FILELIST_FULL_STUB, g_filelist_full); 1210 log_msg(1, "command = %s", command); 1211 paranoid_system(command); 1212 mr_free(command); 1213 } 1214 1215 if (am_I_in_disaster_recovery_mode() 1216 && 1217 /* If it was there, do not overwrite it */ 1218 (extract_mountlist_stub) 1219 && 1220 ask_me_yes_or_no("Do you want to retrieve the mountlist as well?")) { 1221 mr_asprintf(command, "ln -sf %s/%s /tmp", MOUNTLIST_FNAME_STUB, bkpinfo->tmpdir); 1222 paranoid_system(command); 1223 mr_free(command); 1224 } 1225 1217 if (!does_file_exist(MINDI_CACHE"/biggielist.txt")) { 1218 fatal_error("all.tar.gz did not include "MINDI_CACHE"/biggielist.txt"); 1219 } 1220 if (!does_file_exist(MINDI_CACHE"/filelist.full.gz")) { 1221 fatal_error("all.tar.gz did not include "MINDI_CACHE"/filelist.full.gz"); 1222 } 1223 } 1226 1224 chdir(tmp); 1227 1228 if (!does_file_exist(g_biggielist_txt)) {1229 log_msg(1, "Warning - %s not found", g_biggielist_txt);1230 }1231 if (!does_file_exist(g_filelist_full)) {1232 log_msg(1, "Warning - %s does not exist", g_filelist_full);1233 }1234 // popup_and_OK("Wonderful.");1235 1225 1236 1226 log_msg(2, "Forking"); … … 1243 1233 case 0: 1244 1234 log_to_screen("Pre-processing filelist"); 1245 if (!does_file_exist(g_biggielist_txt)) { 1246 mr_asprintf(command, "echo -n > %s", g_biggielist_txt); 1247 paranoid_system(command); 1248 mr_free(command); 1249 } 1250 mr_asprintf(command, "grep -E '^/dev/.*' %s > %s", g_biggielist_txt, g_filelist_imagedevs); 1235 mr_asprintf(command, "grep -E '^/dev/.*' "MINDI_CACHE"/biggielist.txt > %s 2> /dev/null", g_filelist_imagedevs); 1251 1236 paranoid_system(command); 1252 1237 mr_free(command); … … 1264 1249 1265 1250 log_msg(3, "loading filelist"); 1266 filelist = load_filelist( g_filelist_full);1251 filelist = load_filelist(MINDI_CACHE"/filelist.full.gz"); 1267 1252 log_msg(3, "deleting original filelist"); 1268 unlink( g_filelist_full);1253 unlink(MINDI_CACHE"/filelist.full.gz"); 1269 1254 if (g_text_mode) { 1270 1255 printf("Restore which directory? --> "); … … 1288 1273 close_evalcall_form(); 1289 1274 1290 // NB: It's not necessary to add g_biggielist_txt to the filelist.full1275 // NB: It's not necessary to add biggielist.txt to the filelist.full 1291 1276 // file. The filelist.full file already contains the filename of EVERY 1292 1277 // file backed up - regular and biggie files. … … 1392 1377 backup_crucial_file(MNT_RESTORING, "/boot/grub/device.map"); 1393 1378 backup_crucial_file(MNT_RESTORING, "/etc/mtab"); 1394 device = read_cfg_var( g_mondo_cfg_file, "bootloader.device");1395 name = read_cfg_var( g_mondo_cfg_file, "bootloader.name");1379 device = read_cfg_var(MINDI_CACHE"/mondorestore.cfg", "bootloader.device"); 1380 name = read_cfg_var(MINDI_CACHE"/mondorestore.cfg", "bootloader.name"); 1396 1381 log_msg(2, "run_boot_loader: device='%s', name='%s'", device, name); 1397 1382 sync(); … … 1908 1893 assert(bkpinfo != NULL); 1909 1894 1910 malloc_string(g_biggielist_txt);1911 malloc_string(g_filelist_full);1912 1895 malloc_string(g_filelist_imagedevs); 1913 1896 malloc_string(g_imagedevs_restthese); 1914 malloc_string(g_mondo_cfg_file);1915 malloc_string(g_mountlist_fname);1916 1897 malloc_string(g_mondo_home); 1917 1898 1918 sprintf(g_biggielist_txt, "%s/%s", bkpinfo->tmpdir, BIGGIELIST_TXT_STUB);1919 sprintf(g_filelist_full, "%s/%s", bkpinfo->tmpdir, FILELIST_FULL_STUB);1920 1899 sprintf(g_filelist_imagedevs, "%s/tmp/filelist.imagedevs", bkpinfo->tmpdir); 1921 1900 sprintf(g_imagedevs_restthese, "%s/tmp/imagedevs.restore-these", bkpinfo->tmpdir); 1922 if (bkpinfo->disaster_recovery) { 1923 sprintf(g_mondo_cfg_file, "/%s", MONDO_CFG_FILE_STUB); 1924 sprintf(g_mountlist_fname, "/%s", MOUNTLIST_FNAME_STUB); 1925 } else { 1926 sprintf(g_mondo_cfg_file, "%s/%s", bkpinfo->tmpdir, MONDO_CFG_FILE_STUB); 1927 sprintf(g_mountlist_fname, "%s/%s", bkpinfo->tmpdir, MOUNTLIST_FNAME_STUB); 1901 if (! bkpinfo->disaster_recovery) { 1902 /* TODO: We need to get mondorestore.cfg and mountlist.txt from initrd.img */ 1903 get_cfg_file_from_initrd() 1928 1904 } 1929 1905 } … … 2127 2103 2128 2104 2129 /**2130 * Extract mondorestore.cfg and the mountlist from the tape inserted2131 * to the ./tmp/ directory.2132 * @param dev The tape device to read from.2133 * @return 0 for success, nonzero for failure.2134 */2135 int extract_cfg_file_and_mountlist_from_tape_dev(char *dev)2136 {2137 char *command = NULL;2138 int res = 0;2139 2140 if (bkpinfo->use_obdr) {2141 skip_obdr();2142 } else {2143 // BCO: below 32KB seems to block at least on RHAS 2.1 and MDK 10.02144 set_tape_block_size_with_mt(bkpinfo->internal_tape_block_size);2145 }2146 2147 mr_asprintf(command, "dd if=%s bs=%ld count=%ld 2> /dev/null | tar -zx ./%s ./%s ./%s ./%s ./%s", dev, bkpinfo->internal_tape_block_size, 1024L * 1024 * 32 / bkpinfo->internal_tape_block_size, MOUNTLIST_FNAME_STUB, MONDO_CFG_FILE_STUB, BIGGIELIST_TXT_STUB, FILELIST_FULL_STUB, IWANTMYLVM_STUB);2148 log_msg(2, "command = '%s'", command);2149 res = run_program_and_log_output(command, -1);2150 mr_free(command);2151 2152 if (res != 0) {2153 if (does_file_exist(MONDO_CFG_FILE_STUB)) {2154 res = 0;2155 } else {2156 /* Doing that allow us to remain compatible with pre-2.2.5 versions */2157 log_msg(2, "pre-2.2.4 compatible mode on");2158 mr_asprintf(command, "dd if=%s bs=%ld count=%ld 2> /dev/null | tar -zx %s %s %s %s %s", dev, bkpinfo->internal_tape_block_size, 1024L * 1024 * 32 / bkpinfo->internal_tape_block_size, MOUNTLIST_FNAME_STUB, MONDO_CFG_FILE_STUB, BIGGIELIST_TXT_STUB, FILELIST_FULL_STUB, IWANTMYLVM_STUB);2159 log_msg(2, "command = '%s'", command);2160 res = run_program_and_log_output(command, -1);2161 mr_free(command);2162 2163 if ((res != 0) && (does_file_exist(MONDO_CFG_FILE_STUB))) {2164 res = 0;2165 }2166 }2167 }2168 return (res);2169 }2170 2171 2172 2173 /**2174 * Get the configuration file from the floppy, tape, or CD.2175 * @param bkpinfo The backup information structure. Fields used:2176 * - @c bkpinfo->backup_media_type2177 * - @c bkpinfo->media_device2178 * - @c bkpinfo->tmpdir2179 * @return 0 for success, nonzero for failure.2180 */2181 int get_cfg_file_from_archive()2182 {2183 int retval = 0;2184 2185 /** malloc *****/2186 char *command = NULL;2187 char *cfg_file = NULL;2188 char *tmp = NULL;2189 char *tmp1 = NULL;2190 char *mountpt = NULL;2191 char *mountlist_file = NULL;2192 bool extract_mountlist_stub = FALSE;2193 bool extract_i_want_my_lvm = FALSE;2194 2195 bool try_plan_B;2196 2197 assert(bkpinfo != NULL);2198 log_msg(2, "gcffa --- starting");2199 log_to_screen("I'm thinking...");2200 mr_asprintf(mountpt, "%s/mount.bootdisk", bkpinfo->tmpdir);2201 chdir(bkpinfo->tmpdir);2202 mr_asprintf(cfg_file, "%s", MONDO_CFG_FILE_STUB);2203 unlink(cfg_file); // cfg_file[] is missing the '/' at the start, FYI, by intent2204 mr_free(cfg_file);2205 2206 unlink(FILELIST_FULL_STUB);2207 unlink(BIGGIELIST_TXT_STUB);2208 mr_asprintf(command, "mkdir -p %s", mountpt);2209 run_program_and_log_output(command, FALSE);2210 mr_free(command);2211 2212 mr_asprintf(cfg_file, "%s/%s", bkpinfo->tmpdir, MONDO_CFG_FILE_STUB);2213 mr_asprintf(mountlist_file, "%s/%s", bkpinfo->tmpdir, MOUNTLIST_FNAME_STUB);2214 log_msg(2, "mountpt = %s; cfg_file=%s", mountpt, cfg_file);2215 mr_free(mountpt);2216 2217 if (!does_file_exist(cfg_file)) {2218 log_msg(2, "gcffa --- we don't have cfg file yet.");2219 if (IS_THIS_A_STREAMING_BACKUP(bkpinfo->backup_media_type)) {2220 try_plan_B = TRUE;2221 } else {2222 log_msg(2, "gcffa --- calling mount_media now :)");2223 if (!mount_media()) {2224 log_msg(2,2225 "gcffa --- managed to mount CD; so, no need for Plan B");2226 try_plan_B = FALSE;2227 } else {2228 try_plan_B = TRUE;2229 }2230 if (what_number_cd_is_this() > 1) {2231 insist_on_this_cd_number((g_current_media_number = 1));2232 }2233 }2234 if (try_plan_B) {2235 log_msg(2, "gcffa --- OK, switching to Plan B");2236 chdir(bkpinfo->tmpdir);2237 run_program_and_log_output("mkdir -p tmp", FALSE);2238 2239 if (! bkpinfo->media_device) {2240 mr_asprintf(bkpinfo->media_device, "/dev/st0");2241 log_msg(2, "media_device is blank; assuming %s", bkpinfo->media_device);2242 }2243 mr_asprintf(tmp, "%s", bkpinfo->media_device);2244 if (extract_cfg_file_and_mountlist_from_tape_dev (bkpinfo->media_device)) {2245 mr_free(bkpinfo->media_device);2246 mr_asprintf(bkpinfo->media_device, "/dev/st0");2247 if (extract_cfg_file_and_mountlist_from_tape_dev (bkpinfo->media_device)) {2248 mr_free(bkpinfo->media_device);2249 mr_asprintf(bkpinfo->media_device, "/dev/osst0");2250 if (extract_cfg_file_and_mountlist_from_tape_dev (bkpinfo->media_device)) {2251 mr_free(bkpinfo->media_device);2252 mr_asprintf(bkpinfo->media_device, "/dev/ht0");2253 if (extract_cfg_file_and_mountlist_from_tape_dev (bkpinfo->media_device)) {2254 log_msg(3, "I tried lots of devices but none worked.");2255 mr_free(bkpinfo->media_device);2256 mr_asprintf(bkpinfo->media_device, "%s", tmp);2257 }2258 }2259 }2260 }2261 mr_free(tmp);2262 2263 if (!does_file_exist(MINDI_CACHE_REL"/mondorestore.cfg")) {2264 log_to_screen("Cannot find config info on media");2265 return (1);2266 }2267 } else {2268 if (does_file_exist("/"MOUNTLIST_FNAME_STUB)) {2269 extract_mountlist_stub = FALSE;2270 } else {2271 extract_mountlist_stub = TRUE;2272 }2273 if (does_file_exist("/"IWANTMYLVM_STUB)) {2274 extract_i_want_my_lvm = FALSE;2275 } else {2276 extract_i_want_my_lvm = TRUE;2277 }2278 2279 log_msg(2,2280 "gcffa --- Plan B, a.k.a. untarring some file from all.tar.gz");2281 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, IWANTMYLVM_STUB); // add -b TAPE_BLOCK_SIZE if you _really_ think it's necessary2282 run_program_and_log_output(command, TRUE);2283 mr_free(command);2284 2285 if (!does_file_exist(MONDO_CFG_FILE_STUB)) {2286 /* Doing that allow us to remain compatible with pre-2.2.5 versions */2287 log_msg(2, "pre-2.2.4 compatible mode on");2288 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, IWANTMYLVM_STUB); // add -b TAPE_BLOCK_SIZE if you _really_ think it's necessary2289 run_program_and_log_output(command, TRUE);2290 mr_free(command);2291 2292 if (!does_file_exist(MONDO_CFG_FILE_STUB)) {2293 fatal_error2294 ("Please reinsert the disk/CD and try again.");2295 }2296 }2297 }2298 }2299 if (does_file_exist(MONDO_CFG_FILE_STUB)) {2300 log_msg(1, "gcffa --- great! We've got the config file");2301 tmp = call_program_and_get_last_line_of_output("pwd");2302 mr_strcat(tmp, "/%s", MONDO_CFG_FILE_STUB);2303 mr_asprintf(command, "cp -f %s %s", tmp, cfg_file);2304 log_it("%s",command);2305 if (strcmp(tmp, cfg_file) && run_program_and_log_output(command, 1)) {2306 log_msg(1, "... but an error occurred when I tried to move it to %s", cfg_file);2307 } else {2308 log_msg(1, "... and I moved it successfully to %s", cfg_file);2309 }2310 mr_free(command);2311 2312 tmp1 = call_program_and_get_last_line_of_output("pwd");2313 mr_asprintf(command, "cp -f %s/%s %s", tmp1, MOUNTLIST_FNAME_STUB, mountlist_file);2314 mr_free(tmp1);2315 2316 log_it("%s",command);2317 if (extract_mountlist_stub) {2318 if (strcmp(tmp, cfg_file) && run_program_and_log_output(command, 1)) {2319 log_msg(1, "Failed to get mountlist");2320 } else {2321 log_msg(1, "Got mountlist too");2322 2323 mr_free(command);2324 mr_asprintf(command, "cp -f %s %s", mountlist_file, g_mountlist_fname);2325 if (run_program_and_log_output(command, 1)) {2326 log_msg(1, "Failed to copy mountlist to /tmp");2327 } else {2328 log_msg(1, "Copied mountlist to /tmp as well OK");2329 mr_free(command);2330 mr_asprintf(command, "cp -f %s /tmp/",IWANTMYLVM_STUB);2331 run_program_and_log_output(command, 1);2332 }2333 }2334 }2335 mr_free(tmp);2336 mr_free(command);2337 }2338 run_program_and_log_output("umount " MNT_CDROM, FALSE);2339 if (!does_file_exist(cfg_file)) {2340 log_it("%s",cfg_file);2341 log_msg(1, "%s not found", cfg_file);2342 log_to_screen2343 ("Oh dear. Unable to recover configuration file from boot disk");2344 return (1);2345 }2346 2347 log_to_screen("Recovered mondorestore.cfg");2348 if (!does_file_exist(MOUNTLIST_FNAME_STUB)) {2349 log_to_screen("...but not mountlist.txt - a pity, really...");2350 }2351 else {2352 /* Is this code really useful ??? */2353 if (extract_mountlist_stub) {2354 mr_asprintf(command, "cp -f %s %s/%s", MOUNTLIST_FNAME_STUB, bkpinfo->tmpdir, MOUNTLIST_FNAME_STUB);2355 run_program_and_log_output(command, FALSE);2356 mr_free(command);2357 }2358 }2359 2360 mr_asprintf(command, "cp -f %s /%s", cfg_file, MONDO_CFG_FILE_STUB);2361 mr_free(cfg_file);2362 2363 run_program_and_log_output(command, FALSE);2364 mr_free(command);2365 2366 if (extract_mountlist_stub) {2367 mr_asprintf(command, "cp -f %s /%s", mountlist_file, MOUNTLIST_FNAME_STUB);2368 run_program_and_log_output(command, FALSE);2369 mr_free(command);2370 }2371 mr_free(mountlist_file);2372 2373 mr_asprintf(command, "cp -f etc/raidtab /etc/");2374 run_program_and_log_output(command, FALSE);2375 mr_free(command);2376 2377 if (extract_i_want_my_lvm) {2378 mr_asprintf(command, "cp -f %s /tmp/",IWANTMYLVM_STUB);2379 run_program_and_log_output(command, FALSE);2380 mr_free(command);2381 }2382 g_backup_media_type = bkpinfo->backup_media_type;2383 return (retval);2384 }2385 2386 2105 /************************************************************************** 2387 2106 *END_GET_CFG_FILE_FROM_ARCHIVE * -
branches/2.2.10/mondo/src/mondorestore/mondo-rstr-tools.h
r1736 r2623 4 4 5 5 void free_global_filenames(); 6 void get_cfg_file_from_archive_or_bust();7 6 bool is_file_in_list(char *, char *, char *); /* needle, haystack, preamble */ 8 7 int iso_fiddly_bits(bool nuke_me_please); … … 31 30 void termination_in_progress(int); 32 31 int unmount_all_devices(struct mountlist_itself *); 33 int get_cfg_file_from_archive();34 32 void ask_about_these_imagedevs(char *infname, char *outfname); -
branches/2.2.10/mondo/src/mondorestore/mondorestore.c
r2508 r2623 79 79 80 80 /** 81 * The location of 'biggielist.txt', containing the biggiefiles on the current archive set.82 */83 char *g_biggielist_txt;84 85 /**86 81 * The location of 'filelist.full', containing all files (<em>including biggiefiles</em>) on 87 82 * the current archive set. … … 100 95 */ 101 96 char *g_imagedevs_restthese; 102 103 /**104 * The location of 'mondorestore.cfg', containing the metadata105 * information for this backup.106 */107 char *g_mondo_cfg_file;108 109 /**110 * The location of 'mountlist.txt', containing the information on the111 * user's partitions and hard drives.112 */113 char *g_mountlist_fname;114 97 115 98 /** … … 161 144 assert(mountlist != NULL); 162 145 assert(raidlist != NULL); 163 if (!bkpinfo->disaster_recovery) { 164 strcpy(g_mountlist_fname, MINDI_CACHE"/mountlist.txt"); 165 log_msg(2, "I guess you're testing edit_mountlist()"); 166 } 167 if (!does_file_exist(g_mountlist_fname)) { 168 log_to_screen(g_mountlist_fname); 169 log_to_screen("does not exist"); 146 if (!does_file_exist(MINDI_CACHE"/mountlist.txt")) { 147 log_to_screen(MINDI_CACHE"/mountlist.txt doesn't exist"); 170 148 return (1); 171 149 } 172 150 173 retval = load_mountlist(mountlist, g_mountlist_fname);151 retval = load_mountlist(mountlist, MINDI_CACHE"/mountlist.txt"); 174 152 load_raidtab_into_raidlist(raidlist, RAIDTAB_FNAME); 175 153 if (retval) { … … 177 155 ("Warning - load_raidtab_into_raidlist returned an error"); 178 156 } 179 res = edit_mountlist( g_mountlist_fname, mountlist, raidlist);157 res = edit_mountlist(MINDI_CACHE"/mountlist.txt", mountlist, raidlist); 180 158 if (res) { 181 159 return (1); 182 160 } 183 161 184 save_mountlist_to_disk(mountlist, g_mountlist_fname);162 save_mountlist_to_disk(mountlist, MINDI_CACHE"/mountlist.txt"); 185 163 save_raidlist_to_raidtab(raidlist, RAIDTAB_FNAME); 186 164 … … 466 444 467 445 log_it("About to load config file"); 468 get_cfg_file_from_archive_or_bust(); 469 read_cfg_file_into_bkpinfo(g_mondo_cfg_file); 446 read_cfg_file_into_bkpinfo(MINDI_CACHE"/mondorestore.cfg"); 470 447 log_it("Done loading config file; resizing ML"); 471 448 … … 481 458 log_it("About to edit mountlist"); 482 459 if (g_text_mode) { 483 save_mountlist_to_disk(mountlist, g_mountlist_fname);484 mr_asprintf(tmp1, "%s %s", find_my_editor(), g_mountlist_fname);460 save_mountlist_to_disk(mountlist, MINDI_CACHE"/mountlist.txt"); 461 mr_asprintf(tmp1, "%s %s", find_my_editor(), MINDI_CACHE"/mountlist.txt"); 485 462 res = system(tmp1); 486 463 mr_free(tmp1); 487 load_mountlist(mountlist, g_mountlist_fname);464 load_mountlist(mountlist, MINDI_CACHE"/mountlist.txt"); 488 465 } else { 489 res = edit_mountlist( g_mountlist_fname, mountlist, raidlist);466 res = edit_mountlist(MINDI_CACHE"/mountlist.txt", mountlist, raidlist); 490 467 } 491 468 log_it("Finished editing mountlist"); … … 494 471 } 495 472 log_msg(2, "Proceeding..."); 496 save_mountlist_to_disk(mountlist, g_mountlist_fname);473 save_mountlist_to_disk(mountlist, MINDI_CACHE"/mountlist.txt"); 497 474 save_raidlist_to_raidtab(raidlist, RAIDTAB_FNAME); 498 475 mvaddstr_and_log_it(1, 30, "Restoring Interactively"); … … 646 623 mr_asprintf(fstab_fname, "/tmp/fstab"); 647 624 } 648 mr_asprintf(tmp1, "label-partitions-as-necessary %s < %s >> %s 2>> %s", g_mountlist_fname, fstab_fname, MONDO_LOGFILE, MONDO_LOGFILE);625 mr_asprintf(tmp1, "label-partitions-as-necessary %s < %s >> %s 2>> %s", MINDI_CACHE"/mountlist.txt", fstab_fname, MONDO_LOGFILE, MONDO_LOGFILE); 649 626 mr_free(fstab_fname); 650 627 … … 762 739 763 740 log_msg(2, "nuke_mode --- starting"); 764 765 get_cfg_file_from_archive_or_bust(); 766 load_mountlist(mountlist, g_mountlist_fname); // in case read_cfg_file_into_bkpinfo updated the mountlist 741 load_mountlist(mountlist, MINDI_CACHE"/mountlist.txt"); // in case read_cfg_file_into_bkpinfo updated the mountlist 767 742 768 743 tmp = call_program_and_get_last_line_of_output("cat " CMDLINE); … … 788 763 } 789 764 790 save_mountlist_to_disk(mountlist, g_mountlist_fname);765 save_mountlist_to_disk(mountlist, MINDI_CACHE"/mountlist.txt"); 791 766 mvaddstr_and_log_it(1, 30, "Restoring Automatically"); 792 767 if (bkpinfo->differential) { … … 862 837 "Using tune2fs to identify your ext2,3 partitions"); 863 838 864 mr_asprintf(tmp, "label-partitions-as-necessary %s < /tmp/fstab", g_mountlist_fname);839 mr_asprintf(tmp, "label-partitions-as-necessary %s < /tmp/fstab", MINDI_CACHE"/mountlist.txt"); 865 840 res = run_program_and_log_output(tmp, TRUE); 866 841 mr_free(tmp); … … 927 902 mr_free(bkpinfo->restore_path); 928 903 mr_asprintf(bkpinfo->restore_path, "/"); 929 if ( !g_restoring_live_from_cd && !g_restoring_live_from_netfs) {904 if (bkpinfo->backup_media_type != netfs) { 930 905 popup_and_OK 931 906 ("Please insert tape/CD/USB Key, then hit 'OK' to continue."); 932 907 sleep(1); 933 }934 if (!g_restoring_live_from_netfs) {935 908 interactively_obtain_media_parameters_from_user(FALSE); 936 909 } … … 945 918 946 919 open_evalcall_form("Thinking..."); 947 948 get_cfg_file_from_archive_or_bust(); 949 read_cfg_file_into_bkpinfo(g_mondo_cfg_file); 950 load_mountlist(mountlist, g_mountlist_fname); // in case read_cfg_file_into_bkpinfo 920 read_cfg_file_into_bkpinfo(MINDI_CACHE"/mondorestore.cfg"); 921 load_mountlist(mountlist, MINDI_CACHE"/mountlist.txt"); // in case read_cfg_file_into_bkpinfo 951 922 952 923 close_evalcall_form(); 953 retval = load_mountlist(mountlist, g_mountlist_fname);924 retval = load_mountlist(mountlist, MINDI_CACHE"/mountlist.txt"); 954 925 load_raidtab_into_raidlist(raidlist, RAIDTAB_FNAME); 955 926 956 if ( !g_restoring_live_from_netfs&& (filelist = process_filelist_and_biggielist())) {927 if ((bkpinfo->backup_media_type != netfs) && (filelist = process_filelist_and_biggielist())) { 957 928 save_filelist(filelist, "/tmp/selected-files.txt"); 958 929 mr_asprintf(old_restpath, "%s", bkpinfo->restore_path); … … 1945 1916 } 1946 1917 1947 tmp1 = read_cfg_var( g_mondo_cfg_file, "total-slices");1918 tmp1 = read_cfg_var(MINDI_CACHE"/mondorestore.cfg", "total-slices"); 1948 1919 total_slices = atol(tmp1); 1949 1920 mr_free(tmp1); … … 2080 2051 } 2081 2052 insist_on_this_cd_number(g_current_media_number); 2082 tmp1 = read_cfg_var( g_mondo_cfg_file, "last-filelist-number");2053 tmp1 = read_cfg_var(MINDI_CACHE"/mondorestore.cfg", "last-filelist-number"); 2083 2054 max_val = atol(tmp1) + 1; 2084 2055 mr_free(tmp1); … … 2219 2190 assert(bkpinfo != NULL); 2220 2191 2221 tmp1 = read_cfg_var( g_mondo_cfg_file, "total-slices");2192 tmp1 = read_cfg_var(MINDI_CACHE"/mondorestore.cfg", "total-slices"); 2222 2193 total_slices = atol(tmp1); 2223 2194 mr_free(tmp1); … … 2375 2346 assert(bkpinfo != NULL); 2376 2347 mvaddstr_and_log_it(g_currentY, 0, "Restoring from archives"); 2377 tmp = read_cfg_var( g_mondo_cfg_file, "last-filelist-number");2348 tmp = read_cfg_var(MINDI_CACHE"/mondorestore.cfg", "last-filelist-number"); 2378 2349 max_val = atol(tmp) + 1; 2379 2350 mr_free(tmp); … … 2649 2620 g_kernel_version = get_kernel_version(); 2650 2621 2651 log_msg(1, "FYI - g_mountlist_fname = %s", g_mountlist_fname); 2652 if (strlen(g_mountlist_fname) < 3) { 2653 fatal_error("Serious error in malloc()'ing. Could be a bug in your glibc."); 2654 } 2622 log_msg(1, "FYI - mountlist = %s", MINDI_CACHE"/mountlist.txt"); 2655 2623 mkdir(MNT_CDROM, 0x770); 2656 2624 make_hole_for_dir(MONDO_CACHE); 2657 2625 2658 2626 /* Backup original mountlist.txt */ 2659 mr_asprintf(tmp, "%s.orig", g_mountlist_fname); 2660 if (!does_file_exist(g_mountlist_fname)) { 2661 log_msg(2, "%ld: Warning - g_mountlist_fname (%s) does not exist yet", __LINE__, g_mountlist_fname); 2662 } else if (!does_file_exist(tmp)) { 2663 mr_free(tmp); 2664 mr_asprintf(tmp, "cp -f %s %s.orig", g_mountlist_fname, g_mountlist_fname); 2665 run_program_and_log_output(tmp, FALSE); 2666 } 2627 mr_asprintf(tmp, "cp -f "MINDI_CACHE"/mountlist.txt "MINDI_CACHE"/mountlist.txt.orig"); 2628 run_program_and_log_output(tmp, FALSE); 2667 2629 mr_free(tmp); 2668 2630 … … 2694 2656 #endif 2695 2657 load_raidtab_into_raidlist(raidlist, RAIDTAB_FNAME); 2696 if (!does_file_exist(g_mountlist_fname)) {2697 strcpy(g_mountlist_fname, MINDI_CACHE"/mountlist.txt");2698 }2699 2658 res = let_user_edit_the_mountlist(mountlist, raidlist); 2700 2659 #ifdef __FreeBSD__ … … 2795 2754 log_msg(0, "Partitioning only."); 2796 2755 load_raidtab_into_raidlist(raidlist, RAIDTAB_FNAME); 2797 strcpy(g_mountlist_fname, MINDI_CACHE"/mountlist.txt"); 2798 load_mountlist(mountlist, g_mountlist_fname); 2756 load_mountlist(mountlist, MINDI_CACHE"/mountlist.txt"); 2799 2757 res = partition_everything(mountlist); 2800 2758 finish(res); … … 2804 2762 log_msg(0, "Formatting only."); 2805 2763 load_raidtab_into_raidlist(raidlist, RAIDTAB_FNAME); 2806 strcpy(g_mountlist_fname, MINDI_CACHE"/mountlist.txt");2807 load_mountlist(mountlist, g_mountlist_fname);2808 2764 res = format_everything(mountlist, FALSE, raidlist); 2809 2765 finish(res); … … 2813 2769 log_msg(0, "Stopping LVM and RAID"); 2814 2770 load_raidtab_into_raidlist(raidlist, RAIDTAB_FNAME); 2815 strcpy(g_mountlist_fname, MINDI_CACHE"/mountlist.txt"); 2816 load_mountlist(mountlist, g_mountlist_fname); 2771 load_mountlist(mountlist, MINDI_CACHE"/mountlist.txt"); 2817 2772 res = do_my_funky_lvm_stuff(TRUE, FALSE); 2818 2773 res += stop_all_raid_devices(mountlist); … … 2820 2775 } 2821 2776 2822 if ((argc > 1 && strcmp(argv[argc - 1], "--live-from-cd") == 0) && (!bkpinfo->disaster_recovery)) {2823 g_restoring_live_from_cd = TRUE;2824 }2825 2826 2777 // Handle params here first 2827 2778 handle_incoming_parameters(argc,argv); … … 2829 2780 if (!bkpinfo->disaster_recovery) { // live! 2830 2781 log_msg(1, "I am in normal, live mode."); 2831 log_msg(2, "FYI, MOUNTLIST_FNAME = %s", g_mountlist_fname);2832 2782 mount_boot_if_necessary(); /* for Gentoo users */ 2833 2783 log_msg(2, "Still here."); 2834 if (bkpinfo->backup_media_type == netfs) {2835 g_restoring_live_from_netfs = TRUE;2836 }2837 2784 /* Adding an initialisation in order to avoid to hndle NULL pointer later */ 2838 2785 mr_free(bkpinfo->restore_path); … … 2853 2800 /* Disaster recovery mode (must be) */ 2854 2801 log_msg(1, "I must be in disaster recovery mode."); 2855 log_msg(2, "FYI, MOUNTLIST_FNAME = %s ", g_mountlist_fname);2856 2802 2857 2803 log_it("About to call load_mountlist and load_raidtab"); 2858 2804 mr_free(bkpinfo->restore_path); 2859 2805 mr_asprintf(bkpinfo->restore_path, "%s", MNT_RESTORING); 2860 read_cfg_file_into_bkpinfo( g_mondo_cfg_file);2861 retval = load_mountlist(mountlist, g_mountlist_fname);2806 read_cfg_file_into_bkpinfo(MINDI_CACHE"/mondorestore.cfg"); 2807 retval = load_mountlist(mountlist, MINDI_CACHE"/mountlist.txt"); 2862 2808 retval += load_raidtab_into_raidlist(raidlist, RAIDTAB_FNAME); 2863 2809 log_it("Returned from calling load_mountlist and load_raidtab successfully"); … … 2865 2811 // BCO:To be reviewed 2866 2812 if ((bkpinfo->restore_mode == compare) || (bkpinfo->restore_mode == nuke)) { 2867 if ( bkpinfo->backup_media_type == netfs&& bkpinfo->netfs_mount && !is_this_device_mounted(bkpinfo->netfs_mount)) {2813 if ((bkpinfo->backup_media_type == netfs) && bkpinfo->netfs_mount && !is_this_device_mounted(bkpinfo->netfs_mount)) { 2868 2814 log_msg(1, "Mounting remote %s dir", bkpinfo->netfs_proto); 2869 2815 mr_free(bkpinfo->isodir); … … 3011 2957 3012 2958 unlink("/tmp/filelist.full"); 3013 unlink("/tmp/filelist.full.gz");3014 2959 3015 2960 exit(retval); -
branches/2.2.10/mondo/src/mondorestore/mr-externs.h
r2508 r2623 7 7 8 8 #define SIZE 730000 * 1024 /* Size for ISO's stops -1 */ 9 #define BIGGIELIST MNT_CDROM"/archives/biggielist.txt"10 9 #define ARCHIVES_PATH MNT_CDROM"/archives" 10 #define BIGGIELIST ARCHIVES_PATH"/biggielist.txt" 11 11 12 12 #ifdef __FreeBSD__ … … 91 91 mountlist_itself 92 92 *mountlist); 93 extern int get_cfg_file_from_archive();94 95 96 93 97 94 /************************************************************************** … … 106 103 extern FILE *g_tape_stream; 107 104 extern bool g_text_mode; 108 extern bool g_restoring_live_from_cd;109 extern bool g_restoring_live_from_netfs;110 105 extern int fput_string_one_char_at_a_time(FILE *, char *); 111 106 extern char *evaluate_mountlist(struct mountlist_itself *mountlist);
Note:
See TracChangeset
for help on using the changeset viewer.