Changeset 900 in MondoRescue for trunk/mondo/src/mondorestore/mondo-rstr-compare.c
- Timestamp:
- Oct 24, 2006, 8:49:18 AM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/mondo/src/mondorestore/mondo-rstr-compare.c
r783 r900 14 14 #include <pthread.h> 15 15 #endif 16 #include "mr_mem.h" 16 17 17 18 void popup_changelist_from_file(char *); … … 61 62 } 62 63 if (!(fin = fopen(tmp1, "r"))) { 63 asprintf(&tmp, _("Cannot open bigfile %ld (%s)'s info file"),64 mr_asprintf(&tmp, _("Cannot open bigfile %ld (%s)'s info file"), 64 65 bigfileno + 1, tmp); 65 66 log_to_screen(tmp); 66 paranoid_free(tmp);67 paranoid_free(tmp1);67 mr_free(tmp); 68 mr_free(tmp1); 68 69 return (1); 69 70 } 70 paranoid_free(tmp1);71 mr_free(tmp1); 71 72 72 73 fread((void *) &biggiestruct, 1, sizeof(biggiestruct), fin); 73 74 paranoid_fclose(fin); 74 75 75 asprintf(&checksum, biggiestruct.checksum);76 asprintf(&bigfile_fname, biggiestruct.filename);76 mr_asprintf(&checksum, biggiestruct.checksum); 77 mr_asprintf(&bigfile_fname, biggiestruct.filename); 77 78 78 79 log_msg(2, "biggiestruct.filename = %s", bigfile_fname); … … 80 81 81 82 if (!g_text_mode) { 82 asprintf(&tmp, _("Comparing %s"), bigfile_fname);83 mr_asprintf(&tmp, _("Comparing %s"), bigfile_fname); 83 84 newtDrawRootText(0, 22, tmp); 84 85 newtRefresh(); 85 paranoid_free(tmp);86 mr_free(tmp); 86 87 } 87 88 /* BERLIOS: Useless ? … … 93 94 return(0); 94 95 } else { 95 asprintf(&command,96 mr_asprintf(&command, 96 97 "md5sum \"%s%s\" > /tmp/md5sum.txt 2> /tmp/errors.txt", 97 98 MNT_RESTORING, bigfile_fname); … … 101 102 if (system(command)) { 102 103 log_OS_error("Warning - command failed"); 103 paranoid_free(command);104 paranoid_free(bigfile_fname);104 mr_free(command); 105 mr_free(bigfile_fname); 105 106 return (1); 106 107 } else { 107 paranoid_free(command);108 mr_free(command); 108 109 if (!(fin = fopen("/tmp/md5sum.txt", "r"))) { 109 110 log_msg(2, "Unable to open /tmp/md5sum.txt; can't get live checksum"); 110 paranoid_free(bigfile_fname);111 mr_free(bigfile_fname); 111 112 return (1); 112 113 } else { 113 getline(&original_cksum, &n, fin);114 mr_getline(&original_cksum, &n, fin); 114 115 paranoid_fclose(fin); 115 116 for (i = strlen(original_cksum); … … 128 129 retval++; 129 130 } 130 paranoid_free(original_cksum);131 paranoid_free(checksum);131 mr_free(original_cksum); 132 mr_free(checksum); 132 133 133 134 if (retval) { … … 138 139 paranoid_fclose(fout); 139 140 } 140 paranoid_free(bigfile_fname);141 mr_free(bigfile_fname); 141 142 142 143 return (retval); … … 181 182 noof_biggiefiles); 182 183 for (bigfileno = 0; bigfileno < noof_biggiefiles; bigfileno++) { 183 asprintf(&tmp, "Comparing big file #%ld", bigfileno + 1);184 mr_asprintf(&tmp, "Comparing big file #%ld", bigfileno + 1); 184 185 log_msg(1, tmp); 185 186 update_progress_form(tmp); 186 paranoid_free(tmp);187 mr_free(tmp); 187 188 res = compare_a_biggiefile(bkpinfo, bigfileno); 188 189 retval += res; … … 232 233 use_star = (strstr(tarball_fname, ".star")) ? TRUE : FALSE; 233 234 assert_string_is_neither_NULL_nor_zerolength(tarball_fname); 234 asprintf(&filelist_name, MNT_CDROM "/archives/filelist.%d",235 mr_asprintf(&filelist_name, MNT_CDROM "/archives/filelist.%d", 235 236 current_tarball_number); 236 237 237 238 noof_lines = count_lines_in_file(filelist_name); 238 paranoid_free(filelist_name);239 mr_free(filelist_name); 239 240 240 241 if (strstr(tarball_fname, ".bz2")) { 241 asprintf(&compressor_exe, "bzip2");242 mr_asprintf(&compressor_exe, "bzip2"); 242 243 } else if (strstr(tarball_fname, ".lzo")) { 243 asprintf(&compressor_exe, "lzop");244 mr_asprintf(&compressor_exe, "lzop"); 244 245 } else { 245 246 compressor_exe = NULL; … … 247 248 248 249 if (use_star) { 249 asprintf(&archiver_exe, "star -bz");250 } else { 251 asprintf(&archiver_exe, "afio");250 mr_asprintf(&archiver_exe, "star -bz"); 251 } else { 252 mr_asprintf(&archiver_exe, "afio"); 252 253 } 253 254 … … 257 258 fatal_error("(compare_a_tarball) Compression program missing"); 258 259 } 259 paranoid_free(tmp);260 mr_free(tmp); 260 261 261 262 if (use_star) { … … 266 267 } else { 267 268 tmp = compressor_exe; 268 asprintf(&compressor_exe, "-P %s -Z", tmp);269 paranoid_free(tmp);269 mr_asprintf(&compressor_exe, "-P %s -Z", tmp); 270 mr_free(tmp); 270 271 } 271 272 } … … 278 279 #endif 279 280 280 asprintf(&logfile, "/tmp/afio.log.%d", current_tarball_number);281 mr_asprintf(&logfile, "/tmp/afio.log.%d", current_tarball_number); 281 282 if (use_star) // doesn't use compressor_exe 282 283 { 283 asprintf(&command,284 mr_asprintf(&command, 284 285 "%s -diff H=star file=%s >> %s 2>> %s", 285 286 archiver_exe, tarball_fname, logfile, logfile); 286 287 } else { 287 asprintf(&command,288 mr_asprintf(&command, 288 289 "%s -r -b %ld -M 16m -c %ld %s %s >> %s 2>> %s", 289 290 archiver_exe, … … 292 293 } 293 294 #undef BUFSIZE 294 paranoid_free(archiver_exe);295 paranoid_free(compressor_exe);295 mr_free(archiver_exe); 296 mr_free(compressor_exe); 296 297 297 298 res = system(command); … … 300 301 log_OS_error(command); 301 302 } 302 paranoid_free(command);303 mr_free(command); 303 304 304 305 if (length_of_file(logfile) > 5) { 305 asprintf(&command,306 mr_asprintf(&command, 306 307 "sed s/': \\\"'/\\|/ %s | sed s/'\\\": '/\\|/ | cut -d'|' -f2 | sort -u | grep -vx \"dev/.*\" >> /tmp/changed.txt", 307 308 logfile); 308 309 system(command); 309 paranoid_free(command);310 mr_free(command); 310 311 archiver_errors = count_lines_in_file(logfile); 311 312 } else { … … 314 315 315 316 if (archiver_errors) { 316 asprintf(&tmp,317 mr_asprintf(&tmp, 317 318 "Differences found while processing fileset #%d ", 318 319 current_tarball_number); 319 320 log_msg(1, tmp); 320 paranoid_free(tmp);321 mr_free(tmp); 321 322 } 322 323 unlink(logfile); 323 paranoid_free(logfile);324 mr_free(logfile); 324 325 return (retval); 325 326 } … … 353 354 354 355 max_val = atol(tmp); 355 paranoid_free(tmp);356 357 asprintf(&progress_str, _("Comparing with %s #%d "),356 mr_free(tmp); 357 358 mr_asprintf(&progress_str, _("Comparing with %s #%d "), 358 359 bkpinfo->backup_media_string, 359 360 g_current_media_number); … … 369 370 insist_on_this_cd_number(bkpinfo, g_current_media_number); 370 371 update_progress_form(progress_str); 371 asprintf(&tarball_fname,372 mr_asprintf(&tarball_fname, 372 373 MNT_CDROM "/archives/%d.afio.bz2", current_tarball_number); 373 374 374 375 if (!does_file_exist(tarball_fname)) { 375 paranoid_free(tarball_fname);376 asprintf(&tarball_fname, MNT_CDROM "/archives/%d.afio.lzo",376 mr_free(tarball_fname); 377 mr_asprintf(&tarball_fname, MNT_CDROM "/archives/%d.afio.lzo", 377 378 current_tarball_number); 378 379 } 379 380 if (!does_file_exist(tarball_fname)) { 380 paranoid_free(tarball_fname);381 asprintf(&tarball_fname, MNT_CDROM "/archives/%d.afio.",381 mr_free(tarball_fname); 382 mr_asprintf(&tarball_fname, MNT_CDROM "/archives/%d.afio.", 382 383 current_tarball_number); 383 384 } 384 385 if (!does_file_exist(tarball_fname)) { 385 paranoid_free(tarball_fname);386 asprintf(&tarball_fname, MNT_CDROM "/archives/%d.star.bz2",386 mr_free(tarball_fname); 387 mr_asprintf(&tarball_fname, MNT_CDROM "/archives/%d.star.bz2", 387 388 current_tarball_number); 388 389 } 389 390 if (!does_file_exist(tarball_fname)) { 390 paranoid_free(tarball_fname);391 asprintf(&tarball_fname, MNT_CDROM "/archives/%d.star.",391 mr_free(tarball_fname); 392 mr_asprintf(&tarball_fname, MNT_CDROM "/archives/%d.star.", 392 393 current_tarball_number); 393 394 } … … 398 399 == 0) { 399 400 log_msg(2, "OK, I think I'm done with tarballs..."); 400 paranoid_free(tarball_fname);401 mr_free(tarball_fname); 401 402 break; 402 403 } 403 404 log_msg(2, "OK, I think it's time for another CD..."); 404 405 g_current_media_number++; 405 paranoid_free(progress_str);406 asprintf(&progress_str, _("Comparing with %s #%d "),406 mr_free(progress_str); 407 mr_asprintf(&progress_str, _("Comparing with %s #%d "), 407 408 bkpinfo->backup_media_string, 408 409 g_current_media_number); … … 410 411 } else { 411 412 res = compare_a_tarball(tarball_fname, current_tarball_number); 412 paranoid_free(tarball_fname);413 mr_free(tarball_fname); 413 414 414 415 g_current_progress++; … … 416 417 } 417 418 } 418 paranoid_free(progress_str);419 mr_free(progress_str); 419 420 close_progress_form(); 420 421 … … 470 471 noof_changed_files = count_lines_in_file("/tmp/changed.txt"); 471 472 if (noof_changed_files) { 472 asprintf(&tmp, _("%ld files do not match the backup "),473 mr_asprintf(&tmp, _("%ld files do not match the backup "), 473 474 noof_changed_files); 474 475 // mvaddstr_and_log_it( g_currentY++, 0, tmp ); 475 476 log_to_screen(tmp); 476 paranoid_free(tmp);477 478 asprintf(&command, "cat /tmp/changed.txt >> %s", MONDO_LOGFILE);477 mr_free(tmp); 478 479 mr_asprintf(&command, "cat /tmp/changed.txt >> %s", MONDO_LOGFILE); 479 480 paranoid_system(command); 480 paranoid_free(command);481 } else { 482 asprintf(&tmp, _("All files match the backup "));481 mr_free(command); 482 } else { 483 mr_asprintf(&tmp, _("All files match the backup ")); 483 484 mvaddstr_and_log_it(g_currentY++, 0, tmp); 484 485 log_to_screen(tmp); 485 paranoid_free(tmp);486 } 487 488 paranoid_free(cwd);489 paranoid_free(new);486 mr_free(tmp); 487 } 488 489 mr_free(cwd); 490 mr_free(new); 490 491 491 492 return (resA + resB); … … 573 574 } else { 574 575 q = count_lines_in_file("/tmp/changed.files"); 575 asprintf(&tmp, _("%ld significant difference%s found."), q,576 mr_asprintf(&tmp, _("%ld significant difference%s found."), q, 576 577 (q != 1) ? "s" : ""); 577 578 mvaddstr_and_log_it(g_currentY++, 0, tmp); 578 579 log_to_screen(tmp); 579 paranoid_free(tmp);580 581 asprintf(&tmp,580 mr_free(tmp); 581 582 mr_asprintf(&tmp, 582 583 _("Type 'less /tmp/changed.files' for a list of non-matching files")); 583 584 mvaddstr_and_log_it(g_currentY++, 0, tmp); 584 585 log_to_screen(tmp); 585 paranoid_free(tmp);586 mr_free(tmp); 586 587 587 588 log_msg(2, "calling popup_changelist_from_file()"); … … 624 625 chdir(bkpinfo->restore_path); 625 626 626 asprintf(&command, "cp -f /tmp/LAST-FILELIST-NUMBER %s/tmp",627 mr_asprintf(&command, "cp -f /tmp/LAST-FILELIST-NUMBER %s/tmp", 627 628 bkpinfo->restore_path); 628 629 run_program_and_log_output(command, FALSE); 629 paranoid_free(command);630 mr_free(command); 630 631 mvaddstr_and_log_it(g_currentY, 631 632 0, _("Verifying archives against filesystem")); … … 633 634 if (bkpinfo->disaster_recovery 634 635 && does_file_exist("/tmp/CDROM-LIVES-HERE")) { 635 paranoid_free(bkpinfo->media_device);636 mr_free(bkpinfo->media_device); 636 637 // last_line_of_file allocates the string 637 638 bkpinfo->media_device = last_line_of_file("/tmp/CDROM-LIVES-HERE"); 638 639 } else { 639 paranoid_free(bkpinfo->media_device);640 mr_free(bkpinfo->media_device); 640 641 // find_cdrom_device allocates the string 641 642 bkpinfo->media_device = find_cdrom_device(FALSE); … … 653 654 654 655 mvaddstr_and_log_it(g_currentY++, 74, _("Done.")); 655 paranoid_free(dir);656 mr_free(dir); 656 657 return (res); 657 658 } … … 684 685 getcwd(dir, MAX_STR_LEN); 685 686 chdir(bkpinfo->restore_path); 686 asprintf(&command, "cp -f /tmp/LAST-FILELIST-NUMBER %s/tmp",687 mr_asprintf(&command, "cp -f /tmp/LAST-FILELIST-NUMBER %s/tmp", 687 688 bkpinfo->restore_path); 688 689 run_program_and_log_output(command, FALSE); 689 paranoid_free(command);690 mr_free(command); 690 691 691 692 mvaddstr_and_log_it(g_currentY, … … 698 699 mvaddstr_and_log_it(g_currentY++, 74, _("Done.")); 699 700 } 700 paranoid_free(dir);701 mr_free(dir); 701 702 return (res); 702 703 }
Note:
See TracChangeset
for help on using the changeset viewer.