Ignore:
Timestamp:
Aug 18, 2009, 2:34:29 PM (15 years ago)
Author:
Bruno Cornec
Message:

r3327@localhost: bruno | 2009-08-04 00:17:46 +0200
popup_and_get_string and build_partition_name now return an allocated string

File:
1 edited

Legend:

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

    r2296 r2316  
    4242*/
    4343extern char *g_isodir_device;
    44 extern char *g_isodir_format;
    4544extern long g_current_progress, g_maximum_progress;
    4645extern char *g_biggielist_txt;  // where 'biggielist.txt' is stored, on ramdisk / tempdir;
     
    9695*/
    9796paranoid_free(g_isodir_device);
    98 paranoid_free(g_isodir_format);
    9997
    10098}
     
    264262    int retval = 0, i;
    265263    bool already_mounted = FALSE;
     264    char *isodir_format = NULL;
    266265
    267266assert(bkpinfo != NULL);
     
    281280}
    282281
    283 if (!get_isodir_info(g_isodir_device, g_isodir_format, bkpinfo->isodir, nuke_me_please)) {
     282if (!get_isodir_info(g_isodir_device, isodir_format, bkpinfo->isodir, nuke_me_please)) {
     283    mr_free(isodir_format);
    284284    return (1);
    285285}
     
    291291} else {
    292292    mr_asprintf(&mount_isodir_command, "mount %s", g_isodir_device);
    293     if (strlen(g_isodir_format) > 1) {
    294         mr_strcat(mount_isodir_command, " -t %s", g_isodir_format);
    295     }
     293    if (isodir_format) {
     294        mr_strcat(mount_isodir_command, " -t %s", isodir_format);
     295    }
     296
    296297    mr_strcat(mount_isodir_command, " -o ro %s", bkpinfo->isodir);
    297298    run_program_and_log_output("df -m", FALSE);
     
    308309    ("I have mounted the device where the ISO files are stored.");
    309310}
     311mr_free(isodir_format);
     312
    310313if (!IS_THIS_A_STREAMING_BACKUP(bkpinfo->backup_media_type)) {
    311314    mount_media();
     
    14261429  /** malloc **/
    14271430    char *command = NULL;
    1428     char *boot_device;
     1431    char *boot_device = NULL;
    14291432    char *rootdev;
    14301433    char *rootdrive;
     
    14321435    char *tmp = NULL;
    14331436    char *editor;
    1434 
    1435     int res;
    1436     int done;
    1437 
    1438     malloc_string(boot_device);
     1437    char *p = NULL;
     1438
     1439    int res = 0;
     1440    bool done;
     1441
    14391442    malloc_string(editor);
    14401443    malloc_string(rootdev);
     
    14431446    assert_string_is_neither_NULL_nor_zerolength(bd);
    14441447    strcpy(editor, find_my_editor());
    1445     strcpy(boot_device, bd);
     1448    mr_asprintf(&boot_device, "%s", bd);
    14461449
    14471450    if (offer_to_run_stabgrub
    1448         && ask_me_yes_or_no("Did you change the mountlist or cloned the system ?"))
     1451        && ask_me_yes_or_no("Did you change the mountlist or cloned the system ?")) {
    14491452        /* interactive mode */
    1450     {
    14511453        mvaddstr_and_log_it(g_currentY,
    14521454                            0,
    14531455                            "Modifying fstab, mtab, device.map and menu.lst, and running GRUB...                             ");
    14541456        for (done = FALSE; !done;) {
    1455             popup_and_get_string("Boot device",
    1456                                  "Please confirm/enter the boot device. If in doubt, try /dev/hda",
    1457                                  boot_device, MAX_STR_LEN / 4);
    1458             mr_asprintf(&command, "stabgrub-me %s", boot_device);
     1457            p = popup_and_get_string("Boot device", "Please confirm/enter the boot device. If in doubt, try /dev/hda", boot_device);
     1458            if (p == NULL) {
     1459                done = TRUE;
     1460                mr_free(p);
     1461                /* we want some warnings later on */
     1462                res = 1;
     1463                continue;
     1464            }
     1465            mr_asprintf(&command, "stabgrub-me %s", p);
     1466            mr_free(p);
     1467
    14591468            res = run_program_and_log_output(command, 1);
    14601469            mr_free(command);
     
    14941503            }
    14951504        }
    1496     } else
     1505    } else {
    14971506        /* nuke mode */
    1498     {
    14991507        if (!run_program_and_log_output("which grub-MR", FALSE)) {
    15001508            log_msg(1, "Yay! grub-MR found...");
     
    15211529        }
    15221530    }
     1531    mr_free(boot_device);
     1532
    15231533    if (res) {
    15241534        mvaddstr_and_log_it(g_currentY++, 74, "Failed.");
     
    15401550    paranoid_free(rootdrive);
    15411551    paranoid_free(conffile);
    1542     paranoid_free(boot_device);
    15431552    paranoid_free(editor);
    15441553
     
    17441753  /** malloc **/
    17451754    char *command = NULL;
    1746     char *boot_device;
     1755    char *boot_device = NULL;
    17471756    char *tmp = NULL;
    17481757    char *editor;
     1758    char *p = NULL;
    17491759    int res;
    17501760    int done;
    17511761
    1752     malloc_string(boot_device);
    17531762    malloc_string(editor);
    17541763    assert_string_is_neither_NULL_nor_zerolength(bd);
    17551764
    17561765    strcpy(editor, find_my_editor());
    1757     strcpy(boot_device, bd);
     1766    mr_asprintf(&boot_device, "%s", bd);
    17581767
    17591768    if (offer_to_hack_scripts
    1760         && ask_me_yes_or_no("Did you change the mountlist or cloned the system ?"))
     1769        && ask_me_yes_or_no("Did you change the mountlist or cloned the system ?")) {
    17611770        /* interactive mode */
    1762     {
    17631771        mvaddstr_and_log_it(g_currentY, 0,
    17641772                            "Modifying fstab and restoring MBR...                           ");
     
    17761784                }
    17771785            }
    1778             popup_and_get_string("Boot device",
    1779                                  "Please confirm/enter the boot device. If in doubt, try /dev/hda",
    1780                                  boot_device, MAX_STR_LEN / 4);
    1781             mr_asprintf(&command, "stabraw-me %s", boot_device);
     1786            p = popup_and_get_string("Boot device", "Please confirm/enter the boot device. If in doubt, try /dev/hda", boot_device);
     1787            if (p == NULL) {
     1788                done = TRUE;
     1789                mr_free(p);
     1790                /* we want some warnings later on */
     1791                res = 1;
     1792                continue;
     1793            }
     1794            mr_asprintf(&command, "stabraw-me %s", p);
     1795            mr_free(p);
     1796
    17821797            res = run_program_and_log_output(command, 3);
    17831798            mr_free(command);
     
    17891804            }
    17901805        }
    1791     } else
     1806    } else {
    17921807        /* nuke mode */
    1793     {
    17941808        mr_asprintf(&command, "raw-MR %s /tmp/mountlist.txt", boot_device);
    17951809        log_msg(2, "run_raw_mbr() --- command='%s'", command);
     
    18001814        mr_free(command);
    18011815    }
     1816    mr_free(boot_device);
    18021817
    18031818    if (res) {
     
    18081823        mvaddstr_and_log_it(g_currentY++, 74, "Done.");
    18091824    }
    1810     paranoid_free(boot_device);
    18111825    paranoid_free(editor);
    18121826    return (res);
     
    18391853    malloc_string(g_mondo_home);
    18401854    malloc_string(g_isodir_device);
    1841     malloc_string(g_isodir_format);
    18421855
    18431856    temppath = bkpinfo->tmpdir;
Note: See TracChangeset for help on using the changeset viewer.