Changeset 3158


Ignore:
Timestamp:
Jun 24, 2013, 10:20:16 AM (6 years ago)
Author:
bruno
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.
Location:
branches/3.0/mondo
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • branches/3.0/mondo/src/mondorestore/mondo-restore-EXT.h

    r2048 r3158  
    77extern bool g_ISO_restore_mode; /* are we in Iso Mode? */
    88extern bool g_I_have_just_nuked;
    9 extern char *g_isodir_device;
    10 extern char *g_isodir_format;
    119
    1210extern char *g_biggielist_txt;
  • branches/3.0/mondo/src/mondorestore/mondo-rstr-newt.c

    r3069 r3158  
    22662266
    22672267/**
    2268  * Get information about the location of ISO images from the user.
    2269  * @param isodir_device Where to put the device (e.g. /dev/hda4) the user enters.
    2270  * @param isodir_format Where to put the format (e.g. ext2) the user enters.
    2271  * @param isodir_path Where to put the path (e.g. /var/cache/mondo) the user enters.
    2272  * @param nuke_me_please Whether we're planning on nuking or not.
    2273  * @return TRUE if OK was pressed, FALSE otherwise.
    2274  */
    2275 bool
    2276 get_isodir_info(char *isodir_device, char *isodir_format,
    2277                 char *isodir_path, char *subdir_path, bool nuke_me_please)
    2278 {
    2279 
    2280     bool HDD = FALSE;
    2281     /** initialize ********************************************************/
    2282 
    2283     assert(isodir_device != NULL);
    2284     assert(isodir_format != NULL);
    2285     assert(isodir_path != NULL);
    2286 
    2287     log_it("isodir_path = %s", isodir_path);
    2288     isodir_format[0] = '\0';
    2289     if (isodir_device[0] == '\0') {
    2290         strcpy(isodir_device, "/dev/");
    2291     }
    2292     if (isodir_path[0] == '\0') {
    2293         strcpy(isodir_path, "/");
    2294     }
    2295     if (does_file_exist("/tmp/NETFS-SERVER-PATH")) {
    2296         strcpy(isodir_device, last_line_of_file("/tmp/NETFS-SERVER-MOUNT"));
    2297         strcpy(isodir_format, "netfs");
    2298         strcpy(isodir_path, last_line_of_file("/tmp/NETFS-SERVER-PATH"));
    2299     }
    2300     if (nuke_me_please) {
    2301         return (TRUE);
    2302     }
    2303 
    2304     if (popup_and_get_string
    2305         ("ISO Mode - device", "On what device do the ISO files live?",
    2306          isodir_device, MAX_STR_LEN / 4)) {
    2307         if (popup_and_get_string
    2308             ("ISO Mode - format",
    2309              "What is the disk format of the device? (Hit ENTER if you don't know.)",
    2310              isodir_format, 16)) {
    2311             if (popup_with_buttons("Are you restoring from an external hard drive ?", "Yes", "No")) {
    2312                 HDD = TRUE;
    2313             }
    2314             if (popup_and_get_string
    2315                 ("ISO Mode - path",
    2316                 "At what path on this device can the ISO files be found ?",
    2317                 isodir_path, MAX_STR_LEN / 4)) {
    2318                 strip_spaces(isodir_device);
    2319                 strip_spaces(isodir_format);
    2320                 strip_spaces(isodir_path);
    2321                 log_it("isodir_device = %s - isodir_format = %s - isodir_path = %s", isodir_device, isodir_format, isodir_path);
    2322                 if (HDD) {
    2323                     /*  We need an additional param */
    2324                     mr_asprintf(&subdir_path, "%s", isodir_path);
    2325                     strcpy(isodir_path, "/tmp/isodir");
    2326                 }
    2327                 return (TRUE);
    2328             }
    2329         }
    2330     }
    2331     return (FALSE);
    2332 }
    2333 
    2334 
    2335 /**
    23362268 * Create a new raidtab entry for @p device in @p raidlist.
    23372269 * @param raidlist The raidlist to add the device to.
  • branches/3.0/mondo/src/mondorestore/mondo-rstr-newt.h

    r2770 r3158  
    141141int find_next_free_index_in_disklist(struct list_of_disks *);
    142142int find_raid_device_in_raidlist(struct raidlist_itself *, char *);
    143 bool get_isodir_info(char *, char *, char *, char *, bool);
    144143void initiate_new_raidlist_entry(struct raidlist_itself *,
    145144                                 struct mountlist_itself *, int, char *);
  • 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;
  • branches/3.0/mondo/src/mondorestore/mondorestore.c

    r3145 r3158  
    7171 */
    7272bool g_I_have_just_nuked = FALSE;
    73 
    74 /**
    75  * The device to mount to get at the ISO images. Ignored unless @p g_ISO_restore_mode.
    76  */
    77 char *g_isodir_device;
    78 
    79 /**
    80  * The format of @p g_isodir_device. Ignored unless @p g_ISO_restore_mode.
    81  */
    82 char *g_isodir_format;
    8373
    8474/**
     
    294284    if (bkpinfo->backup_media_type == iso) {
    295285        if (iso_fiddly_bits((c == 'N') ? TRUE : FALSE)) {
    296             log_msg(2,
    297                     "catchall_mode --- iso_fiddly_bits returned w/ error");
     286            log_msg(2, "catchall_mode --- iso_fiddly_bits returned w/ error");
    298287            return (1);
    299288        } else {
  • branches/3.0/mondo/src/mondorestore/mr-externs.h

    r2770 r3158  
    3232extern void free_filelist(struct s_node *);
    3333extern long get_time(void);
    34 extern bool get_isodir_info(char *, char *, char *, char *, bool);
    3534extern void fatal_error(char *);
    3635extern void initialize_raid_record(struct raid_device_record *);
  • branches/3.0/mondo/test/test-mountlist.c

    r3141 r3158  
    3232bool g_ISO_restore_mode = FALSE;    /* are we in Iso Mode? */
    3333bool g_I_have_just_nuked = FALSE;
    34 char *g_isodir_device;
    35 char *g_isodir_format;
    3634char *g_biggielist_txt;
    3735char *g_filelist_full;
  • branches/3.0/mondo/test/test-truncname.c

    r3141 r3158  
    2828bool g_ISO_restore_mode = FALSE;    /* are we in Iso Mode? */
    2929bool g_I_have_just_nuked = FALSE;
    30 char *g_isodir_device;
    31 char *g_isodir_format;
    3230char *g_biggielist_txt;
    3331char *g_filelist_full;
Note: See TracChangeset for help on using the changeset viewer.