Changeset 3147 in MondoRescue for branches/3.1/mondo/src/mondorestore/mondo-rstr-tools.c
- Timestamp:
- Jun 19, 2013, 8:34:46 AM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/3.1/mondo/src/mondorestore/mondo-rstr-tools.c
r2937 r3147 80 80 char *incoming = NULL; 81 81 char *question = NULL; 82 char *q; 82 83 83 84 assert_string_is_neither_NULL_nor_zerolength(infname); … … 209 210 if (is_this_device_mounted(g_isodir_device)) { 210 211 log_to_screen("WARNING - isodir is already mounted"); 211 already_mounted = TRUE;212 212 } else { 213 213 mr_asprintf(mount_isodir_command, "mount %s", g_isodir_device); … … 1082 1082 char *tmp; 1083 1083 char *tmp1 = NULL; 1084 char *q; 1084 1085 int res = 0; 1085 1086 pid_t pid; … … 1088 1089 malloc_string(tmp); 1089 1090 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 } 1092 1097 log_msg(1, "chdir(%s)", bkpinfo->tmpdir); 1093 1098 log_to_screen("Extracting filelist and biggielist from media..."); … … 1116 1121 } 1117 1122 } 1118 chdir(tmp); 1123 if (chdir(tmp)) { 1124 // FIXME 1125 } 1119 1126 1120 1127 log_msg(2, "Forking"); … … 1147 1154 unlink(MINDI_CACHE"/filelist.full.gz"); 1148 1155 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) { 1153 1163 res = 1; 1154 1164 } else { 1155 1165 res = 0; 1156 1166 } 1157 mr_free( tmp1);1167 mr_free(q); 1158 1168 } else { 1159 1169 res = edit_filelist(filelist); … … 1229 1239 newtSuspend(); 1230 1240 } 1231 (void)system("chroot " MNT_RESTORING);1241 paranoid_system("chroot " MNT_RESTORING); 1232 1242 if (!g_text_mode) { 1233 1243 newtResume(); … … 1271 1281 backup_crucial_file(MNT_RESTORING, "/boot/grub/menu.lst"); 1272 1282 backup_crucial_file(MNT_RESTORING, "/boot/grub/grub.cfg"); 1283 backup_crucial_file(MNT_RESTORING, "/boot/grub2/grub.cfg"); 1273 1284 backup_crucial_file(MNT_RESTORING, "/etc/lilo.conf"); 1274 1285 backup_crucial_file(MNT_RESTORING, "/etc/elilo.conf"); 1275 1286 backup_crucial_file(MNT_RESTORING, "/boot/grub/device.map"); 1287 backup_crucial_file(MNT_RESTORING, "/boot/grub2/device.map"); 1276 1288 backup_crucial_file(MNT_RESTORING, "/etc/mtab"); 1277 1289 device = read_cfg_var(MINDI_CACHE"/mondorestore.cfg", "bootloader.device"); … … 1385 1397 char *p = NULL; 1386 1398 1387 int res = 0;1388 1399 bool done; 1400 int res = 0; /* FALSE */ 1401 bool mntlistchg = FALSE; 1402 FILE *fin = NULL; 1389 1403 1390 1404 assert_string_is_neither_NULL_nor_zerolength(bd); … … 1397 1411 0, 1398 1412 "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 } 1399 1417 for (done = FALSE; !done;) { 1400 1418 p = popup_and_get_string("Boot device", "Please confirm/enter the boot device. If in doubt, try /dev/hda", boot_device); … … 1406 1424 continue; 1407 1425 } 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)){ 1415 1436 popup_and_OK 1416 1437 ("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 } 1417 1441 if (!g_text_mode) { 1418 1442 newtSuspend(); … … 1426 1450 } else if (does_file_exist(MNT_RESTORING"/boot/grub/grub.cfg")) { 1427 1451 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); 1428 1454 } 1429 1455 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 } 1431 1461 paranoid_system(tmp); 1432 1462 if (!g_text_mode) { … … 1439 1469 ("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."); 1440 1470 newtSuspend(); 1441 system("chroot " MNT_RESTORING);1471 paranoid_system("chroot " MNT_RESTORING); 1442 1472 newtResume(); 1443 1473 popup_and_OK("Thank you."); … … 1501 1531 ("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."); 1502 1532 newtSuspend(); 1503 system("chroot " MNT_RESTORING);1533 paranoid_system("chroot " MNT_RESTORING); 1504 1534 newtResume(); 1505 1535 popup_and_OK("Thank you."); … … 1846 1876 FILE *fout; 1847 1877 char *incoming = NULL; 1878 char *q; 1848 1879 1849 1880 assert_string_is_neither_NULL_nor_zerolength(output_file); … … 1935 1966 "in preparation for the post-restoration reboot.", 1936 1967 "", mountlist->entries); 1937 chdir("/"); 1968 if (chdir("/")) { 1969 // FIXME 1970 } 1938 1971 for (i = 0; 1939 1972 i < 10 … … 2032 2065 /* @} - end restoreUtilityGroup */ 2033 2066 2034 void wait_until_software_raids_are_prepped(char *mdstat_file, 2035 int wait_for_percentage) 2067 void wait_until_software_raids_are_prepped(char *mdstat_file, int wait_for_percentage) 2036 2068 { 2037 2069 struct raidlist_itself *raidlist; 2038 int unfinished_mdstat_devices = 9999, i; 2070 int unfinished_mdstat_devices = 9999; 2071 int i = 0; 2039 2072 char *screen_message = NULL; 2040 2073 … … 2045 2078 while (unfinished_mdstat_devices > 0) { 2046 2079 // FIXME: Prefix '/dev/' should really be dynamic! 2047 if (parse_mdstat( raidlist, "/dev/")) {2080 if (parse_mdstat(MDSTAT_FILE, raidlist, "/dev/")) { 2048 2081 log_to_screen("Sorry, cannot read %s", MDSTAT_FILE); 2049 2082 log_msg(1,"Sorry, cannot read %s", MDSTAT_FILE); 2050 2083 return; 2051 2084 } 2052 for (unfinished_mdstat_devices = i =0; i <= raidlist->entries; i++) {2085 for (unfinished_mdstat_devices = 0; i <= raidlist->entries; i++) { 2053 2086 if (raidlist->el[i].progress < wait_for_percentage) { 2054 2087 unfinished_mdstat_devices++; … … 2067 2100 sleep(2); 2068 2101 // FIXME: Prefix '/dev/' should really be dynamic! 2069 if (parse_mdstat( raidlist, "/dev/")) {2102 if (parse_mdstat(MDSTAT_FILE, raidlist, "/dev/")) { 2070 2103 break; 2071 2104 }
Note:
See TracChangeset
for help on using the changeset viewer.