Changeset 688 in MondoRescue for trunk/mondo/mondo/mondorestore/mondo-rstr-compare.c
- Timestamp:
- Jul 17, 2006, 3:44:46 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/mondo/mondo/mondorestore/mondo-rstr-compare.c
r524 r688 1 1 /*************************************************************************** 2 mondo-compare.c - compares mondoarchive data 3 ------------------- 4 begin : Fri Apr 25 2003 5 copyright : (C) 2000 by Hugo Rabson 6 email : Hugo Rabson <hugorabson@msn.com> 7 cvsid : $Id$ 8 ***************************************************************************/ 9 10 /*************************************************************************** 11 * * 12 * This program is free software; you can redistribute it and/or modify * 13 * it under the terms of the GNU General Public License as published by * 14 * the Free Software Foundation; either version 2 of the License, or * 15 * (at your option) any later version. * 16 * * 17 ***************************************************************************/ 18 19 /*************************************************************************** 20 * Change Log * 21 *************************************************************************** 22 . 23 24 25 26 10/21/2003 27 - changed "/mnt/cdrom" to MNT_CDROM 28 29 10/18 30 - don't say unknown compressor if no compressor at all 31 32 09/17 33 - cleaned up logging & conversion-to-changed.txt 34 - cleaned up compare_mode() 35 36 09/16 37 - fixed bad malloc(),free() pairs in compare_a_biggiefile() 38 39 09/14 40 - compare_mode() --- a couple of strings were the wrong way round, 41 e.g. changed.txt and changed.files 42 43 05/05 44 - exclude /dev/ * from list of changed files 45 46 04/30 47 - added textonly mode 48 49 04/27 50 - improved compare_mode() to allow for ISO/cd/crazy people 51 52 04/25 53 - first incarnation 54 */ 2 * $Id$ - compares mondoarchive data 3 **/ 55 4 56 5 … … 58 7 #include "../common/mondostructures.h" 59 8 #include "../common/libmondo.h" 60 //#include "../../config.h"61 9 #include "mr-externs.h" 62 10 #include "mondo-rstr-compare.h" … … 67 15 #endif 68 16 69 //static char cvsid[] = "$Id$";70 71 17 void popup_changelist_from_file(char *); 72 18 … … 89 35 90 36 /** needs malloc *******/ 91 char *checksum _ptr;92 char *original_cksum _ptr;93 char *bigfile_fname _ptr;94 char *tmp _ptr;95 char * command_ptr;96 97 char *checksum, *original_cksum, *bigfile_fname, *tmp, *command; 98 99 char *p;100 int i;37 char *checksum = NULL; 38 char *original_cksum = NULL; 39 char *bigfile_fname = NULL; 40 char *tmp = NULL; 41 char *tmp1 = NULL; 42 char *command = NULL; 43 44 char *p = NULL; 45 int i = 0; 46 int n = 0; 101 47 int retval = 0; 102 48 103 49 struct s_filename_and_lstat_info biggiestruct; 104 50 105 malloc_string(checksum);106 malloc_string(original_cksum);107 malloc_string(bigfile_fname);108 malloc_string(tmp);109 malloc_string(command);110 malloc_string(checksum_ptr);111 malloc_string(original_cksum_ptr);112 malloc_string(bigfile_fname_ptr);113 malloc_string(command_ptr);114 malloc_string(tmp_ptr);115 116 /*********************************************************************117 * allocate memory clear test sab 16 feb 2003 *118 *********************************************************************/119 51 assert(bkpinfo != NULL); 120 memset(checksum_ptr, '\0', sizeof(checksum)); 121 memset(original_cksum_ptr, '\0', sizeof(original_cksum)); 122 memset(bigfile_fname_ptr, '\0', sizeof(bigfile_fname)); 123 memset(tmp_ptr, '\0', sizeof(tmp)); 124 memset(command_ptr, '\0', sizeof(command)); 125 /** end **/ 126 127 if (!does_file_exist(slice_fname(bigfileno, 0, ARCHIVES_PATH, ""))) { 52 53 tmp1 = slice_fname(bigfileno, 0, ARCHIVES_PATH, ""); 54 if (!does_file_exist(tmp1)) { 128 55 if (does_file_exist(MNT_CDROM "/archives/NOT-THE-LAST")) { 129 56 insist_on_this_cd_number(bkpinfo, (++g_current_media_number)); 130 57 } else { 131 sprintf(tmp_ptr, 132 "No CD's left. No biggiefiles left. No prob, Bob."); 133 log_msg(2, tmp_ptr); 58 log_msg(2, "No CD's left. No biggiefiles left. No problem."); 134 59 return (0); 135 60 } 136 61 } 137 if (!(fin = fopen(slice_fname(bigfileno, 0, ARCHIVES_PATH, ""), "r"))) { 138 sprintf(tmp_ptr, 139 _("Cannot open bigfile %ld (%s)'s info file"), 140 bigfileno + 1, bigfile_fname_ptr); 141 log_to_screen(tmp_ptr); 62 if (!(fin = fopen(tmp1, "r"))) { 63 asprintf(&tmp, _("Cannot open bigfile %ld (%s)'s info file"), 64 bigfileno + 1, tmp); 65 log_to_screen(tmp); 66 paranoid_free(tmp); 67 paranoid_free(tmp1); 142 68 return (1); 143 69 } … … 145 71 paranoid_fclose(fin); 146 72 147 strcpy(checksum_ptr, biggiestruct.checksum); 148 strcpy(bigfile_fname_ptr, biggiestruct.filename); 149 150 log_msg(2, "biggiestruct.filename = %s", biggiestruct.filename); 151 log_msg(2, "biggiestruct.checksum = %s", biggiestruct.checksum); 152 153 sprintf(tmp_ptr, _("Comparing %s"), bigfile_fname_ptr); 73 asprintf(&checksum, biggiestruct.checksum); 74 asprintf(&bigfile_fname, biggiestruct.filename); 75 76 log_msg(2, "biggiestruct.filename = %s", bigfile_fname); 77 log_msg(2, "biggiestruct.checksum = %s", checksum); 154 78 155 79 if (!g_text_mode) { 156 newtDrawRootText(0, 22, tmp_ptr); 80 asprintf(&tmp, _("Comparing %s"), bigfile_fname); 81 newtDrawRootText(0, 22, tmp); 157 82 newtRefresh(); 158 } 83 paranoid_free(tmp); 84 } 85 /* BERLIOS: Useless ? 159 86 if (!checksum[0]) { 160 87 log_msg(2, "Warning - %s has no checksum", bigfile_fname_ptr); 161 } 162 if (!strncmp(bigfile_fname_ptr, "/dev/", 5)) { 163 strcpy(original_cksum_ptr, "IGNORE"); 164 } else { 165 sprintf(command_ptr, 88 } */ 89 if (!strncmp(bigfile_fname, "/dev/", 5)) { 90 log_msg(2, _("Ignoring device %s"), bigfile_fname); 91 return(0); 92 } else { 93 asprintf(&command, 166 94 "md5sum \"%s%s\" > /tmp/md5sum.txt 2> /tmp/errors.txt", 167 MNT_RESTORING, bigfile_fname_ptr); 168 } 169 log_msg(2, command_ptr); 170 paranoid_system 171 ("cat /tmp/errors >> /tmp/mondo-restore.log 2> /dev/null"); 172 if (system(command_ptr)) { 95 MNT_RESTORING, bigfile_fname); 96 } 97 log_msg(2, command); 98 paranoid_system("cat /tmp/errors >> /tmp/mondo-restore.log 2> /dev/null"); 99 if (system(command)) { 173 100 log_OS_error("Warning - command failed"); 174 original_cksum[0] = '\0'; 101 paranoid_free(command); 102 paranoid_free(bigfile_fname); 175 103 return (1); 176 104 } else { 105 paranoid_free(command); 177 106 if (!(fin = fopen("/tmp/md5sum.txt", "r"))) { 178 log_msg(2, 179 "Unable to open /tmp/md5sum.txt; can't get live checksum"); 180 original_cksum[0] = '\0'; 107 log_msg(2, "Unable to open /tmp/md5sum.txt; can't get live checksum"); 108 paranoid_free(bigfile_fname); 181 109 return (1); 182 110 } else { 183 fgets(original_cksum_ptr, MAX_STR_LEN - 1, fin);111 getline(&original_cksum, &n, fin); 184 112 paranoid_fclose(fin); 185 for (i = strlen(original_cksum _ptr);113 for (i = strlen(original_cksum); 186 114 i > 0 && original_cksum[i - 1] < 32; i--); 187 115 original_cksum[i] = '\0'; 188 p = (char *) strchr(original_cksum _ptr, ' ');116 p = (char *) strchr(original_cksum, ' '); 189 117 if (p) { 190 118 *p = '\0'; … … 192 120 } 193 121 } 194 sprintf(tmp_ptr, "bigfile #%ld ('%s') ", bigfileno + 1, 195 bigfile_fname_ptr); 196 if (!strcmp(checksum_ptr, original_cksum_ptr) != 0) { 197 strcat(tmp_ptr, " ... OK"); 198 } else { 199 strcat(tmp_ptr, "... changed"); 122 if (!strcmp(checksum, original_cksum) != 0) { 123 log_msg(1, "bigfile #%ld ('%s') ... OK", bigfileno + 1, bigfile_fname); 124 } else { 125 log_msg(1, "bigfile #%ld ('%s') ... changed", bigfileno + 1, bigfile_fname); 200 126 retval++; 201 127 } 202 log_msg(1, tmp_ptr); 128 paranoid_free(original_cksum); 129 paranoid_free(checksum); 130 203 131 if (retval) { 204 132 if (!(fout = fopen("/tmp/changed.txt", "a"))) { 205 133 fatal_error("Cannot openout changed.txt"); 206 134 } 207 fprintf(fout, "%s\n", bigfile_fname _ptr);135 fprintf(fout, "%s\n", bigfile_fname); 208 136 paranoid_fclose(fout); 209 137 } 210 211 paranoid_free(original_cksum_ptr);212 paranoid_free(original_cksum);213 paranoid_free(bigfile_fname_ptr);214 138 paranoid_free(bigfile_fname); 215 paranoid_free(checksum_ptr);216 paranoid_free(checksum);217 paranoid_free(command_ptr);218 paranoid_free(command);219 paranoid_free(tmp_ptr);220 paranoid_free(tmp);221 139 222 140 return (retval); … … 238 156 int res; 239 157 long noof_biggiefiles, bigfileno = 0; 240 char tmp[MAX_STR_LEN];158 char *tmp; 241 159 242 160 assert(bkpinfo != NULL); … … 254 172 } 255 173 mvaddstr_and_log_it(g_currentY, 0, 256 _("Comparing large files ")); 174 _ 175 ("Comparing large files ")); 257 176 open_progress_form(_("Comparing large files"), 258 177 _("I am now comparing the large files"), … … 260 179 noof_biggiefiles); 261 180 for (bigfileno = 0; bigfileno < noof_biggiefiles; bigfileno++) { 262 sprintf(tmp, "Comparing big file #%ld", bigfileno + 1);181 asprintf(&tmp, "Comparing big file #%ld", bigfileno + 1); 263 182 log_msg(1, tmp); 264 183 update_progress_form(tmp); 184 paranoid_free(tmp); 265 185 res = compare_a_biggiefile(bkpinfo, bigfileno); 266 186 retval += res; … … 268 188 } 269 189 close_progress_form(); 190 /* BERLIOS: useless ? 270 191 return (0); 192 */ 271 193 if (retval) { 272 194 mvaddstr_and_log_it(g_currentY++, 74, _("Errors.")); … … 299 221 300 222 /*** needs malloc *********/ 301 char *command, *tmp, *filelist_name, *logfile, *archiver_exe, 302 *compressor_exe; 303 304 malloc_string(command); 305 malloc_string(tmp); 306 malloc_string(filelist_name); 307 malloc_string(logfile); 308 malloc_string(archiver_exe); 309 malloc_string(compressor_exe); 223 char *command = NULL; 224 char *tmp = NULL; 225 char *filelist_name = NULL; 226 char *logfile = NULL; 227 char *archiver_exe = NULL; 228 char *compressor_exe = NULL; 310 229 311 230 use_star = (strstr(tarball_fname, ".star")) ? TRUE : FALSE; 312 231 assert_string_is_neither_NULL_nor_zerolength(tarball_fname); 313 sprintf(logfile, "/tmp/afio.log.%d", current_tarball_number); 314 sprintf(filelist_name, MNT_CDROM "/archives/filelist.%d", 232 asprintf(&filelist_name, MNT_CDROM "/archives/filelist.%d", 315 233 current_tarball_number); 316 234 317 235 noof_lines = count_lines_in_file(filelist_name); 236 paranoid_free(filelist_name); 318 237 319 238 if (strstr(tarball_fname, ".bz2")) { 320 strcpy(compressor_exe, "bzip2");239 asprintf(&compressor_exe, "bzip2"); 321 240 } else if (strstr(tarball_fname, ".lzo")) { 322 strcpy(compressor_exe, "lzop");323 } else { 324 compressor_exe [0] = '\0';241 asprintf(&compressor_exe, "lzop"); 242 } else { 243 compressor_exe = NULL; 325 244 } 326 245 327 246 if (use_star) { 328 strcpy(archiver_exe, "star"); 329 } else { 330 strcpy(archiver_exe, "afio"); 331 } 332 333 if (compressor_exe[0]) { 334 strcpy(tmp, compressor_exe); 335 if (!find_home_of_exe(tmp)) { 247 asprintf(&archiver_exe, "star -bz"); 248 } else { 249 asprintf(&archiver_exe, "afio"); 250 } 251 252 if (compressor_exe != NULL) { 253 if (!find_home_of_exe(compressor_exe)) { 336 254 fatal_error("(compare_a_tarball) Compression program missing"); 337 255 } 338 if (use_star) // star 339 { 340 if (!strcmp(compressor_exe, "bzip2")) { 341 strcat(archiver_exe, " -bz"); 342 } else { 256 if (use_star) { 257 if (strcmp(compressor_exe, "bzip2")) { 343 258 fatal_error 344 259 ("(compare_a_tarball) Please use only bzip2 with star"); 345 260 } 346 } else // afio347 {261 } else { 262 asprintf(&tmp, compressor_exe); 348 263 sprintf(compressor_exe, "-P %s -Z", tmp); 264 paranoid_free(tmp); 349 265 } 350 266 } … … 356 272 #define BUFSIZE (1024L*1024L)/TAPE_BLOCK_SIZE 357 273 #endif 274 275 asprintf(&logfile, "/tmp/afio.log.%d", current_tarball_number); 358 276 if (use_star) // doesn't use compressor_exe 359 277 { 360 sprintf(command,278 asprintf(&command, 361 279 "%s -diff H=star file=%s >> %s 2>> %s", 362 280 archiver_exe, tarball_fname, logfile, logfile); 363 281 } else { 364 sprintf(command,282 asprintf(&command, 365 283 "%s -r -b %ld -M 16m -c %ld %s %s >> %s 2>> %s", 366 284 archiver_exe, … … 369 287 } 370 288 #undef BUFSIZE 289 paranoid_free(archiver_exe); 290 paranoid_free(compressor_exe); 371 291 372 292 res = system(command); … … 374 294 if (res) { 375 295 log_OS_error(command); 376 sprintf(tmp, "Warning - afio returned error = %d", res);377 296 } 378 297 if (length_of_file(logfile) > 5) { … … 385 304 archiver_errors = 0; 386 305 } 387 sprintf(tmp, "%ld difference%c in fileset #%d ", 388 archiver_errors, (archiver_errors != 1) ? 's' : ' ', 389 current_tarball_number); 306 paranoid_free(command); 307 390 308 if (archiver_errors) { 391 sprintf(tmp,309 asprintf(&tmp, 392 310 "Differences found while processing fileset #%d ", 393 311 current_tarball_number); 394 312 log_msg(1, tmp); 313 paranoid_free(tmp); 395 314 } 396 315 unlink(logfile); 397 paranoid_free(command);398 paranoid_free(tmp);399 paranoid_free(filelist_name);400 316 paranoid_free(logfile); 401 malloc_string(archiver_exe);402 malloc_string(compressor_exe);403 317 return (retval); 404 318 } … … 422 336 /** needs malloc **********/ 423 337 424 char *tarball_fname, *progress_str, *tmp; 338 char *tarball_fname = NULL; 339 char *progress_str = NULL; 340 char *tmp = NULL; 425 341 long max_val; 426 427 malloc_string(tarball_fname);428 malloc_string(progress_str);429 malloc_string(tmp);430 342 431 343 assert(bkpinfo != NULL); … … 434 346 435 347 max_val = atol(tmp); 436 sprintf(progress_str, _("Comparing with %s #%d "), 348 paranoid_free(tmp); 349 350 asprintf(&progress_str, _("Comparing with %s #%d "), 437 351 media_descriptor_string(bkpinfo->backup_media_type), 438 352 g_current_media_number); … … 448 362 insist_on_this_cd_number(bkpinfo, g_current_media_number); 449 363 update_progress_form(progress_str); 450 sprintf(tarball_fname,364 asprintf(&tarball_fname, 451 365 MNT_CDROM "/archives/%d.afio.bz2", current_tarball_number); 452 366 453 367 if (!does_file_exist(tarball_fname)) { 454 sprintf(tarball_fname, MNT_CDROM "/archives/%d.afio.lzo", 368 paranoid_free(tarball_fname); 369 asprintf(&tarball_fname, MNT_CDROM "/archives/%d.afio.lzo", 455 370 current_tarball_number); 456 371 } 457 372 if (!does_file_exist(tarball_fname)) { 458 sprintf(tarball_fname, MNT_CDROM "/archives/%d.afio.", 373 paranoid_free(tarball_fname); 374 asprintf(&tarball_fname, MNT_CDROM "/archives/%d.afio.", 459 375 current_tarball_number); 460 376 } 461 377 if (!does_file_exist(tarball_fname)) { 462 sprintf(tarball_fname, MNT_CDROM "/archives/%d.star.bz2", 378 paranoid_free(tarball_fname); 379 asprintf(&tarball_fname, MNT_CDROM "/archives/%d.star.bz2", 463 380 current_tarball_number); 464 381 } 465 382 if (!does_file_exist(tarball_fname)) { 466 sprintf(tarball_fname, MNT_CDROM "/archives/%d.star.", 383 paranoid_free(tarball_fname); 384 asprintf(&tarball_fname, MNT_CDROM "/archives/%d.star.", 467 385 current_tarball_number); 468 386 } … … 473 391 == 0) { 474 392 log_msg(2, "OK, I think I'm done with tarballs..."); 393 paranoid_free(tarball_fname); 475 394 break; 476 395 } 477 396 log_msg(2, "OK, I think it's time for another CD..."); 478 397 g_current_media_number++; 479 sprintf(progress_str, _("Comparing with %s #%d "), 398 paranoid_free(progress_str); 399 asprintf(&progress_str, _("Comparing with %s #%d "), 480 400 media_descriptor_string(bkpinfo->backup_media_type), 481 401 g_current_media_number); … … 483 403 } else { 484 404 res = compare_a_tarball(tarball_fname, current_tarball_number); 405 paranoid_free(tarball_fname); 485 406 486 407 g_current_progress++; … … 488 409 } 489 410 } 411 paranoid_free(progress_str); 490 412 close_progress_form(); 413 491 414 if (retval) { 492 415 mvaddstr_and_log_it(g_currentY++, 74, _("Errors.")); … … 494 417 mvaddstr_and_log_it(g_currentY++, 74, _("Done.")); 495 418 } 496 paranoid_free(tarball_fname);497 paranoid_free(progress_str);498 paranoid_free(tmp);499 419 return (retval); 500 420 } … … 519 439 { 520 440 /** needs malloc *********/ 521 char *tmp, *cwd, *new, *command; 441 char *tmp = NULL; 442 char *cwd = NULL; 443 char *new = NULL; 444 char *command = NULL; 522 445 int resA = 0; 523 446 int resB = 0; 524 447 long noof_changed_files; 525 448 526 malloc_string(tmp);527 449 malloc_string(cwd); 528 450 malloc_string(new); 529 malloc_string(command);530 451 531 452 assert(bkpinfo != NULL); … … 534 455 chdir(bkpinfo->restore_path); 535 456 getcwd(new, MAX_STR_LEN - 1); 536 sprintf(tmp, "new path is %s", new);537 457 insist_on_this_cd_number(bkpinfo, g_current_media_number); 538 458 unlink("/tmp/changed.txt"); … … 543 463 noof_changed_files = count_lines_in_file("/tmp/changed.txt"); 544 464 if (noof_changed_files) { 545 sprintf(tmp, _("%ld files do not match the backup "),465 asprintf(&tmp, _("%ld files do not match the backup "), 546 466 noof_changed_files); 547 467 // mvaddstr_and_log_it( g_currentY++, 0, tmp ); 548 468 log_to_screen(tmp); 549 sprintf(command, "cat /tmp/changed.txt >> %s", MONDO_LOGFILE); 469 paranoid_free(tmp); 470 471 asprintf(&command, "cat /tmp/changed.txt >> %s", MONDO_LOGFILE); 550 472 paranoid_system(command); 551 } else { 552 sprintf(tmp, _("All files match the backup ")); 473 paranoid_free(command); 474 } else { 475 asprintf(&tmp, _("All files match the backup ")); 553 476 mvaddstr_and_log_it(g_currentY++, 0, tmp); 554 477 log_to_screen(tmp); 555 }556 557 paranoid_free(tmp); 478 paranoid_free(tmp); 479 } 480 558 481 paranoid_free(cwd); 559 482 paranoid_free(new); 560 paranoid_free(command);561 483 562 484 return (resA + resB); … … 566 488 *END_COMPARE_TO_CD * 567 489 **************************************************************************/ 568 569 570 490 571 491 … … 588 508 char *tmp; 589 509 590 malloc_string(tmp);591 592 510 /************************************************************************** 593 511 * also deletes tmp/filelist.full & tmp/biggielist.txt _and_ tries to * … … 600 518 while (get_cfg_file_from_archive(bkpinfo)) { 601 519 if (!ask_me_yes_or_no 602 (_("Failed to find config file/archives. Choose another source?"))) 520 (_ 521 ("Failed to find config file/archives. Choose another source?"))) 603 522 { 604 523 fatal_error("Unable to find config file/archives. Aborting."); … … 628 547 mvaddstr_and_log_it(g_currentY++, 629 548 0, 630 _("Warning - differences found during the compare phase")); 549 _ 550 ("Warning - differences found during the compare phase")); 631 551 } 632 552 … … 635 555 if (count_lines_in_file("/tmp/changed.txt") > 0) { 636 556 mvaddstr_and_log_it(g_currentY++, 0, 637 _("Differences found while files were being compared.")); 557 _ 558 ("Differences found while files were being compared.")); 638 559 streamline_changes_file("/tmp/changed.files", "/tmp/changed.txt"); 639 560 if (count_lines_in_file("/tmp/changed.files") <= 0) { 640 561 mvaddstr_and_log_it(g_currentY++, 0, 641 _("...but they were logfiles and temporary files. Your archives are fine.")); 642 log_to_screen 643 (_("The differences were logfiles and temporary files. Your archives are fine.")); 562 _ 563 ("...but they were logfiles and temporary files. Your archives are fine.")); 564 log_to_screen(_ 565 ("The differences were logfiles and temporary files. Your archives are fine.")); 644 566 } else { 645 567 q = count_lines_in_file("/tmp/changed.files"); 646 sprintf(tmp, _("%ld significant difference%s found."), q,568 asprintf(&tmp, _("%ld significant difference%s found."), q, 647 569 (q != 1) ? "s" : ""); 648 570 mvaddstr_and_log_it(g_currentY++, 0, tmp); 649 571 log_to_screen(tmp); 650 651 strcpy(tmp, 572 paranoid_free(tmp); 573 574 asprintf(&tmp, 652 575 _("Type 'less /tmp/changed.files' for a list of non-matching files")); 653 576 mvaddstr_and_log_it(g_currentY++, 0, tmp); 654 577 log_to_screen(tmp); 578 paranoid_free(tmp); 655 579 656 580 log_msg(2, "calling popup_changelist_from_file()"); … … 660 584 } else { 661 585 log_to_screen 662 (_("No significant differences were found. Your backup is perfect.")); 586 (_ 587 ("No significant differences were found. Your backup is perfect.")); 663 588 } 664 589 kill_petris(); 665 paranoid_free(tmp);666 590 return (retval); 667 591 } … … 670 594 *END_COMPARE_MODE * 671 595 **************************************************************************/ 596 672 597 673 598 /** … … 683 608 int res; 684 609 610 char *dir = NULL; 611 char *command = NULL; 612 613 assert(bkpinfo != NULL); 685 614 /** needs malloc **/ 686 char *dir, *command, *tmp;687 688 assert(bkpinfo != NULL);689 615 malloc_string(dir); 690 malloc_string(command);691 616 getcwd(dir, MAX_STR_LEN); 692 617 chdir(bkpinfo->restore_path); 693 618 694 sprintf(command, "cp -f /tmp/LAST-FILELIST-NUMBER %s/tmp",619 asprintf(&command, "cp -f /tmp/LAST-FILELIST-NUMBER %s/tmp", 695 620 bkpinfo->restore_path); 696 621 run_program_and_log_output(command, FALSE); 622 paranoid_free(command); 697 623 mvaddstr_and_log_it(g_currentY, 698 624 0, _("Verifying archives against filesystem")); … … 700 626 if (bkpinfo->disaster_recovery 701 627 && does_file_exist("/tmp/CDROM-LIVES-HERE")) { 702 asprintf(&tmp,703 last_line_of_file("/tmp/CDROM-LIVES-HERE"));704 628 paranoid_free(bkpinfo->media_device); 705 bkpinfo->media_device = tmp; 629 // last_line_of_file allocates the string 630 bkpinfo->media_device = last_line_of_file("/tmp/CDROM-LIVES-HERE"); 706 631 } else { 707 632 paranoid_free(bkpinfo->media_device); 633 // find_cdrom_device allocates the string 708 634 bkpinfo->media_device = find_cdrom_device(FALSE); 709 635 } … … 721 647 mvaddstr_and_log_it(g_currentY++, 74, _("Done.")); 722 648 paranoid_free(dir); 723 paranoid_free(command);724 649 return (res); 725 650 } … … 744 669 { 745 670 int res; 746 char *dir, *command; 671 char *dir = NULL; 672 char *command = NULL; 747 673 748 674 assert(bkpinfo != NULL); 749 675 malloc_string(dir); 750 malloc_string(command);751 676 752 677 getcwd(dir, MAX_STR_LEN); 753 678 chdir(bkpinfo->restore_path); 754 sprintf(command, "cp -f /tmp/LAST-FILELIST-NUMBER %s/tmp",679 asprintf(&command, "cp -f /tmp/LAST-FILELIST-NUMBER %s/tmp", 755 680 bkpinfo->restore_path); 756 681 run_program_and_log_output(command, FALSE); 682 paranoid_free(command); 683 757 684 mvaddstr_and_log_it(g_currentY, 758 685 0, _("Verifying archives against filesystem")); … … 765 692 } 766 693 paranoid_free(dir); 767 paranoid_free(command);768 694 return (res); 769 695 }
Note:
See TracChangeset
for help on using the changeset viewer.