Changeset 900 in MondoRescue
- Timestamp:
- Oct 24, 2006, 8:49:18 AM (18 years ago)
- Location:
- trunk
- Files:
-
- 8 added
- 1 deleted
- 43 edited
- 2 moved
Legend:
- Unmodified
- Added
- Removed
-
trunk/mondo-doc/Makefile.man
r588 r900 38 38 39 39 %.8.ps: %.8 40 @man2dvi ./$< > $<.dvi 41 @dvips -q $<.dvi -o $@ 42 @rm -f $<.dvi 40 @groff -Tps -mandoc ./$< > $@ 43 41 44 42 %.8.pdf: %.8.ps -
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(); -
trunk/mondo/src/common/libmondo-devices.c
r839 r900 17 17 #include "libmondo-fork-EXT.h" 18 18 #include "libmondo-stream-EXT.h" 19 #include "mr_mem.h" 19 20 20 21 #include <sys/ioctl.h> … … 62 63 { 63 64 if (bkpinfo->media_device != NULL) { 64 paranoid_alloc(g_cdrom_drive_is_here, bkpinfo->media_device); // just in case65 paranoid_alloc(g_dvd_drive_is_here, bkpinfo->media_device); // just in case65 mr_allocstr(g_cdrom_drive_is_here, bkpinfo->media_device); // just in case 66 mr_allocstr(g_dvd_drive_is_here, bkpinfo->media_device); // just in case 66 67 } 67 68 } … … 113 114 make_hole_for_dir(mountpoint); 114 115 if (isdigit(device[0])) { 115 paranoid_free(device);116 mr_free(device); 116 117 device = find_cdrom_device(FALSE); 117 118 } … … 123 124 dev = make_vn(device)); 124 125 if (!dev) { 125 asprintf(&command, "Unable to mount ISO (make_vn(%s) failed)",126 mr_asprintf(&command, "Unable to mount ISO (make_vn(%s) failed)", 126 127 device); 127 128 fatal_error(command); 128 129 } 129 paranoid_free(device);130 mr_free(device); 130 131 device = dev; 131 132 #endif … … 137 138 138 139 #ifdef __FreeBSD__ 139 asprintf(&command, "mount_cd9660 -r %s %s 2>> %s",140 mr_asprintf(&command, "mount_cd9660 -r %s %s 2>> %s", 140 141 device, mountpoint, MONDO_LOGFILE); 141 142 #else 142 asprintf(&command, "mount %s -o ro,loop -t iso9660 %s 2>> %s",143 mr_asprintf(&command, "mount %s -o ro,loop -t iso9660 %s 2>> %s", 143 144 device, mountpoint, MONDO_LOGFILE); 144 145 #endif … … 150 151 retval = system(command); 151 152 log_msg(1, "system(%s) returned %d", command, retval); 152 paranoid_free(command);153 mr_free(command); 153 154 154 155 if (retval == 0) { … … 171 172 bool is_this_a_ramdisk = FALSE; 172 173 173 asprintf(&tmp, where_is_root_mounted());174 asprintf(&comment, "root is mounted at %s\n", tmp);174 mr_asprintf(&tmp, where_is_root_mounted()); 175 mr_asprintf(&comment, "root is mounted at %s\n", tmp); 175 176 log_msg(0, comment); 176 paranoid_free(comment);177 mr_free(comment); 177 178 178 179 log_msg(0, … … 194 195 } 195 196 #endif 196 paranoid_free(tmp);197 mr_free(tmp); 197 198 198 199 if (is_this_a_ramdisk) { … … 222 223 char *output = NULL; 223 224 224 paranoid_free(output);225 mr_free(output); 225 226 226 227 switch (bt) { 227 228 case none: 228 asprintf(&output, _("none"));229 mr_asprintf(&output, _("none")); 229 230 break; 230 231 case iso: 231 asprintf(&output, _("iso"));232 mr_asprintf(&output, _("iso")); 232 233 break; 233 234 case cdr: 234 asprintf(&output, _("cdr"));235 mr_asprintf(&output, _("cdr")); 235 236 break; 236 237 case cdrw: 237 asprintf(&output, _("cdrw"));238 mr_asprintf(&output, _("cdrw")); 238 239 break; 239 240 case cdstream: 240 asprintf(&output, _("cdstream"));241 mr_asprintf(&output, _("cdstream")); 241 242 break; 242 243 case nfs: 243 asprintf(&output, _("nfs"));244 mr_asprintf(&output, _("nfs")); 244 245 break; 245 246 case tape: 246 asprintf(&output, _("tape"));247 mr_asprintf(&output, _("tape")); 247 248 break; 248 249 case udev: 249 asprintf(&output, _("udev"));250 mr_asprintf(&output, _("udev")); 250 251 break; 251 252 default: 252 asprintf(&output, _("default"));253 mr_asprintf(&output, _("default")); 253 254 } 254 255 return (output); … … 272 273 if (IS_THIS_A_STREAMING_BACKUP(g_backup_media_type) 273 274 && g_backup_media_type != udev) { 274 asprintf(&command, "mt -f %s offline", dev);275 mr_asprintf(&command, "mt -f %s offline", dev); 275 276 res1 = run_program_and_log_output(command, 1); 276 paranoid_free(command);277 mr_free(command); 277 278 } else { 278 279 res1 = 0; … … 281 282 #ifdef __FreeBSD__ 282 283 if (strstr(dev, "acd")) { 283 asprintf(&command, "cdcontrol -f %s eject", dev);284 } else { 285 asprintf(&command, "camcontrol eject `echo %s | sed 's|/dev/||'`",284 mr_asprintf(&command, "cdcontrol -f %s eject", dev); 285 } else { 286 mr_asprintf(&command, "camcontrol eject `echo %s | sed 's|/dev/||'`", 286 287 dev); 287 288 } 288 289 #else 289 asprintf(&command, "eject %s", dev);290 mr_asprintf(&command, "eject %s", dev); 290 291 #endif 291 292 292 293 log_msg(3, "Ejecting %s", dev); 293 294 res2 = run_program_and_log_output(command, 1); 294 paranoid_free(command);295 mr_free(command); 295 296 if (res1 && res2) { 296 297 return (1); … … 313 314 #ifdef __FreeBSD__ 314 315 if (strstr(dev, "acd")) { 315 asprintf(&command, "cdcontrol -f %s close", dev);316 } else { 317 asprintf(&command, "camcontrol load `echo %s | sed 's|/dev/||'`",316 mr_asprintf(&command, "cdcontrol -f %s close", dev); 317 } else { 318 mr_asprintf(&command, "camcontrol load `echo %s | sed 's|/dev/||'`", 318 319 dev); 319 320 } 320 321 #else 321 asprintf(&command, "eject -t %s", dev);322 mr_asprintf(&command, "eject -t %s", dev); 322 323 #endif 323 324 i = run_program_and_log_output(command, FALSE); 324 paranoid_free(command);325 mr_free(command); 325 326 return (i); 326 327 } … … 341 342 assert_string_is_neither_NULL_nor_zerolength(device); 342 343 343 asprintf(&tmp, "ls %s > /dev/null 2> /dev/null", device);344 mr_asprintf(&tmp, "ls %s > /dev/null 2> /dev/null", device); 344 345 345 346 if (system(tmp)) { … … 348 349 ret = TRUE; 349 350 } 350 paranoid_free(tmp);351 mr_free(tmp); 351 352 return(ret); 352 353 } … … 398 399 #ifdef __FreeBSD__ 399 400 // We assume here that this is running from mondorestore. (It is.) 400 asprintf(&program, "ls %s >/dev/null 2>&1", drive);401 mr_asprintf(&program, "ls %s >/dev/null 2>&1", drive); 401 402 res = system(program); 402 paranoid_free(program);403 mr_free(program); 403 404 return(res); 404 405 #endif 405 406 406 asprintf(&program, "parted2fdisk -l %s 2> /dev/null", drive);407 mr_asprintf(&program, "parted2fdisk -l %s 2> /dev/null", drive); 407 408 fin = popen(program, "r"); 408 409 if (!fin) { 409 410 log_it("program=%s", program); 410 411 log_OS_error("Cannot popen-in program"); 411 paranoid_free(program);412 mr_free(program); 412 413 return (0); 413 414 } 414 paranoid_free(program);415 mr_free(program); 415 416 416 417 searchstr = build_partition_name(drive, partno); 417 asprintf(&tmp, "%s ", searchstr); 418 paranoid_free(searchstr); 419 420 for (res = 0; !res && getline(&incoming, &n, fin);) { 418 mr_asprintf(&tmp, "%s ", searchstr); 419 mr_free(searchstr); 420 421 for (res = 0; !res ;) { 422 mr_getline(&incoming, &n, fin); 421 423 if (strstr(incoming, tmp)) { 422 424 res = 1; 423 425 } 424 426 } 425 paranoid_free(incoming);427 mr_free(incoming); 426 428 427 429 if (pclose(fin)) { 428 430 log_OS_error("Cannot pclose fin"); 429 431 } 430 paranoid_free(tmp);432 mr_free(tmp); 431 433 return (res); 432 434 } … … 450 452 assert_string_is_neither_NULL_nor_zerolength(str); 451 453 452 asprintf(&command,454 mr_asprintf(&command, 453 455 "dd if=%s bs=446 count=1 2> /dev/null | strings | grep \"%s\" > /dev/null 2> /dev/null", 454 456 dev, str); 455 457 ret = system(command); 456 paranoid_free(command);458 mr_free(command); 457 459 if (ret) { 458 460 return (FALSE); … … 477 479 int ret; 478 480 479 asprintf(&command,481 mr_asprintf(&command, 480 482 "dd if=%s bs=512 count=%i 2> /dev/null | strings | grep \"%s\" > /dev/null 2> /dev/null", 481 483 dev, n, str); 482 484 ret = system(command); 483 paranoid_free(command);485 mr_free(command); 484 486 485 487 if (ret) { … … 514 516 if (g_backup_media_type == dvd) { 515 517 if (g_dvd_drive_is_here != NULL) { 516 asprintf(&dev, g_dvd_drive_is_here);518 mr_asprintf(&dev, g_dvd_drive_is_here); 517 519 } else { 518 520 dev = find_dvd_device(); … … 520 522 } else { 521 523 if (g_cdrom_drive_is_here != NULL) { 522 asprintf(&dev, g_cdrom_drive_is_here);524 mr_asprintf(&dev, g_cdrom_drive_is_here); 523 525 } else { 524 526 // find_cdrom_device allocates the string … … 532 534 533 535 if ((dev == NULL) || (! mount_CDROM_here(dev, mountpoint))) { 534 paranoid_free(dev);536 mr_free(dev); 535 537 if (!popup_and_get_string 536 538 (_("CD-ROM device"), _("Please enter your CD-ROM's /dev device"), dev)) { … … 545 547 log_msg(1, _("mount succeeded with %s"), dev); 546 548 } 547 paranoid_free(dev);549 mr_free(dev); 548 550 return(res); 549 551 } … … 565 567 566 568 if (g_cdrw_drive_is_here != NULL) { 567 asprintf(&cdrw_device, g_cdrw_drive_is_here);569 mr_asprintf(&cdrw_device, g_cdrw_drive_is_here); 568 570 log_msg(3, "Been there, done that. Returning %s", cdrw_device); 569 571 return(cdrw_device); … … 577 579 tmp = find_home_of_exe("cdrecord"); 578 580 if (tmp) { 579 asprintf(&cdr_exe, "cdrecord");580 } else { 581 asprintf(&cdr_exe, "dvdrecord");582 } 583 paranoid_free(tmp);581 mr_asprintf(&cdr_exe, "cdrecord"); 582 } else { 583 mr_asprintf(&cdr_exe, "dvdrecord"); 584 } 585 mr_free(tmp); 584 586 585 587 tmp1 = find_home_of_exe(cdr_exe); 586 588 if (tmp1) { 587 asprintf(&command,589 mr_asprintf(&command, 588 590 "%s -scanbus 2> /dev/null | tr -s '\t' ' ' | grep \"[0-9]*,[0-9]*,[0-9]*\" | grep -v \"[0-9]*) \\*\" | grep CD | cut -d' ' -f2 | head -n1", 589 591 cdr_exe); 590 asprintf(&tmp, call_program_and_get_last_line_of_output(command));591 paranoid_free(command);592 } else { 593 asprintf(&tmp, " ");594 } 595 paranoid_free(tmp1);596 paranoid_free(cdr_exe);592 mr_asprintf(&tmp, call_program_and_get_last_line_of_output(command)); 593 mr_free(command); 594 } else { 595 mr_asprintf(&tmp, " "); 596 } 597 mr_free(tmp1); 598 mr_free(cdr_exe); 597 599 598 600 if (strlen(tmp) < 2) { 599 paranoid_free(tmp);601 mr_free(tmp); 600 602 return(NULL); 601 603 } else { 602 604 cdrw_device = tmp; 603 605 604 asprintf(&comment, "Found CDRW device - %s", cdrw_device);606 mr_asprintf(&comment, "Found CDRW device - %s", cdrw_device); 605 607 log_it(comment); 606 paranoid_free(comment);607 608 paranoid_free(g_cdrw_drive_is_here);609 asprintf(&g_cdrw_drive_is_here, cdrw_device);608 mr_free(comment); 609 610 mr_free(g_cdrw_drive_is_here); 611 mr_asprintf(&g_cdrw_drive_is_here, cdrw_device); 610 612 return(cdrw_device); 611 613 } … … 649 651 650 652 if ((g_cdrom_drive_is_here != NULL) && !isdigit(g_cdrom_drive_is_here[0])) { 651 asprintf(&output, g_cdrom_drive_is_here);653 mr_asprintf(&output, g_cdrom_drive_is_here); 652 654 log_msg(3, "Been there, done that. Returning %s", output); 653 655 return(output); 654 656 } 655 657 if ((the_last_place_i_found_it != NULL) && !try_to_mount) { 656 asprintf(&output, the_last_place_i_found_it);658 mr_asprintf(&output, the_last_place_i_found_it); 657 659 log_msg(3, 658 660 "find_cdrom_device() --- returning last found location - '%s'", … … 663 665 tmp = find_home_of_exe("cdrecord"); 664 666 if (tmp) { 665 asprintf(&cdr_exe, "cdrecord");666 } else { 667 asprintf(&cdr_exe, "dvdrecord");668 } 669 paranoid_free(tmp);667 mr_asprintf(&cdr_exe, "cdrecord"); 668 } else { 669 mr_asprintf(&cdr_exe, "dvdrecord"); 670 } 671 mr_free(tmp); 670 672 671 673 tmp = find_home_of_exe(cdr_exe); 672 674 if (!tmp) { 673 asprintf(&output, "/dev/cdrom");675 mr_asprintf(&output, "/dev/cdrom"); 674 676 log_msg(4, "Can't find cdrecord; assuming %s", output); 675 677 if (!does_device_exist(output)) { 676 678 log_msg(4, "That didn't work. Sorry."); 677 paranoid_free(cdr_exe);678 paranoid_free(output);679 mr_free(cdr_exe); 680 mr_free(output); 679 681 return(NULL); 680 682 } else { 681 paranoid_free(cdr_exe);683 mr_free(cdr_exe); 682 684 return(output); 683 685 } 684 686 } 685 paranoid_free(tmp);686 687 asprintf(&command, "%s -scanbus 2> /dev/null", cdr_exe);687 mr_free(tmp); 688 689 mr_asprintf(&command, "%s -scanbus 2> /dev/null", cdr_exe); 688 690 fin = popen(command, "r"); 689 691 if (!fin) { 690 692 log_msg(4, "command=%s", command); 691 693 log_OS_error("Cannot popen command"); 692 paranoid_free(cdr_exe);693 paranoid_free(command);694 mr_free(cdr_exe); 695 mr_free(command); 694 696 return (NULL); 695 697 } 696 paranoid_free(command);697 698 for ( getline(&tmp, &n, fin); !feof(fin);699 getline(&tmp, &n, fin)) {698 mr_free(command); 699 700 for (mr_getline(&tmp, &n, fin); !feof(fin); 701 mr_getline(&tmp, &n, fin)) { 700 702 p = strchr(tmp, '\''); 701 703 if (p) { … … 713 715 *q = '\0'; 714 716 #ifndef __FreeBSD__ 715 paranoid_free(phrase_two);716 asprintf(&phrase_two, p);717 mr_free(phrase_two); 718 mr_asprintf(&phrase_two, p); 717 719 #endif 718 720 } … … 722 724 } 723 725 paranoid_pclose(fin); 724 paranoid_free(tmp);726 mr_free(tmp); 725 727 tmp = NULL; 726 728 n = 0; … … 730 732 log_msg(4, "Not running phase two. String is empty."); 731 733 } else { 732 asprintf(&command, "dmesg | grep \"%s\" 2> /dev/null", phrase_two);734 mr_asprintf(&command, "dmesg | grep \"%s\" 2> /dev/null", phrase_two); 733 735 fin = popen(command, "r"); 734 736 if (!fin) { 735 737 log_msg(4, "Cannot run 2nd command - non-fatal, fortunately"); 736 738 } else { 737 for ( getline(&tmp, &n, fin); !feof(fin);738 getline(&tmp, &n, fin)) {739 for (mr_getline(&tmp, &n, fin); !feof(fin); 740 mr_getline(&tmp, &n, fin)) { 739 741 log_msg(5, "--> '%s'", tmp); 740 742 if (tmp[0] != ' ' && tmp[1] != ' ') { … … 743 745 *p = '\0'; 744 746 if (strstr(tmp, "DVD")) { 745 paranoid_free(dvd_last_resort);746 asprintf(&dvd_last_resort, "/dev/%s", tmp);747 mr_free(dvd_last_resort); 748 mr_asprintf(&dvd_last_resort, "/dev/%s", tmp); 747 749 log_msg(4, 748 750 "Ignoring '%s' because it's a DVD drive", 749 751 tmp); 750 752 } else { 751 asprintf(&output, "/dev/%s", tmp);753 mr_asprintf(&output, "/dev/%s", tmp); 752 754 found_it = TRUE; 753 755 } … … 755 757 } 756 758 } 757 paranoid_free(tmp);759 mr_free(tmp); 758 760 paranoid_pclose(fin); 759 761 } 760 paranoid_free(command);761 } 762 paranoid_free(phrase_two);762 mr_free(command); 763 } 764 mr_free(phrase_two); 763 765 764 766 #endif … … 789 791 "/dev/cd1"))) 790 792 { 791 paranoid_free(cdr_exe);793 mr_free(cdr_exe); 792 794 return(NULL); 793 795 } … … 804 806 log_msg(4, "Well, I'll use the DVD - %s - as a last resort", 805 807 dvd_last_resort); 806 paranoid_free(output);807 asprintf(&output, dvd_last_resort);808 mr_free(output); 809 mr_asprintf(&output, dvd_last_resort); 808 810 found_it = TRUE; 809 811 } 810 812 } 811 paranoid_free(dvd_last_resort);813 mr_free(dvd_last_resort); 812 814 813 815 if (found_it) { 814 asprintf(&tmp, "grep \"%s=ide-scsi\" /proc/cmdline &> /dev/null",816 mr_asprintf(&tmp, "grep \"%s=ide-scsi\" /proc/cmdline &> /dev/null", 815 817 strrchr(output, '/') + 1); 816 818 if (system(tmp) == 0) { … … 819 821 output); 820 822 found_it = FALSE; 821 paranoid_free(output);822 } 823 paranoid_free(tmp);823 mr_free(output); 824 } 825 mr_free(tmp); 824 826 } 825 827 … … 829 831 log_msg(4, "OK, I was wrong, I haven't found it... yet."); 830 832 found_it = FALSE; 831 paranoid_free(output);833 mr_free(output); 832 834 } 833 835 } … … 862 864 g_cdrw_drive_is_here))) 863 865 { 864 paranoid_free(cdr_exe);866 mr_free(cdr_exe); 865 867 return(NULL); 866 868 } … … 875 877 #endif 876 878 877 asprintf(&mountpoint, "/tmp/cd.%d", (int) (random() % 32767));879 mr_asprintf(&mountpoint, "/tmp/cd.%d", (int) (random() % 32767)); 878 880 make_hole_for_dir(mountpoint); 879 881 … … 882 884 log_msg(4, "[Cardigans] I've changed my mind"); 883 885 found_it = FALSE; 884 paranoid_free(output);886 mr_free(output); 885 887 } else { 886 asprintf(&tmp, "%s/archives", mountpoint);888 mr_asprintf(&tmp, "%s/archives", mountpoint); 887 889 if (!does_file_exist(tmp)) { 888 890 log_msg(4, "[Cardigans] I'll take it back"); 889 891 found_it = FALSE; 890 paranoid_free(output);892 mr_free(output); 891 893 } else { 892 asprintf(&command, "umount %s", output);894 mr_asprintf(&command, "umount %s", output); 893 895 paranoid_system(command); 894 paranoid_free(command);896 mr_free(command); 895 897 log_msg(4, "I'm confident the Mondo CD is in %s", output); 896 898 } 897 paranoid_free(tmp);899 mr_free(tmp); 898 900 } 899 901 } 900 902 unlink(mountpoint); 901 paranoid_free(mountpoint);903 mr_free(mountpoint); 902 904 903 905 if (found_it) { 904 906 if (!does_file_exist(output)) { 905 907 log_msg(3, "I still haven't found it."); 906 paranoid_free(output);908 mr_free(output); 907 909 return(NULL); 908 910 } 909 911 log_msg(3, "(find_cdrom_device) --> '%s'", output); 910 asprintf(&the_last_place_i_found_it, output);911 paranoid_free(g_cdrom_drive_is_here);912 asprintf(&g_cdrom_drive_is_here, output);912 mr_asprintf(&the_last_place_i_found_it, output); 913 mr_free(g_cdrom_drive_is_here); 914 mr_asprintf(&g_cdrom_drive_is_here, output); 913 915 return(output); 914 916 } 915 917 916 asprintf(&command,918 mr_asprintf(&command, 917 919 "%s -scanbus | grep \"[0-9],[0-9],[0-9]\" | grep \"[D|C][V|D]\" | grep -n \"\" | grep \"%s\" | cut -d':' -f2", 918 920 cdr_exe, g_cdrw_drive_is_here); 919 paranoid_free(cdr_exe);921 mr_free(cdr_exe); 920 922 921 923 log_msg(1, "command=%s", command); 922 asprintf(&tmp, call_program_and_get_last_line_of_output(command));923 paranoid_free(command);924 mr_asprintf(&tmp, call_program_and_get_last_line_of_output(command)); 925 mr_free(command); 924 926 925 927 if (tmp[0]) { … … 927 929 log_msg(4, "Finally found it at %s", output); 928 930 } else { 929 paranoid_free(tmp);930 paranoid_free(output);931 mr_free(tmp); 932 mr_free(output); 931 933 log_msg(4, "Still couldn't find it."); 932 934 } … … 942 944 943 945 if (g_dvd_drive_is_here != NULL) { 944 asprintf(&output, g_dvd_drive_is_here);946 mr_asprintf(&output, g_dvd_drive_is_here); 945 947 log_msg(3, "Been there, done that. Returning %s", output); 946 948 return (output); 947 949 } 948 950 949 asprintf(&tmp, call_program_and_get_last_line_of_output951 mr_asprintf(&tmp, call_program_and_get_last_line_of_output 950 952 ("dvdrecord -scanbus 2> /dev/null | grep \") '\" | grep -n \"\" | grep DVD | cut -d':' -f1") 951 953 ); 952 954 log_msg(5, "tmp = '%s'", tmp); 953 955 if (!tmp[0]) { 954 paranoid_free(tmp);955 asprintf(&tmp, call_program_and_get_last_line_of_output956 mr_free(tmp); 957 mr_asprintf(&tmp, call_program_and_get_last_line_of_output 956 958 ("cdrecord -scanbus 2> /dev/null | grep \") '\" | grep -n \"\" | grep DVD | cut -d':' -f1") 957 959 ); … … 960 962 devno = atoi(tmp) - 1; 961 963 } 962 paranoid_free(tmp);964 mr_free(tmp); 963 965 964 966 if (devno >= 0) { 965 967 retval = 0; 966 asprintf(&output, "/dev/scd%d", devno);967 paranoid_free(g_dvd_drive_is_here);968 asprintf(&g_dvd_drive_is_here, output);968 mr_asprintf(&output, "/dev/scd%d", devno); 969 mr_free(g_dvd_drive_is_here); 970 mr_asprintf(&g_dvd_drive_is_here, output); 969 971 log_msg(2, "I think DVD is at %s", output); 970 972 } else { … … 1092 1094 assert_string_is_neither_NULL_nor_zerolength(format); 1093 1095 1094 asprintf(&format_sz, "%s ", format);1096 mr_asprintf(&format_sz, "%s ", format); 1095 1097 1096 1098 #ifdef __FreeBSD__ 1097 asprintf(&command,1099 mr_asprintf(&command, 1098 1100 "lsvfs | tr -s '\t' ' ' | grep -v Filesys | grep -v -- -- | cut -d' ' -f1 | tr -s '\n' ' '"); 1099 1101 #else 1100 asprintf(&command,1102 mr_asprintf(&command, 1101 1103 "grep -v nodev /proc/filesystems | tr -s '\t' ' ' | cut -d' ' -f2 | tr -s '\n' ' '"); 1102 1104 #endif 1103 1105 1104 1106 pin = popen(command, "r"); 1105 paranoid_free(command);1107 mr_free(command); 1106 1108 1107 1109 if (!pin) { … … 1109 1111 retval = FALSE; 1110 1112 } else { 1111 getline(&good_formats, &n , pin);1113 mr_getline(&good_formats, &n , pin); 1112 1114 if (pclose(pin)) { 1113 1115 log_OS_error("Cannot pclose good formats"); … … 1115 1117 strip_spaces(good_formats); 1116 1118 // " ntfs 7 " -- um, cheating much? :) 1117 asprintf(&tmp, " %s swap lvm raid ntfs 7 ",good_formats);1118 paranoid_free(good_formats);1119 mr_asprintf(&tmp, " %s swap lvm raid ntfs 7 ",good_formats); 1120 mr_free(good_formats); 1119 1121 good_formats = tmp; 1120 1122 … … 1124 1126 retval = FALSE; 1125 1127 } 1126 paranoid_free(good_formats);1127 } 1128 paranoid_free(format_sz);1128 mr_free(good_formats); 1129 } 1130 mr_free(format_sz); 1129 1131 return (retval); 1130 1132 } … … 1164 1166 log_msg(1, "%s needs to have a '/' prefixed - I'll do it", 1165 1167 device_raw); 1166 asprintf(&tmp, "/%s", device_raw);1167 } else { 1168 asprintf(&tmp, device_raw);1168 mr_asprintf(&tmp, "/%s", device_raw); 1169 } else { 1170 mr_asprintf(&tmp, device_raw); 1169 1171 } 1170 1172 log_msg(1, "Is %s mounted?", tmp); … … 1174 1176 return (FALSE); 1175 1177 } 1176 asprintf(&device_with_tab, "%s\t", tmp);1177 asprintf(&device_with_space, "%s ", tmp);1178 paranoid_free(tmp);1178 mr_asprintf(&device_with_tab, "%s\t", tmp); 1179 mr_asprintf(&device_with_space, "%s ", tmp); 1180 mr_free(tmp); 1179 1181 1180 1182 if (!(fin = popen("mount", "r"))) { … … 1182 1184 return (FALSE); 1183 1185 } 1184 for ( getline(&incoming, &n, fin); !feof(fin);1185 getline(&incoming, &n, fin)) {1186 for (mr_getline(&incoming, &n, fin); !feof(fin); 1187 mr_getline(&incoming, &n, fin)) { 1186 1188 if (strstr(incoming, device_with_space) //> incoming 1187 1189 || strstr(incoming, device_with_tab)) // > incoming) … … 1191 1193 } 1192 1194 } 1193 paranoid_free(incoming);1194 paranoid_free(device_with_tab);1195 mr_free(incoming); 1196 mr_free(device_with_tab); 1195 1197 paranoid_pclose(fin); 1196 1198 1197 asprintf(&tmp, "%s | grep -w \"%s\" > /dev/null 2> /dev/null",1199 mr_asprintf(&tmp, "%s | grep -w \"%s\" > /dev/null 2> /dev/null", 1198 1200 SWAPLIST_COMMAND, device_with_space); 1199 paranoid_free(device_with_space);1201 mr_free(device_with_space); 1200 1202 1201 1203 log_msg(4, "tmp (command) = '%s'", tmp); 1202 1204 if (!system(tmp)) { 1203 paranoid_free(tmp);1205 mr_free(tmp); 1204 1206 return(TRUE); 1205 1207 } 1206 paranoid_free(tmp);1208 mr_free(tmp); 1207 1209 return (FALSE); 1208 1210 } … … 1228 1230 ("/sbin/sysctl -n kern.osreldate")) < 500000) { 1229 1231 do { 1230 paranoid_free(mddevice);1231 asprintf(&mddevice, "vn%ic", vndev++);1232 1233 paranoid_free(command);1234 asprintf(&command, "vnconfig %s %s", mddevice, fname);1232 mr_free(mddevice); 1233 mr_asprintf(&mddevice, "vn%ic", vndev++); 1234 1235 mr_free(command); 1236 mr_asprintf(&command, "vnconfig %s %s", mddevice, fname); 1235 1237 1236 1238 if (vndev > 10) { 1237 paranoid_free(command);1238 paranoid_free(mddevice);1239 mr_free(command); 1240 mr_free(mddevice); 1239 1241 return NULL; 1240 1242 } 1241 1243 } 1242 1244 while (system(command)); 1243 paranoid_free(command);1244 } else { 1245 asprintf(&command, "mdconfig -a -t vnode -f %s", fname);1246 asprintf(&mddevice, call_program_and_get_last_line_of_output(command));1247 paranoid_free(command);1245 mr_free(command); 1246 } else { 1247 mr_asprintf(&command, "mdconfig -a -t vnode -f %s", fname); 1248 mr_asprintf(&mddevice, call_program_and_get_last_line_of_output(command)); 1249 mr_free(command); 1248 1250 1249 1251 if (!strstr(mddevice, "md")) { 1250 paranoid_free(mddevice);1252 mr_free(mddevice); 1251 1253 return NULL; 1252 1254 } 1253 1255 } 1254 asprintf(&device, "/dev/%s", mddevice);1255 paranoid_free(mddevice);1256 mr_asprintf(&device, "/dev/%s", mddevice); 1257 mr_free(mddevice); 1256 1258 return(device); 1257 1259 } … … 1278 1280 (call_program_and_get_last_line_of_output 1279 1281 ("/sbin/sysctl -n kern.osreldate")) < 500000) { 1280 asprintf(&command, "vnconfig -d %s", dname);1282 mr_asprintf(&command, "vnconfig -d %s", dname); 1281 1283 ret = system(command); 1282 paranoid_free(command);1284 mr_free(command); 1283 1285 return(ret); 1284 1286 } else { 1285 asprintf(&command, "mdconfig -d -u %s", dname);1287 mr_asprintf(&command, "mdconfig -d -u %s", dname); 1286 1288 ret = system(command); 1287 paranoid_free(command);1289 mr_free(command); 1288 1290 return(ret); 1289 1291 } … … 1327 1329 } 1328 1330 1329 asprintf(&tmp, "mkdir -p " MNT_CDROM);1331 mr_asprintf(&tmp, "mkdir -p " MNT_CDROM); 1330 1332 run_program_and_log_output(tmp, 5); 1331 paranoid_free(tmp);1333 mr_free(tmp); 1332 1334 1333 1335 if (g_ISO_restore_mode || bkpinfo->backup_media_type == iso … … 1341 1343 } 1342 1344 system("mkdir -p /tmp/isodir &> /dev/null"); 1343 asprintf(&tmp, "%s/%s/%s-%d.iso", bkpinfo->isodir,1345 mr_asprintf(&tmp, "%s/%s/%s-%d.iso", bkpinfo->isodir, 1344 1346 bkpinfo->nfs_remote_dir, bkpinfo->prefix, 1345 1347 cd_number_i_want); 1346 1348 if (!does_file_exist(tmp)) { 1347 paranoid_free(tmp);1348 asprintf(&tmp, "/tmp/isodir/%s/%s-%d.iso",1349 mr_free(tmp); 1350 mr_asprintf(&tmp, "/tmp/isodir/%s/%s-%d.iso", 1349 1351 bkpinfo->nfs_remote_dir, bkpinfo->prefix, 1350 1352 cd_number_i_want); … … 1353 1355 "FIXME - hacking bkpinfo->isodir from '%s' to /tmp/isodir", 1354 1356 bkpinfo->isodir); 1355 paranoid_alloc(bkpinfo->isodir, "/tmp/isodir");1357 mr_allocstr(bkpinfo->isodir, "/tmp/isodir"); 1356 1358 } 1357 1359 } … … 1360 1362 fatal_error("Mommy!"); 1361 1363 } 1362 paranoid_free(tmp);1364 mr_free(tmp); 1363 1365 } 1364 1366 if ((res = what_number_cd_is_this(bkpinfo)) != cd_number_i_want) { 1365 1367 log_msg(3, "Currently, we hold %d but we want %d", res, 1366 1368 cd_number_i_want); 1367 asprintf(&tmp, "Insisting on %s #%d",1369 mr_asprintf(&tmp, "Insisting on %s #%d", 1368 1370 bkpinfo->backup_media_string, 1369 1371 cd_number_i_want); 1370 asprintf(&request, "Please insert %s #%d and press Enter.",1372 mr_asprintf(&request, "Please insert %s #%d and press Enter.", 1371 1373 bkpinfo->backup_media_string, 1372 1374 cd_number_i_want); 1373 1375 log_msg(3, tmp); 1374 paranoid_free(tmp);1376 mr_free(tmp); 1375 1377 1376 1378 while (what_number_cd_is_this(bkpinfo) != cd_number_i_want) { … … 1399 1401 sync(); 1400 1402 } 1401 paranoid_free(request);1403 mr_free(request); 1402 1404 1403 1405 log_msg(1, "Thankyou. Proceeding..."); … … 1494 1496 finish(1); 1495 1497 } 1496 asprintf(&comment, _("What speed is your %s (re)writer?"),1498 mr_asprintf(&comment, _("What speed is your %s (re)writer?"), 1497 1499 bkpinfo->backup_media_string); 1498 1500 if (bkpinfo->backup_media_type == dvd) { 1499 paranoid_free(bkpinfo->media_device);1501 mr_free(bkpinfo->media_device); 1500 1502 bkpinfo->media_device = find_dvd_device(); 1501 asprintf(&tmp, "1");1502 asprintf(&sz_size, "%d", DEFAULT_DVD_DISK_SIZE); // 4.7 salesman's GB = 4.482 real GB = 4582 MB1503 mr_asprintf(&tmp, "1"); 1504 mr_asprintf(&sz_size, "%d", DEFAULT_DVD_DISK_SIZE); // 4.7 salesman's GB = 4.482 real GB = 4582 MB 1503 1505 log_msg(1, "Setting to DVD defaults"); 1504 1506 } else { 1505 paranoid_alloc(bkpinfo->media_device,VANILLA_SCSI_CDROM );1506 asprintf(&tmp, "4");1507 asprintf(&sz_size, "650");1507 mr_allocstr(bkpinfo->media_device,VANILLA_SCSI_CDROM ); 1508 mr_asprintf(&tmp, "4"); 1509 mr_asprintf(&sz_size, "650"); 1508 1510 log_msg(1, "Setting to CD defaults"); 1509 1511 } … … 1514 1516 } 1515 1517 } 1516 paranoid_free(comment);1518 mr_free(comment); 1517 1519 1518 1520 bkpinfo->cdrw_speed = atoi(tmp); // if DVD then this shouldn't ever be used anyway :) 1519 paranoid_free(tmp);1520 1521 asprintf(&comment,1521 mr_free(tmp); 1522 1523 mr_asprintf(&comment, 1522 1524 _("How much data (in Megabytes) will each %s store?"), 1523 1525 bkpinfo->backup_media_string); … … 1527 1529 finish(1); 1528 1530 } 1529 paranoid_free(comment);1531 mr_free(comment); 1530 1532 1531 1533 for (i = 0; i <= MAX_NOOF_MEDIA; i++) { 1532 1534 bkpinfo->media_size[i] = atoi(sz_size); 1533 1535 } 1534 paranoid_free(sz_size);1536 mr_free(sz_size); 1535 1537 1536 1538 if (bkpinfo->media_size[0] <= 0) { … … 1541 1543 case cdstream: 1542 1544 if (bkpinfo->disaster_recovery) { 1543 paranoid_alloc(bkpinfo->media_device, "/dev/cdrom");1545 mr_allocstr(bkpinfo->media_device, "/dev/cdrom"); 1544 1546 log_msg(2, "CD-ROM device assumed to be at %s", 1545 1547 bkpinfo->media_device); … … 1547 1549 || bkpinfo->backup_media_type == dvd) { 1548 1550 if (bkpinfo->media_device == NULL) { 1549 asprintf(&bkpinfo->media_device, "/dev/cdrom");1551 mr_asprintf(&bkpinfo->media_device, "/dev/cdrom"); 1550 1552 } // just for the heck of it :) 1551 1553 log_msg(1, "bkpinfo->media_device = %s", … … 1554 1556 if ((bkpinfo->backup_media_type == dvd) 1555 1557 || (tmp != NULL)) { 1556 paranoid_alloc(bkpinfo->media_device, tmp);1558 mr_allocstr(bkpinfo->media_device, tmp); 1557 1559 log_msg(1, "bkpinfo->media_device = %s", 1558 1560 bkpinfo->media_device); 1559 asprintf(&comment,1561 mr_asprintf(&comment, 1560 1562 _("Please specify your %s drive's /dev entry"), 1561 1563 bkpinfo->backup_media_string); … … 1565 1567 finish(1); 1566 1568 } 1567 paranoid_free(comment);1568 } 1569 paranoid_free(tmp);1569 mr_free(comment); 1570 } 1571 mr_free(tmp); 1570 1572 1571 1573 log_msg(2, "%s device found at %s", … … 1575 1577 bkpinfo->media_device = find_cdrw_device(); 1576 1578 if (bkpinfo->media_device != NULL) { 1577 asprintf(&tmp,1579 mr_asprintf(&tmp, 1578 1580 _("I think I've found your %s burner at SCSI node %s; am I right on the money? Say no if you have an IDE burner and you are running a 2.6 kernel. Instead, specify the IDE burner's /dev address at the next screen."), 1579 1581 bkpinfo->backup_media_string, 1580 1582 bkpinfo->media_device); 1581 1583 if (!ask_me_yes_or_no(tmp)) { 1582 paranoid_free(bkpinfo->media_device);1584 mr_free(bkpinfo->media_device); 1583 1585 } 1584 paranoid_free(tmp);1586 mr_free(tmp); 1585 1587 } else { 1586 1588 if (g_kernel_version < 2.6) { … … 1613 1615 case tape: 1614 1616 1615 paranoid_free(bkpinfo->media_device);1617 mr_free(bkpinfo->media_device); 1616 1618 if (find_tape_device_and_size(bkpinfo->media_device, sz_size)) { 1617 1619 log_msg(3, _("Ok, using vanilla scsi tape.")); 1618 paranoid_alloc(bkpinfo->media_device,VANILLA_SCSI_TAPE"0" );1620 mr_allocstr(bkpinfo->media_device,VANILLA_SCSI_TAPE"0" ); 1619 1621 if ((fin = fopen(bkpinfo->media_device, "r"))) { 1620 1622 paranoid_fclose(fin); 1621 1623 } else { 1622 paranoid_alloc(bkpinfo->media_device,"/dev/osst0");1624 mr_allocstr(bkpinfo->media_device,"/dev/osst0"); 1623 1625 } 1624 1626 } … … 1628 1630 } else { 1629 1631 if (does_file_exist("/tmp/mondo-restore.cfg")) { 1630 paranoid_free(bkpinfo->media_device);1632 mr_free(bkpinfo->media_device); 1631 1633 read_cfg_var("/tmp/mondo-restore.cfg", "media-dev", 1632 1634 bkpinfo->media_device); 1633 1635 } 1634 1636 } 1635 asprintf(&tmp,1637 mr_asprintf(&tmp, 1636 1638 _("I think I've found your tape streamer at %s; am I right on the money?"), 1637 1639 bkpinfo->media_device); 1638 1640 if (!ask_me_yes_or_no(tmp)) { 1639 paranoid_free(bkpinfo->media_device);1640 } 1641 paranoid_free(tmp);1641 mr_free(bkpinfo->media_device); 1642 } 1643 mr_free(tmp); 1642 1644 } else { 1643 1645 if (!popup_and_get_string … … 1649 1651 } 1650 1652 } 1651 asprintf(&tmp, "ls -l %s", bkpinfo->media_device);1653 mr_asprintf(&tmp, "ls -l %s", bkpinfo->media_device); 1652 1654 if (run_program_and_log_output(tmp, FALSE)) { 1653 1655 log_to_screen(_("User has not specified a valid /dev entry")); 1654 1656 finish(1); 1655 1657 } 1656 paranoid_free(tmp);1658 mr_free(tmp); 1657 1659 log_msg(4, "sz_size = %s", sz_size); 1658 paranoid_free(sz_size);1660 mr_free(sz_size); 1659 1661 bkpinfo->media_size[0] = 0; 1660 1662 log_msg(4, "media_size[0] = %ld", bkpinfo->media_size[0]); … … 1708 1710 if (bkpinfo->nfs_mount[strlen(bkpinfo->nfs_mount) - 1] == '/') 1709 1711 bkpinfo->nfs_mount[strlen(bkpinfo->nfs_mount) - 1] = '\0'; 1710 asprintf(&command, "mount | grep \"%s \" | cut -d' ' -f3",1712 mr_asprintf(&command, "mount | grep \"%s \" | cut -d' ' -f3", 1711 1713 bkpinfo->nfs_mount); 1712 paranoid_free(bkpinfo->isodir);1714 mr_free(bkpinfo->isodir); 1713 1715 bkpinfo->isodir = call_program_and_get_last_line_of_output(command); 1714 paranoid_free(command);1715 1716 asprintf(&comment,1716 mr_free(command); 1717 1718 mr_asprintf(&comment, 1717 1719 _("How much data (in Megabytes) will each media store?")); 1718 1720 if (!popup_and_get_string(_("Size"), comment, sz_size)) { … … 1727 1729 finish(1); 1728 1730 } 1729 paranoid_free(comment);1731 mr_free(comment); 1730 1732 } 1731 1733 if (bkpinfo->disaster_recovery) { … … 1739 1741 } 1740 1742 if (!is_this_device_mounted(bkpinfo->nfs_mount)) { 1741 paranoid_free(bkpinfo->isodir);1742 asprintf(&bkpinfo->isodir, "/tmp/isodir.mondo.%d",1743 mr_free(bkpinfo->isodir); 1744 mr_asprintf(&bkpinfo->isodir, "/tmp/isodir.mondo.%d", 1743 1745 (int) (random() % 32768)); 1744 asprintf(&command, "mkdir -p %s", bkpinfo->isodir);1746 mr_asprintf(&command, "mkdir -p %s", bkpinfo->isodir); 1745 1747 run_program_and_log_output(command, 5); 1746 paranoid_free(command);1747 1748 asprintf(&tmp, "mount -t nfs -o nolock %s %s", bkpinfo->nfs_mount,1748 mr_free(command); 1749 1750 mr_asprintf(&tmp, "mount -t nfs -o nolock %s %s", bkpinfo->nfs_mount, 1749 1751 bkpinfo->isodir); 1750 1752 run_program_and_log_output(tmp, 5); 1751 paranoid_free(tmp);1752 asprintf(&g_selfmounted_isodir, bkpinfo->isodir);1753 mr_free(tmp); 1754 mr_asprintf(&g_selfmounted_isodir, bkpinfo->isodir); 1753 1755 } 1754 1756 if (!is_this_device_mounted(bkpinfo->nfs_mount)) { … … 1763 1765 } 1764 1766 1765 asprintf(&command, "echo hi > '%s/%s/.dummy.txt'", bkpinfo->isodir,1767 mr_asprintf(&command, "echo hi > '%s/%s/.dummy.txt'", bkpinfo->isodir, 1766 1768 bkpinfo->nfs_remote_dir); 1767 1769 while (run_program_and_log_output(command, FALSE)) { 1768 asprintf(&prompt,1770 mr_asprintf(&prompt, 1769 1771 _("Directory '%s' under mountpoint '%s' does not exist or is not writable. You can fix this or change the directory and retry or cancel the backup."), 1770 1772 bkpinfo->nfs_remote_dir, bkpinfo->isodir); … … 1774 1776 finish(1); 1775 1777 } 1776 paranoid_free(prompt);1777 1778 paranoid_free(command);1779 asprintf(&command, "echo hi > %s/%s/.dummy.txt",1778 mr_free(prompt); 1779 1780 mr_free(command); 1781 mr_asprintf(&command, "echo hi > %s/%s/.dummy.txt", 1780 1782 bkpinfo->isodir, bkpinfo->nfs_remote_dir); 1781 1783 } 1782 paranoid_free(command);1784 mr_free(command); 1783 1785 1784 1786 if (!popup_and_get_string … … 1845 1847 1846 1848 if (bkpinfo->boot_device) { 1847 paranoid_free(bkpinfo->boot_device);1849 mr_free(bkpinfo->boot_device); 1848 1850 } 1849 1851 #ifdef __FreeBSD__ … … 1903 1905 } 1904 1906 bkpinfo->boot_loader = i; 1905 asprintf(&bkpinfo->include_paths, "/");1907 mr_asprintf(&bkpinfo->include_paths, "/"); 1906 1908 if (!popup_and_get_string 1907 1909 (_("Backup paths"), … … 1916 1918 if (bkpinfo->exclude_paths != NULL) { 1917 1919 tmp1 = bkpinfo->exclude_paths; 1918 asprintf(&bkpinfo->exclude_paths, "%s %s", tmp1, tmp);1919 paranoid_free(tmp1);1920 mr_asprintf(&bkpinfo->exclude_paths, "%s %s", tmp1, tmp); 1921 mr_free(tmp1); 1920 1922 } else { 1921 1923 bkpinfo->exclude_paths = tmp; 1922 1924 } 1923 1925 } 1924 paranoid_free(tmp);1926 mr_free(tmp); 1925 1927 // NTFS 1926 1928 tmp = call_program_and_get_last_line_of_output … … 1936 1938 if (bkpinfo->image_devs != NULL) { 1937 1939 tmp2 = bkpinfo->image_devs; 1938 asprintf(&bkpinfo->image_devs, "%s %s", tmp2, tmp1);1939 paranoid_free(tmp2);1940 mr_asprintf(&bkpinfo->image_devs, "%s %s", tmp2, tmp1); 1941 mr_free(tmp2); 1940 1942 } else { 1941 1943 bkpinfo->image_devs = tmp1; 1942 1944 } 1943 paranoid_free(tmp1);1944 } 1945 paranoid_free(tmp);1945 mr_free(tmp1); 1946 } 1947 mr_free(tmp); 1946 1948 1947 1949 if (!popup_and_get_string … … 1961 1963 if (!ask_me_yes_or_no 1962 1964 (_("Are you confident that your kernel is a sane, sensible, standard Linux kernel? Say 'no' if you are using a Gentoo <1.4 or Debian <3.0, please."))){ 1963 paranoid_alloc(bkpinfo->kernel_path, "FAILSAFE");1965 mr_allocstr(bkpinfo->kernel_path, "FAILSAFE"); 1964 1966 } 1965 1967 #endif … … 1992 1994 log_it("media size = %ld", bkpinfo->media_size[1]); 1993 1995 log_it("media type = %s", bkpinfo->backup_media_string); 1994 paranoid_free(tmp);1996 mr_free(tmp); 1995 1997 log_it("prefix = %s", bkpinfo->prefix); 1996 1998 log_it("compression = %ld", bkpinfo->compression_level); … … 2024 2026 ("mount -t coda,ncpfs,nfs,smbfs,cifs,afs,mvfs | tr -s '\t' ' ' | cut -d' ' -f3 | tr -s '\n' ' ' | awk '{print $0;}'")); 2025 2027 /* BERLIOS : Useless 2026 asprintf(&exclude_these_devices,2028 mr_asprintf(&exclude_these_devices, 2027 2029 call_program_and_get_last_line_of_output 2028 2030 ("tr -s '\t' ' ' < /etc/fstab | grep -E '( (coda|ncpfs|nfs|smbfs|cifs|mvfs) )' | cut -d' ' -f1 | tr -s '\n' ' ' | awk '{print $0;}'")); … … 2057 2059 2058 2060 if (tmp[0] != '/') { 2059 asprintf(&sz, "/%s", tmp);2060 paranoid_free(tmp);2061 mr_asprintf(&sz, "/%s", tmp); 2062 mr_free(tmp); 2061 2063 tmp = sz; 2062 2064 } … … 2065 2067 } 2066 2068 i = (int) (random() % 32768); 2067 paranoid_free(bkpinfo->tmpdir);2068 asprintf(&bkpinfo->tmpdir, "%s/mondo.tmp.%d", tmp, i);2069 mr_free(bkpinfo->tmpdir); 2070 mr_asprintf(&bkpinfo->tmpdir, "%s/mondo.tmp.%d", tmp, i); 2069 2071 log_it("bkpinfo->tmpdir is being set to %s", bkpinfo->tmpdir); 2070 2072 2071 paranoid_free(bkpinfo->scratchdir);2072 asprintf(&bkpinfo->scratchdir, "%s/mondo.scratch.%d", tmp, i);2073 mr_free(bkpinfo->scratchdir); 2074 mr_asprintf(&bkpinfo->scratchdir, "%s/mondo.scratch.%d", tmp, i); 2073 2075 log_it("bkpinfo->scratchdir is being set to %s", bkpinfo->scratchdir); 2074 2076 2075 asprintf(&g_erase_tmpdir_and_scratchdir, "rm -Rf %s %s", bkpinfo->tmpdir,2077 mr_asprintf(&g_erase_tmpdir_and_scratchdir, "rm -Rf %s %s", bkpinfo->tmpdir, 2076 2078 bkpinfo->scratchdir); 2077 2079 2078 asprintf(&command, "rm -Rf %s/mondo.tmp.* %s/mondo.scratch.*", tmp, tmp);2079 paranoid_free(tmp);2080 mr_asprintf(&command, "rm -Rf %s/mondo.tmp.* %s/mondo.scratch.*", tmp, tmp); 2081 mr_free(tmp); 2080 2082 2081 2083 paranoid_system(command); 2082 paranoid_free(command);2084 mr_free(command); 2083 2085 } 2084 2086 … … 2099 2101 char *command; 2100 2102 2101 paranoid_free(output);2103 mr_free(output); 2102 2104 if (!dev || dev[0] == '\0') { 2103 2105 return (FALSE); … … 2109 2111 return (FALSE); 2110 2112 } 2111 asprintf(&command, "dd bs=%ld count=1 if=%s of=/dev/null &> /dev/null",2113 mr_asprintf(&command, "dd bs=%ld count=1 if=%s of=/dev/null &> /dev/null", 2112 2114 512L, dev); 2113 2115 if (!run_program_and_log_output(command, FALSE) 2114 2116 && !run_program_and_log_output(command, FALSE)) { 2115 asprintf(&output, dev);2117 mr_asprintf(&output, dev); 2116 2118 log_msg(4, "Found it - %s", dev); 2117 paranoid_free(command);2119 mr_free(command); 2118 2120 return (TRUE); 2119 2121 } else { 2120 2122 log_msg(4, "It's not %s", dev); 2121 paranoid_free(command);2123 mr_free(command); 2122 2124 return (FALSE); 2123 2125 } … … 2141 2143 assert(bkpinfo != NULL); 2142 2144 if (g_ISO_restore_mode) { 2143 asprintf(&tmp, "mount | grep iso9660 | awk '{print $3;}'");2145 mr_asprintf(&tmp, "mount | grep iso9660 | awk '{print $3;}'"); 2144 2146 2145 2147 tmp1 = call_program_and_get_last_line_of_output(tmp); 2146 paranoid_free(tmp);2147 2148 asprintf(&mountdev, "%s/archives/THIS-CD-NUMBER", tmp1);2149 paranoid_free(tmp1);2148 mr_free(tmp); 2149 2150 mr_asprintf(&mountdev, "%s/archives/THIS-CD-NUMBER", tmp1); 2151 mr_free(tmp1); 2150 2152 2151 2153 tmp = last_line_of_file(mountdev); 2152 2154 cd_number = atoi(tmp); 2153 paranoid_free(mountdev);2154 paranoid_free(tmp);2155 mr_free(mountdev); 2156 mr_free(tmp); 2155 2157 2156 2158 return (cd_number); … … 2167 2169 tmp = last_line_of_file(MNT_CDROM "/archives/THIS-CD-NUMBER"); 2168 2170 cd_number = atoi(tmp); 2169 paranoid_free(tmp);2171 mr_free(tmp); 2170 2172 return (cd_number); 2171 2173 } … … 2190 2192 ("mount | grep \" on / \" | cut -d' ' -f1 | sed s/[0-9]// | sed s/[0-9]//"); 2191 2193 if (strstr(tmp, "/dev/cciss/")) { 2192 paranoid_free(tmp);2194 mr_free(tmp); 2193 2195 tmp = call_program_and_get_last_line_of_output 2194 2196 ("mount | grep \" on / \" | cut -d' ' -f1 | cut -dp -f1"); 2195 2197 } 2196 2198 if (strstr(tmp, "/dev/md")) { 2197 paranoid_free(tmp);2199 mr_free(tmp); 2198 2200 tmp = call_program_and_get_last_line_of_output 2199 2201 ("mount | grep \" on / \" | cut -d' ' -f1"); … … 2278 2280 #endif 2279 2281 assert(which_device != NULL); 2280 asprintf(&list_drives_cmd,2282 mr_asprintf(&list_drives_cmd, 2281 2283 "parted2fdisk -l 2>/dev/null | grep \"/dev/.*:\" | tr -s ':' ' ' | tr -s ' ' '\n' | grep /dev/; echo %s", 2282 2284 where_is_root_mounted()); … … 2285 2287 if (!(pdrives = popen(list_drives_cmd, "r"))) { 2286 2288 log_OS_error("Unable to open list of drives"); 2287 paranoid_free(list_drives_cmd);2289 mr_free(list_drives_cmd); 2288 2290 return ('\0'); 2289 2291 } 2290 paranoid_free(list_drives_cmd);2291 2292 for ( getline(¤t_drive, &n, pdrives); !feof(pdrives);2293 getline(¤t_drive, &n, pdrives)) {2292 mr_free(list_drives_cmd); 2293 2294 for (mr_getline(¤t_drive, &n, pdrives); !feof(pdrives); 2295 mr_getline(¤t_drive, &n, pdrives)) { 2294 2296 strip_spaces(current_drive); 2295 2297 log_it("looking at drive %s's MBR", current_drive); 2296 2298 if (does_string_exist_in_boot_block(current_drive, "GRUB")) { 2297 2299 count_grubs++; 2298 paranoid_alloc(which_device,current_drive);2300 mr_allocstr(which_device,current_drive); 2299 2301 break; 2300 2302 } 2301 2303 if (does_string_exist_in_boot_block(current_drive, "LILO")) { 2302 2304 count_lilos++; 2303 paranoid_alloc(which_device,current_drive);2305 mr_allocstr(which_device,current_drive); 2304 2306 break; 2305 2307 } … … 2371 2373 log_it 2372 2374 ("resolve_softlinks_to_get_to_actual_device_file --- device not found"); 2373 asprintf(&output, incoming);2374 } else { 2375 asprintf(&curr_fname, incoming);2375 mr_asprintf(&output, incoming); 2376 } else { 2377 mr_asprintf(&curr_fname, incoming); 2376 2378 lstat(curr_fname, &statbuf); 2377 2379 while (S_ISLNK(statbuf.st_mode)) { 2378 2380 log_msg(1, "curr_fname = %s", curr_fname); 2379 asprintf(&command, "file %s", curr_fname);2381 mr_asprintf(&command, "file %s", curr_fname); 2380 2382 tmp = call_program_and_get_last_line_of_output(command); 2381 paranoid_free(command);2383 mr_free(command); 2382 2384 2383 2385 for (p = tmp + strlen(tmp); p != tmp && *p != '`' && *p != ' '; 2384 2386 p--); 2385 2387 p++; 2386 asprintf(&scratch, p);2388 mr_asprintf(&scratch, p); 2387 2389 for (p = scratch; *p != '\0' && *p != '\''; p++); 2388 2390 *p = '\0'; 2389 2391 log_msg(0, "curr_fname %s --> '%s' --> %s", curr_fname, tmp, scratch); 2390 paranoid_free(tmp);2392 mr_free(tmp); 2391 2393 2392 2394 if (scratch[0] == '/') { 2393 paranoid_free(curr_fname);2394 asprintf(&curr_fname, scratch); // copy whole thing because it's an absolute softlink2395 mr_free(curr_fname); 2396 mr_asprintf(&curr_fname, scratch); // copy whole thing because it's an absolute softlink 2395 2397 } else { // copy over the basename cos it's a relative softlink 2396 2398 p = curr_fname + strlen(curr_fname); … … 2402 2404 } 2403 2405 *p = '\0'; 2404 asprintf(&tmp, "%s%s", curr_fname, scratch);2405 paranoid_free(curr_fname);2406 mr_asprintf(&tmp, "%s%s", curr_fname, scratch); 2407 mr_free(curr_fname); 2406 2408 curr_fname = tmp; 2407 2409 } 2408 paranoid_free(scratch);2410 mr_free(scratch); 2409 2411 lstat(curr_fname, &statbuf); 2410 2412 } 2411 asprintf(&output, curr_fname);2413 mr_asprintf(&output, curr_fname); 2412 2414 log_it("resolved %s to %s", incoming, output); 2413 paranoid_free(curr_fname);2415 mr_free(curr_fname); 2414 2416 } 2415 2417 return (output); … … 2431 2433 2432 2434 log_msg(0, "Looking for partition table format type"); 2433 asprintf(&fdisk, "/sbin/parted2fdisk");2435 mr_asprintf(&fdisk, "/sbin/parted2fdisk"); 2434 2436 log_msg(1, "Using %s", fdisk); 2435 asprintf(&command, "%s -l %s | grep 'EFI GPT'", fdisk, drive);2436 paranoid_free(fdisk);2437 mr_asprintf(&command, "%s -l %s | grep 'EFI GPT'", fdisk, drive); 2438 mr_free(fdisk); 2437 2439 2438 2440 tmp = call_program_and_get_last_line_of_output(command); 2439 paranoid_free(command);2441 mr_free(command); 2440 2442 2441 2443 if (strstr(tmp, "GPT") == NULL) { 2442 asprintf(&output, "MBR");2443 } else { 2444 asprintf(&output, "GPT");2445 } 2446 paranoid_free(tmp);2444 mr_asprintf(&output, "MBR"); 2445 } else { 2446 mr_asprintf(&output, "GPT"); 2447 } 2448 mr_free(tmp); 2447 2449 log_msg(0, "Found %s partition table format type", output); 2448 2450 return (output); -
trunk/mondo/src/common/libmondo-fifo.c
r808 r900 28 28 #include "mondostructures.h" 29 29 #include "libmondo.h" 30 #include "mr_mem.h" 30 31 31 32 /** … … 82 83 assert_string_is_neither_NULL_nor_zerolength(device); 83 84 assert(direction == 'w' || direction == 'r'); 84 asprintf(&sz_dir, "%c", direction);85 mr_asprintf(&sz_dir, "%c", direction); 85 86 wise_upper_limit = (am_I_in_disaster_recovery_mode()? 8 : 32); 86 87 wise_lower_limit = 1; // wise_upper_limit/2 + 1; … … 88 89 for (bufsize = wise_upper_limit, res = -1; 89 90 res != 0 && bufsize >= wise_lower_limit; bufsize--) { 90 asprintf(&tmp,91 mr_asprintf(&tmp, 91 92 "dd if=/dev/zero bs=1024 count=16k 2> /dev/null | buffer -o /dev/null -s %ld -m %d%c", 92 93 internal_tape_block_size, bufsize, 'm'); 93 94 res = run_program_and_log_output(tmp, 2); 94 paranoid_free(tmp);95 mr_free(tmp); 95 96 } 96 97 if (!res) { 97 98 bufsize++; 98 asprintf(&tmp, _("Negotiated max buffer of %d MB "), bufsize);99 mr_asprintf(&tmp, _("Negotiated max buffer of %d MB "), bufsize); 99 100 log_to_screen(tmp); 100 paranoid_free(tmp);101 mr_free(tmp); 101 102 } else { 102 103 bufsize = 0; … … 111 112 } 112 113 if (bufsize) { 113 asprintf(&g_sz_call_to_buffer,114 mr_asprintf(&g_sz_call_to_buffer, 114 115 "buffer -m %d%c -p%d -B -s%ld -%c %s 2>> %s", bufsize, 115 116 'm', (direction == 'r') ? 20 : 75, 116 117 internal_tape_block_size, keych, device, MONDO_LOGFILE); 117 118 } else { 118 asprintf(&g_sz_call_to_buffer, "dd bs=%ld %cf=%s",119 mr_asprintf(&g_sz_call_to_buffer, "dd bs=%ld %cf=%s", 119 120 internal_tape_block_size, keych, device); 120 121 } 121 122 log_msg(2, "Calling buffer --- command = '%s'", g_sz_call_to_buffer); 122 123 fres = popen(g_sz_call_to_buffer, sz_dir); 123 paranoid_free(sz_dir);124 mr_free(sz_dir); 124 125 if (fres) { 125 126 log_msg(2, "Successfully opened ('%c') tape device %s", direction, … … 130 131 } 131 132 sleep(2); 132 asprintf(&tmp, "ps %s | grep \"%s\"", ps_options, g_sz_call_to_buffer);133 mr_asprintf(&tmp, "ps %s | grep \"%s\"", ps_options, g_sz_call_to_buffer); 133 134 if (run_program_and_log_output(tmp, 2)) { 134 135 log_msg(2, "Warning - I think I failed to open tape, actually."); 135 136 } 136 paranoid_free(tmp);137 mr_free(tmp); 137 138 g_tape_buffer_size_MB = bufsize; 138 asprintf(&tmp, "ps %s | grep buffer | grep -v grep", ps_options);139 mr_asprintf(&tmp, "ps %s | grep buffer | grep -v grep", ps_options); 139 140 if (run_program_and_log_output(tmp, 1)) { 140 141 fres = NULL; … … 143 144 log_to_screen(_("Buffer successfully started.")); 144 145 } 145 paranoid_free(tmp);146 mr_free(tmp); 146 147 return (fres); 147 148 } … … 157 158 158 159 sync(); 159 asprintf(&command,160 mr_asprintf(&command, 160 161 "ps %s | grep -F \"%s\" | grep -Fv grep | awk '{print $1;}' | grep -v PID | tr -s '\n' ' ' | awk '{ print $1; }'", ps_options, 161 162 g_sz_call_to_buffer); 162 paranoid_free(g_sz_call_to_buffer);163 mr_free(g_sz_call_to_buffer); 163 164 log_msg(2, "kill_buffer() --- command = %s", command); 164 165 165 166 tmp = call_program_and_get_last_line_of_output(command); 166 paranoid_free(command);167 mr_free(command); 167 168 168 asprintf(&command, "kill %s", tmp);169 mr_asprintf(&command, "kill %s", tmp); 169 170 log_msg(2, "kill_buffer() --- command = %s", command); 170 171 … … 172 173 run_program_and_log_output(command, TRUE); 173 174 } 174 paranoid_free(tmp);175 paranoid_free(command);175 mr_free(tmp); 176 mr_free(command); 176 177 } 177 178 -
trunk/mondo/src/common/libmondo-filelist.c
r863 r900 17 17 #include "newt-specific-EXT.h" 18 18 #include "libmondo-tools-EXT.h" 19 #include "mr_string.h" 19 #include "mr_str.h" 20 #include "mr_mem.h" 20 21 21 22 #include <time.h> … … 102 103 { i=0; log_to_screen ("This will take more time. Please be patient."); } 103 104 */ 104 asprintf(&filelist, "%s/archives/filelist.full", bkpinfo->scratchdir);105 mr_asprintf(&filelist, "%s/archives/filelist.full", bkpinfo->scratchdir); 105 106 if (!does_file_exist(filelist)) { 106 107 log_it("filelist %s not found", filelist); … … 111 112 chop_filelist(filelist, bkpinfo->tmpdir, 112 113 bkpinfo->optimal_set_size); 113 paranoid_free(filelist);114 mr_free(filelist); 114 115 115 116 estimate_noof_media_required(bkpinfo, noof_sets); // for cosmetic purposes 116 117 117 asprintf(&tempfile, "%s/biggielist.txt", bkpinfo->tmpdir);118 mr_asprintf(&tempfile, "%s/biggielist.txt", bkpinfo->tmpdir); 118 119 if (!(fout = fopen(tempfile, "a"))) { 119 120 log_OS_error("Cannot append to biggielist"); 120 121 retval++; 121 122 } 122 paranoid_free(tempfile);123 mr_free(tempfile); 123 124 log_it(bkpinfo->image_devs); 124 125 … … 126 127 127 128 while (ptr && *ptr) { 128 asprintf(&dev, ptr);129 mr_asprintf(&dev, ptr); 129 130 log_it("Examining imagedev %s", dev); 130 131 for (i = 0; i < (int) strlen(dev) && dev[i] != ' '; i++); … … 135 136 fprintf(fout, "%s\n", dev); 136 137 log_it("Adding '%s' to biggielist", dev); 137 paranoid_free(dev);138 mr_free(dev); 138 139 139 140 if ((ptr = strchr(ptr, ' '))) { … … 156 157 157 158 log_msg(1, "Sorting file %s", orig_fname); 158 asprintf(&tmp_fname, "/tmp/sort.%d.%d.%d", (int) (random() % 32768),159 mr_asprintf(&tmp_fname, "/tmp/sort.%d.%d.%d", (int) (random() % 32768), 159 160 (int) (random() % 32768), (int) (random() % 32768)); 160 161 … … 163 164 } // no sense in trying to sort an empty file 164 165 165 asprintf(&command, "sort %s > %s 2>> %s", orig_fname, tmp_fname,166 mr_asprintf(&command, "sort %s > %s 2>> %s", orig_fname, tmp_fname, 166 167 MONDO_LOGFILE); 167 168 retval = system(command); 168 paranoid_free(command);169 mr_free(command); 169 170 170 171 if (retval) { … … 173 174 log_msg(2, "Sorted %s --> %s OK. Copying it back to %s now", 174 175 orig_fname, tmp_fname, orig_fname); 175 asprintf(&command, "mv -f %s %s", tmp_fname, orig_fname);176 mr_asprintf(&command, "mv -f %s %s", tmp_fname, orig_fname); 176 177 retval += run_program_and_log_output(command, 2); 177 paranoid_free(command);178 mr_free(command); 178 179 179 180 if (retval) { … … 184 185 } 185 186 } 186 paranoid_free(tmp_fname);187 mr_free(tmp_fname); 187 188 log_msg(1, "Finished sorting file %s", orig_fname); 188 189 return (retval); … … 248 249 curr_set_no = 0; 249 250 curr_set_size = 0; 250 asprintf(&outfname, "%s/filelist.%ld", outdir, curr_set_no);251 asprintf(&biggie_fname, "%s/biggielist.txt", outdir);251 mr_asprintf(&outfname, "%s/filelist.%ld", outdir, curr_set_no); 252 mr_asprintf(&biggie_fname, "%s/biggielist.txt", outdir); 252 253 log_it("outfname=%s; biggie_fname=%s", outfname, biggie_fname); 253 254 if (!(fbig = fopen(biggie_fname, "w"))) { … … 259 260 return (0); 260 261 } 261 (void)getline(&incoming, &n, fin);262 mr_getline(&incoming, &n, fin); 262 263 while (!feof(fin)) { 263 264 lino++; … … 286 287 paranoid_fclose(fout); 287 288 sort_file(outfname); 288 paranoid_free(outfname);289 mr_free(outfname); 289 290 290 291 curr_set_no++; 291 292 curr_set_size = 0; 292 asprintf(&outfname, "%s/filelist.%ld", outdir,293 mr_asprintf(&outfname, "%s/filelist.%ld", outdir, 293 294 curr_set_no); 294 295 if (!(fout = fopen(outfname, "w"))) { … … 299 300 } 300 301 } 301 (void)getline(&incoming, &n, fin);302 mr_getline(&incoming, &n, fin); 302 303 } 303 304 paranoid_fclose(fin); … … 312 313 sort_file(outfname); 313 314 sort_file(biggie_fname); 314 paranoid_free(biggie_fname);315 paranoid_free(outfname);316 317 asprintf(&outfname, "%s/LAST-FILELIST-NUMBER", outdir);318 asprintf(&tmp, "%ld", curr_set_no);315 mr_free(biggie_fname); 316 mr_free(outfname); 317 318 mr_asprintf(&outfname, "%s/LAST-FILELIST-NUMBER", outdir); 319 mr_asprintf(&tmp, "%ld", curr_set_no); 319 320 if (write_one_liner_data_file(outfname, tmp)) { 320 321 log_OS_error … … 322 323 return (0); 323 324 } 324 paranoid_free(outfname);325 paranoid_free(tmp);325 mr_free(outfname); 326 mr_free(tmp); 326 327 327 328 if (curr_set_no == 0) { 328 asprintf(&tmp, "Only one fileset. Fine.");329 mr_asprintf(&tmp, "Only one fileset. Fine."); 329 330 } else { 330 asprintf(&tmp, "Filelist divided into %ld sets", curr_set_no + 1);331 mr_asprintf(&tmp, "Filelist divided into %ld sets", curr_set_no + 1); 331 332 } 332 333 log_msg(1, tmp); 333 paranoid_free(tmp);334 mr_free(tmp); 334 335 close_evalcall_form(); 335 336 /* This is to work around an obscure bug in Newt; open a form, close it, … … 391 392 } 392 393 filelist->ch = '\0'; 393 paranoid_free(filelist);394 mr_free((void *)filelist); 394 395 depth--; 395 396 if (depth == 0) { … … 416 417 return (2); 417 418 } 418 for ( getline(&tmp, &n, pattr); !feof(pattr);getline(&tmp, &n, pattr)) {419 for (mr_getline(&tmp, &n, pattr); !feof(pattr); mr_getline(&tmp, &n, pattr)) { 419 420 fputs(tmp, pout); 420 421 } 421 422 paranoid_pclose(pattr); 422 paranoid_free(tmp);423 mr_free(tmp); 423 424 return (0); 424 425 } … … 432 433 char *pout_command; 433 434 char *syscall; 434 char *tmp;435 435 char *file_to_analyze = NULL; 436 436 int i; … … 441 441 return (1); 442 442 } 443 asprintf(&pout_command, "gzip -c1 > %s", auxlist_fname);443 mr_asprintf(&pout_command, "gzip -c1 > %s", auxlist_fname); 444 444 if (!(pout = popen(pout_command, "w"))) { 445 445 log_msg(1, "Cannot openout auxlist_fname %s", auxlist_fname); 446 446 fclose(fin); 447 paranoid_free(pout_command);447 mr_free(pout_command); 448 448 return (4); 449 449 } 450 paranoid_free(pout_command);451 452 for ( getline(&file_to_analyze, &n, fin); !feof(fin);453 getline(&file_to_analyze, &n, fin)) {450 mr_free(pout_command); 451 452 for (mr_getline(&file_to_analyze, &n, fin); !feof(fin); 453 mr_getline(&file_to_analyze, &n, fin)) { 454 454 i = strlen(file_to_analyze); 455 455 if (i > 0 && file_to_analyze[i - 1] < 32) { … … 458 458 log_msg(8, "Analyzing %s", file_to_analyze); 459 459 /* BERLIOS : to be checked */ 460 asprintf(&syscall, "%s %s 2>> /dev/null", syscall_sprintf,mr_stresc(file_to_analyze, "`$\\\"", '\\'));460 mr_asprintf(&syscall, "%s %s 2>> /dev/null", syscall_sprintf,mr_stresc(file_to_analyze, "`$\\\"", '\\')); 461 461 call_exe_and_pipe_output_to_fd(syscall, pout); 462 paranoid_free(syscall);462 mr_free(syscall); 463 463 } 464 464 paranoid_fclose(fin); 465 465 paranoid_pclose(pout); 466 paranoid_free(file_to_analyze);466 mr_free(file_to_analyze); 467 467 return (0); 468 468 } … … 475 475 int retval = 0; 476 476 477 asprintf(&command, "touch %s", facl_fname);477 mr_asprintf(&command, "touch %s", facl_fname); 478 478 run_program_and_log_output(command, 8); 479 paranoid_free(command);479 mr_free(command); 480 480 481 481 tmp = find_home_of_exe("getfacl"); 482 482 if (tmp) { 483 483 // sort_file(filelist); // FIXME - filelist chopper sorts, so this isn't necessary 484 asprintf(&command,484 mr_asprintf(&command, 485 485 "getfacl --all-effective -P %s 2>> %s | gzip -c1 > %s 2>> %s", 486 486 filelist, MONDO_LOGFILE, facl_fname, MONDO_LOGFILE); 487 487 iamhere(command); 488 488 retval = system(command); 489 paranoid_free(command);490 } 491 paranoid_free(tmp);489 mr_free(command); 490 } 491 mr_free(tmp); 492 492 return (retval); 493 493 } … … 500 500 int retval = 0; 501 501 502 asprintf(&command, "touch %s", fattr_fname);502 mr_asprintf(&command, "touch %s", fattr_fname); 503 503 run_program_and_log_output(command, 8); 504 paranoid_free(command);504 mr_free(command); 505 505 506 506 tmp = find_home_of_exe("getfattr"); … … 511 511 fattr_fname); 512 512 } 513 paranoid_free(tmp);513 mr_free(tmp); 514 514 return (retval); 515 515 } … … 531 531 retval = system(command); 532 532 } 533 paranoid_free(command);533 mr_free(command); 534 534 return(retval); 535 535 } … … 557 557 log_msg(1, 558 558 "No masklist provided. I shall therefore set ALL attributes."); 559 asprintf(&command, "gzip -dc %s | %s --restore - 2>> %s",559 mr_asprintf(&command, "gzip -dc %s | %s --restore - 2>> %s", 560 560 original_exat_fname, executable, MONDO_LOGFILE); 561 561 log_msg(1, "command = %s", command); 562 562 retval = system(command); 563 paranoid_free(command);563 mr_free(command); 564 564 log_msg(1, "Returning w/ retval=%d", retval); 565 565 return (retval); … … 571 571 return (0); 572 572 } 573 asprintf(&masklist, "/tmp/%d.%d.mask", (int) (random() % 32768),573 mr_asprintf(&masklist, "/tmp/%d.%d.mask", (int) (random() % 32768), 574 574 (int) (random() % 32768)); 575 asprintf(&command, "cp -f %s %s", orig_msklist, masklist);575 mr_asprintf(&command, "cp -f %s %s", orig_msklist, masklist); 576 576 run_program_and_log_output(command, 1); 577 paranoid_free(command);577 mr_free(command); 578 578 579 579 sort_file(masklist); 580 asprintf(&syscall_pin, "gzip -dc %s", original_exat_fname);581 asprintf(&syscall_pout, "%s --restore - 2>> %s", executable,580 mr_asprintf(&syscall_pin, "gzip -dc %s", original_exat_fname); 581 mr_asprintf(&syscall_pout, "%s --restore - 2>> %s", executable, 582 582 MONDO_LOGFILE); 583 583 … … 589 589 return (1); 590 590 } 591 paranoid_free(syscall_pout);591 mr_free(syscall_pout); 592 592 593 593 pin = popen(syscall_pin, "r"); … … 597 597 return (1); 598 598 } 599 paranoid_free(syscall_pin);599 mr_free(syscall_pin); 600 600 601 601 faclin = fopen(masklist, "r"); … … 608 608 // printf("Hi there. Starting the loop\n"); 609 609 610 getline(¤t_subset_file, &n, faclin);611 getline(&incoming, &n, pin);610 mr_getline(¤t_subset_file, &n, faclin); 611 mr_getline(&incoming, &n, pin); 612 612 while (!feof(pin) && !feof(faclin)) { 613 613 // printf("incoming = %s", incoming); 614 614 615 asprintf(¤t_master_file, incoming + 8);615 mr_asprintf(¤t_master_file, incoming + 8); 616 616 617 617 p = current_subset_file; … … 641 641 if (i < 0) { // read another subset file in. 642 642 log_msg(my_depth, "Reading next subset line in\n\n"); 643 getline(¤t_subset_file, &n, faclin);643 mr_getline(¤t_subset_file, &n, faclin); 644 644 continue; 645 645 } … … 648 648 fputs(incoming, pout); 649 649 } 650 getline(&incoming, &n, pin);650 mr_getline(&incoming, &n, pin); 651 651 if (!i) { 652 652 log_msg(my_depth, "Copying master %s", q); … … 661 661 fputs(incoming, pout); 662 662 } 663 getline(&incoming, &n, pin);663 mr_getline(&incoming, &n, pin); 664 664 } 665 665 if (!i) { 666 getline(¤t_subset_file, &n, faclin);667 } 668 paranoid_free(current_master_file);669 } 670 paranoid_free(current_subset_file);666 mr_getline(¤t_subset_file, &n, faclin); 667 } 668 mr_free(current_master_file); 669 } 670 mr_free(current_subset_file); 671 671 672 672 while (!feof(pin)) { 673 getline(&incoming, &n, pin);674 } 675 paranoid_free(incoming);673 mr_getline(&incoming, &n, pin); 674 } 675 mr_free(incoming); 676 676 fclose(faclin); 677 677 pclose(pin); … … 681 681 682 682 unlink(masklist); 683 paranoid_free(masklist);683 mr_free(masklist); 684 684 685 685 return (retval); … … 719 719 assert(bkpinfo != NULL); 720 720 721 asprintf(&cfg_fname, "%s/mondo-restore.cfg", bkpinfo->tmpdir);721 mr_asprintf(&cfg_fname, "%s/mondo-restore.cfg", bkpinfo->tmpdir); 722 722 read_cfg_var(cfg_fname, "last-filelist-number", val_sz); 723 723 val_i = atoi(val_sz); 724 paranoid_free(val_sz);724 mr_free(val_sz); 725 725 726 726 if (val_i <= 0) { 727 727 val_i = 500; 728 728 } 729 paranoid_free(cfg_fname);729 mr_free(cfg_fname); 730 730 return (val_i); 731 731 } … … 866 866 } 867 867 log_to_screen(_("Loading filelist")); 868 asprintf(&command_to_open_fname, "gzip -dc %s", filelist_fname);869 asprintf(&tmp, "zcat %s | wc -l", filelist_fname);868 mr_asprintf(&command_to_open_fname, "gzip -dc %s", filelist_fname); 869 mr_asprintf(&tmp, "zcat %s | wc -l", filelist_fname); 870 870 log_msg(6, "tmp = %s", tmp); 871 871 tmp1 = call_program_and_get_last_line_of_output(tmp); 872 paranoid_free(tmp);872 mr_free(tmp); 873 873 874 874 lines_in_filelist = atol(tmp1); 875 paranoid_free(tmp1);875 mr_free(tmp1); 876 876 877 877 if (lines_in_filelist < 3) { … … 893 893 return (NULL); 894 894 } 895 paranoid_free(command_to_open_fname);895 mr_free(command_to_open_fname); 896 896 897 897 open_evalcall_form(_("Loading filelist from disk")); 898 for ( getline(&fname, &n, pin); !feof(pin);getline(&fname, &n, pin)) {898 for (mr_getline(&fname, &n, pin); !feof(pin); mr_getline(&fname, &n, pin)) { 899 899 if ((fname[strlen(fname) - 1] == 13 900 900 || fname[strlen(fname) - 1] == 10) && strlen(fname) > 0) { … … 908 908 continue; 909 909 } 910 asprintf(&tmp, fname);910 mr_asprintf(&tmp, fname); 911 911 tmp[pos_in_fname] = '\0'; 912 912 if (strlen(tmp)) { 913 913 add_string_at_node(filelist, tmp); 914 914 } 915 paranoid_free(tmp);915 mr_free(tmp); 916 916 } 917 917 add_string_at_node(filelist, fname); … … 921 921 } 922 922 } 923 paranoid_free(fname);923 mr_free(fname); 924 924 paranoid_pclose(pin); 925 925 close_evalcall_form(); … … 1352 1352 if (!depth) { 1353 1353 malloc_string(find_skeleton_marker); 1354 asprintf(&find_excludes, " ");1354 mr_asprintf(&find_excludes, " "); 1355 1355 while((token = mr_strtok (sth, delims, &lastpos))) { 1356 asprintf(&strtmp,"%s", find_excludes);1357 paranoid_free(find_excludes);1358 asprintf(&find_excludes,"%s -path %s -prune -o", strtmp, token);1359 paranoid_free(strtmp);1360 paranoid_free(token);1356 mr_asprintf(&strtmp,"%s", find_excludes); 1357 mr_free(find_excludes); 1358 mr_asprintf(&find_excludes,"%s -path %s -prune -o", strtmp, token); 1359 mr_free(strtmp); 1360 mr_free(token); 1361 1361 } 1362 1362 #if linux 1363 1363 // 2.6 has /sys as a proc-type thing -- must be excluded 1364 asprintf(&strtmp,1364 mr_asprintf(&strtmp, 1365 1365 "find %s -maxdepth %d -fstype mvfs -prune -o -path /dev/shm -prune -o %s -type d -print > %s 2> /dev/null", 1366 1366 dir, MAX_SKEL_DEPTH, find_excludes, skeleton_filelist); 1367 1367 #else 1368 1368 // On BSD, for example, /sys is the kernel sources -- don't exclude 1369 asprintf(&strtmp,1369 mr_asprintf(&strtmp, 1370 1370 "find %s -maxdepth %d -fstype mvfs -prune -o -path /proc -prune -o %s -type d -print > %s 2> /dev/null", 1371 1371 dir, MAX_SKEL_DEPTH, find_excludes, skeleton_filelist); 1372 1372 #endif 1373 paranoid_free(find_excludes);1373 mr_free(find_excludes); 1374 1374 log_msg(5, "find command = %s", strtmp); 1375 1375 system(strtmp); 1376 paranoid_free(strtmp);1377 paranoid_free(tmp);1378 1379 asprintf(&tmp, "wc -l %s | awk '{print $1;}'", skeleton_filelist);1376 mr_free(strtmp); 1377 mr_free(tmp); 1378 1379 mr_asprintf(&tmp, "wc -l %s | awk '{print $1;}'", skeleton_filelist); 1380 1380 tmp1 = call_program_and_get_last_line_of_output(tmp); 1381 paranoid_free(tmp);1381 mr_free(tmp); 1382 1382 1383 1383 g_skeleton_entries = 1 + atol(tmp1); 1384 paranoid_free(tmp1);1385 1386 asprintf(&name_of_evalcall_form, "Making catalog of %s", dir);1384 mr_free(tmp1); 1385 1386 mr_asprintf(&name_of_evalcall_form, "Making catalog of %s", dir); 1387 1387 open_evalcall_form(name_of_evalcall_form); 1388 1388 find_skeleton_marker[0] = '\0'; … … 1410 1410 #ifndef _XWIN 1411 1411 if (!g_text_mode) { 1412 asprintf(&tmp, _("Reading %-68s"), dir);1412 mr_asprintf(&tmp, _("Reading %-68s"), dir); 1413 1413 newtDrawRootText(0, g_noof_rows - 3, tmp); 1414 paranoid_free(tmp);1414 mr_free(tmp); 1415 1415 } 1416 1416 #endif … … 1424 1424 // log_msg(0, "Cataloguing %s", dir); 1425 1425 if (sth[0] == ' ') { 1426 asprintf(&skip_these, "%s", sth);1426 mr_asprintf(&skip_these, "%s", sth); 1427 1427 } else { 1428 asprintf(&skip_these, " %s ", sth);1429 } 1430 asprintf(&new_with_spaces, " %s ", dir);1428 mr_asprintf(&skip_these, " %s ", sth); 1429 } 1430 mr_asprintf(&new_with_spaces, " %s ", dir); 1431 1431 if ((dip = opendir(dir)) == NULL) { 1432 1432 log_OS_error("opendir"); … … 1438 1438 i++; 1439 1439 if (strcmp(dir, "/")) { 1440 asprintf(&new, "%s/%s", dir, dit->d_name);1440 mr_asprintf(&new, "%s/%s", dir, dit->d_name); 1441 1441 } else { 1442 asprintf(&new, "%s%s", dir, dit->d_name);1442 mr_asprintf(&new, "%s%s", dir, dit->d_name); 1443 1443 } 1444 paranoid_free(new_with_spaces);1445 asprintf(&new_with_spaces, " %s ", new);1444 mr_free(new_with_spaces); 1445 mr_asprintf(&new_with_spaces, " %s ", new); 1446 1446 /* BERLIOS: Old code 1447 1447 new_with_spaces[0] = ' '; … … 1466 1466 counter = 0; 1467 1467 uberctr++; 1468 asprintf(&tmp, " %c ",1468 mr_asprintf(&tmp, " %c ", 1469 1469 special_dot_char(uberctr)); 1470 1470 #ifndef _XWIN … … 1474 1474 newtRefresh(); 1475 1475 } 1476 paranoid_free(tmp);1476 mr_free(tmp); 1477 1477 #endif 1478 1478 } … … 1481 1481 } 1482 1482 } 1483 paranoid_free(new);1484 } 1485 } 1486 paranoid_free(new_with_spaces);1487 paranoid_free(skip_these);1483 mr_free(new); 1484 } 1485 } 1486 mr_free(new_with_spaces); 1487 mr_free(skip_these); 1488 1488 1489 1489 if (dip) { … … 1495 1495 if (!depth) { 1496 1496 close_evalcall_form(); 1497 paranoid_free(name_of_evalcall_form);1498 paranoid_free(find_skeleton_marker);1497 mr_free(name_of_evalcall_form); 1498 mr_free(find_skeleton_marker); 1499 1499 unlink(skeleton_filelist); 1500 1500 log_msg(5, "g_skeleton_entries = %ld", g_skeleton_entries); … … 1565 1565 1566 1566 // The pathname to the skeleton filelist, used to give better progress reporting for mondo_makefilelist(). 1567 asprintf(&sz_datefile, sz_datefile_wildcard, 0);1567 mr_asprintf(&sz_datefile, sz_datefile_wildcard, 0); 1568 1568 if (!include_paths && !userdef_filelist) { 1569 1569 fatal_error … … 1571 1571 } 1572 1572 // make hole for filelist 1573 asprintf(&command, "mkdir -p %s/archives", scratchdir);1573 mr_asprintf(&command, "mkdir -p %s/archives", scratchdir); 1574 1574 paranoid_system(command); 1575 paranoid_free(command);1576 1577 asprintf(&sz_filelist, "%s/tmpfs/filelist.full", tmpdir);1575 mr_free(command); 1576 1577 mr_asprintf(&sz_filelist, "%s/tmpfs/filelist.full", tmpdir); 1578 1578 make_hole_for_file(sz_filelist); 1579 1579 1580 1580 if (differential == 0) { 1581 1581 // restore last good datefile if it exists 1582 asprintf(&command, "cp -f %s.aborted %s", sz_datefile,1582 mr_asprintf(&command, "cp -f %s.aborted %s", sz_datefile, 1583 1583 sz_datefile); 1584 1584 run_program_and_log_output(command, 3); 1585 paranoid_free(command);1585 mr_free(command); 1586 1586 1587 1587 // backup last known good datefile just in case :) 1588 1588 if (does_file_exist(sz_datefile)) { 1589 asprintf(&command, "mv -f %s %s.aborted", sz_datefile,1589 mr_asprintf(&command, "mv -f %s %s.aborted", sz_datefile, 1590 1590 sz_datefile); 1591 1591 paranoid_system(command); 1592 paranoid_free(command);1592 mr_free(command); 1593 1593 } 1594 1594 make_hole_for_file(sz_datefile); 1595 1595 tmp = call_program_and_get_last_line_of_output("date +%s"); 1596 1596 write_one_liner_data_file(sz_datefile, tmp); 1597 paranoid_free(tmp);1597 mr_free(tmp); 1598 1598 } else if (lstat(sz_datefile, &statbuf)) { 1599 1599 log_msg(2, … … 1605 1605 log_msg(2, "Differential backup. Yay."); 1606 1606 } 1607 paranoid_free(sz_datefile);1607 mr_free(sz_datefile); 1608 1608 1609 1609 // use user-specified filelist (if specified) … … 1612 1612 "Using the user-specified filelist - %s - instead of calculating one", 1613 1613 userdef_filelist); 1614 asprintf(&command, "cp -f %s %s", userdef_filelist, sz_filelist);1614 mr_asprintf(&command, "cp -f %s %s", userdef_filelist, sz_filelist); 1615 1615 if (run_program_and_log_output(command, 3)) { 1616 1616 fatal_error("Failed to copy user-specified filelist"); 1617 1617 } 1618 paranoid_free(command);1618 mr_free(command); 1619 1619 } else { 1620 1620 log_msg(2, "include_paths = '%s'", include_paths); … … 1623 1623 tmp1 = call_program_and_get_last_line_of_output("locate /hiberfil.sys 2> /dev/null"); 1624 1624 tmp2 = call_program_and_get_last_line_of_output("locate /pagefile.sys 2> /dev/null"); 1625 asprintf(&exclude_paths, " %s %s %s %s %s %s . .. \1625 mr_asprintf(&exclude_paths, " %s %s %s %s %s %s . .. \ 1626 1626 " MNT_CDROM " " MNT_FLOPPY " /media/cdrom /media/cdrecorder \ 1627 1627 /proc /sys /tmp /var/cache/mondo /var/cache/mindi", excp, tmp, tmp1, tmp2, (tmpdir[0] == '/' && tmpdir[1] == '/') ? (tmpdir + 1) : tmpdir, (scratchdir[0] == '/' && scratchdir[1] == '/') ? (scratchdir + 1) : scratchdir); 1628 paranoid_free(tmp);1629 paranoid_free(tmp1);1630 paranoid_free(tmp2);1628 mr_free(tmp); 1629 mr_free(tmp1); 1630 mr_free(tmp2); 1631 1631 1632 1632 log_msg(2, "Excluding paths = '%s'", exclude_paths); 1633 1633 log_msg(2, 1634 1634 "Generating skeleton filelist so that we can track our progress"); 1635 asprintf(&skeleton_filelist, "%s/tmpfs/skeleton.txt", tmpdir);1635 mr_asprintf(&skeleton_filelist, "%s/tmpfs/skeleton.txt", tmpdir); 1636 1636 make_hole_for_file(skeleton_filelist); 1637 1637 … … 1661 1661 } 1662 1662 paranoid_fclose(fout); 1663 paranoid_free(skeleton_filelist);1664 paranoid_free(exclude_paths);1663 mr_free(skeleton_filelist); 1664 mr_free(exclude_paths); 1665 1665 } 1666 1666 log_msg(2, "Copying new filelist to scratchdir"); 1667 asprintf(&command, "mkdir -p %s/archives", scratchdir);1667 mr_asprintf(&command, "mkdir -p %s/archives", scratchdir); 1668 1668 paranoid_system(command); 1669 paranoid_free(command);1670 1671 asprintf(&command, "cp -f %s %s/archives/", sz_filelist, scratchdir);1669 mr_free(command); 1670 1671 mr_asprintf(&command, "cp -f %s %s/archives/", sz_filelist, scratchdir); 1672 1672 paranoid_system(command); 1673 paranoid_free(command);1674 1675 asprintf(&command, "mv -f %s %s", sz_filelist, tmpdir);1673 mr_free(command); 1674 1675 mr_asprintf(&command, "mv -f %s %s", sz_filelist, tmpdir); 1676 1676 paranoid_system(command); 1677 paranoid_free(command);1678 paranoid_free(sz_filelist);1677 mr_free(command); 1678 mr_free(sz_filelist); 1679 1679 1680 1680 log_msg(2, "Exiting"); … … 1777 1777 } 1778 1778 while (!feof(fin)) { 1779 getline(&fname, &len, fin);1779 mr_getline(&fname, &len, fin); 1780 1780 if (!use_star) { 1781 1781 if (fname[0] == '/') { 1782 asprintf(&tmp, fname);1782 mr_asprintf(&tmp, fname); 1783 1783 } else { 1784 asprintf(&tmp, "/%s", fname);1784 mr_asprintf(&tmp, "/%s", fname); 1785 1785 } 1786 paranoid_free(fname);1786 mr_free(fname); 1787 1787 fname = tmp; 1788 1788 } … … 1796 1796 if (found_node->selected) { 1797 1797 if (fname[0] == '/') { 1798 asprintf(&tmp, fname + 1);1799 paranoid_free(fname);1798 mr_asprintf(&tmp, fname + 1); 1799 mr_free(fname); 1800 1800 fname = tmp; 1801 1801 } … … 1803 1803 turn_wildcard_chars_into_literal_chars(tmp, fname); 1804 1804 fprintf(fout, "%s\n", tmp); 1805 paranoid_free(tmp);1805 mr_free(tmp); 1806 1806 retval++; 1807 1807 } 1808 1808 } 1809 paranoid_free(fname);1809 mr_free(fname); 1810 1810 } 1811 1811 paranoid_fclose(fout); … … 1836 1836 return (1); 1837 1837 } 1838 for ( getline(&tmp, &n, fin); !feof(fin);getline(&tmp, &n, fin)) {1838 for (mr_getline(&tmp, &n, fin); !feof(fin); mr_getline(&tmp, &n, fin)) { 1839 1839 if (!tmp[0]) { 1840 1840 continue; … … 1861 1861 } 1862 1862 paranoid_fclose(fin); 1863 paranoid_free(tmp);1863 mr_free(tmp); 1864 1864 return (0); 1865 1865 } -
trunk/mondo/src/common/libmondo-files-EXT.h
r783 r900 48 48 extern int read_one_liner_data_file(char *fname, char *contents); 49 49 extern int mode_of_file(char *fname); 50 extern void paranoid_alloc(char *alloc, char *orig); -
trunk/mondo/src/common/libmondo-files.c
r839 r900 18 18 #include "libmondo-fork-EXT.h" 19 19 #include "libmondo-string-EXT.h" 20 #include "mr_mem.h" 20 21 21 22 /*@unused@*/ … … 59 60 60 61 if (does_file_exist(filename)) { 61 asprintf(&command, "md5sum \"%s\"", filename);62 mr_asprintf(&command, "md5sum \"%s\"", filename); 62 63 fin = popen(command, "r"); 63 paranoid_free(command);64 mr_free(command); 64 65 65 66 if (fin) { 66 (void)getline(&output, &n, fin);67 mr_getline(&output, &n, fin); 67 68 p = strchr(output, ' '); 68 69 paranoid_pclose(fin); 69 70 } 70 71 } else { 71 asprintf(&tmp, "File '%s' not found; cannot calc checksum",72 mr_asprintf(&tmp, "File '%s' not found; cannot calc checksum", 72 73 filename); 73 74 log_it(tmp); 74 paranoid_free(tmp);75 mr_free(tmp); 75 76 } 76 77 if (p) { … … 106 107 assert_string_is_neither_NULL_nor_zerolength(filename); 107 108 if (!does_file_exist(filename)) { 108 asprintf(&tmp,109 mr_asprintf(&tmp, 109 110 "%s does not exist, so I cannot found the number of lines in it", 110 111 filename); 111 112 log_it(tmp); 112 paranoid_free(tmp);113 mr_free(tmp); 113 114 return (0); 114 115 } 115 asprintf(&command, "cat %s | wc -l", filename);116 mr_asprintf(&command, "cat %s | wc -l", filename); 116 117 if (!does_file_exist(filename)) { 117 118 return (-1); 118 119 } 119 120 fin = popen(command, "r"); 120 paranoid_free(command);121 mr_free(command); 121 122 122 123 if (fin) { … … 124 125 noof_lines = 0; 125 126 } else { 126 (void)getline(&incoming, &n, fin);127 mr_getline(&incoming, &n, fin); 127 128 while (strlen(incoming) > 0 128 129 && incoming[strlen(incoming) - 1] < 32) { … … 130 131 } 131 132 noof_lines = atol(incoming); 132 paranoid_free(incoming);133 mr_free(incoming); 133 134 } 134 135 paranoid_pclose(fin); … … 189 190 assert_string_is_neither_NULL_nor_zerolength(inout); 190 191 191 asprintf(&infname, "%s.in", inout);192 193 asprintf(&tmp, "cp -f %s %s", inout, infname);192 mr_asprintf(&infname, "%s.in", inout); 193 194 mr_asprintf(&tmp, "cp -f %s %s", inout, infname); 194 195 run_program_and_log_output(tmp, FALSE); 195 paranoid_free(tmp);196 mr_free(tmp); 196 197 197 198 if (!(fin = fopen(infname, "r"))) { 198 199 log_OS_error("Unable to openin infname"); 199 paranoid_free(infname);200 mr_free(infname); 200 201 return; 201 202 } 202 203 203 asprintf(&outfname, "%s", inout);204 mr_asprintf(&outfname, "%s", inout); 204 205 if (!(fout = fopen(outfname, "w"))) { 205 206 log_OS_error("Unable to openout outfname"); 206 paranoid_free(outfname);207 mr_free(outfname); 207 208 return; 208 209 } 209 paranoid_free(outfname);210 211 for ( getline(&incoming, &n, fin); !feof(fin);212 getline(&incoming, &n, fin)) {210 mr_free(outfname); 211 212 for (mr_getline(&incoming, &n, fin); !feof(fin); 213 mr_getline(&incoming, &n, fin)) { 213 214 i = strlen(incoming) - 1; 214 215 if (i >= 0 && incoming[i] < 32) { … … 218 219 fprintf(fout, "%s\n", incoming); 219 220 } else { 220 asprintf(&tmp, "Excluding '%s'-nonexistent\n", incoming);221 mr_asprintf(&tmp, "Excluding '%s'-nonexistent\n", incoming); 221 222 log_it(tmp); 222 paranoid_free(tmp);223 } 224 } 225 paranoid_free(incoming);223 mr_free(tmp); 224 } 225 } 226 mr_free(incoming); 226 227 paranoid_fclose(fout); 227 228 paranoid_fclose(fin); 228 229 unlink(infname); 229 paranoid_free(infname);230 mr_free(infname); 230 231 } 231 232 … … 249 250 // If we didn't get anything back, check whether mindi raised a fatal error 250 251 if (kernel == NULL) { 251 asprintf(&command, "grep 'Fatal error' /var/log/mindi.log");252 mr_asprintf(&command, "grep 'Fatal error' /var/log/mindi.log"); 252 253 tmp = call_program_and_get_last_line_of_output(command); 253 254 if (strlen(tmp) > 1) { … … 255 256 fatal_error("Mindi gave a fatal error. Please check '/var/log/mindi.log'."); 256 257 } 257 paranoid_free(command);258 paranoid_free(tmp);258 mr_free(command); 259 mr_free(tmp); 259 260 } 260 261 … … 303 304 assert_string_is_neither_NULL_nor_zerolength(fname); 304 305 305 asprintf(&command, "which %s 2> /dev/null", fname);306 mr_asprintf(&command, "which %s 2> /dev/null", fname); 306 307 incoming = call_program_and_get_last_line_of_output(command); 307 paranoid_free(command);308 mr_free(command); 308 309 309 310 if (incoming == NULL) { … … 311 312 return (NULL); // forget it :) 312 313 } 313 asprintf(&command,314 mr_asprintf(&command, 314 315 "file %s 2> /dev/null | cut -d':' -f1 2> /dev/null", 315 316 incoming); 316 paranoid_free(incoming);317 mr_free(incoming); 317 318 318 319 incoming = call_program_and_get_last_line_of_output(command); 319 paranoid_free(command);320 mr_free(command); 320 321 } 321 322 if (incoming == NULL) // yes, it is == '\0' twice, not once :) 322 323 { 323 asprintf(&command, "dirname %s 2> /dev/null", incoming);324 paranoid_free(incoming);324 mr_asprintf(&command, "dirname %s 2> /dev/null", incoming); 325 mr_free(incoming); 325 326 326 327 incoming = call_program_and_get_last_line_of_output(command); 327 paranoid_free(command);328 mr_free(command); 328 329 } 329 330 output = incoming; … … 332 333 log_msg(4, "find_home_of_exe () --- Found %s at %s", fname, output); 333 334 } else { 334 paranoid_free(output);335 mr_free(output); 335 336 log_msg(4, "find_home_of_exe() --- Could not find %s", fname); 336 337 } … … 395 396 && !strstr(err_log_lines[i], "% done"); i--); 396 397 if (i < 0) { 397 asprintf(&command,398 mr_asprintf(&command, 398 399 "tail -n3 %s | grep -Fi \"%c\" | tail -n1 | awk '{print $0;}'", 399 400 filename, '%'); 400 401 lastline = call_program_and_get_last_line_of_output(command); 401 paranoid_free(command);402 mr_free(command); 402 403 if (!lastline) { 403 404 return (0); 404 405 } 405 406 } else { 406 asprintf(&lastline, err_log_lines[i]);407 mr_asprintf(&lastline, err_log_lines[i]); 407 408 } 408 409 … … 412 413 } 413 414 if (!p) { 414 paranoid_free(lastline);415 mr_free(lastline); 415 416 return (0); 416 417 } … … 421 422 } 422 423 i = atoi(p); 423 paranoid_free(lastline);424 mr_free(lastline); 424 425 425 426 return (i); … … 447 448 448 449 if (!does_file_exist(filename)) { 449 asprintf(&tmp, _("Tring to get last line of nonexistent file (%s)"),450 mr_asprintf(&tmp, _("Tring to get last line of nonexistent file (%s)"), 450 451 filename); 451 452 log_it(tmp); 452 paranoid_free(tmp);453 mr_free(tmp); 453 454 return (NULL); 454 455 } 455 asprintf(&command, "tail -n1 %s", filename);456 mr_asprintf(&command, "tail -n1 %s", filename); 456 457 fin = popen(command, "r"); 457 paranoid_free(command);458 459 getline(&output, &n, fin);458 mr_free(command); 459 460 mr_getline(&output, &n, fin); 460 461 paranoid_pclose(fin); 461 462 while (strlen(output) > 0 && output[strlen(output) - 1] < 32) { … … 504 505 505 506 assert_string_is_neither_NULL_nor_zerolength(outdir_fname); 506 asprintf(&tmp, "mkdir -p %s", outdir_fname);507 mr_asprintf(&tmp, "mkdir -p %s", outdir_fname); 507 508 res = system(tmp); 508 paranoid_free(tmp);509 mr_free(tmp); 509 510 return (res); 510 511 } … … 532 533 assert(!strstr(outfile_fname, "/dev/cdrom")); 533 534 534 asprintf(&command, "mkdir -p \"%s\" 2> /dev/null", outfile_fname);535 mr_asprintf(&command, "mkdir -p \"%s\" 2> /dev/null", outfile_fname); 535 536 res += system(command); 536 paranoid_free(command);537 538 asprintf(&command, "rmdir \"%s\" 2> /dev/null", outfile_fname);537 mr_free(command); 538 539 mr_asprintf(&command, "rmdir \"%s\" 2> /dev/null", outfile_fname); 539 540 res += system(command); 540 paranoid_free(command);541 542 asprintf(&command, "rm -f \"%s\" 2> /dev/null", outfile_fname);541 mr_free(command); 542 543 mr_asprintf(&command, "rm -f \"%s\" 2> /dev/null", outfile_fname); 543 544 res += system(command); 544 paranoid_free(command);545 mr_free(command); 545 546 unlink(outfile_fname); 546 547 return (0); … … 575 576 return (0); 576 577 } 577 (void)getline(&incoming, &n, fin);578 mr_getline(&incoming, &n, fin); 578 579 while (!feof(fin)) { 579 580 if (strstr(incoming, wildcard)) { 580 581 matches++; 581 582 } 582 (void)getline(&incoming, &n, fin);583 mr_getline(&incoming, &n, fin); 583 584 } 584 585 paranoid_fclose(fin); 585 paranoid_free(incoming);586 mr_free(incoming); 586 587 return (matches); 587 588 } … … 603 604 FILE *fin; 604 605 605 asprintf(&lockfile_fname, "/var/run/monitas-%s.pid", name_str);606 mr_asprintf(&lockfile_fname, "/var/run/monitas-%s.pid", name_str); 606 607 if (!pid) { 607 608 log_it("Unregistering PID"); … … 609 610 log_it("Error unregistering PID"); 610 611 } 611 paranoid_free(lockfile_fname);612 mr_free(lockfile_fname); 612 613 return; 613 614 } 614 615 if (does_file_exist(lockfile_fname)) { 615 616 if ((fin = fopen(lockfile_fname, "r"))) { 616 (void)getline(&tmp, &n, fin);617 mr_getline(&tmp, &n, fin); 617 618 paranoid_fclose(fin); 618 619 } else { … … 620 621 } 621 622 pid = (pid_t) atol(tmp); 622 paranoid_free(tmp);623 624 asprintf(&tmp, "ps %ld > /dev/null 2> /dev/null", (long int) pid);623 mr_free(tmp); 624 625 mr_asprintf(&tmp, "ps %ld > /dev/null 2> /dev/null", (long int) pid); 625 626 res = system(tmp); 626 paranoid_free(tmp);627 mr_free(tmp); 627 628 if (!res) { 628 629 log_it … … 631 632 } 632 633 } 633 asprintf(&tmp, "echo %ld > %s 2> /dev/null", (long int) getpid(),634 mr_asprintf(&tmp, "echo %ld > %s 2> /dev/null", (long int) getpid(), 634 635 lockfile_fname); 635 paranoid_free(lockfile_fname);636 mr_free(lockfile_fname); 636 637 637 638 if (system(tmp)) { 638 639 fatal_error("Cannot register PID"); 639 640 } 640 paranoid_free(tmp);641 mr_free(tmp); 641 642 return; 642 643 } … … 655 656 long file_len_K = 0L; 656 657 657 asprintf(&command,658 mr_asprintf(&command, 658 659 "grep '%s ' %s/mountlist.txt | head -n1 | awk '{print $4;}'", 659 660 dev, tmpdir); … … 662 663 file_len_K = atol(sz_res); 663 664 log_msg(4, "%s --> %s --> %ld", command, sz_res, file_len_K); 664 paranoid_free(command);665 paranoid_free(sz_res);665 mr_free(command); 666 mr_free(sz_res); 666 667 return (file_len_K); 667 668 } … … 692 693 693 694 log_it("Calculating size of all biggiefiles (in total)"); 694 asprintf(&biggielist, "%s/biggielist.txt", bkpinfo->tmpdir);695 mr_asprintf(&biggielist, "%s/biggielist.txt", bkpinfo->tmpdir); 695 696 log_it("biggielist = %s", biggielist); 696 697 if (!(fin = fopen(biggielist, "r"))) { … … 699 700 } else { 700 701 log_msg(4, "Reading it..."); 701 for ( getline(&fname, &n, fin); !feof(fin);702 getline(&fname, &n, fin)) {702 for (mr_getline(&fname, &n, fin); !feof(fin); 703 mr_getline(&fname, &n, fin)) { 703 704 if (fname[strlen(fname) - 1] <= 32) { 704 705 fname[strlen(fname) - 1] = '\0'; … … 710 711 fatal_error("ntfsresize not found"); 711 712 } 712 paranoid_free(tmp);713 714 asprintf(&command, "ntfsresize --force --info %s|grep '^You might resize at '|cut -d' ' -f5", fname);713 mr_free(tmp); 714 715 mr_asprintf(&command, "ntfsresize --force --info %s|grep '^You might resize at '|cut -d' ' -f5", fname); 715 716 log_it("command = %s", command); 716 717 tmp = call_program_and_get_last_line_of_output(command); 717 paranoid_free(command);718 mr_free(command); 718 719 719 720 log_it("res of it = %s", tmp); 720 721 file_len_K = atoll(tmp) / 1024L; 721 paranoid_free(tmp);722 mr_free(tmp); 722 723 } else { 723 724 file_len_K = get_phys_size_of_drive(fname) * 1024L; … … 731 732 log_msg(4, "%s --> %ld K", fname, file_len_K); 732 733 } 733 asprintf(&comment,734 mr_asprintf(&comment, 734 735 "After adding %s, scratchL+%ld now equals %ld", fname, 735 736 file_len_K, scratchL); 736 737 log_msg(4, comment); 737 paranoid_free(comment);738 mr_free(comment); 738 739 739 740 if (feof(fin)) { … … 741 742 } 742 743 } 743 paranoid_free(fname);744 } 745 paranoid_free(biggielist);744 mr_free(fname); 745 } 746 mr_free(biggielist); 746 747 747 748 log_it("Closing..."); … … 771 772 /*@ end vars *************************************************** */ 772 773 773 asprintf(&command, "du -sk %s", mountpt);774 mr_asprintf(&command, "du -sk %s", mountpt); 774 775 errno = 0; 775 776 fin = popen(command, "r"); … … 778 779 llres = 0; 779 780 } else { 780 (void)getline(&tmp, &n, fin);781 mr_getline(&tmp, &n, fin); 781 782 paranoid_pclose(fin); 782 783 p = strchr(tmp, '\t'); … … 790 791 } 791 792 792 paranoid_free(command);793 paranoid_free(tmp);793 mr_free(command); 794 mr_free(tmp); 794 795 return (llres); 795 796 } … … 842 843 843 844 844 asprintf(&command, "which %s > /dev/null 2> /dev/null", fname);845 mr_asprintf(&command, "which %s > /dev/null 2> /dev/null", fname); 845 846 res = system(command); 846 paranoid_free(command);847 mr_free(command); 847 848 848 849 if (res) { 849 asprintf(&errorstr,850 mr_asprintf(&errorstr, 850 851 _("Please install '%s'. I cannot find it on your system."), 851 852 fname); 852 853 log_to_screen(errorstr); 853 paranoid_free(errorstr);854 mr_free(errorstr); 854 855 log_to_screen 855 856 (_("There may be an hyperlink at http://www.mondorescue.org which")); … … 949 950 log_msg(4, "g_mondo_home='%s'", g_mondo_home); 950 951 if ((g_mondo_home == NULL) || strlen(g_mondo_home) < 2) { 951 paranoid_free(g_mondo_home);952 mr_free(g_mondo_home); 952 953 g_mondo_home = find_and_store_mondoarchives_home(); 953 954 } 954 asprintf(&command, CP_BIN " --parents -pRdf %s %s", g_mondo_home,955 mr_asprintf(&command, CP_BIN " --parents -pRdf %s %s", g_mondo_home, 955 956 bkpinfo->scratchdir); 956 957 … … 959 960 fatal_error("Failed to copy Mondo's stuff to scratchdir"); 960 961 } 961 paranoid_free(command);962 963 asprintf(&tmp, "%s/payload.tgz", g_mondo_home);962 mr_free(command); 963 964 mr_asprintf(&tmp, "%s/payload.tgz", g_mondo_home); 964 965 965 966 /* i18n */ 966 asprintf(&command, CP_BIN " --parents /usr/share/locale/*/LC_MESSAGES/mondo.mo %s",bkpinfo->scratchdir);967 mr_asprintf(&command, CP_BIN " --parents /usr/share/locale/*/LC_MESSAGES/mondo.mo %s",bkpinfo->scratchdir); 967 968 log_msg(4, "command = %s", command); 968 969 run_program_and_log_output(command, 1); 969 paranoid_free(command);970 mr_free(command); 970 971 971 972 if (does_file_exist(tmp)) { … … 974 975 (void) getcwd(old_pwd, MAX_STR_LEN - 1); 975 976 chdir(bkpinfo->scratchdir); 976 asprintf(&command, "tar -zxvf %s", tmp);977 mr_asprintf(&command, "tar -zxvf %s", tmp); 977 978 if (run_program_and_log_output(command, FALSE)) { 978 979 fatal_error("Failed to untar payload"); 979 980 } 980 paranoid_free(command);981 mr_free(command); 981 982 chdir(old_pwd); 982 983 } 983 paranoid_free(tmp);984 985 asprintf(&command, "cp -f %s/LAST-FILELIST-NUMBER %s", bkpinfo->tmpdir,984 mr_free(tmp); 985 986 mr_asprintf(&command, "cp -f %s/LAST-FILELIST-NUMBER %s", bkpinfo->tmpdir, 986 987 bkpinfo->scratchdir); 987 988 if (run_program_and_log_output(command, FALSE)) { 988 989 fatal_error("Failed to copy LAST-FILELIST-NUMBER to scratchdir"); 989 990 } 990 paranoid_free(command);991 mr_free(command); 991 992 992 993 tmp = call_program_and_get_last_line_of_output("which mondorestore"); … … 995 996 ("'which mondorestore' returned null. Where's your mondorestore? `which` can't find it. That's odd. Did you install mondorestore?"); 996 997 } 997 asprintf(&command, "cp -f %s %s", tmp, bkpinfo->tmpdir);998 paranoid_free(tmp);998 mr_asprintf(&command, "cp -f %s %s", tmp, bkpinfo->tmpdir); 999 mr_free(tmp); 999 1000 1000 1001 if (run_program_and_log_output(command, FALSE)) { 1001 1002 fatal_error("Failed to copy mondorestore to tmpdir"); 1002 1003 } 1003 paranoid_free(command);1004 1005 asprintf(&command, "hostname > %s/HOSTNAME", bkpinfo->scratchdir);1004 mr_free(command); 1005 1006 mr_asprintf(&command, "hostname > %s/HOSTNAME", bkpinfo->scratchdir); 1006 1007 paranoid_system(command); 1007 paranoid_free(command);1008 mr_free(command); 1008 1009 1009 1010 if (bkpinfo->postnuke_tarball) { 1010 asprintf(&command, "cp -f %s %s/post-nuke.tgz",1011 mr_asprintf(&command, "cp -f %s %s/post-nuke.tgz", 1011 1012 bkpinfo->postnuke_tarball, bkpinfo->tmpdir); 1012 1013 if (run_program_and_log_output(command, FALSE)) { 1013 1014 fatal_error("Unable to copy post-nuke tarball to tmpdir"); 1014 1015 } 1015 paranoid_free(command);1016 mr_free(command); 1016 1017 } 1017 1018 … … 1047 1048 1048 1049 log_it("Storing NFS configuration"); 1049 asprintf(&tmp, bkpinfo->nfs_mount);1050 mr_asprintf(&tmp, bkpinfo->nfs_mount); 1050 1051 p = strchr(tmp, ':'); 1051 1052 if (!p) { … … 1054 1055 } 1055 1056 *(p++) = '\0'; 1056 asprintf(&nfs_server_ipaddr, tmp);1057 paranoid_free(tmp);1058 1059 asprintf(&nfs_mount, p);1057 mr_asprintf(&nfs_server_ipaddr, tmp); 1058 mr_free(tmp); 1059 1060 mr_asprintf(&nfs_mount, p); 1060 1061 /* BERLIOS : there is a bug #67 here as it only considers the first NIC */ 1061 asprintf(&command,1062 mr_asprintf(&command, 1062 1063 "ifconfig | tr '\n' '#' | sed s/##// | tr '#' ' ' | tr '' '\n' | head -n1 | cut -d' ' -f1"); 1063 1064 nfs_dev = call_program_and_get_last_line_of_output(command); 1064 paranoid_free(command);1065 1066 asprintf(&command,1065 mr_free(command); 1066 1067 mr_asprintf(&command, 1067 1068 "ifconfig | tr '\n' '#' | sed s/##// | tr '#' ' ' | tr '' '\\n' | head -n1 | tr -s '\t' ' ' | cut -d' ' -f7 | cut -d':' -f2"); 1068 1069 nfs_client_ipaddr = call_program_and_get_last_line_of_output(command); 1069 paranoid_free(command);1070 1071 asprintf(&command,1070 mr_free(command); 1071 1072 mr_asprintf(&command, 1072 1073 "ifconfig | tr '\n' '#' | sed s/##// | tr '#' ' ' | tr '' '\\n' | head -n1 | tr -s '\t' ' ' | cut -d' ' -f9 | cut -d':' -f2"); 1073 1074 nfs_client_netmask = call_program_and_get_last_line_of_output(command); 1074 paranoid_free(command);1075 1076 asprintf(&command,1075 mr_free(command); 1076 1077 mr_asprintf(&command, 1077 1078 "ifconfig | tr '\n' '#' | sed s/##// | tr '#' ' ' | tr '' '\\n' | head -n1 | tr -s '\t' ' ' | cut -d' ' -f8 | cut -d':' -f2"); 1078 1079 nfs_client_broadcast = call_program_and_get_last_line_of_output(command); 1079 paranoid_free(command);1080 1081 asprintf(&command,1080 mr_free(command); 1081 1082 mr_asprintf(&command, 1082 1083 "route -n | grep '^0.0.0.0' | awk '{print $2}'"); 1083 1084 nfs_client_defgw = call_program_and_get_last_line_of_output(command); 1084 paranoid_free(command);1085 1086 asprintf(&tmp,1085 mr_free(command); 1086 1087 mr_asprintf(&tmp, 1087 1088 "nfs_client_ipaddr=%s; nfs_client_netmask=%s; nfs_server_ipaddr=%s; nfs_mount=%s; nfs_client_defgw=%s; ", 1088 1089 nfs_client_ipaddr, nfs_client_netmask, nfs_server_ipaddr, nfs_mount, nfs_client_defgw); 1089 paranoid_free(nfs_mount);1090 mr_free(nfs_mount); 1090 1091 log_it(tmp); 1091 paranoid_free(tmp);1092 mr_free(tmp); 1092 1093 1093 1094 if (strlen(nfs_dev) < 2) { … … 1107 1108 if (!strncmp(nfs_dev, "bond", 4)) { 1108 1109 log_to_screen("Found bonding device %s; looking for corresponding ethN slave device\n", nfs_dev); 1109 asprintf(&command,1110 mr_asprintf(&command, 1110 1111 "ifconfig %s | awk '{print $5}'", nfs_dev); 1111 1112 mac_addr = call_program_and_get_last_line_of_output(command); 1112 asprintf(&command,1113 mr_asprintf(&command, 1113 1114 "ifconfig | grep -E '%s' | head -n1 | cut -d' ' -f1", mac_addr); 1114 paranoid_free(nfs_dev);1115 mr_free(nfs_dev); 1115 1116 nfs_dev = call_program_and_get_last_line_of_output(command); 1116 paranoid_free(command);1117 paranoid_free(mac_addr);1117 mr_free(command); 1118 mr_free(mac_addr); 1118 1119 1119 1120 log_to_screen("Replacing it with %s\n", nfs_dev); 1120 1121 } 1121 1122 1122 asprintf(&tmp, "%s/NFS-DEV", bkpinfo->tmpdir);1123 mr_asprintf(&tmp, "%s/NFS-DEV", bkpinfo->tmpdir); 1123 1124 write_one_liner_data_file(tmp, nfs_dev); 1124 paranoid_free(nfs_dev);1125 paranoid_free(tmp);1126 1127 asprintf(&tmp, "%s/NFS-CLIENT-IPADDR", bkpinfo->tmpdir);1125 mr_free(nfs_dev); 1126 mr_free(tmp); 1127 1128 mr_asprintf(&tmp, "%s/NFS-CLIENT-IPADDR", bkpinfo->tmpdir); 1128 1129 write_one_liner_data_file(tmp, nfs_client_ipaddr); 1129 paranoid_free(nfs_client_ipaddr);1130 paranoid_free(tmp);1131 1132 asprintf(&tmp, "%s/NFS-CLIENT-NETMASK", bkpinfo->tmpdir);1130 mr_free(nfs_client_ipaddr); 1131 mr_free(tmp); 1132 1133 mr_asprintf(&tmp, "%s/NFS-CLIENT-NETMASK", bkpinfo->tmpdir); 1133 1134 write_one_liner_data_file(tmp, nfs_client_netmask); 1134 paranoid_free(nfs_client_netmask);1135 paranoid_free(tmp);1136 1137 asprintf(&tmp, "%s/NFS-CLIENT-DEFGW", bkpinfo->tmpdir);1135 mr_free(nfs_client_netmask); 1136 mr_free(tmp); 1137 1138 mr_asprintf(&tmp, "%s/NFS-CLIENT-DEFGW", bkpinfo->tmpdir); 1138 1139 write_one_liner_data_file(tmp, nfs_client_defgw); 1139 paranoid_free(nfs_client_defgw);1140 paranoid_free(tmp);1141 1142 asprintf(&tmp, "%s/NFS-CLIENT-BROADCAST", bkpinfo->tmpdir);1140 mr_free(nfs_client_defgw); 1141 mr_free(tmp); 1142 1143 mr_asprintf(&tmp, "%s/NFS-CLIENT-BROADCAST", bkpinfo->tmpdir); 1143 1144 write_one_liner_data_file(tmp, nfs_client_broadcast); 1144 paranoid_free(nfs_client_broadcast);1145 paranoid_free(tmp);1146 1147 asprintf(&tmp, "%s/NFS-SERVER-IPADDR", bkpinfo->tmpdir);1145 mr_free(nfs_client_broadcast); 1146 mr_free(tmp); 1147 1148 mr_asprintf(&tmp, "%s/NFS-SERVER-IPADDR", bkpinfo->tmpdir); 1148 1149 write_one_liner_data_file(tmp, nfs_server_ipaddr); 1149 paranoid_free(nfs_server_ipaddr);1150 paranoid_free(tmp);1151 1152 asprintf(&tmp, "%s/NFS-SERVER-MOUNT", bkpinfo->tmpdir);1150 mr_free(nfs_server_ipaddr); 1151 mr_free(tmp); 1152 1153 mr_asprintf(&tmp, "%s/NFS-SERVER-MOUNT", bkpinfo->tmpdir); 1153 1154 write_one_liner_data_file(tmp, bkpinfo->nfs_mount); 1154 paranoid_free(tmp);1155 1156 asprintf(&tmp, "%s/NFS-SERVER-PATH", bkpinfo->tmpdir);1155 mr_free(tmp); 1156 1157 mr_asprintf(&tmp, "%s/NFS-SERVER-PATH", bkpinfo->tmpdir); 1157 1158 write_one_liner_data_file(tmp, bkpinfo->nfs_remote_dir); 1158 paranoid_free(tmp);1159 1160 asprintf(&tmp, "%s/ISO-PREFIX", bkpinfo->tmpdir);1159 mr_free(tmp); 1160 1161 mr_asprintf(&tmp, "%s/ISO-PREFIX", bkpinfo->tmpdir); 1161 1162 write_one_liner_data_file(tmp, bkpinfo->prefix); 1162 paranoid_free(tmp);1163 mr_free(tmp); 1163 1164 1164 1165 log_it("Finished storing NFS configuration"); … … 1211 1212 } 1212 1213 if (scratchLL <= 1) { 1213 asprintf(&tmp,1214 mr_asprintf(&tmp, 1214 1215 _("Your backup will probably occupy a single %s. Maybe two."), 1215 1216 bkpinfo->backup_media_string); 1216 1217 } else { 1217 asprintf(&tmp, _("Your backup will occupy approximately %s media."),1218 mr_asprintf(&tmp, _("Your backup will occupy approximately %s media."), 1218 1219 number_to_text((int) (scratchLL + 1))); 1219 1220 } … … 1221 1222 log_to_screen(tmp); 1222 1223 } 1223 paranoid_free(tmp);1224 mr_free(tmp); 1224 1225 return; 1225 1226 } … … 1238 1239 char *p = NULL; 1239 1240 1240 asprintf(&tmp, "%s/do-not-compress-these", g_mondo_home);1241 mr_asprintf(&tmp, "%s/do-not-compress-these", g_mondo_home); 1241 1242 if (!does_file_exist(tmp)) { 1242 paranoid_free(tmp);1243 mr_free(tmp); 1243 1244 return (FALSE); 1244 1245 } 1245 paranoid_free(tmp);1246 mr_free(tmp); 1246 1247 1247 1248 do_not_compress_these = last_line_of_file(tmp); 1248 1249 for (p = do_not_compress_these; p != NULL; p++) { 1249 asprintf(&tmp, p);1250 mr_asprintf(&tmp, p); 1250 1251 if (strchr(tmp, ' ')) { 1251 1252 *(strchr(tmp, ' ')) = '\0'; 1252 1253 } 1253 1254 if (!strcmp(strrchr(filename, '.'), tmp)) { 1254 paranoid_free(do_not_compress_these);1255 paranoid_free(tmp);1255 mr_free(do_not_compress_these); 1256 mr_free(tmp); 1256 1257 return (TRUE); 1257 1258 } 1258 paranoid_free(tmp);1259 mr_free(tmp); 1259 1260 1260 1261 if (!(p = strchr(p, ' '))) { … … 1262 1263 } 1263 1264 } 1264 paranoid_free(do_not_compress_these);1265 mr_free(do_not_compress_these); 1265 1266 return (FALSE); 1266 1267 } … … 1296 1297 paranoid_fclose(fout); 1297 1298 log_msg(2, "Created %s", outfile); 1298 asprintf(&tmp, "chmod +x %s", outfile);1299 mr_asprintf(&tmp, "chmod +x %s", outfile); 1299 1300 paranoid_system(tmp); 1300 paranoid_free(tmp);1301 mr_free(tmp); 1301 1302 1302 1303 retval = 0; … … 1308 1309 1309 1310 /* @} - end fileGroup */ 1310 1311 void paranoid_alloc(char *alloc, char *orig)1312 {1313 paranoid_free(alloc);1314 asprintf(&alloc, orig);1315 }1316 -
trunk/mondo/src/common/libmondo-fork.c
r783 r900 10 10 #include "libmondo-files-EXT.h" 11 11 #include "libmondo-tools-EXT.h" 12 #include "mr_mem.h" 12 13 13 14 extern bool g_text_mode; … … 30 31 31 32 if ((fin = popen(call, "r"))) { 32 for ( getline(&result, &n, fin); !feof(fin);getline(&result, &n, fin));33 for (mr_getline(&result, &n, fin); !feof(fin); mr_getline(&result, &n, fin)); 33 34 paranoid_pclose(fin); 34 35 } else { … … 89 90 } 90 91 91 asprintf(&cd_number_str, "%d", cd_no);92 mr_asprintf(&cd_number_str, "%d", cd_no); 92 93 resolve_naff_tokens(midway_call, basic_call, isofile, "_ISO_"); 93 94 resolve_naff_tokens(tmp, midway_call, cd_number_str, "_CD#_"); 94 paranoid_free(cd_number_str);95 mr_free(cd_number_str); 95 96 96 97 resolve_naff_tokens(ultimate_call, tmp, MONDO_LOGFILE, "_ERR_"); … … 99 100 log_msg(4, "tmp = '%s'", tmp); 100 101 log_msg(4, "ultimate call = '%s'", ultimate_call); 101 asprintf(&command, "%s >> %s", ultimate_call, MONDO_LOGFILE);102 mr_asprintf(&command, "%s >> %s", ultimate_call, MONDO_LOGFILE); 102 103 103 104 log_to_screen … … 138 139 (what_i_am_doing, command); 139 140 } 140 paranoid_free(command);141 142 paranoid_free(midway_call);143 paranoid_free(ultimate_call);144 paranoid_free(tmp);141 mr_free(command); 142 143 mr_free(midway_call); 144 mr_free(ultimate_call); 145 mr_free(tmp); 145 146 return (retval); 146 147 } … … 181 182 log_if_failure = TRUE; 182 183 } 183 asprintf(&callstr,184 mr_asprintf(&callstr, 184 185 "%s > /tmp/mondo-run-prog-thing.tmp 2> /tmp/mondo-run-prog-thing.err", 185 186 program); … … 198 199 "--------------------------------start of output-----------------------------"); 199 200 } 200 paranoid_free(callstr);201 mr_free(callstr); 201 202 202 203 if (log_if_failure … … 210 211 fin = fopen("/tmp/mondo-run-prog-thing.tmp", "r"); 211 212 if (fin) { 212 for ( getline(&incoming, &n, fin); !feof(fin);213 getline(&incoming, &n, fin)) {213 for (mr_getline(&incoming, &n, fin); !feof(fin); 214 mr_getline(&incoming, &n, fin)) { 214 215 /* patch by Heiko Schlittermann */ 215 216 p = incoming; … … 227 228 } 228 229 } 229 paranoid_free(incoming);230 mr_free(incoming); 230 231 paranoid_fclose(fin); 231 232 } … … 273 274 assert_string_is_neither_NULL_nor_zerolength(basic_call); 274 275 275 asprintf(&lockfile, "/tmp/mojo-jojo.blah.XXXXXX");276 mr_asprintf(&lockfile, "/tmp/mojo-jojo.blah.XXXXXX"); 276 277 mkstemp(lockfile); 277 asprintf(&command,278 mr_asprintf(&command, 278 279 "echo hi > %s ; %s >> %s 2>> %s; res=$?; sleep 1; rm -f %s; exit $res", 279 280 lockfile, basic_call, MONDO_LOGFILE, MONDO_LOGFILE, lockfile); 280 281 open_evalcall_form(what_i_am_doing); 281 asprintf(&tmp, "Executing %s", basic_call);282 mr_asprintf(&tmp, "Executing %s", basic_call); 282 283 log_msg(2, tmp); 283 paranoid_free(tmp);284 mr_free(tmp); 284 285 285 286 if (!(fin = popen(command, "r"))) { 286 287 log_OS_error("Unable to popen-in command"); 287 asprintf(&tmp, _("Failed utterly to call '%s'"), command);288 mr_asprintf(&tmp, _("Failed utterly to call '%s'"), command); 288 289 log_to_screen(tmp); 289 paranoid_free(tmp);290 paranoid_free(lockfile);291 paranoid_free(command);290 mr_free(tmp); 291 mr_free(lockfile); 292 mr_free(command); 292 293 return (1); 293 294 } 294 paranoid_free(command);295 mr_free(command); 295 296 296 297 if (!does_file_exist(lockfile)) { … … 320 321 close_evalcall_form(); 321 322 unlink(lockfile); 322 paranoid_free(lockfile);323 mr_free(lockfile); 323 324 324 325 return (retval); … … 357 358 fin = f_orig; 358 359 fout = f_archived; 359 asprintf(&tmp, "%-64s", PIMP_START_SZ);360 mr_asprintf(&tmp, "%-64s", PIMP_START_SZ); 360 361 if (fwrite(tmp, 1, 64, fout) != 64) { 361 362 fatal_error("Can't write the introductory block"); 362 363 } 363 paranoid_free(tmp);364 mr_free(tmp); 364 365 365 366 while (1) { … … 368 369 break; 369 370 } 370 asprintf(&tmp, "%-64ld", bytes_read_in);371 mr_asprintf(&tmp, "%-64ld", bytes_read_in); 371 372 if (fwrite(tmp, 1, 64, fout) != 64) { 372 373 fatal_error("Cannot write introductory block"); 373 374 } 374 paranoid_free(tmp);375 mr_free(tmp); 375 376 376 377 log_msg(7, … … 378 379 subsliceno, bytes_read_in, bytes_to_be_read); 379 380 bytes_written_out += fwrite(buf, 1, bytes_read_in, fout); 380 asprintf(&tmp, "%-64ld", subsliceno);381 mr_asprintf(&tmp, "%-64ld", subsliceno); 381 382 if (fwrite(tmp, 1, 64, fout) != 64) { 382 383 fatal_error("Cannot write post-thingy block"); 383 384 } 384 paranoid_free(tmp);385 mr_free(tmp); 385 386 386 387 log_msg(7, "Subslice #%d written OK", subsliceno); 387 388 subsliceno++; 388 389 } 389 asprintf(&tmp, "%-64ld", 0L);390 mr_asprintf(&tmp, "%-64ld", 0L); 390 391 if (fwrite(tmp, 1, 64L, fout) != 64L) { 391 392 fatal_error("Cannot write final introductory block"); … … 436 437 437 438 if (direction == 'w') { 438 paranoid_free(tmp);439 asprintf(&tmp, "%-64s", PIMP_END_SZ);439 mr_free(tmp); 440 mr_asprintf(&tmp, "%-64s", PIMP_END_SZ); 440 441 if (fwrite(tmp, 1, 64L, fout) != 64L) { 441 442 fatal_error("Can't write the final block"); 442 443 } 443 paranoid_free(tmp);444 mr_free(tmp); 444 445 } else { 445 446 log_msg(1, "tmpA is %s", tmp); … … 456 457 fwrite(tmp, 1, bytes_read_in, ftmp); 457 458 458 paranoid_free(tmp);459 mr_free(tmp); 459 460 if (!(tmp = malloc(512))) { 460 461 fatal_error("Failed to malloc() tmp"); … … 471 472 } 472 473 } 473 paranoid_free(tmp);474 } 475 476 paranoid_free(buf);474 mr_free(tmp); 475 } 476 477 mr_free(buf); 477 478 log_msg(3, "Successfully copied %ld bytes", bytes_written_out); 478 479 return (retval); … … 499 500 fatal_error("ntfsclone not found"); 500 501 } 501 paranoid_free(tmp);502 503 asprintf(&command, "ntfsclone --force --save-image --overwrite %s %s", output_fname, input_device);502 mr_free(tmp); 503 504 mr_asprintf(&command, "ntfsclone --force --save-image --overwrite %s %s", output_fname, input_device); 504 505 res = run_program_and_log_output(command, 5); 505 paranoid_free(command);506 mr_free(command); 506 507 507 508 unlink(output_fname); … … 526 527 527 528 tempfile = call_program_and_get_last_line_of_output("mktemp -q /tmp/mondo.XXXXXXXX"); 528 asprintf(&command, "%s >> %s 2>> %s; rm -f %s", cmd, tempfile, tempfile,529 mr_asprintf(&command, "%s >> %s 2>> %s; rm -f %s", cmd, tempfile, tempfile, 529 530 tempfile); 530 531 log_msg(3, command); … … 533 534 if (!(pin = popen(command, "r"))) { 534 535 log_OS_error("fmt err"); 535 paranoid_free(command);536 paranoid_free(tempfile);536 mr_free(command); 537 mr_free(tempfile); 537 538 return (1); 538 539 } 539 paranoid_free(command);540 mr_free(command); 540 541 541 542 maxpc = 100; … … 562 563 } 563 564 unlink(tempfile); 564 paranoid_free(tempfile);565 mr_free(tempfile); 565 566 return (res); 566 567 } … … 608 609 *pchild_result = 999; 609 610 610 asprintf(&command, "%s 2>> %s", cmd, MONDO_LOGFILE);611 mr_asprintf(&command, "%s 2>> %s", cmd, MONDO_LOGFILE); 611 612 log_msg(3, "command = '%s'", command); 612 613 if ((res = … … 636 637 update_evalcall_form(percentage); 637 638 } 638 paranoid_free(command);639 mr_free(command); 639 640 640 641 log_file_end_to_screen(MONDO_LOGFILE, ""); … … 668 669 fatal_error("ntfsclone not found"); 669 670 } 670 paranoid_free(tmp);671 672 asprintf(&command, "ntfsclone --force --restore-image --overwrite %s %s", output_device, input_fifo);671 mr_free(tmp); 672 673 mr_asprintf(&command, "ntfsclone --force --restore-image --overwrite %s %s", output_device, input_fifo); 673 674 res = run_program_and_log_output(command, 5); 674 paranoid_free(command);675 mr_free(command); 675 676 return (res); 676 677 } -
trunk/mondo/src/common/libmondo-mountlist.c
r783 r900 16 16 #include "libmondo-string-EXT.h" 17 17 #include "newt-specific-EXT.h" 18 #include "mr_mem.h" 18 19 19 20 /*@unused@*/ … … 81 82 82 83 if (physical_drive_size < 0) { 83 asprintf(&tmp, " %s does not exist.", drive);84 mr_asprintf(&tmp, " %s does not exist.", drive); 84 85 flaws_str = tmp; 85 86 } else { 86 asprintf(&tmp, "%s is %ld MB", drive, physical_drive_size);87 mr_asprintf(&tmp, "%s is %ld MB", drive, physical_drive_size); 87 88 flaws_str = NULL; 88 89 } 89 90 log_it(tmp); 90 paranoid_free(tmp);91 mr_free(tmp); 91 92 92 93 93 94 /* check DD */ 94 95 for (cur_sp_no = 'a'; cur_sp_no < 'z'; ++cur_sp_no) { 95 asprintf(&device, "%s%c", drive, cur_sp_no);96 mr_asprintf(&device, "%s%c", drive, cur_sp_no); 96 97 if (find_device_in_mountlist(mountlist, device) >= 0) 97 98 foundsome = TRUE; 98 paranoid_free(device);99 mr_free(device); 99 100 } 100 101 if (foundsome) { 101 102 for (cur_sp_no = 'a'; cur_sp_no < 'z'; ++cur_sp_no) { 102 asprintf(&device, "%s%c", drive, cur_sp_no);103 mr_asprintf(&device, "%s%c", drive, cur_sp_no); 103 104 pos = find_device_in_mountlist(mountlist, device); 104 105 if (pos < 0) { 105 106 continue; 106 107 } 107 // BERLIOS : useless ? asprintf(&mountpoint, mountlist->el[pos].mountpoint);108 // BERLIOS : useless ? mr_asprintf(&mountpoint, mountlist->el[pos].mountpoint); 108 109 /* is it too big? */ 109 110 if (curr_part_no > 'h') { 110 asprintf(&tmp, " Can only have up to 'h' in disklabel.");111 mr_asprintf(&tmp, " Can only have up to 'h' in disklabel."); 111 112 log_it(tmp); 112 113 if (flaws_str) { 113 asprintf(&tmp1, "%s%s",flaws_str, tmp);114 mr_asprintf(&tmp1, "%s%s",flaws_str, tmp); 114 115 } else { 115 asprintf(&tmp1, "%s", tmp);116 } 117 paranoid_free(flaws_str);116 mr_asprintf(&tmp1, "%s", tmp); 117 } 118 mr_free(flaws_str); 118 119 flaws_str = tmp1; 119 paranoid_free(tmp);120 mr_free(tmp); 120 121 res++; 121 122 } … … 128 129 } 129 130 if (device_copies > 1) { 130 asprintf(&tmp, " %s %s's.", number_to_text(device_copies),131 mr_asprintf(&tmp, " %s %s's.", number_to_text(device_copies), 131 132 device); 132 133 if (!strstr(flaws_str, tmp)) { 133 134 log_it(tmp); 134 135 if (flaws_str) { 135 asprintf(&tmp1, "%s%s",flaws_str, tmp);136 mr_asprintf(&tmp1, "%s%s",flaws_str, tmp); 136 137 } else { 137 asprintf(&tmp1, "%s", tmp);138 mr_asprintf(&tmp1, "%s", tmp); 138 139 } 139 paranoid_free(flaws_str);140 mr_free(flaws_str); 140 141 flaws_str = tmp1; 141 142 res++; 142 143 } 143 paranoid_free(tmp);144 mr_free(tmp); 144 145 } 145 146 /* silly partition size? */ 146 147 if (mountlist->el[pos].size < 8192 147 148 && strcmp(mountlist->el[pos].mountpoint, "lvm")) { 148 asprintf(&tmp, " %s is tiny!", device);149 mr_asprintf(&tmp, " %s is tiny!", device); 149 150 log_it(tmp); 150 151 if (flaws_str) { 151 asprintf(&tmp1, "%s%s",flaws_str, tmp);152 mr_asprintf(&tmp1, "%s%s",flaws_str, tmp); 152 153 } else { 153 asprintf(&tmp1, "%s", tmp);154 } 155 paranoid_free(flaws_str);154 mr_asprintf(&tmp1, "%s", tmp); 155 } 156 mr_free(flaws_str); 156 157 flaws_str = tmp1; 157 paranoid_free(tmp);158 mr_free(tmp); 158 159 res++; 159 160 } … … 165 166 && strcmp(mountlist->el[pos].mountpoint, "none") 166 167 && mountlist->el[pos].mountpoint[0] != '/') { 167 asprintf(&tmp, " %s has a weird mountpoint.", device);168 mr_asprintf(&tmp, " %s has a weird mountpoint.", device); 168 169 log_it(tmp); 169 170 if (flaws_str) { 170 asprintf(&tmp1, "%s%s",flaws_str, tmp);171 mr_asprintf(&tmp1, "%s%s",flaws_str, tmp); 171 172 } else { 172 asprintf(&tmp1, "%s", tmp);173 } 174 paranoid_free(flaws_str);173 mr_asprintf(&tmp1, "%s", tmp); 174 } 175 mr_free(flaws_str); 175 176 flaws_str = tmp1; 176 paranoid_free(tmp);177 mr_free(tmp); 177 178 res++; 178 179 } 179 180 /* is format sensible? */ 180 181 if (!is_this_a_valid_disk_format(mountlist->el[pos].format)) { 181 asprintf(&tmp, " %s has unsupported format %s.", device, mountlist->el[pos].format);182 mr_asprintf(&tmp, " %s has unsupported format %s.", device, mountlist->el[pos].format); 182 183 log_it(tmp); 183 184 if (flaws_str) { 184 asprintf(&tmp1, "%s%s",flaws_str, tmp);185 mr_asprintf(&tmp1, "%s%s",flaws_str, tmp); 185 186 } else { 186 asprintf(&tmp1, "%s", tmp);187 } 188 paranoid_free(flaws_str);187 mr_asprintf(&tmp1, "%s", tmp); 188 } 189 mr_free(flaws_str); 189 190 flaws_str = tmp1; 190 paranoid_free(tmp);191 mr_free(tmp); 191 192 res++; 192 193 } … … 194 195 prev_sp_no = cur_sp_no; 195 196 196 paranoid_free(device);197 mr_free(device); 197 198 } 198 199 } … … 200 201 npos = pos = 0; 201 202 for (curr_part_no = 1; curr_part_no < 99; curr_part_no++) { 202 asprintf(&device, "%ss%d", drive, curr_part_no);203 mr_asprintf(&device, "%ss%d", drive, curr_part_no); 203 204 pos = find_device_in_mountlist(mountlist, device); 204 205 npos = 0; 205 206 for (cur_sp_no = 'a'; cur_sp_no <= 'h'; cur_sp_no++) { 206 asprintf(&ndevice, "%ss%d%c", device, curr_part_no, cur_sp_no);207 mr_asprintf(&ndevice, "%ss%d%c", device, curr_part_no, cur_sp_no); 207 208 if (find_device_in_mountlist(mountlist, ndevice) >= 0) 208 209 npos++; 209 paranoid_free(ndevice);210 } 211 paranoid_free(device);210 mr_free(ndevice); 211 } 212 mr_free(device); 212 213 213 214 if (((pos >= 0) || npos) && foundsome) { 214 asprintf(&tmp, " %s has both DD and PC-style partitions.", drive);215 mr_asprintf(&tmp, " %s has both DD and PC-style partitions.", drive); 215 216 if (flaws_str) { 216 asprintf(&tmp1, "%s%s",flaws_str, tmp);217 mr_asprintf(&tmp1, "%s%s",flaws_str, tmp); 217 218 } else { 218 asprintf(&tmp1, "%s", tmp);219 } 220 paranoid_free(flaws_str);219 mr_asprintf(&tmp1, "%s", tmp); 220 } 221 mr_free(flaws_str); 221 222 flaws_str = tmp1; 222 paranoid_free(tmp);223 mr_free(tmp); 223 224 return ++res; // fatal error 224 225 } 225 // BERLIOS : useless ? asprintf(&mountpoint, mountlist->el[pos].mountpoint);226 // BERLIOS : useless ? mr_asprintf(&mountpoint, mountlist->el[pos].mountpoint); 226 227 if (pos > 0 && !npos) { 227 asprintf(&device, "%ss%d", drive, curr_part_no);228 mr_asprintf(&device, "%ss%d", drive, curr_part_no); 228 229 /* gap in the partition list? */ 229 230 if (curr_part_no - prev_part_no > 1) { 230 231 if (prev_part_no == 0) { 231 asprintf(&tmp, " Gap prior to %s.", device);232 mr_asprintf(&tmp, " Gap prior to %s.", device); 232 233 log_it(tmp); 233 234 if (flaws_str) { 234 asprintf(&tmp1, "%s%s",flaws_str, tmp);235 mr_asprintf(&tmp1, "%s%s",flaws_str, tmp); 235 236 } else { 236 asprintf(&tmp1, "%s", tmp);237 mr_asprintf(&tmp1, "%s", tmp); 237 238 } 238 paranoid_free(flaws_str);239 mr_free(flaws_str); 239 240 flaws_str = tmp1; 240 paranoid_free(tmp);241 mr_free(tmp); 241 242 res++; 242 243 } else if (curr_part_no > 5 243 244 || (curr_part_no <= 4 && prev_part_no > 0)) { 244 asprintf(&tmp, " Gap between %ss%d and %d.", drive,245 mr_asprintf(&tmp, " Gap between %ss%d and %d.", drive, 245 246 prev_part_no, curr_part_no); 246 247 log_it(tmp); 247 248 if (flaws_str) { 248 asprintf(&tmp1, "%s%s",flaws_str, tmp);249 mr_asprintf(&tmp1, "%s%s",flaws_str, tmp); 249 250 } else { 250 asprintf(&tmp1, "%s", tmp);251 mr_asprintf(&tmp1, "%s", tmp); 251 252 } 252 paranoid_free(flaws_str);253 mr_free(flaws_str); 253 254 flaws_str = tmp1; 254 paranoid_free(tmp);255 mr_free(tmp); 255 256 res++; 256 257 } … … 261 262 if ((curr_part_no >= 5 && prev_part_no == 4) 262 263 && (strcmp(part_table_fmt, "MBR") == 0)) { 263 asprintf(&tmp, " Partition %ss4 is occupied.", drive);264 mr_asprintf(&tmp, " Partition %ss4 is occupied.", drive); 264 265 log_it(tmp); 265 266 if (flaws_str) { 266 asprintf(&tmp1, "%s%s",flaws_str, tmp);267 mr_asprintf(&tmp1, "%s%s",flaws_str, tmp); 267 268 } else { 268 asprintf(&tmp1, "%s", tmp);269 } 270 paranoid_free(flaws_str);269 mr_asprintf(&tmp1, "%s", tmp); 270 } 271 mr_free(flaws_str); 271 272 flaws_str = tmp1; 272 paranoid_free(tmp);273 mr_free(tmp); 273 274 res++; 274 275 } … … 281 282 } 282 283 if (device_copies > 1) { 283 asprintf(&tmp, " %s %s's.", number_to_text(device_copies),284 mr_asprintf(&tmp, " %s %s's.", number_to_text(device_copies), 284 285 device); 285 286 if (!strstr(flaws_str, tmp)) { 286 287 log_it(tmp); 287 288 if (flaws_str) { 288 asprintf(&tmp1, "%s%s",flaws_str, tmp);289 mr_asprintf(&tmp1, "%s%s",flaws_str, tmp); 289 290 } else { 290 asprintf(&tmp1, "%s", tmp);291 mr_asprintf(&tmp1, "%s", tmp); 291 292 } 292 paranoid_free(flaws_str);293 mr_free(flaws_str); 293 294 flaws_str = tmp1; 294 295 res++; 295 296 } 296 paranoid_free(tmp);297 mr_free(tmp); 297 298 } 298 299 /* silly partition size? */ 299 300 if (mountlist->el[pos].size < 8192 300 301 && strcmp(mountlist->el[pos].mountpoint, "lvm")) { 301 asprintf(&tmp, " %s is tiny!", device);302 mr_asprintf(&tmp, " %s is tiny!", device); 302 303 log_it(tmp); 303 304 if (flaws_str) { 304 asprintf(&tmp1, "%s%s",flaws_str, tmp);305 mr_asprintf(&tmp1, "%s%s",flaws_str, tmp); 305 306 } else { 306 asprintf(&tmp1, "%s", tmp);307 } 308 paranoid_free(flaws_str);307 mr_asprintf(&tmp1, "%s", tmp); 308 } 309 mr_free(flaws_str); 309 310 flaws_str = tmp1; 310 paranoid_free(tmp);311 mr_free(tmp); 311 312 res++; 312 313 } … … 318 319 && strcmp(mountlist->el[pos].mountpoint, "none") 319 320 && mountlist->el[pos].mountpoint[0] != '/') { 320 asprintf(&tmp, " %s has a weird mountpoint.", device);321 mr_asprintf(&tmp, " %s has a weird mountpoint.", device); 321 322 log_it(tmp); 322 323 if (flaws_str) { 323 asprintf(&tmp1, "%s%s",flaws_str, tmp);324 mr_asprintf(&tmp1, "%s%s",flaws_str, tmp); 324 325 } else { 325 asprintf(&tmp1, "%s", tmp);326 } 327 paranoid_free(flaws_str);326 mr_asprintf(&tmp1, "%s", tmp); 327 } 328 mr_free(flaws_str); 328 329 flaws_str = tmp1; 329 paranoid_free(tmp);330 mr_free(tmp); 330 331 res++; 331 332 } 332 333 /* is format sensible? */ 333 334 if (!is_this_a_valid_disk_format(mountlist->el[pos].format)) { 334 asprintf(&tmp, " %s has unsupported format %s.", device, mountlist->el[pos].format);335 mr_asprintf(&tmp, " %s has unsupported format %s.", device, mountlist->el[pos].format); 335 336 log_it(tmp); 336 337 if (flaws_str) { 337 asprintf(&tmp1, "%s%s",flaws_str, tmp);338 mr_asprintf(&tmp1, "%s%s",flaws_str, tmp); 338 339 } else { 339 asprintf(&tmp1, "%s", tmp);340 } 341 paranoid_free(flaws_str);340 mr_asprintf(&tmp1, "%s", tmp); 341 } 342 mr_free(flaws_str); 342 343 flaws_str = tmp1; 343 paranoid_free(tmp);344 mr_free(tmp); 344 345 res++; 345 346 } 346 paranoid_free(device);347 mr_free(device); 347 348 } else { 348 349 /* Check subpartitions */ 349 350 for (cur_sp_no = 'a'; cur_sp_no < 'z'; ++cur_sp_no) { 350 asprintf(&device, "%ss%d%c", drive, curr_part_no,351 mr_asprintf(&device, "%ss%d%c", drive, curr_part_no, 351 352 cur_sp_no); 352 353 pos = find_device_in_mountlist(mountlist, device); … … 354 355 continue; 355 356 } 356 // BERLIOS : useless ? asprintf(&mountpoint, mountlist->el[pos].mountpoint);357 // BERLIOS : useless ? mr_asprintf(&mountpoint, mountlist->el[pos].mountpoint); 357 358 /* is it too big? */ 358 359 if (curr_part_no > 'h') { 359 asprintf(&tmp,360 mr_asprintf(&tmp, 360 361 " Can only have up to 'h' in disklabel."); 361 362 log_it(tmp); 362 363 if (flaws_str) { 363 asprintf(&tmp1, "%s%s",flaws_str, tmp);364 mr_asprintf(&tmp1, "%s%s",flaws_str, tmp); 364 365 } else { 365 asprintf(&tmp1, "%s", tmp);366 mr_asprintf(&tmp1, "%s", tmp); 366 367 } 367 paranoid_free(flaws_str);368 mr_free(flaws_str); 368 369 flaws_str = tmp1; 369 paranoid_free(tmp);370 mr_free(tmp); 370 371 res++; 371 372 } … … 378 379 } 379 380 if (device_copies > 1) { 380 asprintf(&tmp, " %s %s's.",381 mr_asprintf(&tmp, " %s %s's.", 381 382 number_to_text(device_copies), device); 382 383 if (!strstr(flaws_str, tmp)) { 383 384 log_it(tmp); 384 385 if (flaws_str) { 385 asprintf(&tmp1, "%s%s",flaws_str, tmp);386 mr_asprintf(&tmp1, "%s%s",flaws_str, tmp); 386 387 } else { 387 asprintf(&tmp1, "%s", tmp);388 mr_asprintf(&tmp1, "%s", tmp); 388 389 } 389 paranoid_free(flaws_str);390 mr_free(flaws_str); 390 391 flaws_str = tmp1; 391 392 res++; 392 393 } 393 paranoid_free(tmp);394 mr_free(tmp); 394 395 } 395 396 /* silly partition size? */ 396 397 if (mountlist->el[pos].size < 8192 397 398 && strcmp(mountlist->el[pos].mountpoint, "lvm")) { 398 asprintf(&tmp, " %s is tiny!", device);399 mr_asprintf(&tmp, " %s is tiny!", device); 399 400 log_it(tmp); 400 401 if (flaws_str) { 401 asprintf(&tmp1, "%s%s",flaws_str, tmp);402 mr_asprintf(&tmp1, "%s%s",flaws_str, tmp); 402 403 } else { 403 asprintf(&tmp1, "%s", tmp);404 mr_asprintf(&tmp1, "%s", tmp); 404 405 } 405 paranoid_free(flaws_str);406 mr_free(flaws_str); 406 407 flaws_str = tmp1; 407 paranoid_free(tmp);408 mr_free(tmp); 408 409 res++; 409 410 } … … 415 416 && strcmp(mountlist->el[pos].mountpoint, "none") 416 417 && mountlist->el[pos].mountpoint[0] != '/') { 417 asprintf(&tmp, " %s has a weird mountpoint.", device);418 mr_asprintf(&tmp, " %s has a weird mountpoint.", device); 418 419 log_it(tmp); 419 420 if (flaws_str) { 420 asprintf(&tmp1, "%s%s",flaws_str, tmp);421 mr_asprintf(&tmp1, "%s%s",flaws_str, tmp); 421 422 } else { 422 asprintf(&tmp1, "%s", tmp);423 mr_asprintf(&tmp1, "%s", tmp); 423 424 } 424 paranoid_free(flaws_str);425 mr_free(flaws_str); 425 426 flaws_str = tmp1; 426 paranoid_free(tmp);427 mr_free(tmp); 427 428 res++; 428 429 } … … 430 431 if (!is_this_a_valid_disk_format 431 432 (mountlist->el[pos].format)) { 432 asprintf(&tmp, " %s has unsupported format %s.", device, mountlist->el[pos].format);433 mr_asprintf(&tmp, " %s has unsupported format %s.", device, mountlist->el[pos].format); 433 434 log_it(tmp); 434 435 if (flaws_str) { 435 asprintf(&tmp1, "%s%s",flaws_str, tmp);436 mr_asprintf(&tmp1, "%s%s",flaws_str, tmp); 436 437 } else { 437 asprintf(&tmp1, "%s", tmp);438 mr_asprintf(&tmp1, "%s", tmp); 438 439 } 439 paranoid_free(flaws_str);440 mr_free(flaws_str); 440 441 flaws_str = tmp1; 441 paranoid_free(tmp);442 mr_free(tmp); 442 443 res++; 443 444 } 444 445 amount_allocated += mountlist->el[pos].size / 1024; 445 446 prev_sp_no = cur_sp_no; 446 paranoid_free(device);447 mr_free(device); 447 448 } 448 449 } … … 456 457 if (amount_allocated > physical_drive_size) // Used to be +1, but what if you're 1 MB too high? 457 458 { 458 asprintf(&tmp, " %ld MB over-allocated on %s.",459 mr_asprintf(&tmp, " %ld MB over-allocated on %s.", 459 460 amount_allocated - physical_drive_size, drive); 460 461 log_it(tmp); 461 462 if (flaws_str) { 462 asprintf(&tmp1, "%s%s",flaws_str, tmp);463 mr_asprintf(&tmp1, "%s%s",flaws_str, tmp); 463 464 } else { 464 asprintf(&tmp1, "%s", tmp);465 } 466 paranoid_free(flaws_str);465 mr_asprintf(&tmp1, "%s", tmp); 466 } 467 mr_free(flaws_str); 467 468 flaws_str = tmp1; 468 paranoid_free(tmp);469 mr_free(tmp); 469 470 res++; 470 471 } else if (amount_allocated < physical_drive_size - 1) { /* NOT AN ERROR, JUST A WARNING :-) */ 471 asprintf(&tmp, " %ld MB unallocated on %s.",472 mr_asprintf(&tmp, " %ld MB unallocated on %s.", 472 473 physical_drive_size - amount_allocated, drive); 473 474 log_it(tmp); 474 475 if (flaws_str) { 475 asprintf(&tmp1, "%s%s",flaws_str, tmp);476 mr_asprintf(&tmp1, "%s%s",flaws_str, tmp); 476 477 } else { 477 asprintf(&tmp1, "%s", tmp);478 } 479 paranoid_free(flaws_str);478 mr_asprintf(&tmp1, "%s", tmp); 479 } 480 mr_free(flaws_str); 480 481 flaws_str = tmp1; 481 paranoid_free(tmp);482 mr_free(tmp); 482 483 } 483 484 if (res) { … … 525 526 526 527 if (physical_drive_size < 0) { 527 asprintf(&tmp, " %s does not exist.", drive);528 mr_asprintf(&tmp, " %s does not exist.", drive); 528 529 if (flaws_str) { 529 asprintf(&tmp1, "%s%s",flaws_str, tmp);530 mr_asprintf(&tmp1, "%s%s",flaws_str, tmp); 530 531 } else { 531 asprintf(&tmp1, "%s", tmp);532 } 533 paranoid_free(flaws_str);532 mr_asprintf(&tmp1, "%s", tmp); 533 } 534 mr_free(flaws_str); 534 535 flaws_str = tmp1; 535 536 res++; 536 537 log_msg(1, tmp); 537 paranoid_free(tmp);538 mr_free(tmp); 538 539 return (FALSE); 539 540 } else { 540 asprintf(&tmp, "%s is %ld MB", drive, physical_drive_size);541 mr_asprintf(&tmp, "%s is %ld MB", drive, physical_drive_size); 541 542 log_it(tmp); 542 paranoid_free(tmp);543 mr_free(tmp); 543 544 } 544 545 545 546 for (curr_part_no = 1; curr_part_no < 99; curr_part_no++) { 546 asprintf(&device, "%s%d", drive, curr_part_no);547 mr_asprintf(&device, "%s%d", drive, curr_part_no); 547 548 pos = find_device_in_mountlist(mountlist, device); 548 549 if (pos < 0) { … … 550 551 } 551 552 if (physical_drive_size < 0) { 552 asprintf(&tmp, " %s refers to non-existent hardware.", device);553 mr_asprintf(&tmp, " %s refers to non-existent hardware.", device); 553 554 if (flaws_str) { 554 asprintf(&tmp1, "%s%s",flaws_str, tmp);555 mr_asprintf(&tmp1, "%s%s",flaws_str, tmp); 555 556 } else { 556 asprintf(&tmp1, "%s", tmp);557 } 558 paranoid_free(flaws_str);557 mr_asprintf(&tmp1, "%s", tmp); 558 } 559 mr_free(flaws_str); 559 560 flaws_str = tmp1; 560 561 res++; 561 paranoid_free(tmp);562 mr_free(tmp); 562 563 continue; 563 564 } … … 566 567 if (curr_part_no - prev_part_no > 1) { 567 568 if (prev_part_no == 0) { 568 asprintf(&tmp, " Gap prior to %s.", device);569 mr_asprintf(&tmp, " Gap prior to %s.", device); 569 570 log_it(tmp); 570 571 if (flaws_str) { 571 asprintf(&tmp1, "%s%s",flaws_str, tmp);572 mr_asprintf(&tmp1, "%s%s",flaws_str, tmp); 572 573 } else { 573 asprintf(&tmp1, "%s", tmp);574 } 575 paranoid_free(flaws_str);574 mr_asprintf(&tmp1, "%s", tmp); 575 } 576 mr_free(flaws_str); 576 577 flaws_str = tmp1; 577 paranoid_free(tmp);578 mr_free(tmp); 578 579 res++; 579 580 } else if (curr_part_no > 5 580 581 || (curr_part_no <= 4 && prev_part_no > 0)) { 581 asprintf(&tmp, " Gap between %s%d and %d.", drive,582 mr_asprintf(&tmp, " Gap between %s%d and %d.", drive, 582 583 prev_part_no, curr_part_no); 583 584 log_it(tmp); 584 585 if (flaws_str) { 585 asprintf(&tmp1, "%s%s",flaws_str, tmp);586 mr_asprintf(&tmp1, "%s%s",flaws_str, tmp); 586 587 } else { 587 asprintf(&tmp1, "%s", tmp);588 } 589 paranoid_free(flaws_str);588 mr_asprintf(&tmp1, "%s", tmp); 589 } 590 mr_free(flaws_str); 590 591 flaws_str = tmp1; 591 paranoid_free(tmp);592 mr_free(tmp); 592 593 res++; 593 594 } … … 598 599 if ((curr_part_no >= 5 && prev_part_no == 4) 599 600 && (strcmp(part_table_fmt, "MBR") == 0)) { 600 asprintf(&tmp, " Partition %s4 is occupied.", drive);601 mr_asprintf(&tmp, " Partition %s4 is occupied.", drive); 601 602 log_it(tmp); 602 603 if (flaws_str) { 603 asprintf(&tmp1, "%s%s",flaws_str, tmp);604 mr_asprintf(&tmp1, "%s%s",flaws_str, tmp); 604 605 } else { 605 asprintf(&tmp1, "%s", tmp);606 } 607 paranoid_free(flaws_str);606 mr_asprintf(&tmp1, "%s", tmp); 607 } 608 mr_free(flaws_str); 608 609 flaws_str = tmp1; 609 paranoid_free(tmp);610 mr_free(tmp); 610 611 res++; 611 612 } 612 paranoid_free(part_table_fmt);613 mr_free(part_table_fmt); 613 614 614 615 /* does partition /dev/hdNX exist more than once in the mountlist? */ … … 620 621 } 621 622 if (device_copies > 1) { 622 asprintf(&tmp, " %s %s's.", number_to_text(device_copies),623 mr_asprintf(&tmp, " %s %s's.", number_to_text(device_copies), 623 624 device); 624 625 if (!strstr(flaws_str, tmp)) { 625 626 log_it(tmp); 626 627 if (flaws_str) { 627 asprintf(&tmp1, "%s%s",flaws_str, tmp);628 mr_asprintf(&tmp1, "%s%s",flaws_str, tmp); 628 629 } else { 629 asprintf(&tmp1, "%s", tmp);630 } 631 paranoid_free(flaws_str);630 mr_asprintf(&tmp1, "%s", tmp); 631 } 632 mr_free(flaws_str); 632 633 flaws_str = tmp1; 633 634 res++; 634 635 } 635 paranoid_free(tmp);636 mr_free(tmp); 636 637 } 637 638 /* silly partition size? */ 638 639 if (mountlist->el[pos].size < 8192 639 640 && strcmp(mountlist->el[pos].mountpoint, "lvm")) { 640 asprintf(&tmp, " %s is tiny!", device);641 mr_asprintf(&tmp, " %s is tiny!", device); 641 642 log_it(tmp); 642 643 if (flaws_str) { 643 asprintf(&tmp1, "%s%s",flaws_str, tmp);644 mr_asprintf(&tmp1, "%s%s",flaws_str, tmp); 644 645 } else { 645 asprintf(&tmp1, "%s", tmp);646 } 647 paranoid_free(flaws_str);646 mr_asprintf(&tmp1, "%s", tmp); 647 } 648 mr_free(flaws_str); 648 649 flaws_str = tmp1; 649 paranoid_free(tmp);650 mr_free(tmp); 650 651 res++; 651 652 } … … 656 657 && strcmp(mountlist->el[pos].mountpoint, "image") 657 658 && mountlist->el[pos].mountpoint[0] != '/') { 658 asprintf(&tmp, " %s has a weird mountpoint.", device);659 mr_asprintf(&tmp, " %s has a weird mountpoint.", device); 659 660 log_it(tmp); 660 661 if (flaws_str) { 661 asprintf(&tmp1, "%s%s",flaws_str, tmp);662 mr_asprintf(&tmp1, "%s%s",flaws_str, tmp); 662 663 } else { 663 asprintf(&tmp1, "%s", tmp);664 } 665 paranoid_free(flaws_str);664 mr_asprintf(&tmp1, "%s", tmp); 665 } 666 mr_free(flaws_str); 666 667 flaws_str = tmp1; 667 paranoid_free(tmp);668 mr_free(tmp); 668 669 res++; 669 670 } 670 671 /* is format sensible? */ 671 672 if (!is_this_a_valid_disk_format(mountlist->el[pos].format)) { 672 asprintf(&tmp, " %s has unsupported format %s.", device, mountlist->el[pos].format);673 mr_asprintf(&tmp, " %s has unsupported format %s.", device, mountlist->el[pos].format); 673 674 log_it(tmp); 674 675 if (flaws_str) { 675 asprintf(&tmp1, "%s%s",flaws_str, tmp);676 mr_asprintf(&tmp1, "%s%s",flaws_str, tmp); 676 677 } else { 677 asprintf(&tmp1, "%s", tmp);678 } 679 paranoid_free(flaws_str);678 mr_asprintf(&tmp1, "%s", tmp); 679 } 680 mr_free(flaws_str); 680 681 flaws_str = tmp1; 681 paranoid_free(tmp);682 mr_free(tmp); 682 683 res++; 683 684 } … … 685 686 amount_allocated += mountlist->el[pos].size / 1024; 686 687 prev_part_no = curr_part_no; 687 paranoid_free(device);688 mr_free(device); 688 689 } 689 690 690 691 /* Over-allocated the disk? Unallocated space on disk? */ 691 692 if (amount_allocated > physical_drive_size + 1) { 692 asprintf(&tmp, " %ld MB over-allocated on %s.",693 mr_asprintf(&tmp, " %ld MB over-allocated on %s.", 693 694 amount_allocated - physical_drive_size, drive); 694 695 log_it(tmp); 695 696 if (flaws_str) { 696 asprintf(&tmp1, "%s%s",flaws_str, tmp);697 mr_asprintf(&tmp1, "%s%s",flaws_str, tmp); 697 698 } else { 698 asprintf(&tmp1, "%s", tmp);699 } 700 paranoid_free(flaws_str);699 mr_asprintf(&tmp1, "%s", tmp); 700 } 701 mr_free(flaws_str); 701 702 flaws_str = tmp1; 702 paranoid_free(tmp);703 mr_free(tmp); 703 704 res++; 704 705 } else if (amount_allocated < physical_drive_size - 1) { /* NOT AN ERROR, JUST A WARNING :-) */ 705 asprintf(&tmp, " %ld MB unallocated on %s.",706 mr_asprintf(&tmp, " %ld MB unallocated on %s.", 706 707 physical_drive_size - amount_allocated, drive); 707 708 log_it(tmp); 708 709 if (flaws_str) { 709 asprintf(&tmp1, "%s%s",flaws_str, tmp);710 mr_asprintf(&tmp1, "%s%s",flaws_str, tmp); 710 711 } else { 711 asprintf(&tmp1, "%s", tmp);712 } 713 paranoid_free(flaws_str);712 mr_asprintf(&tmp1, "%s", tmp); 713 } 714 mr_free(flaws_str); 714 715 flaws_str = tmp1; 715 paranoid_free(tmp);716 mr_free(tmp); 716 717 } 717 718 … … 755 756 assert(mountlist != NULL); 756 757 757 asprintf(&flaws_str, " ");758 mr_asprintf(&flaws_str, " "); 758 759 759 760 make_list_of_drives_in_mountlist(mountlist, drivelist); … … 765 766 (drivelist->el[i].device, 766 767 DONT_KNOW_HOW_TO_EVALUATE_THIS_DEVICE_TYPE)) { 767 asprintf(&tmp, " Not evaluating %s (I don't know how yet)",768 mr_asprintf(&tmp, " Not evaluating %s (I don't know how yet)", 768 769 drivelist->el[i].device); 769 770 log_it(tmp); … … 775 776 } 776 777 } 777 asprintf(&tmp1, "%s%s", flaws_str, tmp);778 paranoid_free(tmp);779 paranoid_free(flaws_str);778 mr_asprintf(&tmp1, "%s%s", flaws_str, tmp); 779 mr_free(tmp); 780 mr_free(flaws_str); 780 781 flaws_str = tmp1; 781 782 } … … 841 842 842 843 for (currline = 0; currline < mountlist->entries; currline++) { 843 asprintf(&curr_mountpoint, mountlist->el[currline].mountpoint);844 mr_asprintf(&curr_mountpoint, mountlist->el[currline].mountpoint); 844 845 for (i = 0, copies = 0, last_copy = -1; i < mountlist->entries; 845 846 i++) { … … 853 854 if (copies > 1 && last_copy == currline 854 855 && strcmp(curr_mountpoint, "raid")) { 855 asprintf(&tmp, " %s %s's.", number_to_text(copies),856 mr_asprintf(&tmp, " %s %s's.", number_to_text(copies), 856 857 curr_mountpoint); 857 858 log_it(tmp); 858 asprintf(&tmp1, "%s%s",flaws_str, tmp);859 paranoid_free(flaws_str);859 mr_asprintf(&tmp1, "%s%s",flaws_str, tmp); 860 mr_free(flaws_str); 860 861 flaws_str = tmp1; 861 paranoid_free(tmp);862 mr_free(tmp); 862 863 res++; 863 864 } 864 paranoid_free(curr_mountpoint);865 mr_free(curr_mountpoint); 865 866 } 866 867 return (res); … … 895 896 for (lino = 0, noof_drives = 0; lino < mountlist->entries; lino++) { 896 897 897 asprintf(&drive, mountlist->el[lino].device);898 mr_asprintf(&drive, mountlist->el[lino].device); 898 899 if (!strncmp(drive, RAID_DEVICE_STUB, strlen(RAID_DEVICE_STUB))) { 899 asprintf(&tmp,900 mr_asprintf(&tmp, 900 901 "Not putting %s in list of drives: it's a virtual drive", 901 902 drive); 902 903 log_msg(8, tmp); 903 paranoid_free(tmp);904 mr_free(tmp); 904 905 continue; 905 906 } … … 907 908 size = mountlist->el[lino].size; 908 909 if (size == 0) { 909 asprintf(&tmp,910 mr_asprintf(&tmp, 910 911 "Not putting %s in list of drives: it has zero size (maybe an LVM volume)", 911 912 drive); 912 913 log_msg(8, tmp); 913 paranoid_free(tmp);914 mr_free(tmp); 914 915 continue; 915 916 } … … 926 927 */ 927 928 928 asprintf(&tmp,929 mr_asprintf(&tmp, 929 930 "Putting %s with size %lli in list of drives", 930 931 drive, size); 931 932 log_msg(8, tmp); 932 paranoid_free(tmp);933 mr_free(tmp); 933 934 934 935 (void) truncate_to_drive_name(drive); … … 940 941 strcpy(drivelist->el[noof_drives++].device, drive); 941 942 } 942 paranoid_free(drive);943 mr_free(drive); 943 944 944 945 } … … 988 989 (void *) &mountlist->el[i], 989 990 sizeof(struct mountlist_line)); 990 asprintf(&tmp,991 mr_asprintf(&tmp, 991 992 "%s is available; user may choose to add it to raid device", 992 993 output_list->el[items - 1].device); 993 994 log_it(tmp); 994 paranoid_free(tmp);995 mr_free(tmp); 995 996 } 996 997 } … … 1058 1059 log_it("Unable to open mountlist - '%s'", fname); 1059 1060 log_to_screen(_("Cannot open mountlist")); 1060 paranoid_free(siz);1061 mr_free(siz); 1061 1062 return (1); 1062 1063 } 1063 1064 items = 0; 1064 (void)getline(&incoming, &n, fin);1065 mr_getline(&incoming, &n, fin); 1065 1066 log_it("Loading mountlist..."); 1066 1067 while (!feof(fin)) { … … 1091 1092 "Ignoring %s in mountlist - not loading that line :) ", 1092 1093 mountlist->el[items].device); 1093 (void)getline(&incoming, &n, fin);1094 mr_getline(&incoming, &n, fin); 1094 1095 continue; 1095 1096 } … … 1107 1108 if (j < items) { 1108 1109 strcat(mountlist->el[items].device, "_dup"); 1109 asprintf(&tmp,1110 mr_asprintf(&tmp, 1110 1111 "Duplicate entry in mountlist - renaming to %s", 1111 1112 mountlist->el[items].device); 1112 1113 log_it(tmp); 1113 paranoid_free(tmp);1114 } 1115 asprintf(&tmp, mountlist->el[items].device);1114 mr_free(tmp); 1115 } 1116 mr_asprintf(&tmp, mountlist->el[items].device); 1116 1117 if (strstr(tmp, "/dev/md/")) { 1117 1118 log_it("format_device() --- Contracting %s", tmp); … … 1126 1127 strcpy(mountlist->el[items].device, tmp); 1127 1128 } 1128 paranoid_free(tmp);1129 1130 asprintf(&tmp,1129 mr_free(tmp); 1130 1131 mr_asprintf(&tmp, 1131 1132 "%s %s %s %lld %s", 1132 1133 mountlist->el[items].device, … … 1137 1138 1138 1139 log_it(tmp); 1139 paranoid_free(tmp);1140 mr_free(tmp); 1140 1141 items++; 1141 1142 } 1142 (void)getline(&incoming, &n, fin);1143 mr_getline(&incoming, &n, fin); 1143 1144 } 1144 1145 paranoid_fclose(fin); 1145 paranoid_free(incoming);1146 mr_free(incoming); 1146 1147 mountlist->entries = items; 1147 1148 1148 1149 log_it("Mountlist loaded successfully."); 1149 asprintf(&tmp, "%d entries in mountlist", items);1150 mr_asprintf(&tmp, "%d entries in mountlist", items); 1150 1151 log_it(tmp); 1151 paranoid_free(tmp);1152 1153 paranoid_free(siz);1152 mr_free(tmp); 1153 1154 mr_free(siz); 1154 1155 return (0); 1155 1156 } … … 1264 1265 assert(b >= 0); 1265 1266 1266 asprintf(&device, mountlist->el[a].device);1267 asprintf(&mountpoint, mountlist->el[a].mountpoint);1268 asprintf(&format, mountlist->el[a].format);1267 mr_asprintf(&device, mountlist->el[a].device); 1268 mr_asprintf(&mountpoint, mountlist->el[a].mountpoint); 1269 mr_asprintf(&format, mountlist->el[a].format); 1269 1270 1270 1271 size = mountlist->el[a].size; -
trunk/mondo/src/common/libmondo-raid.c
r839 r900 9 9 10 10 #include "my-stuff.h" 11 #include "mr_str ing.h"11 #include "mr_str.h" 12 12 #include "mondostructures.h" 13 13 #include "newt-specific-EXT.h" … … 16 16 #include "libmondo-string-EXT.h" 17 17 #include "libmondo-raid.h" 18 #include "mr_ string.h"18 #include "mr_mem.h" 19 19 20 20 #ifdef __FreeBSD__ … … 49 49 50 50 if (raidno == -1) { 51 asprintf(&command,51 mr_asprintf(&command, 52 52 "grep \"linear\" /proc/mdstat > /dev/null 2> /dev/null"); 53 53 } else { 54 asprintf(&command,54 mr_asprintf(&command, 55 55 "grep \"raid%d\" /proc/mdstat > /dev/null 2> /dev/null", 56 56 raidno); … … 58 58 log_it("Is raid %d registered? Command = '%s'", raidno, command); 59 59 res = system(command); 60 paranoid_free(command);60 mr_free(command); 61 61 if (res) { 62 62 return (FALSE); … … 185 185 assert(label != NULL); 186 186 187 asprintf(&sz_value, "%d", value);188 asprintf(&sz_label,label);187 mr_asprintf(&sz_value, "%d", value); 188 mr_asprintf(&sz_label,label); 189 189 raidrec->additional_vars.el[lino].value = sz_value; 190 190 raidrec->additional_vars.el[lino].label = sz_label; … … 320 320 switch (raidrec->plex[i].raidlevel) { 321 321 case -1: 322 asprintf(&org, "%s", "concat");322 mr_asprintf(&org, "%s", "concat"); 323 323 break; 324 324 case 0: 325 asprintf(&org, "%s", "striped");325 mr_asprintf(&org, "%s", "striped"); 326 326 break; 327 327 case 5: 328 asprintf(&org, "%s", "raid5");328 mr_asprintf(&org, "%s", "raid5"); 329 329 break; 330 330 } 331 331 fprintf(fout, " plex org %s", org); 332 paranoid_free(org);332 mr_free(org); 333 333 334 334 if (raidrec->plex[i].raidlevel != -1) { … … 418 418 } 419 419 420 for ( getline(&incoming, &n, fin); !feof(fin);421 getline(&incoming, &n, fin)) {420 for (mr_getline(&incoming, &n, fin); !feof(fin); 421 mr_getline(&incoming, &n, fin)) { 422 422 strip_spaces(incoming); 423 423 p = strchr(incoming, ' '); … … 433 433 return (0); 434 434 } 435 paranoid_free(incoming);435 mr_free(incoming); 436 436 return (1); 437 437 } … … 563 563 fclose(fin); 564 564 log_it("Raidtab loaded successfully."); 565 asprintf(&tmp1, "%d RAID devices in raidtab", raidlist->entries);565 mr_asprintf(&tmp1, "%d RAID devices in raidtab", raidlist->entries); 566 566 log_it(tmp1); 567 paranoid_free(tmp1);567 mr_free(tmp1); 568 568 return (0); 569 569 } … … 700 700 } 701 701 if (!disklist) { 702 asprintf(&tmp,702 mr_asprintf(&tmp, 703 703 "Ignoring '%s %s' pair of disk %s", labelB, valueB, 704 704 label); 705 705 log_it(tmp); 706 paranoid_free(tmp);706 mr_free(tmp); 707 707 } else { 708 708 index = atoi(valueB); 709 709 add_disk_to_raid_device(disklist, value, index); 710 710 } 711 paranoid_free(labelB);712 paranoid_free(valueB);711 mr_free(labelB); 712 mr_free(valueB); 713 713 } else { 714 714 v = raidrec->additional_vars.entries; … … 773 773 int lastpos = 0; 774 774 775 getline(&line, &n, f);775 mr_getline(&line, &n, f); 776 776 if (feof(f)) { 777 777 log_it("[GNVCL] Uh... I reached the EOF."); … … 933 933 934 934 FILE *fin; 935 int r es = 0, row, i, index_min;935 int row, i, index_min; 936 936 int lastpos = 0; 937 937 size_t len = 0; … … 952 952 row = 1; 953 953 // skip first output row - contains registered RAID levels 954 res =getline(&string, &len, fin);954 mr_getline(&string, &len, fin); 955 955 // parse the rest 956 956 while ( !feof_unlocked(fin) ) { 957 res = getline(&string, &len, fin); 958 if (res <= 0) break; 957 mr_getline(&string, &len, fin); 959 958 // trim leading spaces 960 959 pos = string; 961 960 while (*pos == ' ') pos++; 962 asprintf(&strtmp, pos);963 paranoid_alloc(string,strtmp);964 paranoid_free(strtmp);961 mr_asprintf(&strtmp, pos); 962 mr_allocstr(string,strtmp); 963 mr_free(strtmp); 965 964 // if we have newline after only spaces, this is a blank line, update 966 965 // counters, otherwise do normal parsing … … 981 980 token = mr_strtok (string, delims, &lastpos); 982 981 // get RAID device name 983 asprintf(&strtmp,"%s%s", device_prefix, token);982 mr_asprintf(&strtmp,"%s%s", device_prefix, token); 984 983 raidlist->el[raidlist->entries].raid_device = strtmp; 985 paranoid_free(token);984 mr_free(token); 986 985 // skip ':' and status 987 986 token = mr_strtok (string, delims, &lastpos); 988 paranoid_free(token);987 mr_free(token); 989 988 token = mr_strtok (string, delims, &lastpos); 990 989 if (!strcmp(token, "inactive")) { 991 990 log_msg(1, "RAID device '%s' inactive.\n", 992 991 raidlist->el[raidlist->entries].raid_device); 993 paranoid_free(string);994 paranoid_free(token);992 mr_free(string); 993 mr_free(token); 995 994 return 1; 996 995 } 997 paranoid_free(token);996 mr_free(token); 998 997 999 998 // get RAID level … … 1017 1016 } else { 1018 1017 log_msg(1, "Unknown RAID level '%s'.\n", token); 1019 paranoid_free(string);1020 paranoid_free(token);1018 mr_free(string); 1019 mr_free(token); 1021 1020 return 1; 1022 1021 } 1023 paranoid_free(token);1022 mr_free(token); 1024 1023 1025 1024 // get RAID devices (type, index, device) … … 1039 1038 case ' ': // normal data disks 1040 1039 raidlist->el[raidlist->entries].data_disks.el[raidlist->el[raidlist->entries].data_disks.entries].index = atoi(pos + 1); 1041 asprintf(&strtmp,"%s%s", device_prefix, token);1040 mr_asprintf(&strtmp,"%s%s", device_prefix, token); 1042 1041 strcpy(raidlist->el[raidlist->entries].data_disks.el[raidlist->el[raidlist->entries].data_disks.entries].device, strtmp); 1043 paranoid_free(strtmp);1042 mr_free(strtmp); 1044 1043 raidlist->el[raidlist->entries].data_disks.entries++; 1045 1044 break; 1046 1045 case 'S': // spare disks 1047 1046 raidlist->el[raidlist->entries].spare_disks.el[raidlist->el[raidlist->entries].spare_disks.entries].index = atoi(pos + 1); 1048 asprintf(&strtmp,"%s%s", device_prefix, token);1047 mr_asprintf(&strtmp,"%s%s", device_prefix, token); 1049 1048 strcpy(raidlist->el[raidlist->entries].spare_disks.el[raidlist->el[raidlist->entries].spare_disks.entries].device, strtmp); 1050 paranoid_free(strtmp);1049 mr_free(strtmp); 1051 1050 raidlist->el[raidlist->entries].spare_disks.entries++; 1052 1051 break; 1053 1052 case 'F': // failed disks 1054 1053 raidlist->el[raidlist->entries].failed_disks.el[raidlist->el[raidlist->entries].failed_disks.entries].index = atoi(pos + 1); 1055 asprintf(&strtmp,"%s%s", device_prefix, token);1054 mr_asprintf(&strtmp,"%s%s", device_prefix, token); 1056 1055 strcpy(raidlist->el[raidlist->entries].failed_disks.el[raidlist->el[raidlist->entries].failed_disks.entries].device, strtmp); 1057 paranoid_free(strtmp);1056 mr_free(strtmp); 1058 1057 raidlist->el[raidlist->entries].failed_disks.entries++; 1059 1058 log_it("At least one failed disk found in RAID array.\n"); … … 1061 1060 default: // error 1062 1061 log_msg(1, "Unknown device type '%c'\n", type); 1063 paranoid_free(string);1064 paranoid_free(token);1062 mr_free(string); 1063 mr_free(token); 1065 1064 return 1; 1066 1065 break; 1067 1066 } 1068 paranoid_free(token);1067 mr_free(token); 1069 1068 } 1070 1069 … … 1119 1118 if (pos < string) { 1120 1119 log_it("String underflow!\n"); 1121 paranoid_free(string);1120 mr_free(string); 1122 1121 return 1; 1123 1122 } … … 1144 1143 if (pos < string) { 1145 1144 printf("ERROR: String underflow!\n"); 1146 paranoid_free(string);1145 mr_free(string); 1147 1146 return 1; 1148 1147 } … … 1161 1160 fclose(fin); 1162 1161 // free string 1163 paranoid_free(string);1162 mr_free(string); 1164 1163 // return success 1165 1164 return 0; -
trunk/mondo/src/common/libmondo-stream.c
r783 r900 22 22 #include "libmondo-tools-EXT.h" 23 23 #include "libmondo-fifo-EXT.h" 24 #include "mr_mem.h" 24 25 25 26 #define EXTRA_TAPE_CHECKSUMS … … 126 127 eject_device(bkpinfo->media_device); 127 128 } 128 paranoid_free(blk);129 paranoid_free(g_tapecatalog);129 mr_free(blk); 130 mr_free((void *)g_tapecatalog); 130 131 return (retval); 131 132 } … … 180 181 g_tapecatalog->el[i].tape_posK); 181 182 } 182 paranoid_free(blk);183 paranoid_free(g_tapecatalog);183 mr_free(blk); 184 mr_free((void *)g_tapecatalog); 184 185 return (retval); 185 186 } … … 192 193 int res; 193 194 194 asprintf(&command, "mt -f %s status", dev);195 mr_asprintf(&command, "mt -f %s status", dev); 195 196 res = run_program_and_log_output(command, 1); 196 paranoid_free(command);197 mr_free(command); 197 198 if (res) { 198 199 return (FALSE); … … 224 225 tmp = find_home_of_exe("cdrecord"); 225 226 if (tmp) { 226 asprintf(&cdr_exe, "cdrecord");227 } else { 228 asprintf(&cdr_exe, "dvdrecord");229 } 230 paranoid_free(tmp);231 232 asprintf(&command, "%s -scanbus 2> /dev/null | grep -i tape | wc -l",227 mr_asprintf(&cdr_exe, "cdrecord"); 228 } else { 229 mr_asprintf(&cdr_exe, "dvdrecord"); 230 } 231 mr_free(tmp); 232 233 mr_asprintf(&command, "%s -scanbus 2> /dev/null | grep -i tape | wc -l", 233 234 cdr_exe); 234 235 tmp = call_program_and_get_last_line_of_output(command); 235 paranoid_free(command);236 mr_free(command); 236 237 237 238 if (atoi(tmp) != 1) { 238 239 log_it 239 240 ("Either too few or too many tape streamers for me to detect..."); 240 asprintf(&dev, VANILLA_SCSI_TAPE"0");241 paranoid_free(tmp);242 paranoid_free(cdr_exe);241 mr_asprintf(&dev, VANILLA_SCSI_TAPE"0"); 242 mr_free(tmp); 243 mr_free(cdr_exe); 243 244 return 1; 244 245 } 245 paranoid_free(tmp);246 247 asprintf(&command,246 mr_free(tmp); 247 248 mr_asprintf(&command, 248 249 "%s -scanbus 2> /dev/null | tr -s '\t' ' ' | grep \"[0-9]*,[0-9]*,[0-9]*\" | grep -v \"[0-9]*) \\*\" | grep -i TAPE | cut -d' ' -f2 | head -n1", 249 250 cdr_exe); 250 251 tmp = call_program_and_get_last_line_of_output(command); 251 paranoid_free(command);252 mr_free(command); 252 253 if (strlen(tmp) < 2) { 253 254 log_it("Could not find tape device"); 254 paranoid_free(tmp);255 paranoid_free(cdr_exe);255 mr_free(tmp); 256 mr_free(cdr_exe); 256 257 return 1; 257 258 } 258 paranoid_free(tmp);259 260 asprintf(&command,259 mr_free(tmp); 260 261 mr_asprintf(&command, 261 262 "%s -scanbus 2> /dev/null | tr -s '\t' ' ' | grep \"[0-9]*,[0-9]*,[0-9]*\" | grep -v \"[0-9]*) \\*\" | grep -i TAPE | cut -d' ' -f3 | cut -d')' -f1 | head -n1", 262 263 cdr_exe); 263 paranoid_free(cdr_exe);264 mr_free(cdr_exe); 264 265 265 266 tmp = call_program_and_get_last_line_of_output(command); 266 paranoid_free(command);267 268 asprintf(&dev, VANILLA_SCSI_TAPE"%s", tmp);269 paranoid_free(tmp);267 mr_free(command); 268 269 mr_asprintf(&dev, VANILLA_SCSI_TAPE"%s", tmp); 270 mr_free(tmp); 270 271 271 272 if (!mt_says_tape_exists(dev)) { 272 paranoid_free(dev);273 274 asprintf(&dev, ALT_TAPE"%s", tmp);273 mr_free(dev); 274 275 mr_asprintf(&dev, ALT_TAPE"%s", tmp); 275 276 if (!mt_says_tape_exists(dev)) { 276 277 log_it("Cannot openin %s", dev); 277 paranoid_free(dev);278 279 asprintf(&dev, VANILLA_SCSI_TAPE"0");278 mr_free(dev); 279 280 mr_asprintf(&dev, VANILLA_SCSI_TAPE"0"); 280 281 if (!mt_says_tape_exists(dev)) { 281 282 log_it("Cannot openin %s", dev); 282 paranoid_free(dev);283 284 asprintf(&dev, "/dev/osst0");283 mr_free(dev); 284 285 mr_asprintf(&dev, "/dev/osst0"); 285 286 if (!mt_says_tape_exists(dev)) { 286 287 res++; … … 303 304 } else { 304 305 log_it("Turning %s", dev); 305 paranoid_free(tmp);306 asprintf(&tmp1,306 mr_free(tmp); 307 mr_asprintf(&tmp1, 307 308 (strrchr(dev, '/') != NULL) ? strrchr(dev, '/') : dev); 308 paranoid_free(dev);309 asprintf(&dev, "/dev/os%s", tmp1);310 paranoid_free(tmp1);309 mr_free(dev); 310 mr_asprintf(&dev, "/dev/os%s", tmp1); 311 mr_free(tmp1); 311 312 312 313 log_it("...into %s", dev); … … 321 322 322 323 if (res) { 323 paranoid_free(tmp);324 mr_free(tmp); 324 325 return (res); 325 326 } … … 327 328 if (strlen(tmp) < 2) { 328 329 log_it("Warning - size of tape unknown"); 329 paranoid_free(tmp);330 mr_free(tmp); 330 331 return (0); 331 332 } else { … … 352 353 fatal_error("Wrong order, sunshine."); 353 354 } 354 paranoid_free(fname);355 mr_free(fname); 355 356 fname = (char *)&res; 356 357 read_file_from_stream_to_file(bkpinfo, xattr_fname, *ptmp_size); … … 364 365 fatal_error("Wrong order, sunshine."); 365 366 } 366 paranoid_free(fname);367 mr_free(fname); 367 368 fname = (char *)&res; 368 369 if (*pctrl_chr != BLK_START_EXAT_FILE) { … … 425 426 if (g_current_media_number != tapeno) { 426 427 // log_it("g_current_media_number = %d", g_current_media_number); 427 asprintf(&tmp,428 mr_asprintf(&tmp, 428 429 _("When the tape drive goes quiet, please insert volume %d in this series."), 429 430 tapeno); 430 431 popup_and_OK(tmp); 431 paranoid_free(tmp);432 mr_free(tmp); 432 433 open_evalcall_form(_("Waiting while the tape drive settles")); 433 434 } else { … … 482 483 483 484 bufsize_K = (long long) (1024LL * (1 + g_tape_buffer_size_MB)); 484 asprintf(&tmpdir, "%s/tmpfs/backcatalog", td);485 mr_asprintf(&tmpdir, "%s/tmpfs/backcatalog", td); 485 486 if (strstr(latest_fname, ".afio.") || strstr(latest_fname, ".star.")) { 486 487 type = fileset; … … 493 494 } 494 495 mkdir(tmpdir, 0x700); 495 asprintf(&command, "cp -f %s %s", latest_fname, tmpdir);496 mr_asprintf(&command, "cp -f %s %s", latest_fname, tmpdir); 496 497 if (run_program_and_log_output(command, 6)) { 497 498 log_it("Warning - failed to copy %s to backcatalog at %s", 498 499 latest_fname, tmpdir); 499 500 } 500 paranoid_free(command);501 mr_free(command); 501 502 502 503 last = g_tapecatalog->entries - 1; … … 522 523 523 524 for (i = curr - 1; i >= 0 && curr - i < 10; i--) { 524 asprintf(&old_fname, "%s/%s", tmpdir, g_tapecatalog->el[i].fname);525 mr_asprintf(&old_fname, "%s/%s", tmpdir, g_tapecatalog->el[i].fname); 525 526 unlink(old_fname); 526 paranoid_free(old_fname);527 } 528 paranoid_free(tmpdir);527 mr_free(old_fname); 528 } 529 mr_free(tmpdir); 529 530 return (0); 530 531 } … … 554 555 return (0); 555 556 } 556 asprintf(&tmp, "mt -f %s setblk %ld", tapedev,557 mr_asprintf(&tmp, "mt -f %s setblk %ld", tapedev, 557 558 internal_tape_block_size); 558 559 res = run_program_and_log_output(tmp, 3); 559 paranoid_free(tmp);560 mr_free(tmp); 560 561 return (res); 561 562 } … … 605 606 } 606 607 insist_on_this_tape_number(1); 607 asprintf(&outfname, "%s/tmp/all.tar.gz", bkpinfo->tmpdir);608 mr_asprintf(&outfname, "%s/tmp/all.tar.gz", bkpinfo->tmpdir); 608 609 make_hole_for_file(outfname); 609 610 … … 649 650 } 650 651 paranoid_fclose(fout); 651 paranoid_free(datablock);652 mr_free(datablock); 652 653 /* find initial blocks */ 653 654 res = read_header_block_from_stream(&size, NULL, &ctrl_chr); … … 665 666 (void) getcwd(old_cwd, MAX_STR_LEN); 666 667 chdir(bkpinfo->tmpdir); 667 asprintf(&tmp, "tar -zxf %s tmp/mondo-restore.cfg 2> /dev/null",668 mr_asprintf(&tmp, "tar -zxf %s tmp/mondo-restore.cfg 2> /dev/null", 668 669 outfname); 669 670 paranoid_system(tmp); 670 paranoid_free(tmp);671 mr_free(tmp); 671 672 paranoid_system("cp -f tmp/mondo-restore.cfg . 2> /dev/null"); 672 673 chdir(old_cwd); 673 674 unlink(outfname); 674 paranoid_free(outfname);675 mr_free(outfname); 675 676 return (retval); 676 677 } … … 692 693 693 694 /* add 'dummy' if testing */ 694 asprintf(&command,695 mr_asprintf(&command, 695 696 "cdrecord -eject dev=%s speed=%d fs=24m -waiti - >> %s 2>> %s", 696 697 cddev, speed, MONDO_LOGFILE, MONDO_LOGFILE); … … 706 707 /* log_it("Let's see what happens, shall we?"); */ 707 708 g_tape_stream = popen(command, "w"); 708 paranoid_free(command);709 mr_free(command); 709 710 if (g_tape_stream) { 710 711 return (0); … … 852 853 res = read_header_block_from_stream(&temp_size, temp_fname, &ctrl_chr); 853 854 if (orig_size != temp_size && orig_size != -1) { 854 asprintf(&tmp,855 mr_asprintf(&tmp, 855 856 "output file's size should be %ld K but is apparently %ld K", 856 857 (long) size >> 10, (long) temp_size >> 10); 857 858 log_to_screen(tmp); 858 paranoid_free(tmp);859 mr_free(tmp); 859 860 } 860 861 if (ctrl_chr != BLK_START_FILE) { … … 862 863 return (1); 863 864 } 864 asprintf(&tmp, "Reading file from tape; writing to '%s'; %ld KB",865 mr_asprintf(&tmp, "Reading file from tape; writing to '%s'; %ld KB", 865 866 outfname, (long) size >> 10); 866 867 log_to_screen(tmp); 867 paranoid_free(tmp);868 mr_free(tmp); 868 869 869 870 if (foutstream) { … … 921 922 log_msg(6, ".......................... Should be %lld", orig_size); 922 923 g_tape_posK += total_read_from_tape_for_this_file / 1024; 923 asprintf(&actual_cksum, "%04x%04x", crc16, crctt);924 mr_asprintf(&actual_cksum, "%04x%04x", crc16, crctt); 924 925 if (foutstream) { /*log_it("Finished writing to foutstream"); */ 925 926 } else { … … 932 933 } 933 934 if (strcmp(temp_cksum, actual_cksum)) { 934 asprintf(&tmp, _("actual cksum=%s; recorded cksum=%s"), actual_cksum,935 mr_asprintf(&tmp, _("actual cksum=%s; recorded cksum=%s"), actual_cksum, 935 936 temp_cksum); 936 937 log_to_screen(tmp); 937 paranoid_free(tmp);938 939 asprintf(&tmp, _("%s (%ld K) is corrupt on tape"), temp_fname,938 mr_free(tmp); 939 940 mr_asprintf(&tmp, _("%s (%ld K) is corrupt on tape"), temp_fname, 940 941 (long) orig_size >> 10); 941 942 log_to_screen(tmp); 942 paranoid_free(tmp);943 mr_free(tmp); 943 944 retval++; 944 945 } 945 paranoid_free(actual_cksum);946 paranoid_free(datablock);947 paranoid_free(temp_fname);948 paranoid_free(temp_cksum);946 mr_free(actual_cksum); 947 mr_free(datablock); 948 mr_free(temp_fname); 949 mr_free(temp_cksum); 949 950 return (retval); 950 951 } … … 992 993 * something (allocate) */ 993 994 if (filename != NULL) { 994 asprintf(&filename, tempblock + 1000);995 mr_asprintf(&filename, tempblock + 1000); 995 996 } 996 997 if (*pcontrol_char == BLK_ABORTED_BACKUP) { … … 1009 1010 marker_to_string(*pcontrol_char), tempblock + 1000, 1010 1011 (long) (*plen) >> 10); 1011 paranoid_free(tempblock);1012 mr_free(tempblock); 1012 1013 return (retval); 1013 1014 } … … 1133 1134 wrong_marker(BLK_START_AN_AFIO_OR_SLICE, ctrl_chr); 1134 1135 log_msg(3, "Still trying to re-sync w/ tape"); 1135 paranoid_free(temp_fname);1136 mr_free(temp_fname); 1136 1137 temp_fname = (char *)&res; 1137 1138 } … … 1148 1149 /* Do not desallocate when the while condition is met */ 1149 1150 if (ctrl_chr != BLK_START_FILE) { 1150 paranoid_free(temp_fname);1151 mr_free(temp_fname); 1151 1152 temp_fname = (char *)&res; 1152 1153 } … … 1174 1175 } 1175 1176 1176 paranoid_free(temp_fname);1177 mr_free(temp_fname); 1177 1178 temp_fname = (char *)&res; 1178 1179 res = read_header_block_from_stream(&temp_size, NULL, &ctrl_chr); … … 1211 1212 log_msg(2, "Reading %s (it matches %s)", temp_fname, 1212 1213 the_file_I_was_reading); 1213 paranoid_free(temp_fname);1214 paranoid_free(datablock);1214 mr_free(temp_fname); 1215 mr_free(datablock); 1215 1216 return (0); 1216 1217 } … … 1281 1282 } 1282 1283 if (bkpinfo->backup_media_type == cdstream) { 1283 asprintf(&command,1284 mr_asprintf(&command, 1284 1285 "cdrecord -eject dev=%s speed=%d fs=24m -waiti - >> %s 2>> %s", 1285 1286 bkpinfo->media_device, bkpinfo->cdrw_speed, MONDO_LOGFILE, … … 1289 1290 log_it("Let's see what happens, shall we?"); 1290 1291 g_tape_stream = popen(command, "w"); 1291 paranoid_free(command);1292 mr_free(command); 1292 1293 if (!g_tape_stream) { 1293 1294 log_to_screen(_("Failed to openout to cdstream (fifo)")); … … 1332 1333 last = g_tapecatalog->entries - 1; 1333 1334 for (i = 0; i <= last; i++) { 1334 asprintf(&fname, "%s/tmpfs/backcatalog/%s", bkpinfo->tmpdir,1335 mr_asprintf(&fname, "%s/tmpfs/backcatalog/%s", bkpinfo->tmpdir, 1335 1336 g_tapecatalog->el[i].fname); 1336 1337 if (!does_file_exist(fname)) { … … 1351 1352 } 1352 1353 } 1353 paranoid_free(fname);1354 mr_free(fname); 1354 1355 } 1355 1356 log_msg(2, "Finished writing back catalog to tape"); … … 1385 1386 log_it("Data disks = %s", fname); 1386 1387 if (!does_file_exist(fname)) { 1387 asprintf(&tmp, _("Cannot find %s"), fname);1388 mr_asprintf(&tmp, _("Cannot find %s"), fname); 1388 1389 log_to_screen(tmp); 1389 paranoid_free(tmp);1390 mr_free(tmp); 1390 1391 return (1); 1391 1392 } … … 1479 1480 p++; 1480 1481 } 1481 asprintf(&tmp, "Writing file '%s' to tape (%ld KB)", p,1482 mr_asprintf(&tmp, "Writing file '%s' to tape (%ld KB)", p, 1482 1483 (long) filesize >> 10); 1483 1484 log_it(tmp); 1484 paranoid_free(tmp);1485 mr_free(tmp); 1485 1486 1486 1487 write_header_block_to_stream(filesize, infile_basename, … … 1522 1523 } 1523 1524 paranoid_fclose(fin); 1524 asprintf(&checksum, "%04x%04x", crc16, crctt);1525 mr_asprintf(&checksum, "%04x%04x", crc16, crctt); 1525 1526 /* BERLIOS: what does it do ??? */ 1526 1527 write_header_block_to_stream((off_t)g_current_media_number, checksum, 1527 1528 BLK_STOP_FILE); 1528 paranoid_free(checksum);1529 mr_free(checksum); 1529 1530 // log_it("File '%s' written to tape.", infile); 1530 1531 return (retval); … … 1582 1583 fwrite(tempblock, 1, (size_t) TAPE_BLOCK_SIZE, 1583 1584 g_tape_stream) / 1024; 1584 asprintf(&tmp, "%s (fname=%s, size=%ld K)",1585 mr_asprintf(&tmp, "%s (fname=%s, size=%ld K)", 1585 1586 marker_to_string(control_char), p, 1586 1587 (long) length_of_incoming_file >> 10); 1587 1588 log_msg(6, tmp); 1588 paranoid_free(tmp);1589 mr_free(tmp); 1589 1590 return (0); 1590 1591 } … … 1603 1604 1604 1605 /*@ end vars *************************************************** */ 1605 asprintf(&tmp, _("Wrong marker! (Should be %s, is actually %s)"),1606 mr_asprintf(&tmp, _("Wrong marker! (Should be %s, is actually %s)"), 1606 1607 marker_to_string(should_be), marker_to_string(it_is)); 1607 1608 log_to_screen(tmp); 1608 paranoid_free(tmp);1609 mr_free(tmp); 1609 1610 } 1610 1611 -
trunk/mondo/src/common/libmondo-string.c
r863 r900 15 15 #include "libmondo-tools-EXT.h" 16 16 #include <math.h> 17 #include "mr_mem.h" 17 18 18 19 /*@unused@*/ … … 42 43 assert(partno >= 0); 43 44 44 asprintf(&partition, "%s", drive);45 mr_asprintf(&partition, "%s", drive); 45 46 p = partition; 46 47 /* is this a devfs device path? */ … … 55 56 p = partition; 56 57 #ifdef BSD 57 asprintf(&partition, "%ss", p);58 mr_asprintf(&partition, "%ss", p); 58 59 #else 59 60 /* format /dev/cciss/c0d0 */ 60 asprintf(&partition, "%sp", p);61 mr_asprintf(&partition, "%sp", p); 61 62 #endif 62 paranoid_free(p);63 mr_free(p); 63 64 } 64 65 } 65 66 p = partition; 66 asprintf(&partition, "%s%d", p, partno);67 paranoid_free(p);67 mr_asprintf(&partition, "%s%d", p, partno); 68 mr_free(p); 68 69 return (partition); 69 70 } … … 92 93 } 93 94 for (p = in_out; *p == ' '; p++); 94 asprintf(&scratch, p);95 mr_asprintf(&scratch, p); 95 96 strip_spaces (scratch); 96 97 len = (int) strlen(scratch); … … 101 102 } 102 103 in_out[i] = '\0'; 103 asprintf(&out, "%s%s", in_out, scratch);104 paranoid_free(scratch);104 mr_asprintf(&out, "%s%s", in_out, scratch); 105 mr_free(scratch); 105 106 in_out = out; 106 107 for (i = x + len ; i < width - 1; i++) { … … 120 121 bool end = FALSE; 121 122 122 asprintf(&sav, sin);123 mr_asprintf(&sav, sin); 123 124 p = sav; 124 125 while ((*p != '\0') && (! end)) { … … 129 130 // build the new string by recursion 130 131 turn_wildcard_chars_into_literal_chars(q,p); 131 asprintf(&sout, "%s\\%c%s", sav, r, q);132 paranoid_free(q);133 paranoid_free(sav);132 mr_asprintf(&sout, "%s\\%c%s", sav, r, q); 133 mr_free(q); 134 mr_free(sav); 134 135 end = TRUE; 135 136 } … … 160 161 assert(disklist != NULL); 161 162 162 asprintf(&output, "%-24s %8d", disklist->el[lino].device,163 mr_asprintf(&output, "%-24s %8d", disklist->el[lino].device, 163 164 disklist->el[lino].index); 164 165 return (output); … … 188 189 fatal_error("Please use integers only. No decimal points."); 189 190 } 190 asprintf(&tmp, "%s", incoming);191 mr_asprintf(&tmp, "%s", incoming); 191 192 i = (int) strlen(tmp); 192 193 if (tmp[i - 1] == 'B' || tmp[i - 1] == 'b') { … … 197 198 tmp[i] = '\0'; 198 199 outval = atol(tmp); 199 paranoid_free(tmp);200 mr_free(tmp); 200 201 201 202 if (ch == 'g' || ch == 'G') { … … 214 215 fatal_error("Integer overflow."); 215 216 } else if (ch != 'm' && ch != 'M') { 216 asprintf(&tmp, "Re: parameter '%s' - bad multiplier ('%c')",217 mr_asprintf(&tmp, "Re: parameter '%s' - bad multiplier ('%c')", 217 218 incoming, ch); 218 219 fatal_error(tmp); … … 240 241 assert(width > 2); 241 242 242 asprintf(&output, "%s", incoming);243 mr_asprintf(&output, "%s", incoming); 243 244 for (i = (int) strlen(output); i < width; i++) { 244 245 output[i] = ' '; … … 268 269 switch (marker) { 269 270 case BLK_START_OF_BACKUP: 270 asprintf(&outstr, "%s", "BLK_START_OF_BACKUP");271 mr_asprintf(&outstr, "%s", "BLK_START_OF_BACKUP"); 271 272 break; 272 273 case BLK_START_OF_TAPE: 273 asprintf(&outstr, "%s", "BLK_START_OF_TAPE");274 mr_asprintf(&outstr, "%s", "BLK_START_OF_TAPE"); 274 275 break; 275 276 case BLK_START_AN_AFIO_OR_SLICE: 276 asprintf(&outstr, "%s", "BLK_START_AN_AFIO_OR_SLICE");277 mr_asprintf(&outstr, "%s", "BLK_START_AN_AFIO_OR_SLICE"); 277 278 break; 278 279 case BLK_STOP_AN_AFIO_OR_SLICE: 279 asprintf(&outstr, "%s", "BLK_STOP_AN_AFIO_OR_SLICE");280 mr_asprintf(&outstr, "%s", "BLK_STOP_AN_AFIO_OR_SLICE"); 280 281 break; 281 282 case BLK_START_AFIOBALLS: 282 asprintf(&outstr, "%s", "BLK_START_AFIOBALLS");283 mr_asprintf(&outstr, "%s", "BLK_START_AFIOBALLS"); 283 284 break; 284 285 case BLK_STOP_AFIOBALLS: 285 asprintf(&outstr, "%s", "BLK_STOP_AFIOBALLS");286 mr_asprintf(&outstr, "%s", "BLK_STOP_AFIOBALLS"); 286 287 break; 287 288 case BLK_STOP_BIGGIEFILES: 288 asprintf(&outstr, "%s", "BLK_STOP_BIGGIEFILES");289 mr_asprintf(&outstr, "%s", "BLK_STOP_BIGGIEFILES"); 289 290 break; 290 291 case BLK_START_A_NORMBIGGIE: 291 asprintf(&outstr, "%s", "BLK_START_A_NORMBIGGIE");292 mr_asprintf(&outstr, "%s", "BLK_START_A_NORMBIGGIE"); 292 293 break; 293 294 case BLK_START_A_PIHBIGGIE: 294 asprintf(&outstr, "%s", "BLK_START_A_PIHBIGGIE");295 mr_asprintf(&outstr, "%s", "BLK_START_A_PIHBIGGIE"); 295 296 break; 296 297 case BLK_START_EXTENDED_ATTRIBUTES: 297 asprintf(&outstr, "%s", "BLK_START_EXTENDED_ATTRIBUTES");298 mr_asprintf(&outstr, "%s", "BLK_START_EXTENDED_ATTRIBUTES"); 298 299 break; 299 300 case BLK_STOP_EXTENDED_ATTRIBUTES: 300 asprintf(&outstr, "%s", "BLK_STOP_EXTENDED_ATTRIBUTES");301 mr_asprintf(&outstr, "%s", "BLK_STOP_EXTENDED_ATTRIBUTES"); 301 302 break; 302 303 case BLK_START_EXAT_FILE: 303 asprintf(&outstr, "%s", "BLK_START_EXAT_FILE");304 mr_asprintf(&outstr, "%s", "BLK_START_EXAT_FILE"); 304 305 break; 305 306 case BLK_STOP_EXAT_FILE: 306 asprintf(&outstr, "%s", "BLK_STOP_EXAT_FILE");307 mr_asprintf(&outstr, "%s", "BLK_STOP_EXAT_FILE"); 307 308 break; 308 309 case BLK_START_BIGGIEFILES: 309 asprintf(&outstr, "%s", "BLK_START_BIGGIEFILES");310 mr_asprintf(&outstr, "%s", "BLK_START_BIGGIEFILES"); 310 311 break; 311 312 case BLK_STOP_A_BIGGIE: 312 asprintf(&outstr, "%s", "BLK_STOP_A_BIGGIE");313 mr_asprintf(&outstr, "%s", "BLK_STOP_A_BIGGIE"); 313 314 break; 314 315 case BLK_END_OF_TAPE: 315 asprintf(&outstr, "%s", "BLK_END_OF_TAPE");316 mr_asprintf(&outstr, "%s", "BLK_END_OF_TAPE"); 316 317 break; 317 318 case BLK_END_OF_BACKUP: 318 asprintf(&outstr, "%s", "BLK_END_OF_BACKUP");319 mr_asprintf(&outstr, "%s", "BLK_END_OF_BACKUP"); 319 320 break; 320 321 case BLK_ABORTED_BACKUP: 321 asprintf(&outstr, "%s", "BLK_ABORTED_BACKUP");322 mr_asprintf(&outstr, "%s", "BLK_ABORTED_BACKUP"); 322 323 break; 323 324 case BLK_START_FILE: 324 asprintf(&outstr, "%s", "BLK_START_FILE");325 mr_asprintf(&outstr, "%s", "BLK_START_FILE"); 325 326 break; 326 327 case BLK_STOP_FILE: 327 asprintf(&outstr, "%s", "BLK_STOP_FILE");328 mr_asprintf(&outstr, "%s", "BLK_STOP_FILE"); 328 329 break; 329 330 default: 330 asprintf(&outstr, "%s (%d)", "BLK_UNKNOWN", marker);331 mr_asprintf(&outstr, "%s (%d)", "BLK_UNKNOWN", marker); 331 332 break; 332 333 } … … 355 356 assert(mountlist != NULL); 356 357 357 asprintf(&output, "%-24s %-24s %-10s %8lld",358 mr_asprintf(&output, "%-24s %-24s %-10s %8lld", 358 359 mountlist->el[lino].device, mountlist->el[lino].mountpoint, 359 360 mountlist->el[lino].format, mountlist->el[lino].size / 1024); … … 386 387 p = ' '; 387 388 } 388 asprintf(&output, "%d %s disk%c ", noof_disks, label, p);389 mr_asprintf(&output, "%d %s disk%c ", noof_disks, label, p); 389 390 /* BERLIOS: replaced with space^^^^ here ! 390 391 while (strlen(output) < 14) { … … 413 414 switch (i) { 414 415 case 0: 415 asprintf(&output, "%s", "zero");416 mr_asprintf(&output, "%s", "zero"); 416 417 break; 417 418 case 1: 418 asprintf(&output, "%s", "one");419 mr_asprintf(&output, "%s", "one"); 419 420 break; 420 421 case 2: 421 asprintf(&output, "%s", "two");422 mr_asprintf(&output, "%s", "two"); 422 423 break; 423 424 case 3: 424 asprintf(&output, "%s", "three");425 mr_asprintf(&output, "%s", "three"); 425 426 break; 426 427 case 4: 427 asprintf(&output, "%s", "four");428 mr_asprintf(&output, "%s", "four"); 428 429 break; 429 430 case 5: 430 asprintf(&output, "%s", "five");431 mr_asprintf(&output, "%s", "five"); 431 432 break; 432 433 case 6: 433 asprintf(&output, "%s", "six");434 mr_asprintf(&output, "%s", "six"); 434 435 break; 435 436 case 7: 436 asprintf(&output, "%s", "seven");437 mr_asprintf(&output, "%s", "seven"); 437 438 break; 438 439 case 8: 439 asprintf(&output, "%s", "eight");440 mr_asprintf(&output, "%s", "eight"); 440 441 break; 441 442 case 9: 442 asprintf(&output, "%s", "nine");443 mr_asprintf(&output, "%s", "nine"); 443 444 case 10: 444 asprintf(&output, "%s", "ten");445 mr_asprintf(&output, "%s", "ten"); 445 446 default: 446 asprintf(&output, "%d", i);447 mr_asprintf(&output, "%d", i); 447 448 } 448 449 return (output); … … 470 471 471 472 strcpy(output, ip); /* just in case the token doesn't appear in string at all */ 472 asprintf(&input, "%s", ip);473 mr_asprintf(&input, "%s", ip); 473 474 while (strstr(input, token)) { 474 475 strcpy(output, input); … … 478 479 p = strstr(input, token) + strlen(token); 479 480 strcat(output, p); 480 paranoid_free(input);481 asprintf(&input, "%s", output);482 } 483 paranoid_free(input);481 mr_free(input); 482 mr_asprintf(&input, "%s", output); 483 } 484 mr_free(input); 484 485 } 485 486 … … 512 513 513 514 if (s != NULL) { 514 asprintf(&suffix, ".%s", s);515 mr_asprintf(&suffix, ".%s", s); 515 516 } else { 516 asprintf(&suffix, "%s", "");517 } 518 asprintf(&output, "%s/slice-%07ld.%05ld.dat%s", path, bigfileno,517 mr_asprintf(&suffix, "%s", ""); 518 } 519 mr_asprintf(&output, "%s/slice-%07ld.%05ld.dat%s", path, bigfileno, 519 520 sliceno, suffix); 520 paranoid_free(suffix);521 mr_free(suffix); 521 522 return (output); 522 523 } … … 578 579 } 579 580 if (strlen(flaws_str) > 0) { 580 asprintf(&flaws_str_A, "%s", flaws_str + 1);581 mr_asprintf(&flaws_str_A, "%s", flaws_str + 1); 581 582 } 582 583 if (strlen(flaws_str_A) >= 74) { 583 584 for (i = 74; flaws_str_A[i] != ' '; i--); 584 asprintf(&flaws_str_B, "%s", flaws_str_A + i + 1);585 mr_asprintf(&flaws_str_B, "%s", flaws_str_A + i + 1); 585 586 flaws_str_A[i] = '\0'; 586 587 } 587 588 if (strlen(flaws_str_B) >= 74) { 588 589 for (i = 74; flaws_str_B[i] != ' '; i--); 589 asprintf(&flaws_str_C, "%s", flaws_str_B + i + 1);590 mr_asprintf(&flaws_str_C, "%s", flaws_str_B + i + 1); 590 591 flaws_str_B[i] = '\0'; 591 592 } … … 669 670 670 671 assert(input != NULL); 671 asprintf(&output, "%s", input);672 mr_asprintf(&output, "%s", input); 672 673 p = strchr(input, '\"'); 673 674 if (p) { 674 675 q = strchr(++p, '\"'); 675 676 if (q) { 676 paranoid_free(output);677 asprintf(&output, "%s", p);677 mr_free(output); 678 mr_asprintf(&output, "%s", p); 678 679 *(strchr(output, '\"')) = '\0'; 679 680 } … … 706 707 original_incoming_length = (int) strlen(in_out); 707 708 for (i = 0; in_out[i] <= ' ' && i < (int) strlen(in_out); i++); 708 asprintf(&tmp, "%s", in_out + i);709 mr_asprintf(&tmp, "%s", in_out + i); 709 710 for (i = (int) strlen(tmp); i > 0 && tmp[i - 1] <= 32; i--); 710 711 tmp[i] = '\0'; … … 724 725 in_out[i++] = ' '; 725 726 } else if (in_out[i] == '\r') { 726 asprintf(&tmp1, "%s", in_out + i);727 mr_asprintf(&tmp1, "%s", in_out + i); 727 728 strcpy(in_out, tmp1); 728 paranoid_free(tmp1);729 mr_free(tmp1); 729 730 i = -1; 730 731 continue; … … 741 742 } 742 743 in_out[i] = '\0'; 743 paranoid_free(tmp);744 mr_free(tmp); 744 745 } 745 746 … … 760 761 761 762 if (incoming[0] == '\"' && incoming[strlen(incoming) - 1] == '\"') { 762 asprintf(&outgoing, "%s", incoming + 1);763 mr_asprintf(&outgoing, "%s", incoming + 1); 763 764 outgoing[strlen(outgoing) - 1] = '\0'; 764 765 } else { 765 asprintf(&outgoing, incoming);766 mr_asprintf(&outgoing, incoming); 766 767 } 767 768 return (outgoing); … … 831 832 832 833 if (raid_level >= 0) { 833 asprintf(&output, " RAID %-2d ", raid_level);834 mr_asprintf(&output, " RAID %-2d ", raid_level); 834 835 } else { 835 asprintf(&output, "Linear RAID");836 mr_asprintf(&output, "Linear RAID"); 836 837 } 837 838 return (output); … … 855 856 assert_string_is_neither_NULL_nor_zerolength(fn); 856 857 if (!strncmp(fn, MNT_RESTORING, strlen(MNT_RESTORING))) { 857 asprintf(&filename, "%s", fn + strlen(MNT_RESTORING));858 mr_asprintf(&filename, "%s", fn + strlen(MNT_RESTORING)); 858 859 } else if (fn[0] != '/') { 859 asprintf(&filename, "/%s", fn);860 mr_asprintf(&filename, "/%s", fn); 860 861 } else { 861 asprintf(&filename, "%s", fn);862 mr_asprintf(&filename, "%s", fn); 862 863 } 863 864 864 865 if (!strncmp(filename, "/var/", 5)) { 865 866 sev = 2; 866 asprintf(&reason,867 mr_asprintf(&reason, 867 868 _("/var's contents will change regularly, inevitably.")); 868 869 } 869 870 if (!strncmp(filename, "/home", 5)) { 870 871 sev = 2; 871 asprintf(&reason,872 mr_asprintf(&reason, 872 873 _("It's in your /home partiton. Therefore, it is important.")); 873 874 } 874 875 if (!strncmp(filename, "/usr/", 5)) { 875 876 sev = 3; 876 asprintf(&reason,877 mr_asprintf(&reason, 877 878 _("You may have installed/removed software during the backup.")); 878 879 } 879 880 if (!strncmp(filename, "/etc/", 5)) { 880 881 sev = 3; 881 asprintf(&reason,882 mr_asprintf(&reason, 882 883 _("Do not edit config files while backing up your PC.")); 883 884 } … … 885 886 || !strcmp(filename, "/etc/mtab")) { 886 887 sev = 1; 887 asprintf(&reason, _("This file changes all the time. It's OK."));888 mr_asprintf(&reason, _("This file changes all the time. It's OK.")); 888 889 } 889 890 if (!strncmp(filename, "/root/", 6)) { 890 891 sev = 3; 891 asprintf(&reason,892 mr_asprintf(&reason, 892 893 _("Were you compiling/editing something in /root?")); 893 894 } 894 895 if (!strncmp(filename, "/root/.", 7)) { 895 896 sev = 2; 896 asprintf(&reason, _("Temp or 'dot' files changed in /root."));897 mr_asprintf(&reason, _("Temp or 'dot' files changed in /root.")); 897 898 } 898 899 if (!strncmp(filename, "/var/lib/", 9)) { 899 900 sev = 2; 900 asprintf(&reason, _("Did you add/remove software during backing?"));901 mr_asprintf(&reason, _("Did you add/remove software during backing?")); 901 902 } 902 903 if (!strncmp(filename, "/var/lib/rpm", 12)) { 903 904 sev = 3; 904 asprintf(&reason, _("Did you add/remove software during backing?"));905 mr_asprintf(&reason, _("Did you add/remove software during backing?")); 905 906 } 906 907 if (!strncmp(filename, "/var/lib/slocate", 16)) { 907 908 sev = 1; 908 asprintf(&reason,909 mr_asprintf(&reason, 909 910 _("The 'update' daemon ran during backup. This does not affect the integrity of your backup.")); 910 911 } … … 913 914 || !strcmp(filename + strlen(filename) - 4, ".log")) { 914 915 sev = 1; 915 asprintf(&reason,916 mr_asprintf(&reason, 916 917 _("Log files change frequently as the computer runs. Fret not.")); 917 918 } 918 919 if (!strncmp(filename, "/var/spool", 10)) { 919 920 sev = 1; 920 asprintf(&reason,921 mr_asprintf(&reason, 921 922 _("Background processes or printers were active. This does not affect the integrity of your backup.")); 922 923 } 923 924 if (!strncmp(filename, "/var/spool/mail", 10)) { 924 925 sev = 2; 925 asprintf(&reason, _("Mail was sent/received during backup."));926 mr_asprintf(&reason, _("Mail was sent/received during backup.")); 926 927 } 927 928 if (filename[strlen(filename) - 1] == '~') { 928 929 sev = 1; 929 asprintf(&reason,930 mr_asprintf(&reason, 930 931 _("Backup copy of another file which was modified recently.")); 931 932 } 932 933 if (strstr(filename, "cache")) { 933 934 sev = 1; 934 asprintf(&reason,935 mr_asprintf(&reason, 935 936 _("Part of a cache of data. Caches change from time to time. Don't worry.")); 936 937 } … … 940 941 || strstr(filename, "/.Xauthority")) { 941 942 sev = 1; 942 asprintf(&reason,943 mr_asprintf(&reason, 943 944 "Temporary file (a lockfile, perhaps) used by software such as X or KDE to register its presence."); 944 945 } 945 paranoid_free(filename);946 mr_free(filename); 946 947 947 948 if (sev == 0) { 948 949 sev = 3; 949 asprintf(&reason,950 mr_asprintf(&reason, 950 951 _("Changed since backup. Consider running a differential backup in a day or two.")); 951 952 } … … 1005 1006 1006 1007 if (bkpinfo->media_size[g_current_media_number] <= 0) { 1007 asprintf(&outstr, _("Volume %d: %'lld kilobytes archived so far"),1008 mr_asprintf(&outstr, _("Volume %d: %'lld kilobytes archived so far"), 1008 1009 g_current_media_number, g_tape_posK); 1009 1010 … … 1016 1017 (int) (g_tape_posK / 10 / 1017 1018 bkpinfo->media_size[g_current_media_number]); 1018 asprintf(&prepstr, _("Volume %d: ["), g_current_media_number);1019 mr_asprintf(&prepstr, _("Volume %d: ["), g_current_media_number); 1019 1020 } else { 1020 1021 percentage = 1021 1022 (int) (space_occupied_by_cd(bkpinfo->scratchdir) * 100 / 1024 / 1022 1023 bkpinfo->media_size[g_current_media_number]); 1023 asprintf(&prepstr, "%s %d: [",1024 mr_asprintf(&prepstr, "%s %d: [", 1024 1025 bkpinfo->backup_media_string, 1025 1026 g_current_media_number); … … 1046 1047 /* 1047 1048 log_it("percentage: %d", percentage); 1048 asprintf(&outstr, "%s%s%s] %3d%% used", prepstr, tmp1, tmp2, percentage);1049 mr_asprintf(&outstr, "%s%s%s] %3d%% used", prepstr, tmp1, tmp2, percentage); 1049 1050 */ 1050 asprintf(&outstr, _("%s%s%s] %3d percent used"), prepstr, tmp1, tmp2,1051 mr_asprintf(&outstr, _("%s%s%s] %3d percent used"), prepstr, tmp1, tmp2, 1051 1052 percentage); 1052 paranoid_free(prepstr);1053 paranoid_free(tmp1);1054 paranoid_free(tmp2);1053 mr_free(prepstr); 1054 mr_free(tmp1); 1055 mr_free(tmp2); 1055 1056 return (outstr); 1056 1057 } -
trunk/mondo/src/common/libmondo-tools.c
r783 r900 21 21 #include <arpa/inet.h> 22 22 #endif 23 #include "mr_mem.h" 23 24 24 25 /*@unused@*/ … … 169 170 char *tmp; 170 171 171 asprintf(&tmp,172 mr_asprintf(&tmp, 172 173 "for i in `find /root /home -type d -name Desktop -maxdepth 2`; do \ 173 174 file=$i/.directory; if [ -f \"$file\" ] ; then mv -f $file $file.old ; \ … … 175 176 else { print $0;};}' $file.old > $file ; fi ; done"); 176 177 run_program_and_log_output(tmp, 5); 177 paranoid_free(tmp);178 mr_free(tmp); 178 179 } 179 180 … … 190 191 char *home_sz = NULL; 191 192 192 asprintf(&home_sz, MONDO_SHARE);193 mr_asprintf(&home_sz, MONDO_SHARE); 193 194 return (home_sz); 194 195 } … … 369 370 if (bkpinfo->backup_media_type == tape) { 370 371 log_msg(1, "Bar"); 371 asprintf(&tmp, "mt -f %s status", bkpinfo->media_device);372 mr_asprintf(&tmp, "mt -f %s status", bkpinfo->media_device); 372 373 log_msg(1, "tmp = '%s'", tmp); 373 374 if (run_program_and_log_output(tmp, 3)) { … … 375 376 ("Unable to open tape device. If you haven't specified it with -d, do so. If you already have, check your parameter. I think it's wrong."); 376 377 } 377 paranoid_free(tmp);378 mr_free(tmp); 378 379 } 379 380 make_hole_for_dir(bkpinfo->scratchdir); … … 385 386 run_program_and_log_output("cat /etc/*-release", 5); 386 387 run_program_and_log_output("cat /etc/*issue*", 5); 387 asprintf(&g_tmpfs_mountpt, "%s/tmpfs", bkpinfo->tmpdir);388 asprintf(&command, "mkdir -p %s", g_tmpfs_mountpt);388 mr_asprintf(&g_tmpfs_mountpt, "%s/tmpfs", bkpinfo->tmpdir); 389 mr_asprintf(&command, "mkdir -p %s", g_tmpfs_mountpt); 389 390 paranoid_system(command); 390 paranoid_free(command);391 mr_free(command); 391 392 rdsiz_MB = PPCFG_RAMDISK_SIZE + g_tape_buffer_size_MB; 392 393 #ifdef __FreeBSD__ … … 394 395 ("vmstat | tail -1 | tr -s ' ' | cut -d' ' -f6"); 395 396 avm += atol(tmp); 396 paranoid_free(tmp);397 mr_free(tmp); 397 398 tmp = call_program_and_get_last_line_of_output 398 399 ("swapinfo | grep -v Device | tr -s ' ' | cut -d' ' -f4 | tr '\n' '+' | sed 's/+$//' | bc"); 399 400 avm += atol(tmp); 400 paranoid_free(tmp);401 asprintf(&command, "mdmfs -s %d%c md9 %s", rdsiz_MB, 'm',401 mr_free(tmp); 402 mr_asprintf(&command, "mdmfs -s %d%c md9 %s", rdsiz_MB, 'm', 402 403 g_tmpfs_mountpt); 403 404 #else … … 405 406 ("free | grep \":\" | tr -s ' ' '\t' | cut -f2 | head -n1"); 406 407 avm += atol(tmp); 407 paranoid_free(tmp);408 asprintf(&command, "mount /dev/shm -t tmpfs %s -o size=%d%c",408 mr_free(tmp); 409 mr_asprintf(&command, "mount /dev/shm -t tmpfs %s -o size=%d%c", 409 410 g_tmpfs_mountpt, rdsiz_MB, 'm'); 410 411 run_program_and_log_output("cat /proc/cpuinfo", 5); … … 416 417 if (avm / 1024 > rdsiz_MB * 3) { 417 418 if (run_program_and_log_output(command, 5)) { 418 paranoid_free(g_tmpfs_mountpt);419 mr_free(g_tmpfs_mountpt); 419 420 log_it("Failed to mount tmpfs"); 420 421 } else { … … 422 423 } 423 424 } else { 424 paranoid_free(g_tmpfs_mountpt);425 mr_free(g_tmpfs_mountpt); 425 426 log_it("It doesn't seem you have enough swap to use tmpfs. Fine."); 426 427 } 427 paranoid_free(command);428 mr_free(command); 428 429 429 430 if (bkpinfo->use_lzo) { 430 paranoid_alloc(bkpinfo->zip_exe, "lzop");431 paranoid_alloc(bkpinfo->zip_suffix, "lzo");431 mr_allocstr(bkpinfo->zip_exe, "lzop"); 432 mr_allocstr(bkpinfo->zip_suffix, "lzo"); 432 433 } else if (bkpinfo->compression_level != 0) { 433 paranoid_alloc(bkpinfo->zip_exe, "bzip2");434 paranoid_alloc(bkpinfo->zip_suffix, "bz2");434 mr_allocstr(bkpinfo->zip_exe, "bzip2"); 435 mr_allocstr(bkpinfo->zip_suffix, "bz2"); 435 436 } else { 436 437 bkpinfo->zip_exe = NULL; … … 445 446 fatal_error("Please install growisofs."); 446 447 } 447 paranoid_free(tmp);448 mr_free(tmp); 448 449 449 450 if (bkpinfo->nonbootable_backup) { 450 asprintf(&mondo_mkisofs_sz, MONDO_GROWISOFS_NONBOOT);451 mr_asprintf(&mondo_mkisofs_sz, MONDO_GROWISOFS_NONBOOT); 451 452 } else if 452 453 #ifdef __FreeBSD__ … … 457 458 #ifdef __IA64__ 458 459 { 459 asprintf(&mondo_mkisofs_sz, MONDO_GROWISOFS_REGULAR_ELILO);460 mr_asprintf(&mondo_mkisofs_sz, MONDO_GROWISOFS_REGULAR_ELILO); 460 461 } 461 462 #else 462 463 { 463 asprintf(&mondo_mkisofs_sz, MONDO_GROWISOFS_REGULAR_LILO);464 mr_asprintf(&mondo_mkisofs_sz, MONDO_GROWISOFS_REGULAR_LILO); 464 465 } 465 466 #endif 466 467 else 467 468 { 468 asprintf(&mondo_mkisofs_sz, MONDO_GROWISOFS_REGULAR_SYSLINUX);469 mr_asprintf(&mondo_mkisofs_sz, MONDO_GROWISOFS_REGULAR_SYSLINUX); 469 470 } 470 471 if (bkpinfo->manual_cd_tray) { … … 472 473 // -m isn't supported by growisofs, BTW... 473 474 } else { 474 asprintf(&bkpinfo->call_make_iso,475 mr_asprintf(&bkpinfo->call_make_iso, 475 476 "%s %s -Z %s . 2>> _ERR_", 476 477 mondo_mkisofs_sz, "", bkpinfo->media_device); 477 478 } 478 paranoid_free(mondo_mkisofs_sz);479 mr_free(mondo_mkisofs_sz); 479 480 480 481 if (getenv ("SUDO_COMMAND")) { 481 asprintf(&command, "strings `which growisofs` | grep -c SUDO_COMMAND");482 mr_asprintf(&command, "strings `which growisofs` | grep -c SUDO_COMMAND"); 482 483 tmp = call_program_and_get_last_line_of_output(command); 483 484 if (!strcmp(tmp, "1")) { … … 485 486 fatal_error("Can't write DVDs as sudo because growisofs doesn't support this - see the growisofs manpage for details."); 486 487 } 487 paranoid_free(tmp);488 paranoid_free(command);488 mr_free(tmp); 489 mr_free(command); 489 490 } 490 491 log_msg(2, "call_make_iso (DVD res) is ... %s", … … 496 497 || bkpinfo->backup_media_type == cdr) { 497 498 if (!bkpinfo->manual_cd_tray) { 498 asprintf(&extra_cdrom_params, "-waiti ");499 mr_asprintf(&extra_cdrom_params, "-waiti "); 499 500 } 500 501 if (bkpinfo->backup_media_type == cdrw) { 501 502 if (extra_cdrom_params != NULL) { 502 asprintf(&tmp, extra_cdrom_params);503 paranoid_free(extra_cdrom_params);504 asprintf(&extra_cdrom_params, "%s blank=fast ", tmp);503 mr_asprintf(&tmp, extra_cdrom_params); 504 mr_free(extra_cdrom_params); 505 mr_asprintf(&extra_cdrom_params, "%s blank=fast ", tmp); 505 506 } else { 506 asprintf(&extra_cdrom_params, "blank=fast ");507 mr_asprintf(&extra_cdrom_params, "blank=fast "); 507 508 } 508 509 } … … 510 511 tmp1 = find_home_of_exe("dvdrecord"); 511 512 if (tmp) { 512 asprintf(&cdr_exe, "cdrecord");513 mr_asprintf(&cdr_exe, "cdrecord"); 513 514 } else if (tmp1) { 514 asprintf(&cdr_exe, "dvdrecord");515 mr_asprintf(&cdr_exe, "dvdrecord"); 515 516 } else { 516 517 fatal_error("Please install either cdrecord or dvdrecord."); 517 518 } 518 paranoid_free(tmp);519 paranoid_free(tmp1);519 mr_free(tmp); 520 mr_free(tmp1); 520 521 521 522 if (bkpinfo->nonbootable_backup) { 522 asprintf(&mondo_mkisofs_sz, "%s -r -p MondoRescue -publisher www.mondorescue.org -A Mondo_Rescue_GPL_Version -V _CD#_", bkpinfo->mr_conf->mondo_iso_creation_cmd);523 mr_asprintf(&mondo_mkisofs_sz, "%s -r -p MondoRescue -publisher www.mondorescue.org -A Mondo_Rescue_GPL_Version -V _CD#_", bkpinfo->mr_conf->mondo_iso_creation_cmd); 523 524 } else if 524 525 #ifdef __FreeBSD__ … … 529 530 #ifdef __IA64__ 530 531 { 531 asprintf(&mondo_mkisofs_sz, MONDO_MKISOFS_REGULAR_ELILO);532 mr_asprintf(&mondo_mkisofs_sz, MONDO_MKISOFS_REGULAR_ELILO); 532 533 } 533 534 #else 534 535 { 535 asprintf(&mondo_mkisofs_sz, MONDO_MKISOFS_REGULAR_LILO);536 mr_asprintf(&mondo_mkisofs_sz, MONDO_MKISOFS_REGULAR_LILO); 536 537 } 537 538 #endif 538 539 else 539 540 { 540 asprintf(&mondo_mkisofs_sz, MONDO_MKISOFS_REGULAR_SYSLINUX);541 mr_asprintf(&mondo_mkisofs_sz, MONDO_MKISOFS_REGULAR_SYSLINUX); 541 542 } 542 543 if (bkpinfo->manual_cd_tray) { 543 544 if (bkpinfo->call_before_iso == NULL) { 544 asprintf(&bkpinfo->call_before_iso,545 mr_asprintf(&bkpinfo->call_before_iso, 545 546 "%s -o %s/temporary.iso . 2>> _ERR_", 546 547 mondo_mkisofs_sz, bkpinfo->tmpdir); 547 548 } else { 548 asprintf(&call_before_iso_user, bkpinfo->call_before_iso);549 asprintf(&bkpinfo->call_before_iso,549 mr_asprintf(&call_before_iso_user, bkpinfo->call_before_iso); 550 mr_asprintf(&bkpinfo->call_before_iso, 550 551 "( %s -o %s/temporary.iso . 2>> _ERR_ ; %s )", 551 552 mondo_mkisofs_sz, bkpinfo->tmpdir, call_before_iso_user); 552 paranoid_free(call_before_iso_user);553 mr_free(call_before_iso_user); 553 554 } 554 555 log_it("bkpinfo->call_before_iso = %s", bkpinfo->call_before_iso); 555 asprintf(&bkpinfo->call_make_iso,556 mr_asprintf(&bkpinfo->call_make_iso, 556 557 "%s %s -v %s fs=4m dev=%s speed=%d %s/temporary.iso", 557 558 cdr_exe, (bkpinfo->please_dont_eject) ? " " : "-eject", … … 559 560 bkpinfo->cdrw_speed, bkpinfo->tmpdir); 560 561 } else { 561 asprintf(&bkpinfo->call_make_iso,562 mr_asprintf(&bkpinfo->call_make_iso, 562 563 "%s . 2>> _ERR_ | %s %s %s fs=4m dev=%s speed=%d -", 563 564 mondo_mkisofs_sz, cdr_exe, … … 566 567 bkpinfo->cdrw_speed); 567 568 } 568 paranoid_free(mondo_mkisofs_sz);569 paranoid_free(cdr_exe);570 paranoid_free(extra_cdrom_params);569 mr_free(mondo_mkisofs_sz); 570 mr_free(cdr_exe); 571 mr_free(extra_cdrom_params); 571 572 } // end of CD code 572 573 … … 581 582 582 583 log_it("isodir = %s", bkpinfo->isodir); 583 asprintf(&command, "df -P %s | tail -n1 | cut -d' ' -f1",584 mr_asprintf(&command, "df -P %s | tail -n1 | cut -d' ' -f1", 584 585 bkpinfo->isodir); 585 586 log_it("command = %s", command); 586 587 tmp = call_program_and_get_last_line_of_output(command); 587 paranoid_free(command);588 mr_free(command); 588 589 log_it("res of it = %s", tmp); 589 asprintf(&tmp1, "%s/ISO-DEV", bkpinfo->tmpdir);590 mr_asprintf(&tmp1, "%s/ISO-DEV", bkpinfo->tmpdir); 590 591 write_one_liner_data_file(tmp1, tmp); 591 paranoid_free(tmp1);592 593 asprintf(&command, "mount | grep -w %s | tail -n1 | cut -d' ' -f3",592 mr_free(tmp1); 593 594 mr_asprintf(&command, "mount | grep -w %s | tail -n1 | cut -d' ' -f3", 594 595 tmp); 595 paranoid_free(tmp);596 mr_free(tmp); 596 597 log_it("command = %s", command); 597 598 tmp = call_program_and_get_last_line_of_output(command); 598 paranoid_free(command);599 mr_free(command); 599 600 log_it("res of it = %s", tmp); 600 601 601 asprintf(&tmp1, "%s/ISO-MNT", bkpinfo->tmpdir);602 mr_asprintf(&tmp1, "%s/ISO-MNT", bkpinfo->tmpdir); 602 603 write_one_liner_data_file(tmp1, tmp); 603 paranoid_free(tmp1);604 mr_free(tmp1); 604 605 605 606 log_it("isomnt: %s, %d", tmp, strlen(tmp)); 606 607 if (strlen(bkpinfo->isodir) < strlen(tmp)) { 607 asprintf(&iso_path, " ");608 mr_asprintf(&iso_path, " "); 608 609 } else { 609 asprintf(&iso_path, "%s", bkpinfo->isodir + strlen(tmp));610 } 611 paranoid_free(tmp);612 613 asprintf(&tmp, "%s/ISODIR", bkpinfo->tmpdir);610 mr_asprintf(&iso_path, "%s", bkpinfo->isodir + strlen(tmp)); 611 } 612 mr_free(tmp); 613 614 mr_asprintf(&tmp, "%s/ISODIR", bkpinfo->tmpdir); 614 615 write_one_liner_data_file(tmp, iso_path); 615 paranoid_free(tmp);616 mr_free(tmp); 616 617 log_it("isodir: %s", iso_path); 617 paranoid_free(iso_path);618 asprintf(&tmp, "%s/ISO-PREFIX", bkpinfo->tmpdir);618 mr_free(iso_path); 619 mr_asprintf(&tmp, "%s/ISO-PREFIX", bkpinfo->tmpdir); 619 620 write_one_liner_data_file(tmp, bkpinfo->prefix); 620 621 log_it("iso-prefix: %s", bkpinfo->prefix); 621 paranoid_free(tmp);622 mr_free(tmp); 622 623 /* End patch */ 623 624 } // end of iso code 624 625 625 626 if (bkpinfo->backup_media_type == nfs) { 626 asprintf(&hostname, bkpinfo->nfs_mount);627 mr_asprintf(&hostname, bkpinfo->nfs_mount); 627 628 colon = strchr(hostname, ':'); 628 629 if (!colon) { … … 639 640 retval++; 640 641 } else { 641 asprintf(&ip_address, "%s%s", inet_ntoa((struct in_addr)642 mr_asprintf(&ip_address, "%s%s", inet_ntoa((struct in_addr) 642 643 *((struct in_addr 643 644 *) hent-> 644 645 h_addr)), 645 646 strchr(bkpinfo->nfs_mount, ':')); 646 paranoid_alloc(bkpinfo->nfs_mount, ip_address);647 paranoid_free(ip_address);647 mr_allocstr(bkpinfo->nfs_mount, ip_address); 648 mr_free(ip_address); 648 649 } 649 650 } 650 651 store_nfs_config(bkpinfo); 651 paranoid_free(hostname);652 mr_free(hostname); 652 653 } 653 654 … … 656 657 fprintf(stderr, "Type 'man mondoarchive' for help.\n"); 657 658 } 658 asprintf(&tmp, "%s", MONDO_TMPISOS);659 mr_asprintf(&tmp, "%s", MONDO_TMPISOS); 659 660 if (does_file_exist(tmp)) { 660 661 unlink(tmp); 661 662 } 662 paranoid_free(tmp);663 mr_free(tmp); 663 664 664 665 if (strlen(bkpinfo->tmpdir) < 2 || strlen(bkpinfo->scratchdir) < 2) { … … 668 669 if (bkpinfo->include_paths == NULL) { 669 670 // fatal_error ("Why no backup path?"); 670 asprintf(&bkpinfo->include_paths, "/");671 mr_asprintf(&bkpinfo->include_paths, "/"); 671 672 } 672 673 chmod(bkpinfo->scratchdir, 0700); 673 674 chmod(bkpinfo->tmpdir, 0700); 674 675 g_backup_media_type = bkpinfo->backup_media_type; 675 paranoid_alloc(g_backup_media_string,bkpinfo->backup_media_string);676 mr_allocstr(g_backup_media_string,bkpinfo->backup_media_string); 676 677 return (retval); 677 678 } … … 716 717 g_current_media_number = 1; 717 718 bkpinfo->postnuke_tarball = NULL; 718 paranoid_free(bkpinfo->nfs_mount);719 mr_free(bkpinfo->nfs_mount); 719 720 return (res); 720 721 } … … 746 747 } 747 748 748 paranoid_free(bkpinfo->media_device);749 paranoid_free(bkpinfo->boot_device);750 paranoid_free(bkpinfo->zip_exe);751 paranoid_free(bkpinfo->zip_suffix);752 paranoid_free(bkpinfo->restore_path);749 mr_free(bkpinfo->media_device); 750 mr_free(bkpinfo->boot_device); 751 mr_free(bkpinfo->zip_exe); 752 mr_free(bkpinfo->zip_suffix); 753 mr_free(bkpinfo->restore_path); 753 754 bkpinfo->use_lzo = FALSE; 754 755 bkpinfo->verify_data = FALSE; … … 758 759 (am_I_in_disaster_recovery_mode()? TRUE : FALSE); 759 760 if (bkpinfo->disaster_recovery) { 760 paranoid_alloc(bkpinfo->isodir, "/");761 mr_allocstr(bkpinfo->isodir, "/"); 761 762 } else { 762 paranoid_alloc(bkpinfo->isodir, "/var/cache/mondo/iso");763 } 764 paranoid_alloc(bkpinfo->prefix, STD_PREFIX);765 766 paranoid_free(bkpinfo->scratchdir);763 mr_allocstr(bkpinfo->isodir, "/var/cache/mondo/iso"); 764 } 765 mr_allocstr(bkpinfo->prefix, STD_PREFIX); 766 767 mr_free(bkpinfo->scratchdir); 767 768 bkpinfo->make_filelist = TRUE; // unless -J supplied to mondoarchive 768 paranoid_free(bkpinfo->tmpdir);769 asprintf(&bkpinfo->tmpdir, "/tmp/tmpfs/mondo.tmp.%d", (int) (random() % 32768)); // for mondorestore769 mr_free(bkpinfo->tmpdir); 770 mr_asprintf(&bkpinfo->tmpdir, "/tmp/tmpfs/mondo.tmp.%d", (int) (random() % 32768)); // for mondorestore 770 771 bkpinfo->optimal_set_size = 0; 771 772 bkpinfo->backup_media_type = none; 772 paranoid_free(bkpinfo->backup_media_string);773 paranoid_alloc(bkpinfo->include_paths, "/");774 paranoid_free(bkpinfo->exclude_paths);775 paranoid_free(bkpinfo->call_before_iso);776 paranoid_free(bkpinfo->call_make_iso);777 paranoid_free(bkpinfo->call_burn_iso);778 paranoid_free(bkpinfo->call_after_iso);779 paranoid_free(bkpinfo->image_devs);780 paranoid_free(bkpinfo->postnuke_tarball);781 paranoid_free(bkpinfo->kernel_path);782 paranoid_free(bkpinfo->nfs_mount);783 paranoid_free(bkpinfo->nfs_remote_dir);773 mr_free(bkpinfo->backup_media_string); 774 mr_allocstr(bkpinfo->include_paths, "/"); 775 mr_free(bkpinfo->exclude_paths); 776 mr_free(bkpinfo->call_before_iso); 777 mr_free(bkpinfo->call_make_iso); 778 mr_free(bkpinfo->call_burn_iso); 779 mr_free(bkpinfo->call_after_iso); 780 mr_free(bkpinfo->image_devs); 781 mr_free(bkpinfo->postnuke_tarball); 782 mr_free(bkpinfo->kernel_path); 783 mr_free(bkpinfo->nfs_mount); 784 mr_free(bkpinfo->nfs_remote_dir); 784 785 bkpinfo->wipe_media_first = FALSE; 785 786 bkpinfo->differential = FALSE; … … 805 806 assert_string_is_neither_NULL_nor_zerolength(partition); 806 807 807 asprintf(&command, "df -m -P %s &> /dev/null", partition);808 mr_asprintf(&command, "df -m -P %s &> /dev/null", partition); 808 809 if (system(command)) { 809 810 return (-1); 810 811 } // partition does not exist 811 paranoid_free(command);812 813 asprintf(&command, "df -m -P %s | tail -n1 | tr -s ' ' '\t' | cut -f4",812 mr_free(command); 813 814 mr_asprintf(&command, "df -m -P %s | tail -n1 | tr -s ' ' '\t' | cut -f4", 814 815 partition); 815 816 out_sz = call_program_and_get_last_line_of_output(command); 816 paranoid_free(command);817 mr_free(command); 817 818 if (strlen(out_sz) == 0) { 818 819 return (-1); 819 820 } // error within df, probably 820 821 res = atol(out_sz); 821 paranoid_free(out_sz);822 mr_free(out_sz); 822 823 return (res); 823 824 } … … 868 869 (_("WARNING! You have very little RAM. Please upgrade to 64MB or more.")); 869 870 } 870 paranoid_free(tmp);871 mr_free(tmp); 871 872 #endif 872 873 … … 929 930 log_to_screen(_("Please install ms-sys just in case.")); 930 931 } 931 paranoid_free(tmp);932 mr_free(tmp); 932 933 #endif 933 934 } … … 937 938 whine_if_not_found("cmp"); 938 939 } 939 paranoid_free(tmp);940 mr_free(tmp); 940 941 941 942 run_program_and_log_output … … 958 959 } 959 960 } 960 paranoid_free(tmp);961 mr_free(tmp); 961 962 #ifndef __FreeBSD__ 962 963 if (!does_file_exist("/etc/modules.conf")) { … … 1041 1042 1042 1043 if (!does_file_exist(config_file)) { 1043 asprintf(&tmp, "(read_cfg_var) Cannot find %s config file",1044 mr_asprintf(&tmp, "(read_cfg_var) Cannot find %s config file", 1044 1045 config_file); 1045 1046 log_to_screen(tmp); 1046 paranoid_free(tmp);1047 mr_free(tmp); 1047 1048 value = NULL; 1048 1049 return (1); … … 1054 1055 return (0); 1055 1056 */ } else { 1056 asprintf(&command, "grep '%s .*' %s| cut -d' ' -f2,3,4,5",1057 mr_asprintf(&command, "grep '%s .*' %s| cut -d' ' -f2,3,4,5", 1057 1058 label, config_file); 1058 1059 value = call_program_and_get_last_line_of_output(command); 1059 paranoid_free(command);1060 mr_free(command); 1060 1061 if (strlen(value) == 0) { 1061 1062 return (1); … … 1108 1109 log_msg(1, "Started sub"); 1109 1110 log_msg(4, "Setting command to something"); 1110 asprintf(&command,1111 mr_asprintf(&command, 1111 1112 "grep -v \":\" /etc/fstab | grep -vx \"#.*\" | grep -w \"/boot\" | tr -s ' ' '\t' | cut -f1 | head -n1"); 1112 1113 log_msg(4, "Cool. Command = '%s'", command); 1113 1114 tmp = call_program_and_get_last_line_of_output(command); 1114 paranoid_free(command);1115 mr_free(command); 1115 1116 1116 1117 log_msg(4, "tmp = '%s'", tmp); … … 1119 1120 if (strstr(tmp, "LABEL=")) { 1120 1121 if (!run_program_and_log_output("mount /boot", 5)) { 1121 paranoid_free(g_boot_mountpt);1122 asprintf(&g_boot_mountpt, "/boot");1122 mr_free(g_boot_mountpt); 1123 mr_asprintf(&g_boot_mountpt, "/boot"); 1123 1124 log_msg(1, "Mounted /boot"); 1124 1125 } else { … … 1126 1127 } 1127 1128 } else { 1128 asprintf(&command, "mount | grep -w \"%s\"", tmp);1129 mr_asprintf(&command, "mount | grep -w \"%s\"", tmp); 1129 1130 log_msg(3, "command = %s", command); 1130 1131 if (run_program_and_log_output(command, 5)) { 1131 paranoid_free(g_boot_mountpt);1132 asprintf(&g_boot_mountpt, tmp);1133 asprintf(&tmp1,1132 mr_free(g_boot_mountpt); 1133 mr_asprintf(&g_boot_mountpt, tmp); 1134 mr_asprintf(&tmp1, 1134 1135 "%s (your /boot partition) is not mounted. I'll mount it before backing up", 1135 1136 g_boot_mountpt); 1136 1137 log_it(tmp1); 1137 paranoid_free(tmp1);1138 1139 asprintf(&tmp1, "mount %s", g_boot_mountpt);1138 mr_free(tmp1); 1139 1140 mr_asprintf(&tmp1, "mount %s", g_boot_mountpt); 1140 1141 if (run_program_and_log_output(tmp1, 5)) { 1141 1142 /* BERLIOS: Useless ??? 1142 paranoid_free(g_boot_mountpt);1143 asprintf(&g_boot_mountpt, " ");1143 mr_free(g_boot_mountpt); 1144 mr_asprintf(&g_boot_mountpt, " "); 1144 1145 */ 1145 1146 log_msg(1, "Plan B"); 1146 1147 if (!run_program_and_log_output("mount /boot", 5)) { 1147 paranoid_free(g_boot_mountpt);1148 asprintf(&g_boot_mountpt, "/boot");1148 mr_free(g_boot_mountpt); 1149 mr_asprintf(&g_boot_mountpt, "/boot"); 1149 1150 log_msg(1, "Plan B worked"); 1150 1151 } else { … … 1153 1154 } 1154 1155 } 1155 paranoid_free(tmp1);1156 mr_free(tmp1); 1156 1157 } 1157 paranoid_free(command);1158 } 1159 } 1160 paranoid_free(tmp);1158 mr_free(command); 1159 } 1160 } 1161 mr_free(tmp); 1161 1162 log_msg(1, "Ended sub"); 1162 1163 } … … 1172 1173 log_msg(3, "starting"); 1173 1174 if (g_boot_mountpt != NULL) { 1174 asprintf(&tmp, "umount %s", g_boot_mountpt);1175 mr_asprintf(&tmp, "umount %s", g_boot_mountpt); 1175 1176 if (run_program_and_log_output(tmp, 5)) { 1176 1177 log_it("WARNING - unable to unmount /boot"); 1177 1178 } 1178 paranoid_free(tmp);1179 mr_free(tmp); 1179 1180 } 1180 1181 log_msg(3, "leaving"); … … 1205 1206 1206 1207 if (!does_file_exist(config_file)) { 1207 asprintf(&tmp, "(write_cfg_file) Cannot find %s config file",1208 mr_asprintf(&tmp, "(write_cfg_file) Cannot find %s config file", 1208 1209 config_file); 1209 1210 log_to_screen(tmp); 1210 paranoid_free(tmp);1211 mr_free(tmp); 1211 1212 return (1); 1212 1213 } … … 1214 1215 ("mktemp -q /tmp/mojo-jojo.blah.XXXXXX"); 1215 1216 if (does_file_exist(config_file)) { 1216 asprintf(&command, "grep -vx '%s .*' %s > %s",1217 mr_asprintf(&command, "grep -vx '%s .*' %s > %s", 1217 1218 label, config_file, tempfile); 1218 1219 paranoid_system(command); 1219 paranoid_free(command);1220 } 1221 asprintf(&command, "echo \"%s %s\" >> %s", label, value, tempfile);1220 mr_free(command); 1221 } 1222 mr_asprintf(&command, "echo \"%s %s\" >> %s", label, value, tempfile); 1222 1223 paranoid_system(command); 1223 paranoid_free(command);1224 1225 asprintf(&command, "mv -f %s %s", tempfile, config_file);1224 mr_free(command); 1225 1226 mr_asprintf(&command, "mv -f %s %s", tempfile, config_file); 1226 1227 paranoid_system(command); 1227 paranoid_free(command);1228 mr_free(command); 1228 1229 unlink(tempfile); 1229 paranoid_free(tempfile);1230 mr_free(tempfile); 1230 1231 return (0); 1231 1232 } … … 1243 1244 } else { 1244 1245 iamhere("Freeing globals"); 1245 paranoid_free(g_boot_mountpt);1246 paranoid_free(g_mondo_home);1247 paranoid_free(g_tmpfs_mountpt);1248 paranoid_free(g_erase_tmpdir_and_scratchdir);1249 paranoid_free(g_serial_string);1250 paranoid_free(g_magicdev_command);1246 mr_free(g_boot_mountpt); 1247 mr_free(g_mondo_home); 1248 mr_free(g_tmpfs_mountpt); 1249 mr_free(g_erase_tmpdir_and_scratchdir); 1250 mr_free(g_serial_string); 1251 mr_free(g_magicdev_command); 1251 1252 } 1252 1253 } … … 1295 1296 1296 1297 if (!g_magicdev_command) { 1297 asprintf(&tmp, "%s &", g_magicdev_command);1298 mr_asprintf(&tmp, "%s &", g_magicdev_command); 1298 1299 paranoid_system(tmp); 1299 paranoid_free(tmp);1300 mr_free(tmp); 1300 1301 } 1301 1302 } -
trunk/mondo/src/common/libmondo-verify.c
r783 r900 18 18 #include "libmondo-devices-EXT.h" 19 19 #include "libmondo-tools-EXT.h" 20 #include "mr_mem.h" 20 21 21 22 /*@unused@*/ … … 60 61 assert_string_is_neither_NULL_nor_zerolength(stderr_fname); 61 62 62 asprintf(&afio_found_changes, "%s.afio", ignorefiles_fname);63 mr_asprintf(&afio_found_changes, "%s.afio", ignorefiles_fname); 63 64 sync(); 64 65 … … 69 70 70 71 log_msg(1, "Now scanning log file for 'afio: ' stuff"); 71 asprintf(&command,72 mr_asprintf(&command, 72 73 "grep \"afio: \" %s | sed 's/afio: //' | grep -vx \"/dev/.*\" >> %s", 73 74 stderr_fname, afio_found_changes); 74 75 log_msg(2, command); 75 76 res = system(command); 76 paranoid_free(command);77 mr_free(command); 77 78 if (res) { 78 79 log_msg(2, "Warning - failed to think"); … … 80 81 81 82 log_msg(1, "Now scanning log file for 'star: ' stuff"); 82 asprintf(&command,83 mr_asprintf(&command, 83 84 "grep \"star: \" %s | sed 's/star: //' | grep -vx \"/dev/.*\" >> %s", 84 85 stderr_fname, afio_found_changes); 85 86 log_msg(2, command); 86 87 res = system(command); 87 paranoid_free(command);88 mr_free(command); 88 89 if (res) { 89 90 log_msg(2, "Warning - failed to think"); … … 91 92 // exclude_nonexistent_files (afio_found_changes); 92 93 afio_diffs = count_lines_in_file(afio_found_changes); 93 asprintf(&command,94 mr_asprintf(&command, 94 95 "sort %s %s %s | uniq -c | awk '{ if ($1==\"2\") {print $2;};}' | grep -v \"incheckentry xwait()\" > %s", 95 96 ignorefiles_fname, afio_found_changes, afio_found_changes, … … 97 98 log_msg(2, command); 98 99 paranoid_system(command); 99 paranoid_free(command);100 paranoid_free(afio_found_changes);100 mr_free(command); 101 mr_free(afio_found_changes); 101 102 return (afio_diffs); 102 103 } … … 145 146 } else { 146 147 retval++; 147 asprintf(&tmp, "Warning - missing set(s) between %d and %d\n",148 mr_asprintf(&tmp, "Warning - missing set(s) between %d and %d\n", 148 149 g_last_afioball_number, set_number - 1); 149 150 log_to_screen(tmp); 150 paranoid_free(tmp);151 } 152 } 153 asprintf(&tmp, "Verifying %s #%d's tarballs",151 mr_free(tmp); 152 } 153 } 154 mr_asprintf(&tmp, "Verifying %s #%d's tarballs", 154 155 bkpinfo->backup_media_string, 155 156 g_current_media_number); 156 157 open_evalcall_form(tmp); 157 paranoid_free(tmp);158 mr_free(tmp); 158 159 159 160 for (total_sets = set_number; … … 234 235 if (bkpinfo->compression_level > 0) { 235 236 if (bkpinfo->use_lzo) { 236 asprintf(&sz_exe, "lzop");237 mr_asprintf(&sz_exe, "lzop"); 237 238 } else { 238 asprintf(&sz_exe, "bzip2");239 mr_asprintf(&sz_exe, "bzip2"); 239 240 } 240 241 } else { 241 asprintf(&sz_exe, " ");242 mr_asprintf(&sz_exe, " "); 242 243 } 243 244 244 245 iamhere("before vsbf"); 245 asprintf(&tmp, "Verifying %s#%d's big files",246 mr_asprintf(&tmp, "Verifying %s#%d's big files", 246 247 bkpinfo->backup_media_string, 247 248 g_current_media_number); 248 249 open_evalcall_form(tmp); 249 paranoid_free(tmp);250 mr_free(tmp); 250 251 251 252 iamhere("after vsbf"); 252 asprintf(&mountpoint, "%s/archives", mtpt);253 mr_asprintf(&mountpoint, "%s/archives", mtpt); 253 254 if (last_bigfile_num == -1) { 254 255 bigfile_num = 0; … … 279 280 paranoid_fclose(fin); 280 281 } 281 asprintf(&tmp2, "%s/%s", bkpinfo->restore_path,282 mr_asprintf(&tmp2, "%s/%s", bkpinfo->restore_path, 282 283 biggiestruct.filename); 283 284 log_msg(2, "Opening biggiefile #%ld - '%s'", bigfile_num, tmp2); … … 286 287 retval++; 287 288 } 288 paranoid_free(tmp2);289 mr_free(tmp2); 289 290 290 291 slice_num++; … … 299 300 g_current_media_number, bigfile_num, slice_num); 300 301 if (bkpinfo->compression_level > 0) { 301 asprintf(&command, "%s -dc %s 2>> %s", sz_exe, tmp, MONDO_LOGFILE);302 mr_asprintf(&command, "%s -dc %s 2>> %s", sz_exe, tmp, MONDO_LOGFILE); 302 303 } else { 303 asprintf(&command, "cat %s", tmp);304 mr_asprintf(&command, "cat %s", tmp); 304 305 } 305 306 if ((pin = popen(command, "r"))) { … … 339 340 } 340 341 } 341 paranoid_free(command);342 mr_free(command); 342 343 slice_num++; 343 344 } 344 345 } 345 paranoid_free(tmp);346 paranoid_free(tmp1);347 paranoid_free(mountpoint);348 paranoid_free(sz_exe);346 mr_free(tmp); 347 mr_free(tmp1); 348 mr_free(mountpoint); 349 mr_free(sz_exe); 349 350 350 351 last_bigfile_num = bigfile_num; … … 355 356 close_evalcall_form(); 356 357 if (bufblkA) { 357 paranoid_free(bufblkA);358 mr_free(bufblkA); 358 359 } 359 360 if (bufblkB) { 360 paranoid_free(bufblkB);361 mr_free(bufblkB); 361 362 } 362 363 return (0); … … 397 398 398 399 /* chdir("/"); */ 399 asprintf(&outlog, "%s/afio.log", bkpinfo->tmpdir);400 mr_asprintf(&outlog, "%s/afio.log", bkpinfo->tmpdir); 400 401 401 402 /* if programmer forgot to say which compression thingy to use then find out */ … … 403 404 && strcmp(bkpinfo->zip_suffix, "lzo")) { 404 405 log_msg(2, "OK, I'm going to start using lzop."); 405 paranoid_alloc(bkpinfo->zip_exe, "lzop");406 paranoid_alloc(bkpinfo->zip_suffix, "lzo");406 mr_allocstr(bkpinfo->zip_exe, "lzop"); 407 mr_allocstr(bkpinfo->zip_suffix, "lzo"); 407 408 bkpinfo->use_lzo = TRUE; 408 409 } … … 410 411 && strcmp(bkpinfo->zip_suffix, "bz2")) { 411 412 log_msg(2, "OK, I'm going to start using bzip2."); 412 paranoid_alloc(bkpinfo->zip_exe, "bzip2");413 paranoid_alloc(bkpinfo->zip_suffix, "bz2");413 mr_allocstr(bkpinfo->zip_exe, "bzip2"); 414 mr_allocstr(bkpinfo->zip_suffix, "bz2"); 414 415 bkpinfo->use_lzo = FALSE; 415 416 } … … 418 419 bkpinfo->use_star = TRUE; 419 420 if (strstr(tarball_fname, ".bz2")) 420 asprintf(&command,421 mr_asprintf(&command, 421 422 "star -diff diffopts=mode,size,data file=%s %s >> %s 2>> %s", 422 423 tarball_fname, … … 425 426 } else { 426 427 bkpinfo->use_star = FALSE; 427 asprintf(&command, "afio -r -P %s -Z %s >> %s 2>> %s",428 mr_asprintf(&command, "afio -r -P %s -Z %s >> %s 2>> %s", 428 429 bkpinfo->zip_exe, tarball_fname, outlog, outlog); 429 430 } 430 431 log_msg(6, "command=%s", command); 431 432 paranoid_system(command); 432 paranoid_free(command);433 mr_free(command); 433 434 434 435 if (length_of_file(outlog) < 10) { 435 asprintf(&command, "cat %s >> %s", outlog, MONDO_LOGFILE);436 mr_asprintf(&command, "cat %s >> %s", outlog, MONDO_LOGFILE); 436 437 } else { 437 asprintf(&command, "cut -d':' -f%d %s | sort -u",438 mr_asprintf(&command, "cut -d':' -f%d %s | sort -u", 438 439 (bkpinfo->use_star) ? 1 : 2, outlog); 439 440 pin = popen(command, "r"); 440 441 if (pin) { 441 for ( getline(&tmp, &n, pin); !feof(pin);442 getline(&tmp, &n, pin)) {442 for (mr_getline(&tmp, &n, pin); !feof(pin); 443 mr_getline(&tmp, &n, pin)) { 443 444 if (bkpinfo->use_star) { 444 445 if (!strstr(tmp, "diffopts=")) { … … 467 468 } 468 469 paranoid_pclose(pin); 469 paranoid_free(tmp);470 mr_free(tmp); 470 471 } else { 471 472 log_OS_error(command); 472 473 } 473 474 } 474 paranoid_free(outlog);475 paranoid_free(command);475 mr_free(outlog); 476 mr_free(command); 476 477 477 478 /* chdir(old_pwd); */ … … 545 546 p++; 546 547 } 547 asprintf(&tmp, "mkdir -p %s/tmpfs", bkpinfo->tmpdir);548 mr_asprintf(&tmp, "mkdir -p %s/tmpfs", bkpinfo->tmpdir); 548 549 paranoid_system(tmp); 549 paranoid_free(tmp);550 551 asprintf(&tarball_fname, "%s/tmpfs/temporary-%s", bkpinfo->tmpdir, p);550 mr_free(tmp); 551 552 mr_asprintf(&tarball_fname, "%s/tmpfs/temporary-%s", bkpinfo->tmpdir, p); 552 553 /* BERLIOS : useless 553 asprintf(&tmp, "Temporarily copying file from tape to '%s'",554 mr_asprintf(&tmp, "Temporarily copying file from tape to '%s'", 554 555 tarball_fname); 555 556 log_it(tmp); 556 paranoid_free(tmp);557 mr_free(tmp); 557 558 */ 558 559 read_file_from_stream_to_file(bkpinfo, tarball_fname, size); 559 560 res = verify_a_tarball(bkpinfo, tarball_fname); 560 561 if (res) { 561 asprintf(&tmp,562 mr_asprintf(&tmp, 562 563 "Afioball '%s' no longer matches your live filesystem", 563 564 p); 564 565 log_msg(0, tmp); 565 paranoid_free(tmp);566 mr_free(tmp); 566 567 retval++; 567 568 } 568 569 unlink(tarball_fname); 569 paranoid_free(tarball_fname);570 mr_free(tarball_fname); 570 571 return (retval); 571 572 } … … 612 613 p++; 613 614 } 614 asprintf(&test_file, "%s/temporary-%s", bkpinfo->tmpdir, p);615 asprintf(&tmp,615 mr_asprintf(&test_file, "%s/temporary-%s", bkpinfo->tmpdir, p); 616 mr_asprintf(&tmp, 616 617 "Temporarily copying biggiefile %s's slices from tape to '%s'", 617 618 p, test_file); 618 619 log_it(tmp); 619 paranoid_free(tmp);620 mr_free(tmp); 620 621 for (res = 621 622 read_header_block_from_stream(&slice_siz, slice_fnam, &ctrl_chr); … … 629 630 res = read_file_from_stream_to_file(bkpinfo, test_file, slice_siz); 630 631 unlink(test_file); 631 paranoid_free(slice_fnam);632 mr_free(slice_fnam); 632 633 slice_fnam = (char *) &res; 633 634 res = … … 640 641 current_slice_number++; 641 642 retval += res; 642 paranoid_free(slice_fnam);643 mr_free(slice_fnam); 643 644 slice_fnam = (char *) &res; 644 645 } 645 paranoid_free(test_file);646 647 asprintf(&biggie_cksum, slice_fnam);648 paranoid_free(slice_fnam);646 mr_free(test_file); 647 648 mr_asprintf(&biggie_cksum, slice_fnam); 649 mr_free(slice_fnam); 649 650 650 651 if (biggie_cksum[0] != '\0') { 651 652 orig_cksum = calc_checksum_of_file(biggie_fname); 652 653 if (strcmp(biggie_cksum, orig_cksum)) { 653 asprintf(&tmp, "orig cksum=%s; curr cksum=%s", biggie_cksum,654 mr_asprintf(&tmp, "orig cksum=%s; curr cksum=%s", biggie_cksum, 654 655 orig_cksum); 655 656 log_msg(2, tmp); 656 paranoid_free(tmp);657 658 asprintf(&tmp, _("%s has changed on live filesystem"),657 mr_free(tmp); 658 659 mr_asprintf(&tmp, _("%s has changed on live filesystem"), 659 660 biggie_fname); 660 661 log_to_screen(tmp); 661 paranoid_free(tmp);662 663 asprintf(&tmp, "echo \"%s\" >> /tmp/biggies.changed",662 mr_free(tmp); 663 664 mr_asprintf(&tmp, "echo \"%s\" >> /tmp/biggies.changed", 664 665 biggie_fname); 665 666 system(tmp); 666 paranoid_free(tmp);667 } 668 paranoid_free(orig_cksum);669 } 670 paranoid_free(biggie_cksum);667 mr_free(tmp); 668 } 669 mr_free(orig_cksum); 670 } 671 mr_free(biggie_cksum); 671 672 672 673 return (retval); … … 702 703 assert(bkpinfo != NULL); 703 704 704 asprintf(&curr_xattr_list_fname, XATTR_BIGGLST_FNAME_RAW_SZ,705 mr_asprintf(&curr_xattr_list_fname, XATTR_BIGGLST_FNAME_RAW_SZ, 705 706 bkpinfo->tmpdir); 706 asprintf(&curr_acl_list_fname, ACL_BIGGLST_FNAME_RAW_SZ,707 mr_asprintf(&curr_acl_list_fname, ACL_BIGGLST_FNAME_RAW_SZ, 707 708 bkpinfo->tmpdir); 708 709 log_to_screen(_("Verifying regular archives on tape")); … … 726 727 wrong_marker(BLK_START_AFIOBALLS, ctrl_chr); 727 728 } 728 paranoid_free(curr_xattr_list_fname);729 paranoid_free(curr_acl_list_fname);729 mr_free(curr_xattr_list_fname); 730 mr_free(curr_acl_list_fname); 730 731 731 732 for (res = read_header_block_from_stream(&size, fname, &ctrl_chr); 732 733 ctrl_chr != BLK_STOP_AFIOBALLS; 733 734 res = read_header_block_from_stream(&size, fname, &ctrl_chr)) { 734 asprintf(&curr_xattr_list_fname, XATTR_LIST_FNAME_RAW_SZ,735 mr_asprintf(&curr_xattr_list_fname, XATTR_LIST_FNAME_RAW_SZ, 735 736 bkpinfo->tmpdir, current_afioball_number); 736 asprintf(&curr_acl_list_fname, ACL_LIST_FNAME_RAW_SZ,737 mr_asprintf(&curr_acl_list_fname, ACL_LIST_FNAME_RAW_SZ, 737 738 bkpinfo->tmpdir, current_afioball_number); 738 739 if (ctrl_chr == BLK_START_EXTENDED_ATTRIBUTES) { 739 740 iamhere("Reading EXAT files from tape"); 740 paranoid_free(fname);741 mr_free(fname); 741 742 fname = (char *) &res; 742 743 res = … … 745 746 curr_acl_list_fname); 746 747 } 747 paranoid_free(curr_xattr_list_fname);748 paranoid_free(curr_acl_list_fname);748 mr_free(curr_xattr_list_fname); 749 mr_free(curr_acl_list_fname); 749 750 750 751 if (ctrl_chr != BLK_START_AN_AFIO_OR_SLICE) { 751 752 wrong_marker(BLK_START_AN_AFIO_OR_SLICE, ctrl_chr); 752 753 } 753 asprintf(&tmp, "Verifying fileset #%ld", current_afioball_number);754 mr_asprintf(&tmp, "Verifying fileset #%ld", current_afioball_number); 754 755 /*log_it(tmp); */ 755 756 update_progress_form(tmp); 756 paranoid_free(tmp);757 mr_free(tmp); 757 758 758 759 res = verify_an_afioball_from_stream(bkpinfo, fname, size); 759 760 if (res) { 760 asprintf(&tmp, _("Afioball %ld differs from live filesystem"),761 mr_asprintf(&tmp, _("Afioball %ld differs from live filesystem"), 761 762 current_afioball_number); 762 763 log_to_screen(tmp); 763 paranoid_free(tmp);764 mr_free(tmp); 764 765 } 765 766 retval += res; 766 767 current_afioball_number++; 767 768 g_current_progress++; 768 paranoid_free(fname);769 mr_free(fname); 769 770 fname = (char *) &res; 770 771 res = read_header_block_from_stream(&size, fname, &ctrl_chr); … … 772 773 wrong_marker(BLK_STOP_AN_AFIO_OR_SLICE, ctrl_chr); 773 774 } 774 paranoid_free(fname);775 mr_free(fname); 775 776 fname = (char *) &res; 776 777 } 777 778 log_msg(1, "All done with afioballs"); 778 779 close_progress_form(); 779 paranoid_free(fname);780 mr_free(fname); 780 781 return (retval); 781 782 } … … 816 817 assert(bkpinfo != NULL); 817 818 818 asprintf(&curr_xattr_list_fname, XATTR_BIGGLST_FNAME_RAW_SZ,819 mr_asprintf(&curr_xattr_list_fname, XATTR_BIGGLST_FNAME_RAW_SZ, 819 820 bkpinfo->tmpdir); 820 asprintf(&curr_acl_list_fname, ACL_BIGGLST_FNAME_RAW_SZ,821 mr_asprintf(&curr_acl_list_fname, ACL_BIGGLST_FNAME_RAW_SZ, 821 822 bkpinfo->tmpdir); 822 asprintf(&comment, "Verifying all bigfiles.");823 mr_asprintf(&comment, "Verifying all bigfiles."); 823 824 log_to_screen(comment); 824 825 res = read_header_block_from_stream(&size, orig_fname, &ctrl_chr); … … 826 827 if (ctrl_chr == BLK_START_EXTENDED_ATTRIBUTES) { 827 828 iamhere("Grabbing the EXAT biggiefiles"); 828 paranoid_free(orig_fname);829 mr_free(orig_fname); 829 830 orig_fname = (char *) &ctrl_chr; 830 831 res = … … 834 835 } 835 836 } 836 paranoid_free(curr_xattr_list_fname);837 paranoid_free(curr_acl_list_fname);838 paranoid_free(orig_fname);837 mr_free(curr_xattr_list_fname); 838 mr_free(curr_acl_list_fname); 839 mr_free(orig_fname); 839 840 orig_fname = (char *) &ctrl_chr; 840 841 … … 847 848 _("Please wait. This may take some time."), "", 848 849 noof_biggiefiles); 849 paranoid_free(comment);850 mr_free(comment); 850 851 851 852 for (res = read_header_block_from_stream(&size, orig_fname, &ctrl_chr); … … 863 864 p++; 864 865 } 865 asprintf(&comment, _("Verifying bigfile #%ld (%ld K)"),866 mr_asprintf(&comment, _("Verifying bigfile #%ld (%ld K)"), 866 867 current_biggiefile_number, (long) size >> 10); 867 868 update_progress_form(comment); 868 paranoid_free(comment);869 870 asprintf(&logical_fname, "%s/%s", bkpinfo->restore_path,869 mr_free(comment); 870 871 mr_asprintf(&logical_fname, "%s/%s", bkpinfo->restore_path, 871 872 orig_fname); 872 873 res = 873 874 verify_a_biggiefile_from_stream(bkpinfo, logical_fname, size); 874 paranoid_free(logical_fname);875 mr_free(logical_fname); 875 876 retval += res; 876 877 current_biggiefile_number++; 877 878 g_current_progress++; 878 paranoid_free(orig_fname);879 mr_free(orig_fname); 879 880 orig_fname = (char *) &ctrl_chr; 880 881 } … … 922 923 assert(bkpinfo != NULL); 923 924 924 asprintf(&mountpoint, "%s/cdrom", bkpinfo->tmpdir);925 asprintf(&fname, "%s/%s/%s-%d.iso", bkpinfo->isodir, bkpinfo->nfs_remote_dir,925 mr_asprintf(&mountpoint, "%s/cdrom", bkpinfo->tmpdir); 926 mr_asprintf(&fname, "%s/%s/%s-%d.iso", bkpinfo->isodir, bkpinfo->nfs_remote_dir, 926 927 bkpinfo->prefix, g_current_media_number); 927 928 … … 929 930 sync(); 930 931 if (!does_file_exist(fname)) { 931 asprintf(&tmp,932 mr_asprintf(&tmp, 932 933 "%s not found; assuming you backed up to CD; verifying CD...", 933 934 fname); 934 935 log_msg(2, tmp); 935 paranoid_free(tmp);936 mr_free(tmp); 936 937 937 938 if (bkpinfo->manual_cd_tray) { … … 943 944 } 944 945 } else { 945 asprintf(&tmp, "%s found; verifying ISO...", fname);946 mr_asprintf(&tmp, "%s found; verifying ISO...", fname); 946 947 log_to_screen(tmp); 947 paranoid_free(tmp);948 mr_free(tmp); 948 949 #ifdef __FreeBSD__ 949 950 ret = 0; … … 951 952 mddevice = make_vn(fname); 952 953 if (ret) { 953 asprintf(&tmp, _("make_vn of %s failed; unable to verify ISO\n"),954 mr_asprintf(&tmp, _("make_vn of %s failed; unable to verify ISO\n"), 954 955 fname); 955 956 log_to_screen(tmp); 956 paranoid_free(tmp);957 mr_free(tmp); 957 958 return (1); 958 959 } 959 asprintf(&command, "mount_cd9660 %s %s", mddevice, mountpoint);960 mr_asprintf(&command, "mount_cd9660 %s %s", mddevice, mountpoint); 960 961 #else 961 asprintf(&command, "mount -o loop,ro -t iso9660 %s %s", fname,962 mr_asprintf(&command, "mount -o loop,ro -t iso9660 %s %s", fname, 962 963 mountpoint); 963 964 #endif 964 965 if (run_program_and_log_output(command, FALSE)) { 965 asprintf(&tmp, _("%s failed; unable to mount ISO image\n"),966 mr_asprintf(&tmp, _("%s failed; unable to mount ISO image\n"), 966 967 command); 967 968 log_to_screen(tmp); 968 paranoid_free(tmp);969 mr_free(tmp); 969 970 return (1); 970 971 } 971 paranoid_free(command);972 mr_free(command); 972 973 } 973 974 log_msg(2, "OK, I've mounted the ISO/CD\n"); 974 asprintf(&tmp, "%s/archives/NOT-THE-LAST", mountpoint);975 mr_asprintf(&tmp, "%s/archives/NOT-THE-LAST", mountpoint); 975 976 if (!does_file_exist(tmp)) { 976 977 log_msg … … 984 985 */ 985 986 } 986 paranoid_free(tmp);987 mr_free(tmp); 987 988 988 989 verify_afioballs_on_CD(bkpinfo, mountpoint); … … 992 993 #ifdef __FreeBSD__ 993 994 ret = 0; 994 asprintf(&command, "umount %s", mountpoint);995 mr_asprintf(&command, "umount %s", mountpoint); 995 996 ret += system(command); 996 997 … … 998 999 if (ret) 999 1000 #else 1000 asprintf(&command, "umount %s", mountpoint);1001 mr_asprintf(&command, "umount %s", mountpoint); 1001 1002 1002 1003 if (system(command)) 1003 1004 #endif 1004 1005 { 1005 asprintf(&tmp, "%s failed; unable to unmount ISO image\n",1006 mr_asprintf(&tmp, "%s failed; unable to unmount ISO image\n", 1006 1007 command); 1007 1008 log_to_screen(tmp); 1008 paranoid_free(tmp);1009 mr_free(tmp); 1009 1010 retval++; 1010 1011 } else { 1011 1012 log_msg(2, "OK, I've unmounted the ISO file\n"); 1012 1013 } 1013 paranoid_free(command);1014 paranoid_free(mountpoint);1014 mr_free(command); 1015 mr_free(mountpoint); 1015 1016 1016 1017 if (!does_file_exist(fname)) { 1017 asprintf(&command, "umount %s", bkpinfo->media_device);1018 mr_asprintf(&command, "umount %s", bkpinfo->media_device); 1018 1019 run_program_and_log_output(command, 2); 1019 paranoid_free(command);1020 mr_free(command); 1020 1021 1021 1022 if (!bkpinfo->please_dont_eject … … 1024 1025 } 1025 1026 } 1026 paranoid_free(fname);1027 mr_free(fname); 1027 1028 return (retval); 1028 1029 } … … 1068 1069 paranoid_system 1069 1070 ("rm -f /tmp/biggies.changed /tmp/changed.files.[0-9]* 2> /dev/null"); 1070 asprintf(&changed_files_fname, "/tmp/changed.files.%d",1071 mr_asprintf(&changed_files_fname, "/tmp/changed.files.%d", 1071 1072 (int) (random() % 32767)); 1072 asprintf(&tmp,1073 mr_asprintf(&tmp, 1073 1074 "grep -x \"%s:.*\" %s | cut -d'\"' -f2 | sort -u | awk '{print \"/\"$0;};' | tr -s '/' '/' | grep -v \"(total of\" | grep -v \"incheckentry.*xwait\" | grep -vx \"/afio:.*\" | grep -vx \"dev/.*\" > %s", 1074 1075 (bkpinfo->use_star) ? "star" : "afio", MONDO_LOGFILE, … … 1086 1087 } 1087 1088 } 1088 paranoid_free(tmp);1089 1090 asprintf(&tmp, "cat /tmp/biggies.changed >> %s", changed_files_fname);1089 mr_free(tmp); 1090 1091 mr_asprintf(&tmp, "cat /tmp/biggies.changed >> %s", changed_files_fname); 1091 1092 paranoid_system(tmp); 1092 paranoid_free(tmp);1093 mr_free(tmp); 1093 1094 1094 1095 diffs = count_lines_in_file(changed_files_fname); 1095 1096 if (diffs > 0) { 1096 asprintf(&tmp, "cp -f %s %s", changed_files_fname,1097 mr_asprintf(&tmp, "cp -f %s %s", changed_files_fname, 1097 1098 "/tmp/changed.files"); 1098 1099 run_program_and_log_output(tmp, FALSE); 1099 paranoid_free(tmp);1100 1101 asprintf(&tmp,1100 mr_free(tmp); 1101 1102 mr_asprintf(&tmp, 1102 1103 "%ld files differed from live filesystem; type less %s or less %s to see", 1103 1104 diffs, changed_files_fname, "/tmp/changed.files"); 1104 1105 log_msg(0, tmp); 1105 paranoid_free(tmp);1106 mr_free(tmp); 1106 1107 1107 1108 log_to_screen … … 1111 1112 // retval++; 1112 1113 } 1113 paranoid_free(changed_files_fname);1114 mr_free(changed_files_fname); 1114 1115 return (retval); 1115 1116 } … … 1133 1134 assert(bkpinfo != NULL); 1134 1135 assert_string_is_neither_NULL_nor_zerolength(mountpoint); 1135 asprintf(&output, "%s/archives/%d.star.%s", mountpoint, setno,1136 mr_asprintf(&output, "%s/archives/%d.star.%s", mountpoint, setno, 1136 1137 bkpinfo->zip_suffix); 1137 1138 if (!does_file_exist(output)) { 1138 paranoid_free(output);1139 asprintf(&output, "%s/archives/%d.afio.%s", mountpoint, setno,1139 mr_free(output); 1140 mr_asprintf(&output, "%s/archives/%d.afio.%s", mountpoint, setno, 1140 1141 bkpinfo->zip_suffix); 1141 1142 } -
trunk/mondo/src/common/mondostructures.h
r783 r900 773 773 int mindi_ia64_boot_size; 774 774 char *mondo_iso_creation_cmd; 775 }; 775 char *mondo_logfile; 776 }; -
trunk/mondo/src/common/mr_string.c
r863 r900 1 1 /* 2 * mr_string.c - New generation of string handling functions 2 * $Id$ 3 * 4 * New generation of string handling functions 3 5 */ 4 6 … … 98 100 99 101 return retstr; 100 101 102 } -
trunk/mondo/src/common/newt-specific.c
r838 r900 26 26 #include "libmondo-fork-EXT.h" 27 27 #include "newt-specific-EXT.h" 28 #include "mr_mem.h" 28 29 29 30 /*@unused@*/ … … 116 117 ("---promptdialogYN---1--- %s\r\n---promptdialogYN---Q--- [yes] [no] ---\r\n--> ", 117 118 prompt); 118 (void)getline(&tmp, &n, stdin);119 mr_getline(&tmp, &n, stdin); 119 120 if (tmp[strlen(tmp) - 1] == '\n') 120 121 tmp[strlen(tmp) - 1] = '\0'; … … 125 126 } 126 127 if (strstr(_("yesYES"), tmp)) { 127 paranoid_free(tmp);128 mr_free(tmp); 128 129 return (TRUE); 129 130 } else if (strstr(_("NOno"), tmp)) { 130 paranoid_free(tmp);131 mr_free(tmp); 131 132 return (FALSE); 132 133 } else { … … 161 162 ("---promptdialogOKC---1--- %s\r\n---promptdialogOKC---Q--- [OK] [Cancel] ---\r\n--> ", 162 163 prompt); 163 (void)getline(&tmp, &n, stdin);164 mr_getline(&tmp, &n, stdin); 164 165 if (tmp[strlen(tmp) - 1] == '\n') 165 166 tmp[strlen(tmp) - 1] = '\0'; … … 170 171 } 171 172 if (strstr(_("okOKOkYESyes"), tmp)) { 172 paranoid_free(tmp);173 mr_free(tmp); 173 174 return (TRUE); 174 175 } else { 175 paranoid_free(tmp);176 mr_free(tmp); 176 177 return (FALSE); 177 178 } … … 243 244 char *tmp = NULL; 244 245 245 asprintf(&tmp,"kill `ps %s | grep \" %s \" | awk '{print $1;}' | grep -vx \"\\?\"`", ps_options, str);246 mr_asprintf(&tmp,"kill `ps %s | grep \" %s \" | awk '{print $1;}' | grep -vx \"\\?\"`", ps_options, str); 246 247 run_program_and_log_output(tmp, TRUE); 247 paranoid_free(tmp);248 mr_free(tmp); 248 249 } 249 250 … … 264 265 /*@ end vars **************************************************** */ 265 266 266 asprintf(&fatalstr, "-------FATAL ERROR---------");267 mr_asprintf(&fatalstr, "-------FATAL ERROR---------"); 267 268 set_signals(FALSE); // link to external func 268 269 g_exiting = TRUE; … … 297 298 sync(); 298 299 if (g_tmpfs_mountpt != NULL) { 299 asprintf(&tmp, "umount %s", g_tmpfs_mountpt);300 mr_asprintf(&tmp, "umount %s", g_tmpfs_mountpt); 300 301 chdir("/"); 301 302 for (i = 0; i < 10 && run_program_and_log_output(tmp, 5); i++) { … … 304 305 run_program_and_log_output(tmp, 5); 305 306 } 306 paranoid_free(tmp);307 mr_free(tmp); 307 308 } 308 309 … … 312 313 313 314 if (g_selfmounted_isodir) { 314 asprintf(&command, "umount %s", g_selfmounted_isodir);315 mr_asprintf(&command, "umount %s", g_selfmounted_isodir); 315 316 run_program_and_log_output(command, 5); 316 asprintf(&command, "rmdir %s", g_selfmounted_isodir);317 mr_asprintf(&command, "rmdir %s", g_selfmounted_isodir); 317 318 run_program_and_log_output(command, 5); 318 paranoid_free(g_selfmounted_isodir);319 mr_free(g_selfmounted_isodir); 319 320 } 320 321 … … 322 323 log_msg(0, fatalstr); 323 324 log_msg(0, error_string); 324 // popup_and_OK (error_string);325 325 newtFinished(); 326 326 } 327 327 328 system329 ("gzip -9c "MONDO_LOGFILE" > /tmp/MA.log.gz 2> /dev/null");330 328 printf 331 329 (_("If you require technical support, please contact the mailing list.\n")); … … 334 332 (_("The list's members can help you, if you attach that file to your e-mail.\n")); 335 333 printf(_("Log file: %s\n"), MONDO_LOGFILE); 336 if (does_file_exist("/tmp/MA.log.gz")) {337 printf338 (_("FYI, I have gzipped the log and saved it to /tmp/MA.log.gz\n"));339 }340 334 printf(_("Mondo has aborted.\n")); 341 335 register_pid(0, "mondo"); // finish() does this too, FYI … … 357 351 finish(int signal) { 358 352 char *command = NULL; 359 360 /* if (signal==0) { popup_and_OK("Please press <enter> to quit."); } */361 362 /* newtPopHelpLine(); */363 353 364 354 register_pid(0, "mondo"); … … 371 361 } 372 362 if (g_selfmounted_isodir) { 373 asprintf(&command, "umount %s", g_selfmounted_isodir);363 mr_asprintf(&command, "umount %s", g_selfmounted_isodir); 374 364 run_program_and_log_output(command, 1); 375 asprintf(&command, "rmdir %s", g_selfmounted_isodir);365 mr_asprintf(&command, "rmdir %s", g_selfmounted_isodir); 376 366 run_program_and_log_output(command, 1); 377 paranoid_free(g_selfmounted_isodir); 378 } 379 // iamhere("foo"); 380 /* system("clear"); */ 381 // iamhere("About to call newtFinished"); 367 mr_free(g_selfmounted_isodir); 368 } 382 369 if (!g_text_mode) { 383 370 if (does_file_exist("/THIS-IS-A-RAMDISK")) { … … 389 376 } 390 377 } 391 // system("clear");392 // iamhere("Finished calling newtFinished");393 378 printf(_("Execution run ended; result=%d\n"), signal); 394 379 printf(_("Type 'less %s' to see the output log\n"), MONDO_LOGFILE); … … 428 413 } 429 414 if (grep_for_me[0] != '\0') { 430 asprintf(&command, "grep '%s' %s | tail -n%d",415 mr_asprintf(&command, "grep '%s' %s | tail -n%d", 431 416 grep_for_me, filename, g_noof_log_lines); 432 417 } else { 433 asprintf(&command, "tail -n%d %s", g_noof_log_lines, filename);418 mr_asprintf(&command, "tail -n%d %s", g_noof_log_lines, filename); 434 419 } 435 420 fin = popen(command, "r"); … … 440 425 for (; 441 426 strlen(err_log_lines[i]) < 2 && !feof(fin);) { 442 getline(&(err_log_lines[i]), &n, fin);427 mr_getline(&(err_log_lines[i]), &n, fin); 443 428 strip_spaces(err_log_lines[i]); 444 429 if (!strncmp(err_log_lines[i], "root:", 5)) { 445 asprintf(&tmp, "%s", err_log_lines[i] + 6);446 paranoid_free(err_log_lines[i]);430 mr_asprintf(&tmp, "%s", err_log_lines[i] + 6); 431 mr_free(err_log_lines[i]); 447 432 err_log_lines[i] = tmp; 448 433 } … … 455 440 } 456 441 refresh_log_screen(); 457 paranoid_free(command);442 mr_free(command); 458 443 } 459 444 … … 477 462 478 463 va_start(args, fmt); 479 vasprintf(&output, fmt, args);464 mr_vasprintf(&output, fmt, args); 480 465 log_msg(0, output); 481 466 if (strlen(output) > 80) { … … 489 474 490 475 if (err_log_lines) { 491 paranoid_free(err_log_lines[0]);476 mr_free(err_log_lines[0]); 492 477 for (i = 1; i < g_noof_log_lines; i++) { 493 478 err_log_lines[i - 1] = err_log_lines[i]; … … 549 534 550 535 assert(ttl != NULL); 551 asprintf(&title, ttl);536 mr_asprintf(&title, ttl); 552 537 // BERLIOS: We need to unallocate it somewhere 553 asprintf(&g_isoform_header_str, title);538 mr_asprintf(&g_isoform_header_str, title); 554 539 // center_string (title, 80); 555 540 if (g_text_mode) { 556 541 log_msg(0, title); 557 542 } else { 558 asprintf(&tmp, title);543 mr_asprintf(&tmp, title); 559 544 /* BERLIOS: center_string is now broken replace it ! */ 560 545 //center_string(tmp, 80); 561 546 newtPushHelpLine(tmp); 562 paranoid_free(tmp);547 mr_free(tmp); 563 548 } 564 549 /* BERLIOS: center_string is now broken replace it ! */ … … 581 566 } 582 567 update_evalcall_form(0); 583 paranoid_free(title);568 mr_free(title); 584 569 } 585 570 … … 613 598 assert(b3 != NULL); 614 599 615 asprintf(&blurb1, b1);616 asprintf(&blurb2, b2);617 asprintf(&blurb3, b3);618 asprintf(&b1c, b1);600 mr_asprintf(&blurb1, b1); 601 mr_asprintf(&blurb2, b2); 602 mr_asprintf(&blurb3, b3); 603 mr_asprintf(&b1c, b1); 619 604 /* BERLIOS: center_string is now broken replace it ! */ 620 605 //center_string(b1c, 80); … … 627 612 g_current_progress = 0; 628 613 // BERLIOS: We need to unallocate them 629 asprintf(&g_blurb_str_1, blurb1);630 asprintf(&g_blurb_str_2, blurb3);631 asprintf(&g_blurb_str_3, blurb2);614 mr_asprintf(&g_blurb_str_1, blurb1); 615 mr_asprintf(&g_blurb_str_2, blurb3); 616 mr_asprintf(&g_blurb_str_3, blurb2); 632 617 if (g_text_mode) { 633 618 log_msg(0, blurb1); … … 651 636 } 652 637 update_progress_form_full(blurb1, blurb2, blurb3); 653 paranoid_free(b1c);654 paranoid_free(blurb1);655 paranoid_free(blurb2);656 paranoid_free(blurb3);638 mr_free(b1c); 639 mr_free(blurb1); 640 mr_free(blurb2); 641 mr_free(blurb3); 657 642 } 658 643 … … 710 695 ("---promptstring---1--- %s\r\n---promptstring---2--- %s\r\n---promptstring---Q---\r\n--> ", 711 696 title, b); 712 paranoid_free(output);713 (void)getline(&output, &n, stdin);697 mr_free(output); 698 mr_getline(&output, &n, stdin); 714 699 if (output[strlen(output) - 1] == '\n') 715 700 output[strlen(output) - 1] = '\0'; 716 701 return (ret); 717 702 } 718 asprintf(&blurb, b);703 mr_asprintf(&blurb, b); 719 704 text = newtTextboxReflowed(2, 1, blurb, 48, 5, 5, 0); 720 705 … … 732 717 //center_string(blurb, 80); 733 718 newtPushHelpLine(blurb); 734 paranoid_free(blurb);719 mr_free(blurb); 735 720 736 721 b_res = newtRunForm(myForm); … … 741 726 // Copy entry_value before destroying the form 742 727 // clearing potentially output before 743 paranoid_alloc(output,*entry_value);728 mr_allocstr(output,*entry_value); 744 729 } 745 730 newtFormDestroy(myForm); … … 779 764 printf("%s (%s or %s) --> ", p, button1, button2); 780 765 } 781 for ( asprintf(&tmp, " ");766 for (mr_asprintf(&tmp, " "); 782 767 strcmp(tmp, button1) && (strlen(button2) == 0 783 768 || strcmp(tmp, button2));) { 784 769 printf("--> "); 785 paranoid_free(tmp);786 (void)getline(&tmp, &n, stdin);770 mr_free(tmp); 771 mr_getline(&tmp, &n, stdin); 787 772 } 788 773 if (!strcmp(tmp, button1)) { 789 paranoid_free(tmp);774 mr_free(tmp); 790 775 return (TRUE); 791 776 } else { 792 paranoid_free(tmp);777 mr_free(tmp); 793 778 return (FALSE); 794 779 } 795 780 } 796 781 797 asprintf(&prompt, p);782 mr_asprintf(&prompt, p); 798 783 text = newtTextboxReflowed(1, 1, prompt, 40, 5, 5, 0); 799 784 b_1 = … … 816 801 //center_string(prompt, 80); 817 802 newtPushHelpLine(prompt); 818 paranoid_free(prompt);803 mr_free(prompt); 819 804 b_res = newtRunForm(myForm); 820 805 newtPopHelpLine(); … … 943 928 || percentage > g_isoform_old_progress) { 944 929 g_isoform_old_progress = percentage; 945 asprintf(&timeline_str,930 mr_asprintf(&timeline_str, 946 931 _("%2ld:%02ld taken %2ld:%02ld remaining"), 947 932 time_taken / 60, time_taken % 60, time_remaining / 60, … … 968 953 *p = '\0'; 969 954 970 asprintf(&pcline_str, " Working%s%s %c", tmp1, tmp2,955 mr_asprintf(&pcline_str, " Working%s%s %c", tmp1, tmp2, 971 956 special_dot_char(g_mysterious_dot_counter)); 972 paranoid_free(tmp1);973 paranoid_free(tmp2);957 mr_free(tmp1); 958 mr_free(tmp2); 974 959 } else { 975 asprintf(&pcline_str,960 mr_asprintf(&pcline_str, 976 961 _(" %3d%% done %3d%% to go"), 977 962 percentage, 100 - percentage); … … 992 977 993 978 if (percentage >= 3) { 994 asprintf(&taskprogress,979 mr_asprintf(&taskprogress, 995 980 "TASK: [%s%s] %3d%% done; %2ld:%02ld to go", 996 981 tmp1, tmp2, percentage, time_remaining / 60, … … 1000 985 printf("---evalcall---2--- %s\r\n", taskprogress); 1001 986 printf("---evalcall---E---\r\n"); 1002 paranoid_free(taskprogress);987 mr_free(taskprogress); 1003 988 } 1004 989 } else { … … 1010 995 } 1011 996 } 1012 paranoid_free(timeline_str);1013 paranoid_free(pcline_str);997 mr_free(timeline_str); 998 mr_free(pcline_str); 1014 999 } 1015 1000 if (!g_text_mode) { … … 1032 1017 return; 1033 1018 } 1034 paranoid_free(g_blurb_str_2);1035 asprintf(&g_blurb_str_2, blurb3);1019 mr_free(g_blurb_str_2); 1020 mr_asprintf(&g_blurb_str_2, blurb3); 1036 1021 update_progress_form_full(g_blurb_str_1, g_blurb_str_2, 1037 1022 g_blurb_str_3); … … 1081 1066 } else { 1082 1067 if (g_current_progress > g_maximum_progress) { 1083 asprintf(&tmp,1068 mr_asprintf(&tmp, 1084 1069 "update_progress_form_full(%s,%s,%s) --- g_current_progress=%ld; g_maximum_progress=%ld", 1085 1070 blurb1, blurb2, blurb3, g_current_progress, 1086 1071 g_maximum_progress); 1087 1072 log_msg(0, tmp); 1088 paranoid_free(tmp);1073 mr_free(tmp); 1089 1074 g_current_progress = g_maximum_progress; 1090 1075 } … … 1108 1093 /* BERLIOS/ Is it useful here ? */ 1109 1094 //g_mysterious_dot_counter = (g_mysterious_dot_counter + 1) % 27; 1110 asprintf(&timeline_str,1095 mr_asprintf(&timeline_str, 1111 1096 "%2ld:%02ld taken %2ld:%02ld remaining ", 1112 1097 time_taken / 60, time_taken % 60, time_remaining / 60, 1113 1098 time_remaining % 60); 1114 asprintf(&percentline_str,1099 mr_asprintf(&percentline_str, 1115 1100 " %3d%% done %3d%% to go", percentage, 1116 1101 100 - percentage); … … 1138 1123 log_msg(2, _("percentage = %d"), percentage); 1139 1124 } 1140 asprintf(&taskprogress,1125 mr_asprintf(&taskprogress, 1141 1126 _("TASK: [%s%s] %3d%% done; %2ld:%02ld to go"), tmp1, 1142 1127 tmp2, percentage, time_remaining / 60, … … 1144 1129 1145 1130 printf(_("---progress-form---4--- %s\r\n"), taskprogress); 1146 paranoid_free(taskprogress);1131 mr_free(taskprogress); 1147 1132 } else { 1148 1133 /* BERLIOS: center_string is now broken replace it ! */ … … 1162 1147 newtRefresh(); 1163 1148 } 1164 paranoid_free(percentline_str);1165 paranoid_free(timeline_str);1149 mr_free(percentline_str); 1150 mr_free(timeline_str); 1166 1151 } 1167 1152 … … 1214 1199 } 1215 1200 printf(")\n--> "); 1216 (void)getline(&outstr, &n, stdin);1201 mr_getline(&outstr, &n, stdin); 1217 1202 strip_spaces(outstr); 1218 1203 for (i = 0; possible_responses[i]; i++) { … … 1222 1207 } 1223 1208 } 1224 paranoid_free(outstr);1209 mr_free(outstr); 1225 1210 return (backup_type); 1226 1211 } 1227 1212 newtDrawRootText(18, 0, WELCOME_STRING); 1228 1213 if (restoring) { 1229 asprintf(&title_sz,1214 mr_asprintf(&title_sz, 1230 1215 _("Please choose the backup media from which you want to read data.")); 1231 asprintf(&minimsg_sz, _("Read from:"));1232 } else { 1233 asprintf(&title_sz,1216 mr_asprintf(&minimsg_sz, _("Read from:")); 1217 } else { 1218 mr_asprintf(&title_sz, 1234 1219 _("Please choose the backup media to which you want to archive data.")); 1235 asprintf(&minimsg_sz, _("Backup to:"));1220 mr_asprintf(&minimsg_sz, _("Backup to:")); 1236 1221 } 1237 1222 newtPushHelpLine(title_sz); 1238 paranoid_free(title_sz);1223 mr_free(title_sz); 1239 1224 1240 1225 // newtOpenWindow (23, 3, 34, 17, minimsg_sz); 1241 1226 newtCenteredWindow(34, 17, minimsg_sz); 1242 paranoid_free(minimsg_sz);1227 mr_free(minimsg_sz); 1243 1228 1244 1229 b1 = newtButton(1, 1, _("CD-R disks ")); … … 1363 1348 break; 1364 1349 } 1365 (void)getline(&tmp, &n, fin);1350 mr_getline(&tmp, &n, fin); 1366 1351 i = (int) strlen(tmp); 1367 1352 if (i < 2) { … … 1385 1370 filelist->el[filelist->entries].severity = 1386 1371 severity_of_difference(tmp, reason); 1387 paranoid_free(reason);1372 mr_free(reason); 1388 1373 strcpy(filelist->el[filelist->entries].filename, tmp); 1389 1374 if (feof(fin)) { … … 1394 1379 if (filelist->entries >= ARBITRARY_MAXIMUM) { 1395 1380 log_to_screen(_("Arbitrary limits suck, man!")); 1396 paranoid_free(tmp);1381 mr_free(tmp); 1397 1382 return (1); 1398 1383 } 1399 paranoid_free(tmp);1384 mr_free(tmp); 1400 1385 1401 1386 for (done = FALSE; !done;) { … … 1442 1427 assert(flentry != NULL); 1443 1428 if (flentry->severity == 0) { 1444 asprintf(&comment, "0 %93s", flentry->filename);1429 mr_asprintf(&comment, "0 %93s", flentry->filename); 1445 1430 } else if (flentry->severity == 1) { 1446 asprintf(&comment, "low %93s", flentry->filename);1431 mr_asprintf(&comment, "low %93s", flentry->filename); 1447 1432 } else if (flentry->severity == 2) { 1448 asprintf(&comment, "med %93s", flentry->filename);1449 } else { 1450 asprintf(&comment, "high %93s", flentry->filename);1433 mr_asprintf(&comment, "med %93s", flentry->filename); 1434 } else { 1435 mr_asprintf(&comment, "high %93s", flentry->filename); 1451 1436 } 1452 1437 iamhere("leaving"); … … 1525 1510 keylist[i]); 1526 1511 } 1527 asprintf(&differ_sz,1512 mr_asprintf(&differ_sz, 1528 1513 _(" %ld files differ. Hit 'Select' to pick a file. Hit 'Close' to quit the list."), 1529 1514 i); 1530 1515 newtPushHelpLine(differ_sz); 1531 paranoid_free(differ_sz);1516 mr_free(differ_sz); 1532 1517 1533 1518 bClose = newtCompactButton(10, 15, _(" Close ")); 1534 1519 bSelect = newtCompactButton(30, 15, _(" Select ")); 1535 asprintf(&tmp, "%-10s %-20s", _("Priority"),1520 mr_asprintf(&tmp, "%-10s %-20s", _("Priority"), 1536 1521 _("Filename")); 1537 1522 headerMsg = newtLabel(2, 1, tmp); 1538 paranoid_free(tmp);1523 mr_free(tmp); 1539 1524 1540 1525 newtOpenWindow(5, 4, 70, 16, _("Non-matching files")); … … 1558 1543 severity_of_difference(filelist->el[currline]. 1559 1544 filename, reason); 1560 asprintf(&tmp, "%s --- %s",1545 mr_asprintf(&tmp, "%s --- %s", 1561 1546 filelist->el[currline].filename, reason); 1562 1547 popup_and_OK(tmp); 1563 paranoid_free(tmp);1564 paranoid_free(reason);1548 mr_free(tmp); 1549 mr_free(reason); 1565 1550 } 1566 1551 } -
trunk/mondo/src/include/mr_str.h
r895 r900 1 /* mr_string.h 2 * 1 /* 3 2 * $Id$ 4 3 * 5 * Header file of mr_str ing: a set of function manipulating strings4 * Header file of mr_str.c: a set of function manipulating strings 6 5 * Provided under the GPL v2 7 6 */ 8 7 9 #ifndef MR_STR ING_H10 #define MR_STR ING_H8 #ifndef MR_STR_H 9 #define MR_STR_H 11 10 12 11 /* functions (public methods) */ … … 15 14 extern char *mr_stresc(char *instr, char *toesc, const char escchr); 16 15 17 #endif /* MR_STR ING_H */16 #endif /* MR_STR_H */ -
trunk/mondo/src/include/my-stuff.h
r849 r900 294 294 */ 295 295 #define paranoid_system(x) {if(system(x)) log_msg(4, x); } 296 297 /**298 * Free @p x and set it to NULL.299 */300 #define paranoid_free(x) {if ((x) != NULL) free(x); (x)=NULL;}301 296 302 297 /** -
trunk/mondo/src/lib/Makefile.am
r826 r900 7 7 noinst_LIBRARIES = libmr.a 8 8 9 libmr_a_SOURCES = mr_conf.c mr_str ing.c9 libmr_a_SOURCES = mr_conf.c mr_str.c mr_mem.c mr_err.c mr_msg.c -
trunk/mondo/src/lib/mr_conf.c
r852 r900 17 17 #include <string.h> 18 18 19 #include "my-stuff.h" 20 21 /* BERLIOS: instead of this declaration, we need a good include structure */ 22 extern void (*log_debug_msg) (int debug_level, const char *szFile, 23 const char *szFunction, int nLine, 24 const char *fmt, ...); 19 #include "mr_msg.h" 20 #include "mr_mem.h" 21 #include "mr_gettext.h" 25 22 26 23 /* error flags */ … … 79 76 static FILE *CONF = NULL; /* Configuration file FD */ 80 77 81 /*if output all error and warnin messages*/78 /*if output all error and warning messages*/ 82 79 static int mr_conf_flags = MRCONF_FLAG_VERBOSE; 83 80 … … 95 92 int mr_conf_open(const char *filename) { 96 93 size_t length; /*length of the buffer/file */ 94 size_t res = 0; 97 95 98 96 /* check if mr_conf is already opened? */ … … 126 124 /*reading file in buffer (skip all 0 characters) */ 127 125 128 (void)fread(buffer, sizeof(char), length, CONF);126 res = fread(buffer, sizeof(char), length, CONF); 129 127 buffer[length] = (char) 0; /*finalize the string */ 130 128 … … 146 144 mr_conf_error_msg(MRCONF_CLOSE_BUT_NOT_OPEN, NULL); 147 145 } 148 paranoid_free(buffer);146 mr_free(buffer); 149 147 fclose(CONF); 150 148 … … 215 213 /* 216 214 reads string outstr after string str in the current file (between 217 "..."), not more than maxlength s imbols: cannot check if outstr has215 "..."), not more than maxlength symbols: cannot check if outstr has 218 216 enough length! It must be at least maxlength+1 ! Returns number of 219 217 read chars … … 233 231 return(p); 234 232 } 235 asprintf(&q, p);233 mr_asprintf(&q, p); 236 234 237 235 /* trunk at first \n */ … … 252 250 253 251 ret[i] = (char) 0; /*and set its length */ 254 paranoid_free(q);252 mr_free(q); 255 253 256 254 return ret; … … 299 297 tmp_buf[k] = (char) 0; /*and set its length */ 300 298 301 paranoid_free(buffer);299 mr_free(buffer); 302 300 /*copy filtered data to the buffer */ 303 301 buffer = tmp_buf; … … 339 337 switch (error_code) { 340 338 case MRCONF_BAD_FILE: 341 log_msg(4,"%s %s %s\n", MRCONF_STR_ERROR, MRCONF_STR_BAD_FILE,339 mr_msg(0,"%s %s %s\n", MRCONF_STR_ERROR, MRCONF_STR_BAD_FILE, 342 340 add_line); 343 341 break; 344 342 345 343 case MRCONF_ALLOC_FAILED: 346 log_msg(4,"%s %s\n", MRCONF_STR_ERROR, MRCONF_STR_ALLOC_FAILED);344 mr_msg(0,"%s %s\n", MRCONF_STR_ERROR, MRCONF_STR_ALLOC_FAILED); 347 345 break; 348 346 349 347 case MRCONF_READING_FAILED: 350 log_msg(4,"%s %s\n", MRCONF_STR_ERROR, MRCONF_STR_READING_FAILED);348 mr_msg(0,"%s %s\n", MRCONF_STR_ERROR, MRCONF_STR_READING_FAILED); 351 349 break; 352 350 353 351 case MRCONF_FIELD_NOT_FOUND: 354 log_msg(4, "%s %s \"%s\"\n", MRCONF_STR_ERROR, 355 MRCONF_STR_FIELD_NOT_FOUND, add_line); 356 log_msg(4, "%s %s\n", MRCONF_STR_WARNING, MRCONF_STR_SET_TO_ZERO); 352 mr_msg(1,"%s %s \"%s\"\n", MRCONF_STR_ERROR, MRCONF_STR_FIELD_NOT_FOUND, add_line); 353 mr_msg(1,"%s %s\n", MRCONF_STR_WARNING, MRCONF_STR_SET_TO_ZERO); 357 354 break; 358 355 359 356 case MRCONF_FIELD_NO_VALUE: 360 log_msg(4, "%s %s \"%s\"\n", MRCONF_STR_ERROR, 361 MRCONF_STR_FIELD_NO_VALUE, add_line); 362 log_msg(4, "%s %s\n", MRCONF_STR_WARNING, MRCONF_STR_IGNORE); 357 mr_msg(1,"%s %s \"%s\"\n", MRCONF_STR_ERROR, MRCONF_STR_FIELD_NO_VALUE, add_line); 358 mr_msg(1,"%s %s\n", MRCONF_STR_WARNING, MRCONF_STR_IGNORE); 363 359 break; 364 360 365 361 case MRCONF_CLOSE_BUT_NOT_OPEN: 366 log_msg(4, "%s %s\n", MRCONF_STR_WARNING, 367 MRCONF_STR_CLOSE_BUT_NOT_OPEN); 362 mr_msg(0,"%s %s\n", MRCONF_STR_WARNING, MRCONF_STR_CLOSE_BUT_NOT_OPEN); 368 363 break; 369 364 370 365 case MRCONF_CALL_BUT_NOT_OPEN: 371 log_msg(4, "%s %s\n", MRCONF_STR_WARNING, 372 MRCONF_STR_CALL_BUT_NOT_OPEN); 366 mr_msg(0,"%s %s\n", MRCONF_STR_WARNING, MRCONF_STR_CALL_BUT_NOT_OPEN); 373 367 break; 374 368 375 369 case MRCONF_OPEN_OPENED: 376 log_msg(4,"%s %s\n", MRCONF_STR_ERROR, MRCONF_STR_OPEN_OPENED);370 mr_msg(0,"%s %s\n", MRCONF_STR_ERROR, MRCONF_STR_OPEN_OPENED); 377 371 break; 378 372 379 373 default: 380 log_msg(4,"%s %s\n", MRCONF_STR_ERROR, MRCONF_STR_DEFAULT_ERROR);381 break; 382 } 383 } 384 } 374 mr_msg(1,"%s %s\n", MRCONF_STR_ERROR, MRCONF_STR_DEFAULT_ERROR); 375 break; 376 } 377 } 378 } -
trunk/mondo/src/mondoarchive/Makefile.am
r867 r900 1 ## $Id$ 1 2 ## 2 3 ## Process with Automake to generate Makefile.in -
trunk/mondo/src/mondoarchive/main.c
r815 r900 21 21 #include "../common/libmondo.h" 22 22 #include "mondo-cli-EXT.h" 23 24 #include "mr_mem.h" 23 25 24 26 // for CVS … … 185 187 186 188 /* make sure PATH environmental variable allows access to mkfs, fdisk, etc. */ 187 asprintf(&tmp, "/sbin:/usr/sbin:%s:/usr/local/sbin", getenv("PATH"));189 mr_asprintf(&tmp, "/sbin:/usr/sbin:%s:/usr/local/sbin", getenv("PATH")); 188 190 setenv("PATH", tmp, 1); 189 paranoid_free(tmp);191 mr_free(tmp); 190 192 191 193 /* Add the ARCH environment variable for ia64 purposes */ … … 236 238 turn_wildcard_chars_into_literal_chars(tmp, argv[2]); 237 239 printf("in=%s; out=%s\n", argv[2], tmp); 238 paranoid_free(tmp);240 mr_free(tmp); 239 241 finish(1); 240 242 } … … 268 270 printf(_("CD-RW is at %s\n"), tmp); 269 271 } 270 paranoid_free(tmp);272 mr_free(tmp); 271 273 272 274 if ((tmp = find_cdrom_device(FALSE)) == NULL) { … … 275 277 printf(_("CD-ROM is at %s\n"), tmp); 276 278 } 277 paranoid_free(tmp);279 mr_free(tmp); 278 280 finish(0); 279 281 } … … 288 290 printf(_("DVD is at %s\n"), tmp); 289 291 } 290 paranoid_free(tmp);292 mr_free(tmp); 291 293 finish(0); 292 294 } … … 345 347 retval += res; 346 348 if (res) { 347 asprintf(&say_at_end,349 mr_asprintf(&say_at_end, 348 350 _("Data archived. Please check the logs, just as a precaution. ")); 349 351 } else { 350 asprintf(&say_at_end, _("Data archived OK. "));352 mr_asprintf(&say_at_end, _("Data archived OK. ")); 351 353 } 352 354 } … … 356 358 res = verify_data(bkpinfo); 357 359 if (res < 0) { 358 asprintf(&say_at_end, _("%d difference%c found."), -res,360 mr_asprintf(&say_at_end, _("%d difference%c found."), -res, 359 361 (-res != 1) ? 's' : ' '); 360 362 res = 0; … … 399 401 } 400 402 log_to_screen(say_at_end); 401 paranoid_free(say_at_end);402 403 asprintf(&tmp, "umount %s/tmpfs", bkpinfo->tmpdir);403 mr_free(say_at_end); 404 405 mr_asprintf(&tmp, "umount %s/tmpfs", bkpinfo->tmpdir); 404 406 run_program_and_log_output(tmp, TRUE); 405 paranoid_free(tmp);406 407 asprintf(&g_erase_tmpdir_and_scratchdir, "rm -Rf %s %s", bkpinfo->tmpdir,407 mr_free(tmp); 408 409 mr_asprintf(&g_erase_tmpdir_and_scratchdir, "rm -Rf %s %s", bkpinfo->tmpdir, 408 410 bkpinfo->scratchdir); 409 411 run_program_and_log_output(g_erase_tmpdir_and_scratchdir, TRUE); … … 424 426 system(g_erase_tmpdir_and_scratchdir); 425 427 free_libmondo_global_strings(); 426 paranoid_free(bkpinfo);428 mr_free((void *)bkpinfo); 427 429 428 430 unlink("/tmp/filelist.full"); -
trunk/mondo/src/mondoarchive/mondo-cli.c
r815 r900 14 14 #include <pthread.h> 15 15 #endif 16 #include "mr_mem.h" 16 17 17 18 extern int g_loglevel; … … 82 83 for (i = 0; i < 128; i++) { 83 84 if (flag_set[i]) { 84 asprintf(&tmp, "-%c %s", i, flag_val[i]);85 mr_asprintf(&tmp, "-%c %s", i, flag_val[i]); 85 86 log_msg(3, tmp); 86 paranoid_free(tmp);87 mr_free(tmp); 87 88 } 88 89 } 89 90 // } 90 asprintf(&tmp, "rm -Rf %s/mondo.tmp.*", bkpinfo->tmpdir);91 mr_asprintf(&tmp, "rm -Rf %s/mondo.tmp.*", bkpinfo->tmpdir); 91 92 paranoid_system(tmp); 92 paranoid_free(tmp);93 94 asprintf(&tmp, "rm -Rf %s/mondo.scratch.*", bkpinfo->scratchdir);93 mr_free(tmp); 94 95 mr_asprintf(&tmp, "rm -Rf %s/mondo.scratch.*", bkpinfo->scratchdir); 95 96 paranoid_system(tmp); 96 paranoid_free(tmp);97 mr_free(tmp); 97 98 98 99 /* BERLIOS : Useless ??? … … 103 104 */ 104 105 105 asprintf(&tmp, "mkdir -p %s/tmpfs", bkpinfo->tmpdir);106 mr_asprintf(&tmp, "mkdir -p %s/tmpfs", bkpinfo->tmpdir); 106 107 paranoid_system(tmp); 107 paranoid_free(tmp);108 109 asprintf(&tmp, "mkdir -p %s", bkpinfo->scratchdir);108 mr_free(tmp); 109 110 mr_asprintf(&tmp, "mkdir -p %s", bkpinfo->scratchdir); 110 111 paranoid_system(tmp); 111 paranoid_free(tmp);112 mr_free(tmp); 112 113 113 114 if (bkpinfo->nfs_mount != NULL) { … … 139 140 for (j = 1, p = value; j < MAX_NOOF_MEDIA && strchr(p, ','); 140 141 j++, p = strchr(p, ',') + 1) { 141 asprintf(&tmp, p);142 mr_asprintf(&tmp, p); 142 143 q = strchr(tmp, ','); 143 144 if (q != NULL) { … … 145 146 } 146 147 bkpinfo->media_size[j] = friendly_sizestr_to_sizelong(tmp); 147 paranoid_free(tmp);148 149 asprintf(&comment, "media_size[%d] = %ld", j,148 mr_free(tmp); 149 150 mr_asprintf(&comment, "media_size[%d] = %ld", j, 150 151 bkpinfo->media_size[j]); 151 152 log_msg(3, comment); 152 paranoid_free(comment);153 mr_free(comment); 153 154 } 154 155 for (; j <= MAX_NOOF_MEDIA; j++) { … … 245 246 } 246 247 } 247 paranoid_free(tmp);248 mr_free(tmp); 248 249 249 250 if (flag_set['R']) { … … 257 258 } 258 259 } 259 paranoid_free(tmp1);260 mr_free(tmp1); 260 261 261 262 if (flag_set['W']) { … … 276 277 bkpinfo->include_paths = NULL; 277 278 } 278 asprintf(&tmp1, flag_val['I']);279 mr_asprintf(&tmp1, flag_val['I']); 279 280 p = tmp1; 280 281 q = tmp1; … … 298 299 } 299 300 } 300 paranoid_free(tmp1);301 mr_free(tmp1); 301 302 302 303 if (bkpinfo->include_paths == NULL) { 303 asprintf(&tmp1, "%s", flag_val['I']);304 mr_asprintf(&tmp1, "%s", flag_val['I']); 304 305 } else { 305 asprintf(&tmp1, "%s %s", bkpinfo->include_paths, flag_val['I']);306 } 307 paranoid_alloc(bkpinfo->include_paths,tmp1);308 paranoid_free(tmp1);306 mr_asprintf(&tmp1, "%s %s", bkpinfo->include_paths, flag_val['I']); 307 } 308 mr_allocstr(bkpinfo->include_paths,tmp1); 309 mr_free(tmp1); 309 310 310 311 log_msg(1, "include_paths is now '%s'", bkpinfo->include_paths); … … 328 329 } 329 330 bkpinfo->make_filelist = FALSE; 330 paranoid_alloc(bkpinfo->include_paths, flag_val['J']);331 mr_allocstr(bkpinfo->include_paths, flag_val['J']); 331 332 } 332 333 … … 384 385 } 385 386 flag_set['d'] = TRUE; 386 paranoid_free(tmp); // allocation from find_tape_device_and_size387 388 asprintf(&tmp,387 mr_free(tmp); // allocation from find_tape_device_and_size 388 389 mr_asprintf(&tmp, 389 390 _("You didn't specify a tape streamer device. I'm assuming %s"), 390 391 flag_val['d']); 391 392 log_to_screen(tmp); 392 paranoid_free(tmp);393 mr_free(tmp); 393 394 percent = 0; 394 395 } … … 412 413 } 413 414 if (!flag_set['s']) { 414 asprintf(&flag_val['s'], "%dm", DEFAULT_DVD_DISK_SIZE); // 4.7 salesman's GB = 4.482 real GB = 4582 MB415 mr_asprintf(&flag_val['s'], "%dm", DEFAULT_DVD_DISK_SIZE); // 4.7 salesman's GB = 4.482 real GB = 4582 MB 415 416 log_to_screen 416 417 (_("You did not specify a size (-s) for DVD. I'm guessing %s."), … … 454 455 } 455 456 if (flag_set['n']) { 456 paranoid_alloc(bkpinfo->nfs_mount,flag_val['n']);457 mr_allocstr(bkpinfo->nfs_mount,flag_val['n']); 457 458 if (!flag_set['d']) { 458 paranoid_alloc(bkpinfo->nfs_remote_dir,"/");459 } 460 asprintf(&tmp, "mount | grep -x \"%s .*\" | cut -d' ' -f3",459 mr_allocstr(bkpinfo->nfs_remote_dir,"/"); 460 } 461 mr_asprintf(&tmp, "mount | grep -x \"%s .*\" | cut -d' ' -f3", 461 462 bkpinfo->nfs_mount); 462 paranoid_free(bkpinfo->isodir);463 mr_free(bkpinfo->isodir); 463 464 bkpinfo->isodir = call_program_and_get_last_line_of_output(tmp); 464 paranoid_free(tmp);465 mr_free(tmp); 465 466 466 467 if (strlen(bkpinfo->isodir) < 3) { … … 503 504 504 505 if (flag_set['E']) { 505 asprintf(&tmp1, flag_val['E']);506 mr_asprintf(&tmp1, flag_val['E']); 506 507 p = tmp1; 507 508 q = tmp1; … … 531 532 } 532 533 } 533 paranoid_free(tmp1);534 mr_free(tmp1); 534 535 535 536 if (bkpinfo->exclude_paths == NULL) { 536 asprintf(&tmp1, "%s", flag_val['E']);537 mr_asprintf(&tmp1, "%s", flag_val['E']); 537 538 } else { 538 asprintf(&tmp1, "%s %s", bkpinfo->exclude_paths, flag_val['E']);539 } 540 paranoid_alloc(bkpinfo->exclude_paths,tmp1);541 paranoid_free(tmp1);539 mr_asprintf(&tmp1, "%s %s", bkpinfo->exclude_paths, flag_val['E']); 540 } 541 mr_allocstr(bkpinfo->exclude_paths,tmp1); 542 mr_free(tmp1); 542 543 } 543 544 … … 550 551 psz = list_of_NFS_mounts_only(); 551 552 if (bkpinfo->exclude_paths != NULL) { 552 asprintf(&tmp1, "%s %s", bkpinfo->exclude_paths, psz);553 mr_asprintf(&tmp1, "%s %s", bkpinfo->exclude_paths, psz); 553 554 } else { 554 asprintf(&tmp1, "%s", psz);555 } 556 paranoid_free(psz);557 paranoid_alloc(bkpinfo->exclude_paths, tmp1);558 paranoid_free(tmp1);555 mr_asprintf(&tmp1, "%s", psz); 556 } 557 mr_free(psz); 558 mr_allocstr(bkpinfo->exclude_paths, tmp1); 559 mr_free(tmp1); 559 560 560 561 log_msg(3, "-N means we're now excluding %s", … … 563 564 564 565 if (flag_set['b']) { 565 asprintf(&psz, flag_val['b']);566 mr_asprintf(&psz, flag_val['b']); 566 567 log_msg(1, "psz = '%s'", psz); 567 568 if (psz[strlen(psz) - 1] == 'k') { … … 571 572 itbs = atol(psz); 572 573 } 573 paranoid_free(psz);574 mr_free(psz); 574 575 575 576 log_msg(1, "'%s' --> %ld", flag_val['b'], itbs); … … 592 593 593 594 if (flag_set['x']) { 594 paranoid_alloc(bkpinfo->image_devs,flag_val['x']);595 mr_allocstr(bkpinfo->image_devs,flag_val['x']); 595 596 if (run_program_and_log_output("which ntfsclone", 2)) { 596 597 fatal_error("Please install ntfsprogs package/tarball."); … … 604 605 if (flag_set['k']) { 605 606 if (strcasecmp(flag_val['k'], "FAILSAFE")) { 606 paranoid_alloc(bkpinfo->kernel_path,"FAILSAFE");607 mr_allocstr(bkpinfo->kernel_path,"FAILSAFE"); 607 608 608 609 if (!does_file_exist(bkpinfo->kernel_path)) { 609 610 retval++; 610 asprintf(&tmp,611 mr_asprintf(&tmp, 611 612 _("You specified kernel '%s', which does not exist\n"), 612 613 bkpinfo->kernel_path); 613 614 log_to_screen(tmp); 614 paranoid_free(tmp);615 mr_free(tmp); 615 616 } 616 617 } else { 617 paranoid_alloc(bkpinfo->kernel_path,flag_val['k']);618 mr_allocstr(bkpinfo->kernel_path,flag_val['k']); 618 619 } 619 620 } 620 621 621 622 if (flag_set['p']) { 622 paranoid_alloc(bkpinfo->prefix,flag_val['p']);623 mr_allocstr(bkpinfo->prefix,flag_val['p']); 623 624 } 624 625 625 626 if (flag_set['d']) { /* backup directory (if ISO/NFS) */ 626 627 if (flag_set['i']) { 627 paranoid_alloc(bkpinfo->isodir,flag_val['d']);628 asprintf(&tmp, "ls -l %s", bkpinfo->isodir);628 mr_allocstr(bkpinfo->isodir,flag_val['d']); 629 mr_asprintf(&tmp, "ls -l %s", bkpinfo->isodir); 629 630 if (run_program_and_log_output(tmp, FALSE)) { 630 631 fatal_error 631 632 ("output folder does not exist - please create it"); 632 633 } 633 paranoid_free(tmp);634 mr_free(tmp); 634 635 } else if (flag_set['n']) { 635 paranoid_alloc(bkpinfo->nfs_remote_dir,flag_val['d']);636 mr_allocstr(bkpinfo->nfs_remote_dir,flag_val['d']); 636 637 } else { /* backup device (if tape/CD-R/CD-RW) */ 637 638 638 paranoid_alloc(bkpinfo->media_device, flag_val['d']);639 mr_allocstr(bkpinfo->media_device, flag_val['d']); 639 640 } 640 641 } 641 642 642 643 if (flag_set['n']) { 643 asprintf(&tmp, "echo hi > %s/%s/.dummy.txt", bkpinfo->isodir,644 mr_asprintf(&tmp, "echo hi > %s/%s/.dummy.txt", bkpinfo->isodir, 644 645 bkpinfo->nfs_remote_dir); 645 646 if (run_program_and_log_output(tmp, FALSE)) { 646 647 retval++; 647 paranoid_free(tmp);648 asprintf(&tmp,648 mr_free(tmp); 649 mr_asprintf(&tmp, 649 650 _("Are you sure directory '%s' exists in remote dir '%s'?\nIf so, do you have rights to write to it?\n"), 650 651 bkpinfo->nfs_remote_dir, bkpinfo->nfs_mount); 651 652 log_to_screen(tmp); 652 653 } 653 paranoid_free(tmp);654 mr_free(tmp); 654 655 } 655 656 … … 664 665 } 665 666 } else if ((tmp = find_cdrw_device()) == NULL) { 666 paranoid_alloc(bkpinfo->media_device, tmp);667 paranoid_free(tmp);667 mr_allocstr(bkpinfo->media_device, tmp); 668 mr_free(tmp); 668 669 retval++; 669 670 log_to_screen … … 671 672 } else { 672 673 flag_set['d'] = TRUE; 673 asprintf(&flag_val['d'], bkpinfo->media_device);674 mr_asprintf(&flag_val['d'], bkpinfo->media_device); 674 675 } 675 676 } … … 689 690 j = (int) random() % 32768; 690 691 if (flag_set['S']) { 691 asprintf(&tmp, "%s/mondo.scratch.%d", flag_val['S'], j);692 paranoid_free(bkpinfo->scratchdir);692 mr_asprintf(&tmp, "%s/mondo.scratch.%d", flag_val['S'], j); 693 mr_free(bkpinfo->scratchdir); 693 694 bkpinfo->scratchdir = tmp; 694 695 } 695 696 if (flag_set['T']) { 696 asprintf(&tmp, "%s/mondo.tmp.%d", flag_val['T'], j);697 paranoid_free(bkpinfo->tmpdir);697 mr_asprintf(&tmp, "%s/mondo.tmp.%d", flag_val['T'], j); 698 mr_free(bkpinfo->tmpdir); 698 699 bkpinfo->tmpdir = tmp; 699 asprintf(&tmp, "touch %s/.foo.dat", flag_val['T']);700 mr_asprintf(&tmp, "touch %s/.foo.dat", flag_val['T']); 700 701 if (run_program_and_log_output(tmp, 1)) { 701 702 retval++; … … 704 705 fatal_error("I cannot write to the tempdir you specified."); 705 706 } 706 paranoid_free(tmp);707 708 asprintf(&tmp, "ln -sf %s/.foo.dat %s/.bar.dat", flag_val['T'],707 mr_free(tmp); 708 709 mr_asprintf(&tmp, "ln -sf %s/.foo.dat %s/.bar.dat", flag_val['T'], 709 710 flag_val['T']); 710 711 if (run_program_and_log_output(tmp, 1)) { … … 714 715 fatal_error("I cannot write to the tempdir you specified."); 715 716 } 716 paranoid_free(tmp);717 mr_free(tmp); 717 718 } 718 719 719 720 if (flag_set['A']) { 720 paranoid_alloc(bkpinfo->call_after_iso,flag_val['A']);721 mr_allocstr(bkpinfo->call_after_iso,flag_val['A']); 721 722 } 722 723 if (flag_set['B']) { 723 paranoid_alloc(bkpinfo->call_before_iso,flag_val['B']);724 mr_allocstr(bkpinfo->call_before_iso,flag_val['B']); 724 725 } 725 726 if (flag_set['F']) { … … 753 754 if (flag_set['f']) { 754 755 tmp = resolve_softlinks_to_get_to_actual_device_file(flag_val['f']); 755 paranoid_alloc(bkpinfo->boot_device,tmp);756 mr_allocstr(bkpinfo->boot_device,tmp); 756 757 } 757 758 if (flag_set['Q']) { … … 763 764 log_msg(3, "boot loader is %c, residing at %s", i, tmp); 764 765 printf(_("boot loader is %c, residing at %s\n"), i, tmp); 765 paranoid_free(tmp);766 mr_free(tmp); 766 767 finish(0); 767 768 } 768 paranoid_free(tmp);769 mr_free(tmp); 769 770 770 771 if (flag_set['P']) { 771 paranoid_alloc(bkpinfo->postnuke_tarball,flag_val['P']);772 mr_allocstr(bkpinfo->postnuke_tarball,flag_val['P']); 772 773 } 773 774 … … 883 884 if (flag_set[optopt]) { 884 885 bad_switches = TRUE; 885 asprintf(&tmp, _("Switch -%c previously defined as %s\n"), opt,886 mr_asprintf(&tmp, _("Switch -%c previously defined as %s\n"), opt, 886 887 flag_val[i]); 887 888 log_to_screen(tmp); 888 paranoid_free(tmp);889 mr_free(tmp); 889 890 } else { 890 891 flag_set[opt] = TRUE; … … 900 901 if (strchr(flag_val[opt], '/') 901 902 && flag_val[opt][0] != '/') { 902 asprintf(&tmp,903 mr_asprintf(&tmp, 903 904 _("-%c flag --- must be absolute path --- '%s' isn't absolute"), 904 905 opt, flag_val[opt]); 905 906 log_to_screen(tmp); 906 paranoid_free(tmp);907 mr_free(tmp); 907 908 bad_switches = TRUE; 908 909 } 909 910 } 910 asprintf(&flag_val[opt], optarg);911 mr_asprintf(&flag_val[opt], optarg); 911 912 } 912 913 } … … 915 916 for (i = optind; i < argc; i++) { 916 917 bad_switches = TRUE; 917 asprintf(&tmp, _("Invalid arg -- %s\n"), argv[i]);918 mr_asprintf(&tmp, _("Invalid arg -- %s\n"), argv[i]); 918 919 log_to_screen(tmp); 919 paranoid_free(tmp);920 mr_free(tmp); 920 921 } 921 922 return (bad_switches); … … 946 947 switch (sig) { 947 948 case SIGINT: 948 asprintf(&tmp, _("SIGINT signal received from OS"));949 asprintf(&tmp2, _("You interrupted me :-)"));949 mr_asprintf(&tmp, _("SIGINT signal received from OS")); 950 mr_asprintf(&tmp2, _("You interrupted me :-)")); 950 951 break; 951 952 case SIGKILL: 952 asprintf(&tmp, _("SIGKILL signal received from OS"));953 asprintf(&tmp2,953 mr_asprintf(&tmp, _("SIGKILL signal received from OS")); 954 mr_asprintf(&tmp2, 954 955 _("I seriously have no clue how this signal even got to me. Something's wrong with your system.")); 955 956 break; 956 957 case SIGTERM: 957 asprintf(&tmp, _("SIGTERM signal received from OS"));958 asprintf(&tmp2, _("Got terminate signal"));958 mr_asprintf(&tmp, _("SIGTERM signal received from OS")); 959 mr_asprintf(&tmp2, _("Got terminate signal")); 959 960 break; 960 961 case SIGHUP: 961 asprintf(&tmp, _("SIGHUP signal received from OS"));962 asprintf(&tmp2, _("Hangup on line"));962 mr_asprintf(&tmp, _("SIGHUP signal received from OS")); 963 mr_asprintf(&tmp2, _("Hangup on line")); 963 964 break; 964 965 case SIGSEGV: 965 asprintf(&tmp, _("SIGSEGV signal received from OS"));966 asprintf(&tmp2,966 mr_asprintf(&tmp, _("SIGSEGV signal received from OS")); 967 mr_asprintf(&tmp2, 967 968 _("Internal programming error. Please send a backtrace as well as your log.")); 968 969 break; 969 970 case SIGPIPE: 970 asprintf(&tmp, _("SIGPIPE signal received from OS"));971 asprintf(&tmp2, _("Pipe was broken"));971 mr_asprintf(&tmp, _("SIGPIPE signal received from OS")); 972 mr_asprintf(&tmp2, _("Pipe was broken")); 972 973 break; 973 974 case SIGABRT: 974 asprintf(&tmp, _("SIGABRT signal received from OS"));975 asprintf(&tmp2,975 mr_asprintf(&tmp, _("SIGABRT signal received from OS")); 976 mr_asprintf(&tmp2, 976 977 _("Abort - probably failed assertion. I'm sleeping for a few seconds so you can read the message.")); 977 978 break; 978 979 default: 979 asprintf(&tmp, _("(Unknown)"));980 asprintf(&tmp2, _("(Unknown)"));980 mr_asprintf(&tmp, _("(Unknown)")); 981 mr_asprintf(&tmp2, _("(Unknown)")); 981 982 } 982 983 983 984 log_to_screen(tmp); 984 985 log_to_screen(tmp2); 985 paranoid_free(tmp);986 paranoid_free(tmp2);986 mr_free(tmp); 987 mr_free(tmp2); 987 988 if (sig == SIGABRT) { 988 989 sleep(10); -
trunk/mondo/src/mondorestore/Makefile.am
r867 r900 1 ## $Id$ 1 2 ## 2 3 ## Process with Automake to generate Makefile.in … … 14 15 mondorestore_SOURCES = mondo-prep.c mondo-restore.c mondo-rstr-newt.c \ 15 16 mondo-rstr-compare.c mondo-rstr-tools.c 16 mondorestore_LDADD = ${top_builddir}/src/common/libmondo.a ${top_builddir}/src/lib/libmr.a @MONDORESTORE_STATIC@ 17 18 17 mondorestore_LDADD = ${top_builddir}/src/common/libmondo.a ${top_builddir}/src/lib/libmr.a @MONDORESTORE_STATIC@ -
trunk/mondo/src/mondorestore/mondo-prep.c
r783 r900 19 19 #include <math.h> 20 20 #include <unistd.h> 21 #include "mr_mem.h" 21 22 22 23 … … 63 64 make_list_of_drives_in_mountlist(mountlist, drivelist); 64 65 for (lino = 0; lino < drivelist->entries; lino++) { 65 asprintf(&command,66 mr_asprintf(&command, 66 67 "dd if=%s bs=512 count=1 2> /dev/null | grep \"%s\"", 67 68 drivelist->el[lino].device, MONDO_WAS_HERE); … … 69 70 log_msg(1, "Found MONDO_WAS_HERE marker on drive#%d (%s)", 70 71 lino, drivelist->el[lino].device); 71 paranoid_free(command);72 mr_free(command); 72 73 break; 73 74 } 74 paranoid_free(command);75 mr_free(command); 75 76 } 76 77 … … 86 87 log_to_screen("Please hit 'Enter' to reboot."); 87 88 for (lino = 0; lino < drivelist->entries; lino++) { 88 asprintf(&buf, "%s\n", MONDO_WAS_HERE);89 mr_asprintf(&buf, "%s\n", MONDO_WAS_HERE); 89 90 fout = fopen(drivelist->el[lino].device, "w+"); 90 91 if (!fout) { … … 101 102 fclose(fout); 102 103 } 103 paranoid_free(buf);104 mr_free(buf); 104 105 } 105 106 sync(); … … 201 202 if (tmp) // found it :) cool 202 203 { 203 asprintf(&lvscan_sz, "lvm lvscan");204 asprintf(&lvremove_sz, "lvm lvremove");205 asprintf(&vgscan_sz, "lvm vgscan");206 asprintf(&pvscan_sz, "lvm pvscan");207 asprintf(&vgchange_sz, "lvm vgchange");208 asprintf(&vgremove_sz, "lvm vgremove");204 mr_asprintf(&lvscan_sz, "lvm lvscan"); 205 mr_asprintf(&lvremove_sz, "lvm lvremove"); 206 mr_asprintf(&vgscan_sz, "lvm vgscan"); 207 mr_asprintf(&pvscan_sz, "lvm pvscan"); 208 mr_asprintf(&vgchange_sz, "lvm vgchange"); 209 mr_asprintf(&vgremove_sz, "lvm vgremove"); 209 210 } else { 210 asprintf(&lvscan_sz, "lvscan");211 asprintf(&lvremove_sz, "lvremove");212 asprintf(&vgscan_sz, "vgscan");213 asprintf(&pvscan_sz, "pvscan");214 asprintf(&vgchange_sz, "vgchange");215 asprintf(&vgremove_sz, "vgremove");216 } 217 paranoid_free(tmp);218 219 asprintf(&command,211 mr_asprintf(&lvscan_sz, "lvscan"); 212 mr_asprintf(&lvremove_sz, "lvremove"); 213 mr_asprintf(&vgscan_sz, "vgscan"); 214 mr_asprintf(&pvscan_sz, "pvscan"); 215 mr_asprintf(&vgchange_sz, "vgchange"); 216 mr_asprintf(&vgremove_sz, "vgremove"); 217 } 218 mr_free(tmp); 219 220 mr_asprintf(&command, 220 221 "for i in `%s | cut -d\"'\" -f2 | sort -r` ; do echo \"Shutting down lv $i\" >> " 221 222 MONDO_LOGFILE "; %s -f $i; done", lvscan_sz, lvremove_sz); 222 paranoid_free(lvscan_sz);223 paranoid_free(lvremove_sz);223 mr_free(lvscan_sz); 224 mr_free(lvremove_sz); 224 225 225 226 run_program_and_log_output(command, 5); 226 paranoid_free(command);227 mr_free(command); 227 228 228 229 sleep(1); 229 asprintf(&command,230 mr_asprintf(&command, 230 231 "for i in `%s | grep -i lvm | cut -d'\"' -f2` ; do %s -a n $i ; %s $i; echo \"Shutting down vg $i\" >> " 231 232 MONDO_LOGFILE "; done", vgscan_sz, vgchange_sz, vgremove_sz); 232 paranoid_free(vgchange_sz);233 paranoid_free(vgremove_sz);233 mr_free(vgchange_sz); 234 mr_free(vgremove_sz); 234 235 235 236 run_program_and_log_output(command, 5); 236 paranoid_free(command);237 mr_free(command); 237 238 238 239 if (just_erase_existing_volumes) { … … 250 251 log_msg(1, "OK, rewound i-want-my-lvm. Doing funky stuff..."); 251 252 rewind(fin); 252 for ( getline(&incoming, &n1, fin); !feof(fin);getline(&incoming, &n1, fin)) {253 for (mr_getline(&incoming, &n1, fin); !feof(fin); mr_getline(&incoming, &n1, fin)) { 253 254 fgetpos(fin, &orig_pos); 254 255 /* we want to execute lines begining with a # */ … … 264 265 if ((p = strstr(incoming, "vgcreate"))) { 265 266 // include next line(s) if they end in /dev (cos we've got a broken i-want-my-lvm) 266 for ( getline(&tmp, &n, fin); !feof(fin);getline(&tmp, &n, fin)) {267 for (mr_getline(&tmp, &n, fin); !feof(fin); mr_getline(&tmp, &n, fin)) { 267 268 if (tmp[0] == '#') { 268 269 fsetpos(fin, &orig_pos); … … 270 271 } else { 271 272 fgetpos(fin, &orig_pos); 272 asprintf(&tmp1, "%s%s", incoming, tmp);273 paranoid_free(incoming);273 mr_asprintf(&tmp1, "%s%s", incoming, tmp); 274 mr_free(incoming); 274 275 incoming = tmp1; 275 276 } 276 277 } 277 paranoid_free(tmp);278 mr_free(tmp); 278 279 279 280 for (q = incoming; *q != '\0'; q++) { … … 282 283 } 283 284 } 284 asprintf(&tmp1, p + strlen("vgcreate") + 1);285 mr_asprintf(&tmp1, p + strlen("vgcreate") + 1); 285 286 for (q = tmp1; *q > 32; q++); 286 287 *q = '\0'; 287 288 log_msg(1, "Deleting old entries at /dev/%s", tmp1); 288 asprintf(&tmp, "rm -Rf /dev/%s", tmp1);289 paranoid_free(tmp1);289 mr_asprintf(&tmp, "rm -Rf /dev/%s", tmp1); 290 mr_free(tmp1); 290 291 291 292 run_program_and_log_output(tmp, 1); 292 paranoid_free(tmp);293 mr_free(tmp); 293 294 294 295 run_program_and_log_output(vgscan_sz, 1); … … 299 300 } 300 301 for (p = incoming + 1; *p == ' '; p++); 301 paranoid_alloc(command,p);302 mr_allocstr(command,p); 302 303 for (p = command; *p != '\0'; p++); 303 304 for (; *(p - 1) < 32; p--); … … 333 334 extents = atol(p); 334 335 log_msg(5, "p='%s' --> extents=%ld", p, extents); 335 paranoid_free(tmp);336 mr_free(tmp); 336 337 337 338 p = strstr(command, "-L"); … … 384 385 retval++; 385 386 } 386 asprintf(&tmp, "echo \"%s\" >> /tmp/out.sh", command);387 mr_asprintf(&tmp, "echo \"%s\" >> /tmp/out.sh", command); 387 388 system(tmp); 388 paranoid_free(tmp);389 mr_free(tmp); 389 390 sleep(1); 390 391 } 391 392 paranoid_fclose(fin); 392 paranoid_free(vgscan_sz);393 paranoid_free(pvscan_sz);394 paranoid_free(command);395 paranoid_free(incoming);393 mr_free(vgscan_sz); 394 mr_free(pvscan_sz); 395 mr_free(command); 396 mr_free(incoming); 396 397 397 398 log_msg(1, "Closed i-want-my-lvm. Finished doing funky stuff."); … … 460 461 finish(1); 461 462 } 462 for ( getline(&incoming, &n, fin); !feof(fin)463 for (mr_getline(&incoming, &n, fin); !feof(fin) 463 464 && !strstr(incoming, old_mountlist->el[lino].device); 464 getline(&incoming, &n, fin));465 mr_getline(&incoming, &n, fin)); 465 466 if (!feof(fin)) { 466 asprintf(&tmp, "Investigating %s",467 mr_asprintf(&tmp, "Investigating %s", 467 468 old_mountlist->el[lino].device); 468 469 log_it(tmp); 469 paranoid_free(tmp);470 471 for ( getline(&incoming, &n, fin); !feof(fin)470 mr_free(tmp); 471 472 for (mr_getline(&incoming, &n, fin); !feof(fin) 472 473 && !strstr(incoming, "raiddev"); 473 getline(&incoming, &n, fin)) {474 mr_getline(&incoming, &n, fin)) { 474 475 if (strstr(incoming, OSSWAP("device", "drive")) 475 476 && !strchr(incoming, '#')) { … … 478 479 *p = '\0'; 479 480 for (p--; p > incoming && *(p - 1) > 32; p--); 480 asprintf(&tmp, "Extrapolating %s", p);481 mr_asprintf(&tmp, "Extrapolating %s", p); 481 482 log_it(tmp); 482 paranoid_free(tmp);483 mr_free(tmp); 483 484 484 485 for (j = 0; … … 499 500 new_mountlist->entries++; 500 501 } else { 501 asprintf(&tmp,502 mr_asprintf(&tmp, 502 503 "Not adding %s to mountlist: it's already there", p); 503 504 log_it(tmp); 504 paranoid_free(tmp);505 mr_free(tmp); 505 506 } 506 507 } 507 508 } 508 509 } 509 paranoid_free(incoming);510 mr_free(incoming); 510 511 paranoid_fclose(fin); 511 512 } else { … … 566 567 } 567 568 // create device list from normal disks followed by spare ones 568 asprintf(&devices, raidlist->el[i].data_disks.el[0].device);569 mr_asprintf(&devices, raidlist->el[i].data_disks.el[0].device); 569 570 for (j = 1; j < raidlist->el[i].data_disks.entries; j++) { 570 asprintf(&strtmp, "%s", devices);571 paranoid_free(devices);572 asprintf(&devices, "%s %s", strtmp,571 mr_asprintf(&strtmp, "%s", devices); 572 mr_free(devices); 573 mr_asprintf(&devices, "%s %s", strtmp, 573 574 raidlist->el[i].data_disks.el[j].device); 574 paranoid_free(strtmp);575 mr_free(strtmp); 575 576 } 576 577 for (j = 0; j < raidlist->el[i].spare_disks.entries; j++) { 577 asprintf(&strtmp, "%s", devices);578 paranoid_free(devices);579 asprintf(&devices, "%s %s", strtmp,578 mr_asprintf(&strtmp, "%s", devices); 579 mr_free(devices); 580 mr_asprintf(&devices, "%s %s", strtmp, 580 581 raidlist->el[i].spare_disks.el[j].device); 581 paranoid_free(strtmp);582 mr_free(strtmp); 582 583 } 583 584 // translate RAID level 584 585 if (raidlist->el[i].raid_level == -2) { 585 asprintf(&level, "multipath");586 mr_asprintf(&level, "multipath"); 586 587 } else if (raidlist->el[i].raid_level == -1) { 587 asprintf(&level, "linear");588 mr_asprintf(&level, "linear"); 588 589 } else { 589 asprintf(&level, "raid%d", raidlist->el[i].raid_level);590 mr_asprintf(&level, "raid%d", raidlist->el[i].raid_level); 590 591 } 591 592 // create RAID device: … … 594 595 // - faulty devices ignored 595 596 // - persistent superblock always used as this is recommended 596 asprintf(&program,597 mr_asprintf(&program, 597 598 "mdadm --create --force --run --auto=yes %s --level=%s --raid-devices=%d", 598 599 raidlist->el[i].raid_device, level, 599 600 raidlist->el[i].data_disks.entries); 600 601 if (raidlist->el[i].parity != -1) { 601 asprintf(&strtmp, "%s", program);602 paranoid_free(program);602 mr_asprintf(&strtmp, "%s", program); 603 mr_free(program); 603 604 switch (raidlist->el[i].parity) { 604 605 case 0: 605 asprintf(&program, "%s --parity=%s", strtmp, "la");606 mr_asprintf(&program, "%s --parity=%s", strtmp, "la"); 606 607 break; 607 608 case 1: 608 asprintf(&program, "%s --parity=%s", strtmp, "ra");609 mr_asprintf(&program, "%s --parity=%s", strtmp, "ra"); 609 610 break; 610 611 case 2: 611 asprintf(&program, "%s --parity=%s", strtmp, "ls");612 mr_asprintf(&program, "%s --parity=%s", strtmp, "ls"); 612 613 break; 613 614 case 3: 614 asprintf(&program, "%s --parity=%s", strtmp, "rs");615 mr_asprintf(&program, "%s --parity=%s", strtmp, "rs"); 615 616 break; 616 617 default: … … 618 619 break; 619 620 } 620 paranoid_free(strtmp);621 mr_free(strtmp); 621 622 } 622 623 if (raidlist->el[i].chunk_size != -1) { 623 asprintf(&strtmp, "%s", program);624 paranoid_free(program);625 asprintf(&program, "%s --chunk=%d", strtmp,624 mr_asprintf(&strtmp, "%s", program); 625 mr_free(program); 626 mr_asprintf(&program, "%s --chunk=%d", strtmp, 626 627 raidlist->el[i].chunk_size); 627 paranoid_free(strtmp);628 mr_free(strtmp); 628 629 } 629 630 if (raidlist->el[i].spare_disks.entries > 0) { 630 asprintf(&strtmp, "%s", program);631 paranoid_free(program);632 asprintf(&program, "%s --spare-devices=%d", strtmp,631 mr_asprintf(&strtmp, "%s", program); 632 mr_free(program); 633 mr_asprintf(&program, "%s --spare-devices=%d", strtmp, 633 634 raidlist->el[i].spare_disks.entries); 634 paranoid_free(strtmp);635 } 636 asprintf(&strtmp, "%s", program);637 paranoid_free(program);638 asprintf(&program, "%s %s", strtmp, devices);639 paranoid_free(strtmp);635 mr_free(strtmp); 636 } 637 mr_asprintf(&strtmp, "%s", program); 638 mr_free(program); 639 mr_asprintf(&program, "%s %s", strtmp, devices); 640 mr_free(strtmp); 640 641 res = run_program_and_log_output(program, 1); 641 642 // free memory 642 paranoid_free(devices);643 paranoid_free(level);644 paranoid_free(program);643 mr_free(devices); 644 mr_free(level); 645 mr_free(program); 645 646 // return to calling instance 646 647 return res; … … 687 688 688 689 if (strstr(format, "raid")) { // do not form RAID disks; do it to /dev/md* instead 689 asprintf(&tmp, "Not formatting %s (it is a RAID disk)", device);690 mr_asprintf(&tmp, "Not formatting %s (it is a RAID disk)", device); 690 691 log_it(tmp); 691 paranoid_free(tmp);692 mr_free(tmp); 692 693 return (0); 693 694 } … … 699 700 #endif 700 701 if (strlen(format) <= 2) { 701 asprintf(&tmp,702 mr_asprintf(&tmp, 702 703 "%s has a really small format type ('%s') - this is probably a hexadecimal string, which would suggest the partition is an image --- I shouldn't format it", 703 704 device, format); 704 705 log_it(tmp); 705 paranoid_free(tmp);706 mr_free(tmp); 706 707 return (0); 707 708 } 708 709 if (is_this_device_mounted(device)) { 709 asprintf(&tmp, _("%s is mounted - cannot format it "), device);710 mr_asprintf(&tmp, _("%s is mounted - cannot format it "), device); 710 711 log_to_screen(tmp); 711 paranoid_free(tmp);712 mr_free(tmp); 712 713 return (1); 713 714 } … … 736 737 737 738 if (vinum_started_yet) { 738 asprintf(&tmp,739 mr_asprintf(&tmp, 739 740 _ 740 741 ("Initializing Vinum device %s (this may take a *long* time)"), 741 742 device); 742 743 log_to_screen(tmp); 743 paranoid_free(tmp);744 mr_free(tmp); 744 745 745 746 /* format raid partition */ 746 asprintf(&program,747 mr_asprintf(&program, 747 748 "for plex in `vinum lv -r %s | grep '^P' | tr '\t' ' ' | tr -s ' ' | cut -d' ' -f2`; do echo $plex; done > /tmp/plexes", 748 749 basename(device)); … … 752 753 fprintf(g_fprep, "%s\n", program); 753 754 } 754 paranoid_free(program);755 mr_free(program); 755 756 756 757 fin = fopen("/tmp/plexes", "r"); 757 while ( getline(&line, &n, fin)) {758 while (mr_getline(&line, &n, fin)) { 758 759 if (strchr(line, '\n')) 759 760 *(strchr(line, '\n')) = '\0'; // get rid of the \n on the end 760 761 761 asprintf(&tmp, "Initializing plex: %s", line);762 mr_asprintf(&tmp, "Initializing plex: %s", line); 762 763 open_evalcall_form(tmp); 763 paranoid_free(tmp);764 765 asprintf(&tmp, "vinum init %s", line);764 mr_free(tmp); 765 766 mr_asprintf(&tmp, "vinum init %s", line); 766 767 system(tmp); 767 paranoid_free(tmp);768 mr_free(tmp); 768 769 769 770 while (1) { 770 asprintf(&tmp,771 mr_asprintf(&tmp, 771 772 "vinum lp -r %s | grep '^S' | head -1 | tr -s ' ' | cut -d: -f2 | cut -f1 | sed 's/^ //' | sed 's/I //' | sed 's/%%//'", 772 773 line); 773 774 pin = popen(tmp, "r"); 774 paranoid_free(tmp);775 776 getline(&status, &n1, pin);775 mr_free(tmp); 776 777 mr_getline(&status, &n1, pin); 777 778 pclose(pin); 778 779 … … 782 783 update_evalcall_form(atoi(status)); 783 784 usleep(250000); 784 paranoid_free(status);785 mr_free(status); 785 786 } 786 787 close_evalcall_form(); 787 788 } 788 paranoid_free(line);789 mr_free(line); 789 790 fclose(fin); 790 791 unlink("/tmp/plexes"); … … 792 793 } 793 794 #else 794 asprintf(&tmp, _("Initializing RAID device %s"), device);795 mr_asprintf(&tmp, _("Initializing RAID device %s"), device); 795 796 log_to_screen(tmp); 796 paranoid_free(tmp);797 mr_free(tmp); 797 798 798 799 // Shouldn't be necessary. … … 814 815 device, res); 815 816 } else { 816 asprintf(&program, "mkraid --really-force %s", device);817 mr_asprintf(&program, "mkraid --really-force %s", device); 817 818 res = run_program_and_log_output(program, 1); 818 819 log_msg(1, "%s returned %d", program, res); … … 823 824 fprintf(g_fprep, "%s\n", program); 824 825 } 825 paranoid_free(program);826 mr_free(program); 826 827 } 827 828 sync(); … … 842 843 res = which_format_command_do_i_need(format, program); 843 844 if (strstr(program, "kludge")) { 844 asprintf(&tmp, "%s %s /", program, device);845 mr_asprintf(&tmp, "%s %s /", program, device); 845 846 } else { 846 asprintf(&tmp, "%s %s", program, device);847 } 848 paranoid_free(program);849 850 asprintf(&program, "sh -c 'echo -en \"y\\ny\\ny\\n\" | %s'", tmp);851 paranoid_free(tmp);852 853 asprintf(&tmp, "Formatting %s as %s", device, format);847 mr_asprintf(&tmp, "%s %s", program, device); 848 } 849 mr_free(program); 850 851 mr_asprintf(&program, "sh -c 'echo -en \"y\\ny\\ny\\n\" | %s'", tmp); 852 mr_free(tmp); 853 854 mr_asprintf(&tmp, "Formatting %s as %s", device, format); 854 855 update_progress_form(tmp); 855 856 … … 857 858 if (res && strstr(program, "kludge")) { 858 859 #ifdef __FreeBSD__ 859 paranoid_free(program);860 asprintf(&program, "newfs_msdos -F 32 %s", device);860 mr_free(program); 861 mr_asprintf(&program, "newfs_msdos -F 32 %s", device); 861 862 #else 862 863 #ifdef __IA64__ 863 864 /* For EFI partitions take fat16 864 865 * as we want to make small ones */ 865 paranoid_free(program);866 asprintf(&program, "mkfs -t %s -F 16 %s", format, device);866 mr_free(program); 867 mr_asprintf(&program, "mkfs -t %s -F 16 %s", format, device); 867 868 #else 868 paranoid_free(program);869 asprintf(&program, "mkfs -t %s -F 32 %s", format, device);869 mr_free(program); 870 mr_asprintf(&program, "mkfs -t %s -F 32 %s", format, device); 870 871 #endif 871 872 #endif … … 875 876 } 876 877 } 877 paranoid_free(program);878 mr_free(program); 878 879 879 880 retval += res; 880 881 if (retval) { 881 asprintf(&tmp1, "%s%s",tmp, _("...failed"));882 mr_asprintf(&tmp1, "%s%s",tmp, _("...failed")); 882 883 } else { 883 asprintf(&tmp1, "%s%s",tmp, _("...OK"));884 } 885 paranoid_free(tmp);884 mr_asprintf(&tmp1, "%s%s",tmp, _("...OK")); 885 } 886 mr_free(tmp); 886 887 887 888 log_to_screen(tmp1); 888 paranoid_free(tmp1);889 mr_free(tmp1); 889 890 sync(); 890 891 sleep(1); … … 923 924 924 925 assert(mountlist != NULL); 925 asprintf(&tmp, "format_everything (mountlist, interactively = %s",926 mr_asprintf(&tmp, "format_everything (mountlist, interactively = %s", 926 927 (interactively) ? "true" : "false"); 927 928 log_it(tmp); 928 paranoid_free(tmp);929 mr_free(tmp); 929 930 930 931 mvaddstr_and_log_it(g_currentY, 0, _("Formatting partitions ")); … … 952 953 if (interactively) { 953 954 // ask user if we should format the current device 954 asprintf(&tmp, "Shall I format %s (%s) ?", me->device,955 mr_asprintf(&tmp, "Shall I format %s (%s) ?", me->device, 955 956 me->mountpoint); 956 957 do_it = ask_me_yes_or_no(tmp); 957 paranoid_free(tmp);958 mr_free(tmp); 958 959 } else { 959 960 do_it = TRUE; … … 1003 1004 me = &mountlist->el[lino]; // the current mountlist entry 1004 1005 if (!strcmp(me->mountpoint, "image")) { 1005 asprintf(&tmp, "Not formatting %s - it's an image", me->device);1006 mr_asprintf(&tmp, "Not formatting %s - it's an image", me->device); 1006 1007 log_it(tmp); 1007 paranoid_free(tmp);1008 mr_free(tmp); 1008 1009 } else if (!strcmp(me->format, "raid")) { 1009 asprintf(&tmp, "Not formatting %s - it's a raid-let",1010 mr_asprintf(&tmp, "Not formatting %s - it's a raid-let", 1010 1011 me->device); 1011 1012 log_it(tmp); 1012 paranoid_free(tmp);1013 mr_free(tmp); 1013 1014 continue; 1014 1015 } else if (!strcmp(me->format, "lvm")) { 1015 asprintf(&tmp, "Not formatting %s - it's an LVM", me->device);1016 mr_asprintf(&tmp, "Not formatting %s - it's an LVM", me->device); 1016 1017 log_it(tmp); 1017 paranoid_free(tmp);1018 mr_free(tmp); 1018 1019 continue; 1019 1020 } else if (!strncmp(me->device, "/dev/md", 7)) { 1020 asprintf(&tmp, "Already formatted %s - it's a soft-RAID dev",1021 mr_asprintf(&tmp, "Already formatted %s - it's a soft-RAID dev", 1021 1022 me->device); 1022 1023 log_it(tmp); 1023 paranoid_free(tmp);1024 mr_free(tmp); 1024 1025 continue; 1025 1026 } else if (!does_file_exist(me->device) 1026 1027 && strncmp(me->device, "/dev/hd", 7) 1027 1028 && strncmp(me->device, "/dev/sd", 7)) { 1028 asprintf(&tmp,1029 mr_asprintf(&tmp, 1029 1030 "Not formatting %s yet - doesn't exist - probably an LVM", 1030 1031 me->device); 1031 1032 log_it(tmp); 1032 paranoid_free(tmp);1033 mr_free(tmp); 1033 1034 continue; 1034 1035 } else { 1035 1036 if (interactively) { 1036 1037 // ask user if we should format the current device 1037 asprintf(&tmp, "Shall I format %s (%s) ?", me->device,1038 mr_asprintf(&tmp, "Shall I format %s (%s) ?", me->device, 1038 1039 me->mountpoint); 1039 1040 do_it = ask_me_yes_or_no(tmp); 1040 paranoid_free(tmp);1041 mr_free(tmp); 1041 1042 } else { 1042 1043 do_it = TRUE; … … 1068 1069 } 1069 1070 1070 asprintf(&tmp, "format_everything () - %s",1071 mr_asprintf(&tmp, "format_everything () - %s", 1071 1072 (retval) ? "failed!" : "finished successfully"); 1072 1073 log_it(tmp); 1073 paranoid_free(tmp);1074 mr_free(tmp); 1074 1075 1075 1076 if (g_partition_table_locked_up > 0) { … … 1135 1136 1136 1137 if (devno_we_must_allow_for >= 5) { 1137 asprintf(&tmp, "Making dummy primary %s%d", drivename, 1);1138 mr_asprintf(&tmp, "Making dummy primary %s%d", drivename, 1); 1138 1139 log_it(tmp); 1139 paranoid_free(tmp);1140 mr_free(tmp); 1140 1141 1141 1142 g_maximum_progress++; … … 1151 1152 } 1152 1153 for (; current_devno < devno_we_must_allow_for; current_devno++) { 1153 asprintf(&tmp, "Creating dummy partition %s%d", drivename,1154 mr_asprintf(&tmp, "Creating dummy partition %s%d", drivename, 1154 1155 current_devno); 1155 1156 log_it(tmp); 1156 paranoid_free(tmp);1157 mr_free(tmp); 1157 1158 1158 1159 g_maximum_progress++; … … 1301 1302 off_t mediasize; 1302 1303 1303 asprintf(&lnamebuf, "%s", dkname);1304 mr_asprintf(&lnamebuf, "%s", dkname); 1304 1305 if ((f = open(lnamebuf, O_RDONLY)) == -1) { 1305 1306 warn("cannot open %s", lnamebuf); 1306 paranoid_free(lnamebuf);1307 mr_free(lnamebuf); 1307 1308 return (NULL); 1308 1309 } 1309 paranoid_free(lnamebuf);1310 mr_free(lnamebuf); 1310 1311 1311 1312 /* New world order */ … … 1389 1390 for (c = 'a'; c <= 'z'; ++c) { 1390 1391 int idx; 1391 asprintf(&subdev_str, "%s%c", drivename, c);1392 mr_asprintf(&subdev_str, "%s%c", drivename, c); 1392 1393 if ((idx = find_device_in_mountlist(mountlist, subdev_str)) < 0) { 1393 1394 lp->d_partitions[c - 'a'].p_size = 0; … … 1414 1415 lp->d_partitions[c - 'a'].p_fstype = FS_OTHER; 1415 1416 } 1416 paranoid_free(subdev_str);1417 mr_free(subdev_str); 1417 1418 } 1418 1419 … … 1445 1446 display_disklabel(ftmp, lp); 1446 1447 fclose(ftmp); 1447 asprintf(&command, "disklabel -wr %s auto", canonical_name(drivename));1448 mr_asprintf(&command, "disklabel -wr %s auto", canonical_name(drivename)); 1448 1449 retval += run_program_and_log_output(command, TRUE); 1449 paranoid_free(command);1450 1451 asprintf(&command, "disklabel -R %s /tmp/disklabel",1450 mr_free(command); 1451 1452 mr_asprintf(&command, "disklabel -R %s /tmp/disklabel", 1452 1453 canonical_name(drivename)); 1453 1454 retval += run_program_and_log_output(command, TRUE); 1454 paranoid_free(command);1455 mr_free(command); 1455 1456 if (ret) 1456 1457 *ret = *lp; … … 1495 1496 assert_string_is_neither_NULL_nor_zerolength(drivename); 1496 1497 1497 asprintf(&tmp, "Partitioning drive %s", drivename);1498 mr_asprintf(&tmp, "Partitioning drive %s", drivename); 1498 1499 log_it(tmp); 1499 paranoid_free(tmp);1500 mr_free(tmp); 1500 1501 1501 1502 #if __FreeBSD__ … … 1504 1505 #else 1505 1506 make_hole_for_file(FDISK_LOG); 1506 asprintf(&tmp, "parted2fdisk %s >> %s 2>> %s", drivename, FDISK_LOG,1507 mr_asprintf(&tmp, "parted2fdisk %s >> %s 2>> %s", drivename, FDISK_LOG, 1507 1508 FDISK_LOG); 1508 1509 pout_to_fdisk = popen(tmp, "w"); 1509 paranoid_free(tmp);1510 mr_free(tmp); 1510 1511 1511 1512 if (!pout_to_fdisk) { … … 1531 1532 // try DangerouslyDedicated mode 1532 1533 for (c = 'a'; c <= 'z'; c++) { 1533 asprintf(&subdev_str, "%s%c", drivename, c);1534 mr_asprintf(&subdev_str, "%s%c", drivename, c); 1534 1535 if (find_device_in_mountlist(mountlist, subdev_str) > 0) { 1535 1536 fbsd_part = TRUE; 1536 1537 } 1537 paranoid_free(subdev_str);1538 mr_free(subdev_str); 1538 1539 } 1539 1540 if (fbsd_part) { … … 1541 1542 drivename, 1542 1543 0); 1543 asprintf(&command, "disklabel -B %s",1544 mr_asprintf(&command, "disklabel -B %s", 1544 1545 basename(drivename)); 1545 1546 if (system(command)) { … … 1548 1549 ("Warning! Unable to make the drive bootable.")); 1549 1550 } 1550 paranoid_free(command);1551 paranoid_free(device_str);1551 mr_free(command); 1552 mr_free(device_str); 1552 1553 1553 1554 return r; … … 1555 1556 } 1556 1557 for (c = 'a'; c <= 'z'; c++) { 1557 asprintf(&subdev_str, "%s%c", device_str, c);1558 mr_asprintf(&subdev_str, "%s%c", device_str, c); 1558 1559 if (find_device_in_mountlist(mountlist, subdev_str) > 0) { 1559 1560 fbsd_part = TRUE; 1560 1561 } 1561 paranoid_free(subdev_str);1562 mr_free(subdev_str); 1562 1563 } 1563 1564 // Now we check the subpartitions of the current partition. … … 1565 1566 int i, line; 1566 1567 1567 asprintf(&format, "ufs");1568 mr_asprintf(&format, "ufs"); 1568 1569 partsize = 0; 1569 1570 for (i = 'a'; i < 'z'; ++i) { 1570 asprintf(&subdev_str, "%s%c", device_str, i);1571 mr_asprintf(&subdev_str, "%s%c", device_str, i); 1571 1572 line = find_device_in_mountlist(mountlist, subdev_str); 1572 paranoid_free(subdev_str);1573 mr_free(subdev_str); 1573 1574 1574 1575 if (line > 0) { … … 1596 1597 file = open(drivename, O_WRONLY); 1597 1598 if (!file) { 1598 asprintf(&tmp,1599 mr_asprintf(&tmp, 1599 1600 _("Warning - unable to open %s for wiping it's partition table"), 1600 1601 drivename); 1601 1602 log_to_screen(tmp); 1602 paranoid_free(tmp);1603 mr_free(tmp); 1603 1604 } 1604 1605 1605 1606 for (i = 0; i < 512; i++) { 1606 1607 if (!write(file, "\0", 1)) { 1607 asprintf(&tmp, _("Warning - unable to write to %s"),1608 mr_asprintf(&tmp, _("Warning - unable to write to %s"), 1608 1609 drivename); 1609 1610 log_to_screen(tmp); 1610 paranoid_free(tmp);1611 mr_free(tmp); 1611 1612 } 1612 1613 } … … 1629 1630 #endif 1630 1631 1631 asprintf(&format, mountlist->el[lino].format);1632 mr_asprintf(&format, mountlist->el[lino].format); 1632 1633 partsize = mountlist->el[lino].size; 1633 1634 … … 1640 1641 (_ 1641 1642 ("You must leave at least one partition spare as the Extended partition.")); 1642 paranoid_free(device_str);1643 paranoid_free(format);1643 mr_free(device_str); 1644 mr_free(format); 1644 1645 1645 1646 return (1); … … 1652 1653 #ifdef __FreeBSD__ 1653 1654 if ((current_devno <= 4) && fbsd_part) { 1654 asprintf(&tmp, "disklabel -B %s", basename(device_str));1655 mr_asprintf(&tmp, "disklabel -B %s", basename(device_str)); 1655 1656 retval += label_drive_or_slice(mountlist, device_str, 0); 1656 1657 if (system(tmp)) { … … 1658 1659 (_("Warning! Unable to make the slice bootable.")); 1659 1660 } 1660 paranoid_free(tmp);1661 mr_free(tmp); 1661 1662 } 1662 1663 #endif … … 1664 1665 previous_devno = current_devno; 1665 1666 } 1666 paranoid_free(device_str);1667 paranoid_free(format);1667 mr_free(device_str); 1668 mr_free(format); 1668 1669 1669 1670 if (pout_to_fdisk) { … … 1671 1672 tmp1 = call_program_and_get_last_line_of_output 1672 1673 ("make-me-bootable /tmp/mountlist.txt dummy"); 1673 asprintf(&tmp, "a\n%s\n", tmp1);1674 paranoid_free(tmp1);1674 mr_asprintf(&tmp, "a\n%s\n", tmp1); 1675 mr_free(tmp1); 1675 1676 1676 1677 fput_string_one_char_at_a_time(pout_to_fdisk, tmp); 1677 paranoid_free(tmp);1678 mr_free(tmp); 1678 1679 1679 1680 // close fdisk … … 1683 1684 log_msg(0, 1684 1685 "------------------- fdisk.log looks like this ------------------"); 1685 asprintf(&tmp, "cat %s >> %s", FDISK_LOG, MONDO_LOGFILE);1686 mr_asprintf(&tmp, "cat %s >> %s", FDISK_LOG, MONDO_LOGFILE); 1686 1687 system(tmp); 1687 paranoid_free(tmp);1688 mr_free(tmp); 1688 1689 1689 1690 log_msg(0, 1690 1691 "------------------- end of fdisk.log... word! ------------------"); 1691 asprintf(&tmp, "tail -n6 %s | grep -F \"16: \"", FDISK_LOG);1692 mr_asprintf(&tmp, "tail -n6 %s | grep -F \"16: \"", FDISK_LOG); 1692 1693 if (!run_program_and_log_output(tmp, 5)) { 1693 1694 g_partition_table_locked_up++; … … 1696 1697 ("A flaw in the Linux kernel has locked the partition table.")); 1697 1698 } 1698 paranoid_free(tmp);1699 mr_free(tmp); 1699 1700 } 1700 1701 return (retval); … … 1739 1740 1740 1741 if (!strncmp(drive, RAID_DEVICE_STUB, strlen(RAID_DEVICE_STUB))) { 1741 asprintf(&tmp, "Not partitioning %s - it is a virtual drive", drive);1742 mr_asprintf(&tmp, "Not partitioning %s - it is a virtual drive", drive); 1742 1743 log_it(tmp); 1743 paranoid_free(tmp);1744 mr_free(tmp); 1744 1745 return (0); 1745 1746 } 1746 1747 partition_name = build_partition_name(drive, partno); 1747 1748 if (partsize <= 0) { 1748 asprintf(&tmp, "Partitioning device %s (max size)", partition_name);1749 mr_asprintf(&tmp, "Partitioning device %s (max size)", partition_name); 1749 1750 } else { 1750 asprintf(&tmp, "Partitioning device %s (%lld MB)", partition_name,1751 mr_asprintf(&tmp, "Partitioning device %s (%lld MB)", partition_name, 1751 1752 (long long) partsize / 1024); 1752 1753 } 1753 1754 update_progress_form(tmp); 1754 1755 log_it(tmp); 1755 paranoid_free(tmp);1756 mr_free(tmp); 1756 1757 1757 1758 if (is_this_device_mounted(partition_name)) { 1758 asprintf(&tmp, _("%s is mounted, and should not be partitioned"),1759 mr_asprintf(&tmp, _("%s is mounted, and should not be partitioned"), 1759 1760 partition_name); 1760 paranoid_free(partition_name);1761 mr_free(partition_name); 1761 1762 1762 1763 log_to_screen(tmp); 1763 paranoid_free(tmp);1764 mr_free(tmp); 1764 1765 return (1); 1765 1766 } 1766 1767 1767 1768 p = (char *) strrchr(partition_name, '/'); 1768 asprintf(&program, "parted2fdisk %s >> %s 2>> %s", drive, MONDO_LOGFILE,1769 mr_asprintf(&program, "parted2fdisk %s >> %s 2>> %s", drive, MONDO_LOGFILE, 1769 1770 MONDO_LOGFILE); 1770 1771 … … 1773 1774 /* make it a primary/extended/logical */ 1774 1775 if (partno <= 4) { 1775 asprintf(&output,"n\np\n%d\n", partno);1776 mr_asprintf(&output,"n\np\n%d\n", partno); 1776 1777 } else { 1777 1778 /* MBR needs an extended partition if more than 4 partitions */ … … 1782 1783 (_ 1783 1784 ("You need to leave at least one partition free, for 'extended/logical'")); 1784 paranoid_free(partition_name);1785 paranoid_free(program);1786 1787 paranoid_free(output);1785 mr_free(partition_name); 1786 mr_free(program); 1787 1788 mr_free(output); 1788 1789 return (1); 1789 1790 } else { 1790 asprintf(&output,"n\ne\n%d\n\n\n",prev_partno + 1);1791 mr_asprintf(&output,"n\ne\n%d\n\n\n",prev_partno + 1); 1791 1792 } 1792 1793 } 1793 asprintf(&tmp,"%sn\nl\n",output);1794 paranoid_free(output);1794 mr_asprintf(&tmp,"%sn\nl\n",output); 1795 mr_free(output); 1795 1796 output = tmp; 1796 1797 } else { 1797 1798 /* GPT allows more than 4 primary partitions */ 1798 asprintf(&output,"n\np\n%d\n",partno);1799 } 1800 } 1801 paranoid_free(part_table_fmt);1799 mr_asprintf(&output,"n\np\n%d\n",partno); 1800 } 1801 } 1802 mr_free(part_table_fmt); 1802 1803 /*start block (ENTER for next free blk */ 1803 asprintf(&tmp,"%s\n",output);1804 paranoid_free(output);1804 mr_asprintf(&tmp,"%s\n",output); 1805 mr_free(output); 1805 1806 output = tmp; 1806 1807 … … 1810 1811 partsize += 512; 1811 1812 } 1812 asprintf(&tmp,"%s+%lldK", output, (long long) (partsize));1813 paranoid_free(output);1813 mr_asprintf(&tmp,"%s+%lldK", output, (long long) (partsize)); 1814 mr_free(output); 1814 1815 output = tmp; 1815 1816 } 1816 asprintf(&tmp,"%s\n",output);1817 paranoid_free(output);1817 mr_asprintf(&tmp,"%s\n",output); 1818 mr_free(output); 1818 1819 output = tmp; 1819 1820 #if 0 1820 1821 /* 1821 1822 #endif 1822 asprintf(&tmp,"PARTSIZE = +%ld",(long)partsize);1823 mr_asprintf(&tmp,"PARTSIZE = +%ld",(long)partsize); 1823 1824 log_it(tmp); 1824 paranoid_free(tmp);1825 mr_free(tmp); 1825 1826 1826 1827 log_it("---fdisk command---"); … … 1845 1846 partno); 1846 1847 } 1847 paranoid_free(tmp);1848 mr_free(tmp); 1848 1849 1849 1850 if (!retval) { … … 1864 1865 } 1865 1866 } else { 1866 asprintf(&tmp,"%sw\n\n",output);1867 paranoid_free(output);1867 mr_asprintf(&tmp,"%sw\n\n",output); 1868 mr_free(output); 1868 1869 output = tmp; 1869 1870 … … 1885 1886 format, -1); 1886 1887 if (res) { 1887 asprintf(&tmp, "Failed to vacuum-pack %s", partition_name);1888 mr_asprintf(&tmp, "Failed to vacuum-pack %s", partition_name); 1888 1889 log_it(tmp); 1889 paranoid_free(tmp);1890 mr_free(tmp); 1890 1891 1891 1892 retval++; … … 1899 1900 partsize); 1900 1901 if (retval) { 1901 asprintf(&tmp, "Partitioned %s but failed to set its type",1902 mr_asprintf(&tmp, "Partitioned %s but failed to set its type", 1902 1903 partition_name); 1903 1904 log_it(tmp); 1904 paranoid_free(tmp);1905 mr_free(tmp); 1905 1906 } else { 1906 1907 if (partsize > 0) { 1907 asprintf(&tmp, "Partition %s created+configured OK",1908 mr_asprintf(&tmp, "Partition %s created+configured OK", 1908 1909 partition_name); 1909 1910 log_to_screen(tmp); 1910 paranoid_free(tmp);1911 mr_free(tmp); 1911 1912 } else { 1912 1913 log_it("Returning from a successful vacuum-pack"); … … 1914 1915 } 1915 1916 } else { 1916 asprintf(&tmp, "Failed to partition %s", partition_name);1917 mr_asprintf(&tmp, "Failed to partition %s", partition_name); 1917 1918 if (partsize > 0) { 1918 1919 log_to_screen(tmp); … … 1920 1921 log_it(tmp); 1921 1922 } 1922 paranoid_free(tmp);1923 mr_free(tmp); 1923 1924 retval++; 1924 1925 } … … 1926 1927 g_current_progress++; 1927 1928 log_it("partition_device() --- leaving"); 1928 paranoid_free(partition_name);1929 paranoid_free(program);1930 paranoid_free(output);1929 mr_free(partition_name); 1930 mr_free(program); 1931 mr_free(output); 1931 1932 return (retval); 1932 1933 } … … 2014 2015 system("clear"); 2015 2016 newtResume(); 2016 paranoid_free(drivelist);2017 mr_free(drivelist); 2017 2018 return (retval); 2018 2019 } … … 2058 2059 p = (char *) strrchr(partition, '/'); 2059 2060 if (strcmp(format, "swap") == 0) { 2060 asprintf(&partcode, "82");2061 mr_asprintf(&partcode, "82"); 2061 2062 } else if (strcmp(format, "vfat") == 0) { 2062 2063 if (partsize / 1024 > 8192) { 2063 asprintf(&partcode, "c");2064 mr_asprintf(&partcode, "c"); 2064 2065 } else { 2065 asprintf(&partcode, "b");2066 mr_asprintf(&partcode, "b"); 2066 2067 } 2067 2068 } else if (strcmp(format, "ext2") == 0 … … 2069 2070 || strcmp(format, "ext3") == 0 || strcmp(format, "xfs") == 0 2070 2071 || strcmp(format, "jfs") == 0) { 2071 asprintf(&partcode, "83");2072 mr_asprintf(&partcode, "83"); 2072 2073 } else if (strcmp(format, "minix") == 0) { 2073 asprintf(&partcode, "81");2074 mr_asprintf(&partcode, "81"); 2074 2075 } else if (strcmp(format, "raid") == 0) { 2075 asprintf(&partcode, "fd");2076 mr_asprintf(&partcode, "fd"); 2076 2077 } else if ((strcmp(format, "ufs") == 0) 2077 2078 || (strcmp(format, "ffs") == 0)) { /* raid autodetect */ 2078 asprintf(&partcode, "a5");2079 mr_asprintf(&partcode, "a5"); 2079 2080 } else if (strcmp(format, "lvm") == 0) { 2080 asprintf(&partcode, "8e");2081 mr_asprintf(&partcode, "8e"); 2081 2082 } else if (format[0] == '\0') { /* LVM physical partition */ 2082 asprintf(&partcode, "%s", "");2083 mr_asprintf(&partcode, "%s", ""); 2083 2084 } else if (strlen(format) >= 1 && strlen(format) <= 2) { 2084 asprintf(&partcode, format);2085 mr_asprintf(&partcode, format); 2085 2086 } else { 2086 2087 /* probably an image */ 2087 asprintf(&tmp,2088 mr_asprintf(&tmp, 2088 2089 "Unknown format ('%s') - using supplied string anyway", 2089 2090 format); 2090 2091 mvaddstr_and_log_it(g_currentY++, 0, tmp); 2091 paranoid_free(tmp);2092 mr_free(tmp); 2092 2093 #ifdef __FreeBSD__ 2093 asprintf(&partcode, format); // was a52094 mr_asprintf(&partcode, format); // was a5 2094 2095 #else 2095 asprintf(&partcode, format); // was 832096 #endif 2097 } 2098 asprintf(&tmp, "Setting %s's type to %s (%s)", partition, format,2096 mr_asprintf(&partcode, format); // was 83 2097 #endif 2098 } 2099 mr_asprintf(&tmp, "Setting %s's type to %s (%s)", partition, format, 2099 2100 partcode); 2100 paranoid_free(partition);2101 mr_free(partition); 2101 2102 2102 2103 log_msg(1, tmp); 2103 paranoid_free(tmp);2104 mr_free(tmp); 2104 2105 if (partcode[0] != '\0' && strcmp(partcode, "83")) { /* no need to set type if 83: 83 is default */ 2105 2106 … … 2111 2112 || strstr(tmp1, " (1-4)")) { 2112 2113 log_msg(5, "Specifying partno (%d) - yay", partno); 2113 asprintf(&tmp, "%d\n", partno);2114 mr_asprintf(&tmp, "%d\n", partno); 2114 2115 fput_string_one_char_at_a_time(pout_to_fdisk, tmp); 2115 paranoid_free(tmp);2116 paranoid_free(tmp1);2116 mr_free(tmp); 2117 mr_free(tmp1); 2117 2118 tmp1 = last_line_of_file(FDISK_LOG); 2118 2119 log_msg(5, "A - last line = '%s'", tmp1); 2119 2120 } 2120 paranoid_free(tmp1);2121 2122 asprintf(&tmp, "%s\n", partcode);2121 mr_free(tmp1); 2122 2123 mr_asprintf(&tmp, "%s\n", partcode); 2123 2124 fput_string_one_char_at_a_time(pout_to_fdisk, tmp); 2124 paranoid_free(tmp);2125 mr_free(tmp); 2125 2126 tmp1 = last_line_of_file(FDISK_LOG); 2126 2127 log_msg(5, "B - last line = '%s'",tmp1); 2127 paranoid_free(tmp1);2128 mr_free(tmp1); 2128 2129 2129 2130 fput_string_one_char_at_a_time(pout_to_fdisk, "\n"); 2130 2131 tmp1 = last_line_of_file(FDISK_LOG); 2131 2132 log_msg(5, "C - last line = '%s'",tmp1); 2132 paranoid_free(tmp1);2133 mr_free(tmp1); 2133 2134 2134 2135 tmp = last_line_of_file(FDISK_LOG); … … 2138 2139 fput_string_one_char_at_a_time(pout_to_fdisk, "\n"); 2139 2140 } 2140 paranoid_free(tmp);2141 mr_free(tmp); 2141 2142 fput_string_one_char_at_a_time(pout_to_fdisk, "p\n"); 2142 2143 } else { 2143 asprintf(&output, "t\n%d\n%s\nw\n", partno, partcode);2144 asprintf(&command, "parted2fdisk %s >> %s 2>> %s", drive,2144 mr_asprintf(&output, "t\n%d\n%s\nw\n", partno, partcode); 2145 mr_asprintf(&command, "parted2fdisk %s >> %s 2>> %s", drive, 2145 2146 MONDO_LOGFILE, MONDO_LOGFILE); 2146 2147 log_msg(5, "output = '%s'", output); … … 2156 2157 paranoid_pclose(fout); 2157 2158 } 2158 paranoid_free(command);2159 paranoid_free(output);2159 mr_free(command); 2160 mr_free(output); 2160 2161 } 2161 2162 /* BERLIOS: Useless as command not initialized in all cases … … 2165 2166 */ 2166 2167 } 2167 paranoid_free(partcode);2168 mr_free(partcode); 2168 2169 2169 2170 … … 2190 2191 return 1; 2191 2192 } 2192 asprintf(&program, "vinum start -f %s", raid_device);2193 mr_asprintf(&program, "vinum start -f %s", raid_device); 2193 2194 #else 2194 asprintf(&program, "raidstart %s", raid_device);2195 mr_asprintf(&program, "raidstart %s", raid_device); 2195 2196 #endif 2196 2197 log_msg(1, "program = %s", program); … … 2199 2200 fprintf(g_fprep, "%s\n", program); 2200 2201 } 2201 paranoid_free(program);2202 mr_free(program); 2202 2203 2203 2204 if (res) { … … 2234 2235 return 1; 2235 2236 } 2236 asprintf(&program, "vinum stop -f %s", raid_device);2237 mr_asprintf(&program, "vinum stop -f %s", raid_device); 2237 2238 #else 2238 2239 // use raidstop if it exists, otherwise use mdadm 2239 2240 if (run_program_and_log_output("which raidstop", FALSE)) { 2240 asprintf(&program, "mdadm -S %s", raid_device);2241 mr_asprintf(&program, "mdadm -S %s", raid_device); 2241 2242 } else { 2242 asprintf(&program, "raidstop %s", raid_device);2243 mr_asprintf(&program, "raidstop %s", raid_device); 2243 2244 } 2244 2245 #endif … … 2248 2249 fprintf(g_fprep, "%s\n", program); 2249 2250 } 2250 paranoid_free(program);2251 mr_free(program); 2251 2252 2252 2253 if (res) { … … 2322 2323 return (1); 2323 2324 } 2324 for ( getline(&incoming, &n, fin); !feof(fin);2325 getline(&incoming, &n, fin)) {2325 for (mr_getline(&incoming, &n, fin); !feof(fin); 2326 mr_getline(&incoming, &n, fin)) { 2326 2327 retval += stop_raid_device(incoming); 2327 2328 } … … 2332 2333 return (1); 2333 2334 } 2334 for ( getline(&incoming, &n, fin); !feof(fin);2335 getline(&incoming, &n, fin)) {2335 for (mr_getline(&incoming, &n, fin); !feof(fin); 2336 mr_getline(&incoming, &n, fin)) { 2336 2337 for (p = incoming; 2337 2338 *p != '\0' && (*p != 'm' || *(p + 1) != 'd' 2338 2339 || !isdigit(*(p + 2))); p++); 2339 2340 if (*p != '\0') { 2340 asprintf(&dev, "/dev/%s", p);2341 mr_asprintf(&dev, "/dev/%s", p); 2341 2342 /* BERLIOS : 32 Hard coded value */ 2342 2343 for (p = dev; *p > 32; p++); 2343 2344 *p = '\0'; 2344 2345 res = stop_raid_device(dev); 2345 paranoid_free(dev);2346 } 2347 } 2348 #endif 2349 paranoid_free(incoming);2346 mr_free(dev); 2347 } 2348 } 2349 #endif 2350 mr_free(incoming); 2350 2351 } 2351 2352 paranoid_fclose(fin); … … 2381 2382 if (strcmp(format, "swap") == 0) { 2382 2383 #ifdef __FreeBSD__ 2383 asprintf(&program, "true");2384 mr_asprintf(&program, "true"); 2384 2385 #else 2385 asprintf(&program, "mkswap");2386 mr_asprintf(&program, "mkswap"); 2386 2387 #endif 2387 2388 } else if (strcmp(format, "vfat") == 0) { 2388 asprintf(&program, "format-and-kludge-vfat");2389 mr_asprintf(&program, "format-and-kludge-vfat"); 2389 2390 #ifndef __FreeBSD__ 2390 2391 } else if (strcmp(format, "reiserfs") == 0) { 2391 asprintf(&program, "mkreiserfs -ff");2392 mr_asprintf(&program, "mkreiserfs -ff"); 2392 2393 } else if (strcmp(format, "xfs") == 0) { 2393 asprintf(&program, "mkfs.xfs -f -q");2394 mr_asprintf(&program, "mkfs.xfs -f -q"); 2394 2395 } else if (strcmp(format, "jfs") == 0) { 2395 asprintf(&program, "mkfs.jfs");2396 mr_asprintf(&program, "mkfs.jfs"); 2396 2397 } else if (strcmp(format, "ext3") == 0) { 2397 asprintf(&program, "mkfs -t ext2 -F -j -q");2398 mr_asprintf(&program, "mkfs -t ext2 -F -j -q"); 2398 2399 } else if (strcmp(format, "minix") == 0) { 2399 asprintf(&program, "mkfs.minix");2400 mr_asprintf(&program, "mkfs.minix"); 2400 2401 #endif 2401 2402 } else if (strcmp(format, "ext2") == 0) { 2402 asprintf(&program, "mke2fs -F -q");2403 mr_asprintf(&program, "mke2fs -F -q"); 2403 2404 } else { 2404 2405 #ifdef __FreeBSD__ 2405 asprintf(&program, "newfs_%s", format);2406 mr_asprintf(&program, "newfs_%s", format); 2406 2407 #else 2407 asprintf(&program, "mkfs -t %s -c", format); // -c checks for bad blocks2408 #endif 2409 asprintf(&tmp, "Unknown format (%s) - assuming '%s' will do", format,2408 mr_asprintf(&program, "mkfs -t %s -c", format); // -c checks for bad blocks 2409 #endif 2410 mr_asprintf(&tmp, "Unknown format (%s) - assuming '%s' will do", format, 2410 2411 program); 2411 2412 log_it(tmp); 2412 paranoid_free(tmp);2413 mr_free(tmp); 2413 2414 res = 0; 2414 2415 } … … 2448 2449 original_size_of_drive += mountlist->el[partno].size; 2449 2450 } else { 2450 asprintf(&tmp, "Skipping %s", mountlist->el[partno].device);2451 mr_asprintf(&tmp, "Skipping %s", mountlist->el[partno].device); 2451 2452 // log_to_screen(tmp); 2452 paranoid_free(tmp);2453 mr_free(tmp); 2453 2454 } 2454 2455 } … … 2512 2513 return; 2513 2514 } 2514 asprintf(&tmp, _("Expanding entries to suit drive %s (%ld MB)"),2515 mr_asprintf(&tmp, _("Expanding entries to suit drive %s (%ld MB)"), 2515 2516 drive_name, current_size_of_drive); 2516 2517 log_to_screen(tmp); 2517 paranoid_free(tmp);2518 mr_free(tmp); 2518 2519 2519 2520 drivemntlist = malloc(sizeof(struct mountlist_reference)); … … 2532 2533 2533 2534 if (original_size_of_drive <= 0) { 2534 asprintf(&tmp, _("Cannot resize %s's entries. Drive not found."),2535 mr_asprintf(&tmp, _("Cannot resize %s's entries. Drive not found."), 2535 2536 drive_name); 2536 2537 log_to_screen(tmp); 2537 paranoid_free(tmp);2538 mr_free(tmp); 2538 2539 return; 2539 2540 } 2540 2541 factor = 2541 2542 (float) (current_size_of_drive) / (float) (original_size_of_drive); 2542 asprintf(&tmp, "Disk %s was %ld MB; is now %ld MB; factor = %f",2543 mr_asprintf(&tmp, "Disk %s was %ld MB; is now %ld MB; factor = %f", 2543 2544 drive_name, original_size_of_drive, current_size_of_drive, 2544 2545 factor); 2545 2546 log_to_screen(tmp); 2546 paranoid_free(tmp);2547 mr_free(tmp); 2547 2548 2548 2549 lastpart = drivemntlist->entries - 1; … … 2563 2564 newsizL = (long) new_size; 2564 2565 } 2565 asprintf(&tmp, _("Changing %s from %lld KB to %ld KB"),2566 mr_asprintf(&tmp, _("Changing %s from %lld KB to %ld KB"), 2566 2567 drivemntlist->el[partno]->device, 2567 2568 drivemntlist->el[partno]->size, newsizL); 2568 2569 log_to_screen(tmp); 2569 paranoid_free(tmp);2570 mr_free(tmp); 2570 2571 drivemntlist->el[partno]->size = newsizL; 2571 2572 } 2572 2573 final_size = get_phys_size_of_drive(drive_name); 2573 asprintf(&tmp, _("final_size = %ld MB"), final_size);2574 mr_asprintf(&tmp, _("final_size = %ld MB"), final_size); 2574 2575 log_to_screen(tmp); 2575 paranoid_free(tmp);2576 mr_free(tmp); 2576 2577 } 2577 2578 … … 2613 2614 } 2614 2615 log_to_screen(_("Mountlist adjusted to suit current hard drive(s)")); 2615 paranoid_free(drivelist);2616 mr_free(drivelist); 2616 2617 } 2617 2618 … … 2637 2638 log_msg(1, "Creating list of partitions for drive %s", drive_name); 2638 2639 2639 asprintf(&tmp_drive_name,drive_name);2640 mr_asprintf(&tmp_drive_name,drive_name); 2640 2641 if (!tmp_drive_name) 2641 2642 fatal_error("Out of memory"); … … 2657 2658 } 2658 2659 } 2659 paranoid_free(tmp_drive_name);2660 mr_free(tmp_drive_name); 2660 2661 } 2661 2662 -
trunk/mondo/src/mondorestore/mondo-restore.c
r851 r900 23 23 #include <pthread.h> 24 24 #endif 25 #include "mr_mem.h" 25 26 26 27 extern void twenty_seconds_til_yikes(void); … … 160 161 assert(raidlist != NULL); 161 162 if (!bkpinfo->disaster_recovery) { 162 paranoid_alloc(g_mountlist_fname, "/tmp/mountlist.txt");163 mr_allocstr(g_mountlist_fname, "/tmp/mountlist.txt"); 163 164 log_msg(2, "I guess you're testing edit_mountlist()"); 164 165 } … … 274 275 } 275 276 if (g_ISO_restore_mode) { 276 asprintf(&tmp, "umount %s", bkpinfo->isodir);277 mr_asprintf(&tmp, "umount %s", bkpinfo->isodir); 277 278 run_program_and_log_output(tmp, FALSE); 278 paranoid_free(tmp);279 mr_free(tmp); 279 280 } 280 281 paranoid_MR_finish(0); … … 386 387 save_mountlist_to_disk(mountlist, g_mountlist_fname); 387 388 tmp1 = find_my_editor(); 388 asprintf(&tmp, "%s %s", tmp1, g_mountlist_fname);389 paranoid_free(tmp1);389 mr_asprintf(&tmp, "%s %s", tmp1, g_mountlist_fname); 390 mr_free(tmp1); 390 391 391 392 res = system(tmp); 392 paranoid_free(tmp);393 mr_free(tmp); 393 394 load_mountlist(mountlist, g_mountlist_fname); 394 395 } else { … … 500 501 ask_me_yes_or_no 501 502 (_("Do you want me to restore _some_ of your data?")))) { 502 asprintf(&old_restpath,bkpinfo->restore_path);503 mr_asprintf(&old_restpath,bkpinfo->restore_path); 503 504 for (done = FALSE; !done;) { 504 505 unlink("/tmp/filelist.full"); … … 514 515 if (!strcmp(bkpinfo->restore_path, "/")) { 515 516 if (!ask_me_yes_or_no(_("Are you sure?"))) { 516 paranoid_alloc(bkpinfo->restore_path, old_restpath);517 mr_allocstr(bkpinfo->restore_path, old_restpath); 517 518 goto gotos_suck; 518 519 } 519 paranoid_alloc(bkpinfo->restore_path, ""); // so we restore to [blank]/file/name :)520 mr_allocstr(bkpinfo->restore_path, ""); // so we restore to [blank]/file/name :) 520 521 } 521 522 log_msg(1, "Restoring subset"); … … 523 524 free_filelist(filelist); 524 525 } else { 525 paranoid_alloc(bkpinfo->restore_path,old_restpath);526 mr_allocstr(bkpinfo->restore_path,old_restpath); 526 527 free_filelist(filelist); 527 528 } … … 534 535 } 535 536 } 536 paranoid_free(old_restpath);537 mr_free(old_restpath); 537 538 } else { 538 539 mvaddstr_and_log_it(g_currentY++, … … 567 568 ("Using e2label to label your ext2,3 partitions")); 568 569 if (does_file_exist("/tmp/fstab.new")) { 569 asprintf(&fstab_fname, "/tmp/fstab.new");570 mr_asprintf(&fstab_fname, "/tmp/fstab.new"); 570 571 } else { 571 asprintf(&fstab_fname, "/tmp/fstab");572 } 573 asprintf(&tmp,572 mr_asprintf(&fstab_fname, "/tmp/fstab"); 573 } 574 mr_asprintf(&tmp, 574 575 "label-partitions-as-necessary %s < %s >> %s 2>> %s", 575 576 g_mountlist_fname, fstab_fname, MONDO_LOGFILE, 576 577 MONDO_LOGFILE); 577 paranoid_free(fstab_fname);578 mr_free(fstab_fname); 578 579 579 580 res = system(tmp); 580 paranoid_free(tmp);581 mr_free(tmp); 581 582 if (res) { 582 583 log_to_screen … … 679 680 (strstr(tmp1,"RESTORE") == NULL)) { 680 681 /* -H option */ 681 asprintf(&tmp,682 mr_asprintf(&tmp, 682 683 _ 683 684 (" Mondo has restored your system. Please remove the backup media and reboot.\n\nPlease visit our website at http://www.mondorescue.org for more information.")); 684 685 popup_and_OK(tmp); 685 paranoid_free(tmp);686 } 687 paranoid_free(tmp1);686 mr_free(tmp); 687 } 688 mr_free(tmp1); 688 689 689 690 log_to_screen(_ … … 739 740 resize_mountlist_proportionately_to_suit_new_drives(mountlist); 740 741 } 741 paranoid_free(tmp);742 mr_free(tmp); 742 743 743 744 if (!evaluate_mountlist(mountlist, tmpA, tmpB, tmpC)) { 744 asprintf(&tmp,745 mr_asprintf(&tmp, 745 746 _ 746 747 ("Mountlist analyzed. Result: \"%s %s %s\" Switch to Interactive Mode?"), 747 748 tmpA, tmpB, tmpC); 748 749 if (ask_me_yes_or_no(tmp)) { 749 paranoid_free(tmp);750 mr_free(tmp); 750 751 retval = interactive_mode(bkpinfo, mountlist, raidlist); 751 752 goto after_the_nuke; 752 753 } else { 753 paranoid_free(tmp);754 mr_free(tmp); 754 755 fatal_error("Nuke Mode aborted. "); 755 756 } … … 787 788 } 788 789 } 789 paranoid_free(tmp);790 mr_free(tmp); 790 791 791 792 retval += res; … … 840 841 ("Using e2label to label your ext2,3 partitions")); 841 842 842 asprintf(&tmp, "label-partitions-as-necessary %s < /tmp/fstab",843 mr_asprintf(&tmp, "label-partitions-as-necessary %s < /tmp/fstab", 843 844 g_mountlist_fname); 844 845 res = run_program_and_log_output(tmp, TRUE); 845 paranoid_free(tmp);846 mr_free(tmp); 846 847 847 848 if (res) { … … 916 917 } 917 918 918 paranoid_alloc(bkpinfo->restore_path, "/");919 mr_allocstr(bkpinfo->restore_path, "/"); 919 920 if (!g_restoring_live_from_cd) { 920 921 popup_and_OK … … 945 946 if (filelist) { 946 947 save_filelist(filelist, "/tmp/selected-files.txt"); 947 asprintf(&old_restpath,bkpinfo->restore_path);948 mr_asprintf(&old_restpath,bkpinfo->restore_path); 948 949 if (popup_and_get_string(_("Restore path"), 949 950 _("Restore files to where? )"), … … 953 954 } 954 955 free_filelist(filelist); 955 paranoid_alloc(bkpinfo->restore_path,old_restpath);956 mr_allocstr(bkpinfo->restore_path,old_restpath); 956 957 } 957 958 if (IS_THIS_A_STREAMING_BACKUP(bkpinfo->backup_media_type)) { … … 1034 1035 if (!(fin = fopen(tmp,"r"))) { 1035 1036 log_to_screen(_("Cannot even open bigfile's info file")); 1036 paranoid_free(tmp);1037 mr_free(tmp); 1037 1038 return (pathname_of_last_file_restored); 1038 1039 } 1039 paranoid_free(tmp);1040 mr_free(tmp); 1040 1041 1041 1042 memset((void *) &biggiestruct, 0, sizeof(biggiestruct)); … … 1047 1048 paranoid_fclose(fin); 1048 1049 1049 asprintf(&checksum, biggiestruct.checksum);1050 mr_asprintf(&checksum, biggiestruct.checksum); 1050 1051 1051 1052 if (!checksum[0]) { 1052 asprintf(&tmp, "Warning - bigfile %ld does not have a checksum",1053 mr_asprintf(&tmp, "Warning - bigfile %ld does not have a checksum", 1053 1054 bigfileno + 1); 1054 1055 log_msg(3, tmp); 1055 paranoid_free(tmp);1056 mr_free(tmp); 1056 1057 /* BERLIOS : Useless ??? 1057 1058 p = checksum; 1058 1059 */ 1059 1060 } 1060 paranoid_free(checksum);1061 mr_free(checksum); 1061 1062 1062 1063 if (!strncmp(biggiestruct.filename, "/dev/", 5)) // Whether NTFS or not :) 1063 1064 { 1064 asprintf(&outfile_fname, biggiestruct.filename);1065 mr_asprintf(&outfile_fname, biggiestruct.filename); 1065 1066 } else { 1066 asprintf(&outfile_fname, "%s/%s", bkpinfo->restore_path,1067 mr_asprintf(&outfile_fname, "%s/%s", bkpinfo->restore_path, 1067 1068 biggiestruct.filename); 1068 1069 } … … 1101 1102 "Calling ntfsclone in background because %s is an NTFS /dev entry", 1102 1103 outfile_fname); 1103 asprintf(&ntfsprog_fifo, "/tmp/%d.%d.000", (int) (random() % 32768),1104 mr_asprintf(&ntfsprog_fifo, "/tmp/%d.%d.000", (int) (random() % 32768), 1104 1105 (int) (random() % 32768)); 1105 1106 mkfifo(ntfsprog_fifo, 0x770); … … 1125 1126 } 1126 1127 // BERLIOS: Is it the right place ?? 1127 paranoid_free(ntfsprog_fifo);1128 mr_free(ntfsprog_fifo); 1128 1129 } else { 1129 1130 use_ntfsprog_hack = FALSE; … … 1135 1136 } 1136 1137 1137 asprintf(&tmp, "Reassembling big file %ld (%s)", bigfileno + 1,1138 mr_asprintf(&tmp, "Reassembling big file %ld (%s)", bigfileno + 1, 1138 1139 outfile_fname); 1139 1140 log_msg(2, tmp); 1140 paranoid_free(tmp);1141 mr_free(tmp); 1141 1142 1142 1143 /* … … 1146 1147 */ 1147 1148 1148 asprintf(&pathname_of_last_file_restored, biggiestruct.filename);1149 mr_asprintf(&pathname_of_last_file_restored, biggiestruct.filename); 1149 1150 1150 1151 log_msg(3, "file_to_openout = %s", file_to_openout); … … 1165 1166 g_current_media_number); 1166 1167 g_current_media_number++; 1167 asprintf(&tmp3,1168 mr_asprintf(&tmp3, 1168 1169 "Asking for %s #%d so that I may read slice #%ld\n", 1169 1170 bkpinfo->backup_media_string, 1170 1171 g_current_media_number, sliceno); 1171 1172 log_msg(2, tmp3); 1172 paranoid_free(tmp3);1173 1174 asprintf(&tmp3, _("Restoring from %s #%d"),1173 mr_free(tmp3); 1174 1175 mr_asprintf(&tmp3, _("Restoring from %s #%d"), 1175 1176 bkpinfo->backup_media_string, 1176 1177 g_current_media_number); 1177 1178 log_to_screen(tmp3); 1178 paranoid_free(tmp3);1179 mr_free(tmp3); 1179 1180 1180 1181 insist_on_this_cd_number(bkpinfo, g_current_media_number); … … 1189 1190 } else { 1190 1191 if (does_file_exist(tmp1)) { 1191 asprintf(&bzip2_command, "lzop -dc %s 2>> %s",tmp1, MONDO_LOGFILE);1192 mr_asprintf(&bzip2_command, "lzop -dc %s 2>> %s",tmp1, MONDO_LOGFILE); 1192 1193 } else if (does_file_exist(tmp2)) { 1193 asprintf(&bzip2_command, "bzip2 -dc %s 2>> %s",tmp2, MONDO_LOGFILE);1194 mr_asprintf(&bzip2_command, "bzip2 -dc %s 2>> %s",tmp2, MONDO_LOGFILE); 1194 1195 } else if (does_file_exist(tmp)) { 1195 asprintf(&bzip2_command, "%s", "");1196 mr_asprintf(&bzip2_command, "%s", ""); 1196 1197 } else { 1197 1198 log_to_screen(_("OK, that's pretty fsck0red...")); … … 1201 1202 1202 1203 if (bzip2_command == NULL) { 1203 asprintf(&bzip2_command, "cat %s 2>> %s", tmp, MONDO_LOGFILE);1204 } 1205 asprintf(&tmp3, "Working on %s #%d, file #%ld, slice #%ld ",1204 mr_asprintf(&bzip2_command, "cat %s 2>> %s", tmp, MONDO_LOGFILE); 1205 } 1206 mr_asprintf(&tmp3, "Working on %s #%d, file #%ld, slice #%ld ", 1206 1207 bkpinfo->backup_media_string, 1207 1208 g_current_media_number, bigfileno + 1, sliceno); … … 1212 1213 update_progress_form(tmp3); 1213 1214 } 1214 paranoid_free(tmp3);1215 mr_free(tmp3); 1215 1216 1216 1217 if (!(fbzip2 = popen(bzip2_command, "r"))) { 1217 1218 fatal_error("Can't run popen command"); 1218 1219 } 1219 paranoid_free(bzip2_command);1220 mr_free(bzip2_command); 1220 1221 1221 1222 while (!feof(fbzip2)) { … … 1223 1224 if (siz > 0) { 1224 1225 siz1 = fwrite(bigblk, 1, siz, fout); 1225 asprintf(&sz_msg, "Read %ld from fbzip2; written %ld to fout", siz, siz1);1226 mr_asprintf(&sz_msg, "Read %ld from fbzip2; written %ld to fout", siz, siz1); 1226 1227 log_it(sz_msg); 1227 paranoid_free(sz_msg);1228 mr_free(sz_msg); 1228 1229 } 1229 1230 } … … 1234 1235 g_current_progress++; 1235 1236 } 1236 paranoid_free(tmp);1237 paranoid_free(tmp1);1238 paranoid_free(tmp2);1237 mr_free(tmp); 1238 mr_free(tmp1); 1239 mr_free(tmp2); 1239 1240 } 1240 1241 paranoid_fclose(fout); … … 1243 1244 if (use_ntfsprog_hack) { 1244 1245 log_msg(3, "Waiting for ntfsclone to finish"); 1245 asprintf(&tmp,1246 mr_asprintf(&tmp, 1246 1247 " ps | grep \" ntfsclone \" | grep -v grep > /dev/null 2> /dev/null"); 1247 1248 while (system(tmp) == 0) { 1248 1249 sleep(1); 1249 1250 } 1250 paranoid_free(tmp);1251 mr_free(tmp); 1251 1252 log_it("OK, ntfsclone has really finished"); 1252 1253 } … … 1260 1261 utime(outfile_fname, ubuf); 1261 1262 } 1262 paranoid_free(outfile_fname);1263 paranoid_free(bigblk);1263 mr_free(outfile_fname); 1264 mr_free(bigblk); 1264 1265 1265 1266 return (pathname_of_last_file_restored); … … 1329 1330 } 1330 1331 1331 asprintf(&pathname_of_last_file_restored, orig_bf_fname);1332 mr_asprintf(&pathname_of_last_file_restored, orig_bf_fname); 1332 1333 1333 1334 /* open out to biggiefile to be restored (or /dev/null if biggiefile is not to be restored) */ … … 1359 1360 if (use_ntfsprog) { 1360 1361 g_loglevel = 4; 1361 asprintf(&outfile_fname, orig_bf_fname);1362 mr_asprintf(&outfile_fname, orig_bf_fname); 1362 1363 use_ntfsprog_hack = TRUE; 1363 1364 log_msg(2, 1364 1365 "Calling ntfsclone in background because %s is a /dev entry", 1365 1366 outfile_fname); 1366 asprintf(&ntfsprog_fifo, "%s/%d.%d.000",1367 mr_asprintf(&ntfsprog_fifo, "%s/%d.%d.000", 1367 1368 bkpinfo->tmpdir, 1368 1369 (int) (random() % 32768), … … 1387 1388 (long int) (pid)); 1388 1389 } 1389 paranoid_free(ntfsprog_fifo);1390 mr_free(ntfsprog_fifo); 1390 1391 } else { 1391 1392 if (!strncmp(orig_bf_fname, "/dev/", 5)) // non-NTFS partition 1392 1393 { 1393 asprintf(&outfile_fname, orig_bf_fname);1394 mr_asprintf(&outfile_fname, orig_bf_fname); 1394 1395 } else // biggiefile 1395 1396 { 1396 asprintf(&outfile_fname, "%s/%s", bkpinfo->restore_path,1397 mr_asprintf(&outfile_fname, "%s/%s", bkpinfo->restore_path, 1397 1398 orig_bf_fname); 1398 1399 } … … 1403 1404 make_hole_for_file(outfile_fname); 1404 1405 } 1405 asprintf(&tmp1, "Reassembling big file %ld (%s)",1406 mr_asprintf(&tmp1, "Reassembling big file %ld (%s)", 1406 1407 biggiefile_number + 1, orig_bf_fname); 1407 1408 log_msg(2, tmp1); 1408 paranoid_free(tmp1);1409 mr_free(tmp1); 1409 1410 } 1410 1411 1411 1412 if (dummy_restore) { 1412 paranoid_free(outfile_fname);1413 asprintf(&outfile_fname, "/dev/null");1413 mr_free(outfile_fname); 1414 mr_asprintf(&outfile_fname, "/dev/null"); 1414 1415 } 1415 1416 1416 1417 if (bkpinfo->zip_exe == NULL) { 1417 asprintf(&command, "cat > \"%s\"", file_to_openout);1418 mr_asprintf(&command, "cat > \"%s\"", file_to_openout); 1418 1419 } else { 1419 asprintf(&command, "%s -dc > \"%s\" 2>> %s", bkpinfo->zip_exe,1420 mr_asprintf(&command, "%s -dc > \"%s\" 2>> %s", bkpinfo->zip_exe, 1420 1421 file_to_openout, MONDO_LOGFILE); 1421 1422 } 1422 asprintf(&tmp1, "Pipe command = '%s'", command);1423 mr_asprintf(&tmp1, "Pipe command = '%s'", command); 1423 1424 log_msg(3, tmp1); 1424 paranoid_free(tmp1);1425 mr_free(tmp1); 1425 1426 1426 1427 /* restore biggiefile, one slice at a time */ … … 1428 1429 fatal_error("Cannot pipe out"); 1429 1430 } 1430 paranoid_free(command);1431 mr_free(command); 1431 1432 1432 1433 for (res = read_header_block_from_stream(&slice_siz, tmp, &ctrl_chr); … … 1436 1437 wrong_marker(BLK_START_AN_AFIO_OR_SLICE, ctrl_chr); 1437 1438 } 1438 asprintf(&tmp1, "Working on file #%ld, slice #%ld ",1439 mr_asprintf(&tmp1, "Working on file #%ld, slice #%ld ", 1439 1440 biggiefile_number + 1, current_slice_number); 1440 1441 log_msg(2, tmp1); … … 1446 1447 strip_spaces(tmp1); 1447 1448 update_progress_form(tmp1); 1448 paranoid_free(tmp1);1449 mr_free(tmp1); 1449 1450 1450 1451 if (current_slice_number == 0) { … … 1477 1478 g_current_progress++; 1478 1479 } 1479 paranoid_free(tmp);1480 mr_free(tmp); 1480 1481 paranoid_pclose(pout); 1481 1482 … … 1485 1486 if (use_ntfsprog_hack) { 1486 1487 log_msg(3, "Waiting for ntfsclone to finish"); 1487 asprintf(&tmp,1488 mr_asprintf(&tmp, 1488 1489 " ps | grep \" ntfsclone \" | grep -v grep > /dev/null 2> /dev/null"); 1489 1490 while (system(tmp) == 0) { 1490 1491 sleep(1); 1491 1492 } 1492 paranoid_free(tmp);1493 mr_free(tmp); 1493 1494 log_msg(3, "OK, ntfsclone has really finished"); 1494 1495 } … … 1505 1506 } 1506 1507 1507 paranoid_free(outfile_fname);1508 mr_free(outfile_fname); 1508 1509 g_loglevel = old_loglevel; 1509 1510 return (pathname_of_last_file_restored); … … 1551 1552 log_msg(5, "Entering"); 1552 1553 use_star = (strstr(tarball_fname, ".star")) ? TRUE : FALSE; 1553 asprintf(&command, "mkdir -p %s/tmp", MNT_RESTORING);1554 mr_asprintf(&command, "mkdir -p %s/tmp", MNT_RESTORING); 1554 1555 run_program_and_log_output(command, 9); 1555 paranoid_free(command);1556 1557 asprintf(&filelist_name, MNT_CDROM "/archives/filelist.%ld",1556 mr_free(command); 1557 1558 mr_asprintf(&filelist_name, MNT_CDROM "/archives/filelist.%ld", 1558 1559 current_tarball_number); 1559 1560 if (length_of_file(filelist_name) <= 2) { … … 1572 1573 log_msg(3, "length_of_file(%s) = %llu", tarball_fname, 1573 1574 length_of_file(tarball_fname)); 1574 asprintf(&tmp, "Unable to restore fileset #%ld (CD I/O error)",1575 mr_asprintf(&tmp, "Unable to restore fileset #%ld (CD I/O error)", 1575 1576 current_tarball_number); 1576 1577 log_to_screen(tmp); 1577 paranoid_free(tmp);1578 mr_free(tmp); 1578 1579 retval = 1; 1579 1580 log_msg(5, "Leaving"); … … 1582 1583 1583 1584 if (filelist) { 1584 asprintf(&filelist_subset_fname, "/tmp/filelist-subset-%ld.tmp",1585 mr_asprintf(&filelist_subset_fname, "/tmp/filelist-subset-%ld.tmp", 1585 1586 current_tarball_number); 1586 1587 if ((matches = … … 1589 1590 use_star)) 1590 1591 <= 0) { 1591 asprintf(&tmp, "Skipping fileset %ld", current_tarball_number);1592 mr_asprintf(&tmp, "Skipping fileset %ld", current_tarball_number); 1592 1593 log_msg(1, tmp); 1593 paranoid_free(tmp);1594 mr_free(tmp); 1594 1595 } else { 1595 1596 log_msg(3, "Saved fileset %ld's subset to %s", 1596 1597 current_tarball_number, filelist_subset_fname); 1597 1598 } 1598 asprintf(&tmp, "Tarball #%ld --- %ld matches",1599 mr_asprintf(&tmp, "Tarball #%ld --- %ld matches", 1599 1600 current_tarball_number, matches); 1600 1601 log_to_screen(tmp); 1601 paranoid_free(tmp);1602 mr_free(tmp); 1602 1603 } else { 1603 1604 filelist_subset_fname = NULL; 1604 1605 } 1605 paranoid_free(filelist_name);1606 mr_free(filelist_name); 1606 1607 1607 1608 if (filelist == NULL || matches > 0) { 1608 asprintf(&xattr_fname, XATTR_LIST_FNAME_RAW_SZ,1609 mr_asprintf(&xattr_fname, XATTR_LIST_FNAME_RAW_SZ, 1609 1610 MNT_CDROM "/archives", current_tarball_number); 1610 asprintf(&acl_fname, ACL_LIST_FNAME_RAW_SZ, MNT_CDROM "/archives",1611 mr_asprintf(&acl_fname, ACL_LIST_FNAME_RAW_SZ, MNT_CDROM "/archives", 1611 1612 current_tarball_number); 1612 1613 if (strstr(tarball_fname, ".bz2")) { 1613 asprintf(&executable, "bzip2");1614 mr_asprintf(&executable, "bzip2"); 1614 1615 } else if (strstr(tarball_fname, ".lzo")) { 1615 asprintf(&executable, "lzop");1616 mr_asprintf(&executable, "lzop"); 1616 1617 } else { 1617 1618 executable = NULL; … … 1619 1620 1620 1621 if (executable == NULL) { 1621 asprintf(&tmp, "which %s > /dev/null 2> /dev/null", executable);1622 mr_asprintf(&tmp, "which %s > /dev/null 2> /dev/null", executable); 1622 1623 if (run_program_and_log_output(tmp, FALSE)) { 1623 1624 log_to_screen … … 1626 1627 paranoid_MR_finish(1); 1627 1628 } 1628 paranoid_free(tmp);1629 1630 asprintf(&tmp, executable);1631 asprintf(&executable, "-P %s -Z", tmp);1632 paranoid_free(tmp);1629 mr_free(tmp); 1630 1631 mr_asprintf(&tmp, executable); 1632 mr_asprintf(&executable, "-P %s -Z", tmp); 1633 mr_free(tmp); 1633 1634 } 1634 1635 #ifdef __FreeBSD__ … … 1638 1639 #endif 1639 1640 1640 asprintf(&temp_log, "/tmp/%d.%d", (int) (random() % 32768),1641 mr_asprintf(&temp_log, "/tmp/%d.%d", (int) (random() % 32768), 1641 1642 (int) (random() % 32768)); 1642 1643 1643 1644 if (use_star) { 1644 1645 if (strstr(tarball_fname, ".bz2")) { 1645 asprintf(&tmp, " -bz");1646 mr_asprintf(&tmp, " -bz"); 1646 1647 } else { 1647 asprintf(&tmp, "%s", "");1648 } 1649 asprintf(&command,1648 mr_asprintf(&tmp, "%s", ""); 1649 } 1650 mr_asprintf(&command, 1650 1651 "star -x -force-remove -U " STAR_ACL_SZ 1651 1652 " errctl= file=%s %s 2>> %s >> %s", tarball_fname, tmp, temp_log, temp_log); 1652 paranoid_free(tmp);1653 mr_free(tmp); 1653 1654 } else { 1654 1655 if (filelist_subset_fname != NULL) { 1655 asprintf(&command,1656 mr_asprintf(&command, 1656 1657 "afio -i -M 8m -b %ld -c %ld %s -w '%s' %s 2>> %s >> %s", 1657 1658 TAPE_BLOCK_SIZE, … … 1660 1661 tarball_fname, temp_log, temp_log); 1661 1662 } else { 1662 asprintf(&command,1663 mr_asprintf(&command, 1663 1664 "afio -i -b %ld -c %ld -M 8m %s %s 2>> %s >> %s", 1664 1665 TAPE_BLOCK_SIZE, … … 1666 1667 } 1667 1668 } 1668 paranoid_free(executable);1669 mr_free(executable); 1669 1670 1670 1671 #undef BUFSIZE … … 1680 1681 } 1681 1682 } 1682 paranoid_free(command);1683 mr_free(command); 1683 1684 1684 1685 if (res && length_of_file(temp_log) < 5) { … … 1711 1712 } 1712 1713 if (retval) { 1713 asprintf(&command, "cat %s >> %s", temp_log, MONDO_LOGFILE);1714 mr_asprintf(&command, "cat %s >> %s", temp_log, MONDO_LOGFILE); 1714 1715 system(command); 1715 paranoid_free(command);1716 mr_free(command); 1716 1717 log_msg(2, "Errors occurred while processing fileset #%d", 1717 1718 current_tarball_number); … … 1720 1721 } 1721 1722 unlink(xattr_fname); 1722 paranoid_free(xattr_fname);1723 mr_free(xattr_fname); 1723 1724 } 1724 1725 if (does_file_exist("/PAUSE")) { … … 1731 1732 unlink(temp_log); 1732 1733 1733 paranoid_free(filelist_subset_fname);1734 paranoid_free(acl_fname);1735 paranoid_free(temp_log);1734 mr_free(filelist_subset_fname); 1735 mr_free(acl_fname); 1736 mr_free(temp_log); 1736 1737 1737 1738 log_msg(5, "Leaving"); … … 1785 1786 /* to do it with a file... */ 1786 1787 use_star = (strstr(tarball_fname, ".star")) ? TRUE : FALSE; 1787 asprintf(&tmp,1788 mr_asprintf(&tmp, 1788 1789 "Restoring from fileset #%ld (%ld KB) on %s #%d", 1789 1790 current_tarball_number, (long) size >> 10, … … 1791 1792 g_current_media_number); 1792 1793 log_msg(2, tmp); 1793 paranoid_free(tmp);1794 mr_free(tmp); 1794 1795 run_program_and_log_output("mkdir -p " MNT_RESTORING "/tmp", FALSE); 1795 1796 … … 1799 1800 * in afio or someting; oh darn.. OK, use tmpfs :-) * 1800 1801 ****************************************************************************/ 1801 asprintf(&afio_fname, "/tmp/tmpfs/archive.tmp.%ld",1802 mr_asprintf(&afio_fname, "/tmp/tmpfs/archive.tmp.%ld", 1802 1803 current_tarball_number); 1803 asprintf(&filelist_fname, "%s/filelist.%ld", bkpinfo->tmpdir,1804 mr_asprintf(&filelist_fname, "%s/filelist.%ld", bkpinfo->tmpdir, 1804 1805 current_tarball_number); 1805 asprintf(&filelist_subset_fname, "%s/filelist-subset-%ld.tmp",1806 mr_asprintf(&filelist_subset_fname, "%s/filelist-subset-%ld.tmp", 1806 1807 bkpinfo->tmpdir, current_tarball_number); 1807 1808 res = read_file_from_stream_to_file(bkpinfo, afio_fname, size); … … 1814 1815 if (bkpinfo->compression_level != 0) { 1815 1816 if (bkpinfo->use_star) { 1816 asprintf(&executable, " -bz");1817 mr_asprintf(&executable, " -bz"); 1817 1818 } else { 1818 asprintf(&executable, "-P %s -Z", bkpinfo->zip_exe);1819 mr_asprintf(&executable, "-P %s -Z", bkpinfo->zip_exe); 1819 1820 } 1820 1821 } … … 1827 1828 if (strstr(tarball_fname, ".star.")) { 1828 1829 use_star = TRUE; 1829 asprintf(&command, "star -t file=%s %s > %s 2>> %s", afio_fname, executable, filelist_fname, MONDO_LOGFILE);1830 mr_asprintf(&command, "star -t file=%s %s > %s 2>> %s", afio_fname, executable, filelist_fname, MONDO_LOGFILE); 1830 1831 } else { 1831 1832 use_star = FALSE; 1832 asprintf(&command, "afio -t -M 8m -b %ld %s %s > %s 2>> %s", TAPE_BLOCK_SIZE,1833 mr_asprintf(&command, "afio -t -M 8m -b %ld %s %s > %s 2>> %s", TAPE_BLOCK_SIZE, 1833 1834 executable, afio_fname, filelist_fname, MONDO_LOGFILE); 1834 1835 } … … 1837 1838 log_msg(4, "Warning - error occurred while retrieving TOC"); 1838 1839 } 1839 paranoid_free(command);1840 mr_free(command); 1840 1841 if ((matches = 1841 1842 save_filelist_entries_in_common(filelist_fname, filelist, … … 1847 1848 current_tarball_number); 1848 1849 } 1849 asprintf(&tmp, "Skipping fileset %ld", current_tarball_number);1850 mr_asprintf(&tmp, "Skipping fileset %ld", current_tarball_number); 1850 1851 log_msg(2, tmp); 1851 paranoid_free(tmp);1852 mr_free(tmp); 1852 1853 restore_this_fileset = FALSE; 1853 1854 } else { … … 1859 1860 } 1860 1861 unlink(filelist_fname); 1861 paranoid_free(filelist_fname);1862 mr_free(filelist_fname); 1862 1863 1863 1864 // Concoct the call to star/afio to restore files … … 1865 1866 // star 1866 1867 if (filelist) { 1867 asprintf(&command, "star -x file=%s %s list=%s 2>> %s", afio_fname, executable,1868 mr_asprintf(&command, "star -x file=%s %s list=%s 2>> %s", afio_fname, executable, 1868 1869 filelist_subset_fname,MONDO_LOGFILE); 1869 1870 } else { 1870 asprintf(&command,"star -x file=%s %s 2>> %s", afio_fname, executable,MONDO_LOGFILE);1871 mr_asprintf(&command,"star -x file=%s %s 2>> %s", afio_fname, executable,MONDO_LOGFILE); 1871 1872 } 1872 1873 } else { 1873 1874 // afio 1874 1875 if (filelist) { 1875 asprintf(&command, "afio -i -M 8m -b %ld %s -w %s %s 2>> %s", TAPE_BLOCK_SIZE, executable, filelist_subset_fname,afio_fname,MONDO_LOGFILE);1876 mr_asprintf(&command, "afio -i -M 8m -b %ld %s -w %s %s 2>> %s", TAPE_BLOCK_SIZE, executable, filelist_subset_fname,afio_fname,MONDO_LOGFILE); 1876 1877 } else { 1877 asprintf(&command, "afio -i -M 8m -b %ld %s %s 2>> %s", TAPE_BLOCK_SIZE, executable,afio_fname,MONDO_LOGFILE);1878 } 1879 } 1880 paranoid_free(executable);1878 mr_asprintf(&command, "afio -i -M 8m -b %ld %s %s 2>> %s", TAPE_BLOCK_SIZE, executable,afio_fname,MONDO_LOGFILE); 1879 } 1880 } 1881 mr_free(executable); 1881 1882 1882 1883 // Call if IF there are files to restore (selectively/unconditionally) … … 1905 1906 log_msg(1, "NOT CALLING '%s'", command); 1906 1907 } 1907 paranoid_free(command);1908 mr_free(command); 1908 1909 1909 1910 if (does_file_exist("/PAUSE") && current_tarball_number >= 50) { … … 1915 1916 unlink(afio_fname); 1916 1917 1917 paranoid_free(filelist_subset_fname);1918 paranoid_free(afio_fname);1918 mr_free(filelist_subset_fname); 1919 mr_free(afio_fname); 1919 1920 return (retval); 1920 1921 } … … 1952 1953 assert(bkpinfo != NULL); 1953 1954 1954 asprintf(&biggies_whose_EXATs_we_should_set,1955 mr_asprintf(&biggies_whose_EXATs_we_should_set, 1955 1956 "%s/biggies-whose-EXATs-we-should-set", bkpinfo->tmpdir); 1956 1957 if (!(fbw = fopen(biggies_whose_EXATs_we_should_set, "w"))) { … … 1961 1962 read_cfg_var(g_mondo_cfg_file, "total-slices", tmp); 1962 1963 total_slices = atol(tmp); 1963 paranoid_free(tmp);1964 1965 asprintf(&tmp, _("Reassembling large files "));1964 mr_free(tmp); 1965 1966 mr_asprintf(&tmp, _("Reassembling large files ")); 1966 1967 mvaddstr_and_log_it(g_currentY, 0, tmp); 1967 paranoid_free(tmp);1968 mr_free(tmp); 1968 1969 1969 1970 if (length_of_file(BIGGIELIST) < 6) { … … 1977 1978 return (0); 1978 1979 } 1979 asprintf(&tmp, "OK, there are %ld biggiefiles in the archives",1980 mr_asprintf(&tmp, "OK, there are %ld biggiefiles in the archives", 1980 1981 noof_biggiefiles); 1981 1982 log_msg(2, tmp); 1982 paranoid_free(tmp);1983 mr_free(tmp); 1983 1984 1984 1985 open_progress_form(_("Reassembling large files"), … … 1998 1999 tmp1 = slice_fname(bigfileno + 1, 0, ARCHIVES_PATH, ""); 1999 2000 log_msg(3, "Slicename would have been %s", tmp1); 2000 paranoid_free(tmp1);2001 mr_free(tmp1); 2001 2002 2002 2003 // I'm not positive 'just_changed_cds' is even necessary... … … 2008 2009 insist_on_this_cd_number(bkpinfo, 2009 2010 ++g_current_media_number); 2010 asprintf(&tmp, _("Restoring from %s #%d"),2011 mr_asprintf(&tmp, _("Restoring from %s #%d"), 2011 2012 bkpinfo->backup_media_string, 2012 2013 g_current_media_number); 2013 2014 log_to_screen(tmp); 2014 paranoid_free(tmp);2015 mr_free(tmp); 2015 2016 2016 2017 just_changed_cds = TRUE; … … 2023 2024 } else { 2024 2025 just_changed_cds = FALSE; 2025 asprintf(&tmp, _("Restoring big file %ld"), bigfileno + 1);2026 mr_asprintf(&tmp, _("Restoring big file %ld"), bigfileno + 1); 2026 2027 update_progress_form(tmp); 2027 paranoid_free(tmp);2028 mr_free(tmp); 2028 2029 2029 2030 pathname_of_last_biggie_restored = … … 2033 2034 fprintf(fbw, "%s\n", pathname_of_last_biggie_restored); 2034 2035 } 2035 paranoid_free(pathname_of_last_biggie_restored);2036 mr_free(pathname_of_last_biggie_restored); 2036 2037 retval += res; 2037 2038 bigfileno++; 2038 2039 2039 2040 } 2040 paranoid_free(tmp);2041 mr_free(tmp); 2041 2042 } 2042 2043 2043 2044 if (fbw) { 2044 2045 fclose(fbw); 2045 asprintf(&acl_fname, ACL_BIGGLST_FNAME_RAW_SZ, ARCHIVES_PATH);2046 asprintf(&xattr_fname, XATTR_BIGGLST_FNAME_RAW_SZ, ARCHIVES_PATH);2046 mr_asprintf(&acl_fname, ACL_BIGGLST_FNAME_RAW_SZ, ARCHIVES_PATH); 2047 mr_asprintf(&xattr_fname, XATTR_BIGGLST_FNAME_RAW_SZ, ARCHIVES_PATH); 2047 2048 tmp = find_home_of_exe("setfacl"); 2048 2049 if (length_of_file(acl_fname) > 0 && tmp) { 2049 2050 set_acl_list(biggies_whose_EXATs_we_should_set, acl_fname); 2050 2051 } 2051 paranoid_free(tmp);2052 mr_free(tmp); 2052 2053 2053 2054 tmp = find_home_of_exe("setfattr"); … … 2055 2056 set_fattr_list(biggies_whose_EXATs_we_should_set, xattr_fname); 2056 2057 } 2057 paranoid_free(tmp);2058 paranoid_free(acl_fname);2059 paranoid_free(xattr_fname);2060 } 2061 paranoid_free(biggies_whose_EXATs_we_should_set);2058 mr_free(tmp); 2059 mr_free(acl_fname); 2060 mr_free(xattr_fname); 2061 } 2062 mr_free(biggies_whose_EXATs_we_should_set); 2062 2063 2063 2064 if (does_file_exist("/PAUSE")) { … … 2117 2118 read_cfg_var(g_mondo_cfg_file, "last-filelist-number", tmp); 2118 2119 max_val = atol(tmp) + 1; 2119 paranoid_free(tmp);2120 2121 asprintf(&progress_str, _("Restoring from %s #%d"),2120 mr_free(tmp); 2121 2122 mr_asprintf(&progress_str, _("Restoring from %s #%d"), 2122 2123 bkpinfo->backup_media_string, 2123 2124 g_current_media_number); … … 2131 2132 update_progress_form(progress_str); 2132 2133 2133 asprintf(&tarball_fname, MNT_CDROM "/archives/%ld.afio.bz2",2134 mr_asprintf(&tarball_fname, MNT_CDROM "/archives/%ld.afio.bz2", 2134 2135 current_tarball_number); 2135 2136 if (!does_file_exist(tarball_fname)) { 2136 paranoid_free(tarball_fname);2137 asprintf(&tarball_fname, MNT_CDROM "/archives/%ld.afio.lzo",2137 mr_free(tarball_fname); 2138 mr_asprintf(&tarball_fname, MNT_CDROM "/archives/%ld.afio.lzo", 2138 2139 current_tarball_number); 2139 2140 } 2140 2141 if (!does_file_exist(tarball_fname)) { 2141 paranoid_free(tarball_fname);2142 asprintf(&tarball_fname, MNT_CDROM "/archives/%ld.afio.",2142 mr_free(tarball_fname); 2143 mr_asprintf(&tarball_fname, MNT_CDROM "/archives/%ld.afio.", 2143 2144 current_tarball_number); 2144 2145 } 2145 2146 if (!does_file_exist(tarball_fname)) { 2146 paranoid_free(tarball_fname);2147 asprintf(&tarball_fname, MNT_CDROM "/archives/%ld.star.bz2",2147 mr_free(tarball_fname); 2148 mr_asprintf(&tarball_fname, MNT_CDROM "/archives/%ld.star.bz2", 2148 2149 current_tarball_number); 2149 2150 } 2150 2151 if (!does_file_exist(tarball_fname)) { 2151 paranoid_free(tarball_fname);2152 asprintf(&tarball_fname, MNT_CDROM "/archives/%ld.star.",2152 mr_free(tarball_fname); 2153 mr_asprintf(&tarball_fname, MNT_CDROM "/archives/%ld.star.", 2153 2154 current_tarball_number); 2154 2155 } 2155 2156 if (!does_file_exist(tarball_fname)) { 2156 paranoid_free(tarball_fname);2157 mr_free(tarball_fname); 2157 2158 if (current_tarball_number == 0) { 2158 2159 log_to_screen … … 2168 2169 } 2169 2170 g_current_media_number++; 2170 paranoid_free(progress_str);2171 asprintf(&progress_str, _("Restoring from %s #%d"),2171 mr_free(progress_str); 2172 mr_asprintf(&progress_str, _("Restoring from %s #%d"), 2172 2173 bkpinfo->backup_media_string, 2173 2174 g_current_media_number); 2174 2175 log_to_screen(progress_str); 2175 2176 } else { 2176 paranoid_free(progress_str);2177 asprintf(&progress_str,2177 mr_free(progress_str); 2178 mr_asprintf(&progress_str, 2178 2179 _("Restoring from fileset #%ld on %s #%d"), 2179 2180 current_tarball_number, … … 2189 2190 } 2190 2191 if (res) { 2191 asprintf(&tmp1, _("reported errors"));2192 mr_asprintf(&tmp1, _("reported errors")); 2192 2193 } else { 2193 asprintf(&tmp1, _("succeeded"));2194 } 2195 asprintf(&tmp, _("%s #%d, fileset #%ld - restore %s"),2194 mr_asprintf(&tmp1, _("succeeded")); 2195 } 2196 mr_asprintf(&tmp, _("%s #%d, fileset #%ld - restore %s"), 2196 2197 bkpinfo->backup_media_string, 2197 2198 g_current_media_number, current_tarball_number,tmp1); 2198 paranoid_free(tmp1);2199 mr_free(tmp1); 2199 2200 2200 2201 if (attempts > 1) { 2201 asprintf(&tmp1, _(" (%d attempts) - review logs"), attempts);2202 } 2203 asprintf(&comment, "%s%s", tmp, tmp1);2204 paranoid_free(tmp);2205 paranoid_free(tmp1);2202 mr_asprintf(&tmp1, _(" (%d attempts) - review logs"), attempts); 2203 } 2204 mr_asprintf(&comment, "%s%s", tmp, tmp1); 2205 mr_free(tmp); 2206 mr_free(tmp1); 2206 2207 if (attempts > 1) { 2207 2208 log_to_screen(comment); 2208 2209 } 2209 paranoid_free(comment);2210 mr_free(comment); 2210 2211 2211 2212 retval += res; … … 2213 2214 g_current_progress++; 2214 2215 } 2215 paranoid_free(tarball_fname);2216 } 2217 paranoid_free(progress_str);2216 mr_free(tarball_fname); 2217 } 2218 mr_free(progress_str); 2218 2219 close_progress_form(); 2219 2220 … … 2265 2266 read_cfg_var(g_mondo_cfg_file, "total-slices", tmp); 2266 2267 total_slices = atol(tmp); 2267 paranoid_free(tmp);2268 2269 asprintf(&tmp, "Reassembling large files ");2270 asprintf(&xattr_fname, XATTR_BIGGLST_FNAME_RAW_SZ, bkpinfo->tmpdir);2271 asprintf(&acl_fname, ACL_BIGGLST_FNAME_RAW_SZ, bkpinfo->tmpdir);2268 mr_free(tmp); 2269 2270 mr_asprintf(&tmp, "Reassembling large files "); 2271 mr_asprintf(&xattr_fname, XATTR_BIGGLST_FNAME_RAW_SZ, bkpinfo->tmpdir); 2272 mr_asprintf(&acl_fname, ACL_BIGGLST_FNAME_RAW_SZ, bkpinfo->tmpdir); 2272 2273 mvaddstr_and_log_it(g_currentY, 0, tmp); 2273 paranoid_free(tmp);2274 2275 asprintf(&biggies_whose_EXATs_we_should_set,2274 mr_free(tmp); 2275 2276 mr_asprintf(&biggies_whose_EXATs_we_should_set, 2276 2277 "%s/biggies-whose-EXATs-we-should-set", bkpinfo->tmpdir); 2277 2278 if (!(fbw = fopen(biggies_whose_EXATs_we_should_set, "w"))) { … … 2290 2291 2291 2292 noof_biggiefiles = atol(biggie_fname); 2292 asprintf(&tmp, "OK, there are %ld biggiefiles in the archives",2293 mr_asprintf(&tmp, "OK, there are %ld biggiefiles in the archives", 2293 2294 noof_biggiefiles); 2294 2295 log_msg(2, tmp); 2295 paranoid_free(tmp);2296 mr_free(tmp); 2296 2297 2297 2298 open_progress_form(_("Reassembling large files"), … … 2319 2320 } 2320 2321 */ 2321 asprintf(&tmp, _("Restoring big file %ld (%lld K)"),2322 mr_asprintf(&tmp, _("Restoring big file %ld (%lld K)"), 2322 2323 current_bigfile_number + 1, biggie_size / 1024); 2323 2324 update_progress_form(tmp); 2324 paranoid_free(tmp);2325 mr_free(tmp); 2325 2326 2326 2327 pathname_of_last_biggie_restored = restore_a_biggiefile_from_stream(bkpinfo, biggie_fname, … … 2332 2333 fprintf(fbw, "%s\n", pathname_of_last_biggie_restored); 2333 2334 } 2334 paranoid_free(pathname_of_last_biggie_restored);2335 mr_free(pathname_of_last_biggie_restored); 2335 2336 2336 2337 retval += res; … … 2340 2341 if (current_bigfile_number != noof_biggiefiles 2341 2342 && noof_biggiefiles != 0) { 2342 asprintf(&tmp, "Warning - bigfileno=%ld but noof_biggiefiles=%ld\n",2343 mr_asprintf(&tmp, "Warning - bigfileno=%ld but noof_biggiefiles=%ld\n", 2343 2344 current_bigfile_number, noof_biggiefiles); 2344 2345 } else { 2345 asprintf(&tmp,2346 mr_asprintf(&tmp, 2346 2347 "%ld biggiefiles in biggielist.txt; %ld biggiefiles processed today.", 2347 2348 noof_biggiefiles, current_bigfile_number); 2348 2349 } 2349 2350 log_msg(1, tmp); 2350 paranoid_free(tmp);2351 mr_free(tmp); 2351 2352 2352 2353 if (fbw) { … … 2370 2371 } 2371 2372 } 2372 paranoid_free(xattr_fname);2373 paranoid_free(acl_fname);2374 paranoid_free(biggies_whose_EXATs_we_should_set);2373 mr_free(xattr_fname); 2374 mr_free(acl_fname); 2375 mr_free(biggies_whose_EXATs_we_should_set); 2375 2376 2376 2377 if (does_file_exist("/PAUSE")) { … … 2386 2387 mvaddstr_and_log_it(g_currentY++, 74, _("Done.")); 2387 2388 } 2388 paranoid_free(biggie_fname);2389 mr_free(biggie_fname); 2389 2390 return (retval); 2390 2391 } … … 2428 2429 read_cfg_var(g_mondo_cfg_file, "last-filelist-number", tmp); 2429 2430 max_val = atol(tmp) + 1; 2430 paranoid_free(tmp);2431 mr_free(tmp); 2431 2432 2432 2433 chdir(bkpinfo->restore_path); /* I don't know why this is needed _here_ but it seems to be. -HR, 02/04/2002 */ … … 2434 2435 run_program_and_log_output("pwd", 5); 2435 2436 2436 asprintf(&progress_str, _("Restoring from media #%d"),2437 mr_asprintf(&progress_str, _("Restoring from media #%d"), 2437 2438 g_current_media_number); 2438 2439 log_to_screen(progress_str); … … 2456 2457 while (ctrl_chr != BLK_STOP_AFIOBALLS) { 2457 2458 update_progress_form(progress_str); 2458 asprintf(&xattr_fname, "%s/xattr-subset-%ld.tmp", bkpinfo->tmpdir,2459 mr_asprintf(&xattr_fname, "%s/xattr-subset-%ld.tmp", bkpinfo->tmpdir, 2459 2460 current_afioball_number); 2460 asprintf(&acl_fname, "%s/acl-subset-%ld.tmp", bkpinfo->tmpdir,2461 mr_asprintf(&acl_fname, "%s/acl-subset-%ld.tmp", bkpinfo->tmpdir, 2461 2462 current_afioball_number); 2462 2463 unlink(xattr_fname); … … 2473 2474 } 2474 2475 /* BERLIOS: useless ? 2475 asprintf(&tmp,2476 mr_asprintf(&tmp, 2476 2477 _("Restoring from fileset #%ld (name=%s, size=%ld K)"), 2477 2478 current_afioball_number, tmp_fname, (long) tmp_size >> 10); … … 2484 2485 retval += res; 2485 2486 if (res) { 2486 asprintf(&tmp, _("Fileset %ld - errors occurred"),2487 mr_asprintf(&tmp, _("Fileset %ld - errors occurred"), 2487 2488 current_afioball_number); 2488 2489 log_to_screen(tmp); 2489 paranoid_free(tmp);2490 mr_free(tmp); 2490 2491 } 2491 2492 res = … … 2498 2499 g_current_progress++; 2499 2500 2500 paranoid_free(progress_str);2501 asprintf(&progress_str, _("Restoring from fileset #%ld on %s #%d"),2501 mr_free(progress_str); 2502 mr_asprintf(&progress_str, _("Restoring from fileset #%ld on %s #%d"), 2502 2503 current_afioball_number, 2503 2504 bkpinfo->backup_media_string, … … 2507 2508 unlink(xattr_fname); 2508 2509 unlink(acl_fname); 2509 paranoid_free(xattr_fname);2510 paranoid_free(acl_fname);2510 mr_free(xattr_fname); 2511 mr_free(acl_fname); 2511 2512 } // next 2512 paranoid_free(progress_str);2513 paranoid_free(tmp_fname);2513 mr_free(progress_str); 2514 mr_free(tmp_fname); 2514 2515 2515 2516 log_msg(1, "All done with afioballs"); … … 2555 2556 /* BERLIOS: should test return value, or better change the function */ 2556 2557 getcwd(cwd, MAX_STR_LEN - 1); 2557 asprintf(&tmp, "mkdir -p %s", bkpinfo->restore_path);2558 mr_asprintf(&tmp, "mkdir -p %s", bkpinfo->restore_path); 2558 2559 run_program_and_log_output(tmp, FALSE); 2559 paranoid_free(tmp);2560 mr_free(tmp); 2560 2561 2561 2562 log_msg(1, "Changing dir to %s", bkpinfo->restore_path); … … 2572 2573 newtRefresh(); 2573 2574 } 2574 paranoid_free(tmp);2575 mr_free(tmp); 2575 2576 2576 2577 mvaddstr_and_log_it(g_currentY, 0, … … 2613 2614 kill_petris(); 2614 2615 log_msg(2, "restore_everything() --- leaving"); 2615 paranoid_free(cwd);2616 paranoid_free(newpath);2616 mr_free(cwd); 2617 mr_free(newpath); 2617 2618 return (resA + resB); 2618 2619 } … … 2715 2716 g_text_mode = FALSE; 2716 2717 } // newt :-) 2717 paranoid_free(tmp);2718 mr_free(tmp); 2718 2719 2719 2720 if (! … … 2732 2733 2733 2734 g_mondo_home = call_program_and_get_last_line_of_output("which mondorestore"); 2734 paranoid_alloc(g_tmpfs_mountpt, "/tmp/tmpfs");2735 mr_allocstr(g_tmpfs_mountpt, "/tmp/tmpfs"); 2735 2736 make_hole_for_dir(g_tmpfs_mountpt); 2736 2737 g_current_media_number = 1; // precaution … … 2757 2758 2758 2759 /* Backup original mountlist.txt */ 2759 asprintf(&tmp, "%s.orig", g_mountlist_fname);2760 mr_asprintf(&tmp, "%s.orig", g_mountlist_fname); 2760 2761 if (!does_file_exist(g_mountlist_fname)) { 2761 2762 log_msg(2, … … 2763 2764 __LINE__, g_mountlist_fname); 2764 2765 } else if (!does_file_exist(tmp)) { 2765 paranoid_free(tmp);2766 asprintf(&tmp, "cp -f %s %s.orig", g_mountlist_fname,2766 mr_free(tmp); 2767 mr_asprintf(&tmp, "cp -f %s %s.orig", g_mountlist_fname, 2767 2768 g_mountlist_fname); 2768 2769 run_program_and_log_output(tmp, FALSE); 2769 2770 } 2770 paranoid_free(tmp);2771 mr_free(tmp); 2771 2772 2772 2773 /* Init directories */ 2773 2774 make_hole_for_dir(bkpinfo->tmpdir); 2774 asprintf(&tmp, "mkdir -p %s", bkpinfo->tmpdir);2775 mr_asprintf(&tmp, "mkdir -p %s", bkpinfo->tmpdir); 2775 2776 run_program_and_log_output(tmp, FALSE); 2776 paranoid_free(tmp);2777 mr_free(tmp); 2777 2778 2778 2779 make_hole_for_dir("/var/log"); … … 2805 2806 load_raidtab_into_raidlist(raidlist, RAIDTAB_FNAME); 2806 2807 if (!does_file_exist(g_mountlist_fname)) { 2807 paranoid_alloc(g_mountlist_fname, "/tmp/mountlist.txt");2808 mr_allocstr(g_mountlist_fname, "/tmp/mountlist.txt"); 2808 2809 } 2809 2810 res = let_user_edit_the_mountlist(bkpinfo, mountlist, raidlist); … … 2832 2833 bkpinfo->compression_level = 1; 2833 2834 g_current_media_number = 2; 2834 paranoid_alloc(bkpinfo->restore_path, "/tmp/TESTING");2835 mr_allocstr(bkpinfo->restore_path, "/tmp/TESTING"); 2835 2836 bkpinfo->backup_media_type = dvd; 2836 paranoid_free(bkpinfo->backup_media_string);2837 mr_free(bkpinfo->backup_media_string); 2837 2838 bkpinfo->backup_media_string = bkptype_to_string(bkpinfo->backup_media_type); 2838 2839 open_progress_form(_("Reassembling /dev/hda1"), … … 2859 2860 // finish(0); 2860 2861 // toggle_path_selection (filelist, "/root/stuff", TRUE); 2861 asprintf(&a, argv[3]);2862 asprintf(&b, argv[4]);2862 mr_asprintf(&a, argv[3]); 2863 mr_asprintf(&b, argv[4]); 2863 2864 2864 2865 res = save_filelist_entries_in_common(a, filelist, b, FALSE); 2865 2866 free_filelist(filelist); 2866 paranoid_free(a);2867 paranoid_free(b);2867 mr_free(a); 2868 mr_free(b); 2868 2869 printf("res = %d", res); 2869 2870 finish(0); … … 2944 2945 log_msg(2, "Still here. Yay."); 2945 2946 if (strlen(bkpinfo->tmpdir) > 0) { 2946 asprintf(&tmp, "rm -Rf %s/*", bkpinfo->tmpdir);2947 mr_asprintf(&tmp, "rm -Rf %s/*", bkpinfo->tmpdir); 2947 2948 run_program_and_log_output(tmp, FALSE); 2948 paranoid_free(tmp);2949 mr_free(tmp); 2949 2950 } 2950 2951 unmount_boot_if_necessary(); /* for Gentoo users */ … … 2960 2961 2961 2962 iamhere("About to call load_mountlist and load_raidtab"); 2962 paranoid_alloc(bkpinfo->restore_path, MNT_RESTORING);2963 mr_allocstr(bkpinfo->restore_path, MNT_RESTORING); 2963 2964 read_cfg_file_into_bkpinfo(g_mondo_cfg_file, bkpinfo); 2964 2965 retval = load_mountlist(mountlist, g_mountlist_fname); … … 2973 2974 && !is_this_device_mounted(bkpinfo->nfs_mount)) { 2974 2975 log_msg(1, "Mounting nfs dir"); 2975 paranoid_alloc(bkpinfo->isodir, "/tmp/isodir");2976 mr_allocstr(bkpinfo->isodir, "/tmp/isodir"); 2976 2977 run_program_and_log_output("mkdir -p /tmp/isodir", 5); 2977 asprintf(&tmp, "mount %s -t nfs -o nolock /tmp/isodir",2978 mr_asprintf(&tmp, "mount %s -t nfs -o nolock /tmp/isodir", 2978 2979 bkpinfo->nfs_mount); 2979 2980 run_program_and_log_output(tmp, 1); 2980 paranoid_free(tmp);2981 mr_free(tmp); 2981 2982 } 2982 2983 } … … 2995 2996 log_msg(0, "Partitioning only."); 2996 2997 load_raidtab_into_raidlist(raidlist, RAIDTAB_FNAME); 2997 paranoid_alloc(g_mountlist_fname, "/tmp/mountlist.txt");2998 mr_allocstr(g_mountlist_fname, "/tmp/mountlist.txt"); 2998 2999 load_mountlist(mountlist, g_mountlist_fname); 2999 3000 res = partition_everything(mountlist); … … 3004 3005 log_msg(0, "Formatting only."); 3005 3006 load_raidtab_into_raidlist(raidlist, RAIDTAB_FNAME); 3006 paranoid_alloc(g_mountlist_fname, "/tmp/mountlist.txt");3007 mr_allocstr(g_mountlist_fname, "/tmp/mountlist.txt"); 3007 3008 load_mountlist(mountlist, g_mountlist_fname); 3008 3009 res = format_everything(mountlist, FALSE, raidlist); … … 3013 3014 log_msg(0, "Stopping LVM and RAID"); 3014 3015 load_raidtab_into_raidlist(raidlist, RAIDTAB_FNAME); 3015 paranoid_alloc(g_mountlist_fname, "/tmp/mountlist.txt");3016 mr_allocstr(g_mountlist_fname, "/tmp/mountlist.txt"); 3016 3017 load_mountlist(mountlist, g_mountlist_fname); 3017 3018 res = do_my_funky_lvm_stuff(TRUE, FALSE); … … 3139 3140 unlink("/tmp/mondo-run-prog.tmp"); 3140 3141 set_signals(FALSE); 3141 asprintf(&tmp, "rm -Rf %s", bkpinfo->tmpdir);3142 mr_asprintf(&tmp, "rm -Rf %s", bkpinfo->tmpdir); 3142 3143 run_program_and_log_output(tmp, FALSE); 3143 paranoid_free(tmp);3144 mr_free(tmp); 3144 3145 3145 3146 log_to_screen 3146 3147 (_ 3147 3148 ("Restore log copied to /tmp/mondo-restore.log on your hard disk")); 3148 asprintf(&tmp,3149 mr_asprintf(&tmp, 3149 3150 _ 3150 3151 ("Mondo-restore is exiting (retval=%d) "), 3151 3152 retval); 3152 3153 log_to_screen(tmp); 3153 paranoid_free(tmp);3154 3155 asprintf(&tmp, "umount %s", bkpinfo->isodir);3154 mr_free(tmp); 3155 3156 mr_asprintf(&tmp, "umount %s", bkpinfo->isodir); 3156 3157 run_program_and_log_output(tmp, 5); 3157 paranoid_free(tmp);3158 3159 paranoid_free(mountlist);3160 paranoid_free(raidlist);3158 mr_free(tmp); 3159 3160 mr_free(mountlist); 3161 mr_free(raidlist); 3161 3162 if (am_I_in_disaster_recovery_mode()) { 3162 3163 run_program_and_log_output("mount / -o remount,rw", 2); -
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 } -
trunk/mondo/src/mondorestore/mondo-rstr-newt.c
r783 r900 16 16 17 17 #include "mondo-rstr-newt.h" 18 #include "mr_mem.h" 18 19 19 20 /** … … 78 79 (_ 79 80 (" Add one of the following unallocated RAID partitions to this RAID device.")); 80 asprintf(&tmp, "%-26s %s", _("Device"), _("Size"));81 mr_asprintf(&tmp, "%-26s %s", _("Device"), _("Size")); 81 82 headerMsg = newtLabel(1, 1, tmp); 82 paranoid_free(tmp);83 mr_free(tmp); 83 84 84 85 partitionsListbox = … … 167 168 assert(keylist != NULL); 168 169 169 asprintf(&device_str, "/dev/");170 asprintf(&mountpoint_str, "/");170 mr_asprintf(&device_str, "/dev/"); 171 mr_asprintf(&mountpoint_str, "/"); 171 172 #ifdef __FreeBSD__ 172 asprintf(&format_str, "ufs");173 mr_asprintf(&format_str, "ufs"); 173 174 #else 174 asprintf(&format_str, "ext2");175 mr_asprintf(&format_str, "ext2"); 175 176 #endif 176 177 newtOpenWindow(20, 5, 48, 10, _("Add entry")); … … 199 200 b_res = newtRunForm(myForm); 200 201 201 paranoid_free(device_str);202 asprintf(&device_str, device_here);202 mr_free(device_str); 203 mr_asprintf(&device_str, device_here); 203 204 strip_spaces(device_str); 204 205 205 paranoid_free(format_str);206 asprintf(&format_str, format_here);206 mr_free(format_str); 207 mr_asprintf(&format_str, format_here); 207 208 strip_spaces(format_str); 208 209 209 paranoid_free(mountpoint_str);210 asprintf(&mountpoint_str, mountpoint_here);210 mr_free(mountpoint_str); 211 mr_asprintf(&mountpoint_str, mountpoint_here); 211 212 strip_spaces(mountpoint_str); 212 213 213 paranoid_free(size_str);214 asprintf(&size_str, size_here);214 mr_free(size_str); 215 mr_asprintf(&size_str, size_here); 215 216 strip_spaces(size_str); 216 217 … … 234 235 return; 235 236 } 236 asprintf(&drive_to_add, device_str);237 mr_asprintf(&drive_to_add, device_str); 237 238 for (i = strlen(drive_to_add); isdigit(drive_to_add[i - 1]); i--); 238 239 num_to_add = atoi(drive_to_add + i); 239 240 drive_to_add[i] = '\0'; 240 paranoid_free(drive_to_add);241 mr_free(drive_to_add); 241 242 242 243 currline = mountlist->entries; 243 244 strcpy(mountlist->el[currline].device, device_str); 244 245 strcpy(mountlist->el[currline].mountpoint, mountpoint_str); 245 paranoid_free(mountpoint_str);246 mr_free(mountpoint_str); 246 247 247 248 strcpy(mountlist->el[currline].format, format_str); 248 paranoid_free(format_str);249 mr_free(format_str); 249 250 250 251 mountlist->el[currline].size = atol(size_str) * 1024; 251 paranoid_free(size_str);252 mr_free(size_str); 252 253 253 254 mountlist->entries++; … … 256 257 device_str); 257 258 } 258 paranoid_free(device_str);259 mr_free(device_str); 259 260 redraw_mountlist(mountlist, keylist, listbox); 260 261 } … … 296 297 } 297 298 } 298 paranoid_free(sz_out);299 mr_free(sz_out); 299 300 } 300 301 #endif … … 335 336 && strcmp(raidlist->el[i].volname, basename(raid_device)); i++); 336 337 if (i == raidlist->entries) { 337 asprintf(&tmp,338 mr_asprintf(&tmp, 338 339 "Cannot calc size of raid device %s - cannot find it in raidlist", 339 340 raid_device); 340 341 log_it(tmp); 341 paranoid_free(tmp);342 mr_free(tmp); 342 343 return (0); // Isn't this more sensible than 999999999? If the raid dev !exists, 343 344 // then it has no size, right? … … 351 352 int k = 0, l = 0; 352 353 for (k = 0; k < raidrec->plex[j].subdisks; ++k) { 353 asprintf(&devname, raidrec->plex[j].sd[k].which_device);354 mr_asprintf(&devname, raidrec->plex[j].sd[k].which_device); 354 355 for (l = 0; l < raidlist->disks.entries; ++l) { 355 356 if (!strcmp(devname, raidlist->disks.el[l].name)) { … … 379 380 } 380 381 } 381 paranoid_free(devname);382 mr_free(devname); 382 383 } 383 384 … … 400 401 } 401 402 402 asprintf(&tmp, "I have calculated %s's real size to be %ld",403 mr_asprintf(&tmp, "I have calculated %s's real size to be %ld", 403 404 raid_device, (long) smallest_plex); 404 405 log_it(tmp); 405 paranoid_free(tmp);406 mr_free(tmp); 406 407 return (smallest_plex); 407 408 #else … … 431 432 && strcmp(raidlist->el[i].raid_device, raid_device); i++); 432 433 if (i == raidlist->entries) { 433 asprintf(&tmp,434 mr_asprintf(&tmp, 434 435 "Cannot calc size of raid device %s - cannot find it in raidlist", 435 436 raid_device); 436 437 log_it(tmp); 437 paranoid_free(tmp);438 mr_free(tmp); 438 439 return (999999999); 439 440 } … … 458 459 total_size = smallest_partition * (noof_partitions - 1); 459 460 } 460 asprintf(&tmp, "I have calculated %s's real size to be %ld",461 mr_asprintf(&tmp, "I have calculated %s's real size to be %ld", 461 462 raid_device, (long) total_size); 462 463 log_it(tmp); 463 paranoid_free(tmp);464 mr_free(tmp); 464 465 return (total_size); 465 466 #endif … … 487 488 char *sz = NULL; 488 489 489 asprintf(&prompt,490 mr_asprintf(&prompt, 490 491 _ 491 492 ("Please enter the RAID level you want. (concat, striped, raid5)")); 492 493 if (raidrec->raidlevel == -1) { 493 asprintf(&tmp, "concat");494 mr_asprintf(&tmp, "concat"); 494 495 } else if (raidrec->raidlevel == 0) { 495 asprintf(&tmp, "striped");496 mr_asprintf(&tmp, "striped"); 496 497 } else { 497 asprintf(&tmp, "raid%i", raidrec->raidlevel);498 mr_asprintf(&tmp, "raid%i", raidrec->raidlevel); 498 499 } 499 500 for (out = 999; out == 999;) { … … 504 505 /* BERLIOS: Useless ??? 505 506 if (tmp[0] == '[' && tmp[strlen(tmp) - 1] == ']') { 506 asprintf(&sz, tmp);507 mr_asprintf(&sz, tmp); 507 508 strncpy(tmp, sz + 1, strlen(sz) - 2); 508 509 tmp[strlen(sz) - 2] = '\0'; 509 paranoid_free(sz);510 mr_free(sz); 510 511 } 511 512 */ … … 518 519 } 519 520 log_it(tmp); 520 paranoid_free(tmp);521 mr_free(tmp); 521 522 if (is_this_raid_personality_registered(out)) { 522 523 log_it … … 530 531 } 531 532 } 532 paranoid_free(prompt);533 mr_free(prompt); 533 534 raidrec->raidlevel = out; 534 535 #else … … 544 545 ("grep Pers /proc/mdstat > /tmp/raid-personalities.txt 2> /dev/null"); 545 546 personalities = last_line_of_file("/tmp/raid-personalities.txt"); 546 asprintf(&prompt, _("Please enter the RAID level you want. %s"),547 mr_asprintf(&prompt, _("Please enter the RAID level you want. %s"), 547 548 personalities); 548 paranoid_free(personalities);549 mr_free(personalities); 549 550 550 551 if (raidrec->raid_level == -1) { 551 asprintf(&tmp, "linear");552 mr_asprintf(&tmp, "linear"); 552 553 } else { 553 asprintf(&tmp, "%d", raidrec->raid_level);554 mr_asprintf(&tmp, "%d", raidrec->raid_level); 554 555 } 555 556 for (out = 999; … … 563 564 /* BERLIOS: Useless ??? 564 565 if (tmp[0] == '[' && tmp[strlen(tmp) - 1] == ']') { 565 asprintf(&sz, tmp);566 paranoid_free(tmp);567 568 asprintf(&tmp, sz + 1);566 mr_asprintf(&sz, tmp); 567 mr_free(tmp); 568 569 mr_asprintf(&tmp, sz + 1); 569 570 tmp[strlen(sz) - 2] = '\0'; 570 paranoid_free(sz);571 mr_free(sz); 571 572 } 572 573 */ … … 591 592 } 592 593 } 593 paranoid_free(tmp);594 paranoid_free(prompt);594 mr_free(tmp); 595 mr_free(prompt); 595 596 raidrec->raid_level = out; 596 597 #endif … … 659 660 assert_string_is_neither_NULL_nor_zerolength(raid_device); 660 661 661 asprintf(&tmp, _("Delete %s from RAID device %s - are you sure?"),662 mr_asprintf(&tmp, _("Delete %s from RAID device %s - are you sure?"), 662 663 disklist->el[currline].device, raid_device); 663 664 if (!ask_me_yes_or_no(tmp)) { 664 paranoid_free(tmp);665 mr_free(tmp); 665 666 return; 666 667 } 667 paranoid_free(tmp);668 mr_free(tmp); 668 669 for (pos = currline; pos < disklist->entries - 1; pos++) { 669 670 /* memcpy((void*)&disklist->el[pos], (void*)&disklist->el[pos+1], sizeof(struct s_disk)); */ … … 707 708 device); 708 709 if (pos >= 0) { 709 asprintf(&tmp,710 mr_asprintf(&tmp, 710 711 _("Cannot delete %s: it is in use by RAID device %s"), 711 712 mountlist->el[currline].device, 712 713 raidlist->el[pos].OSSWAP(raid_device, volname)); 713 714 popup_and_OK(tmp); 714 paranoid_free(tmp);715 mr_free(tmp); 715 716 return; 716 717 } 717 asprintf(&tmp, _("Delete %s - are you sure?"),718 mr_asprintf(&tmp, _("Delete %s - are you sure?"), 718 719 mountlist->el[currline].device); 719 720 if (!ask_me_yes_or_no(tmp)) { 720 paranoid_free(tmp);721 mr_free(tmp); 721 722 return; 722 723 } 723 paranoid_free(tmp);724 mr_free(tmp); 724 725 725 726 if (strstr(mountlist->el[currline].device, RAID_DEVICE_STUB)) { 726 asprintf(&device, mountlist->el[currline].device);727 mr_asprintf(&device, mountlist->el[currline].device); 727 728 delete_raidlist_entry(mountlist, raidlist, device); 728 729 for (currline = 0; … … 732 733 if (currline == mountlist->entries) { 733 734 log_it("Dev is gone. I can't delete it. Ho-hum"); 734 paranoid_free(device);735 mr_free(device); 735 736 return; 736 737 } 737 paranoid_free(device);738 mr_free(device); 738 739 } 739 740 memcpy((void *) &mountlist->el[currline], … … 775 776 return; 776 777 } 777 asprintf(&tmp,778 mr_asprintf(&tmp, 778 779 _("Do you want me to delete %s's partitions, too?"), device); 779 780 delete_partitions_too = ask_me_yes_or_no(tmp); … … 820 821 items--; 821 822 } 822 paranoid_free(tmp);823 mr_free(tmp); 823 824 824 825 raidlist->entries = items; … … 845 846 846 847 av = &raidrec->additional_vars; 847 asprintf(&tmp, _("Delete %s - are you sure?"), av->el[lino].label);848 mr_asprintf(&tmp, _("Delete %s - are you sure?"), av->el[lino].label); 848 849 if (ask_me_yes_or_no(tmp)) { 849 850 if (!strcmp(av->el[lino].label, "persistent-superblock") 850 851 || !strcmp(av->el[lino].label, "chunk-size")) { 851 paranoid_free(tmp);852 asprintf(&tmp, _("%s must not be deleted. It would be bad."),852 mr_free(tmp); 853 mr_asprintf(&tmp, _("%s must not be deleted. It would be bad."), 853 854 av->el[lino].label); 854 855 popup_and_OK(tmp); 855 856 } else { 856 paranoid_free(av->el[lino].label);857 paranoid_free(av->el[lino].value);857 mr_free(av->el[lino].label); 858 mr_free(av->el[lino].value); 858 859 memcpy((void *) &av->el[lino], (void *) &av->el[av->entries--], 859 860 sizeof(struct raid_var_line)); … … 864 865 } 865 866 } 866 paranoid_free(tmp);867 mr_free(tmp); 867 868 } 868 869 #endif … … 924 925 if (!warned_already) { 925 926 warned_already = TRUE; 926 asprintf(&tmp,927 mr_asprintf(&tmp, 927 928 _ 928 929 ("Too many lines. Displaying first %d entries only. Close a directory to see more."), 929 930 ARBITRARY_MAXIMUM); 930 931 popup_and_OK(tmp); 931 paranoid_free(tmp);932 mr_free(tmp); 932 933 } 933 934 } else { … … 948 949 (g_strings_of_flist_window[i], 949 950 g_strings_of_flist_window[i - 1]) < 0) { 950 asprintf(&tmp, g_strings_of_flist_window[i]);951 mr_asprintf(&tmp, g_strings_of_flist_window[i]); 951 952 strcpy(g_strings_of_flist_window[i], 952 953 g_strings_of_flist_window[i - 1]); 953 954 strcpy(g_strings_of_flist_window[i - 1], tmp); 954 paranoid_free(tmp);955 mr_free(tmp); 955 956 956 957 dummybool = g_is_path_selected[i]; … … 963 964 newtListboxClear(listbox); 964 965 for (i = 0; i < lines_in_flist_window; i++) { 965 asprintf(&tmp, "%c%c %-80s",966 mr_asprintf(&tmp, "%c%c %-80s", 966 967 (g_is_path_selected[i] ? '*' : ' '), 967 968 (g_is_path_expanded[i] ? '+' : '-'), … … 973 974 keylist[i] = (void *) i; 974 975 newtListboxAppendEntry(listbox, tmp, keylist[i]); 975 paranoid_free(tmp);976 mr_free(tmp); 976 977 } 977 978 return (lines_in_flist_window); … … 1223 1224 memcpy((void *) &bkp_raidlist, (void *) raidlist, 1224 1225 sizeof(struct raidlist_itself)); 1225 asprintf(&device_str, mountlist->el[currline].device);1226 asprintf(&device_used_to_be, mountlist->el[currline].device);1227 asprintf(&mountpoint_str, mountlist->el[currline].mountpoint);1228 asprintf(&mountpt_used_to_be, mountlist->el[currline].mountpoint);1229 asprintf(&format_str, mountlist->el[currline].format);1230 asprintf(&size_str, "%lld", mountlist->el[currline].size / 1024);1226 mr_asprintf(&device_str, mountlist->el[currline].device); 1227 mr_asprintf(&device_used_to_be, mountlist->el[currline].device); 1228 mr_asprintf(&mountpoint_str, mountlist->el[currline].mountpoint); 1229 mr_asprintf(&mountpt_used_to_be, mountlist->el[currline].mountpoint); 1230 mr_asprintf(&format_str, mountlist->el[currline].format); 1231 mr_asprintf(&size_str, "%lld", mountlist->el[currline].size / 1024); 1231 1232 1232 1233 newtOpenWindow(20, 5, 48, 10, "Edit entry"); … … 1237 1238 deviceComp = 1238 1239 newtEntry(14, 1, device_str, 30, (void *) &device_here, 0); 1239 paranoid_free(device_str);1240 mr_free(device_str); 1240 1241 1241 1242 mountpointComp = 1242 1243 newtEntry(14, 2, mountpoint_str, 30, (void *) &mountpoint_here, 0); 1243 paranoid_free(mountpoint_str);1244 mr_free(mountpoint_str); 1244 1245 1245 1246 formatComp = 1246 1247 newtEntry(14, 4, format_str, 15, (void *) &format_here, 0); 1247 paranoid_free(format_str);1248 mr_free(format_str); 1248 1249 1249 1250 if (strstr(mountlist->el[currline].device, RAID_DEVICE_STUB) … … 1253 1254 sizeComp = newtEntry(14, 3, size_str, 10, (void *) &size_here, 0); 1254 1255 } 1255 paranoid_free(size_str);1256 mr_free(size_str); 1256 1257 1257 1258 bOK = newtButton(2, 6, _(" OK ")); … … 1270 1271 b_res = newtRunForm(myForm); 1271 1272 1272 paranoid_free(device_str);1273 asprintf(&device_str, device_here);1273 mr_free(device_str); 1274 mr_asprintf(&device_str, device_here); 1274 1275 strip_spaces(device_str); 1275 1276 1276 paranoid_free(mountpoint_str);1277 asprintf(&mountpoint_str, mountpoint_here);1277 mr_free(mountpoint_str); 1278 mr_asprintf(&mountpoint_str, mountpoint_here); 1278 1279 strip_spaces(mountpoint_str); 1279 1280 1280 paranoid_free(format_str);1281 asprintf(&format_str, format_here);1282 paranoid_free(format_here);1281 mr_free(format_str); 1282 mr_asprintf(&format_str, format_here); 1283 mr_free(format_here); 1283 1284 strip_spaces(format_str); 1284 1285 if (b_res == bOK && strstr(device_str, RAID_DEVICE_STUB) … … 1295 1296 continue; 1296 1297 } 1297 paranoid_free(mountpt_used_to_be);1298 mr_free(mountpt_used_to_be); 1298 1299 1299 1300 if (!strstr(mountlist->el[currline].device, RAID_DEVICE_STUB) 1300 1301 && strcmp(mountlist->el[currline].mountpoint, "image")) { 1301 asprintf(&size_str, size_here);1302 mr_asprintf(&size_str, size_here); 1302 1303 strip_spaces(size_str); 1303 1304 } else { 1304 asprintf(&size_str, "%ld",1305 mr_asprintf(&size_str, "%ld", 1305 1306 calculate_raid_device_size(mountlist, raidlist, 1306 1307 mountlist->el[currline]. … … 1308 1309 newtLabelSetText(sizeComp, size_str); 1309 1310 } 1310 paranoid_free(size_here);1311 mr_free(size_here); 1311 1312 1312 1313 /* do not let user click RAID button if user has changed device_str */ … … 1325 1326 device); 1326 1327 if (j < 0) { 1327 asprintf(&tmp,1328 mr_asprintf(&tmp, 1328 1329 _ 1329 1330 ("/etc/raidtab does not have an entry for %s; please delete it and add it again"), 1330 1331 mountlist->el[currline].device); 1331 1332 popup_and_OK(tmp); 1332 paranoid_free(tmp);1333 mr_free(tmp); 1333 1334 } else { 1334 1335 log_it(_("edit_raidlist_entry - calling")); … … 1339 1340 } 1340 1341 } 1341 paranoid_free(device_here);1342 paranoid_free(mountpoint_here);1342 mr_free(device_here); 1343 mr_free(mountpoint_here); 1343 1344 1344 1345 newtFormDestroy(myForm); … … 1352 1353 strcpy(mountlist->el[currline].device, device_str); 1353 1354 strcpy(mountlist->el[currline].mountpoint, mountpoint_str); 1354 paranoid_free(mountpoint_str);1355 mr_free(mountpoint_str); 1355 1356 1356 1357 strcpy(mountlist->el[currline].format, format_str); 1357 paranoid_free(format_str);1358 mr_free(format_str); 1358 1359 1359 1360 if (strcmp(mountlist->el[currline].mountpoint, "image")) { … … 1366 1367 } 1367 1368 } 1368 paranoid_free(size_str);1369 mr_free(size_str); 1369 1370 1370 1371 newtListboxSetEntry(listbox, (long) keylist[currline], … … 1397 1398 #endif 1398 1399 redraw_mountlist(mountlist, keylist, listbox); 1399 paranoid_free(device_str);1400 paranoid_free(device_used_to_be);1400 mr_free(device_str); 1401 mr_free(device_used_to_be); 1401 1402 } 1402 1403 … … 1516 1517 memcpy((void *) &bkp_raidrec, (void *) raidrec, 1517 1518 sizeof(struct vinum_volume)); 1518 asprintf(&title_of_editraidForm_window, _("Plexes on %s"),1519 mr_asprintf(&title_of_editraidForm_window, _("Plexes on %s"), 1519 1520 raidrec->volname); 1520 1521 newtPushHelpLine(_(" Please select a plex to edit")); 1521 1522 newtOpenWindow(13, 5, 54, 15, title_of_editraidForm_window); 1522 paranoid_free(title_of_editraidForm_window);1523 mr_free(title_of_editraidForm_window); 1523 1524 1524 1525 for (;;) { 1525 asprintf(&headerstr, "%-14s %-8s %11s %8s", _("Plex"), _("Level",) _("Stripe Size"), _("Subdisks"));1526 mr_asprintf(&headerstr, "%-14s %-8s %11s %8s", _("Plex"), _("Level",) _("Stripe Size"), _("Subdisks")); 1526 1527 1527 1528 bOK = newtCompactButton(2, 13, _(" OK ")); … … 1534 1535 newtListbox(2, 3, 9, NEWT_FLAG_SCROLL | NEWT_FLAG_RETURNEXIT); 1535 1536 plexesHeader = newtLabel(2, 2, headerstr); 1536 paranoid_free(headerstr);1537 mr_free(headerstr); 1537 1538 1538 1539 editraidForm = newtForm(NULL, NULL, 0); … … 1544 1545 switch (raidrec->plex[i].raidlevel) { 1545 1546 case -1: 1546 asprintf(&raidlevel, "concat");1547 mr_asprintf(&raidlevel, "concat"); 1547 1548 break; 1548 1549 case 0: 1549 asprintf(&raidlevel, "striped");1550 mr_asprintf(&raidlevel, "striped"); 1550 1551 break; 1551 1552 case 5: 1552 asprintf(&raidlevel, "raid5");1553 mr_asprintf(&raidlevel, "raid5"); 1553 1554 break; 1554 1555 default: 1555 asprintf(&raidlevel, "raid%i",1556 mr_asprintf(&raidlevel, "raid%i", 1556 1557 raidrec->plex[i].raidlevel); 1557 1558 break; … … 1559 1560 1560 1561 if (raidrec->plex[i].raidlevel == -1) { 1561 asprintf(&chunksize, "N/A");1562 mr_asprintf(&chunksize, "N/A"); 1562 1563 } else { 1563 asprintf(&chunksize, "%dk", raidrec->plex[i].stripesize);1564 mr_asprintf(&chunksize, "%dk", raidrec->plex[i].stripesize); 1564 1565 } 1565 asprintf(&pname, "%s.p%i", raidrec->volname, i);1566 asprintf(&entry, "%-14s %-8s %11s %8d",1566 mr_asprintf(&pname, "%s.p%i", raidrec->volname, i); 1567 mr_asprintf(&entry, "%-14s %-8s %11s %8d", 1567 1568 pname, raidlevel, chunksize, 1568 1569 raidrec->plex[i].subdisks); 1569 paranoid_free(pname);1570 paranoid_free(chunksize);1571 paranoid_free(raidlevel);1570 mr_free(pname); 1571 mr_free(chunksize); 1572 mr_free(raidlevel); 1572 1573 newtListboxAppendEntry(plexesListbox, entry, keylist[i]); 1573 paranoid_free(entry);1574 mr_free(entry); 1574 1575 } 1575 1576 } … … 1592 1593 1593 1594 if (b_res == bDelete) { 1594 asprintf(&msg, _("Are you sure you want to delete %s.p%i?"),1595 mr_asprintf(&msg, _("Are you sure you want to delete %s.p%i?"), 1595 1596 raidrec->volname, currline2); 1596 1597 if (ask_me_yes_or_no(msg)) { … … 1601 1602 raidrec->plexes--; 1602 1603 } 1603 paranoid_free(msg);1604 mr_free(msg); 1604 1605 continue; 1605 1606 } … … 1659 1660 memcpy((void *) bkp_raidrec, (void *) raidrec, 1660 1661 sizeof(struct raid_device_record)); 1661 asprintf(&title_of_editraidForm_window, _("Edit %s"), raidrec->raid_device);1662 mr_asprintf(&title_of_editraidForm_window, _("Edit %s"), raidrec->raid_device); 1662 1663 log_msg(2, "Opening newt window"); 1663 1664 newtOpenWindow(20, 5, 40, 14, title_of_editraidForm_window); 1664 paranoid_free(title_of_editraidForm_window);1665 mr_free(title_of_editraidForm_window); 1665 1666 1666 1667 for (;;) { 1667 1668 log_msg(2, "Main loop"); 1668 asprintf(&sz_raid_level,1669 mr_asprintf(&sz_raid_level, 1669 1670 turn_raid_level_number_to_string(raidrec->raid_level)); 1670 asprintf(&sz_data_disks,1671 mr_asprintf(&sz_data_disks, 1671 1672 number_of_disks_as_string(raidrec->data_disks.entries, 1672 1673 _("data"))); 1673 asprintf(&sz_spare_disks,1674 mr_asprintf(&sz_spare_disks, 1674 1675 number_of_disks_as_string(raidrec->spare_disks.entries, 1675 1676 _("spare"))); 1676 asprintf(&sz_parity_disks,1677 mr_asprintf(&sz_parity_disks, 1677 1678 number_of_disks_as_string(raidrec->parity_disks.entries, 1678 1679 _("parity"))); 1679 asprintf(&sz_failed_disks,1680 mr_asprintf(&sz_failed_disks, 1680 1681 number_of_disks_as_string(raidrec->failed_disks.entries, 1681 1682 _("failed"))); … … 1685 1686 bSelectFailed = newtButton(20, 5, sz_failed_disks); 1686 1687 bChangeRaid = newtButton(1, 9, sz_raid_level); 1687 paranoid_free(sz_raid_level);1688 paranoid_free(sz_data_disks);1689 paranoid_free(sz_spare_disks);1690 paranoid_free(sz_parity_disks);1691 paranoid_free(sz_failed_disks);1688 mr_free(sz_raid_level); 1689 mr_free(sz_data_disks); 1690 mr_free(sz_spare_disks); 1691 mr_free(sz_parity_disks); 1692 mr_free(sz_failed_disks); 1692 1693 1693 1694 bOK = newtButton(16 + (raidrec->raid_level == -1), 9, _(" OK ")); … … 1735 1736 calculate_raid_device_size(mountlist, raidlist, 1736 1737 raidrec->raid_device); 1737 paranoid_free(bkp_raidrec);1738 mr_free(bkp_raidrec); 1738 1739 #endif 1739 1740 } … … 1792 1793 memcpy((void *) &bkp_raidrec, (void *) raidrec, 1793 1794 sizeof(struct vinum_plex)); 1794 asprintf(&title_of_editraidForm_window, "%s.p%i",1795 mr_asprintf(&title_of_editraidForm_window, "%s.p%i", 1795 1796 raidlist->el[currline].volname, currline2); 1796 1797 newtPushHelpLine … … 1798 1799 (" Please select a subdisk to edit, or edit this plex's parameters")); 1799 1800 newtOpenWindow(13, 3, 54, 18, title_of_editraidForm_window); 1800 paranoid_free(title_of_editraidForm_window);1801 mr_free(title_of_editraidForm_window); 1801 1802 1802 1803 for (;;) { 1803 1804 switch (raidrec->raidlevel) { 1804 1805 case -1: 1805 asprintf(&tmp, "concat");1806 mr_asprintf(&tmp, "concat"); 1806 1807 break; 1807 1808 case 0: 1808 asprintf(&tmp, "striped");1809 mr_asprintf(&tmp, "striped"); 1809 1810 break; 1810 1811 case 5: 1811 asprintf(&tmp, "raid5");1812 mr_asprintf(&tmp, "raid5"); 1812 1813 break; 1813 1814 default: 1814 asprintf(&tmp, _("unknown (%i)"), raidrec->raidlevel);1815 mr_asprintf(&tmp, _("unknown (%i)"), raidrec->raidlevel); 1815 1816 break; 1816 1817 } 1817 1818 bLevel = newtCompactButton(2, 2, _(" RAID level ")); 1818 1819 sLevel = newtLabel(19, 2, tmp); 1819 paranoid_free(tmp);1820 mr_free(tmp); 1820 1821 1821 1822 if (raidrec->raidlevel >= 0) { 1822 asprintf(&tmp, "%ik", raidrec->stripesize);1823 mr_asprintf(&tmp, "%ik", raidrec->stripesize); 1823 1824 bStripeSize = newtCompactButton(2, 4, _(" Stripe size ")); 1824 1825 } else { 1825 asprintf(&tmp, "N/A");1826 mr_asprintf(&tmp, "N/A"); 1826 1827 bStripeSize = newtLabel(2, 4, _("Stripe size:")); 1827 1828 } 1828 1829 sStripeSize = newtLabel(19, 4, tmp); 1829 paranoid_free(tmp);1830 mr_free(tmp); 1830 1831 1831 1832 bOK = newtCompactButton(2, 16, _(" OK ")); … … 1854 1855 keylist[i] = (void *) i; 1855 1856 if (i < raidrec->subdisks) { 1856 asprintf(&entry, "%-17s",1857 mr_asprintf(&entry, "%-17s", 1857 1858 find_dev_entry_for_raid_device_name(raidlist, 1858 1859 raidrec-> … … 1860 1861 which_device)); 1861 1862 newtListboxAppendEntry(allocListbox, entry, keylist[i]); 1862 paranoid_free(entry);1863 mr_free(entry); 1863 1864 } 1864 1865 if (i < unallocparts->entries) { 1865 asprintf(&entry, "%-17s", unallocparts->el[i].device);1866 mr_asprintf(&entry, "%-17s", unallocparts->el[i].device); 1866 1867 newtListboxAppendEntry(unallocListbox, entry, keylist[i]); 1867 paranoid_free(entry);1868 mr_free(entry); 1868 1869 } 1869 1870 } … … 1915 1916 choose_raid_level(raidrec); 1916 1917 } else if (b_res == bStripeSize) { 1917 asprintf(&tmp, "%i", raidrec->stripesize);1918 mr_asprintf(&tmp, "%i", raidrec->stripesize); 1918 1919 if (popup_and_get_string 1919 1920 (_("Stripe size"), … … 1921 1922 raidrec->stripesize = atoi(tmp); 1922 1923 } 1923 paranoid_free(tmp);1924 mr_free(tmp); 1924 1925 } else if ((b_res == bAlloc) || (b_res == unallocListbox)) { 1925 1926 if (currline_u <= unallocparts->entries) … … 1969 1970 assert(lino >= 0); 1970 1971 1971 asprintf(&sz_out, raidrec->additional_vars.el[lino].value);1972 asprintf(&header, _("Edit %s"), raidrec->additional_vars.el[lino].label);1973 asprintf(&comment, _("Please set %s's value (currently '%s')"),1972 mr_asprintf(&sz_out, raidrec->additional_vars.el[lino].value); 1973 mr_asprintf(&header, _("Edit %s"), raidrec->additional_vars.el[lino].label); 1974 mr_asprintf(&comment, _("Please set %s's value (currently '%s')"), 1974 1975 raidrec->additional_vars.el[lino].label, sz_out); 1975 1976 if (popup_and_get_string(header, comment, sz_out)) { 1976 paranoid_free(raidrec->additional_vars.el[lino].value);1977 mr_free(raidrec->additional_vars.el[lino].value); 1977 1978 raidrec->additional_vars.el[lino].value = sz_out; 1978 1979 } 1979 paranoid_free(header);1980 paranoid_free(comment);1980 mr_free(header); 1981 mr_free(comment); 1981 1982 } 1982 1983 #endif … … 2043 2044 bCancel = newtCompactButton(i += 12, 17, _("Cancel")); 2044 2045 bOK = newtCompactButton(i += 12, 17, _(" OK ")); 2045 asprintf(&tmp, "%-24s %-24s %-8s %s", _("Device"), _("Mountpoint"),2046 mr_asprintf(&tmp, "%-24s %-24s %-8s %s", _("Device"), _("Mountpoint"), 2046 2047 _("Format"), _("Size (MB)")); 2047 2048 headerMsg = newtLabel(2, 1, tmp); … … 2064 2065 newtLabelSetText(flawsLabelC, flaws_str_C); 2065 2066 2066 paranoid_free(flaws_str_A);2067 paranoid_free(flaws_str_B);2068 paranoid_free(flaws_str_C);2067 mr_free(flaws_str_A); 2068 mr_free(flaws_str_B); 2069 mr_free(flaws_str_C); 2069 2070 2070 2071 b_res = newtRunForm(myForm); … … 2196 2197 memcpy((void *) &bkp_raidrec, (void *) raidrec, 2197 2198 sizeof(struct raid_device_record)); 2198 asprintf(&title_of_window, "Additional variables");2199 mr_asprintf(&title_of_window, "Additional variables"); 2199 2200 newtPushHelpLine 2200 2201 (_ … … 2211 2212 bCancel = newtCompactButton(i += 9, 9, _("Cancel")); 2212 2213 newtOpenWindow(17, 7, 46, 10, title_of_window); 2213 paranoid_free(title_of_window);2214 mr_free(title_of_window); 2214 2215 2215 2216 myForm = newtForm(NULL, NULL, 0); … … 2306 2307 #ifdef __FreeBSD__ 2307 2308 for (i = 0; i < raidlist->entries; i++) { 2308 asprintf(&vdev, "/dev/vinum/%s", raidlist->el[i].volname);2309 mr_asprintf(&vdev, "/dev/vinum/%s", raidlist->el[i].volname); 2309 2310 if (!strcmp(device, vdev)) { 2310 paranoid_free(vdev);2311 mr_free(vdev); 2311 2312 break; 2312 2313 } 2313 paranoid_free(vdev);2314 mr_free(vdev); 2314 2315 } 2315 2316 #else … … 2344 2345 // log_it("%d - AAA - isodir_path = %s", isodir_path); 2345 2346 if (isodir_device == NULL) { 2346 asprintf(&isodir_device, "/dev/");2347 mr_asprintf(&isodir_device, "/dev/"); 2347 2348 } 2348 2349 if (isodir_path == NULL) { 2349 asprintf(&isodir_path, "/");2350 mr_asprintf(&isodir_path, "/"); 2350 2351 } 2351 2352 if (does_file_exist("/tmp/NFS-SERVER-PATH")) { 2352 paranoid_free(isodir_device);2353 mr_free(isodir_device); 2353 2354 isodir_device = last_line_of_file("/tmp/NFS-SERVER-MOUNT"); 2354 asprintf(&isodir_format, "nfs");2355 paranoid_free(isodir_path);2355 mr_asprintf(&isodir_format, "nfs"); 2356 mr_free(isodir_path); 2356 2357 isodir_path = last_line_of_file("/tmp/NFS-SERVER-PATH"); 2357 2358 } … … 2415 2416 raidrec = &raidlist->el[pos_in_raidlist]; 2416 2417 initialize_raidrec(raidrec); 2417 asprintf(&raidrec->OSSWAP(raid_device, volname),2418 mr_asprintf(&raidrec->OSSWAP(raid_device, volname), 2418 2419 OSSWAP(device, basename(device))); 2419 2420 #ifndef __FreeBSD__ … … 2573 2574 } 2574 2575 for (i = 0; i < unallocated_raid_partitions->entries; i++) { 2575 asprintf(&tmp, "%-22s %8lld",2576 mr_asprintf(&tmp, "%-22s %8lld", 2576 2577 unallocated_raid_partitions->el[i].device, 2577 2578 unallocated_raid_partitions->el[i].size / 1024); 2578 2579 newtListboxAppendEntry(listbox, tmp, keylist[i]); 2579 paranoid_free(tmp);2580 mr_free(tmp); 2580 2581 } 2581 2582 } … … 2610 2611 } 2611 2612 for (i = 0; i < additional_vars->entries; i++) { 2612 asprintf(&tmp, "%-32s %-8s", additional_vars->el[i].label,2613 mr_asprintf(&tmp, "%-32s %-8s", additional_vars->el[i].label, 2613 2614 additional_vars->el[i].value); 2614 2615 newtListboxAppendEntry(listbox, tmp, keylist[i]); 2615 paranoid_free(tmp);2616 mr_free(tmp); 2616 2617 } 2617 2618 } … … 2683 2684 pos = which_raid_device_is_using_this_partition(raidlist, old_dev); 2684 2685 if (pos < 0) { 2685 asprintf(&tmp, "No need to rejig %s in raidlist: it's not listed.",2686 mr_asprintf(&tmp, "No need to rejig %s in raidlist: it's not listed.", 2686 2687 old_dev); 2687 2688 log_it(tmp); 2688 paranoid_free(tmp);2689 mr_free(tmp); 2689 2690 } else { 2690 2691 if ((j = … … 2718 2719 #endif 2719 2720 else { 2720 asprintf(&tmp,2721 mr_asprintf(&tmp, 2721 2722 "%s is supposed to be listed in this raid dev but it's not...", 2722 2723 old_dev); 2723 2724 log_it(tmp); 2724 paranoid_free(tmp);2725 mr_free(tmp); 2725 2726 } 2726 2727 } … … 2833 2834 2834 2835 iamhere("Post-malloc"); 2835 asprintf(&help_text,2836 mr_asprintf(&help_text, 2836 2837 _ 2837 2838 (" Edit this RAID device's list of partitions. Choose OK or Cancel when done.")); 2838 asprintf(&header_text, "%-24s %s", _("Device"), _("Index"));2839 asprintf(&title_of_window, _("%s contains..."), raidrec->raid_device);2839 mr_asprintf(&header_text, "%-24s %s", _("Device"), _("Index")); 2840 mr_asprintf(&title_of_window, _("%s contains..."), raidrec->raid_device); 2840 2841 newtPushHelpLine(help_text); 2841 paranoid_free(help_text);2842 mr_free(help_text); 2842 2843 for (b_res = (newtComponent) 12345; b_res != bOK && b_res != bCancel;) { 2843 2844 headerMsg = newtLabel(1, 1, header_text); … … 2896 2897 redraw_disklist(disklist, keylist, partitionsListbox); 2897 2898 } else { 2898 asprintf(&tmp, _("%s's index is %d. What should it be?"),2899 mr_asprintf(&tmp, _("%s's index is %d. What should it be?"), 2899 2900 raidrec->raid_device, 2900 2901 disklist->el[currline].index); 2901 asprintf(&sz_res, "%d", disklist->el[currline].index);2902 mr_asprintf(&sz_res, "%d", disklist->el[currline].index); 2902 2903 if (popup_and_get_string 2903 2904 (_("Set index"), tmp, sz_res)) { 2904 2905 disklist->el[currline].index = atoi(sz_res); 2905 2906 } 2906 paranoid_free(tmp);2907 paranoid_free(sz_res);2907 mr_free(tmp); 2908 mr_free(sz_res); 2908 2909 redraw_disklist(disklist, keylist, partitionsListbox); 2909 2910 } … … 2913 2914 newtPopWindow(); 2914 2915 } 2915 paranoid_free(title_of_window);2916 paranoid_free(header_text);2916 mr_free(title_of_window); 2917 mr_free(header_text); 2917 2918 2918 2919 newtPopHelpLine(); … … 2925 2926 sizeof(struct list_of_disks)); 2926 2927 } 2927 paranoid_free(bkp_raidrec);2928 paranoid_free(bkp_disklist);2929 paranoid_free(bkp_raidlist);2930 paranoid_free(unallocated_raid_partitions);2928 mr_free(bkp_raidrec); 2929 mr_free(bkp_disklist); 2930 mr_free(bkp_raidlist); 2931 mr_free(unallocated_raid_partitions); 2931 2932 } 2932 2933 #endif … … 2960 2961 (_ 2961 2962 ("Which mode - (A)utomatic, (I)nteractive, \n(C)ompare only, or (E)xit to shell?\n--> ")); 2962 getline(&tmp, &n, stdin);2963 } 2964 paranoid_free(tmp);2963 mr_getline(&tmp, &n, stdin); 2964 } 2965 mr_free(tmp); 2965 2966 return (output); 2966 2967 } -
trunk/mondo/src/mondorestore/mondo-rstr-tools.c
r808 r900 13 13 #include <pthread.h> 14 14 #endif 15 #include "mr_mem.h" 15 16 16 17 extern bool g_sigpipe_caught; … … 52 53 void free_MR_global_filenames() 53 54 { 54 paranoid_free(g_biggielist_txt);55 paranoid_free(g_filelist_full);56 paranoid_free(g_filelist_imagedevs);57 paranoid_free(g_imagedevs_restthese);58 paranoid_free(g_mondo_cfg_file);59 paranoid_free(g_mountlist_fname);60 paranoid_free(g_mondo_home);61 paranoid_free(g_tmpfs_mountpt);62 paranoid_free(g_isodir_device);63 paranoid_free(g_isodir_format);55 mr_free(g_biggielist_txt); 56 mr_free(g_filelist_full); 57 mr_free(g_filelist_imagedevs); 58 mr_free(g_imagedevs_restthese); 59 mr_free(g_mondo_cfg_file); 60 mr_free(g_mountlist_fname); 61 mr_free(g_mondo_home); 62 mr_free(g_tmpfs_mountpt); 63 mr_free(g_isodir_device); 64 mr_free(g_isodir_format); 64 65 65 66 } … … 94 95 fatal_error("Cannot openin outfname"); 95 96 } 96 for ( getline(&incoming, &n, fin);97 !feof(fin); getline(&incoming, &n, fin)) {97 for (mr_getline(&incoming, &n, fin); 98 !feof(fin); mr_getline(&incoming, &n, fin)) { 98 99 strip_spaces(incoming); 99 100 … … 102 103 } 103 104 104 asprintf(&question,105 mr_asprintf(&question, 105 106 _("Should I restore the image of %s ?"), incoming); 106 107 … … 108 109 fprintf(fout, "%s\n", incoming); 109 110 } 110 paranoid_free(question);111 mr_free(question); 111 112 } 112 113 113 114 /*** free memory ***********/ 114 paranoid_free(incoming);115 mr_free(incoming); 115 116 116 117 paranoid_fclose(fout); … … 147 148 assert_string_is_neither_NULL_nor_zerolength(output_cfg_file); 148 149 assert_string_is_neither_NULL_nor_zerolength(output_mountlist_file); 149 asprintf(&mountpt, "%s/mount.bootdisk", bkpinfo->tmpdir);150 asprintf(&command, "mkdir -p %s", mountpt);150 mr_asprintf(&mountpt, "%s/mount.bootdisk", bkpinfo->tmpdir); 151 mr_asprintf(&command, "mkdir -p %s", mountpt); 151 152 run_program_and_log_output(command, FALSE); 152 paranoid_free(command);153 154 asprintf(&command, "gzip -dc %s > %s/mindi.rd 2> /dev/null",153 mr_free(command); 154 155 mr_asprintf(&command, "gzip -dc %s > %s/mindi.rd 2> /dev/null", 155 156 ramdisk_fname, bkpinfo->tmpdir); 156 157 run_program_and_log_output(command, FALSE); 157 paranoid_free(command);158 159 asprintf(&command, "umount %s", mountpt);158 mr_free(command); 159 160 mr_asprintf(&command, "umount %s", mountpt); 160 161 run_program_and_log_output(command, FALSE); 161 paranoid_free(command);162 163 asprintf(&command, "mount -o loop %s/mindi.rd -t ext2 %s",162 mr_free(command); 163 164 mr_asprintf(&command, "mount -o loop %s/mindi.rd -t ext2 %s", 164 165 bkpinfo->tmpdir, mountpt); 165 166 run_program_and_log_output(command, FALSE); 166 paranoid_free(command);167 168 asprintf(&command, "mkdir -p %s/tmp", bkpinfo->tmpdir);167 mr_free(command); 168 169 mr_asprintf(&command, "mkdir -p %s/tmp", bkpinfo->tmpdir); 169 170 run_program_and_log_output(command, FALSE); 170 paranoid_free(command);171 172 asprintf(&command, "cp -f %s/%s %s", // %s/%s becomes {mountpt}/tmp/m*ndo-restore.cfg171 mr_free(command); 172 173 mr_asprintf(&command, "cp -f %s/%s %s", // %s/%s becomes {mountpt}/tmp/m*ndo-restore.cfg 173 174 mountpt, g_mondo_cfg_file, output_cfg_file); 174 175 run_program_and_log_output(command, FALSE); 175 paranoid_free(command);176 177 asprintf(&orig_fname, "%s/%s", mountpt, g_mountlist_fname);176 mr_free(command); 177 178 mr_asprintf(&orig_fname, "%s/%s", mountpt, g_mountlist_fname); 178 179 if (does_file_exist(orig_fname)) { 179 asprintf(&command, "cp -f %s %s", orig_fname, output_mountlist_file);180 mr_asprintf(&command, "cp -f %s %s", orig_fname, output_mountlist_file); 180 181 run_program_and_log_output(command, FALSE); 181 paranoid_free(command);182 } 183 asprintf(&command, "umount %s", mountpt);184 paranoid_free(mountpt);182 mr_free(command); 183 } 184 mr_asprintf(&command, "umount %s", mountpt); 185 mr_free(mountpt); 185 186 186 187 run_program_and_log_output(command, FALSE); 187 paranoid_free(command);188 mr_free(command); 188 189 189 190 if (!does_file_exist(output_cfg_file) … … 196 197 retval = 0; 197 198 } 198 paranoid_free(orig_fname);199 mr_free(orig_fname); 199 200 return (retval); 200 201 } … … 240 241 241 242 if (strncmp(preamble, f, strlen(preamble)) == 0) { 242 asprintf(&file, f + strlen(preamble));243 } else { 244 asprintf(&file, f);243 mr_asprintf(&file, f + strlen(preamble)); 244 } else { 245 mr_asprintf(&file, f); 245 246 } 246 247 if (file[0] == '/' && file[1] == '/') { 247 asprintf(&tmp, file);248 paranoid_free(file);249 asprintf(&file, tmp + 1);250 paranoid_free(tmp);251 } 252 asprintf(&tmp,248 mr_asprintf(&tmp, file); 249 mr_free(file); 250 mr_asprintf(&file, tmp + 1); 251 mr_free(tmp); 252 } 253 mr_asprintf(&tmp, 253 254 "Checking to see if f=%s, file=%s, is in the list of biggiefiles", 254 255 f, file); 255 256 log_msg(2, tmp); 256 paranoid_free(tmp);257 258 asprintf(&command, "grep -x \"%s\" %s", file, list_fname);259 paranoid_free(file);257 mr_free(tmp); 258 259 mr_asprintf(&command, "grep -x \"%s\" %s", file, list_fname); 260 mr_free(file); 260 261 261 262 res = run_program_and_log_output(command, FALSE); 262 paranoid_free(command);263 mr_free(command); 263 264 if (res) { 264 265 return (FALSE); … … 292 293 g_ISO_restore_mode = TRUE; 293 294 294 paranoid_free(g_isodir_device);295 mr_free(g_isodir_device); 295 296 read_cfg_var(g_mondo_cfg_file, "iso-dev", g_isodir_device); 296 297 if (bkpinfo->disaster_recovery) { … … 298 299 * Don't let this clobber an existing bkpinfo->isodir */ 299 300 if (!bkpinfo->isodir) { 300 paranoid_alloc(bkpinfo->isodir, "/tmp/isodir");301 mr_allocstr(bkpinfo->isodir, "/tmp/isodir"); 301 302 } 302 303 /* End patch */ 303 asprintf(&command, "mkdir -p %s", bkpinfo->isodir);304 mr_asprintf(&command, "mkdir -p %s", bkpinfo->isodir); 304 305 run_program_and_log_output(command, 5); 305 paranoid_free(command);306 mr_free(command); 306 307 log_msg(2, "Setting isodir to %s", bkpinfo->isodir); 307 308 } … … 319 320 } else { 320 321 if (g_isodir_format != NULL) { 321 asprintf(&mount_isodir_command, "mount %s -t %s -o ro %s", g_isodir_device, g_isodir_format, bkpinfo->isodir);322 mr_asprintf(&mount_isodir_command, "mount %s -t %s -o ro %s", g_isodir_device, g_isodir_format, bkpinfo->isodir); 322 323 } else { 323 asprintf(&mount_isodir_command, "mount %s -o ro %s", g_isodir_device, bkpinfo->isodir);324 mr_asprintf(&mount_isodir_command, "mount %s -o ro %s", g_isodir_device, bkpinfo->isodir); 324 325 } 325 326 run_program_and_log_output("df -m", FALSE); 326 asprintf(&tmp,327 mr_asprintf(&tmp, 327 328 "The 'mount' command is '%s'. PLEASE report this command to be if you have problems, ok?", 328 329 mount_isodir_command); 329 330 log_msg(1, tmp); 330 paranoid_free(tmp);331 mr_free(tmp); 331 332 332 333 if (run_program_and_log_output(mount_isodir_command, FALSE)) { … … 334 335 (_ 335 336 ("Cannot mount the device where the ISO files are stored.")); 336 paranoid_free(mount_isodir_command);337 mr_free(mount_isodir_command); 337 338 return (1); 338 339 } 339 paranoid_free(mount_isodir_command);340 mr_free(mount_isodir_command); 340 341 log_to_screen 341 342 (_ … … 346 347 } 347 348 i = what_number_cd_is_this(bkpinfo); /* has the side-effect of calling mount_cdrom() */ 348 asprintf(&tmp, "%s #%d has been mounted via loopback mount",349 mr_asprintf(&tmp, "%s #%d has been mounted via loopback mount", 349 350 bkpinfo->backup_media_string, i); 350 351 log_msg(1, tmp); 351 paranoid_free(tmp);352 mr_free(tmp); 352 353 353 354 if (i < 0) { … … 368 369 { 369 370 char *command; 370 asprintf(&command,371 mr_asprintf(&command, 371 372 "kill `ps 2> /dev/null | grep petris 2> /dev/null | grep -v grep | cut -d' ' -f2` 2> /dev/null"); 372 373 paranoid_system(command); 373 paranoid_free(command);374 mr_free(command); 374 375 } 375 376 … … 413 414 "Again with the /proc - why is this in your mountlist?"); 414 415 } else if (is_this_device_mounted(mountlist->el[lino].device)) { 415 asprintf(&tmp, _("%s is already mounted"),416 mr_asprintf(&tmp, _("%s is already mounted"), 416 417 mountlist->el[lino].device); 417 418 log_to_screen(tmp); 418 paranoid_free(tmp);419 mr_free(tmp); 419 420 } else if (strcmp(mountlist->el[lino].mountpoint, "none") 420 421 && strcmp(mountlist->el[lino].mountpoint, "lvm") 421 422 && strcmp(mountlist->el[lino].mountpoint, "raid") 422 423 && strcmp(mountlist->el[lino].mountpoint, "image")) { 423 asprintf(&tmp, "Mounting %s", mountlist->el[lino].device);424 mr_asprintf(&tmp, "Mounting %s", mountlist->el[lino].device); 424 425 update_progress_form(tmp); 425 paranoid_free(tmp);426 427 asprintf(&format, mountlist->el[lino].format);426 mr_free(tmp); 427 428 mr_asprintf(&format, mountlist->el[lino].format); 428 429 if (!strcmp(format, "ext3")) { 429 paranoid_free(format);430 asprintf(&format, "ext2");430 mr_free(format); 431 mr_asprintf(&format, "ext2"); 431 432 } 432 433 res = mount_device(mountlist->el[lino].device, … … 436 437 if (res) { 437 438 if (these_failed != NULL) { /* not the first time */ 438 asprintf(&tmp, "%s %s", these_failed, mountlist->el[lino].device);439 paranoid_free(these_failed);439 mr_asprintf(&tmp, "%s %s", these_failed, mountlist->el[lino].device); 440 mr_free(these_failed); 440 441 these_failed = tmp; 441 442 } else { /* The first time */ 442 asprintf(&these_failed, "%s ", mountlist->el[lino].device);443 mr_asprintf(&these_failed, "%s ", mountlist->el[lino].device); 443 444 } 444 445 } 445 paranoid_free(format);446 mr_free(format); 446 447 } 447 448 g_current_progress++; … … 459 460 ("format and restore *without* partitioning first. Sorry for the inconvenience.")); 460 461 } 461 asprintf(&tmp, _("Could not mount devices %s- shall I abort?"),462 mr_asprintf(&tmp, _("Could not mount devices %s- shall I abort?"), 462 463 these_failed); 463 paranoid_free(these_failed);464 mr_free(these_failed); 464 465 465 466 if (!ask_me_yes_or_no(tmp)) { … … 474 475 (_("Unable to mount some or all of your partitions.")); 475 476 } 476 paranoid_free(tmp);477 mr_free(tmp); 477 478 } else { 478 479 log_to_screen(_("All partitions were mounted OK.")); … … 480 481 } 481 482 run_program_and_log_output("df -m", 3); 482 paranoid_free(mountlist);483 mr_free(mountlist); 483 484 return (retval); 484 485 } … … 523 524 if ((!bkpinfo->isodir || !strcmp(bkpinfo->isodir, "/")) 524 525 && am_I_in_disaster_recovery_mode()) { 525 paranoid_alloc(bkpinfo->isodir, "/tmp/isodir");526 mr_allocstr(bkpinfo->isodir, "/tmp/isodir"); 526 527 log_msg(1, "isodir is being set to %s", bkpinfo->isodir); 527 528 } 528 529 #ifdef __FreeBSD__ 529 asprintf(&mount_cmd, "/mnt/isodir/%s/%s/%s-%d.iso", bkpinfo->isodir,530 mr_asprintf(&mount_cmd, "/mnt/isodir/%s/%s/%s-%d.iso", bkpinfo->isodir, 530 531 bkpinfo->nfs_remote_dir, bkpinfo->prefix, 531 532 g_current_media_number); 532 533 mddev = make_vn(mount_cmd); 533 paranoid_free(mount_cmd);534 535 asprintf(&mount_cmd, "mount_cd9660 -r %s " MNT_CDROM, mddev);536 paranoid_free(mddev);534 mr_free(mount_cmd); 535 536 mr_asprintf(&mount_cmd, "mount_cd9660 -r %s " MNT_CDROM, mddev); 537 mr_free(mddev); 537 538 #else 538 asprintf(&mount_cmd,539 mr_asprintf(&mount_cmd, 539 540 "mount %s/%s/%s-%d.iso -t iso9660 -o loop,ro %s", 540 541 bkpinfo->isodir, bkpinfo->nfs_remote_dir, bkpinfo->prefix, … … 544 545 } else if (bkpinfo->backup_media_type == iso) { 545 546 #ifdef __FreeBSD__ 546 asprintf(&mount_cmd, "%s/%s-%d.iso", bkpinfo->isodir,547 mr_asprintf(&mount_cmd, "%s/%s-%d.iso", bkpinfo->isodir, 547 548 bkpinfo->prefix, g_current_media_number); 548 549 mddev = make_vn(mount_cmd); 549 paranoid_free(mount_cmd);550 551 asprintf(&mount_cmd, "mount_cd9660 -r %s %s", mddev, MNT_CDROM);552 paranoid_free(mddev);550 mr_free(mount_cmd); 551 552 mr_asprintf(&mount_cmd, "mount_cd9660 -r %s %s", mddev, MNT_CDROM); 553 mr_free(mddev); 553 554 #else 554 asprintf(&mount_cmd, "mount %s/%s-%d.iso -t iso9660 -o loop,ro %s",555 mr_asprintf(&mount_cmd, "mount %s/%s-%d.iso -t iso9660 -o loop,ro %s", 555 556 bkpinfo->isodir, bkpinfo->prefix, g_current_media_number, 556 557 MNT_CDROM); … … 559 560 #ifdef __FreeBSD__ 560 561 { 561 asprintf(&mount_cmd, "mount_cd9660 -r %s %s", bkpinfo->media_device,562 mr_asprintf(&mount_cmd, "mount_cd9660 -r %s %s", bkpinfo->media_device, 562 563 MNT_CDROM); 563 564 } 564 565 #else 565 566 { 566 asprintf(&mount_cmd, "mount %s -t iso9660 -o ro %s",567 mr_asprintf(&mount_cmd, "mount %s -t iso9660 -o ro %s", 567 568 bkpinfo->media_device, MNT_CDROM); 568 569 } … … 572 573 if (bkpinfo->disaster_recovery 573 574 && does_file_exist("/tmp/CDROM-LIVES-HERE")) { 574 paranoid_free(bkpinfo->media_device);575 mr_free(bkpinfo->media_device); 575 576 bkpinfo->media_device = last_line_of_file("/tmp/CDROM-LIVES-HERE"); 576 577 } else { 577 paranoid_free(bkpinfo->media_device);578 mr_free(bkpinfo->media_device); 578 579 bkpinfo->media_device = find_cdrom_device(TRUE); 579 580 } 580 581 581 582 #ifdef __FreeBSD__ 582 asprintf(&mount_cmd, "mount_cd9660 -r %s %s", bkpinfo->media_device,583 mr_asprintf(&mount_cmd, "mount_cd9660 -r %s %s", bkpinfo->media_device, 583 584 MNT_CDROM); 584 585 #else 585 asprintf(&mount_cmd, "mount %s -t iso9660 -o ro %s",586 mr_asprintf(&mount_cmd, "mount %s -t iso9660 -o ro %s", 586 587 bkpinfo->media_device, MNT_CDROM); 587 588 #endif … … 599 600 } 600 601 } 601 paranoid_free(mount_cmd);602 mr_free(mount_cmd); 602 603 603 604 if (res) { … … 639 640 640 641 if (!strcmp(mpt, "/1")) { 641 asprintf(&mountpoint, "/");642 mr_asprintf(&mountpoint, "/"); 642 643 log_msg(3, "Mommm! SME is being a dildo!"); 643 644 } else { 644 asprintf(&mountpoint, mpt);645 mr_asprintf(&mountpoint, mpt); 645 646 } 646 647 647 648 if (!strcmp(mountpoint, "lvm")) { 648 paranoid_free(mountpoint);649 mr_free(mountpoint); 649 650 return (0); 650 651 } 651 652 if (!strcmp(mountpoint, "image")) { 652 paranoid_free(mountpoint);653 mr_free(mountpoint); 653 654 return (0); 654 655 } 655 asprintf(&tmp, "Mounting device %s ", device);656 mr_asprintf(&tmp, "Mounting device %s ", device); 656 657 log_msg(1, tmp); 657 658 658 659 if (writeable) { 659 asprintf(&p1, "-o rw");660 } else { 661 asprintf(&p1, "-o ro");660 mr_asprintf(&p1, "-o rw"); 661 } else { 662 mr_asprintf(&p1, "-o ro"); 662 663 } 663 664 tmp = find_home_of_exe("setfattr"); 664 665 if (tmp) { 665 asprintf(&p2, ",user_xattr");666 } else { 667 asprintf(&p2, "%s", "");668 } 669 paranoid_free(tmp);666 mr_asprintf(&p2, ",user_xattr"); 667 } else { 668 mr_asprintf(&p2, "%s", ""); 669 } 670 mr_free(tmp); 670 671 671 672 tmp = find_home_of_exe("setfacl"); 672 673 if (tmp) { 673 asprintf(&p3, ",acl");674 } else { 675 asprintf(&p3, "%s", "");676 } 677 paranoid_free(tmp);678 679 asprintf(&additional_parameters, "%s%s%s", p1, p2, p3);680 paranoid_free(p1);681 paranoid_free(p2);682 paranoid_free(p3);674 mr_asprintf(&p3, ",acl"); 675 } else { 676 mr_asprintf(&p3, "%s", ""); 677 } 678 mr_free(tmp); 679 680 mr_asprintf(&additional_parameters, "%s%s%s", p1, p2, p3); 681 mr_free(p1); 682 mr_free(p2); 683 mr_free(p3); 683 684 684 685 if (!strcmp(mountpoint, "swap")) { 685 asprintf(&command, "swapon %s", device);686 mr_asprintf(&command, "swapon %s", device); 686 687 } else { 687 688 if (!strcmp(mountpoint, "/")) { 688 asprintf(&mountdir, MNT_RESTORING);689 mr_asprintf(&mountdir, MNT_RESTORING); 689 690 } else { 690 asprintf(&mountdir, "%s%s", MNT_RESTORING, mountpoint);691 } 692 asprintf(&command, "mkdir -p %s", mountdir);691 mr_asprintf(&mountdir, "%s%s", MNT_RESTORING, mountpoint); 692 } 693 mr_asprintf(&command, "mkdir -p %s", mountdir); 693 694 run_program_and_log_output(command, FALSE); 694 paranoid_free(command);695 696 asprintf(&command, "mount -t %s %s %s %s 2>> %s", format, device,695 mr_free(command); 696 697 mr_asprintf(&command, "mount -t %s %s %s %s 2>> %s", format, device, 697 698 additional_parameters, mountdir, MONDO_LOGFILE); 698 699 log_msg(2, "command='%s'", command); 699 700 } 700 paranoid_free(additional_parameters);701 mr_free(additional_parameters); 701 702 702 703 res = run_program_and_log_output(command, TRUE); 703 704 if (res && (strstr(command, "xattr") || strstr(command, "acl"))) { 704 705 log_msg(1, "Re-trying without the fancy extra parameters"); 705 paranoid_free(command);706 707 asprintf(&command, "mount -t %s %s %s 2>> %s", format, device,706 mr_free(command); 707 708 mr_asprintf(&command, "mount -t %s %s %s 2>> %s", format, device, 708 709 mountdir, MONDO_LOGFILE); 709 710 res = run_program_and_log_output(command, TRUE); … … 717 718 } else { 718 719 log_msg(2, "Retrying w/o the '-t' switch"); 719 paranoid_free(command);720 721 asprintf(&command, "mount %s %s 2>> %s", device, mountdir,720 mr_free(command); 721 722 mr_asprintf(&command, "mount %s %s 2>> %s", device, mountdir, 722 723 MONDO_LOGFILE); 723 724 log_msg(2, "2nd command = '%s'", command); … … 731 732 } 732 733 } 733 paranoid_free(tmp);734 paranoid_free(command);735 paranoid_free(mountdir);734 mr_free(tmp); 735 mr_free(command); 736 mr_free(mountdir); 736 737 737 738 if (res && !strcmp(mountpoint, "swap")) { … … 740 741 res = 0; 741 742 } 742 paranoid_free(mountpoint);743 mr_free(mountpoint); 743 744 744 745 return (res); … … 836 837 } 837 838 } 838 paranoid_free(value);839 mr_free(value); 839 840 840 841 if (read_cfg_var(cfg_file, "iso-prefix", value) == 0) { 841 paranoid_alloc(bkpinfo->prefix,value);842 mr_allocstr(bkpinfo->prefix,value); 842 843 } else { 843 paranoid_alloc(bkpinfo->prefix, STD_PREFIX);844 mr_allocstr(bkpinfo->prefix, STD_PREFIX); 844 845 } 845 846 } else if (!strcmp(value, "nfs")) { 846 847 bkpinfo->backup_media_type = nfs; 847 paranoid_free(value);848 mr_free(value); 848 849 if (read_cfg_var(cfg_file, "iso-prefix", value) == 0) { 849 paranoid_alloc(bkpinfo->prefix,value);850 mr_allocstr(bkpinfo->prefix,value); 850 851 } else { 851 paranoid_alloc(bkpinfo->prefix, STD_PREFIX);852 mr_allocstr(bkpinfo->prefix, STD_PREFIX); 852 853 } 853 854 /* We need to override prefix value in PXE mode as it's … … 868 869 fatal_error("backup-media-type not specified!"); 869 870 } 870 paranoid_free(value);871 mr_free(value); 871 872 872 873 if (bkpinfo->disaster_recovery) { 873 874 if (bkpinfo->backup_media_type == cdstream) { 874 paranoid_alloc(bkpinfo->media_device, "/dev/cdrom");875 mr_allocstr(bkpinfo->media_device, "/dev/cdrom"); 875 876 bkpinfo->media_size[0] = 1999 * 1024; 876 877 bkpinfo->media_size[1] = 650; /* good guess */ 877 878 } else if (bkpinfo->backup_media_type == tape 878 879 || bkpinfo->backup_media_type == udev) { 879 paranoid_free(bkpinfo->media_device);880 mr_free(bkpinfo->media_device); 880 881 if (read_cfg_var(cfg_file, "media-dev", bkpinfo->media_device)) { 881 882 fatal_error("Cannot get tape device name from cfg file"); … … 883 884 read_cfg_var(cfg_file, "media-size", value); 884 885 bkpinfo->media_size[1] = atol(value); 885 paranoid_free(value);886 887 asprintf(&tmp, "Backup medium is TAPE --- dev=%s",886 mr_free(value); 887 888 mr_asprintf(&tmp, "Backup medium is TAPE --- dev=%s", 888 889 bkpinfo->media_device); 889 890 log_msg(2, tmp); 890 paranoid_free(tmp);891 mr_free(tmp); 891 892 } else { 892 paranoid_alloc(bkpinfo->media_device, "/dev/cdrom");893 mr_allocstr(bkpinfo->media_device, "/dev/cdrom"); 893 894 bkpinfo->media_size[0] = 1999 * 1024; /* 650, probably, but we don't need this var anyway */ 894 895 bkpinfo->media_size[1] = 1999 * 1024; /* 650, probably, but we don't need this var anyway */ … … 905 906 log_msg(1, "Goody! ... bkpinfo->use_star is now true."); 906 907 } 907 paranoid_free(value);908 mr_free(value); 908 909 909 910 if (0 == read_cfg_var(cfg_file, "internal-tape-block-size", value)) { … … 917 918 DEFAULT_INTERNAL_TAPE_BLOCK_SIZE); 918 919 } 919 paranoid_free(value);920 mr_free(value); 920 921 921 922 read_cfg_var(cfg_file, "use-lzo", value); 922 923 if (strstr(value, "yes")) { 923 924 bkpinfo->use_lzo = TRUE; 924 paranoid_alloc(bkpinfo->zip_exe, "lzop");925 paranoid_alloc(bkpinfo->zip_suffix, "lzo");926 } else { 927 paranoid_free(value);925 mr_allocstr(bkpinfo->zip_exe, "lzop"); 926 mr_allocstr(bkpinfo->zip_suffix, "lzo"); 927 } else { 928 mr_free(value); 928 929 read_cfg_var(cfg_file, "use-comp", value); 929 930 if (strstr(value, "yes")) { 930 931 bkpinfo->use_lzo = FALSE; 931 paranoid_alloc(bkpinfo->zip_exe, "bzip2");932 paranoid_alloc(bkpinfo->zip_suffix, "bz2");932 mr_allocstr(bkpinfo->zip_exe, "bzip2"); 933 mr_allocstr(bkpinfo->zip_suffix, "bz2"); 933 934 } else { 934 935 // Just to be sure … … 937 938 } 938 939 } 939 paranoid_free(value);940 mr_free(value); 940 941 941 942 read_cfg_var(cfg_file, "differential", value); … … 944 945 } 945 946 log_msg(2, "differential var = '%s'", value); 946 paranoid_free(value);947 mr_free(value); 947 948 948 949 if (bkpinfo->differential) { … … 962 963 log_msg(2, "Ok, I shan't eject when restoring! Groovy."); 963 964 } 964 paranoid_free(tmp);965 paranoid_free(tmp1);965 mr_free(tmp); 966 mr_free(tmp1); 966 967 967 968 if (bkpinfo->backup_media_type == nfs) { … … 973 974 "...cos it wouldn't make sense to abandon the values that GOT ME to this config file in the first place"); 974 975 } else { 975 paranoid_free(bkpinfo->nfs_mount);976 paranoid_free(bkpinfo->nfs_remote_dir);976 mr_free(bkpinfo->nfs_mount); 977 mr_free(bkpinfo->nfs_remote_dir); 977 978 read_cfg_var(g_mondo_cfg_file, "nfs-server-mount", 978 979 bkpinfo->nfs_mount); … … 994 995 * isodir in disaster recovery mode 995 996 */ 996 paranoid_alloc(old_isodir,bkpinfo->isodir);997 mr_allocstr(old_isodir,bkpinfo->isodir); 997 998 read_cfg_var(g_mondo_cfg_file, "iso-mnt", iso_mnt); 998 999 read_cfg_var(g_mondo_cfg_file, "isodir", iso_path); 999 1000 if (iso_mnt && iso_path) { 1000 paranoid_free(bkpinfo->isodir);1001 asprintf(&bkpinfo->isodir, "%s%s", iso_mnt, iso_path);1002 } 1003 paranoid_free(iso_mnt);1004 paranoid_free(iso_path);1001 mr_free(bkpinfo->isodir); 1002 mr_asprintf(&bkpinfo->isodir, "%s%s", iso_mnt, iso_path); 1003 } 1004 mr_free(iso_mnt); 1005 mr_free(iso_path); 1005 1006 1006 1007 if (!bkpinfo->disaster_recovery) { … … 1011 1012 } 1012 1013 } 1013 paranoid_free(old_isodir);1014 1015 paranoid_free(g_isodir_device);1014 mr_free(old_isodir); 1015 1016 mr_free(g_isodir_device); 1016 1017 read_cfg_var(g_mondo_cfg_file, "iso-dev", g_isodir_device); 1017 1018 log_msg(2, "isodir=%s; iso-dev=%s", bkpinfo->isodir, g_isodir_device); … … 1020 1021 log_msg(2, "NB: isodir is already mounted"); 1021 1022 /* Find out where it's mounted */ 1022 asprintf(&command,1023 mr_asprintf(&command, 1023 1024 "mount | grep -w %s | tail -n1 | cut -d' ' -f3", 1024 1025 g_isodir_device); … … 1027 1028 log_it("res of it = %s", tmp); 1028 1029 iso_mnt = tmp; 1029 paranoid_free(command);1030 mr_free(command); 1030 1031 } else { 1031 asprintf(&iso_mnt, "/tmp/isodir");1032 asprintf(&tmp, "mkdir -p %s", iso_mnt);1032 mr_asprintf(&iso_mnt, "/tmp/isodir"); 1033 mr_asprintf(&tmp, "mkdir -p %s", iso_mnt); 1033 1034 run_program_and_log_output(tmp, 5); 1034 paranoid_free(tmp);1035 1036 asprintf(&tmp, "mount %s %s", g_isodir_device, iso_mnt);1035 mr_free(tmp); 1036 1037 mr_asprintf(&tmp, "mount %s %s", g_isodir_device, iso_mnt); 1037 1038 if (run_program_and_log_output(tmp, 3)) { 1038 1039 log_msg(1, 1039 1040 "Unable to mount isodir. Perhaps this is really a CD backup?"); 1040 1041 bkpinfo->backup_media_type = cdr; 1041 paranoid_alloc(bkpinfo->media_device, "/dev/cdrom");1042 paranoid_free(bkpinfo->isodir);1043 paranoid_free(iso_mnt);1044 paranoid_free(iso_path);1045 asprintf(&iso_mnt, "%s", "");1046 asprintf(&iso_path, "%s", "");1042 mr_allocstr(bkpinfo->media_device, "/dev/cdrom"); 1043 mr_free(bkpinfo->isodir); 1044 mr_free(iso_mnt); 1045 mr_free(iso_path); 1046 mr_asprintf(&iso_mnt, "%s", ""); 1047 mr_asprintf(&iso_path, "%s", ""); 1047 1048 1048 1049 if (mount_cdrom(bkpinfo)) { … … 1054 1055 } 1055 1056 } 1056 paranoid_free(tmp);1057 mr_free(tmp); 1057 1058 } 1058 1059 /* bkpinfo->isodir should now be the true path to prefix-1.iso etc... */ 1059 1060 if (bkpinfo->backup_media_type == iso) { 1060 paranoid_free(bkpinfo->isodir);1061 asprintf(&bkpinfo->isodir, "%s%s", iso_mnt, iso_path);1062 } 1063 paranoid_free(iso_mnt);1064 paranoid_free(iso_path);1061 mr_free(bkpinfo->isodir); 1062 mr_asprintf(&bkpinfo->isodir, "%s%s", iso_mnt, iso_path); 1063 } 1064 mr_free(iso_mnt); 1065 mr_free(iso_path); 1065 1066 } 1066 1067 } … … 1131 1132 unlink("/tmp/i-want-my-lvm"); 1132 1133 if (IS_THIS_A_STREAMING_BACKUP(bkpinfo->backup_media_type)) { 1133 asprintf(&command,1134 mr_asprintf(&command, 1134 1135 "tar -zxf %s %s %s %s %s %s", 1135 1136 bkpinfo->media_device, … … 1140 1141 log_msg(1, "tarcommand = %s", command); 1141 1142 run_program_and_log_output(command, 1); 1142 paranoid_free(command);1143 mr_free(command); 1143 1144 } else { 1144 1145 log_msg(2, … … 1148 1149 log_msg(2, "Back from iotcn"); 1149 1150 run_program_and_log_output("mount", 1); 1150 asprintf(&command,1151 mr_asprintf(&command, 1151 1152 "tar -zxf %s/images/all.tar.gz %s %s %s %s %s", 1152 1153 MNT_CDROM, … … 1158 1159 log_msg(1, "tarcommand = %s", command); 1159 1160 run_program_and_log_output(command, 1); 1160 paranoid_free(command);1161 mr_free(command); 1161 1162 1162 1163 if (!does_file_exist(BIGGIELIST_TXT_STUB)) { … … 1169 1170 } 1170 1171 } 1171 asprintf(&command, "cp -f %s %s", MONDO_CFG_FILE_STUB,1172 mr_asprintf(&command, "cp -f %s %s", MONDO_CFG_FILE_STUB, 1172 1173 g_mondo_cfg_file); 1173 1174 run_program_and_log_output(command, FALSE); 1174 paranoid_free(command);1175 1176 asprintf(&command, "cp -f %s/%s %s", bkpinfo->tmpdir,1175 mr_free(command); 1176 1177 mr_asprintf(&command, "cp -f %s/%s %s", bkpinfo->tmpdir, 1177 1178 BIGGIELIST_TXT_STUB, g_biggielist_txt); 1178 1179 log_msg(1, "command = %s", command); 1179 1180 paranoid_system(command); 1180 paranoid_free(command);1181 1182 asprintf(&command, "ln -sf %s/%s %s", bkpinfo->tmpdir,1181 mr_free(command); 1182 1183 mr_asprintf(&command, "ln -sf %s/%s %s", bkpinfo->tmpdir, 1183 1184 FILELIST_FULL_STUB, g_filelist_full); 1184 1185 log_msg(1, "command = %s", command); 1185 1186 paranoid_system(command); 1186 paranoid_free(command);1187 mr_free(command); 1187 1188 } 1188 1189 … … 1192 1193 ("Do you want to retrieve the mountlist as well?"))) 1193 1194 { 1194 asprintf(&command, "ln -sf %s/%s /tmp", MOUNTLIST_FNAME_STUB,1195 mr_asprintf(&command, "ln -sf %s/%s /tmp", MOUNTLIST_FNAME_STUB, 1195 1196 bkpinfo->tmpdir); 1196 1197 paranoid_system(command); 1197 paranoid_free(command);1198 mr_free(command); 1198 1199 } 1199 1200 1200 1201 chdir(tmp); 1201 paranoid_free(tmp);1202 mr_free(tmp); 1202 1203 1203 1204 if (!does_file_exist(g_biggielist_txt)) { … … 1219 1220 log_to_screen(("Pre-processing filelist")); 1220 1221 if (!does_file_exist(g_biggielist_txt)) { 1221 asprintf(&command, "> %s", g_biggielist_txt);1222 mr_asprintf(&command, "> %s", g_biggielist_txt); 1222 1223 paranoid_system(command); 1223 paranoid_free(command);1224 } 1225 asprintf(&command, "grep -x \"/dev/.*\" %s > %s",1224 mr_free(command); 1225 } 1226 mr_asprintf(&command, "grep -x \"/dev/.*\" %s > %s", 1226 1227 g_biggielist_txt, g_filelist_imagedevs); 1227 1228 paranoid_system(command); 1228 paranoid_free(command);1229 mr_free(command); 1229 1230 exit(0); 1230 1231 break; … … 1245 1246 if (g_text_mode) { 1246 1247 printf(_("Restore which directory? --> ")); 1247 getline(&tmp, &n, stdin);1248 mr_getline(&tmp, &n, stdin); 1248 1249 toggle_path_selection(filelist, tmp, TRUE); 1249 1250 if (strlen(tmp) == 0) { … … 1252 1253 res = 0; 1253 1254 } 1254 paranoid_free(tmp);1255 mr_free(tmp); 1255 1256 } else { 1256 1257 res = edit_filelist(filelist); … … 1296 1297 assert_string_is_neither_NULL_nor_zerolength(filename); 1297 1298 1298 asprintf(&command, "cp -f %s/%s %s/%s.pristine", path_root, filename,path_root, filename);1299 mr_asprintf(&command, "cp -f %s/%s %s/%s.pristine", path_root, filename,path_root, filename); 1299 1300 res = run_program_and_log_output(command, 5); 1300 paranoid_free(command);1301 mr_free(command); 1301 1302 return (res); 1302 1303 } … … 1324 1325 read_cfg_var(g_mondo_cfg_file, "bootloader.device", device); 1325 1326 read_cfg_var(g_mondo_cfg_file, "bootloader.name", name); 1326 asprintf(&tmp, "run_boot_loader: device='%s', name='%s'", device, name);1327 mr_asprintf(&tmp, "run_boot_loader: device='%s', name='%s'", device, name); 1327 1328 log_msg(2, tmp); 1328 paranoid_free(tmp);1329 mr_free(tmp); 1329 1330 1330 1331 sync(); … … 1349 1350 #ifdef __FreeBSD__ 1350 1351 else if (!strcmp(name, "BOOT0")) { 1351 asprintf(&tmp, "boot0cfg -B %s", device);1352 mr_asprintf(&tmp, "boot0cfg -B %s", device); 1352 1353 res = run_program_and_log_output(tmp, FALSE); 1353 paranoid_free(tmp);1354 } else { 1355 asprintf(&tmp, "ls /dev | grep -xq %ss[1-4].*", device);1354 mr_free(tmp); 1355 } else { 1356 mr_asprintf(&tmp, "ls /dev | grep -xq %ss[1-4].*", device); 1356 1357 if (!system(tmp)) { 1357 paranoid_free(tmp);1358 asprintf(&tmp, MNT_RESTORING "/sbin/fdisk -B %s", device);1358 mr_free(tmp); 1359 mr_asprintf(&tmp, MNT_RESTORING "/sbin/fdisk -B %s", device); 1359 1360 res = run_program_and_log_output(tmp, 3); 1360 1361 } else { … … 1362 1363 "I'm not running any boot loader. You have a DD boot drive. It's already loaded up."); 1363 1364 } 1364 paranoid_free(tmp);1365 mr_free(tmp); 1365 1366 } 1366 1367 #else … … 1372 1373 } 1373 1374 #endif 1374 paranoid_free(device);1375 paranoid_free(name);1375 mr_free(device); 1376 mr_free(name); 1376 1377 1377 1378 retval += res; … … 1401 1402 tmp = find_home_of_exe("pico"); 1402 1403 if (tmp) { 1403 asprintf(&output, "pico");1404 mr_asprintf(&output, "pico"); 1404 1405 } else { 1405 1406 tmp = find_home_of_exe("nano"); 1406 1407 if (tmp) { 1407 asprintf(&output, "nano");1408 mr_asprintf(&output, "nano"); 1408 1409 } else { 1409 1410 tmp = find_home_of_exe("vi"); 1410 1411 if (tmp) { 1411 asprintf(&output, "vi");1412 mr_asprintf(&output, "vi"); 1412 1413 } else { 1413 asprintf(&output, "emacs");1414 } 1415 } 1416 } 1417 paranoid_free(tmp);1414 mr_asprintf(&output, "emacs"); 1415 } 1416 } 1417 } 1418 mr_free(tmp); 1418 1419 1419 1420 tmp = find_home_of_exe(output); … … 1421 1422 log_msg(2, " (find_my_editor) --- warning - %s not found", output); 1422 1423 } 1423 paranoid_free(tmp);1424 mr_free(tmp); 1424 1425 return (output); 1425 1426 } … … 1454 1455 popup_and_get_string(_("Boot device"), 1455 1456 _("Please confirm/enter the boot device. If in doubt, try /dev/hda"), bd); 1456 asprintf(&command, "stabgrub-me %s", bd);1457 mr_asprintf(&command, "stabgrub-me %s", bd); 1457 1458 res = run_program_and_log_output(command, 1); 1458 paranoid_free(command);1459 mr_free(command); 1459 1460 1460 1461 if (res) { … … 1474 1475 } 1475 1476 editor = find_my_editor(); 1476 asprintf(&tmp, "%s " MNT_RESTORING "/etc/fstab", editor);1477 mr_asprintf(&tmp, "%s " MNT_RESTORING "/etc/fstab", editor); 1477 1478 paranoid_system(tmp); 1478 paranoid_free(tmp);1479 1480 asprintf(&tmp, "%s " MNT_RESTORING "/etc/grub.conf", editor);1481 paranoid_free(editor);1479 mr_free(tmp); 1480 1481 mr_asprintf(&tmp, "%s " MNT_RESTORING "/etc/grub.conf", editor); 1482 mr_free(editor); 1482 1483 1483 1484 paranoid_system(tmp); 1484 paranoid_free(tmp);1485 mr_free(tmp); 1485 1486 1486 1487 if (!g_text_mode) { … … 1492 1493 if (!run_program_and_log_output("which grub-MR", FALSE)) { 1493 1494 log_msg(1, "Yay! grub-MR found..."); 1494 asprintf(&command, "grub-MR %s /tmp/mountlist.txt", bd);1495 mr_asprintf(&command, "grub-MR %s /tmp/mountlist.txt", bd); 1495 1496 log_msg(1, "command = %s", command); 1496 1497 } else { 1497 asprintf(&command, "chroot " MNT_RESTORING " grub-install %s", bd);1498 mr_asprintf(&command, "chroot " MNT_RESTORING " grub-install %s", bd); 1498 1499 log_msg(1, "WARNING - grub-MR not found; using grub-install"); 1499 1500 } … … 1504 1505 iamhere(command); 1505 1506 res = run_program_and_log_output(command, 1); 1506 paranoid_free(command);1507 mr_free(command); 1507 1508 1508 1509 if (res) { … … 1563 1564 _ 1564 1565 ("Modifying fstab and elilo.conf... ")); 1565 asprintf(&command, "stabelilo-me");1566 mr_asprintf(&command, "stabelilo-me"); 1566 1567 res = run_program_and_log_output(command, 3); 1567 paranoid_free(command);1568 mr_free(command); 1568 1569 1569 1570 if (res) { … … 1576 1577 } 1577 1578 editor = find_my_editor(); 1578 asprintf(&tmp, "%s " MNT_RESTORING "/etc/fstab", editor);1579 mr_asprintf(&tmp, "%s " MNT_RESTORING "/etc/fstab", editor); 1579 1580 paranoid_system(tmp); 1580 paranoid_free(tmp);1581 1582 asprintf(&tmp, "%s " MNT_RESTORING "/etc/elilo.conf", editor);1583 paranoid_free(editor);1581 mr_free(tmp); 1582 1583 mr_asprintf(&tmp, "%s " MNT_RESTORING "/etc/elilo.conf", editor); 1584 mr_free(editor); 1584 1585 1585 1586 paranoid_system(tmp); 1586 paranoid_free(tmp);1587 mr_free(tmp); 1587 1588 1588 1589 if (!g_text_mode) { … … 1638 1639 _ 1639 1640 ("Modifying fstab and lilo.conf, and running LILO... ")); 1640 asprintf(&command, "stablilo-me");1641 mr_asprintf(&command, "stablilo-me"); 1641 1642 res = run_program_and_log_output(command, 3); 1642 paranoid_free(command);1643 mr_free(command); 1643 1644 1644 1645 if (res) { … … 1651 1652 } 1652 1653 editor = find_my_editor(); 1653 asprintf(&tmp, "%s " MNT_RESTORING "/etc/fstab", editor);1654 mr_asprintf(&tmp, "%s " MNT_RESTORING "/etc/fstab", editor); 1654 1655 paranoid_system(tmp); 1655 paranoid_free(tmp);1656 1657 asprintf(&tmp, "%s " MNT_RESTORING "/etc/lilo.conf", editor);1658 paranoid_free(editor);1656 mr_free(tmp); 1657 1658 mr_asprintf(&tmp, "%s " MNT_RESTORING "/etc/lilo.conf", editor); 1659 mr_free(editor); 1659 1660 1660 1661 paranoid_system(tmp); 1661 paranoid_free(tmp);1662 mr_free(tmp); 1662 1663 1663 1664 if (!g_text_mode) { … … 1753 1754 } 1754 1755 editor = find_my_editor(); 1755 asprintf(&tmp, "%s " MNT_RESTORING "/etc/fstab", editor);1756 paranoid_free(editor);1756 mr_asprintf(&tmp, "%s " MNT_RESTORING "/etc/fstab", editor); 1757 mr_free(editor); 1757 1758 1758 1759 paranoid_system(tmp); 1759 paranoid_free(tmp);1760 mr_free(tmp); 1760 1761 1761 1762 if (!g_text_mode) { … … 1767 1768 _ 1768 1769 ("Please confirm/enter the boot device. If in doubt, try /dev/hda"), bd); 1769 asprintf(&command, "stabraw-me %s", bd);1770 mr_asprintf(&command, "stabraw-me %s", bd); 1770 1771 res = run_program_and_log_output(command, 3); 1771 paranoid_free(command);1772 mr_free(command); 1772 1773 1773 1774 if (res) { … … 1783 1784 _ 1784 1785 ("Restoring MBR... ")); 1785 asprintf(&command, "raw-MR %s /tmp/mountlist.txt", bd);1786 mr_asprintf(&command, "raw-MR %s /tmp/mountlist.txt", bd); 1786 1787 log_msg(2, "run_raw_mbr() --- command='%s'", command); 1787 1788 res = run_program_and_log_output(command, 3); 1788 paranoid_free(command);1789 mr_free(command); 1789 1790 } 1790 1791 if (res) { … … 1839 1840 assert(bkpinfo != NULL); 1840 1841 1841 asprintf(&g_biggielist_txt, "%s/%s",bkpinfo->tmpdir , BIGGIELIST_TXT_STUB);1842 asprintf(&g_filelist_full, "%s/%s", bkpinfo->tmpdir, FILELIST_FULL_STUB);1843 asprintf(&g_filelist_imagedevs, "%s/tmp/filelist.imagedevs", bkpinfo->tmpdir);1844 asprintf(&g_imagedevs_restthese, "%s/tmp/imagedevs.restore-these",1842 mr_asprintf(&g_biggielist_txt, "%s/%s",bkpinfo->tmpdir , BIGGIELIST_TXT_STUB); 1843 mr_asprintf(&g_filelist_full, "%s/%s", bkpinfo->tmpdir, FILELIST_FULL_STUB); 1844 mr_asprintf(&g_filelist_imagedevs, "%s/tmp/filelist.imagedevs", bkpinfo->tmpdir); 1845 mr_asprintf(&g_imagedevs_restthese, "%s/tmp/imagedevs.restore-these", 1845 1846 bkpinfo->tmpdir); 1846 paranoid_free(g_mondo_cfg_file);1847 paranoid_free(g_mountlist_fname);1847 mr_free(g_mondo_cfg_file); 1848 mr_free(g_mountlist_fname); 1848 1849 if (bkpinfo->disaster_recovery) { 1849 asprintf(&g_mondo_cfg_file, "/%s", MONDO_CFG_FILE_STUB);1850 asprintf(&g_mountlist_fname, "/%s", MOUNTLIST_FNAME_STUB);1851 } else { 1852 asprintf(&g_mondo_cfg_file, "%s/%s", bkpinfo->tmpdir, MONDO_CFG_FILE_STUB);1853 asprintf(&g_mountlist_fname, "%s/%s", bkpinfo->tmpdir, MOUNTLIST_FNAME_STUB);1850 mr_asprintf(&g_mondo_cfg_file, "/%s", MONDO_CFG_FILE_STUB); 1851 mr_asprintf(&g_mountlist_fname, "/%s", MOUNTLIST_FNAME_STUB); 1852 } else { 1853 mr_asprintf(&g_mondo_cfg_file, "%s/%s", bkpinfo->tmpdir, MONDO_CFG_FILE_STUB); 1854 mr_asprintf(&g_mountlist_fname, "%s/%s", bkpinfo->tmpdir, MOUNTLIST_FNAME_STUB); 1854 1855 } 1855 1856 } … … 1882 1883 fatal_error("cannot open output_file"); 1883 1884 } 1884 for ( getline(&incoming, &n, fin); !feof(fin);1885 getline(&incoming, &n, fin)) {1885 for (mr_getline(&incoming, &n, fin); !feof(fin); 1886 mr_getline(&incoming, &n, fin)) { 1886 1887 if (strncmp(incoming, "etc/adjtime", 11) 1887 1888 && strncmp(incoming, "etc/mtab", 8) … … 1893 1894 fprintf(fout, "%s", incoming); /* don't need \n here, for some reason.. */ 1894 1895 } 1895 paranoid_free(incoming);1896 mr_free(incoming); 1896 1897 paranoid_fclose(fout); 1897 1898 paranoid_fclose(fin); … … 1936 1937 for (i = 0; i < 20; i++) { 1937 1938 g_current_progress = i; 1938 asprintf(&tmp, _("You have %d seconds left to abort."), 20 - i);1939 mr_asprintf(&tmp, _("You have %d seconds left to abort."), 20 - i); 1939 1940 update_progress_form(tmp); 1940 paranoid_free(tmp);1941 mr_free(tmp); 1941 1942 sleep(1); 1942 1943 } … … 2025 2026 continue; 2026 2027 } 2027 asprintf(&tmp, _("Unmounting device %s "),2028 mr_asprintf(&tmp, _("Unmounting device %s "), 2028 2029 mountlist->el[lino].device); 2029 2030 … … 2032 2033 if (is_this_device_mounted(mountlist->el[lino].device)) { 2033 2034 if (!strcmp(mountlist->el[lino].mountpoint, "swap")) { 2034 asprintf(&command, "swapoff %s", mountlist->el[lino].device);2035 mr_asprintf(&command, "swapoff %s", mountlist->el[lino].device); 2035 2036 } else { 2036 2037 if (!strcmp(mountlist->el[lino].mountpoint, "/1")) { 2037 asprintf(&command, "umount %s/", MNT_RESTORING);2038 mr_asprintf(&command, "umount %s/", MNT_RESTORING); 2038 2039 log_msg(3, 2039 2040 "Well, I know a certain kitty-kitty who'll be sleeping with Mommy tonight..."); 2040 2041 } else { 2041 asprintf(&command, "umount " MNT_RESTORING "%s",2042 mr_asprintf(&command, "umount " MNT_RESTORING "%s", 2042 2043 mountlist->el[lino].mountpoint); 2043 2044 } … … 2045 2046 log_msg(10, "The 'umount' command is '%s'", command); 2046 2047 res = run_program_and_log_output(command, 3); 2047 paranoid_free(command);2048 mr_free(command); 2048 2049 } else { 2049 asprintf(&tmp1, "%s%s", tmp, _("...not mounted anyway :-) OK"));2050 paranoid_free(tmp);2050 mr_asprintf(&tmp1, "%s%s", tmp, _("...not mounted anyway :-) OK")); 2051 mr_free(tmp); 2051 2052 tmp = tmp1; 2052 2053 res = 0; … … 2054 2055 g_current_progress++; 2055 2056 if (res) { 2056 asprintf(&tmp1, "%s%s", tmp, _("...Failed"));2057 paranoid_free(tmp);2057 mr_asprintf(&tmp1, "%s%s", tmp, _("...Failed")); 2058 mr_free(tmp); 2058 2059 tmp = tmp1; 2059 2060 retval++; … … 2062 2063 log_msg(2, tmp); 2063 2064 } 2064 paranoid_free(tmp);2065 mr_free(tmp); 2065 2066 } 2066 2067 close_progress_form(); … … 2097 2098 2098 2099 // tar -zxvf- 2099 asprintf(&command,2100 mr_asprintf(&command, 2100 2101 "dd if=%s bs=%ld count=%ld 2> /dev/null | tar -zx %s %s %s %s %s", 2101 2102 dev, … … 2106 2107 log_msg(2, "command = '%s'", command); 2107 2108 res = run_program_and_log_output(command, -1); 2108 paranoid_free(command);2109 mr_free(command); 2109 2110 2110 2111 if (res != 0 && does_file_exist(MONDO_CFG_FILE_STUB)) { … … 2142 2143 log_msg(2, "gcffa --- starting"); 2143 2144 log_to_screen(_("I'm thinking...")); 2144 asprintf(&mountpt, "%s/mount.bootdisk", bkpinfo->tmpdir);2145 mr_asprintf(&mountpt, "%s/mount.bootdisk", bkpinfo->tmpdir); 2145 2146 chdir(bkpinfo->tmpdir); 2146 2147 // MONDO_CFG_FILE_STUB is missing the '/' at the start, FYI, by intent … … 2150 2151 unlink(BIGGIELIST_TXT_STUB); 2151 2152 unlink("tmp/i-want-my-lvm"); 2152 asprintf(&command, "mkdir -p %s", mountpt);2153 mr_asprintf(&command, "mkdir -p %s", mountpt); 2153 2154 run_program_and_log_output(command, FALSE); 2154 paranoid_free(command);2155 2156 asprintf(&cfg_file, "%s/%s", bkpinfo->tmpdir, MONDO_CFG_FILE_STUB);2157 asprintf(&mountlist_file, "%s/%s", bkpinfo->tmpdir,2155 mr_free(command); 2156 2157 mr_asprintf(&cfg_file, "%s/%s", bkpinfo->tmpdir, MONDO_CFG_FILE_STUB); 2158 mr_asprintf(&mountlist_file, "%s/%s", bkpinfo->tmpdir, 2158 2159 MOUNTLIST_FNAME_STUB); 2159 2160 log_msg(2, "mountpt = %s; cfg_file=%s", mountpt, cfg_file); 2160 2161 2161 2162 /* Floppy? */ 2162 asprintf(&tmp, "mkdir -p %s", mountpt);2163 mr_asprintf(&tmp, "mkdir -p %s", mountpt); 2163 2164 run_program_and_log_output(tmp, FALSE); 2164 paranoid_free(tmp);2165 2166 asprintf(&tmp, "mkdir -p %s/tmp", bkpinfo->tmpdir);2165 mr_free(tmp); 2166 2167 mr_asprintf(&tmp, "mkdir -p %s/tmp", bkpinfo->tmpdir); 2167 2168 run_program_and_log_output(tmp, FALSE); 2168 paranoid_free(tmp);2169 2170 asprintf(&command, "mount /dev/fd0u1722 %s", mountpt);2171 asprintf(&tmp,2169 mr_free(tmp); 2170 2171 mr_asprintf(&command, "mount /dev/fd0u1722 %s", mountpt); 2172 mr_asprintf(&tmp, 2172 2173 "(sleep 15; kill `ps | grep \"%s\" | cut -d' ' -f1` 2> /dev/null) &", 2173 2174 command); 2174 2175 log_msg(1, "tmp = '%s'", tmp); 2175 2176 system(tmp); 2176 paranoid_free(tmp);2177 mr_free(tmp); 2177 2178 2178 2179 res = run_program_and_log_output(command, FALSE); 2179 paranoid_free(command);2180 mr_free(command); 2180 2181 2181 2182 if (res) { 2182 asprintf(&command, "mount /dev/fd0H1440 %s", mountpt);2183 mr_asprintf(&command, "mount /dev/fd0H1440 %s", mountpt); 2183 2184 res = run_program_and_log_output(command, FALSE); 2184 paranoid_free(command);2185 mr_free(command); 2185 2186 } 2186 2187 if (res) { … … 2192 2193 // NB: If busybox does not support 'mount -o loop' then Plan A WILL NOT WORK. 2193 2194 log_msg(2, "Processing floppy (plan A?)"); 2194 asprintf(&ramdisk_fname, "%s/mindi.rdz", mountpt);2195 mr_asprintf(&ramdisk_fname, "%s/mindi.rdz", mountpt); 2195 2196 if (!does_file_exist(ramdisk_fname)) { 2196 paranoid_free(ramdisk_fname);2197 asprintf(&ramdisk_fname, "%s/initrd.img", mountpt);2197 mr_free(ramdisk_fname); 2198 mr_asprintf(&ramdisk_fname, "%s/initrd.img", mountpt); 2198 2199 } 2199 2200 if (!does_file_exist(ramdisk_fname)) { … … 2206 2207 "Warning - failed to extract config file from ramdisk. I think this boot disk is mangled."); 2207 2208 } 2208 asprintf(&command, "umount %s", mountpt);2209 mr_asprintf(&command, "umount %s", mountpt); 2209 2210 run_program_and_log_output(command, 5); 2210 paranoid_free(command);2211 mr_free(command); 2211 2212 2212 2213 unlink(ramdisk_fname); 2213 paranoid_free(ramdisk_fname);2214 mr_free(ramdisk_fname); 2214 2215 } 2215 2216 if (!does_file_exist(cfg_file)) { … … 2237 2238 2238 2239 if (bkpinfo->media_device == NULL) { 2239 asprintf(&bkpinfo->media_device, "/dev/st0");2240 mr_asprintf(&bkpinfo->media_device, "/dev/st0"); 2240 2241 log_msg(2, "media_device is blank; assuming %s", 2241 2242 bkpinfo->media_device); 2242 2243 } 2243 asprintf(&sav, bkpinfo->media_device);2244 mr_asprintf(&sav, bkpinfo->media_device); 2244 2245 if (extract_cfg_file_and_mountlist_from_tape_dev 2245 2246 (bkpinfo->media_device)) { 2246 paranoid_alloc(bkpinfo->media_device, "/dev/st0");2247 mr_allocstr(bkpinfo->media_device, "/dev/st0"); 2247 2248 if (extract_cfg_file_and_mountlist_from_tape_dev 2248 2249 (bkpinfo->media_device)) { 2249 paranoid_alloc(bkpinfo->media_device, "/dev/osst0");2250 mr_allocstr(bkpinfo->media_device, "/dev/osst0"); 2250 2251 if (extract_cfg_file_and_mountlist_from_tape_dev 2251 2252 (bkpinfo->media_device)) { 2252 paranoid_alloc(bkpinfo->media_device, "/dev/ht0");2253 mr_allocstr(bkpinfo->media_device, "/dev/ht0"); 2253 2254 if (extract_cfg_file_and_mountlist_from_tape_dev 2254 2255 (bkpinfo->media_device)) { 2255 2256 log_msg(3, 2256 2257 "I tried lots of devices but none worked."); 2257 paranoid_alloc(bkpinfo->media_device, sav);2258 mr_allocstr(bkpinfo->media_device, sav); 2258 2259 } 2259 2260 } 2260 2261 } 2261 2262 } 2262 paranoid_free(sav);2263 mr_free(sav); 2263 2264 2264 2265 if (!does_file_exist("tmp/mondo-restore.cfg")) { … … 2271 2272 "gcffa --- looking at mounted CD for mindi-boot.2880.img"); 2272 2273 /* BERLIOS : Useless ? 2273 asprintf(&command,2274 mr_asprintf(&command, 2274 2275 "mount " MNT_CDROM 2275 2276 "/images/mindi-boot.2880.img -o loop %s", mountpt); 2276 2277 */ 2277 asprintf(&mounted_cfgf_path, "%s/%s", mountpt, cfg_file);2278 mr_asprintf(&mounted_cfgf_path, "%s/%s", mountpt, cfg_file); 2278 2279 if (!does_file_exist(mounted_cfgf_path)) { 2279 2280 log_msg(2, 2280 2281 "gcffa --- Plan C, a.k.a. untarring some file from all.tar.gz"); 2281 asprintf(&command, "tar -zxvf " MNT_CDROM "/images/all.tar.gz %s %s %s %s %s", MOUNTLIST_FNAME_STUB, MONDO_CFG_FILE_STUB, BIGGIELIST_TXT_STUB, FILELIST_FULL_STUB, "tmp/i-want-my-lvm"); // add -b TAPE_BLOCK_SIZE if you _really_ think it's necessary2282 mr_asprintf(&command, "tar -zxvf " MNT_CDROM "/images/all.tar.gz %s %s %s %s %s", MOUNTLIST_FNAME_STUB, MONDO_CFG_FILE_STUB, BIGGIELIST_TXT_STUB, FILELIST_FULL_STUB, "tmp/i-want-my-lvm"); // add -b TAPE_BLOCK_SIZE if you _really_ think it's necessary 2282 2283 run_program_and_log_output(command, TRUE); 2283 paranoid_free(command);2284 mr_free(command); 2284 2285 2285 2286 if (!does_file_exist(MONDO_CFG_FILE_STUB)) { … … 2288 2289 } 2289 2290 } 2290 paranoid_free(mounted_cfgf_path);2291 } 2292 } 2293 paranoid_free(mountpt);2291 mr_free(mounted_cfgf_path); 2292 } 2293 } 2294 mr_free(mountpt); 2294 2295 2295 2296 if (does_file_exist(MONDO_CFG_FILE_STUB)) { 2296 2297 log_msg(1, "gcffa --- great! We've got the config file"); 2297 2298 tmp1 = call_program_and_get_last_line_of_output("pwd"); 2298 asprintf(&tmp, "%s/%s", tmp1,MONDO_CFG_FILE_STUB);2299 asprintf(&command, "cp -f %s %s", tmp, cfg_file);2299 mr_asprintf(&tmp, "%s/%s", tmp1,MONDO_CFG_FILE_STUB); 2300 mr_asprintf(&command, "cp -f %s %s", tmp, cfg_file); 2300 2301 iamhere(command); 2301 2302 … … 2308 2309 log_msg(1, "... and I moved it successfully to %s", cfg_file); 2309 2310 } 2310 paranoid_free(command);2311 2312 asprintf(&command, "cp -f %s/%s %s",tmp1,2311 mr_free(command); 2312 2313 mr_asprintf(&command, "cp -f %s/%s %s",tmp1, 2313 2314 MOUNTLIST_FNAME_STUB, mountlist_file); 2314 paranoid_free(tmp1);2315 mr_free(tmp1); 2315 2316 2316 2317 iamhere(command); … … 2320 2321 } else { 2321 2322 log_msg(1, "Got mountlist too"); 2322 paranoid_free(command);2323 asprintf(&command, "cp -f %s %s", mountlist_file,2323 mr_free(command); 2324 mr_asprintf(&command, "cp -f %s %s", mountlist_file, 2324 2325 g_mountlist_fname); 2325 2326 if (run_program_and_log_output(command, 1)) { … … 2327 2328 } else { 2328 2329 log_msg(1, "Copied mountlist to /tmp as well OK"); 2329 paranoid_free(command);2330 asprintf(&command, "cp -f tmp/i-want-my-lvm /tmp/");2330 mr_free(command); 2331 mr_asprintf(&command, "cp -f tmp/i-want-my-lvm /tmp/"); 2331 2332 run_program_and_log_output(command, 1); 2332 2333 } 2333 2334 } 2334 paranoid_free(command);2335 paranoid_free(tmp);2335 mr_free(command); 2336 mr_free(tmp); 2336 2337 } 2337 2338 run_program_and_log_output("umount " MNT_CDROM, FALSE); … … 2351 2352 /* start SAH */ 2352 2353 else { 2353 asprintf(&command, "cp -f %s %s/%s", MOUNTLIST_FNAME_STUB,2354 mr_asprintf(&command, "cp -f %s %s/%s", MOUNTLIST_FNAME_STUB, 2354 2355 bkpinfo->tmpdir, MOUNTLIST_FNAME_STUB); 2355 2356 run_program_and_log_output(command, FALSE); 2356 paranoid_free(command);2357 mr_free(command); 2357 2358 } 2358 2359 /* end SAH */ 2359 2360 2360 asprintf(&command, "cp -f %s /%s", cfg_file, MONDO_CFG_FILE_STUB);2361 paranoid_free(cfg_file);2361 mr_asprintf(&command, "cp -f %s /%s", cfg_file, MONDO_CFG_FILE_STUB); 2362 mr_free(cfg_file); 2362 2363 2363 2364 run_program_and_log_output(command, FALSE); 2364 paranoid_free(command);2365 2366 asprintf(&command, "cp -f %s /%s", mountlist_file, MOUNTLIST_FNAME_STUB);2367 paranoid_free(mountlist_file);2365 mr_free(command); 2366 2367 mr_asprintf(&command, "cp -f %s /%s", mountlist_file, MOUNTLIST_FNAME_STUB); 2368 mr_free(mountlist_file); 2368 2369 2369 2370 run_program_and_log_output(command, FALSE); 2370 paranoid_free(command);2371 2372 asprintf(&command, "cp -f etc/raidtab /etc/");2371 mr_free(command); 2372 2373 mr_asprintf(&command, "cp -f etc/raidtab /etc/"); 2373 2374 run_program_and_log_output(command, FALSE); 2374 paranoid_free(command);2375 2376 asprintf(&command, "cp -f tmp/i-want-my-lvm /tmp/");2375 mr_free(command); 2376 2377 mr_asprintf(&command, "cp -f tmp/i-want-my-lvm /tmp/"); 2377 2378 run_program_and_log_output(command, FALSE); 2378 paranoid_free(command);2379 mr_free(command); 2379 2380 2380 2381 g_backup_media_type = bkpinfo->backup_media_type; … … 2412 2413 log_msg(1, "Sync'ing %s (i=%d)", 2413 2414 raidlist->el[i].raid_device, i); 2414 asprintf(&screen_message, "Sync'ing %s",2415 mr_asprintf(&screen_message, "Sync'ing %s", 2415 2416 raidlist->el[i].raid_device); 2416 2417 open_evalcall_form(screen_message); 2417 paranoid_free(screen_message);2418 mr_free(screen_message); 2418 2419 2419 2420 if (raidlist->el[i].progress == -1) { // delayed while another partition inits … … 2434 2435 } 2435 2436 } 2436 paranoid_free(raidlist);2437 } 2437 mr_free(raidlist); 2438 } -
trunk/mondo/src/test/mktest
r768 r900 7 7 8 8 gcc -O2 -I../common -I../lib test-conf.c ../lib/mr_conf.c ../common/libmondo-msg.c -o test-conf 9 gcc -O2 -I../common -I../lib test-string.c ../lib/mr_str ing.c -o test-string9 gcc -O2 -I../common -I../lib test-string.c ../lib/mr_str.c -o test-string 10 10 11 11 for f in "test-conf"; do -
trunk/mondo/src/test/test-conf.c
r768 r900 9 9 #include "my-stuff.h" 10 10 #include "mr_conf.h" 11 #include "mr_mem.h" 11 12 12 13 int g_main_pid = 0; … … 38 39 } 39 40 fprintf(stdout, "String : ***%s***\n",s); 40 paranoid_free(s);41 mr_free(s); 41 42 mr_conf_close(); 42 43 exit(0); -
trunk/mondo/src/test/test-string.c
r768 r900 12 12 13 13 #include "my-stuff.h" 14 #include "mr_string.h" 14 #include "mr_str.h" 15 #include "mr_mem.h" 15 16 16 17 main() { … … 21 22 char *string = NULL; 22 23 23 asprintf(&string, "%s", "md0 : active raid10 hda1[0] hda12[3] hda6[2] hda5[1]\n");24 mr_asprintf(&string, "%s", "md0 : active raid10 hda1[0] hda12[3] hda6[2] hda5[1]\n"); 24 25 fprintf(stdout, "string=|%s|\n", string); 25 26 token = mr_strtok(string, delims, &lastpos); 26 27 while (lastpos > 0) { 27 28 fprintf(stdout, "token=|%s|, lastpos=%d\n", token, lastpos); 28 paranoid_free(token);29 mr_free(token); 29 30 token = mr_strtok(string, delims, &lastpos); 30 31 } 31 paranoid_free(string);32 mr_free(string); 32 33 exit(0); 33 34 } -
trunk/tools/build2pkg
r839 r900 63 63 ar=$ARCH 64 64 fi 65 pkg1="${TOPBUILDDIR}/RPMS/${ar}/$pv-${TAG}${suf}.${ar}.rpm"66 #rm -f $pkg167 65 68 pkg="$pkg $pkg1" 69 70 log=$TMP/$p-rpm.log 66 log=$MONDOTMP/$p-rpm.log 71 67 72 68 if [ "$dfam" = "mandriva" ] || [ "$dfam" = "suse" ]; then … … 87 83 status=-1 88 84 else 85 export pkg1="`egrep '^Wrote:' $log | grep -v debug | cut -d: -f2`" 89 86 if [ -f /usr/bin/rpmlint ]; then 90 /usr/bin/rpmlint `egrep '^Wrote:' $log | cut -d: -f2`87 /usr/bin/rpmlint $pkg1 91 88 else 92 89 echo "No rpmlint found, please install it" 93 90 fi 91 export pkg="$pkg `ls $pkg1 | grep -v src.rpm`" 94 92 fi 95 93 rm -rf ${TOPBUILDDIR}/BUILD/* … … 116 114 fi 117 115 elif [ _"$dtype" = _"deb" ]; then 118 export TMPDIR=/tmp119 116 cd $TOPBUILDDIR 120 117 tar xfz $src … … 130 127 echo "Packages handled : $pkg" 131 128 132 rm -rf $ TMP129 rm -rf $MONDOTMP 133 130 134 131 if [ $status = 0 ]; then -
trunk/tools/build2qemu
r764 r900 45 45 fi 46 46 47 mkdir -p $TMP 48 cat > $TMP/mkmondo << EOF 47 cat > $MONDOTMP/mkmondo << EOF 49 48 #!/bin/bash 50 49 … … 57 56 $TOOLHOME/pkg2ftp $LAST 58 57 EOF 59 chmod 755 $ TMP/mkmondo58 chmod 755 $MONDOTMP/mkmondo 60 59 61 60 if [ $single -eq 0 ]; then 62 61 $TOOLHOME/file2ftp 63 62 fi 64 cd $TOOLHOME/.. 65 tar cfz $TMP/mkmondo.tar.gz $TOOLHOME $TMP/mkmondo $TOPDIR/${VER}-$TAG 63 64 # TOPDIR contains ../.. which causes problems to tar 65 # so we need to recompute it 66 cd $TOPDIR 67 dir=`pwd` 68 tar cfz $MONDOTMP/mkmondo.tar.gz $TOOLHOME $MONDOTMP/mkmondo $dir/${VER}-$TAG 66 69 67 70 for m in $VMS; do … … 69 72 if [ ! -f /users/qemu/$m.qemu ]; then 70 73 echo "VM unaccessible. Verify NFS mount" 71 rm -rf $ TMP74 rm -rf $MONDOTMP 72 75 exit -1 73 76 fi … … 82 85 sleep 300 83 86 fi 84 scp -P $sp $ TMP/mkmondo.tar.gz ~/.rpmmacros ~/.rpmrc bruno@localhost:87 scp -P $sp $MONDOTMP/mkmondo.tar.gz ~/.rpmmacros ~/.rpmrc bruno@localhost: 85 88 rdate=`date "+%m%d%H%M"` 86 89 ssh -p $sp root@localhost "date $rdate" 87 ssh -p $sp bruno@localhost "cd / ; rm -rf ~bruno/mondo ~bruno/RPMS/BUILD/* ~bruno/RPMS/tmp/* /tmp/* ; tar xfz ~bruno/mkmondo.tar.gz ; $ TMP/mkmondo " | tee $TMP/mkvm.log88 #ssh -p $sp bruno@localhost "cd / ; tar xfz ~bruno/mkmondo.tar.gz ; $ TMP/mkmondo ; rm -f $TMP" | tee $TMP/mkvm.log90 ssh -p $sp bruno@localhost "cd / ; rm -rf ~bruno/mondo ~bruno/RPMS/BUILD/* ~bruno/RPMS/tmp/* /tmp/* ; tar xfz ~bruno/mkmondo.tar.gz ; $MONDOTMP/mkmondo " | tee $MONDOTMP/mkvm.log 91 #ssh -p $sp bruno@localhost "cd / ; tar xfz ~bruno/mkmondo.tar.gz ; $MONDOTMP/mkmondo ; rm -f $MONDOTMP" | tee $MONDOTMP/mkvm.log 89 92 if [ $vmp -eq 1 ]; then 90 93 ssh -p $sp root@localhost "halt -p" … … 99 102 100 103 # Should be removed at the end 101 rm -rf $ TMP104 rm -rf $MONDOTMP 102 105 ) 2>&1 | tee /tmp/build2qemu.log -
trunk/tools/common-env
r764 r900 7 7 8 8 # Adapt to your needs 9 export BASE=${HOME}/mondo 10 export TOPDIR=${BASE}/build 9 d=`dirname ${TOOLHOME}` 10 if [ _"`basename ${d}/..`" = _"trunk" ]; then 11 BASE=${TOOLHOME}/../.. 12 else 13 BASE=${TOOLHOME}/../../.. 14 fi 15 export TOPDIR=${BASE}/delivery 11 16 mkdir -p ${TOPDIR} 17 12 18 export TMPDIR=/tmp 13 export TMP=`mktemp -d /tmp/mondobuild.XXXXXXXXXX` 19 export MONDOTMP=`mktemp -d $TMPDIR/mondobuild.XXXXXXXXXX` 20 mkdir -p $MONDOTMP 14 21 15 22 umask 022 -
trunk/tools/distro-env
r764 r900 7 7 # Input parameters : $ddir (distro name) and $dver (distro version) 8 8 # If they do not exist then deduce from current distro 9 # Exports : $dfam (distro family) $suf (pkg suffix) $dtype (distro type) BUILDDIR (dir to build packages)9 # Exports : $dfam (distro family) $suf (pkg suffix) $dtype (distro type) TOPBUILDDIR (dir to build packages) 10 10 11 11 # … … 68 68 dtype="deb" 69 69 suf=".${dfam}${dver}" 70 BUILDDIR=${TOPDIR}/debian71 70 elif [ $ddir = "gentoo" ]; then 72 71 dfam="gentoo" … … 74 73 dver1=`echo ${dver} | sed "s/\.//"` 75 74 suf=".${ddir}${dver1}" 76 BUILDDIR=${TOPDIR}/ebuild77 75 elif [ $ddir = "slackware" ]; then 78 76 dfam="slack" 79 77 dtype="tgz" 80 78 suf=".${dfam}${dver}" 81 BUILDDIR=${TOPDIR}/slack82 79 elif [ $ddir = "sles" -o $ddir = "suse" ]; then 83 80 dfam="suse" 84 81 dtype="rpm" 85 82 suf=".${ddir}${dver}" 86 BUILDDIR=${TOPDIR}/SPECS87 83 elif [ $ddir = "fedora" -o $ddir = "redhat" -o $ddir = "rhel" ]; then 88 84 dfam="redhat" … … 96 92 suf=".rhel${dver1}" 97 93 fi 98 BUILDDIR=${TOPDIR}/SPECS 99 elif [ $ddir = "mandrake" -o $ddir = "mandriva" ]; then 94 elif [ $ddir = "mandrake" ]; then 100 95 dfam="mandriva" 101 96 dtype="rpm" 102 97 suf=".`echo $dver | sed 's/\.//'`mdk" 103 BUILDDIR=${TOPDIR}/SPECS 98 elif [ $ddir = "mandriva" ]; then 99 dfam="mandriva" 100 dtype="rpm" 101 suf=".`echo $dver | sed 's/\.//'`mdv" 104 102 else 105 103 dfam="unknown" 106 104 dtype="unknown" 107 BUILDDIR=${TOPDIR}/SPECS108 105 suf="unknown" 109 106 fi … … 111 108 export dfam 112 109 export dtype 113 export BUILDDIR114 110 export suf 115 111 … … 117 113 # Additional exports and preparation for some distros 118 114 # 115 116 # Default 117 export TOPBUILDDIR=${TOPDIR}/../build 118 119 119 if [ _"$dtype" = _"rpm" ]; then 120 120 export ARCH=`rpm --showrc | egrep "^build arch" | awk '{print $4}'` 121 121 if [ -f ${HOME}/.rpmmacros ]; then 122 122 export TOPBUILDDIR=`egrep '^%_topdir' ${HOME}/.rpmmacros | awk '{print $2}'` 123 else124 export TOPBUILDDIR=${BASE}/build125 123 fi 126 124 mkdir -p ${TOPBUILDDIR}/{RPMS,SRPMS,SPECS,SOURCES,BUILD} 127 125 elif [ _"$dtype" = _"deb" ]; then 128 export TOPBUILDDIR=${BASE}/build129 126 mkdir -p ${TOPBUILDDIR} 130 127 elif [ _"$dtype" = _"ebuild" ]; then 131 export TOPBUILDDIR=${BASE}/build132 128 mkdir -p ${TOPBUILDDIR}/portage 133 129 fi -
trunk/tools/ftp-env
r592 r900 7 7 8 8 # BerliOS FTP/SSH setup 9 export ACCOUNT=bruno@ftp.mondorescue.org 9 /sbin/ifconfig | egrep -q '10\.3' 2>&1 > /dev/null 10 if [ $? = 0 ]; then 11 export DESTMACH=mondo.hpintelco.org 12 else 13 export DESTMACH=www.mondorescue.org 14 fi 15 16 export ACCOUNT=bruno@$DESTMACH 10 17 export DSTDIR=/mondo/ftp 11 18 export FTPSERV="ftp.berlios.de" -
trunk/tools/livwww
r672 r900 31 31 fi 32 32 33 /sbin/ifconfig | egrep -q '10\.3' 2>&1 > /dev/null34 if [ $? = 0 ]; then35 DESTMACH=mondo.hpintelco.org36 else37 DESTMACH=www.mondorescue.org38 fi39 40 33 dname=`dirname $0` 41 34 prem=`echo $dname |cut -c1` … … 48 41 . $TOOLHOME/common-env 49 42 . $TOOLHOME/svn-env 43 . $TOOLHOME/ftp-env 50 44 51 cd ${BASE}/svn 45 # To be safe for SVN commands 46 cd ${TOOLHOME}/.. 52 47 53 48 if [ $force -eq 1 ]; then … … 56 51 fi 57 52 58 svn export $optsvn ${ SVNBRANCH}/website $LOCALDIR53 svn export $optsvn ${TOOLHOME}/../website $LOCALDIR 59 54 60 55 if [ $force -eq 1 ]; then … … 63 58 fi 64 59 65 svn export $optsvn ${ SVNBRANCH}/mondo-doc $LOCALDOC60 svn export $optsvn ${TOOLHOME}/../mondo-doc $LOCALDOC 66 61 67 62 # -
trunk/tools/mkannounce
r764 r900 32 32 SEARCH=`echo $VER | cut -c2-` 33 33 34 rm -f $ TMP/announce.tmp35 cat > $ TMP/announce.tmp << EOF34 rm -f $MONDOTMP/announce.tmp 35 cat > $MONDOTMP/announce.tmp << EOF 36 36 MondoRescue $VER is now available</p> 37 37 … … 43 43 <p> 44 44 EOF 45 ssh ${ACCOUNT} "cd $DSTDIR ; find . -name 'm[oi]nd[io]-[0-9]$SEARCH*'" | grep -v 'src.rpm' >> $ TMP/announce.tmp46 cat >> $ TMP/announce.tmp << EOF45 ssh ${ACCOUNT} "cd $DSTDIR ; find . -name 'm[oi]nd[io]-[0-9]$SEARCH*'" | grep -v 'src.rpm' >> $MONDOTMP/announce.tmp 46 cat >> $MONDOTMP/announce.tmp << EOF 47 47 </p> 48 48 … … 55 55 56 56 # Generating log files 57 $TOOLHOME/mkchangelog.pl announce mindi $ TMP/mindi.ann58 $TOOLHOME/mkchangelog.pl announce mondo $ TMP/mondo.ann59 echo "<p>" >> $ TMP/announce.tmp60 sed 's/$/<br>/' $ TMP/mindi.ann >> $TMP/announce.tmp61 echo "</p><p>" >> $ TMP/announce.tmp62 sed 's/$/<br>/' $ TMP/mondo.ann >> $TMP/announce.tmp63 echo "</p>" >> $ TMP/announce.tmp64 rm -f $ TMP/mindi.ann $TMP/mondo.ann57 $TOOLHOME/mkchangelog.pl announce mindi $MONDOTMP/mindi.ann 58 $TOOLHOME/mkchangelog.pl announce mondo $MONDOTMP/mondo.ann 59 echo "<p>" >> $MONDOTMP/announce.tmp 60 sed 's/$/<br>/' $MONDOTMP/mindi.ann >> $MONDOTMP/announce.tmp 61 echo "</p><p>" >> $MONDOTMP/announce.tmp 62 sed 's/$/<br>/' $MONDOTMP/mondo.ann >> $MONDOTMP/announce.tmp 63 echo "</p>" >> $MONDOTMP/announce.tmp 64 rm -f $MONDOTMP/mindi.ann $MONDOTMP/mondo.ann 65 65 66 vi $ TMP/announce.tmp66 vi $MONDOTMP/announce.tmp 67 67 # Store it in DB for Web pages generation 68 $TOOLHOME/mkannounce.pl $ TMP/announce.tmp68 $TOOLHOME/mkannounce.pl $MONDOTMP/announce.tmp 69 69 # Then deliver it on the Web 70 70 $TOOLHOME/livwww www 71 cat > $ TMP/announce.hdr << EOF71 cat > $MONDOTMP/announce.hdr << EOF 72 72 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/x html1/DTD/xhtml1-strict.dtd"> 73 73 … … 78 78 <p> 79 79 EOF 80 cat > $ TMP/announce.ftr << EOF80 cat > $MONDOTMP/announce.ftr << EOF 81 81 </body> 82 82 </html> 83 83 EOF 84 84 # Mail it to mr ML 85 cat $ TMP/announce.hdr $TMP/announce.tmp $TMP/announce.ftr | w3m -dump -T text/html > $TMP/mondo.ann.txt85 cat $MONDOTMP/announce.hdr $MONDOTMP/announce.tmp $MONDOTMP/announce.ftr | w3m -dump -T text/html > $MONDOTMP/mondo.ann.txt 86 86 export EMAIL="bruno@mondorescue.org" 87 export TMPDIR=$TMP 88 cat $TMP/mondo.ann.txt | mutt -s "`head -1 $TMP/mondo.ann.txt`" mondo-devel@lists.sourceforge.net -c mondorescue-announce@lists.berlios.de 89 rm -rf $TMP 87 cat $MONDOTMP/mondo.ann.txt | mutt -s "`head -1 $MONDOTMP/mondo.ann.txt`" mondo-devel@lists.sourceforge.net -c mondorescue-announce@lists.berlios.de 88 rm -rf $MONDOTMP -
trunk/tools/qemu-vm.txt
r764 r900 4 4 5 5 # RPM based : urpmi, yum install, yast2 6 urpmi neon newt-devel slang-devel autoconf automake libtool gcc rpm-build wget gvim/vim-X11 gcc-c++ docbook-utils-pdf ImageMagick man patch mindi mondo6 urpmi neon newt-devel slang-devel glibc-static-devel autoconf automake libtool gcc rpm-build wget gvim/vim-X11 gcc-c++ docbook-utils-pdf ImageMagick man patch mindi mondo 7 7 8 8 # gentoo -
trunk/tools/quality
r688 r900 28 28 29 29 # How many sprintf/strcat/strcpy vs asprintf are they 30 for s in asprintf sprintf strcat strcpy strncpy fgets malloc malloc_string MAX_STR_LEN getcwd goto; do30 for s in asprintf mr_asprintf sprintf strcat strcpy strncpy fgets malloc mr_malloc malloc_string getline mr_getline MAX_STR_LEN getcwd goto free mr_free; do 31 31 echo "monodrescue $s usage : " 32 32 tot=0 -
trunk/tools/svn-env
r782 r900 6 6 # 7 7 8 export SVNBRANCH="`cat ${TOOLHOME}/../mondo/VERSION`" 9 export VER=`cat ${BASE}/svn/${SVNBRANCH}/mondo/VERSION` 8 export VER=`cat ${TOOLHOME}/../mondo/VERSION` 10 9 11 10 # To be safe for SVN commands -
trunk/tools/svn2build
r839 r900 33 33 34 34 # Make it safe for SVN commands 35 cd ${ BASE}/svn35 cd ${TOOLHOME}/.. 36 36 37 37 for p in $c; do 38 v=`cat ${ SVNBRANCH}/$p/VERSION`38 v=`cat ${TOOLHOME}/../$p/VERSION` 39 39 echo "Management of $p $v-$TAG (rev $REVISION)" 40 dest="$ p-$v"40 dest="$DEST/$p-$v" 41 41 rm -fr $dest 42 svn export ${ SVNBRANCH}/$p $dest42 svn export ${TOOLHOME}/../$p $dest 43 43 echo "$REVISION" > $dest/REVISION 44 44 echo "Generating SVN log file ..." 45 svn log -v ${ SVNBRANCH}/$p > $dest/svn.log45 svn log -v ${TOOLHOME}/../$p > $dest/svn.log 46 46 47 47 for d in `cat ${TOOLHOME}/DISTROS`; do … … 51 51 . $TOOLHOME/distro-env 52 52 53 # Create conf file dir54 mkdir -p ${BUILDDIR}55 56 53 ddd=`LANG=C ; date '+%Y-%m-%d'` 57 cat > $ TMP/mondorescue.mc << EOF54 cat > $MONDOTMP/mondorescue.mc << EOF 58 55 define(\`TTT', ${TAG})dnl 59 56 define(\`RRR', ${TAG}${suf})dnl … … 74 71 echo "Using $inc customization to build SPEC file" 75 72 76 $TOOLHOME/mkchangelog.pl $dtype $p $ TMP/$p.spec73 $TOOLHOME/mkchangelog.pl $dtype $p $MONDOTMP/$p.spec 77 74 if [ $? -ne 0 ]; then 78 75 echo "Unable to create changelog for ${ddir}-$dver/$p.spec" 79 76 exit -1 80 77 fi 81 m4 $ TMP/mondorescue.mc $inc $dest/distributions/rpm/$p.spec $TMP/$p.spec > $dest/distributions/${ddir}-$dver/$p.spec78 m4 $MONDOTMP/mondorescue.mc $inc $dest/distributions/rpm/$p.spec $MONDOTMP/$p.spec > $dest/distributions/${ddir}-$dver/$p.spec 82 79 83 rm -f $ TMP/$p.spec80 rm -f $MONDOTMP/$p.spec 84 81 elif [ "$dtype" = "ebuild" ]; then 85 m4 $ TMP/mondorescue.mc $dest/distributions/$dfam/$p.ebuild > $dest/distributions/${ddir}-$dver/$p-$v.ebuild82 m4 $MONDOTMP/mondorescue.mc $dest/distributions/$dfam/$p.ebuild > $dest/distributions/${ddir}-$dver/$p-$v.ebuild 86 83 elif [ "$dtype" = "deb" ]; then 87 # To be developped88 #m4 $TMP/mondorescue.mc $dest/distributions/$dfam/$p > /dev/null89 84 cp -a $dest/distributions/$ddir/* $dest/distributions/${ddir}-$dver 90 m4 $ TMP/mondorescue.mc $dest/distributions/$ddir/rules > $dest/distributions/${ddir}-$dver/rules85 m4 $MONDOTMP/mondorescue.mc $dest/distributions/$ddir/rules > $dest/distributions/${ddir}-$dver/rules 91 86 $TOOLHOME/mkchangelog.pl $dtype $p $dest/distributions/${ddir}-$dver/changelog 92 87 if [ $? -ne 0 ]; then … … 99 94 done 100 95 96 # The rest is done there 97 cd $DEST 101 98 if [ _"`echo $p | grep mondo-doc`" != _"" ]; then 102 99 cd $dest 103 100 for f in mondorescue-howto.sgml *8; do 104 m4 $ TMP/mondorescue.mc $f > ${f}.new101 m4 $MONDOTMP/mondorescue.mc $f > ${f}.new 105 102 mv ${f}.new $f 106 103 done … … 117 114 118 115 if [ _"`echo $p | grep -vE 'kernel|busybox' | grep mindi`" != _"" ]; then 119 v1=`cat ${ SVNBRANCH}/mondo-doc/VERSION`116 v1=`cat ${TOOLHOME}/../mondo-doc/VERSION` 120 117 if [ ! -d mondo-doc-$v1 ]; then 121 118 echo "mondo-doc should be created before $p" 122 119 exit -1 123 120 fi 124 (cd mondo-doc-$v1 ; make -f Makefile.man install-$p INSTALLDIR=../$ dest)121 (cd mondo-doc-$v1 ; make -f Makefile.man install-$p INSTALLDIR=../$p-$v) 125 122 rm -f $dest/rootfs/sbin/parted2fdisk-ia64 126 123 fi 127 124 if [ "`echo $p | grep -v doc | grep mondo`" != "" ]; then 128 v1=`cat ${ SVNBRANCH}/mondo-doc/VERSION`125 v1=`cat ${TOOLHOME}/../mondo-doc/VERSION` 129 126 if [ ! -d mondo-doc-$v1 ]; then 130 127 echo "mondo-doc should be created before $p" 131 128 exit -1 132 129 fi 133 (cd mondo-doc-$v1 ; make -f Makefile.howto install INSTALLDIR=../$ dest/docs/en ; make -f Makefile.man install-$p INSTALLDIR=../$dest/docs/man)130 (cd mondo-doc-$v1 ; make -f Makefile.howto install INSTALLDIR=../$p-$v/docs/en ; make -f Makefile.man install-$p INSTALLDIR=../$p-$v/docs/man) 134 131 (cd $dest ; echo "Bootstraping mondo ... " ; ./bootstrap) 135 132 fi … … 137 134 # Finally creates the tar files 138 135 echo -n "Creating $p tar files (gzip... " 139 tar cfphz ${DEST}/$p-$v.tar.gz $ dest136 tar cfphz ${DEST}/$p-$v.tar.gz $p-$v 140 137 echo -n " bzip2..." 141 tar cfphj ${DEST}/$p-$v.tar.bz2 $ dest138 tar cfphj ${DEST}/$p-$v.tar.bz2 $p-$v 142 139 echo " )" 143 140 done 144 141 145 rm -rf $ TMP142 rm -rf $MONDOTMP 146 143 147 144 echo "Version delivered :"
Note:
See TracChangeset
for help on using the changeset viewer.