Changeset 3076 in MondoRescue
- Timestamp:
- Nov 24, 2012, 8:23:58 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/3.0/mondo/src/mondorestore/mondo-rstr-tools.c
r2982 r3076 119 119 char *incoming_ptr; 120 120 char *question_ptr; 121 char *q; 121 122 122 123 char incoming[MAX_STR_LEN] = "\0"; … … 128 129 incoming_ptr = malloc(sizeof(incoming)); 129 130 if (incoming_ptr == NULL) { 130 fprintf(stderr, "Out of Memory\n");131 exit(EXIT_FAILURE);131 fprintf(stderr, "Out of Memory\n"); 132 exit(EXIT_FAILURE); 132 133 } 133 134 134 135 question_ptr = malloc(sizeof(question)); 135 136 if (question_ptr == NULL) { 136 fprintf(stderr, "Out of Memory\n");137 exit(EXIT_FAILURE);137 fprintf(stderr, "Out of Memory\n"); 138 exit(EXIT_FAILURE); 138 139 } 139 140 … … 144 145 145 146 if (!(fin = fopen(infname, "r"))) { 146 fatal_error("Cannot openin infname");147 fatal_error("Cannot openin infname"); 147 148 } 148 149 if (!(fout = fopen(outfname, "w"))) { 149 fatal_error("Cannot openin outfname"); 150 } 151 for (fgets(incoming_ptr, MAX_STR_LEN, fin); 152 !feof(fin); fgets(incoming_ptr, MAX_STR_LEN, fin)) { 153 strip_spaces(incoming_ptr); 154 155 if (incoming[0] == '\0') { 156 continue; 157 } 158 159 sprintf(question_ptr, 160 "Should I restore the image of %s ?", incoming_ptr); 161 162 if (ask_me_yes_or_no(question_ptr)) { 163 fprintf(fout, "%s\n", incoming_ptr); 164 } 150 fatal_error("Cannot openin outfname"); 151 } 152 for (q = fgets(incoming_ptr, MAX_STR_LEN, fin); !feof(fin) && (q != NULL); q = fgets(incoming_ptr, MAX_STR_LEN, fin)) { 153 strip_spaces(incoming_ptr); 154 155 if (incoming[0] == '\0') { 156 continue; 157 } 158 159 sprintf(question_ptr, "Should I restore the image of %s ?", incoming_ptr); 160 161 if (ask_me_yes_or_no(question_ptr)) { 162 fprintf(fout, "%s\n", incoming_ptr); 163 } 165 164 } 166 165 … … 1005 1004 char *command; 1006 1005 char *tmp; 1006 char *q; 1007 1007 int res = 0; 1008 1008 pid_t pid; … … 1028 1028 } else { 1029 1029 getcwd(tmp, MAX_STR_LEN); 1030 chdir(bkpinfo->tmpdir); 1030 if (chdir(bkpinfo->tmpdir)) { 1031 // FIXME 1032 } 1031 1033 log_msg(1, "chdir(%s)", bkpinfo->tmpdir); 1032 1034 log_to_screen("Extracting filelist and biggielist from media..."); … … 1128 1130 } 1129 1131 1130 chdir(tmp); 1132 if (chdir(tmp)) { 1133 // FIXME 1134 } 1131 1135 1132 1136 if (!does_file_exist(g_biggielist_txt)) { … … 1171 1175 unlink(g_filelist_full); 1172 1176 if (g_text_mode) { 1173 printf("Restore which directory? --> "); 1174 fgets(tmp, sizeof(tmp), stdin); 1177 q = NULL; 1178 while (q == NULL) { 1179 printf("Restore which directory? --> "); 1180 q = fgets(tmp, sizeof(tmp), stdin); 1181 } 1175 1182 toggle_path_selection(filelist, tmp, TRUE); 1176 1183 if (strlen(tmp) == 0) { … … 1255 1262 newtSuspend(); 1256 1263 } 1257 (void)system("chroot " MNT_RESTORING);1264 paranoid_system("chroot " MNT_RESTORING); 1258 1265 if (!g_text_mode) { 1259 1266 newtResume(); … … 1312 1319 log_msg(2, tmp); 1313 1320 paranoid_free(tmp); 1314 system("sync");1321 paranoid_system("sync"); 1315 1322 1316 1323 offer_to_make_initrd(); … … 1489 1496 ("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."); 1490 1497 newtSuspend(); 1491 system("chroot " MNT_RESTORING);1498 paranoid_system("chroot " MNT_RESTORING); 1492 1499 newtResume(); 1493 1500 popup_and_OK("Thank you."); … … 1512 1519 ("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."); 1513 1520 newtSuspend(); 1514 system("chroot " MNT_RESTORING);1521 paranoid_system("chroot " MNT_RESTORING); 1515 1522 newtResume(); 1516 1523 popup_and_OK("Thank you."); … … 1872 1879 /** malloc **/ 1873 1880 char *incoming; 1881 char *q; 1874 1882 1875 1883 assert_string_is_neither_NULL_nor_zerolength(output_file); … … 1884 1892 fatal_error("cannot open output_file"); 1885 1893 } 1886 for ( fgets(incoming, MAX_STR_LEN - 1, fin); !feof(fin);1887 fgets(incoming, MAX_STR_LEN - 1, fin)) {1894 for (q = fgets(incoming, MAX_STR_LEN - 1, fin); !feof(fin) && (q != NULL); 1895 q = fgets(incoming, MAX_STR_LEN - 1, fin)) { 1888 1896 if (strncmp(incoming, "etc/adjtime", 11) 1889 1897 && strncmp(incoming, "etc/mtab", 8) … … 1964 1972 "in preparation for the post-restoration reboot.", 1965 1973 "", mountlist->entries); 1966 chdir("/"); 1974 if (chdir("/")) { 1975 // FIXME 1976 } 1967 1977 for (i = 0; 1968 1978 i < 10 … … 2153 2163 sprintf(mountpt, "%s/mount.bootdisk", bkpinfo->tmpdir); 2154 2164 device[0] = '\0'; 2155 chdir(bkpinfo->tmpdir); 2165 if (chdir(bkpinfo->tmpdir)) { 2166 // FIXME 2167 } 2156 2168 strcpy(cfg_file, MONDO_CFG_FILE_STUB); 2157 2169 unlink(cfg_file); // cfg_file[] is missing the '/' at the start, FYI, by intent … … 2186 2198 if (try_plan_B) { 2187 2199 log_msg(2, "gcffa --- OK, switching to Plan B"); 2188 chdir(bkpinfo->tmpdir); 2200 if (chdir(bkpinfo->tmpdir)) { 2201 // FIXME 2202 } 2189 2203 run_program_and_log_output("mkdir -p tmp", FALSE); 2190 2204
Note:
See TracChangeset
for help on using the changeset viewer.