Ignore:
Timestamp:
Jun 24, 2013, 10:20:16 AM (11 years ago)
Author:
Bruno Cornec
Message:
  • First attempt at fixing #628 by avoiding to erase choices done for varible bkpinfo->isodir and g_isodir_device in iso_fiddly_bits later in the code. Needs testing by people using external disks containing ISO.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/3.0/mondo/src/mondorestore/mondo-rstr-tools.c

    r3157 r3158  
    4141extern char *g_tmpfs_mountpt;
    4242*/
    43 extern char *g_isodir_device;
    44 extern char *g_isodir_format;
     43
     44/**
     45 * The device to mount to get at the ISO images. Ignored unless @p g_ISO_restore_mode.
     46 */
     47char *g_isodir_device;
     48
     49
     50/**
     51 * The format of @p g_isodir_device. Ignored unless @p g_ISO_restore_mode.
     52 */
     53char *g_isodir_format;
     54
    4555extern long g_current_progress, g_maximum_progress;
    4656extern char *g_biggielist_txt;  // where 'biggielist.txt' is stored, on ramdisk / tempdir;
     
    264274**************************************************************************/
    265275
     276/**
     277 * Get information about the location of ISO images from the user.
     278 * @param isodir_device Where to put the device (e.g. /dev/hda4) the user enters.
     279 * @param isodir_format Where to put the format (e.g. ext2) the user enters.
     280 * @param nuke_me_please Whether we're planning on nuking or not.
     281 * @return TRUE if OK was pressed, FALSE otherwise.
     282 */
     283bool
     284get_isodir_info(char *isodir_device, char *isodir_format,
     285                struct s_bkpinfo *bkpinfo, bool nuke_me_please)
     286{
     287
     288    bool HDD = FALSE;
     289    /** initialize ********************************************************/
     290
     291    assert(isodir_device != NULL);
     292    assert(isodir_format != NULL);
     293    assert(bkpinfo->isodir != NULL);
     294
     295    log_it("bkpinfo->isodir = %s", bkpinfo->isodir);
     296    isodir_format[0] = '\0';
     297    if (isodir_device[0] == '\0') {
     298        strcpy(isodir_device, "/dev/");
     299    }
     300    if (bkpinfo->isodir[0] == '\0') {
     301        strcpy(bkpinfo->isodir, "/");
     302    }
     303    if (does_file_exist("/tmp/NETFS-SERVER-PATH")) {
     304        strcpy(isodir_device, last_line_of_file("/tmp/NETFS-SERVER-MOUNT"));
     305        strcpy(isodir_format, "netfs");
     306        strcpy(bkpinfo->isodir, last_line_of_file("/tmp/NETFS-SERVER-PATH"));
     307    }
     308    if (nuke_me_please) {
     309        return (TRUE);
     310    }
     311
     312    if (popup_and_get_string
     313        ("ISO Mode - device", "On what device do the ISO files live?",
     314         isodir_device, MAX_STR_LEN / 4)) {
     315        if (popup_and_get_string
     316            ("ISO Mode - format",
     317             "What is the disk format of the device? (Hit ENTER if you don't know.)",
     318             isodir_format, 16)) {
     319            if (popup_with_buttons("Are you restoring from an external hard drive ?", "Yes", "No")) {
     320                HDD = TRUE;
     321            }
     322            if (popup_and_get_string
     323                ("ISO Mode - path",
     324                "At what path on this device can the ISO files be found ?",
     325                bkpinfo->isodir, MAX_STR_LEN / 4)) {
     326                strip_spaces(isodir_device);
     327                strip_spaces(isodir_format);
     328                strip_spaces(bkpinfo->isodir);
     329                log_it("isodir_device = %s - isodir_format = %s - bkpinfo->isodir = %s", isodir_device, isodir_format, bkpinfo->isodir);
     330                if (HDD) {
     331                    /*  We need an additional param */
     332                    mr_asprintf(&(bkpinfo->subdir), "%s", bkpinfo->isodir);
     333                    strcpy(bkpinfo->isodir, "/tmp/isodir");
     334                    log_it("Now bkpinfo->isodir = %s and subdir = ", bkpinfo->isodir, bkpinfo->subdir);
     335                }
     336                return (TRUE);
     337            }
     338        }
     339    }
     340    return (FALSE);
     341}
    266342
    267343
     
    299375}
    300376
    301 if (!get_isodir_info(g_isodir_device, g_isodir_format, bkpinfo->isodir, bkpinfo->subdir, nuke_me_please)) {
     377if (!get_isodir_info(g_isodir_device, g_isodir_format, bkpinfo, nuke_me_please)) {
    302378    return (1);
    303379}
     
    643719//  assert_string_is_neither_NULL_nor_zerolength(cfg_file);
    644720assert(bkpinfo != NULL);
     721log_it("Entering read_cfg_file_into_bkpinfo");
    645722
    646723if (!cfgf) {
     
    665742    bkpinfo->please_dont_eject = TRUE;
    666743} else if (!strcmp(value, "iso")) {
    667 
    668 // Patch by Conor Daly - 2004/07/12
    669744    bkpinfo->backup_media_type = iso;
    670745    if (am_I_in_disaster_recovery_mode()) {
    671746        /* Check to see if CD is already mounted before mounting it... */
    672747        if (!is_this_device_mounted("/dev/cdrom")) {
    673             log_msg(2,
    674                     "NB: CDROM device not mounted, mounting...");
    675             run_program_and_log_output("mount /dev/cdrom "
    676                                        MNT_CDROM, 1);
     748            log_msg(2, "NB: CDROM device not mounted, mounting...");
     749            run_program_and_log_output("mount /dev/cdrom " MNT_CDROM, 1);
    677750        }
    678751        if (does_file_exist(MNT_CDROM "/archives/filelist.0")) {
    679752            bkpinfo->backup_media_type = cdr;
    680753            run_program_and_log_output("umount -d " MNT_CDROM, 1);
    681             log_it
    682                 ("Re-jigging configuration AGAIN. CD-R, not ISO.");
     754            log_it("Re-jigging configuration AGAIN. CD-R, not ISO.");
    683755        }
    684756    }
    685757    if (read_cfg_var(cfg_file, "iso-prefix", value) == 0) {
    686             strcpy(bkpinfo->prefix,value);
     758        strcpy(bkpinfo->prefix,value);
    687759    } else {
    688             strcpy(bkpinfo->prefix,STD_PREFIX);
    689     }
     760        strcpy(bkpinfo->prefix,STD_PREFIX);
     761    }
     762    log_it("Setting Prefix to %s", bkpinfo->prefix);
    690763} else if ((!strcmp(value, "netfs")) || (!strcmp(value, "nfs"))) {
    691764    /* Stay compatible with previous versions by allowing nfs as an entry here */
     
    757830        strcpy(bkpinfo->media_device, "/dev/cdrom");    /* we don't really need this var */
    758831        bkpinfo->media_size = 1999 * 1024;  /* 650, probably, but we don't need this var anyway */
    759         log_msg(2, "Backup medium is CD-R[W]");
     832        log_msg(2, "Backup medium is similar to CD-R[W]");
    760833    }
    761834} else {
     
    843916
    844917read_cfg_var(g_mondo_cfg_file, "please-dont-eject", tmp);
    845 if (tmp[0]
    846 ||
    847 strstr(call_program_and_get_last_line_of_output
    848        ("cat /proc/cmdline"), "donteject")) {
    849 bkpinfo->please_dont_eject = TRUE;
    850 log_msg(2, "Ok, I shan't eject when restoring! Groovy.");
     918if (tmp[0] || strstr(call_program_and_get_last_line_of_output("cat /proc/cmdline"), "donteject")) {
     919    bkpinfo->please_dont_eject = TRUE;
     920    log_msg(2, "Ok, I shan't eject when restoring! Groovy.");
    851921}
    852922
     
    897967        strcpy(bkpinfo->isodir, old_isodir);
    898968    }
    899     if (!bkpinfo->disaster_recovery) {
     969    if ((!bkpinfo->disaster_recovery) || (g_isodir_device[0] != '\0')) {
    900970        if (strcmp(old_isodir, bkpinfo->isodir)) {
    901971            log_it
     
    905975        }
    906976    }
    907     read_cfg_var(g_mondo_cfg_file, "iso-dev", g_isodir_device);
    908     log_msg(2, "isodir=%s; iso-dev=%s", bkpinfo->isodir,
    909             g_isodir_device);
     977    if (g_isodir_device[0] == '\0') {
     978        /*  We don't want to loose our conf made earlier in iso_fiddly_bits
     979         *  so go here only if job not done already */
     980        read_cfg_var(g_mondo_cfg_file, "iso-dev", g_isodir_device);
     981    }
     982
     983    log_msg(2, "isodir=%s; iso-dev=%s", bkpinfo->isodir, g_isodir_device);
    910984    if (bkpinfo->disaster_recovery) {
    911985        if (is_this_device_mounted(g_isodir_device)) {
    912986            log_msg(2, "NB: isodir is already mounted");
    913987            /* Find out where it's mounted */
    914             sprintf(command,
    915                     "mount | grep -E '^%s' | tail -n1 | cut -d' ' -f3",
    916                     g_isodir_device);
     988            sprintf(command, "mount | grep -E '^%s' | tail -n1 | cut -d' ' -f3", g_isodir_device);
    917989            log_it("command = %s", command);
    918990            log_it("res of it = %s",
     
    9411013        }
    9421014        /* bkpinfo->isodir should now be the true path to prefix-1.iso etc... */
    943         if (bkpinfo->backup_media_type == iso) {
     1015        /*  except when already done is iso_fiddly_bits */
     1016        if ((bkpinfo->backup_media_type == iso) && (g_isodir_device[0] == '\0')) {
    9441017            sprintf(bkpinfo->isodir, "%s%s", iso_mnt, iso_path);
    9451018        }
     
    9501023    if (g_restoring_live_from_cd) {
    9511024        if (bkpinfo->backup_media_type != media_specified_by_user) {
    952             log_msg(2,
    953                     "bkpinfo->backup_media_type != media_specified_by_user, so I'd better ask :)");
     1025            log_msg(2, "bkpinfo->backup_media_type != media_specified_by_user, so I'd better ask :)");
    9541026            interactively_obtain_media_parameters_from_user(FALSE);
    9551027            media_specified_by_user = bkpinfo->backup_media_type;
Note: See TracChangeset for help on using the changeset viewer.