Changeset 900 in MondoRescue for trunk/mondo/src/common/libmondo-archive.c
- Timestamp:
- Oct 24, 2006, 8:49:18 AM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/mondo/src/common/libmondo-archive.c
r815 r900 9 9 * This is the main file (at least the longest one) in libmondo. 10 10 */ 11 #include <sys/sem.h> 12 #include <sys/types.h> 13 #include <sys/ipc.h> 14 #include <stdarg.h> 15 #include <unistd.h> 11 16 12 17 #include "my-stuff.h" 13 18 #include "../common/mondostructures.h" 14 19 #include "mr_conf.h" 20 #include "mr_mem.h" 21 #include "mr_err.h" 22 15 23 #include "libmondo-string-EXT.h" 16 24 #include "libmondo-stream-EXT.h" … … 24 32 #include "libmondo-verify-EXT.h" 25 33 #include "libmondo-archive.h" 26 #include <sys/sem.h>27 #include <sys/types.h>28 #include <sys/ipc.h>29 #include <stdarg.h>30 #include <unistd.h>31 34 #define DVDRWFORMAT 1 32 35 … … 201 204 202 205 if (!does_file_exist(filelist)) { 203 asprintf(&tmp,206 mr_asprintf(&tmp, 204 207 "(archive_this_fileset) - filelist %s does not exist", 205 208 filelist); 206 209 log_to_screen(tmp); 207 paranoid_free(tmp);210 mr_free(tmp); 208 211 return (1); 209 212 } 210 213 211 asprintf(&tmp, "echo hi > %s 2> /dev/null", fname);214 mr_asprintf(&tmp, "echo hi > %s 2> /dev/null", fname); 212 215 if (system(tmp)) { 213 216 fatal_error("Unable to write tarball to scratchdir"); 214 217 } 215 paranoid_free(tmp);216 217 asprintf(&command, "star H=star list=%s -c " STAR_ACL_SZ " file=%s",218 mr_free(tmp); 219 220 mr_asprintf(&command, "star H=star list=%s -c " STAR_ACL_SZ " file=%s", 218 221 filelist, fname); 219 222 if (bkpinfo->use_lzo) { … … 221 224 } 222 225 if (bkpinfo->compression_level > 0) { 223 asprintf(&tmp, "%s -bz", command);224 paranoid_free(command);226 mr_asprintf(&tmp, "%s -bz", command); 227 mr_free(command); 225 228 command = tmp; 226 229 } 227 asprintf(&tmp, "%s 2>> %s", command, MONDO_LOGFILE);228 paranoid_free(command);230 mr_asprintf(&tmp, "%s 2>> %s", command, MONDO_LOGFILE); 231 mr_free(command); 229 232 command = tmp; 230 233 log_msg(4, "command = '%s'", command); … … 241 244 res = 0; 242 245 } 243 paranoid_free(tmp);246 mr_free(tmp); 244 247 if (res) { 245 248 log_OS_error(command); … … 256 259 } 257 260 } 258 paranoid_free(command);261 mr_free(command); 259 262 260 263 retval += res; … … 314 317 315 318 if (!does_file_exist(filelist)) { 316 asprintf(&tmp,319 mr_asprintf(&tmp, 317 320 "(archive_this_fileset) - filelist %s does not exist", 318 321 filelist); 319 322 log_to_screen(tmp); 320 paranoid_free(tmp)323 mr_free(tmp); 321 324 return (1); 322 325 } 323 asprintf(&tmp, "echo hi > %s 2> /dev/null", fname);326 mr_asprintf(&tmp, "echo hi > %s 2> /dev/null", fname); 324 327 if (system(tmp)) { 325 328 fatal_error("Unable to write tarball to scratchdir"); 326 329 } 327 paranoid_free(tmp)330 mr_free(tmp); 328 331 329 332 330 333 if (bkpinfo->compression_level > 0) { 331 asprintf(&tmp, "%s/do-not-compress-these", g_mondo_home);334 mr_asprintf(&tmp, "%s/do-not-compress-these", g_mondo_home); 332 335 // -b %ld, TAPE_BLOCK_SIZE 333 asprintf(&zipparams, "-Z -P %s -G %d -T 3k", bkpinfo->zip_exe,336 mr_asprintf(&zipparams, "-Z -P %s -G %d -T 3k", bkpinfo->zip_exe, 334 337 bkpinfo->compression_level); 335 338 if (does_file_exist(tmp)) { 336 asprintf(&tmp1, "%s -E %s", zipparams, tmp);337 paranoid_free(zipparams)339 mr_asprintf(&tmp1, "%s -E %s", zipparams, tmp); 340 mr_free(zipparams); 338 341 zipparams = tmp1; 339 342 } else { 340 asprintf(&zipparams, " ");343 mr_asprintf(&zipparams, " "); 341 344 log_msg(3, "%s not found. Cannot exclude zipfiles, etc.", tmp); 342 345 } 343 paranoid_free(tmp)346 mr_free(tmp); 344 347 } else { 345 asprintf(&zipparams, " ");348 mr_asprintf(&zipparams, " "); 346 349 } 347 350 … … 356 359 fatal_error("scratchdir not found"); 357 360 } 358 asprintf(&command, "rm -f %s %s. %s.gz %s.%s", fname, fname, fname,361 mr_asprintf(&command, "rm -f %s %s. %s.gz %s.%s", fname, fname, fname, 359 362 fname, bkpinfo->zip_suffix); 360 363 paranoid_system(command); 361 paranoid_free(command);362 363 asprintf(&command, "afio -o -b %ld -M 16m %s %s < %s 2>> %s",364 mr_free(command); 365 366 mr_asprintf(&command, "afio -o -b %ld -M 16m %s %s < %s 2>> %s", 364 367 TAPE_BLOCK_SIZE, zipparams, fname, filelist, MONDO_LOGFILE); 365 paranoid_free(zipparams);366 367 asprintf(&tmp, "echo hi > %s 2> /dev/null", fname);368 mr_free(zipparams); 369 370 mr_asprintf(&tmp, "echo hi > %s 2> /dev/null", fname); 368 371 if (system(tmp)) { 369 372 fatal_error("Unable to write tarball to scratchdir"); 370 373 } 371 paranoid_free(tmp);374 mr_free(tmp); 372 375 373 376 for (res = 99, tries = 0; tries < 3 && res != 0; tries++) { … … 382 385 } 383 386 } 384 paranoid_free(command);387 mr_free(command); 385 388 386 389 retval += res; … … 396 399 ("df -m -P | grep dev/shm | grep -v none | tr -s ' ' '\t' | cut -f4"); 397 400 i = atoi(tmp); 398 paranoid_free(tmp);401 mr_free(tmp); 399 402 400 403 if (i > 0) { … … 440 443 ("Cannot find dvd+rw-format. Please install it or fix your PATH."); 441 444 } 442 paranoid_free(tmp);445 mr_free(tmp); 443 446 #endif 444 447 tmp = find_home_of_exe("growisofs"); … … 447 450 ("Cannot find growisofs. Please install it or fix your PATH."); 448 451 } 449 paranoid_free(tmp);452 mr_free(tmp); 450 453 } 451 454 … … 458 461 459 462 /* 460 asprintf(&tmp, "wc -l %s/archives/filelist.full > %s/archives/filelist.count",bkpinfo->scratchdir, bkpinfo->scratchdir);463 mr_asprintf(&tmp, "wc -l %s/archives/filelist.full > %s/archives/filelist.count",bkpinfo->scratchdir, bkpinfo->scratchdir); 461 464 if (run_program_and_log_output(tmp, 2)) 462 465 { fatal_error("Failed to count filelist.full"); } 463 466 */ 464 asprintf(&tmp, "gzip -9 %s/archives/filelist.full",467 mr_asprintf(&tmp, "gzip -9 %s/archives/filelist.full", 465 468 bkpinfo->scratchdir); 466 469 if (run_program_and_log_output(tmp, 2)) { 467 470 fatal_error("Failed to gzip filelist.full"); 468 471 } 469 paranoid_free(tmp);470 asprintf(&tmp, "cp -f %s/archives/*list*.gz %s", bkpinfo->scratchdir,472 mr_free(tmp); 473 mr_asprintf(&tmp, "cp -f %s/archives/*list*.gz %s", bkpinfo->scratchdir, 471 474 bkpinfo->tmpdir); 472 475 if (run_program_and_log_output(tmp, 2)) { 473 476 fatal_error("Failed to copy to tmpdir"); 474 477 } 475 paranoid_free(tmp);478 mr_free(tmp); 476 479 477 480 copy_mondo_and_mindi_stuff_to_scratchdir(bkpinfo); // payload, too, if it exists 478 481 #if __FreeBSD__ == 5 479 paranoid_alloc(bkpinfo->kernel_path, "/boot/kernel/kernel");482 mr_allocstr(bkpinfo->kernel_path, "/boot/kernel/kernel"); 480 483 #elif __FreeBSD__ == 4 481 paranoid_alloc(bkpinfo->kernel_path, "/kernel");484 mr_allocstr(bkpinfo->kernel_path, "/kernel"); 482 485 #elif linux 483 486 if (figure_out_kernel_path_interactively_if_necessary … … 493 496 } 494 497 retval += do_that_initial_phase(bkpinfo); // prepare 495 asprintf(&tmp, "rm -f %s/images/*.iso", bkpinfo->scratchdir);498 mr_asprintf(&tmp, "rm -f %s/images/*.iso", bkpinfo->scratchdir); 496 499 run_program_and_log_output(tmp, 1); 497 paranoid_free(tmp);500 mr_free(tmp); 498 501 retval += make_those_slices_phase(bkpinfo); // backup BIG files 499 502 retval += do_that_final_phase(bkpinfo); // clean up … … 564 567 assert(bkpinfo != NULL); 565 568 566 asprintf(&tmp,569 mr_asprintf(&tmp, 567 570 "echo '%s' | tr -s ' ' '\n' | grep -x '/dev/.*' | tr -s '\n' ' ' | awk '{print $0\"\\n\";}'", 568 571 bkpinfo->exclude_paths); 569 572 devs_to_exclude = call_program_and_get_last_line_of_output(tmp); 570 paranoid_free(tmp);571 asprintf(&tmp, "devs_to_exclude = '%s'", devs_to_exclude);573 mr_free(tmp); 574 mr_asprintf(&tmp, "devs_to_exclude = '%s'", devs_to_exclude); 572 575 log_msg(2, tmp); 573 paranoid_free(tmp);576 mr_free(tmp); 574 577 mvaddstr_and_log_it(g_currentY, 0, 575 578 "Calling MINDI to create boot+data disks"); 576 asprintf(&tmp, "%s/filelist.full", bkpinfo->tmpdir);579 mr_asprintf(&tmp, "%s/filelist.full", bkpinfo->tmpdir); 577 580 if (!does_file_exist(tmp)) { 578 paranoid_free(tmp);579 asprintf(&tmp, "%s/tmpfs/filelist.full", bkpinfo->tmpdir);581 mr_free(tmp); 582 mr_asprintf(&tmp, "%s/tmpfs/filelist.full", bkpinfo->tmpdir); 580 583 if (!does_file_exist(tmp)) { 581 584 fatal_error … … 584 587 } 585 588 lines_in_filelist = count_lines_in_file(tmp); 586 paranoid_free(tmp);587 asprintf(&tmp, "%s/LAST-FILELIST-NUMBER", bkpinfo->tmpdir);589 mr_free(tmp); 590 mr_asprintf(&tmp, "%s/LAST-FILELIST-NUMBER", bkpinfo->tmpdir); 588 591 last_filelist_number = last_line_of_file(tmp); 589 paranoid_free(tmp);592 mr_free(tmp); 590 593 if (IS_THIS_A_STREAMING_BACKUP(bkpinfo->backup_media_type)) { 591 asprintf(&tape_size_sz, "%ld", bkpinfo->media_size[1]);592 asprintf(&tape_device, bkpinfo->media_device);594 mr_asprintf(&tape_size_sz, "%ld", bkpinfo->media_size[1]); 595 mr_asprintf(&tape_device, bkpinfo->media_device); 593 596 } else { 594 asprintf(&tape_size_sz, " ");595 asprintf(&tape_device, " ");597 mr_asprintf(&tape_size_sz, " "); 598 mr_asprintf(&tape_device, " "); 596 599 } 597 600 if (bkpinfo->use_lzo) { 598 asprintf(&use_lzo_sz, "yes");601 mr_asprintf(&use_lzo_sz, "yes"); 599 602 } else { 600 asprintf(&use_lzo_sz, "no");603 mr_asprintf(&use_lzo_sz, "no"); 601 604 } 602 605 if (bkpinfo->use_star) { 603 asprintf(&use_star_sz, "yes");606 mr_asprintf(&use_star_sz, "yes"); 604 607 } else { 605 asprintf(&use_star_sz, "no");608 mr_asprintf(&use_star_sz, "no"); 606 609 } 607 610 608 611 if (bkpinfo->compression_level > 0) { 609 asprintf(&use_comp_sz, "yes");612 mr_asprintf(&use_comp_sz, "yes"); 610 613 } else { 611 asprintf(&use_comp_sz, "no");612 } 613 614 asprintf(&broken_bios_sz, "yes"); /* assume so */614 mr_asprintf(&use_comp_sz, "no"); 615 } 616 617 mr_asprintf(&broken_bios_sz, "yes"); /* assume so */ 615 618 if (g_cd_recovery) { 616 asprintf(&cd_recovery_sz, "yes");619 mr_asprintf(&cd_recovery_sz, "yes"); 617 620 } else { 618 asprintf(&cd_recovery_sz, "no");621 mr_asprintf(&cd_recovery_sz, "no"); 619 622 } 620 623 /* Field shared between LILO/ELILO */ 621 624 if (bkpinfo->make_cd_use_lilo) { 622 asprintf(&use_lilo_sz, "yes");625 mr_asprintf(&use_lilo_sz, "yes"); 623 626 } else { 624 asprintf(&use_lilo_sz, "no");627 mr_asprintf(&use_lilo_sz, "no"); 625 628 } 626 629 … … 644 647 } 645 648 if ((bootdev) && (strstr(bootdev, "/dev/cciss/"))) { 646 paranoid_free(bootdev);649 mr_free(bootdev); 647 650 bootdev = call_program_and_get_last_line_of_output 648 651 ("mount | grep ' /boot ' | head -1 | cut -d' ' -f1 | cut -dp -f1"); … … 655 658 656 659 if (bkpinfo->boot_loader != '\0') { 657 asprintf(&tmp, "User specified boot loader. It is '%c'.",660 mr_asprintf(&tmp, "User specified boot loader. It is '%c'.", 658 661 bkpinfo->boot_loader); 659 662 log_msg(2, tmp); 660 paranoid_free(tmp);663 mr_free(tmp); 661 664 } else { 662 665 bkpinfo->boot_loader = ch; 663 666 } 664 667 if (bkpinfo->boot_device != NULL) { 665 asprintf(&tmp, "User specified boot device. It is '%s'.",668 mr_asprintf(&tmp, "User specified boot device. It is '%s'.", 666 669 bkpinfo->boot_device); 667 670 log_msg(2, tmp); 668 paranoid_free(tmp);669 paranoid_free(bootdev);671 mr_free(tmp); 672 mr_free(bootdev); 670 673 } else { 671 674 bkpinfo->boot_device = bootdev; … … 687 690 } 688 691 if (bkpinfo->boot_loader == 'L') { 689 asprintf(&bootldr_str, "LILO");692 mr_asprintf(&bootldr_str, "LILO"); 690 693 if (!does_file_exist("/etc/lilo.conf")) { 691 694 fatal_error … … 693 696 } 694 697 } else if (bkpinfo->boot_loader == 'G') { 695 asprintf(&bootldr_str, "GRUB");698 mr_asprintf(&bootldr_str, "GRUB"); 696 699 if (!does_file_exist("/etc/grub.conf") 697 700 && does_file_exist("/boot/grub/grub.conf")) { … … 710 713 } 711 714 } else if (bkpinfo->boot_loader == 'E') { 712 asprintf(&bootldr_str, "ELILO");715 mr_asprintf(&bootldr_str, "ELILO"); 713 716 /* BERLIOS: fix it for SuSE, Debian, Mandrake, ... */ 714 717 if (!does_file_exist("/etc/elilo.conf") … … 723 726 } 724 727 } else if (bkpinfo->boot_loader == 'R') { 725 asprintf(&bootldr_str, "RAW");728 mr_asprintf(&bootldr_str, "RAW"); 726 729 } 727 730 #ifdef __FreeBSD__ 728 731 else if (bkpinfo->boot_loader == 'D') { 729 asprintf(&bootldr_str, "DD");732 mr_asprintf(&bootldr_str, "DD"); 730 733 } 731 734 732 735 else if (bkpinfo->boot_loader == 'B') { 733 asprintf(&bootldr_str, "BOOT0");736 mr_asprintf(&bootldr_str, "BOOT0"); 734 737 } 735 738 #endif 736 739 else { 737 asprintf(&bootldr_str, "unknown");738 } 739 asprintf(&tmp, "Your boot loader is %s and it boots from %s",740 mr_asprintf(&bootldr_str, "unknown"); 741 } 742 mr_asprintf(&tmp, "Your boot loader is %s and it boots from %s", 740 743 bootldr_str, bkpinfo->boot_device); 741 744 log_to_screen(tmp); 742 paranoid_free(tmp);743 asprintf(&tmp, "%s/BOOTLOADER.DEVICE", bkpinfo->tmpdir);745 mr_free(tmp); 746 mr_asprintf(&tmp, "%s/BOOTLOADER.DEVICE", bkpinfo->tmpdir); 744 747 if (write_one_liner_data_file(tmp, bkpinfo->boot_device)) { 745 748 log_msg(1, "%ld: Unable to write one-liner boot device", __LINE__); 746 749 } 747 paranoid_free(tmp);750 mr_free(tmp); 748 751 /* BERLIOS: Use bkptype_to_string without LANG */ 749 752 switch (bkpinfo->backup_media_type) { 750 753 case cdr: 751 asprintf(&value, "cdr");754 mr_asprintf(&value, "cdr"); 752 755 break; 753 756 case cdrw: 754 asprintf(&value, "cdrw");757 mr_asprintf(&value, "cdrw"); 755 758 break; 756 759 case cdstream: 757 asprintf(&value, "cdstream");760 mr_asprintf(&value, "cdstream"); 758 761 break; 759 762 case tape: 760 asprintf(&value, "tape");763 mr_asprintf(&value, "tape"); 761 764 break; 762 765 case udev: 763 asprintf(&value, "udev");766 mr_asprintf(&value, "udev"); 764 767 break; 765 768 case iso: 766 asprintf(&value, "iso");769 mr_asprintf(&value, "iso"); 767 770 break; 768 771 case nfs: 769 asprintf(&value, "nfs");772 mr_asprintf(&value, "nfs"); 770 773 break; 771 774 case dvd: 772 asprintf(&value, "dvd");775 mr_asprintf(&value, "dvd"); 773 776 break; 774 777 default: 775 778 fatal_error("Unknown backup_media_type"); 776 779 } 777 asprintf(&tmp, "%s/BACKUP-MEDIA-TYPE", bkpinfo->tmpdir);780 mr_asprintf(&tmp, "%s/BACKUP-MEDIA-TYPE", bkpinfo->tmpdir); 778 781 if (write_one_liner_data_file(tmp, value)) { 779 782 res++; … … 781 784 __LINE__); 782 785 } 783 paranoid_free(value);784 paranoid_free(tmp);786 mr_free(value); 787 mr_free(tmp); 785 788 log_to_screen(bkpinfo->tmpdir); 786 asprintf(&tmp, "%s/BOOTLOADER.NAME", bkpinfo->tmpdir);789 mr_asprintf(&tmp, "%s/BOOTLOADER.NAME", bkpinfo->tmpdir); 787 790 if (write_one_liner_data_file(tmp, bootldr_str)) { 788 791 res++; … … 790 793 __LINE__); 791 794 } 792 paranoid_free(bootldr_str);793 paranoid_free(tmp);794 asprintf(&tmp, "%s/DIFFERENTIAL", bkpinfo->tmpdir);795 mr_free(bootldr_str); 796 mr_free(tmp); 797 mr_asprintf(&tmp, "%s/DIFFERENTIAL", bkpinfo->tmpdir); 795 798 if (bkpinfo->differential) { 796 799 res += write_one_liner_data_file(tmp, "1"); … … 798 801 res += write_one_liner_data_file(tmp, "0"); 799 802 } 800 paranoid_free(tmp);803 mr_free(tmp); 801 804 802 805 estimated_total_noof_slices = 803 806 size_of_all_biggiefiles_K(bkpinfo) / bkpinfo->optimal_set_size + 1; 804 asprintf(&command, "mkdir -p %s/images", bkpinfo->scratchdir);807 mr_asprintf(&command, "mkdir -p %s/images", bkpinfo->scratchdir); 805 808 if (system(command)) { 806 809 res++; 807 810 log_OS_error("Unable to make images directory"); 808 811 } 809 paranoid_free(command);810 811 asprintf(&command, "mkdir -p %s%s", bkpinfo->scratchdir, MNT_FLOPPY);812 mr_free(command); 813 814 mr_asprintf(&command, "mkdir -p %s%s", bkpinfo->scratchdir, MNT_FLOPPY); 812 815 if (system(command)) { 813 816 res++; 814 817 log_OS_error("Unable to make mnt floppy directory"); 815 818 } 816 paranoid_free(command);817 818 asprintf(&tmp, "BTW, I'm telling Mindi your kernel is '%s'",819 mr_free(command); 820 821 mr_asprintf(&tmp, "BTW, I'm telling Mindi your kernel is '%s'", 819 822 bkpinfo->kernel_path); 820 823 log_to_screen(tmp); 821 paranoid_free(tmp);824 mr_free(tmp); 822 825 823 826 log_msg(1, "lines_in_filelist = %ld", lines_in_filelist); … … 825 828 // Watch it! This next line adds a parameter... 826 829 if (bkpinfo->nonbootable_backup) { 827 asprintf(&tmp, " NONBOOTABLE");830 mr_asprintf(&tmp, " NONBOOTABLE"); 828 831 } else { 829 asprintf(&tmp, " ");830 } 831 832 asprintf(&command,832 mr_asprintf(&tmp, " "); 833 } 834 835 mr_asprintf(&command, 833 836 /* "mindi --custom 2=%s 3=%s/images 4=\"%s\" 5=\"%s\" \ 834 837 6=\"%s\" 7=%ld 8=\"%s\" 9=\"%s\" 10=\"%s\" \ … … 855 858 bkpinfo->differential, // parameter #19 (INT) 856 859 tmp); 857 paranoid_free(tmp);858 paranoid_free(tape_size_sz);859 paranoid_free(use_lzo_sz);860 paranoid_free(tape_device);861 paranoid_free(use_star_sz);862 paranoid_free(use_comp_sz);863 paranoid_free(broken_bios_sz);864 paranoid_free(cd_recovery_sz);865 paranoid_free(last_filelist_number);866 paranoid_free(devs_to_exclude);867 paranoid_free(use_lilo_sz);860 mr_free(tmp); 861 mr_free(tape_size_sz); 862 mr_free(use_lzo_sz); 863 mr_free(tape_device); 864 mr_free(use_star_sz); 865 mr_free(use_comp_sz); 866 mr_free(broken_bios_sz); 867 mr_free(cd_recovery_sz); 868 mr_free(last_filelist_number); 869 mr_free(devs_to_exclude); 870 mr_free(use_lilo_sz); 868 871 869 872 log_msg(2, command); … … 872 875 res = run_program_and_log_to_screen(command, 873 876 "Generating boot+data disks"); 874 paranoid_free(command);877 mr_free(command); 875 878 876 879 if (bkpinfo->nonbootable_backup) { … … 879 882 if (!res) { 880 883 log_to_screen("Boot+data disks were created OK"); 881 asprintf(&command, "mkdir -p /var/cache/mindi/");884 mr_asprintf(&command, "mkdir -p /var/cache/mindi/"); 882 885 log_msg(2, command); 883 886 run_program_and_log_output(command, FALSE); 884 paranoid_free(command);885 886 asprintf(&command,887 mr_free(command); 888 889 mr_asprintf(&command, 887 890 "cp -f %s/images/mindi.iso /var/cache/mindi/mondorescue.iso", 888 891 bkpinfo->scratchdir); 889 892 log_msg(2, command); 890 893 run_program_and_log_output(command, FALSE); 891 paranoid_free(command);894 mr_free(command); 892 895 893 896 if (bkpinfo->nonbootable_backup) { 894 asprintf(&command, "cp -f %s/all.tar.gz %s/images",897 mr_asprintf(&command, "cp -f %s/all.tar.gz %s/images", 895 898 bkpinfo->tmpdir, bkpinfo->scratchdir); 896 899 if (system(command)) { 897 900 fatal_error("Unable to create temporary duff tarball"); 898 paranoid_free(command);899 } 900 } 901 asprintf(&command, "cp -f %s/mindi-*oot*.img %s/images",901 mr_free(command); 902 } 903 } 904 mr_asprintf(&command, "cp -f %s/mindi-*oot*.img %s/images", 902 905 bkpinfo->tmpdir, bkpinfo->scratchdir); 903 906 log_msg(2, command); 904 907 run_program_and_log_output(command, FALSE); 905 paranoid_free(command);906 907 asprintf(&tmp, "cp -f %s/images/all.tar.gz %s",908 mr_free(command); 909 910 mr_asprintf(&tmp, "cp -f %s/images/all.tar.gz %s", 908 911 bkpinfo->scratchdir, bkpinfo->tmpdir); 909 912 if (system(tmp)) { 910 913 fatal_error("Cannot find all.tar.gz in tmpdir"); 911 914 } 912 paranoid_free(tmp);915 mr_free(tmp); 913 916 914 917 if (res) { … … 919 922 } else { 920 923 log_to_screen("Mindi failed to create your boot+data disks."); 921 asprintf(&command, "grep 'Fatal error' /var/log/mindi.log");924 mr_asprintf(&command, "grep 'Fatal error' /var/log/mindi.log"); 922 925 tmp = call_program_and_get_last_line_of_output(command); 923 paranoid_free(command);926 mr_free(command); 924 927 if (strlen(tmp) > 1) { 925 928 popup_and_OK(tmp); 926 929 } 927 paranoid_free(tmp);930 mr_free(tmp); 928 931 } 929 932 return (res); … … 990 993 bkpinfo = (struct s_bkpinfo *) (inbuf + BKPINFO_LOC_OFFSET); 991 994 992 asprintf(&archiving_filelist_fname, FILELIST_FNAME_RAW_SZ,995 mr_asprintf(&archiving_filelist_fname, FILELIST_FNAME_RAW_SZ, 993 996 bkpinfo->tmpdir, 0L); 994 997 archiving_set_no = 0; 995 998 while (does_file_exist(archiving_filelist_fname)) { 996 paranoid_free(archiving_filelist_fname);999 mr_free(archiving_filelist_fname); 997 1000 if (g_exiting) { 998 1001 fatal_error("Execution run aborted (pthread)"); … … 1015 1018 1016 1019 /* backup this set of files */ 1017 asprintf(&archiving_afioball_fname, AFIOBALL_FNAME_RAW_SZ,1020 mr_asprintf(&archiving_afioball_fname, AFIOBALL_FNAME_RAW_SZ, 1018 1021 bkpinfo->tmpdir, archiving_set_no, bkpinfo->zip_suffix); 1019 asprintf(&archiving_filelist_fname, FILELIST_FNAME_RAW_SZ,1022 mr_asprintf(&archiving_filelist_fname, FILELIST_FNAME_RAW_SZ, 1020 1023 bkpinfo->tmpdir, archiving_set_no); 1021 1024 if (!does_file_exist(archiving_filelist_fname)) { … … 1024 1027 FORTY_SPACES, getpid(), this_thread_no, 1025 1028 archiving_set_no); 1026 paranoid_free(archiving_filelist_fname);1027 paranoid_free(archiving_afioball_fname);1029 mr_free(archiving_filelist_fname); 1030 mr_free(archiving_afioball_fname); 1028 1031 break; 1029 1032 } 1030 1033 1031 asprintf(&tmp, AFIOBALL_FNAME_RAW_SZ, bkpinfo->tmpdir,1034 mr_asprintf(&tmp, AFIOBALL_FNAME_RAW_SZ, bkpinfo->tmpdir, 1032 1035 archiving_set_no - ARCH_BUFFER_NUM, bkpinfo->zip_suffix); 1033 1036 if (does_file_exist(tmp)) { … … 1039 1042 log_msg(4, "[%d] - continuing", getpid()); 1040 1043 } 1041 paranoid_free(tmp);1044 mr_free(tmp); 1042 1045 1043 1046 log_msg(4, "%s[%d:%d] - EXATing %d...", FORTY_SPACES, getpid(), 1044 1047 this_thread_no, archiving_set_no); 1045 asprintf(&curr_xattr_list_fname, XATTR_LIST_FNAME_RAW_SZ,1048 mr_asprintf(&curr_xattr_list_fname, XATTR_LIST_FNAME_RAW_SZ, 1046 1049 bkpinfo->tmpdir, archiving_set_no); 1047 asprintf(&curr_acl_list_fname, ACL_LIST_FNAME_RAW_SZ,1050 mr_asprintf(&curr_acl_list_fname, ACL_LIST_FNAME_RAW_SZ, 1048 1051 bkpinfo->tmpdir, archiving_set_no); 1049 1052 get_fattr_list(archiving_filelist_fname, curr_xattr_list_fname); 1050 paranoid_free(curr_xattr_list_fname);1053 mr_free(curr_xattr_list_fname); 1051 1054 get_acl_list(archiving_filelist_fname, curr_acl_list_fname); 1052 paranoid_free(curr_acl_list_fname);1055 mr_free(curr_acl_list_fname); 1053 1056 1054 1057 log_msg(4, "%s[%d:%d] - archiving %d...", FORTY_SPACES, getpid(), … … 1057 1060 archiving_afioball_fname, 1058 1061 archiving_set_no); 1059 paranoid_free(archiving_afioball_fname);1060 paranoid_free(archiving_filelist_fname);1062 mr_free(archiving_afioball_fname); 1063 mr_free(archiving_filelist_fname); 1061 1064 retval += res; 1062 1065 1063 1066 if (res) { 1064 asprintf(&tmp,1067 mr_asprintf(&tmp, 1065 1068 "Errors occurred while archiving set %ld. Please review logs.", 1066 1069 archiving_set_no); 1067 1070 log_to_screen(tmp); 1068 paranoid_free(tmp);1071 mr_free(tmp); 1069 1072 } 1070 1073 if (!semaphore_p()) { … … 1084 1087 this_thread_no, archiving_set_no); 1085 1088 archiving_set_no++; 1086 asprintf(&archiving_filelist_fname, FILELIST_FNAME_RAW_SZ,1089 mr_asprintf(&archiving_filelist_fname, FILELIST_FNAME_RAW_SZ, 1087 1090 bkpinfo->tmpdir, archiving_set_no); 1088 1091 } … … 1096 1099 log_msg(3, "%s[%d:%d] - exiting", FORTY_SPACES, getpid(), 1097 1100 this_thread_no); 1098 paranoid_free(archiving_filelist_fname);1101 mr_free(archiving_filelist_fname); 1099 1102 pthread_exit(NULL); 1100 1103 } … … 1178 1181 1179 1182 assert(bkpinfo != NULL); 1180 asprintf(&data_disks_file, "%s/all.tar.gz", bkpinfo->tmpdir);1183 mr_asprintf(&data_disks_file, "%s/all.tar.gz", bkpinfo->tmpdir); 1181 1184 1182 1185 g_serial_string = call_program_and_get_last_line_of_output("dd \ 1183 1186 if=/dev/urandom bs=16 count=1 2> /dev/null | \ 1184 1187 hexdump | tr -s ' ' '0' | head -n1"); 1185 asprintf(&tmp, "%s...word.", g_serial_string);1186 paranoid_free(g_serial_string);1188 mr_asprintf(&tmp, "%s...word.", g_serial_string); 1189 mr_free(g_serial_string); 1187 1190 g_serial_string = tmp; 1188 1191 log_msg(2, "g_serial_string = '%s'", g_serial_string); 1189 1192 1190 asprintf(&tmpfile, "%s/archives/SERIAL-STRING", bkpinfo->scratchdir);1193 mr_asprintf(&tmpfile, "%s/archives/SERIAL-STRING", bkpinfo->scratchdir); 1191 1194 if (write_one_liner_data_file(tmpfile, g_serial_string)) { 1192 1195 log_msg(1, "%ld: Failed to write serial string", __LINE__); 1193 1196 } 1194 paranoid_free(g_serial_string);1195 paranoid_free(tmpfile);1197 mr_free(g_serial_string); 1198 mr_free(tmpfile); 1196 1199 1197 1200 mvaddstr_and_log_it(g_currentY, 0, "Preparing to archive your data"); … … 1210 1213 log_msg(1, "Backing up to CD's"); 1211 1214 } 1212 paranoid_free(data_disks_file);1213 1214 asprintf(&command, "rm -f %s/%s/%s-[1-9]*.iso", bkpinfo->isodir,1215 mr_free(data_disks_file); 1216 1217 mr_asprintf(&command, "rm -f %s/%s/%s-[1-9]*.iso", bkpinfo->isodir, 1215 1218 bkpinfo->nfs_remote_dir, bkpinfo->prefix); 1216 1219 paranoid_system(command); 1217 paranoid_free(command);1220 mr_free(command); 1218 1221 wipe_archives(bkpinfo->scratchdir); 1219 1222 mvaddstr_and_log_it(g_currentY++, 74, "Done."); … … 1274 1277 /* if not Debian then go ahead & use fdformat */ 1275 1278 tempfile = call_program_and_get_last_line_of_output("mktemp -q /tmp/mondo.XXXXXXXX"); 1276 asprintf(&command, "%s >> %s 2>> %s; rm -f %s", cmd, tempfile,1279 mr_asprintf(&command, "%s >> %s 2>> %s; rm -f %s", cmd, tempfile, 1277 1280 tempfile, tempfile); 1278 1281 log_msg(3, command); … … 1287 1290 maxtracks = 80; 1288 1291 } 1289 paranoid_free(command);1292 mr_free(command); 1290 1293 1291 1294 for (sleep(1); does_file_exist(tempfile); sleep(1)) { … … 1309 1312 } 1310 1313 unlink(tempfile); 1311 paranoid_free(tempfile);1314 mr_free(tempfile); 1312 1315 return (res); 1313 1316 } … … 1338 1341 assert_string_is_neither_NULL_nor_zerolength(device); 1339 1342 if (!system("which superformat > /dev/null 2> /dev/null")) { 1340 asprintf(&command, "superformat %s", device);1343 mr_asprintf(&command, "superformat %s", device); 1341 1344 } else { 1342 1345 #ifdef __FreeBSD__ 1343 asprintf(&command, "fdformat -y %s", device);1346 mr_asprintf(&command, "fdformat -y %s", device); 1344 1347 #else 1345 asprintf(&command, "fdformat %s", device);1348 mr_asprintf(&command, "fdformat %s", device); 1346 1349 #endif 1347 1350 } 1348 asprintf(&title, "Formatting disk %s", device);1351 mr_asprintf(&title, "Formatting disk %s", device); 1349 1352 while ((res = format_disk_SUB(command, title))) { 1350 1353 if (!ask_me_yes_or_no("Failed to format disk. Retry?")) { … … 1352 1355 } 1353 1356 } 1354 paranoid_free(title);1355 paranoid_free(command);1357 mr_free(title); 1358 mr_free(command); 1356 1359 return (res); 1357 1360 } … … 1502 1505 /* maybe */ 1503 1506 tmp = percent_media_full_comment(bkpinfo); 1504 asprintf(&media_usage_comment, "%s", tmp);1505 paranoid_free(tmp);1507 mr_asprintf(&media_usage_comment, "%s", tmp); 1508 mr_free(tmp); 1506 1509 if (!misc_counter_that_is_not_important) { 1507 1510 update_progress_form(media_usage_comment); 1508 1511 } 1509 paranoid_free(media_usage_comment);1512 mr_free(media_usage_comment); 1510 1513 sleep(1); 1511 1514 } else { 1512 1515 // store set N 1513 asprintf(&storing_filelist_fname, FILELIST_FNAME_RAW_SZ,1516 mr_asprintf(&storing_filelist_fname, FILELIST_FNAME_RAW_SZ, 1514 1517 bkpinfo->tmpdir, storing_set_no); 1515 asprintf(&storing_afioball_fname, AFIOBALL_FNAME_RAW_SZ,1518 mr_asprintf(&storing_afioball_fname, AFIOBALL_FNAME_RAW_SZ, 1516 1519 bkpinfo->tmpdir, storing_set_no, bkpinfo->zip_suffix); 1517 asprintf(&curr_xattr_list_fname, XATTR_LIST_FNAME_RAW_SZ,1520 mr_asprintf(&curr_xattr_list_fname, XATTR_LIST_FNAME_RAW_SZ, 1518 1521 bkpinfo->tmpdir, storing_set_no); 1519 asprintf(&curr_acl_list_fname, ACL_LIST_FNAME_RAW_SZ,1522 mr_asprintf(&curr_acl_list_fname, ACL_LIST_FNAME_RAW_SZ, 1520 1523 bkpinfo->tmpdir, storing_set_no); 1521 1524 … … 1529 1532 } 1530 1533 tmp = percent_media_full_comment(bkpinfo); 1531 asprintf(&media_usage_comment, "%s", tmp);1532 paranoid_free(tmp);1534 mr_asprintf(&media_usage_comment, "%s", tmp); 1535 mr_free(tmp); 1533 1536 /* copy to CD (scratchdir) ... and an actual CD-R if necessary */ 1534 1537 if (IS_THIS_A_STREAMING_BACKUP(bkpinfo->backup_media_type)) { … … 1552 1555 storing_afioball_fname, NULL); 1553 1556 } 1554 paranoid_free(storing_filelist_fname);1555 paranoid_free(storing_afioball_fname);1556 paranoid_free(curr_xattr_list_fname);1557 paranoid_free(curr_acl_list_fname);1557 mr_free(storing_filelist_fname); 1558 mr_free(storing_afioball_fname); 1559 mr_free(curr_xattr_list_fname); 1560 mr_free(curr_acl_list_fname); 1558 1561 retval += res; 1559 1562 g_current_progress++; 1560 1563 update_progress_form(media_usage_comment); 1561 paranoid_free(media_usage_comment);1564 mr_free(media_usage_comment); 1562 1565 1563 1566 if (res) { 1564 asprintf(&tmp,1567 mr_asprintf(&tmp, 1565 1568 "Failed to add archive %ld's files to CD dir\n", 1566 1569 storing_set_no); 1567 1570 log_to_screen(tmp); 1568 paranoid_free(tmp);1571 mr_free(tmp); 1569 1572 fatal_error 1570 1573 ("Is your hard disk full? If not, please send the author the logfile."); … … 1584 1587 log_msg(2, "Done."); 1585 1588 if (retval) { 1586 asprintf(&tmp,1589 mr_asprintf(&tmp, 1587 1590 "Your regular files have been archived (with errors)."); 1588 1591 } else { 1589 asprintf(&tmp,1592 mr_asprintf(&tmp, 1590 1593 "Your regular files have been archived successfully"); 1591 1594 } 1592 1595 log_to_screen(tmp); 1593 paranoid_free(tmp);1594 paranoid_free(transfer_block);1595 paranoid_free(result_str);1596 mr_free(tmp); 1597 mr_free(transfer_block); 1598 mr_free(result_str); 1596 1599 return (retval); 1597 1600 } … … 1647 1650 assert_string_is_neither_NULL_nor_zerolength(destfile); 1648 1651 1649 asprintf(&tmp, "%s/isolinux.bin", bkpinfo->scratchdir);1650 asprintf(&tmp2, "%s/isolinux.bin", bkpinfo->tmpdir);1652 mr_asprintf(&tmp, "%s/isolinux.bin", bkpinfo->scratchdir); 1653 mr_asprintf(&tmp2, "%s/isolinux.bin", bkpinfo->tmpdir); 1651 1654 if (does_file_exist(tmp)) { 1652 asprintf(&tmp3, "cp -f %s %s", tmp, tmp2);1655 mr_asprintf(&tmp3, "cp -f %s %s", tmp, tmp2); 1653 1656 paranoid_system(tmp3); 1654 paranoid_free(tmp3);1657 mr_free(tmp3); 1655 1658 } 1656 1659 if (!does_file_exist(tmp) && does_file_exist(tmp2)) { 1657 asprintf(&tmp3, "cp -f %s %s", tmp2, tmp);1660 mr_asprintf(&tmp3, "cp -f %s %s", tmp2, tmp); 1658 1661 paranoid_system(tmp3); 1659 paranoid_free(tmp3);1660 } 1661 paranoid_free(tmp2);1662 paranoid_free(tmp);1662 mr_free(tmp3); 1663 } 1664 mr_free(tmp2); 1665 mr_free(tmp); 1663 1666 1664 1667 if (bkpinfo->backup_media_type == iso && bkpinfo->manual_cd_tray) { … … 1670 1673 /* BERLIOS: Do not ignore getcwd result */ 1671 1674 (void) getcwd(old_pwd, MAX_STR_LEN - 1); 1672 asprintf(&tmp, "chmod 755 %s", bkpinfo->scratchdir);1675 mr_asprintf(&tmp, "chmod 755 %s", bkpinfo->scratchdir); 1673 1676 run_program_and_log_output(tmp, FALSE); 1674 paranoid_free(tmp);1677 mr_free(tmp); 1675 1678 chdir(bkpinfo->scratchdir); 1676 1679 1677 1680 if (bkpinfo->call_before_iso != NULL) { 1678 asprintf(&message_to_screen, "Running pre-ISO call for CD#%d",1681 mr_asprintf(&message_to_screen, "Running pre-ISO call for CD#%d", 1679 1682 g_current_media_number); 1680 1683 res = eval_call_to_make_ISO(bkpinfo, bkpinfo->call_before_iso, … … 1686 1689 log_to_screen("%s...OK", message_to_screen); 1687 1690 } 1688 paranoid_free(message_to_screen);1691 mr_free(message_to_screen); 1689 1692 retval += res; 1690 1693 } … … 1692 1695 if (bkpinfo->call_make_iso != NULL) { 1693 1696 log_msg(2, "bkpinfo->call_make_iso = %s", bkpinfo->call_make_iso); 1694 asprintf(&tmp, "%s/archives/NOT-THE-LAST", bkpinfo->scratchdir);1695 asprintf(&message_to_screen, "Making an ISO (%s #%d)",1697 mr_asprintf(&tmp, "%s/archives/NOT-THE-LAST", bkpinfo->scratchdir); 1698 mr_asprintf(&message_to_screen, "Making an ISO (%s #%d)", 1696 1699 bkpinfo->backup_media_string, 1697 1700 g_current_media_number); … … 1720 1723 retval += res; 1721 1724 #ifdef DVDRWFORMAT 1722 asprintf(&tmp,1725 mr_asprintf(&tmp, 1723 1726 "tail -n8 %s | grep 'blank=full.*dvd-compat.*DAO'", 1724 1727 MONDO_LOGFILE); … … 1738 1741 } 1739 1742 pause_for_N_seconds(5, "Letting DVD drive settle"); 1740 asprintf(&sz_blank_disk, "dvd+rw-format %s",1743 mr_asprintf(&sz_blank_disk, "dvd+rw-format %s", 1741 1744 bkpinfo->media_device); 1742 1745 log_msg(3, "sz_blank_disk = '%s'", sz_blank_disk); … … 1757 1760 ("Format succeeded. Sleeping for 5 seconds to take a breath..."); 1758 1761 } 1759 paranoid_free(sz_blank_disk);1762 mr_free(sz_blank_disk); 1760 1763 pause_for_N_seconds(5, "Letting DVD drive settle"); 1761 1764 if (!bkpinfo->please_dont_eject) { … … 1783 1786 } 1784 1787 } 1785 paranoid_free(tmp);1788 mr_free(tmp); 1786 1789 #endif 1787 1790 if (g_backup_media_type == dvd && !bkpinfo->please_dont_eject) { … … 1789 1792 } 1790 1793 } 1791 paranoid_free(message_to_screen);1794 mr_free(message_to_screen); 1792 1795 } else { 1793 asprintf(&message_to_screen, "Running mkisofs to make %s #%d",1796 mr_asprintf(&message_to_screen, "Running mkisofs to make %s #%d", 1794 1797 bkpinfo->backup_media_string, 1795 1798 g_current_media_number); 1796 1799 log_msg(1, message_to_screen); 1797 asprintf(&result_sz, "Call to mkisofs to make ISO (%s #%d) ",1800 mr_asprintf(&result_sz, "Call to mkisofs to make ISO (%s #%d) ", 1798 1801 bkpinfo->backup_media_string, 1799 1802 g_current_media_number); … … 1821 1824 #ifdef __IA64__ 1822 1825 log_msg(1, "IA64 --> elilo"); 1823 asprintf(&tmp2,"mkisofs -no-emul-boot -b images/mindi-bootroot.%s.img -c boot.cat -o _ISO_ -J -r -p MondoRescue -publisher www.mondorescue.org -A Mondo_Rescue_GPL -V _CD#_ .", bkpinfo->mrconf->mindi_ia64_boot_size);1826 mr_asprintf(&tmp2,"mkisofs -no-emul-boot -b images/mindi-bootroot.%s.img -c boot.cat -o _ISO_ -J -r -p MondoRescue -publisher www.mondorescue.org -A Mondo_Rescue_GPL -V _CD#_ .", bkpinfo->mrconf->mindi_ia64_boot_size); 1824 1827 res = eval_call_to_make_ISO(bkpinfo, 1825 1828 tmp2, … … 1831 1834 // FIXME --- change mkisofs string to MONDO_MKISOFS_REGULAR_SYSLINUX/LILO depending on bkpinfo->make_cd_usE_lilo 1832 1835 // and add ' .' at end 1833 paranoid_free(tmp2);1836 mr_free(tmp2); 1834 1837 log_msg(1, "Non-ia64 --> lilo"); 1835 1838 res = eval_call_to_make_ISO(bkpinfo, … … 1857 1860 } 1858 1861 retval += res; 1859 paranoid_free(message_to_screen);1860 paranoid_free(result_sz);1862 mr_free(message_to_screen); 1863 mr_free(result_sz); 1861 1864 } 1862 1865 … … 1867 1870 "Warning - %s mounted. I'm unmounting it before I burn to it.", 1868 1871 bkpinfo->media_device); 1869 asprintf(&tmp, "umount %s", bkpinfo->media_device);1872 mr_asprintf(&tmp, "umount %s", bkpinfo->media_device); 1870 1873 run_program_and_log_output(tmp, FALSE); 1871 paranoid_free(tmp);1874 mr_free(tmp); 1872 1875 } 1873 1876 } … … 1875 1878 if (bkpinfo->call_burn_iso != NULL) { 1876 1879 log_msg(2, "bkpinfo->call_burn_iso = %s", bkpinfo->call_burn_iso); 1877 asprintf(&message_to_screen, "Burning %s #%d",1880 mr_asprintf(&message_to_screen, "Burning %s #%d", 1878 1881 bkpinfo->backup_media_string, 1879 1882 g_current_media_number); … … 1887 1890 log_to_screen("%s...OK", message_to_screen); 1888 1891 } 1889 paranoid_free(message_to_screen);1892 mr_free(message_to_screen); 1890 1893 retval += res; 1891 1894 } 1892 1895 1893 1896 if (bkpinfo->call_after_iso != NULL) { 1894 asprintf(&message_to_screen, "Running post-ISO call (%s #%d)",1897 mr_asprintf(&message_to_screen, "Running post-ISO call (%s #%d)", 1895 1898 bkpinfo->backup_media_string, 1896 1899 g_current_media_number); … … 1903 1906 log_to_screen("%s...OK", message_to_screen); 1904 1907 } 1905 paranoid_free(message_to_screen);1908 mr_free(message_to_screen); 1906 1909 retval += res; 1907 1910 } … … 1911 1914 log_msg(1, "WARNING - make_iso_fs returned an error"); 1912 1915 } 1913 paranoid_free(old_pwd);1916 mr_free(old_pwd); 1914 1917 return (retval); 1915 1918 } … … 1921 1924 char *command; 1922 1925 bool ret = TRUE; 1923 asprintf(&command,1926 mr_asprintf(&command, 1924 1927 "dd if=%s bs=512 count=1 2> /dev/null | strings | head -n1", 1925 1928 bigfile_fname); … … 1927 1930 tmp = call_program_and_get_last_line_of_output(command); 1928 1931 log_msg(1, "--> tmp = '%s'", tmp); 1929 paranoid_free(command);1932 mr_free(command); 1930 1933 if (strstr(tmp, "NTFS")) { 1931 1934 iamhere("TRUE"); … … 1934 1937 ret = FALSE; 1935 1938 } 1936 paranoid_free(tmp);1939 mr_free(tmp); 1937 1940 return(ret); 1938 1941 } … … 1997 2000 return (0); 1998 2001 } 1999 asprintf(&tmp, "I am now backing up all large files.");2002 mr_asprintf(&tmp, "I am now backing up all large files."); 2000 2003 log_to_screen(tmp); 2001 2004 noof_biggie_files = count_lines_in_file(biggielist_fname); … … 2003 2006 "Please wait. This may take some time.", "", 2004 2007 estimated_total_noof_slices); 2005 paranoid_free(tmp);2008 mr_free(tmp); 2006 2009 2007 2010 if (!(fin = fopen(biggielist_fname, "r"))) { … … 2009 2012 return (1); 2010 2013 } 2011 for ( getline(&bigfile_fname, &n, fin); !feof(fin);2012 getline(&bigfile_fname, &n, fin), biggie_file_number++) {2014 for (mr_getline(&bigfile_fname, &n, fin); !feof(fin); 2015 mr_getline(&bigfile_fname, &n, fin), biggie_file_number++) { 2013 2016 use_ntfsprog = FALSE; 2014 2017 if (bigfile_fname[strlen(bigfile_fname) - 1] < 32) { … … 2021 2024 ftmp = fopen(bigfile_fname, "w"); 2022 2025 paranoid_fclose(ftmp); 2023 asprintf(&tmp, "bigfile %s was deleted - creating a dummy",2026 mr_asprintf(&tmp, "bigfile %s was deleted - creating a dummy", 2024 2027 bigfile_fname); 2025 2028 delete_when_done = TRUE; … … 2035 2038 "Calling ntfsclone in background because %s is an NTFS partition", 2036 2039 bigfile_fname); 2037 asprintf(&sz_devfile, "%s/%d.%d.000",2040 mr_asprintf(&sz_devfile, "%s/%d.%d.000", 2038 2041 bkpinfo->tmpdir, 2039 2042 (int) (random() % 32768), … … 2056 2059 (long int) (pid)); 2057 2060 2058 paranoid_free(sz_devfile);2061 mr_free(sz_devfile); 2059 2062 } 2060 2063 } … … 2081 2084 tmp = calc_checksum_of_file(bigfile_fname); 2082 2085 write_header_block_to_stream((off_t)0, tmp, BLK_STOP_A_BIGGIE); 2083 paranoid_free(tmp);2086 mr_free(tmp); 2084 2087 } 2085 2088 retval += res; … … 2091 2094 } 2092 2095 if (res) { 2093 asprintf(&tmp, "Archiving %s ... Failed!", bigfile_fname);2096 mr_asprintf(&tmp, "Archiving %s ... Failed!", bigfile_fname); 2094 2097 } else { 2095 asprintf(&tmp, "Archiving %s ... OK!", bigfile_fname);2098 mr_asprintf(&tmp, "Archiving %s ... OK!", bigfile_fname); 2096 2099 } 2097 2100 … … 2108 2111 #endif 2109 2112 } 2110 paranoid_free(tmp);2111 paranoid_free(bigfile_fname);2113 mr_free(tmp); 2114 mr_free(bigfile_fname); 2112 2115 paranoid_fclose(fin); 2113 2116 … … 2141 2144 2142 2145 /* BERLIOS: Useless ? 2143 asprintf(&tmp, "%s/archives/filelist.full", bkpinfo->scratchdir);2146 mr_asprintf(&tmp, "%s/archives/filelist.full", bkpinfo->scratchdir); 2144 2147 */ 2145 2148 … … 2152 2155 get_last_filelist_number(bkpinfo) + 1); 2153 2156 2154 asprintf(&curr_filelist_fname, FILELIST_FNAME_RAW_SZ, bkpinfo->tmpdir,2157 mr_asprintf(&curr_filelist_fname, FILELIST_FNAME_RAW_SZ, bkpinfo->tmpdir, 2155 2158 0L); 2156 2159 … … 2158 2161 while (does_file_exist(curr_filelist_fname)) { 2159 2162 /* backup this set of files */ 2160 asprintf(&curr_afioball_fname, AFIOBALL_FNAME_RAW_SZ,2163 mr_asprintf(&curr_afioball_fname, AFIOBALL_FNAME_RAW_SZ, 2161 2164 bkpinfo->tmpdir, curr_set_no, bkpinfo->zip_suffix); 2162 2165 2163 2166 log_msg(1, "EXAT'g set %ld", curr_set_no); 2164 asprintf(&curr_xattr_list_fname, XATTR_LIST_FNAME_RAW_SZ,2167 mr_asprintf(&curr_xattr_list_fname, XATTR_LIST_FNAME_RAW_SZ, 2165 2168 bkpinfo->tmpdir, curr_set_no); 2166 asprintf(&curr_acl_list_fname, ACL_LIST_FNAME_RAW_SZ,2169 mr_asprintf(&curr_acl_list_fname, ACL_LIST_FNAME_RAW_SZ, 2167 2170 bkpinfo->tmpdir, curr_set_no); 2168 2171 get_fattr_list(curr_filelist_fname, curr_xattr_list_fname); … … 2174 2177 retval += res; 2175 2178 if (res) { 2176 asprintf(&tmp,2179 mr_asprintf(&tmp, 2177 2180 "Errors occurred while archiving set %ld. Perhaps your live filesystem changed?", 2178 2181 curr_set_no); 2179 2182 log_to_screen(tmp); 2180 paranoid_free(tmp);2183 mr_free(tmp); 2181 2184 } 2182 2185 2183 2186 tmp = percent_media_full_comment(bkpinfo); 2184 asprintf(&media_usage_comment, "%s", tmp);2185 paranoid_free(tmp);2187 mr_asprintf(&media_usage_comment, "%s", tmp); 2188 mr_free(tmp); 2186 2189 2187 2190 /* copy to CD (scratchdir) ... and an actual CD-R if necessary */ … … 2206 2209 g_current_progress++; 2207 2210 update_progress_form(media_usage_comment); 2208 paranoid_free(media_usage_comment);2211 mr_free(media_usage_comment); 2209 2212 2210 2213 if (res) { 2211 asprintf(&tmp, "Failed to add archive %ld's files to CD dir\n",2214 mr_asprintf(&tmp, "Failed to add archive %ld's files to CD dir\n", 2212 2215 curr_set_no); 2213 2216 log_to_screen(tmp); 2214 paranoid_free(tmp);2217 mr_free(tmp); 2215 2218 fatal_error 2216 2219 ("Is your hard disk is full? If not, please send the author the logfile."); 2217 2220 } 2218 paranoid_free(curr_filelist_fname);2219 paranoid_free(curr_afioball_fname);2220 paranoid_free(curr_xattr_list_fname);2221 paranoid_free(curr_acl_list_fname);2222 asprintf(&curr_filelist_fname, FILELIST_FNAME_RAW_SZ,2221 mr_free(curr_filelist_fname); 2222 mr_free(curr_afioball_fname); 2223 mr_free(curr_xattr_list_fname); 2224 mr_free(curr_acl_list_fname); 2225 mr_asprintf(&curr_filelist_fname, FILELIST_FNAME_RAW_SZ, 2223 2226 bkpinfo->tmpdir, ++curr_set_no); 2224 2227 } 2225 paranoid_free(curr_filelist_fname);2228 mr_free(curr_filelist_fname); 2226 2229 close_progress_form(); 2227 2230 if (retval) { … … 2310 2313 mvaddstr_and_log_it(g_currentY, 0, 2311 2314 "Archiving large files to media "); 2312 asprintf(&biggielist, "%s/archives/biggielist.txt",2315 mr_asprintf(&biggielist, "%s/archives/biggielist.txt", 2313 2316 bkpinfo->scratchdir); 2314 asprintf(&xattr_fname, XATTR_BIGGLST_FNAME_RAW_SZ, bkpinfo->tmpdir);2315 asprintf(&acl_fname, ACL_BIGGLST_FNAME_RAW_SZ, bkpinfo->tmpdir);2316 2317 asprintf(&command, "cp %s/biggielist.txt %s", bkpinfo->tmpdir,2317 mr_asprintf(&xattr_fname, XATTR_BIGGLST_FNAME_RAW_SZ, bkpinfo->tmpdir); 2318 mr_asprintf(&acl_fname, ACL_BIGGLST_FNAME_RAW_SZ, bkpinfo->tmpdir); 2319 2320 mr_asprintf(&command, "cp %s/biggielist.txt %s", bkpinfo->tmpdir, 2318 2321 biggielist); 2319 2322 paranoid_system(command); 2320 paranoid_free(command);2321 2322 asprintf(&blah, "biggielist = %s", biggielist);2323 mr_free(command); 2324 2325 mr_asprintf(&blah, "biggielist = %s", biggielist); 2323 2326 log_msg(2, blah); 2324 paranoid_free(blah);2327 mr_free(blah); 2325 2328 2326 2329 if (!does_file_exist(biggielist)) { … … 2330 2333 get_fattr_list(biggielist, xattr_fname); 2331 2334 get_acl_list(biggielist, acl_fname); 2332 asprintf(&command, "cp %s %s/archives/", xattr_fname,2335 mr_asprintf(&command, "cp %s %s/archives/", xattr_fname, 2333 2336 bkpinfo->scratchdir); 2334 2337 paranoid_system(command); 2335 paranoid_free(command);2336 2337 asprintf(&command, "cp %s %s/archives/", acl_fname,2338 mr_free(command); 2339 2340 mr_asprintf(&command, "cp %s %s/archives/", acl_fname, 2338 2341 bkpinfo->scratchdir); 2339 2342 paranoid_system(command); 2340 paranoid_free(command);2343 mr_free(command); 2341 2344 2342 2345 if (IS_THIS_A_STREAMING_BACKUP(bkpinfo->backup_media_type)) { 2343 2346 res += write_EXAT_files_to_tape(bkpinfo, xattr_fname, acl_fname); 2344 asprintf(&blah, "%ld", count_lines_in_file(biggielist));2347 mr_asprintf(&blah, "%ld", count_lines_in_file(biggielist)); 2345 2348 write_header_block_to_stream((off_t)0, blah, BLK_START_BIGGIEFILES); 2346 paranoid_free(blah);2347 } 2348 paranoid_free(xattr_fname);2349 paranoid_free(acl_fname);2349 mr_free(blah); 2350 } 2351 mr_free(xattr_fname); 2352 mr_free(acl_fname); 2350 2353 2351 2354 res = make_slices_and_images(bkpinfo, biggielist); 2352 paranoid_free(biggielist);2355 mr_free(biggielist); 2353 2356 2354 2357 if (IS_THIS_A_STREAMING_BACKUP(bkpinfo->backup_media_type)) { … … 2418 2421 continue; 2419 2422 } 2420 asprintf(&curr_file, "%s", cf);2423 mr_asprintf(&curr_file, "%s", cf); 2421 2424 if (!does_file_exist(curr_file)) { 2422 2425 log_msg(1, … … 2427 2430 would_occupy += length_of_file(curr_file) / 1024; 2428 2431 } 2429 paranoid_free(curr_file);2432 mr_free(curr_file); 2430 2433 } 2431 2434 va_end(ap); … … 2448 2451 continue; 2449 2452 } 2450 asprintf(&curr_file, "%s", cf);2451 2452 asprintf(&tmp, "mv -f %s %s/archives/", curr_file,2453 mr_asprintf(&curr_file, "%s", cf); 2454 2455 mr_asprintf(&tmp, "mv -f %s %s/archives/", curr_file, 2453 2456 bkpinfo->scratchdir); 2454 2457 res = run_program_and_log_output(tmp, 5); … … 2459 2462 log_msg(8, "Moved %s to CD OK", tmp); 2460 2463 } 2461 paranoid_free(tmp);2462 paranoid_free(curr_file);2464 mr_free(tmp); 2465 mr_free(curr_file); 2463 2466 // unlink (curr_file); 2464 2467 } … … 2518 2521 system("/usr/sbin/fdcontrol -F 1722 /dev/fd0.1722"); 2519 2522 #endif 2520 asprintf(&bootdisk_dev, "%s", DEFAULT_1722MB_DISK);2523 mr_asprintf(&bootdisk_dev, "%s", DEFAULT_1722MB_DISK); 2521 2524 } else if (does_device_exist(BACKUP_1722MB_DISK)) { 2522 asprintf(&bootdisk_dev, "/dev/fd0H1722");2525 mr_asprintf(&bootdisk_dev, "/dev/fd0H1722"); 2523 2526 } else { 2524 2527 log_msg(1, "Warning - can't find a 1.72MB floppy device *sigh*"); 2525 asprintf(&bootdisk_dev, DEFAULT_1722MB_DISK);2526 } 2527 asprintf(&datadisk_dev, "%s", "/dev/fd0");2528 mr_asprintf(&bootdisk_dev, DEFAULT_1722MB_DISK); 2529 } 2530 mr_asprintf(&datadisk_dev, "%s", "/dev/fd0"); 2528 2531 if (!does_device_exist(datadisk_dev)) { 2529 2532 log_msg(1, "Warning - can't find a 1.44MB floppy device *sigh*"); 2530 paranoid_free(datadisk_dev);2531 asprintf(&datadisk_dev, "%s", "/dev/fd0");2533 mr_free(datadisk_dev); 2534 mr_asprintf(&datadisk_dev, "%s", "/dev/fd0"); 2532 2535 } 2533 2536 format_first = ask_me_yes_or_no … … 2538 2541 log_to_screen("Writing boot floppy"); 2539 2542 #ifdef __FreeBSD__ 2540 asprintf(&tmp, "%s/mindi-kern.1722.img", imagesdir);2543 mr_asprintf(&tmp, "%s/mindi-kern.1722.img", imagesdir); 2541 2544 if (format_first) { 2542 2545 format_disk(bootdisk_dev); 2543 2546 } 2544 2547 res += write_image_to_floppy(bootdisk_dev, tmp); 2545 paranoid_free(tmp);2548 mr_free(tmp); 2546 2549 2547 2550 if (ask_me_OK_or_cancel("About to write 1.44MB mfsroot disk")) { … … 2550 2553 format_disk(datadisk_dev); 2551 2554 } 2552 asprintf(&tmp, "%s/mindi-mfsroot.1440.img", imagesdir);2555 mr_asprintf(&tmp, "%s/mindi-mfsroot.1440.img", imagesdir); 2553 2556 write_image_to_floppy(datadisk_dev, tmp); 2554 paranoid_free(tmp);2557 mr_free(tmp); 2555 2558 } 2556 2559 #else 2557 asprintf(&bootdisk_file, "%s/mindi-bootroot.1722.img", imagesdir);2560 mr_asprintf(&bootdisk_file, "%s/mindi-bootroot.1722.img", imagesdir); 2558 2561 if (does_file_exist(bootdisk_file)) { 2559 2562 if (format_first) { … … 2562 2565 res += write_image_to_floppy(bootdisk_dev, bootdisk_file); 2563 2566 } else { 2564 paranoid_free(bootdisk_file);2565 asprintf(&bootdisk_file, "%s/mindi-boot.1440.img", imagesdir);2566 asprintf(&rootdisk_file, "%s/mindi-root.1440.img", imagesdir);2567 mr_free(bootdisk_file); 2568 mr_asprintf(&bootdisk_file, "%s/mindi-boot.1440.img", imagesdir); 2569 mr_asprintf(&rootdisk_file, "%s/mindi-root.1440.img", imagesdir); 2567 2570 root_disk_exists = TRUE; 2568 2571 if (!does_file_exist(rootdisk_file) … … 2572 2575 log_to_screen 2573 2576 ("Failed to find boot/root floppy images. Oh dear."); 2574 paranoid_free(bootdisk_file);2575 paranoid_free(rootdisk_file);2576 paranoid_free(bootdisk_dev);2577 mr_free(bootdisk_file); 2578 mr_free(rootdisk_file); 2579 mr_free(bootdisk_dev); 2577 2580 return (1); 2578 2581 } … … 2586 2589 format_disk(datadisk_dev); 2587 2590 } 2588 asprintf(&tmp, "cat %s > %s", rootdisk_file, datadisk_dev);2591 mr_asprintf(&tmp, "cat %s > %s", rootdisk_file, datadisk_dev); 2589 2592 log_msg(1, "tmp = '%s'", tmp); 2590 2593 res += … … 2592 2595 ("Writing root floppy", tmp); 2593 2596 // res += write_image_to_floppy (datadisk_dev, rootdisk_file); 2594 paranoid_free(tmp);2595 } 2596 paranoid_free(rootdisk_file);2597 paranoid_free(bootdisk_file);2597 mr_free(tmp); 2598 } 2599 mr_free(rootdisk_file); 2600 mr_free(bootdisk_file); 2598 2601 } 2599 2602 #endif 2600 2603 } 2601 paranoid_free(bootdisk_dev);2604 mr_free(bootdisk_dev); 2602 2605 2603 2606 if (IS_THIS_A_STREAMING_BACKUP(bkpinfo->backup_media_type)) { … … 2607 2610 } 2608 2611 for (i = 1; i < 99; i++) { 2609 asprintf(&tmp, "%s/mindi-data-%d.img", imagesdir, i);2612 mr_asprintf(&tmp, "%s/mindi-data-%d.img", imagesdir, i); 2610 2613 log_msg(3, tmp); 2611 2614 if (!does_file_exist(tmp)) { … … 2613 2616 break; 2614 2617 } 2615 asprintf(&comment, "About to write data disk #%d", i);2618 mr_asprintf(&comment, "About to write data disk #%d", i); 2616 2619 if (ask_me_OK_or_cancel(comment)) { 2617 paranoid_free(comment);2618 asprintf(&comment, "Writing data disk #%3d", i);2620 mr_free(comment); 2621 mr_asprintf(&comment, "Writing data disk #%3d", i); 2619 2622 log_to_screen(comment); 2620 paranoid_free(comment);2623 mr_free(comment); 2621 2624 if (format_first) { 2622 2625 res += format_disk(datadisk_dev); … … 2625 2628 } 2626 2629 } 2627 paranoid_free(tmp);2628 paranoid_free(datadisk_dev);2630 mr_free(tmp); 2631 mr_free(datadisk_dev); 2629 2632 return (res); 2630 2633 } … … 2729 2732 continue; 2730 2733 } 2731 asprintf(&curr_file, "%s", cf);2734 mr_asprintf(&curr_file, "%s", cf); 2732 2735 if (!does_file_exist(curr_file)) { 2733 2736 log_msg(1, … … 2752 2755 retval += res; 2753 2756 unlink(curr_file); 2754 paranoid_free(curr_file);2757 mr_free(curr_file); 2755 2758 /* write closing header */ 2756 2759 write_header_block_to_stream((off_t)0, "finished-writing-file", stop_chr); … … 2786 2789 if ((cdrw_device = find_cdrw_device()) != NULL) { 2787 2790 if (!system("which cdrecord > /dev/null 2> /dev/null")) { 2788 asprintf(&cdrecord, "cdrecord dev=%s -atip", cdrw_device);2791 mr_asprintf(&cdrecord, "cdrecord dev=%s -atip", cdrw_device); 2789 2792 } else if (!system("which dvdrecord > /dev/null 2> /dev/null")) { 2790 asprintf(&cdrecord, "cdrecord dev=%s -atip", cdrw_device);2793 mr_asprintf(&cdrecord, "cdrecord dev=%s -atip", cdrw_device); 2791 2794 } else { 2792 asprintf(&cdrecord, " ");2795 mr_asprintf(&cdrecord, " "); 2793 2796 log_msg(2, "Found no cdrecord nor dvdrecord in path."); 2794 2797 } … … 2797 2800 run_program_and_log_output(cdrecord, 5); 2798 2801 } 2799 paranoid_free(cdrecord);2802 mr_free(cdrecord); 2800 2803 } 2801 2804 return(cdrw_device); … … 2827 2830 char *szunmount; 2828 2831 2829 asprintf(&szmsg, "I am about to burn %s #%d",2832 mr_asprintf(&szmsg, "I am about to burn %s #%d", 2830 2833 g_backup_media_string, 2831 2834 g_current_media_number); 2832 2835 log_to_screen(szmsg); 2833 paranoid_free(szmsg);2836 mr_free(szmsg); 2834 2837 if (g_current_media_number < ask_for_one_if_more_than_this) { 2835 2838 return; 2836 2839 } 2837 2840 log_to_screen("Scanning CD-ROM drive..."); 2838 asprintf(&mtpt, "/tmp/cd.mtpt.%ld.%ld", (long int) random(),2841 mr_asprintf(&mtpt, "/tmp/cd.mtpt.%ld.%ld", (long int) random(), 2839 2842 (long int) random()); 2840 2843 make_hole_for_dir(mtpt); … … 2848 2851 retract_CD_tray_and_defeat_autorun(); 2849 2852 */ 2850 asprintf(&tmp, "umount %s", cdrom_dev);2853 mr_asprintf(&tmp, "umount %s", cdrom_dev); 2851 2854 run_program_and_log_output(tmp, 1); 2852 paranoid_free(tmp);2853 asprintf(&szcdno, "%s/archives/THIS-CD-NUMBER", mtpt);2854 asprintf(&szserfname, "%s/archives/SERIAL-STRING", mtpt);2855 asprintf(&szunmount, "umount %s", mtpt);2855 mr_free(tmp); 2856 mr_asprintf(&szcdno, "%s/archives/THIS-CD-NUMBER", mtpt); 2857 mr_asprintf(&szserfname, "%s/archives/SERIAL-STRING", mtpt); 2858 mr_asprintf(&szunmount, "umount %s", mtpt); 2856 2859 cd_number = -1; 2857 asprintf(&tmp, "mount %s %s", cdrom_dev, mtpt);2860 mr_asprintf(&tmp, "mount %s %s", cdrom_dev, mtpt); 2858 2861 if ((attempt_to_mount_returned_this = 2859 2862 run_program_and_log_output(tmp, 1))) { 2860 2863 log_msg(4, "Failed to mount %s at %s", cdrom_dev, mtpt); 2861 2864 log_to_screen("If there's a CD/DVD in the drive, it's blank."); 2862 asprintf(&our_serial_str, "%s", "");2865 mr_asprintf(&our_serial_str, "%s", ""); 2863 2866 } else if (!does_file_exist(szcdno) 2864 2867 || !does_file_exist(szserfname)) { … … 2866 2869 ("%s has data on it but it's probably not a Mondo CD.", 2867 2870 g_backup_media_string); 2868 asprintf(&our_serial_str, "%s", "");2871 mr_asprintf(&our_serial_str, "%s", ""); 2869 2872 } else { 2870 2873 log_to_screen("%s found in drive. It's a Mondo disk.", … … 2872 2875 tmp1 = last_line_of_file(szcdno); 2873 2876 cd_number = atoi(tmp1); 2874 paranoid_free(tmp1);2875 asprintf(&tmp1, "cat %s 2> /dev/null", szserfname);2877 mr_free(tmp1); 2878 mr_asprintf(&tmp1, "cat %s 2> /dev/null", szserfname); 2876 2879 our_serial_str = call_program_and_get_last_line_of_output(tmp1); 2877 paranoid_free(tmp1);2880 mr_free(tmp1); 2878 2881 // FIXME - should be able to use last_line_of_file(), surely? 2879 2882 } 2880 paranoid_free(szcdno);2881 paranoid_free(szserfname);2882 paranoid_free(tmp);2883 mr_free(szcdno); 2884 mr_free(szserfname); 2885 mr_free(tmp); 2883 2886 2884 2887 run_program_and_log_output(szunmount, 1); 2885 paranoid_free(szunmount);2888 mr_free(szunmount); 2886 2889 2887 2890 log_msg(2, "paafcd: cd_number = %d", cd_number); … … 2904 2907 log_to_screen("...but not part of _our_ backup set."); 2905 2908 } 2906 paranoid_free(our_serial_str);2909 mr_free(our_serial_str); 2907 2910 } else { 2908 2911 log_msg(2, … … 2914 2917 g_backup_media_string); 2915 2918 } 2916 paranoid_free(cdrw_device);2917 } 2918 paranoid_free(mtpt);2919 mr_free(cdrw_device); 2920 } 2921 mr_free(mtpt); 2919 2922 2920 2923 if (!ok_go_ahead_burn_it) { 2921 2924 eject_device(cdrom_dev); 2922 asprintf(&tmp,2925 mr_asprintf(&tmp, 2923 2926 "I am about to burn %s #%d of the backup set. Please insert %s and press Enter.", 2924 2927 g_backup_media_string, … … 2926 2929 g_backup_media_string); 2927 2930 popup_and_OK(tmp); 2928 paranoid_free(tmp);2931 mr_free(tmp); 2929 2932 goto gotos_make_me_puke; 2930 2933 } else { 2931 2934 log_msg(2, "paafcd: OK, going ahead and burning it."); 2932 2935 } 2933 paranoid_free(cdrom_dev);2936 mr_free(cdrom_dev); 2934 2937 2935 2938 log_msg(2, … … 3048 3051 if (is_this_file_compressed(biggie_filename) 3049 3052 || bkpinfo->compression_level == 0) { 3050 asprintf(&suffix, "%s", "");3053 mr_asprintf(&suffix, "%s", ""); 3051 3054 // log_it("%s is indeed compressed :-)", filename); 3052 3055 should_I_compress_slices = FALSE; 3053 3056 } else { 3054 asprintf(&suffix, "%s", bkpinfo->zip_suffix);3057 mr_asprintf(&suffix, "%s", bkpinfo->zip_suffix); 3055 3058 should_I_compress_slices = TRUE; 3056 3059 } … … 3061 3064 if (ntfsprog_fifo) { 3062 3065 file_to_openin = ntfsprog_fifo; 3063 asprintf(&checksum_line, "IGNORE");3066 mr_asprintf(&checksum_line, "IGNORE"); 3064 3067 log_msg(2, 3065 3068 "Not calculating checksum for %s: it would take too long", … … 3069 3072 fatal_error("ntfsresize not found"); 3070 3073 } 3071 paranoid_free(tmp);3072 3073 asprintf(&command, "ntfsresize --force --info %s|grep '^You might resize at '|cut -d' ' -f5", biggie_filename);3074 mr_free(tmp); 3075 3076 mr_asprintf(&command, "ntfsresize --force --info %s|grep '^You might resize at '|cut -d' ' -f5", biggie_filename); 3074 3077 log_it("command = %s", command); 3075 3078 tmp = call_program_and_get_last_line_of_output(command); 3076 paranoid_free(command);3079 mr_free(command); 3077 3080 3078 3081 log_it("res of it = %s", tmp); 3079 3082 totallength = (off_t)atoll(tmp); 3080 paranoid_free(tmp);3083 mr_free(tmp); 3081 3084 } else { 3082 3085 file_to_openin = biggie_filename; 3083 3086 if (strchr(biggie_filename,'\'') != NULL) { 3084 asprintf(&command, "md5sum \"%s\"", biggie_filename);3087 mr_asprintf(&command, "md5sum \"%s\"", biggie_filename); 3085 3088 } else { 3086 asprintf(&command, "md5sum '%s'", biggie_filename);3089 mr_asprintf(&command, "md5sum '%s'", biggie_filename); 3087 3090 } 3088 3091 if (!(fin = popen(command, "r"))) { 3089 3092 log_OS_error("Unable to popen-in command"); 3090 paranoid_free(command);3093 mr_free(command); 3091 3094 return (1); 3092 3095 } 3093 paranoid_free(command);3094 (void)getline(&checksum_line, &n, fin);3096 mr_free(command); 3097 mr_getline(&checksum_line, &n, fin); 3095 3098 pclose(fin); 3096 3099 totallength = length_of_file (biggie_filename); … … 3114 3117 fatal_error("checksum_line too big"); 3115 3118 } 3116 paranoid_free(checksum_line);3119 mr_free(checksum_line); 3117 3120 3118 3121 tmp = slice_fname(biggie_file_number, 0, bkpinfo->tmpdir, ""); 3119 3122 fout = fopen(tmp, "w"); 3120 paranoid_free(tmp);3123 mr_free(tmp); 3121 3124 (void) fwrite((void *) &biggiestruct, 1, sizeof(biggiestruct), fout); 3122 3125 paranoid_fclose(fout); … … 3126 3129 if (!(fin = fopen(file_to_openin, "r"))) { 3127 3130 log_OS_error("Unable to openin biggie_filename"); 3128 asprintf(&tmp, "Cannot archive bigfile '%s': not found",3131 mr_asprintf(&tmp, "Cannot archive bigfile '%s': not found", 3129 3132 biggie_filename); 3130 3133 log_to_screen(tmp); 3131 paranoid_free(tmp);3132 3133 paranoid_free(suffix);3134 mr_free(tmp); 3135 3136 mr_free(suffix); 3134 3137 return (1); 3135 3138 } … … 3140 3143 res = move_files_to_cd(bkpinfo, tmp, NULL); 3141 3144 } 3142 paranoid_free(tmp);3145 mr_free(tmp); 3143 3146 i = bkpinfo->optimal_set_size / 256; 3144 3147 for (slice_num = 1; !finished; slice_num++) { … … 3148 3151 tmp = percent_media_full_comment(bkpinfo); 3149 3152 update_progress_form(tmp); 3150 paranoid_free(tmp);3153 mr_free(tmp); 3151 3154 3152 3155 if (!(fout = fopen(curr_slice_fname_uncompressed, "w"))) { 3153 3156 log_OS_error(curr_slice_fname_uncompressed); 3154 3157 3155 paranoid_free(curr_slice_fname_uncompressed);3156 paranoid_free(curr_slice_fname_compressed);3157 paranoid_free(suffix);3158 mr_free(curr_slice_fname_uncompressed); 3159 mr_free(curr_slice_fname_compressed); 3160 mr_free(suffix); 3158 3161 return (1); 3159 3162 } … … 3175 3178 i = 0; 3176 3179 } 3177 paranoid_free(tempblock);3180 mr_free(tempblock); 3178 3181 paranoid_fclose(fout); 3179 3182 if (i > 0) // length_of_file (curr_slice_fname_uncompressed) … … 3185 3188 } 3186 3189 if (should_I_compress_slices && bkpinfo->compression_level > 0) { 3187 asprintf(&command, "%s -%d %s", bkpinfo->zip_exe,3190 mr_asprintf(&command, "%s -%d %s", bkpinfo->zip_exe, 3188 3191 bkpinfo->compression_level, 3189 3192 curr_slice_fname_uncompressed); … … 3195 3198 } else { 3196 3199 /* BERLIOS: Useless 3197 asprintf(&command, "mv %s %s 2>> %s",3200 mr_asprintf(&command, "mv %s %s 2>> %s", 3198 3201 curr_slice_fname_uncompressed, 3199 3202 curr_slice_fname_compressed, MONDO_LOGFILE); … … 3212 3215 } 3213 3216 if (res) { 3214 asprintf(&tmp, "Problem with slice # %ld", slice_num);3217 mr_asprintf(&tmp, "Problem with slice # %ld", slice_num); 3215 3218 } else { 3216 asprintf(&tmp,3219 mr_asprintf(&tmp, 3217 3220 "%s - Bigfile #%ld, slice #%ld compressed OK ", 3218 3221 biggie_filename, biggie_file_number + 1, … … 3229 3232 log_msg(2, tmp); 3230 3233 #endif 3231 paranoid_free(tmp);3232 asprintf(&file_to_archive, "%s", curr_slice_fname_compressed);3234 mr_free(tmp); 3235 mr_asprintf(&file_to_archive, "%s", curr_slice_fname_compressed); 3233 3236 g_current_progress++; 3234 3237 } else { /* if i==0 then ... */ 3235 3238 3236 3239 finished = TRUE; 3237 asprintf(&file_to_archive, "%s",3240 mr_asprintf(&file_to_archive, "%s", 3238 3241 curr_slice_fname_uncompressed); 3239 3242 if (IS_THIS_A_STREAMING_BACKUP(bkpinfo->backup_media_type)) { … … 3251 3254 res = move_files_to_cd(bkpinfo, file_to_archive, NULL); 3252 3255 } 3253 paranoid_free(file_to_archive);3256 mr_free(file_to_archive); 3254 3257 retval += res; 3255 3258 if (res) { 3256 asprintf(&tmp,3259 mr_asprintf(&tmp, 3257 3260 "Failed to add slice %ld of bigfile %ld to scratchdir", 3258 3261 slice_num, biggie_file_number + 1); 3259 3262 log_to_screen(tmp); 3260 paranoid_free(tmp);3263 mr_free(tmp); 3261 3264 fatal_error 3262 3265 ("Hard disk full. You should have bought a bigger one."); 3263 3266 } 3264 paranoid_free(curr_slice_fname_uncompressed);3265 paranoid_free(curr_slice_fname_compressed);3266 } 3267 paranoid_free(suffix);3267 mr_free(curr_slice_fname_uncompressed); 3268 mr_free(curr_slice_fname_compressed); 3269 } 3270 mr_free(suffix); 3268 3271 paranoid_fclose(fin); 3269 3272 if (retval) { 3270 asprintf(&tmp, "Sliced bigfile #%ld...FAILED",3273 mr_asprintf(&tmp, "Sliced bigfile #%ld...FAILED", 3271 3274 biggie_file_number + 1); 3272 3275 } else { 3273 asprintf(&tmp, "Sliced bigfile #%ld...OK!",3276 mr_asprintf(&tmp, "Sliced bigfile #%ld...OK!", 3274 3277 biggie_file_number + 1); 3275 3278 } 3276 3279 log_msg(1, tmp); 3277 paranoid_free(tmp);3280 mr_free(tmp); 3278 3281 return (retval); 3279 3282 } … … 3300 3303 assert_string_is_neither_NULL_nor_zerolength(d); 3301 3304 3302 asprintf(&dir, "%s/archives", d);3303 asprintf(&tmp, "find %s -name '*.afio*' -exec rm -f '{}' \\;", dir);3305 mr_asprintf(&dir, "%s/archives", d); 3306 mr_asprintf(&tmp, "find %s -name '*.afio*' -exec rm -f '{}' \\;", dir); 3304 3307 run_program_and_log_output(tmp, FALSE); 3305 paranoid_free(tmp);3306 3307 asprintf(&tmp, "find %s -name '*list.[0-9]*' -exec rm -f '{}' \\;",3308 mr_free(tmp); 3309 3310 mr_asprintf(&tmp, "find %s -name '*list.[0-9]*' -exec rm -f '{}' \\;", 3308 3311 dir); 3309 3312 run_program_and_log_output(tmp, FALSE); 3310 paranoid_free(tmp);3311 3312 asprintf(&tmp, "find %s -name 'slice*' -exec rm -f '{}' \\;", dir);3313 mr_free(tmp); 3314 3315 mr_asprintf(&tmp, "find %s -name 'slice*' -exec rm -f '{}' \\;", dir); 3313 3316 run_program_and_log_output(tmp, FALSE); 3314 paranoid_free(tmp);3315 3316 asprintf(&tmp, "rm -f %s/cklist*", dir);3317 mr_free(tmp); 3318 3319 mr_asprintf(&tmp, "rm -f %s/cklist*", dir); 3317 3320 run_program_and_log_output(tmp, FALSE); 3318 paranoid_free(tmp);3319 3320 asprintf(&tmp, "rm -f %s/zero", dir);3321 mr_free(tmp); 3322 3323 mr_asprintf(&tmp, "rm -f %s/zero", dir); 3321 3324 run_program_and_log_output(tmp, FALSE); 3322 paranoid_free(tmp);3325 mr_free(tmp); 3323 3326 3324 3327 log_msg(1, "Wiped %s's archives", dir); 3325 asprintf(&tmp, "ls -l %s", dir);3328 mr_asprintf(&tmp, "ls -l %s", dir); 3326 3329 run_program_and_log_output(tmp, FALSE); 3327 paranoid_free(tmp);3328 3329 paranoid_free(dir);3330 mr_free(tmp); 3331 3332 mr_free(dir); 3330 3333 } 3331 3334 … … 3357 3360 // I should really check if there are any slices or tarballs to be copied to CD-R(W)'s; the odds are approx. 1 in a million that there are no files here, so I'll just go ahead & make one more CD anyway 3358 3361 3359 asprintf(&tmp, "Writing the final ISO");3362 mr_asprintf(&tmp, "Writing the final ISO"); 3360 3363 log_msg(2, tmp); 3361 3364 /* BERLIOS: center_string is now broken … … 3367 3370 } 3368 3371 #endif 3369 paranoid_free(tmp);3372 mr_free(tmp); 3370 3373 res = write_iso_and_go_on(bkpinfo, TRUE); 3371 3374 #ifndef _XWIN … … 3432 3435 /* label the ISO with its number */ 3433 3436 3434 asprintf(&cdno_fname, "%s/archives/THIS-CD-NUMBER",3437 mr_asprintf(&cdno_fname, "%s/archives/THIS-CD-NUMBER", 3435 3438 bkpinfo->scratchdir); 3436 3439 fout = fopen(cdno_fname, "w"); 3437 3440 fprintf(fout, "%d", g_current_media_number); 3438 3441 paranoid_fclose(fout); 3439 paranoid_free(cdno_fname);3440 3441 asprintf(&tmp, "cp -f %s/autorun %s/", g_mondo_home,3442 mr_free(cdno_fname); 3443 3444 mr_asprintf(&tmp, "cp -f %s/autorun %s/", g_mondo_home, 3442 3445 bkpinfo->scratchdir); 3443 3446 if (run_program_and_log_output(tmp, FALSE)) { 3444 3447 log_msg(2, "Warning - unable to copy autorun to scratchdir"); 3445 3448 } 3446 paranoid_free(tmp);3449 mr_free(tmp); 3447 3450 3448 3451 /* last CD or not? Label accordingly */ 3449 asprintf(&lastcd_fname, "%s/archives/NOT-THE-LAST",3452 mr_asprintf(&lastcd_fname, "%s/archives/NOT-THE-LAST", 3450 3453 bkpinfo->scratchdir); 3451 3454 if (last_cd) { … … 3459 3462 paranoid_fclose(fout); 3460 3463 } 3461 paranoid_free(lastcd_fname);3464 mr_free(lastcd_fname); 3462 3465 3463 3466 if (space_occupied_by_cd(bkpinfo->scratchdir) / 1024 > 3464 3467 bkpinfo->media_size[g_current_media_number]) { 3465 asprintf(&tmp,3468 mr_asprintf(&tmp, 3466 3469 "Warning! CD is too big. It occupies %ld KB, which is more than the %ld KB allowed.", 3467 3470 (long) space_occupied_by_cd(bkpinfo->scratchdir), 3468 3471 (long) bkpinfo->media_size[g_current_media_number]); 3469 3472 log_to_screen(tmp); 3470 paranoid_free(tmp);3471 } 3472 asprintf(&isofile, "%s/%s/%s-%d.iso", bkpinfo->isodir,3473 mr_free(tmp); 3474 } 3475 mr_asprintf(&isofile, "%s/%s/%s-%d.iso", bkpinfo->isodir, 3473 3476 bkpinfo->nfs_remote_dir, bkpinfo->prefix, 3474 3477 g_current_media_number); … … 3485 3488 else { 3486 3489 log_msg(3, "Great. Found Mike's CD-ROM drive."); 3487 paranoid_free(tmp);3490 mr_free(tmp); 3488 3491 } 3489 3492 } … … 3500 3503 that_one_was_ok = TRUE; 3501 3504 } else { 3502 asprintf(&tmp, "Failed to burn %s #%d. Retry?",3505 mr_asprintf(&tmp, "Failed to burn %s #%d. Retry?", 3503 3506 bkpinfo->backup_media_string, 3504 3507 g_current_media_number); 3505 3508 res = ask_me_yes_or_no(tmp); 3506 paranoid_free(tmp);3509 mr_free(tmp); 3507 3510 if (!res) { 3508 3511 if (ask_me_yes_or_no("Abort the backup?")) { … … 3520 3523 if (using_nfs) 3521 3524 { 3522 asprintf(&tmp,"mv -f %s %s/%s/", isofile, bkpinfo->isodir, bkpinfo->nfs_remote_dir);3525 mr_asprintf(&tmp,"mv -f %s %s/%s/", isofile, bkpinfo->isodir, bkpinfo->nfs_remote_dir); 3523 3526 if (run_program_and_log_output(tmp, FALSE)) 3524 3527 { log_to_screen("Unable to move ISO to NFS dir"); } 3525 3528 } 3526 3529 */ 3527 paranoid_free(isofile);3530 mr_free(isofile); 3528 3531 3529 3532 g_current_media_number++; … … 3532 3535 } 3533 3536 wipe_archives(bkpinfo->scratchdir); 3534 asprintf(&tmp, "rm -Rf %s/images/*gz %s/images/*data*img",3537 mr_asprintf(&tmp, "rm -Rf %s/images/*gz %s/images/*data*img", 3535 3538 bkpinfo->scratchdir, bkpinfo->scratchdir); 3536 3539 if (system(tmp)) { … … 3538 3541 "Error occurred when I tried to delete the redundant IMGs and GZs"); 3539 3542 } 3540 paranoid_free(tmp);3543 mr_free(tmp); 3541 3544 3542 3545 if (last_cd) { … … 3576 3579 "Verifying archives against live filesystem"); 3577 3580 if (bkpinfo->backup_media_type == cdstream) { 3578 paranoid_alloc(bkpinfo->media_device,"/dev/cdrom");3581 mr_allocstr(bkpinfo->media_device,"/dev/cdrom"); 3579 3582 } 3580 3583 verify_tape_backups(bkpinfo); … … 3606 3609 retval += res; 3607 3610 if (res) { 3608 asprintf(&tmp,3611 mr_asprintf(&tmp, 3609 3612 "Warnings/errors were reported while checking %s #%d", 3610 3613 bkpinfo->backup_media_string, 3611 3614 g_current_media_number); 3612 3615 log_to_screen(tmp); 3613 paranoid_free(tmp);3614 3615 } 3616 } 3617 asprintf(&tmp,3616 mr_free(tmp); 3617 3618 } 3619 } 3620 mr_asprintf(&tmp, 3618 3621 "grep 'afio: ' %s | sed 's/afio: //' | grep -vx '/dev/.*' >> /tmp/changed.files", 3619 3622 MONDO_LOGFILE); 3620 3623 system(tmp); 3621 paranoid_free(tmp);3622 3623 asprintf(&tmp,3624 mr_free(tmp); 3625 3626 mr_asprintf(&tmp, 3624 3627 "grep 'star: ' %s | sed 's/star: //' | grep -vx '/dev/.*' >> /tmp/changed.files", 3625 3628 MONDO_LOGFILE); 3626 3629 system(tmp); 3627 paranoid_free(tmp);3630 mr_free(tmp); 3628 3631 3629 3632 run_program_and_log_output("umount " MNT_CDROM, FALSE); … … 3676 3679 p++; 3677 3680 } 3678 asprintf(&title, "Writing %s to floppy", p);3681 mr_asprintf(&title, "Writing %s to floppy", p); 3679 3682 open_evalcall_form(title); 3680 paranoid_free(title);3683 mr_free(title); 3681 3684 3682 3685 /* functional stuff */ … … 3687 3690 maxblocks = 1440; 3688 3691 } 3689 asprintf(&tmp, "maxblocks = %d; p=%s", maxblocks, p);3692 mr_asprintf(&tmp, "maxblocks = %d; p=%s", maxblocks, p); 3690 3693 log_msg(2, tmp); 3691 paranoid_free(tmp);3694 mr_free(tmp); 3692 3695 3693 3696 /* copy data from image to floppy */ … … 3763 3766 char *param = NULL; 3764 3767 3765 mr_conf = (struct s_mr_conf *)malloc(sizeof(struct s_mr_conf)); 3766 if (mr_conf == NULL) { 3767 fatal_error("Unable to malloc mr_conf"); 3768 } 3769 /* Default for everything int : 0 char * : NULL */ 3768 mr_conf = (struct s_mr_conf *)mr_malloc(sizeof(struct s_mr_conf)); 3770 3769 3771 3770 /* mindi conf parameters also needed in mondo */ 3772 mr_conf->mindi_ia64_boot_size = 0; 3773 3774 asprintf(&command, "mindi -printvar IA64_BOOT_SIZE"); 3771 mr_asprintf(&command, "mindi -printvar IA64_BOOT_SIZE"); 3775 3772 fin = popen(command, "r"); 3776 getline(¶m, &n, fin);3773 mr_getline(¶m, &n, fin); 3777 3774 pclose(fin); 3778 paranoid_free(command); 3775 mr_free(command); 3776 3779 3777 mr_conf->mindi_ia64_boot_size = atoi(param); 3780 paranoid_free(param); 3781 3782 mr_conf->mondo_iso_creation_cmd = NULL; 3778 mr_free(param); 3783 3779 3784 3780 /* Finds mondo conf file */ … … 3786 3782 3787 3783 /* mondo conf parameters needed */ 3788 mr_conf->mondo_iso_creation_cmd = mr_conf_sread("mondo_iso_creation_cmd"); 3784 if ((mr_conf->mondo_iso_creation_cmd = mr_conf_sread("mondo_iso_creation_cmd")) == NULL) {; 3785 mr_log_exit(-1,"Unable to get mondo_iso_creation_cmd parameter from conf file\nAborting...\n"); 3786 } 3787 3788 if ((mr_conf->mondo_logfile = mr_conf_sread("mondo_logfile")) == NULL) { 3789 mr_log_exit(-1,"Unable to get mondo_logfile parameter from conf file\nAborting...\n"); 3790 } 3789 3791 3790 3792 mr_conf_close();
Note:
See TracChangeset
for help on using the changeset viewer.