Changeset 2334 in MondoRescue for branches/2.2.10/mondo/src/mondorestore/mondorestore.c
- Timestamp:
- Aug 18, 2009, 5:28:18 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2.2.10/mondo/src/mondorestore/mondorestore.c
r2331 r2334 443 443 char *p = NULL; 444 444 char *tmp1 = NULL; 445 char *fstab_fname ;445 char *fstab_fname = NULL; 446 446 char *old_restpath = NULL; 447 447 … … 453 453 454 454 malloc_string(tmp); 455 malloc_string(fstab_fname);456 455 assert(bkpinfo != NULL); 457 456 assert(mountlist != NULL); … … 640 639 "Using tune2fs to identify your ext2,3,4 partitions"); 641 640 if (does_file_exist("/tmp/fstab.new")) { 642 strcpy(fstab_fname, "/tmp/fstab.new");641 mr_asprintf(fstab_fname, "/tmp/fstab.new"); 643 642 } else { 644 strcpy(fstab_fname, "/tmp/fstab");643 mr_asprintf(fstab_fname, "/tmp/fstab"); 645 644 } 646 645 mr_asprintf(tmp1, "label-partitions-as-necessary %s < %s >> %s 2>> %s", g_mountlist_fname, fstab_fname, MONDO_LOGFILE, MONDO_LOGFILE); 646 mr_free(fstab_fname); 647 647 648 res = system(tmp1); 648 649 mr_free(tmp1); … … 665 666 end_of_func: 666 667 paranoid_free(tmp); 667 paranoid_free(fstab_fname);668 668 log_it("Leaving interactive_mode()"); 669 669 return (retval); … … 1018 1018 1019 1019 /** malloc ***/ 1020 char *checksum ;1020 char *checksum = NULL; 1021 1021 char *outfile_fname = NULL; 1022 1022 char *tmp = NULL; 1023 1023 char *bzip2_command = NULL; 1024 char *ntfsprog_command, *suffix; 1024 char *ntfsprog_command; 1025 char *suffix = NULL; 1025 1026 char *sz_devfile = NULL; 1026 1027 char *bigblk; 1027 char *p;1028 1028 char *mds = NULL; 1029 1029 int retval = 0; … … 1031 1031 long sliceno; 1032 1032 long siz; 1033 char ntfsprog_fifo[MAX_STR_LEN];1033 char *ntfsprog_fifo = NULL; 1034 1034 char *file_to_openout = NULL; 1035 1035 struct s_filename_and_lstat_info biggiestruct; … … 1045 1045 assert(bkpinfo != NULL); 1046 1046 1047 malloc_string(checksum);1048 1047 malloc_string(ntfsprog_command); 1049 malloc_string(suffix);1050 1048 1051 1049 pathname_of_last_file_restored[0] = '\0'; … … 1067 1065 paranoid_fclose(fin); 1068 1066 1069 strcpy(checksum, biggiestruct.checksum); 1070 1067 mr_asprintf(checksum, "%s", biggiestruct.checksum); 1071 1068 if (!checksum[0]) { 1072 1069 log_msg(3, "Warning - bigfile %ld does not have a checksum", bigfileno + 1); 1073 p = checksum;1074 }1070 } 1071 mr_free(checksum); 1075 1072 1076 1073 if (!strncmp(biggiestruct.filename, "/dev/", 5)) // Whether NTFS or not :) … … 1085 1082 node = find_string_at_node(filelist, biggiestruct.filename); 1086 1083 if (!node) { 1087 log_msg(0, "Skipping %s (name isn't in filelist)", 1088 biggiestruct.filename); 1084 log_msg(0, "Skipping %s (name isn't in filelist)", biggiestruct.filename); 1089 1085 pathname_of_last_file_restored[0] = '\0'; 1090 1086 return (0); 1091 1087 } else if (!(node->selected)) { 1092 log_msg(1, "Skipping %s (name isn't in biggielist subset)", 1093 biggiestruct.filename); 1088 log_msg(1, "Skipping %s (name isn't in biggielist subset)", biggiestruct.filename); 1094 1089 pathname_of_last_file_restored[0] = '\0'; 1095 1090 return (0); 1096 1091 } 1097 1092 } 1093 1098 1094 /* otherwise, continue */ 1099 1100 1095 log_msg(1, "DEFINITELY restoring %s", biggiestruct.filename); 1101 1096 if (biggiestruct.use_ntfsprog) { 1102 1097 if (strncmp(biggiestruct.filename, "/dev/", 5)) { 1103 log_msg(1, 1104 "I was in error when I set biggiestruct.use_ntfsprog to TRUE."); 1098 log_msg(1, "I was in error when I set biggiestruct.use_ntfsprog to TRUE."); 1105 1099 log_msg(1, "%s isn't even in /dev", biggiestruct.filename); 1106 1100 biggiestruct.use_ntfsprog = FALSE; … … 1109 1103 1110 1104 if (biggiestruct.use_ntfsprog) // if it's an NTFS device 1111 // if (!strncmp ( biggiestruct.filename, "/dev/", 5))1112 1105 { 1113 1106 g_loglevel = 4; … … 1116 1109 mr_asprintf(sz_devfile, "/tmp/%d.%d.000", (int) (random() % 32768), (int) (random() % 32768)); 1117 1110 mkfifo(sz_devfile, 0x770); 1118 strcpy(ntfsprog_fifo, sz_devfile);1111 mr_asprintf(ntfsprog_fifo, "%s", sz_devfile); 1119 1112 mr_free(sz_devfile); 1120 1113 file_to_openout = ntfsprog_fifo; … … 1123 1116 fatal_error("Fork failure"); 1124 1117 case 0: 1125 log_msg(3, 1126 "CHILD - fip - calling feed_outfrom_ntfsprog(%s, %s)", 1127 biggiestruct.filename, ntfsprog_fifo); 1128 res = 1129 feed_outfrom_ntfsprog(biggiestruct.filename, 1130 ntfsprog_fifo); 1131 // log_msg(3, "CHILD - fip - exiting"); 1118 log_msg(3, "CHILD - fip - calling feed_outfrom_ntfsprog(%s, %s)", biggiestruct.filename, ntfsprog_fifo); 1119 res = feed_outfrom_ntfsprog(biggiestruct.filename, ntfsprog_fifo); 1120 mr_free(ntfsprog_fifo); 1132 1121 exit(res); 1133 1122 break; 1134 1123 default: 1135 log_msg(3, 1136 "feed_into_ntfsprog() called in background --- pid=%ld", 1137 (long int) (pid)); 1138 } 1124 log_msg(3, "feed_into_ntfsprog() called in background --- pid=%ld", (long int) (pid)); 1125 } 1126 mr_free(ntfsprog_fifo); 1139 1127 } else { 1140 1128 use_ntfsprog_hack = FALSE; 1141 ntfsprog_fifo[0] = '\0';1142 1129 file_to_openout = outfile_fname; 1143 1130 if (!does_file_exist(outfile_fname)) // yes, it looks weird with the '!' but it's correct that way … … 1155 1142 */ 1156 1143 1157 strncpy(pathname_of_last_file_restored, biggiestruct.filename, 1158 MAX_STR_LEN - 1); 1144 strncpy(pathname_of_last_file_restored, biggiestruct.filename, MAX_STR_LEN - 1); 1159 1145 pathname_of_last_file_restored[MAX_STR_LEN - 1] = '\0'; 1160 1146 … … 1167 1153 1168 1154 for (sliceno = 1, finished = FALSE; !finished;) { 1169 if (!does_file_exist 1170 (slice_fname(bigfileno, sliceno, ARCHIVES_PATH, "")) 1171 && 1172 !does_file_exist(slice_fname 1173 (bigfileno, sliceno, ARCHIVES_PATH, "lzo")) 1174 && 1175 !does_file_exist(slice_fname 1176 (bigfileno, sliceno, ARCHIVES_PATH, "gz")) 1177 && 1178 !does_file_exist(slice_fname 1179 (bigfileno, sliceno, ARCHIVES_PATH, "bz2"))) { 1180 log_msg(3, 1181 "Cannot find a data slice or terminator slice on CD %d", 1182 g_current_media_number); 1155 if (!does_file_exist(slice_fname(bigfileno, sliceno, ARCHIVES_PATH, "")) && 1156 !does_file_exist(slice_fname(bigfileno, sliceno, ARCHIVES_PATH, "lzo")) && 1157 !does_file_exist(slice_fname(bigfileno, sliceno, ARCHIVES_PATH, "gz")) && 1158 !does_file_exist(slice_fname(bigfileno, sliceno, ARCHIVES_PATH, "bz2"))) { 1159 log_msg(3, "Cannot find a data slice or terminator slice on CD %d", g_current_media_number); 1183 1160 g_current_media_number++; 1184 1161 mds = media_descriptor_string(bkpinfo->backup_media_type); … … 1193 1170 mr_asprintf(tmp, "%s", slice_fname(bigfileno, sliceno, ARCHIVES_PATH, "")); 1194 1171 if (does_file_exist(tmp) && length_of_file(tmp) == 0) { 1195 log_msg(2, 1196 "End of bigfile # %ld (slice %ld is the terminator)", 1197 bigfileno + 1, sliceno); 1172 log_msg(2, "End of bigfile # %ld (slice %ld is the terminator)", bigfileno + 1, sliceno); 1198 1173 finished = TRUE; 1199 1174 mr_free(tmp); 1200 1175 continue; 1201 1176 } else { 1202 if (does_file_exist 1203 (slice_fname 1204 (bigfileno, sliceno, ARCHIVES_PATH, "lzo"))) { 1177 if (does_file_exist(slice_fname(bigfileno, sliceno, ARCHIVES_PATH, "lzo"))) { 1205 1178 mr_asprintf(bzip2_command, "lzop"); 1206 strcpy(suffix, "lzo");1179 mr_asprintf(suffix, "lzo"); 1207 1180 } else 1208 if (does_file_exist 1209 (slice_fname 1210 (bigfileno, sliceno, ARCHIVES_PATH, "gz"))) { 1181 if (does_file_exist(slice_fname(bigfileno, sliceno, ARCHIVES_PATH, "gz"))) { 1211 1182 mr_asprintf(bzip2_command, "gzip"); 1212 strcpy(suffix, "gz");1183 mr_asprintf(suffix, "gz"); 1213 1184 } else 1214 if (does_file_exist 1215 (slice_fname 1216 (bigfileno, sliceno, ARCHIVES_PATH, "bz2"))) { 1185 if (does_file_exist(slice_fname(bigfileno, sliceno, ARCHIVES_PATH, "bz2"))) { 1217 1186 mr_asprintf(bzip2_command, "bzip2"); 1218 strcpy(suffix, "bz2");1187 mr_asprintf(suffix, "bz2"); 1219 1188 } else 1220 if (does_file_exist 1221 (slice_fname 1222 (bigfileno, sliceno, ARCHIVES_PATH, ""))) { 1189 if (does_file_exist(slice_fname(bigfileno, sliceno, ARCHIVES_PATH, ""))) { 1223 1190 mr_asprintf(bzip2_command, ""); 1224 strcpy(suffix, "");1191 mr_asprintf(suffix, ""); 1225 1192 } else { 1226 1193 log_to_screen("OK, that's pretty fsck0red..."); … … 1235 1202 mr_asprintf(bzip2_command, "cat %s 2>> %s", slice_fname(bigfileno, sliceno, ARCHIVES_PATH, suffix), MONDO_LOGFILE); 1236 1203 } 1204 mr_free(suffix); 1205 1237 1206 mds = media_descriptor_string(bkpinfo->backup_media_type); 1238 1207 mr_asprintf(tmp, "Working on %s #%d, file #%ld, slice #%ld ", mds, g_current_media_number, bigfileno + 1, sliceno); … … 1288 1257 mr_free(outfile_fname); 1289 1258 paranoid_free(bigblk); 1290 paranoid_free(checksum);1291 1259 paranoid_free(ntfsprog_command); 1292 paranoid_free(suffix);1293 1260 1294 1261 return (retval); … … 1331 1298 char *ntfsprog_command; 1332 1299 char *sz_devfile = NULL; 1333 char *ntfsprog_fifo ;1300 char *ntfsprog_fifo = NULL; 1334 1301 char *file_to_openout = NULL; 1335 1302 … … 1350 1317 1351 1318 malloc_string(tmp); 1352 malloc_string(ntfsprog_fifo);1353 1319 malloc_string(ntfsprog_command); 1354 1320 old_loglevel = g_loglevel; … … 1407 1373 mr_asprintf(sz_devfile, "%s/%d.%d.000", bkpinfo->tmpdir, (int) (random() % 32768), (int) (random() % 32768)); 1408 1374 mkfifo(sz_devfile, 0x770); 1409 strcpy(ntfsprog_fifo, sz_devfile);1375 mr_asprintf(ntfsprog_fifo, "%s", sz_devfile); 1410 1376 mr_free(sz_devfile); 1411 1377 … … 1417 1383 log_msg(3, "CHILD - fip - calling feed_outfrom_ntfsprog(%s, %s)", outfile_fname, ntfsprog_fifo); 1418 1384 res = feed_outfrom_ntfsprog(outfile_fname, ntfsprog_fifo); 1385 mr_free(ntfsprog_fifo); 1419 1386 exit(res); 1420 1387 break; … … 1422 1389 log_msg(3, "feed_into_ntfsprog() called in background --- pid=%ld", (long int) (pid)); 1423 1390 } 1391 mr_free(ntfsprog_fifo); 1424 1392 } else { 1425 1393 if (!strncmp(orig_bf_fname, "/dev/", 5)) { … … 1431 1399 } 1432 1400 use_ntfsprog_hack = FALSE; 1433 ntfsprog_fifo[0] = '\0';1434 1401 file_to_openout = outfile_fname; 1435 1402 if (!does_file_exist(outfile_fname)) // yes, it looks weird with the '!' but it's correct that way … … 1539 1506 paranoid_free(tmp); 1540 1507 paranoid_free(ntfsprog_command); 1541 paranoid_free(ntfsprog_fifo);1542 1508 g_loglevel = old_loglevel; 1543 1509 return (retval); … … 2099 2065 char *tarball_fname = NULL; 2100 2066 char *progress_str = NULL; 2101 char *comment;2102 2103 malloc_string(comment);2104 2067 2105 2068 assert(bkpinfo != NULL); … … 2182 2145 mr_strcat(tmp1, " (%d attempts) - review logs", attempts); 2183 2146 } 2184 strcpy(comment, tmp1); 2147 if (attempts > 1) { 2148 log_to_screen(tmp1); 2149 } 2185 2150 mr_free(tmp1); 2186 if (attempts > 1) {2187 log_to_screen(comment);2188 }2189 2151 2190 2152 retval += res; … … 2203 2165 mvaddstr_and_log_it(g_currentY++, 74, "Done."); 2204 2166 } 2205 paranoid_free(comment);2206 2167 2207 2168 return (retval); … … 2633 2594 struct raidlist_itself *raidlist; 2634 2595 struct s_node *filelist; 2635 char *a, *b; 2596 char *tmp1 = NULL; 2597 char *tmp2 = NULL; 2636 2598 bool run_postnuke = FALSE; 2637 2599 … … 2663 2625 run_program_and_log_output("mkdir -p " MNT_CDROM, FALSE); 2664 2626 2665 malloc_string(a);2666 malloc_string(b);2667 2627 setup_MR_global_filenames(); // malloc() and set globals, using bkpinfo->tmpdir etc. 2668 2628 bkpinfo->backup_media_type = none; // in case boot disk was made for one backup type but user wants to restore from another backup type … … 2753 2713 toggle_path_selection(filelist, "/usr/share", TRUE); 2754 2714 save_filelist(filelist, "/tmp/out.txt"); 2755 strcpy(a, argv[3]); 2756 strcpy(b, argv[4]); 2757 2758 res = save_filelist_entries_in_common(a, filelist, b, FALSE); 2715 mr_asprintf(tmp1, "%s", argv[3]); 2716 mr_asprintf(tmp2, "%s", argv[4]); 2717 2718 res = save_filelist_entries_in_common(tmp1, filelist, tmp2, FALSE); 2719 mr_free(tmp1); 2720 mr_free(tmp2); 2721 2759 2722 free_filelist(filelist); 2760 2723 printf("res = %d", res); … … 3029 2992 paranoid_MR_finish(retval); // frees global stuff plus bkpinfo 3030 2993 free_libmondo_global_strings(); // it's fine to have this here :) really :) 3031 paranoid_free(a);3032 paranoid_free(b);3033 2994 3034 2995 unlink("/tmp/filelist.full");
Note:
See TracChangeset
for help on using the changeset viewer.