Changeset 2623 in MondoRescue for branches/2.2.10/mondo/src


Ignore:
Timestamp:
Apr 12, 2010, 3:23:24 PM (15 years ago)
Author:
Bruno Cornec
Message:

r3783@localhost: bruno | 2010-04-11 11:57:27 +0200

  • Use MINDI_CACHE for temp file communication between archive/restore
  • Remove some now useless globals in mondo
  • Remove function get_cfg_file_from_archive_or_bust and get_cfg_file_from_archive
  • Adds function get_cfg_file_from_initrd (Not finished)
  • Recovery doesn't work in that version atm (checkpoint version)
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  
    22032203    }
    22042204
    2205     mr_asprintf(command, "cp %s/biggielist.txt %s", bkpinfo->tmpdir,
    2206             biggielist);
    2207     paranoid_system(command);
    2208     mr_free(command);
    2209 
    22102205    mr_asprintf(blah, "biggielist = %s", biggielist);
    22112206    log_msg(2, blah);
  • branches/2.2.10/mondo/src/common/libmondo-devices.c

    r2588 r2623  
    5454 * @ingroup globalGroup
    5555 */
    56 bool g_restoring_live_from_cd = FALSE;
    57 bool g_restoring_live_from_netfs = FALSE;
    58 
    5956extern t_bkptype g_backup_media_type;   // set by main()
    6057
     
    25612558    // Tape, CD, NETFS, ...?
    25622559    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);
    25662561    if (bkpinfo->backup_media_type == none) {
    25672562        log_to_screen("User has chosen not to backup the PC");
  • branches/2.2.10/mondo/src/common/libmondo-filelist.c

    r2576 r2623  
    104104    estimate_noof_media_required(noof_sets);    // for cosmetic purposes
    105105
    106     mr_asprintf(tempfile, "%s/biggielist.txt", bkpinfo->tmpdir);
     106    mr_asprintf(tempfile, "%s/biggielist.txt", bkpinfo->scratchdir);
    107107    if (!(fout = fopen(tempfile, "a"))) {
    108108        log_OS_error("Cannot append to biggielist");
     
    237237    curr_set_size = 0;
    238238    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);
    240240    log_it("outfname=%s; biggie_fname=%s", outfname, biggie_fname);
    241241    if (!(fbig = fopen(biggie_fname, "w"))) {
     
    261261            i = 0;
    262262        }
    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         */
    270263        if (incoming[i] < 32) {
    271264            incoming[i] = '\0';
  • branches/2.2.10/mondo/src/common/libmondo-files.c

    r2569 r2623  
    754754
    755755    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);
    757757    log_it("biggielist = %s", biggielist);
    758758    fin = fopen(biggielist, "r");
  • branches/2.2.10/mondo/src/mondorestore/mondo-prep.c

    r2603 r2623  
    3535//static char cvsid[] = "$Id$";
    3636
    37 extern char *g_mountlist_fname;
    3837extern long g_current_progress, g_maximum_progress;
    3938
     
    7271// then zero & insist on reboot.
    7372    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 :)
    7574    {
    7675        drivelist = malloc(sizeof(struct list_of_disks));
     
    172171 */
    173172/**
    174  * Execute the commands in /tmp/i-want-my-lvm.
     173 * Execute the commands in MINDI_CACHE"i-want-my-lvm.
    175174 * These should probably be commands to set up LVM.
    176175 * @return The number of errors encountered (0 for success).
     
    221220    mr_free(tmp);
    222221
    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");
    225224        return (1);
    226225    }
     
    937936// do LVMs now
    938937    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")) {
    940939        wait_until_software_raids_are_prepped("/proc/mdstat", 100);
    941940        log_to_screen("Configuring LVM");
     
    18611860    log_msg(0, "Done.");
    18621861
    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 recently
    1867       }
    1868 */
    1869 
    18701862    open_progress_form("Partitioning devices",
    18711863                       "I am now going to partition all your drives.",
     
    24252417    assert(mountlist != NULL);
    24262418
    2427     if (g_mountlist_fname[0] == '\0') {
    2428         log_it
    2429             ("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     }
    24332419    log_it("Resizing mountlist");
    24342420    make_list_of_drives_in_mountlist(mountlist, drivelist);
  • branches/2.2.10/mondo/src/mondorestore/mondo-restore-EXT.h

    r2048 r2623  
    1010extern char *g_isodir_format;
    1111
    12 extern char *g_biggielist_txt;
    1312extern char *g_filelist_full;
    1413extern char *g_biggielist_pot;
     
    1817extern char *g_biggielist_restthese;
    1918extern char *g_imagedevs_restthese;
    20 extern char *g_mondo_cfg_file;
    21 extern char *g_mountlist_fname;
    2219extern char *g_mondo_home;
    2320
  • branches/2.2.10/mondo/src/mondorestore/mondo-rstr-compare.c

    r2508 r2623  
    1818/* Reference to global bkpinfo */
    1919extern struct s_bkpinfo *bkpinfo;
    20 
    21 extern char *g_mountlist_fname;
    2220
    2321//static char cvsid[] = "$Id$";
     
    352350    assert(bkpinfo != NULL);
    353351    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");
    355353    max_val = atol(tmp);
    356354    mr_free(tmp);
     
    523521
    524522  /**************************************************************************
    525    * also deletes tmp/filelist.full & tmp/biggielist.txt _and_ tries to     *
     523   * also deletes tmp/filelist.full & biggielist.txt _and_ tries to     *
    526524   * restore them from start of tape, if available                          *
    527525   **************************************************************************/
     
    530528    assert(raidlist != NULL);
    531529
    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");
    542531
    543532    /* edit_mountlist if wanted */
    544533    log_it("About to edit mountlist");
    545534    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");
    548537        res = system(tmp);
    549538        mr_free(tmp);
    550539
    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);
    554543    }
    555544    log_it("Finished editing mountlist");
     
    557546        paranoid_MR_finish(1);
    558547    }
    559     save_mountlist_to_disk(mountlist, g_mountlist_fname);
     548    save_mountlist_to_disk(mountlist, MINDI_CACHE"/mountlist.txt");
    560549    save_raidlist_to_raidtab(raidlist, RAIDTAB_FNAME);
    561550
  • branches/2.2.10/mondo/src/mondorestore/mondo-rstr-tools-EXT.h

    r2049 r2623  
    44
    55extern void free_MR_global_filenames();
    6 extern void get_cfg_file_from_archive_or_bust();
    76extern bool is_file_in_list(char *, char *, char *);    /* needle, haystack, preamble */
    87extern int iso_fiddly_bits(bool nuke_me_please);
     
    2827extern void termination_in_progress(int);
    2928extern int unmount_all_devices(struct mountlist_itself *);
    30 extern int get_cfg_file_from_archive();
    3129extern void ask_about_these_imagedevs(char *infname, char *outfname);
    3230
  • branches/2.2.10/mondo/src/mondorestore/mondo-rstr-tools.c

    r2607 r2623  
    1313#include "mondo-rstr-tools.h"
    1414
    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 stub
    36  */
    37 #define IWANTMYLVM_STUB "tmp/i-want-my-lvm"
    38 
    3915extern bool g_ISO_restore_mode; /* are we in Iso Mode? */
    4016extern bool g_I_have_just_nuked;
     
    4420extern char *g_isodir_device;
    4521extern 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 the
    48                   // backup media set in question
    49 extern char *g_filelist_full;   // filelist.full.gz is the list of all regular files
    50                   // (excluding big files) stored on the backup media set
    5122extern char *g_biggielist_pot;  // list of big files which _could_ be restored, if the
    5223                  // user chooses them
     
    5627extern char *g_imagedevs_restthese; // of the imagedevs listed in FILELIST_IMAGEDEVS,
    5728                      // restore only these
    58 extern char *g_mondo_cfg_file;  // where m*ndo-restore.cfg (the config file) is stored
    59 extern char *g_mountlist_fname; // where mountlist.txt (the mountlist file) is stored
    6029extern char *g_mondo_home;      // homedir of Mondo; usually /usr/local/share/mondo
    6130
     
    8554void free_MR_global_filenames(void)
    8655{
    87 paranoid_free(g_biggielist_txt);
    88 paranoid_free(g_filelist_full);
    8956paranoid_free(g_filelist_imagedevs);
    9057paranoid_free(g_imagedevs_restthese);
    91 paranoid_free(g_mondo_cfg_file);
    92 paranoid_free(g_mountlist_fname);
    9358paranoid_free(g_mondo_home);
    9459/*
     
    148113*ASK_ABOUT_THESE_IMAGEDEVS                                               *
    149114**************************************************************************/
    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 restoreUtilityGroup
    166 */
    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_no
    175     ("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 
    183115
    184116/**
     
    252184g_ISO_restore_mode = TRUE;
    253185mr_free(g_isodir_device);
    254 g_isodir_device = read_cfg_var(g_mondo_cfg_file, "iso-dev");
     186g_isodir_device = read_cfg_var(MINDI_CACHE"/mondorestore.cfg", "iso-dev");
    255187if (bkpinfo->disaster_recovery) {
    256188    /* Patch Conor Daly 26-june-2004
     
    272204    return (1);
    273205}
    274 paranoid_system("umount " MNT_CDROM " 2> /dev/null");   /* just in case */
     206paranoid_system("umount "MNT_CDROM" 2> /dev/null"); /* just in case */
    275207
    276208if (is_this_device_mounted(g_isodir_device)) {
     
    554486    }
    555487
    556     if (!run_program_and_log_output("mount | grep -F " MNT_CDROM, FALSE)) {
     488    if (!run_program_and_log_output("mount | grep -F "MNT_CDROM, FALSE)) {
    557489        log_msg(2, "mount_media() - media already mounted. Fair enough.");
    558490        return (0);
     
    579511        mr_free(mount_cmd);
    580512
    581         mr_asprintf(mount_cmd, "mount_cd9660 -r %s " MNT_CDROM, mddev);
     513        mr_asprintf(mount_cmd, "mount_cd9660 -r %s "MNT_CDROM, mddev);
    582514#else
    583515        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);
     
    673605**************************************************************************/
    674606
     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 */
     614int 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 */
     645int 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}
    675745
    676746
     
    700770//  assert_string_is_neither_NULL_nor_zerolength(cfg_file);
    701771assert(bkpinfo != NULL);
    702 
    703 if (!cfgf) {
    704     cfg_file = g_mondo_cfg_file;
    705 } else {
    706     cfg_file = cfgf;
    707 }
     772assert(cfgf != NULL);
    708773
    709774media_specified_by_user = bkpinfo->backup_media_type;   // or 'none', if not specified
     
    728793            if (!is_this_device_mounted("/dev/cdrom")) {
    729794                log_msg(2, "NB: CDROM device not mounted, mounting...");
    730                 run_program_and_log_output("mount /dev/cdrom " MNT_CDROM, 1);
    731             }
    732             if (does_file_exist(MNT_CDROM "/archives/filelist.0")) {
     795                run_program_and_log_output("mount /dev/cdrom "MNT_CDROM, 1);
     796            }
     797            if (does_file_exist(MNT_CDROM"/archives/filelist.0")) {
    733798                bkpinfo->backup_media_type = cdr;
    734                 run_program_and_log_output("umount " MNT_CDROM, 1);
     799                run_program_and_log_output("umount "MNT_CDROM, 1);
    735800                log_it
    736801                    ("Re-jigging configuration AGAIN. CD-R, not ISO.");
     
    9511016}
    9521017
    953 tmp = read_cfg_var(g_mondo_cfg_file, "please-dont-eject");
     1018tmp = read_cfg_var(MINDI_CACHE"/mondorestore.cfg", "please-dont-eject");
    9541019tmp1 = call_program_and_get_last_line_of_output("cat " CMDLINE);
    9551020if (tmp || strstr(tmp1, "donteject")) {
     
    9711036    } else {
    9721037        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");
    9741039
    9751040        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");
    9771042
    9781043        if (bkpinfo->netfs_mount != NULL) {
     
    10141079    */
    10151080    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");
    10181083    mr_free(bkpinfo->isodir);
    10191084    mr_asprintf(bkpinfo->isodir, "%s%s", iso_mnt, iso_path);
     
    10361101    }
    10371102    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");
    10391104    log_msg(2, "isodir=%s; iso-dev=%s", bkpinfo->isodir, g_isodir_device);
    10401105
     
    10811146
    10821147if (media_specified_by_user != none) {
    1083     if (g_restoring_live_from_cd) {
     1148    if (! bkpinfo->disaster_recovery) {
    10841149        if (bkpinfo->backup_media_type != media_specified_by_user) {
    10851150            log_msg(2,
     
    10871152            interactively_obtain_media_parameters_from_user(FALSE);
    10881153            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();
    10941155        }
    10951156    }
     
    11241185struct s_node *filelist;
    11251186
    1126 /** add mallocs**/
    11271187char *command = NULL;
    11281188char *tmp;
     
    11301190int res = 0;
    11311191pid_t pid;
    1132 bool extract_mountlist_stub = FALSE;
    11331192
    11341193assert(bkpinfo != NULL);
    11351194malloc_string(tmp);
    11361195
    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 {
    11511196    getcwd(tmp, MAX_STR_LEN);
    11521197    chdir(bkpinfo->tmpdir);
    11531198    log_msg(1, "chdir(%s)", bkpinfo->tmpdir);
    11541199    log_to_screen("Extracting filelist and biggielist from media...");
    1155     unlink("/tmp/filelist.full");
    1156     unlink(FILELIST_FULL_STUB);
    11571200    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);
    11591202        log_msg(1, "tarcommand = %s", command);
    11601203        run_program_and_log_output(command, 1);
    11611204        mr_free(command);
    11621205
    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         }
    11711206    } else {
    11721207        log_msg(2, "Calling insist_on_this_cd_number; bkpinfo->isodir=%s", bkpinfo->isodir);
     
    11741209        log_msg(2, "Back from iotcn");
    11751210        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");
    11771212
    11781213        log_msg(1, "tarcommand = %s", command);
     
    11801215        mr_free(command);
    11811216
    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    }
    12261224    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.");
    12351225
    12361226    log_msg(2, "Forking");
     
    12431233    case 0:
    12441234        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);
    12511236        paranoid_system(command);
    12521237        mr_free(command);
     
    12641249
    12651250    log_msg(3, "loading filelist");
    1266     filelist = load_filelist(g_filelist_full);
     1251    filelist = load_filelist(MINDI_CACHE"/filelist.full.gz");
    12671252    log_msg(3, "deleting original filelist");
    1268     unlink(g_filelist_full);
     1253    unlink(MINDI_CACHE"/filelist.full.gz");
    12691254    if (g_text_mode) {
    12701255        printf("Restore which directory? --> ");
     
    12881273    close_evalcall_form();
    12891274
    1290     // NB: It's not necessary to add g_biggielist_txt to the filelist.full
     1275    // NB: It's not necessary to add biggielist.txt to the filelist.full
    12911276    // file. The filelist.full file already contains the filename of EVERY
    12921277    // file backed up - regular and biggie files.
     
    13921377    backup_crucial_file(MNT_RESTORING, "/boot/grub/device.map");
    13931378    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");
    13961381    log_msg(2, "run_boot_loader: device='%s', name='%s'", device, name);
    13971382    sync();
     
    19081893    assert(bkpinfo != NULL);
    19091894
    1910     malloc_string(g_biggielist_txt);
    1911     malloc_string(g_filelist_full);
    19121895    malloc_string(g_filelist_imagedevs);
    19131896    malloc_string(g_imagedevs_restthese);
    1914     malloc_string(g_mondo_cfg_file);
    1915     malloc_string(g_mountlist_fname);
    19161897    malloc_string(g_mondo_home);
    19171898
    1918     sprintf(g_biggielist_txt, "%s/%s", bkpinfo->tmpdir, BIGGIELIST_TXT_STUB);
    1919     sprintf(g_filelist_full, "%s/%s", bkpinfo->tmpdir, FILELIST_FULL_STUB);
    19201899    sprintf(g_filelist_imagedevs, "%s/tmp/filelist.imagedevs", bkpinfo->tmpdir);
    19211900    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()
    19281904    }
    19291905}
     
    21272103
    21282104
    2129 /**
    2130  * Extract mondorestore.cfg and the mountlist from the tape inserted
    2131  * 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.0
    2144         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_type
    2177  * - @c bkpinfo->media_device
    2178  * - @c bkpinfo->tmpdir
    2179  * @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 intent
    2204     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 necessary
    2282                 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 necessary
    2289                     run_program_and_log_output(command, TRUE);
    2290                     mr_free(command);
    2291 
    2292                     if (!does_file_exist(MONDO_CFG_FILE_STUB)) {
    2293                         fatal_error
    2294                             ("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_screen
    2343             ("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 
    23862105/**************************************************************************
    23872106 *END_GET_CFG_FILE_FROM_ARCHIVE                                           *
  • branches/2.2.10/mondo/src/mondorestore/mondo-rstr-tools.h

    r1736 r2623  
    44
    55void free_global_filenames();
    6 void get_cfg_file_from_archive_or_bust();
    76bool is_file_in_list(char *, char *, char *);   /* needle, haystack, preamble */
    87int iso_fiddly_bits(bool nuke_me_please);
     
    3130void termination_in_progress(int);
    3231int unmount_all_devices(struct mountlist_itself *);
    33 int get_cfg_file_from_archive();
    3432void ask_about_these_imagedevs(char *infname, char *outfname);
  • branches/2.2.10/mondo/src/mondorestore/mondorestore.c

    r2508 r2623  
    7979
    8080/**
    81  * The location of 'biggielist.txt', containing the biggiefiles on the current archive set.
    82  */
    83 char *g_biggielist_txt;
    84 
    85 /**
    8681 * The location of 'filelist.full', containing all files (<em>including biggiefiles</em>) on
    8782 * the current archive set.
     
    10095 */
    10196char *g_imagedevs_restthese;
    102 
    103 /**
    104  * The location of 'mondorestore.cfg', containing the metadata
    105  * information for this backup.
    106  */
    107 char *g_mondo_cfg_file;
    108 
    109 /**
    110  * The location of 'mountlist.txt', containing the information on the
    111  * user's partitions and hard drives.
    112  */
    113 char *g_mountlist_fname;
    11497
    11598/**
     
    161144    assert(mountlist != NULL);
    162145    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");
    170148        return (1);
    171149    }
    172150
    173     retval = load_mountlist(mountlist, g_mountlist_fname);
     151    retval = load_mountlist(mountlist, MINDI_CACHE"/mountlist.txt");
    174152    load_raidtab_into_raidlist(raidlist, RAIDTAB_FNAME);
    175153    if (retval) {
     
    177155            ("Warning - load_raidtab_into_raidlist returned an error");
    178156    }
    179     res = edit_mountlist(g_mountlist_fname, mountlist, raidlist);
     157    res = edit_mountlist(MINDI_CACHE"/mountlist.txt", mountlist, raidlist);
    180158    if (res) {
    181159        return (1);
    182160    }
    183161
    184     save_mountlist_to_disk(mountlist, g_mountlist_fname);
     162    save_mountlist_to_disk(mountlist, MINDI_CACHE"/mountlist.txt");
    185163    save_raidlist_to_raidtab(raidlist, RAIDTAB_FNAME);
    186164
     
    466444
    467445    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");
    470447    log_it("Done loading config file; resizing ML");
    471448
     
    481458        log_it("About to edit mountlist");
    482459        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");
    485462            res = system(tmp1);
    486463            mr_free(tmp1);
    487             load_mountlist(mountlist, g_mountlist_fname);
     464            load_mountlist(mountlist, MINDI_CACHE"/mountlist.txt");
    488465        } else {
    489             res = edit_mountlist(g_mountlist_fname, mountlist, raidlist);
     466            res = edit_mountlist(MINDI_CACHE"/mountlist.txt", mountlist, raidlist);
    490467        }
    491468        log_it("Finished editing mountlist");
     
    494471        }
    495472        log_msg(2, "Proceeding...");
    496         save_mountlist_to_disk(mountlist, g_mountlist_fname);
     473        save_mountlist_to_disk(mountlist, MINDI_CACHE"/mountlist.txt");
    497474        save_raidlist_to_raidtab(raidlist, RAIDTAB_FNAME);
    498475        mvaddstr_and_log_it(1, 30, "Restoring Interactively");
     
    646623            mr_asprintf(fstab_fname, "/tmp/fstab");
    647624        }
    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);
    649626        mr_free(fstab_fname);
    650627
     
    762739
    763740    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
    767742
    768743    tmp = call_program_and_get_last_line_of_output("cat " CMDLINE);
     
    788763    }
    789764
    790     save_mountlist_to_disk(mountlist, g_mountlist_fname);
     765    save_mountlist_to_disk(mountlist, MINDI_CACHE"/mountlist.txt");
    791766    mvaddstr_and_log_it(1, 30, "Restoring Automatically");
    792767    if (bkpinfo->differential) {
     
    862837                        "Using tune2fs to identify your ext2,3 partitions");
    863838
    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");
    865840    res = run_program_and_log_output(tmp, TRUE);
    866841    mr_free(tmp);
     
    927902    mr_free(bkpinfo->restore_path);
    928903    mr_asprintf(bkpinfo->restore_path, "/");
    929     if (!g_restoring_live_from_cd && !g_restoring_live_from_netfs) {
     904    if (bkpinfo->backup_media_type != netfs) {
    930905        popup_and_OK
    931906            ("Please insert tape/CD/USB Key, then hit 'OK' to continue.");
    932907        sleep(1);
    933     }
    934     if (!g_restoring_live_from_netfs) {
    935908        interactively_obtain_media_parameters_from_user(FALSE);
    936909    }
     
    945918
    946919    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
    951922
    952923    close_evalcall_form();
    953     retval = load_mountlist(mountlist, g_mountlist_fname);
     924    retval = load_mountlist(mountlist, MINDI_CACHE"/mountlist.txt");
    954925    load_raidtab_into_raidlist(raidlist, RAIDTAB_FNAME);
    955926
    956     if (!g_restoring_live_from_netfs && (filelist = process_filelist_and_biggielist())) {
     927    if ((bkpinfo->backup_media_type != netfs) && (filelist = process_filelist_and_biggielist())) {
    957928        save_filelist(filelist, "/tmp/selected-files.txt");
    958929        mr_asprintf(old_restpath, "%s", bkpinfo->restore_path);
     
    19451916    }
    19461917
    1947     tmp1 = read_cfg_var(g_mondo_cfg_file, "total-slices");
     1918    tmp1 = read_cfg_var(MINDI_CACHE"/mondorestore.cfg", "total-slices");
    19481919    total_slices = atol(tmp1);
    19491920    mr_free(tmp1);
     
    20802051    }
    20812052    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");
    20832054    max_val = atol(tmp1) + 1;
    20842055    mr_free(tmp1);
     
    22192190    assert(bkpinfo != NULL);
    22202191
    2221     tmp1 = read_cfg_var(g_mondo_cfg_file, "total-slices");
     2192    tmp1 = read_cfg_var(MINDI_CACHE"/mondorestore.cfg", "total-slices");
    22222193    total_slices = atol(tmp1);
    22232194    mr_free(tmp1);
     
    23752346    assert(bkpinfo != NULL);
    23762347    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");
    23782349    max_val = atol(tmp) + 1;
    23792350    mr_free(tmp);
     
    26492620    g_kernel_version = get_kernel_version();
    26502621
    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");
    26552623    mkdir(MNT_CDROM, 0x770);
    26562624    make_hole_for_dir(MONDO_CACHE);
    26572625
    26582626    /* 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);
    26672629    mr_free(tmp);
    26682630
     
    26942656#endif
    26952657        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         }
    26992658        res = let_user_edit_the_mountlist(mountlist, raidlist);
    27002659#ifdef __FreeBSD__
     
    27952754        log_msg(0, "Partitioning only.");
    27962755        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");
    27992757        res = partition_everything(mountlist);
    28002758        finish(res);
     
    28042762        log_msg(0, "Formatting only.");
    28052763        load_raidtab_into_raidlist(raidlist, RAIDTAB_FNAME);
    2806         strcpy(g_mountlist_fname, MINDI_CACHE"/mountlist.txt");
    2807         load_mountlist(mountlist, g_mountlist_fname);
    28082764        res = format_everything(mountlist, FALSE, raidlist);
    28092765        finish(res);
     
    28132769        log_msg(0, "Stopping LVM and RAID");
    28142770        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");
    28172772        res = do_my_funky_lvm_stuff(TRUE, FALSE);
    28182773        res += stop_all_raid_devices(mountlist);
     
    28202775    }
    28212776
    2822     if ((argc > 1 && strcmp(argv[argc - 1], "--live-from-cd") == 0) && (!bkpinfo->disaster_recovery)) {
    2823         g_restoring_live_from_cd = TRUE;
    2824     }
    2825 
    28262777    // Handle params here first
    28272778    handle_incoming_parameters(argc,argv);
     
    28292780    if (!bkpinfo->disaster_recovery) {  // live!
    28302781        log_msg(1, "I am in normal, live mode.");
    2831         log_msg(2, "FYI, MOUNTLIST_FNAME = %s", g_mountlist_fname);
    28322782        mount_boot_if_necessary();  /* for Gentoo users */
    28332783        log_msg(2, "Still here.");
    2834         if (bkpinfo->backup_media_type == netfs) {
    2835             g_restoring_live_from_netfs = TRUE;
    2836         }
    28372784        /* Adding an initialisation in order to avoid to hndle NULL pointer later */
    28382785        mr_free(bkpinfo->restore_path);
     
    28532800        /* Disaster recovery mode (must be) */
    28542801        log_msg(1, "I must be in disaster recovery mode.");
    2855         log_msg(2, "FYI, MOUNTLIST_FNAME = %s ", g_mountlist_fname);
    28562802
    28572803        log_it("About to call load_mountlist and load_raidtab");
    28582804        mr_free(bkpinfo->restore_path);
    28592805        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");
    28622808        retval += load_raidtab_into_raidlist(raidlist, RAIDTAB_FNAME);
    28632809        log_it("Returned from calling load_mountlist and load_raidtab successfully");
     
    28652811        // BCO:To be reviewed
    28662812        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)) {
    28682814                log_msg(1, "Mounting remote %s dir", bkpinfo->netfs_proto);
    28692815                mr_free(bkpinfo->isodir);
     
    30112957
    30122958    unlink("/tmp/filelist.full");
    3013     unlink("/tmp/filelist.full.gz");
    30142959
    30152960    exit(retval);
  • branches/2.2.10/mondo/src/mondorestore/mr-externs.h

    r2508 r2623  
    77
    88#define SIZE 730000 * 1024      /*  Size for ISO's stops -1 */
    9 #define BIGGIELIST MNT_CDROM"/archives/biggielist.txt"
    109#define ARCHIVES_PATH MNT_CDROM"/archives"
     10#define BIGGIELIST ARCHIVES_PATH"/biggielist.txt"
    1111
    1212#ifdef __FreeBSD__
     
    9191                                                                mountlist_itself
    9292                                                                *mountlist);
    93 extern int get_cfg_file_from_archive();
    94 
    95 
    9693
    9794/**************************************************************************
     
    106103extern FILE *g_tape_stream;
    107104extern bool g_text_mode;
    108 extern bool g_restoring_live_from_cd;
    109 extern bool g_restoring_live_from_netfs;
    110105extern int fput_string_one_char_at_a_time(FILE *, char *);
    111106extern char *evaluate_mountlist(struct mountlist_itself *mountlist);
Note: See TracChangeset for help on using the changeset viewer.