Ignore:
Timestamp:
Jun 19, 2013, 8:34:46 AM (7 years ago)
Author:
Bruno Cornec
Message:
  • First pass on svn merge -r 2935:3146 ../3.0
File:
1 edited

Legend:

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

    r2937 r3147  
    8080char *incoming = NULL;
    8181char *question = NULL;
     82char *q;
    8283
    8384assert_string_is_neither_NULL_nor_zerolength(infname);
     
    209210if (is_this_device_mounted(g_isodir_device)) {
    210211    log_to_screen("WARNING - isodir is already mounted");
    211     already_mounted = TRUE;
    212212} else {
    213213    mr_asprintf(mount_isodir_command, "mount %s", g_isodir_device);
     
    10821082char *tmp;
    10831083char *tmp1 = NULL;
     1084char *q;
    10841085int res = 0;
    10851086pid_t pid;
     
    10881089malloc_string(tmp);
    10891090
    1090     getcwd(tmp, MAX_STR_LEN);
    1091     chdir(bkpinfo->tmpdir);
     1091    if (getcwd(tmp, MAX_STR_LEN) == NULL) {
     1092        // FIXME
     1093    }
     1094    if (chdir(bkpinfo->tmpdir)) {
     1095        // FIXME
     1096    }
    10921097    log_msg(1, "chdir(%s)", bkpinfo->tmpdir);
    10931098    log_to_screen("Extracting filelist and biggielist from media...");
     
    11161121        }
    11171122    }
    1118     chdir(tmp);
     1123    if (chdir(tmp)) {
     1124        // FIXME
     1125    }
    11191126
    11201127    log_msg(2, "Forking");
     
    11471154    unlink(MINDI_CACHE"/filelist.full.gz");
    11481155    if (g_text_mode) {
    1149         printf("Restore which directory? --> ");
    1150         mr_getline(tmp1, stdin);
    1151         toggle_path_selection(filelist, tmp1, TRUE);
    1152         if (strlen(tmp1) == 0) {
     1156        q = NULL;
     1157        while (q == NULL) {
     1158            printf("Restore which directory? --> ");
     1159            mr_getline(q, stdin);
     1160        }
     1161        toggle_path_selection(filelist, q, TRUE);
     1162        if (strlen(q) == 0) {
    11531163            res = 1;
    11541164        } else {
    11551165            res = 0;
    11561166        }
    1157         mr_free(tmp1);
     1167        mr_free(q);
    11581168    } else {
    11591169        res = edit_filelist(filelist);
     
    12291239            newtSuspend();
    12301240        }
    1231         (void)system("chroot " MNT_RESTORING);
     1241        paranoid_system("chroot " MNT_RESTORING);
    12321242        if (!g_text_mode) {
    12331243            newtResume();
     
    12711281    backup_crucial_file(MNT_RESTORING, "/boot/grub/menu.lst");
    12721282    backup_crucial_file(MNT_RESTORING, "/boot/grub/grub.cfg");
     1283    backup_crucial_file(MNT_RESTORING, "/boot/grub2/grub.cfg");
    12731284    backup_crucial_file(MNT_RESTORING, "/etc/lilo.conf");
    12741285    backup_crucial_file(MNT_RESTORING, "/etc/elilo.conf");
    12751286    backup_crucial_file(MNT_RESTORING, "/boot/grub/device.map");
     1287    backup_crucial_file(MNT_RESTORING, "/boot/grub2/device.map");
    12761288    backup_crucial_file(MNT_RESTORING, "/etc/mtab");
    12771289    device = read_cfg_var(MINDI_CACHE"/mondorestore.cfg", "bootloader.device");
     
    13851397    char *p = NULL;
    13861398
    1387     int res = 0;
    13881399    bool done;
     1400    int res = 0;        /*  FALSE */
     1401    bool mntlistchg = FALSE;
     1402    FILE *fin = NULL;
    13891403
    13901404    assert_string_is_neither_NULL_nor_zerolength(bd);
     
    13971411                            0,
    13981412                            "Modifying fstab, mtab, device.map and menu.lst/grub.cfg, and running GRUB...                             ");
     1413        /*  Did we changed the mountlist ? If yes, then force editing conf files */
     1414        if ((fin = fopen(MONDO_MNTLISTCHG, "r")) != NULL) {
     1415            mntlistchg = TRUE;
     1416        }
    13991417        for (done = FALSE; !done;) {
    14001418            p = popup_and_get_string("Boot device", "Please confirm/enter the boot device. If in doubt, try /dev/hda", boot_device);
     
    14061424                continue;
    14071425            }
    1408             mr_asprintf(command, "stabgrub-me %s", p);
    1409             mr_free(p);
    1410 
    1411             res = run_program_and_log_output(command, 1);
    1412             mr_free(command);
    1413 
    1414             if (res) {
     1426            /*  Only try to adapt grub here first if the mountlist wasn't changed before */
     1427            if (! mntlistchg) {
     1428                mr_asprintf(command, "stabgrub-me %s", p);
     1429                mr_free(p);
     1430
     1431                res = run_program_and_log_output(command, 1);
     1432                mr_free(command);
     1433            }
     1434
     1435            if ((res) || (mntlistchg)){
    14151436                popup_and_OK
    14161437                    ("GRUB installation failed. You will now edit fstab, mtab, device.map and menu.lst/grub.cfg in order to fix grub install");
     1438                } else {
     1439                    popup_and_OK("The mountlist was changed. You will now edit fstab, mtab, device.map and menu.lst/grub.cfg in order to fix grub install");
     1440                }
    14171441                if (!g_text_mode) {
    14181442                    newtSuspend();
     
    14261450                } else if (does_file_exist(MNT_RESTORING"/boot/grub/grub.cfg")) {
    14271451                    sprintf(tmp, "chroot %s %s /boot/grub/grub.cfg", MNT_RESTORING, editor);
     1452                } else if (does_file_exist(MNT_RESTORING"/boot/grub2/grub.cfg")) {
     1453                    sprintf(tmp, "chroot %s %s /boot/grub2/grub.cfg", MNT_RESTORING, editor);
    14281454                }
    14291455                paranoid_system(tmp);
    1430                 sprintf(tmp, "chroot %s %s /boot/grub/device.map", MNT_RESTORING, editor);
     1456                if (does_file_exist(MNT_RESTORING"/boot/grub/device.map")) {
     1457                    sprintf(tmp, "chroot %s %s /boot/grub/device.map", MNT_RESTORING, editor);
     1458                } else if (does_file_exist(MNT_RESTORING"/boot/grub2/device.map")) {
     1459                    sprintf(tmp, "chroot %s %s /boot/grub2/device.map", MNT_RESTORING, editor);
     1460                                }
    14311461                paranoid_system(tmp);
    14321462                if (!g_text_mode) {
     
    14391469                        ("GRUB installation failed. Please fix the conf files so that a manual install using 'grub-install' or similar command works. You are now chroot()'ed to your restored system. Please type 'exit' when you are done.");
    14401470                    newtSuspend();
    1441                     system("chroot " MNT_RESTORING);
     1471                    paranoid_system("chroot " MNT_RESTORING);
    14421472                    newtResume();
    14431473                    popup_and_OK("Thank you.");
     
    15011531                ("Because of bugs in GRUB's own installer, GRUB was not installed properly. Please install the boot loader manually now, using this chroot()'ed shell prompt. Type 'exit' when you have finished.");
    15021532            newtSuspend();
    1503             system("chroot " MNT_RESTORING);
     1533            paranoid_system("chroot " MNT_RESTORING);
    15041534            newtResume();
    15051535            popup_and_OK("Thank you.");
     
    18461876    FILE *fout;
    18471877    char *incoming = NULL;
     1878    char *q;
    18481879
    18491880    assert_string_is_neither_NULL_nor_zerolength(output_file);
     
    19351966                       "in preparation for the post-restoration reboot.",
    19361967                       "", mountlist->entries);
    1937     chdir("/");
     1968    if (chdir("/")) {
     1969        // FIXME
     1970    }
    19381971    for (i = 0;
    19391972         i < 10
     
    20322065/* @} - end restoreUtilityGroup */
    20332066
    2034 void wait_until_software_raids_are_prepped(char *mdstat_file,
    2035                                            int wait_for_percentage)
     2067void wait_until_software_raids_are_prepped(char *mdstat_file, int wait_for_percentage)
    20362068{
    20372069    struct raidlist_itself *raidlist;
    2038     int unfinished_mdstat_devices = 9999, i;
     2070    int unfinished_mdstat_devices = 9999;
     2071    int i = 0;
    20392072    char *screen_message = NULL;
    20402073
     
    20452078    while (unfinished_mdstat_devices > 0) {
    20462079            // FIXME: Prefix '/dev/' should really be dynamic!
    2047         if (parse_mdstat(raidlist, "/dev/")) {
     2080        if (parse_mdstat(MDSTAT_FILE, raidlist, "/dev/")) {
    20482081            log_to_screen("Sorry, cannot read %s", MDSTAT_FILE);
    20492082            log_msg(1,"Sorry, cannot read %s", MDSTAT_FILE);
    20502083            return;
    20512084        }
    2052         for (unfinished_mdstat_devices = i = 0; i <= raidlist->entries; i++) {
     2085        for (unfinished_mdstat_devices = 0; i <= raidlist->entries; i++) {
    20532086            if (raidlist->el[i].progress < wait_for_percentage) {
    20542087                unfinished_mdstat_devices++;
     
    20672100                    sleep(2);
    20682101                    // FIXME: Prefix '/dev/' should really be dynamic!
    2069                     if (parse_mdstat(raidlist, "/dev/")) {
     2102                    if (parse_mdstat(MDSTAT_FILE, raidlist, "/dev/")) {
    20702103                        break;
    20712104                    }
Note: See TracChangeset for help on using the changeset viewer.