Changeset 3191 in MondoRescue for branches/3.2/mondo/src/common/libmondo-archive.c
- Timestamp:
- Sep 25, 2013, 8:55:45 AM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/3.2/mondo/src/common/libmondo-archive.c
r3185 r3191 64 64 extern bool g_cd_recovery; 65 65 extern char *g_mondo_home; 66 /* 67 extern char *g_tmpfs_mountpt; 68 */ 69 extern char *g_serial_string; 66 67 /** 68 * The serial string (used to differentiate between backups) of the current backup. 69 */ 70 char *g_serial_string = NULL; 71 70 72 extern char *g_getfacl; 71 73 extern char *g_getfattr; … … 200 202 201 203 if (!does_file_exist(filelist)) { 202 mr_asprintf(tmp, "(archive_this_fileset) - filelist %s does not exist", filelist); 203 log_to_screen(tmp); 204 paranoid_free(tmp); 204 log_to_screen("(archive_this_fileset) - filelist %s does not exist", filelist); 205 205 return (1); 206 206 } … … 208 208 mr_asprintf(tmp, "echo hi > %s 2> /dev/null", fname); 209 209 if (system(tmp)) { 210 paranoid_free(tmp);210 mr_free(tmp); 211 211 fatal_error("Unable to write tarball to scratchdir"); 212 212 } 213 213 paranoid_free(tmp); 214 214 215 mr_asprintf(command, "star H=exustar list=%s -c -sparse " STAR_ACL_SZ " file=%s", 216 filelist, fname); 215 mr_asprintf(command, "star H=exustar list=%s -c -sparse " STAR_ACL_SZ " file=%s", filelist, fname); 217 216 if (bkpinfo->use_lzo) { 217 mr_free(command); 218 218 fatal_error("Can't use lzop"); 219 219 } … … 235 235 res = 0; 236 236 } 237 paranoid_free(tmp);237 mr_free(tmp); 238 238 239 239 if (res) { … … 251 251 } 252 252 } 253 paranoid_free(command);253 mr_free(command); 254 254 255 255 retval += res; … … 307 307 308 308 if (!does_file_exist(filelist)) { 309 mr_asprintf(tmp, "(archive_this_fileset) - filelist %s does not exist", 310 filelist); 311 log_to_screen(tmp); 312 paranoid_free(tmp); 309 log_to_screen("(archive_this_fileset) - filelist %s does not exist", filelist); 313 310 return (1); 314 311 } 315 312 mr_asprintf(tmp, "echo hi > %s 2> /dev/null", fname); 316 313 if (system(tmp)) { 317 paranoid_free(tmp);314 mr_free(tmp); 318 315 fatal_error("Unable to write tarball to scratchdir"); 319 316 } 320 paranoid_free(tmp);317 mr_free(tmp); 321 318 322 319 … … 324 321 mr_asprintf(tmp, "%s/do-not-compress-these", g_mondo_home); 325 322 // -b %ld, TAPE_BLOCK_SIZE 326 mr_asprintf(zipparams, "-Z -P %s -G %d -T 3k", bkpinfo->zip_exe, 327 bkpinfo->compression_level); 323 mr_asprintf(zipparams, "-Z -P %s -G %d -T 3k", bkpinfo->zip_exe, bkpinfo->compression_level); 328 324 if (does_file_exist(tmp)) { 329 325 mr_strcat(zipparams, " -E %s",tmp); … … 331 327 log_msg(3, "%s not found. Cannot exclude zipfiles, etc.", tmp); 332 328 } 333 paranoid_free(tmp);329 mr_free(tmp); 334 330 } else { 335 331 mr_asprintf(zipparams, ""); 336 332 } 337 338 // make_hole_for_file(fname);339 333 340 334 if (!does_file_exist(bkpinfo->tmpdir)) { … … 346 340 fatal_error("scratchdir not found"); 347 341 } 348 mr_asprintf(command, "rm -f %s %s. %s.gz %s.%s", fname, fname, fname, 349 fname, bkpinfo->zip_suffix); 342 mr_asprintf(command, "rm -f %s %s. %s.gz %s.%s", fname, fname, fname, fname, bkpinfo->zip_suffix); 350 343 paranoid_system(command); 351 paranoid_free(command); 352 353 mr_asprintf(command, "afio -o -b %ld -M 16m %s %s < %s 2>> %s", 354 TAPE_BLOCK_SIZE, zipparams, fname, filelist, MONDO_LOGFILE); 355 paranoid_free(zipparams); 344 mr_free(command); 345 346 mr_asprintf(command, "afio -o -b %ld -M 16m %s %s < %s 2>> %s", TAPE_BLOCK_SIZE, zipparams, fname, filelist, MONDO_LOGFILE); 347 mr_free(zipparams); 356 348 357 349 mr_asprintf(tmp, "echo hi > %s 2> /dev/null", fname); 358 350 if (system(tmp)) { 359 paranoid_free(tmp);351 mr_free(tmp); 360 352 fatal_error("Unable to write tarball to scratchdir"); 361 353 } 362 paranoid_free(tmp);354 mr_free(tmp); 363 355 364 356 for (res = 99, tries = 0; tries < 3 && res != 0; tries++) { … … 406 398 { 407 399 int retval = 0, res = 0; 408 char *tmp ;400 char *tmp = NULL; 409 401 410 402 assert(bkpinfo != NULL); 411 403 set_g_cdrom_and_g_dvd_to_bkpinfo_value(); 412 malloc_string(tmp);413 404 if (bkpinfo->backup_media_type == dvd) { 414 405 #ifdef DVDRWFORMAT … … 431 422 } 432 423 433 /* 434 sprintf(tmp, "wc -l %s/archives/filelist.full > %s/archives/filelist.count",bkpinfo->scratchdir, bkpinfo->scratchdir); 435 if (run_program_and_log_output(tmp, 2)) 436 { fatal_error("Failed to count filelist.full"); } 437 */ 438 sprintf(tmp, "gzip -9 %s/archives/filelist.full", bkpinfo->scratchdir); 424 mr_asprintf(tmp, "gzip -9 %s/archives/filelist.full", bkpinfo->scratchdir); 439 425 if (run_program_and_log_output(tmp, 2)) { 426 mr_free(tmp); 440 427 fatal_error("Failed to gzip filelist.full"); 441 428 } 442 sprintf(tmp, "cp -f %s/archives/*list*.gz %s", bkpinfo->scratchdir, 443 bkpinfo->tmpdir); 429 mr_free(tmp); 430 431 mr_asprintf(tmp, "cp -f %s/archives/*list*.gz %s", bkpinfo->scratchdir, bkpinfo->tmpdir); 444 432 if (run_program_and_log_output(tmp, 2)) { 433 mr_free(tmp); 445 434 fatal_error("Failed to copy to tmpdir"); 446 435 } 436 mr_free(tmp); 447 437 448 438 copy_mondo_and_mindi_stuff_to_scratchdir(); // payload, too, if it exists … … 464 454 } 465 455 retval += do_that_initial_phase(); // prepare 466 sprintf(tmp, "rm -f %s/images/*.iso", bkpinfo->scratchdir);456 mr_asprintf(tmp, "rm -f %s/images/*.iso", bkpinfo->scratchdir); 467 457 run_program_and_log_output(tmp, 1); 458 mr_free(tmp); 459 468 460 retval += make_those_afios_phase(); // backup regular files 469 461 retval += make_those_slices_phase(); // backup BIG files … … 473 465 sleep(2); 474 466 } 475 paranoid_free(tmp);476 467 return (retval); 477 468 } … … 514 505 char *use_lzo_sz = NULL; 515 506 char *use_gzip_sz = NULL; 507 char *use_lzma_sz = NULL; 516 508 char *use_comp_sz = NULL; 517 509 char *use_star_sz = NULL; … … 542 534 assert(bkpinfo != NULL); 543 535 544 mvaddstr_and_log_it(g_currentY, 0, 545 "Calling MINDI to create boot+data disks"); 536 mvaddstr_and_log_it(g_currentY, 0, "Calling MINDI to create boot+data disks"); 546 537 open_evalcall_form("Calling MINDI to create boot+data disks"); 547 538 mr_asprintf(tmp, "%s/filelist.full", bkpinfo->tmpdir); … … 550 541 mr_asprintf(tmp, "%s/tmpfs/filelist.full", bkpinfo->tmpdir); 551 542 if (!does_file_exist(tmp)) { 552 fatal_error553 543 mr_free(tmp); 544 fatal_error ("Cannot find filelist.full, so I cannot count its lines"); 554 545 } 555 546 } … … 571 562 } 572 563 } 573 paranoid_free(ntapedev);564 mr_free(ntapedev); 574 565 mr_asprintf(tape_device, "%s", bkpinfo->media_device); 575 566 } else { … … 586 577 } else { 587 578 mr_asprintf(use_gzip_sz, "no"); 579 } 580 if (bkpinfo->use_lzma) { 581 mr_asprintf(use_lzma_sz, "yes"); 582 } else { 583 mr_asprintf(use_lzma_sz, "no"); 588 584 } 589 585 if (bkpinfo->use_star) { … … 660 656 ch = 'U'; 661 657 if (bkpinfo->boot_loader != '\0') { 662 mr_asprintf(tmp, "User specified boot loader. It is '%c'.", bkpinfo->boot_loader); 663 log_msg(2, tmp); 664 mr_free(tmp); 658 log_msg(2, "User specified boot loader. It is '%c'.", bkpinfo->boot_loader); 665 659 } else { 666 660 bkpinfo->boot_loader = ch; 667 661 } 668 662 if (bkpinfo->boot_device[0] != '\0') { 669 mr_asprintf(tmp, "User specified boot device. It is '%s'.", bkpinfo->boot_device); 670 log_msg(2, tmp); 671 mr_free(tmp); 663 log_msg(2, "User specified boot device. It is '%s'.", bkpinfo->boot_device); 672 664 } else { 673 665 strcpy(bkpinfo->boot_device, bootdev); … … 692 684 mr_asprintf(bootldr_str, "LILO"); 693 685 if (!does_file_exist("/etc/lilo.conf")) { 694 fatal_error 695 ("The de facto standard location for your boot loader's config file is /etc/lilo.conf but I cannot find it there. What is wrong with your Linux distribution?"); 686 fatal_error("The de facto standard location for your boot loader's config file is /etc/lilo.conf but I cannot find it there. What is wrong with your Linux distribution?"); 696 687 } 697 688 } else if (bkpinfo->boot_loader == 'G') { 698 689 mr_asprintf(bootldr_str, "GRUB"); 699 if (!does_file_exist("/boot/grub/menu.lst") 700 && does_file_exist("/boot/grub/grub.conf")) { 701 run_program_and_log_output 702 ("ln -sf /boot/grub/grub.conf /boot/grub/menu.lst", 5); 690 if (!does_file_exist("/boot/grub/menu.lst") && does_file_exist("/boot/grub/grub.conf")) { 691 run_program_and_log_output("ln -sf /boot/grub/grub.conf /boot/grub/menu.lst", 5); 703 692 } 704 693 if ((!does_file_exist("/boot/grub/menu.lst")) && (!does_file_exist("/boot/grub/grub.cfg")) && (!does_file_exist("/boot/grub2/grub.cfg"))) { 705 fatal_error 706 ("The de facto standard location for your boot loader's config file is /boot/grub/menu.lst, /boot/grub/grub.cfg, or /boot/grub2/grub.cfg but I cannot find it there. What is wrong with your Linux distribution?"); 694 fatal_error("The de facto standard location for your boot loader's config file is /boot/grub/menu.lst, /boot/grub/grub.cfg, or /boot/grub2/grub.cfg but I cannot find it there. What is wrong with your Linux distribution?"); 707 695 } 708 696 mr_asprintf(bootldr_ver, "%s", call_program_and_get_last_line_of_output("grub --version")); … … 710 698 mr_asprintf(bootldr_str, "ELILO"); 711 699 /* BCO: fix it for Debian, Mandrake, ... */ 712 if (!does_file_exist("/etc/elilo.conf") 713 && does_file_exist("/boot/efi/efi/redhat/elilo.conf")) { 714 run_program_and_log_output 715 ("ln -sf /boot/efi/efi/redhat/elilo.conf /etc/elilo.conf", 716 5); 717 } 718 if (!does_file_exist("/etc/elilo.conf") 719 && does_file_exist("/boot/efi/efi/SuSE/elilo.conf")) { 720 run_program_and_log_output 721 ("ln -sf /boot/efi/efi/SuSE/elilo.conf /etc/elilo.conf", 722 5); 723 } 724 if (!does_file_exist("/etc/elilo.conf") 725 && does_file_exist("/boot/efi/efi/debian/elilo.conf")) { 726 run_program_and_log_output 727 ("ln -sf /boot/efi/efi/debian/elilo.conf /etc/elilo.conf", 728 5); 729 } 730 if (!does_file_exist("/etc/elilo.conf") 731 && does_file_exist("/boot/efi/debian/elilo.conf")) { 732 run_program_and_log_output 733 ("ln -sf /boot/efi/debian/elilo.conf /etc/elilo.conf", 734 5); 700 if (!does_file_exist("/etc/elilo.conf") && does_file_exist("/boot/efi/efi/redhat/elilo.conf")) { 701 run_program_and_log_output("ln -sf /boot/efi/efi/redhat/elilo.conf /etc/elilo.conf", 5); 702 } 703 if (!does_file_exist("/etc/elilo.conf") && does_file_exist("/boot/efi/efi/SuSE/elilo.conf")) { 704 run_program_and_log_output("ln -sf /boot/efi/efi/SuSE/elilo.conf /etc/elilo.conf", 5); 705 } 706 if (!does_file_exist("/etc/elilo.conf") && does_file_exist("/boot/efi/efi/debian/elilo.conf")) { 707 run_program_and_log_output ("ln -sf /boot/efi/efi/debian/elilo.conf /etc/elilo.conf", 5); 708 } 709 if (!does_file_exist("/etc/elilo.conf") && does_file_exist("/boot/efi/debian/elilo.conf")) { 710 run_program_and_log_output ("ln -sf /boot/efi/debian/elilo.conf /etc/elilo.conf", 5); 735 711 } 736 712 if (!does_file_exist("/etc/elilo.conf")) { 737 fatal_error 738 ("The de facto mondo standard location for your boot loader's config file is /etc/elilo.conf but I cannot find it there. What is wrong with your Linux distribution? Try finding it under /boot/efi and do 'ln -s /boot/efi/..../elilo.conf /etc/elilo.conf'"); 713 fatal_error("The de facto mondo standard location for your boot loader's config file is /etc/elilo.conf but I cannot find it there. What is wrong with your Linux distribution? Try finding it under /boot/efi and do 'ln -s /boot/efi/..../elilo.conf /etc/elilo.conf'"); 739 714 } 740 715 } else if (bkpinfo->boot_loader == 'R') { … … 753 728 mr_asprintf(bootldr_str, "unknown"); 754 729 } 755 mr_asprintf(tmp, "Your boot loader is %s and it boots from %s", bootldr_str, bkpinfo->boot_device); 756 log_to_screen(tmp); 757 mr_free(tmp); 730 log_to_screen("Your boot loader is %s and it boots from %s", bootldr_str, bkpinfo->boot_device); 731 758 732 if (bootldr_ver != NULL) { 759 mr_asprintf(tmp, "Boot loader version string: %s", bootldr_ver); 760 log_to_screen(tmp); 761 mr_free(tmp); 733 log_to_screen("Boot loader version string: %s", bootldr_ver); 762 734 } 763 735 … … 799 771 fatal_error("Unknown backup_media_type"); 800 772 } 801 if (bkpinfo->backup_media_type == usb) { 773 774 if ((bkpinfo->backup_media_type == usb) && (bkpinfo->media_device)) { 802 775 mr_asprintf(tmp2, "--usb %s", bkpinfo->media_device); 803 776 } else { … … 808 781 if (write_one_liner_data_file(tmp, value)) { 809 782 res++; 810 log_msg(1, "%ld: Unable to write one-liner backup-media-type", 811 __LINE__); 783 log_msg(1, "%ld: Unable to write one-liner backup-media-type", __LINE__); 812 784 } 813 785 mr_free(value); … … 817 789 if (write_one_liner_data_file(tmp, bootldr_str)) { 818 790 res++; 819 log_msg(1, "%ld: Unable to write one-liner bootloader.name", 820 __LINE__); 791 log_msg(1, "%ld: Unable to write one-liner bootloader.name", __LINE__); 821 792 } 822 793 mr_free(bootldr_str); … … 865 836 } 866 837 867 estimated_total_noof_slices = 868 size_of_all_biggiefiles_K(bkpinfo) / bkpinfo->optimal_set_size + 1; 869 /* add netfs stuff here? */838 estimated_total_noof_slices = size_of_all_biggiefiles_K(bkpinfo) / bkpinfo->optimal_set_size + 1; 839 840 /* TODO: add netfs stuff here? */ 870 841 mr_asprintf(command, "mkdir -p %s/images", bkpinfo->scratchdir); 871 842 if (system(command)) { … … 873 844 log_OS_error("Unable to make images directory"); 874 845 } 875 paranoid_free(command);846 mr_free(command); 876 847 log_msg(1, "lines_in_filelist = %ld", lines_in_filelist); 877 848 update_evalcall_form(3); … … 890 861 use_lzo_sz, // parameter #8 891 862 cd_recovery_sz, // parameter #9 892 bkpinfo->image_devs, // parameter #10863 (bkpinfo->image_devs == NULL) ? "\"\"" : bkpinfo->image_devs, // parameter #10 893 864 broken_bios_sz, // parameter #11 894 865 last_filelist_number, // parameter #12 (STRING) … … 900 871 bkpinfo->internal_tape_block_size, // parameter #18 (LONG) 901 872 bkpinfo->differential, // parameter #19 (INT) 902 use_gzip_sz); // parameter #20 (STRING) 873 use_gzip_sz, // parameter #19 (STRING) 874 use_lzma_sz, // parameter #20 (STRING) 875 value, // parameter #21 (STRING) 876 MONDO_LOGFILE); 903 877 904 878 mr_free(last_filelist_number); … … 906 880 mr_free(use_lzo_sz); 907 881 mr_free(use_gzip_sz); 882 mr_free(use_lzma_sz); 908 883 mr_free(use_star_sz); 909 884 mr_free(use_comp_sz); … … 913 888 mr_free(tape_size_sz); 914 889 890 /* This parameter is always the last one and optional */ 915 891 if (bkpinfo->nonbootable_backup) { 916 892 mr_strcat(command, " NONBOOTABLE"); … … 929 905 if (!res) { 930 906 log_to_screen("Boot+data disks were created OK"); 931 mr_asprintf(command, "cp -f %s/images/mindi.iso %s/mondorescue.iso", 932 bkpinfo->scratchdir, MINDI_CACHE); 907 mr_asprintf(command, "cp -f %s/images/mindi.iso %s/mondorescue.iso", bkpinfo->scratchdir, MINDI_CACHE); 933 908 log_msg(2, command); 934 909 run_program_and_log_output(command, FALSE); 935 paranoid_free(command);910 mr_free(command); 936 911 937 912 if (bkpinfo->nonbootable_backup) { 938 mr_asprintf(command, "cp -f %s/all.tar.gz %s/images", 939 bkpinfo->tmpdir, bkpinfo->scratchdir); 913 mr_asprintf(command, "cp -f %s/all.tar.gz %s/images", bkpinfo->tmpdir, bkpinfo->scratchdir); 940 914 if (system(command)) { 941 paranoid_free(command);915 mr_free(command); 942 916 fatal_error("Unable to create temporary all tarball"); 943 917 } 944 paranoid_free(command);918 mr_free(command); 945 919 } 946 920 /* For USB we already have everything on the key */ … … 948 922 mr_asprintf(command, "rm -rf %s/images", bkpinfo->scratchdir); 949 923 run_program_and_log_output(command, FALSE); 950 paranoid_free(command);924 mr_free(command); 951 925 } else { 952 mr_asprintf(tmp, "cp -f %s/images/all.tar.gz %s", bkpinfo->scratchdir, 953 bkpinfo->tmpdir); 926 mr_asprintf(tmp, "cp -f %s/images/all.tar.gz %s", bkpinfo->scratchdir, bkpinfo->tmpdir); 954 927 if (system(tmp)) { 955 928 fatal_error("Cannot find all.tar.gz in tmpdir"); … … 966 939 mr_asprintf(command, "grep 'Fatal error' /var/log/mindi.log"); 967 940 mr_asprintf(tmp, "%s", call_program_and_get_last_line_of_output(command)); 968 paranoid_free(command);941 mr_free(command); 969 942 970 943 if (strlen(tmp) > 1) { … … 1017 990 void *create_afio_files_in_background(void *inbuf) 1018 991 { 1019 long int archiving_set_no ;1020 char *archiving_filelist_fname ;1021 char *archiving_afioball_fname ;992 long int archiving_set_no = 0L; 993 char *archiving_filelist_fname = NULL; 994 char *archiving_afioball_fname = NULL; 1022 995 char *curr_xattr_list_fname = NULL; 1023 char *curr_acl_list_fname ;1024 1025 char *tmp ;996 char *curr_acl_list_fname = NULL; 997 998 char *tmp = NULL; 1026 999 int res = 0, retval = 0; 1027 1000 int *p_archival_threads_running; … … 1031 1004 int this_thread_no = g_current_thread_no++; 1032 1005 1033 malloc_string(curr_xattr_list_fname);1034 malloc_string(curr_acl_list_fname);1035 malloc_string(archiving_filelist_fname);1036 malloc_string(archiving_afioball_fname);1037 malloc_string(tmp);1038 1006 p_last_set_archived = (int *) inbuf; 1039 1007 p_archival_threads_running = (int *) (inbuf + 4); … … 1041 1009 p_list_of_fileset_flags = (char *) (inbuf + 12); 1042 1010 1043 sprintf(archiving_filelist_fname, FILELIST_FNAME_RAW_SZ, 1044 bkpinfo->tmpdir, 0L); 1045 for (archiving_set_no = 0L; does_file_exist(archiving_filelist_fname); 1046 sprintf(archiving_filelist_fname, FILELIST_FNAME_RAW_SZ, 1047 bkpinfo->tmpdir, archiving_set_no)) { 1011 mr_asprintf(archiving_filelist_fname, FILELIST_FNAME_RAW_SZ, bkpinfo->tmpdir, 0L); 1012 1013 while (does_file_exist(archiving_filelist_fname)) { 1048 1014 if (g_exiting) { 1015 mr_free(archiving_filelist_fname); 1049 1016 fatal_error("Execution run aborted (pthread)"); 1050 1017 } 1051 1018 if (archiving_set_no >= MAX_NOOF_SETS_HERE) { 1052 fatal_error1053 1019 mr_free(archiving_filelist_fname); 1020 fatal_error("Maximum number of filesets exceeded. Adjust MAX_NOOF_SETS_HERE, please."); 1054 1021 } 1055 1022 if (!semaphore_p()) { 1056 1023 log_msg(3, "P sem failed (pid=%d)", (int) getpid()); 1024 mr_free(archiving_filelist_fname); 1057 1025 fatal_error("Cannot get semaphore P"); 1058 1026 } … … 1062 1030 *p_next_set_to_archive = *p_next_set_to_archive + 1; 1063 1031 if (!semaphore_v()) { 1032 mr_free(archiving_filelist_fname); 1064 1033 fatal_error("Cannot get semaphore V"); 1065 1034 } 1066 1035 1067 1036 /* backup this set of files */ 1068 sprintf(archiving_afioball_fname, AFIOBALL_FNAME_RAW_SZ, 1069 bkpinfo->tmpdir, archiving_set_no, bkpinfo->zip_suffix); 1070 sprintf(archiving_filelist_fname, FILELIST_FNAME_RAW_SZ, 1071 bkpinfo->tmpdir, archiving_set_no); 1037 mr_asprintf(archiving_afioball_fname, AFIOBALL_FNAME_RAW_SZ, bkpinfo->tmpdir, archiving_set_no, bkpinfo->zip_suffix); 1038 mr_free(archiving_filelist_fname); 1039 mr_asprintf(archiving_filelist_fname, FILELIST_FNAME_RAW_SZ, bkpinfo->tmpdir, archiving_set_no); 1072 1040 if (!does_file_exist(archiving_filelist_fname)) { 1073 log_msg(3, 1074 "%s[%d:%d] - well, I would archive %d, except that it doesn't exist. I'll stop now.", 1075 FORTY_SPACES, getpid(), this_thread_no, 1076 archiving_set_no); 1041 log_msg(3, "%s[%d:%d] - well, I would archive %d, except that it doesn't exist. I'll stop now.", FORTY_SPACES, getpid(), this_thread_no, archiving_set_no); 1042 mr_free(archiving_afioball_fname); 1077 1043 break; 1078 1044 } 1079 1045 1080 sprintf(tmp, AFIOBALL_FNAME_RAW_SZ, bkpinfo->tmpdir, 1081 archiving_set_no - ARCH_BUFFER_NUM, bkpinfo->zip_suffix); 1046 mr_asprintf(tmp, AFIOBALL_FNAME_RAW_SZ, bkpinfo->tmpdir, archiving_set_no - ARCH_BUFFER_NUM, bkpinfo->zip_suffix); 1082 1047 if (does_file_exist(tmp)) { 1083 log_msg(4, "%s[%d:%d] - waiting for storer", FORTY_SPACES, 1084 getpid(), this_thread_no); 1048 log_msg(4, "%s[%d:%d] - waiting for storer", FORTY_SPACES, getpid(), this_thread_no); 1085 1049 while (does_file_exist(tmp)) { 1086 1050 sleep(1); … … 1088 1052 log_msg(4, "[%d] - continuing", getpid()); 1089 1053 } 1090 1091 log_msg(4, "%s[%d:%d] - EXATing %d...", FORTY_SPACES, getpid(), 1092 this_thread_no, archiving_set_no); 1054 mr_free(tmp); 1055 1056 log_msg(4, "%s[%d:%d] - EXATing %d...", FORTY_SPACES, getpid(), this_thread_no, archiving_set_no); 1057 1093 1058 if (g_getfattr) { 1094 sprintf(curr_xattr_list_fname, XATTR_LIST_FNAME_RAW_SZ, 1095 bkpinfo->tmpdir, archiving_set_no); 1059 mr_asprintf(curr_xattr_list_fname, XATTR_LIST_FNAME_RAW_SZ, bkpinfo->tmpdir, archiving_set_no); 1096 1060 get_fattr_list(archiving_filelist_fname, curr_xattr_list_fname); 1061 mr_free(curr_xattr_list_fname); 1097 1062 } 1098 1063 if (g_getfacl) { 1099 sprintf(curr_acl_list_fname, ACL_LIST_FNAME_RAW_SZ, 1100 bkpinfo->tmpdir, archiving_set_no); 1064 mr_asprintf(curr_acl_list_fname, ACL_LIST_FNAME_RAW_SZ, bkpinfo->tmpdir, archiving_set_no); 1101 1065 get_acl_list(archiving_filelist_fname, curr_acl_list_fname); 1102 } 1103 1104 log_msg(4, "%s[%d:%d] - archiving %d...", FORTY_SPACES, getpid(), 1105 this_thread_no, archiving_set_no); 1106 res = 1107 archive_this_fileset(archiving_filelist_fname, 1108 archiving_afioball_fname, 1109 archiving_set_no); 1066 mr_free(curr_acl_list_fname); 1067 } 1068 1069 log_msg(4, "%s[%d:%d] - archiving %d...", FORTY_SPACES, getpid(), this_thread_no, archiving_set_no); 1070 res = archive_this_fileset(archiving_filelist_fname, archiving_afioball_fname, archiving_set_no); 1071 mr_free(archiving_afioball_fname); 1072 1110 1073 retval += res; 1111 1074 1112 1075 if (res) { 1113 sprintf(tmp, 1114 "Errors occurred while archiving set %ld. Please review logs.", 1115 archiving_set_no); 1116 log_to_screen(tmp); 1117 } 1076 log_to_screen("Errors occurred while archiving set %ld. Please review logs.", archiving_set_no); 1077 } 1078 1118 1079 if (!semaphore_p()) { 1080 mr_free(archiving_filelist_fname); 1119 1081 fatal_error("Cannot get semaphore P"); 1120 1082 } … … 1127 1089 1128 1090 if (!semaphore_v()) { 1091 mr_free(archiving_filelist_fname); 1129 1092 fatal_error("Cannot get semaphore V"); 1130 1093 } 1131 log_msg(4, "%s[%d:%d] - archived %d OK", FORTY_SPACES, getpid(), 1132 this_thread_no, archiving_set_no); 1094 log_msg(4, "%s[%d:%d] - archived %d OK", FORTY_SPACES, getpid(), this_thread_no, archiving_set_no); 1133 1095 archiving_set_no++; 1134 } 1096 1097 mr_free(archiving_filelist_fname); 1098 mr_asprintf(archiving_filelist_fname, FILELIST_FNAME_RAW_SZ, bkpinfo->tmpdir, archiving_set_no); 1099 } 1100 mr_free(archiving_filelist_fname); 1101 1135 1102 if (!semaphore_p()) { 1136 1103 fatal_error("Cannot get semaphore P"); … … 1140 1107 fatal_error("Cannot get semaphore V"); 1141 1108 } 1142 log_msg(3, "%s[%d:%d] - exiting", FORTY_SPACES, getpid(), 1143 this_thread_no); 1144 paranoid_free(archiving_filelist_fname); 1145 paranoid_free(archiving_afioball_fname); 1146 paranoid_free(curr_xattr_list_fname); 1147 paranoid_free(curr_acl_list_fname); 1148 paranoid_free(tmp); 1109 log_msg(3, "%s[%d:%d] - exiting", FORTY_SPACES, getpid(), this_thread_no); 1149 1110 pthread_exit(NULL); 1150 1111 } … … 1228 1189 1229 1190 /*@ buffers *********************************** */ 1230 char *command, *tmpfile, *data_disks_file; 1191 char *command = NULL; 1192 char *tmpfile = NULL; 1193 char *data_disks_file = NULL; 1231 1194 1232 1195 assert(bkpinfo != NULL); 1233 malloc_string(command); 1234 malloc_string(tmpfile); 1235 malloc_string(data_disks_file); 1236 sprintf(data_disks_file, "%s/all.tar.gz", bkpinfo->tmpdir); 1237 1238 snprintf(g_serial_string, MAX_STR_LEN - 8, "%s", 1239 call_program_and_get_last_line_of_output("dd \ 1240 if=/dev/urandom bs=16 count=1 2> /dev/null | \ 1241 hexdump | tr -s ' ' '0' | head -n1")); 1196 mr_asprintf(data_disks_file, "%s/all.tar.gz", bkpinfo->tmpdir); 1197 1198 snprintf(g_serial_string, MAX_STR_LEN - 8, "%s", call_program_and_get_last_line_of_output("dd if=/dev/urandom bs=16 count=1 2> /dev/null | hexdump | tr -s ' ' '0' | head -n1")); 1242 1199 strip_spaces(g_serial_string); 1243 1200 strcat(g_serial_string, "...word."); … … 1245 1202 assert(strlen(g_serial_string) < MAX_STR_LEN); 1246 1203 1247 sprintf(tmpfile, "%s/archives/SERIAL-STRING", bkpinfo->scratchdir);1204 mr_asprintf(tmpfile, "%s/archives/SERIAL-STRING", bkpinfo->scratchdir); 1248 1205 if (write_one_liner_data_file(tmpfile, g_serial_string)) { 1249 1206 log_msg(1, "%ld: Failed to write serial string", __LINE__); 1250 1207 } 1208 mr_free(tmpfile); 1251 1209 1252 1210 mvaddstr_and_log_it(g_currentY, 0, "Preparing to archive your data"); … … 1269 1227 } 1270 1228 } 1271 1272 sprintf(command, "rm -f %s/%s/%s-[1-9]*.iso", bkpinfo->isodir, 1273 1229 mr_free(data_disks_file); 1230 1231 mr_asprintf(command, "rm -f %s/%s/%s-[1-9]*.iso", bkpinfo->isodir, bkpinfo->netfs_remote_dir, bkpinfo->prefix); 1274 1232 paranoid_system(command); 1233 mr_free(command); 1234 1275 1235 wipe_archives(bkpinfo->scratchdir); 1276 1236 mvaddstr_and_log_it(g_currentY++, 74, "Done."); … … 1281 1241 BLK_START_OF_BACKUP); 1282 1242 } 1283 paranoid_free(command);1284 paranoid_free(tmpfile);1285 paranoid_free(data_disks_file);1286 1243 return (retval); 1287 1244 } … … 1356 1313 1357 1314 /*@ buffers ********************************************** */ 1358 char *storing_filelist_fname ;1359 char *storing_afioball_fname ;1315 char *storing_filelist_fname = NULL; 1316 char *storing_afioball_fname = NULL; 1360 1317 char *tmp = NULL; 1361 1318 char *media_usage_comment = NULL; … … 1374 1331 assert(bkpinfo != NULL); 1375 1332 malloc_string(result_str); 1376 malloc_string(curr_xattr_list_fname); 1377 malloc_string(curr_acl_list_fname); 1378 malloc_string(storing_filelist_fname); 1379 malloc_string(storing_afioball_fname); 1380 transfer_block = 1381 malloc(sizeof(struct s_bkpinfo) + BKPINFO_LOC_OFFSET + 64); 1382 memset((void *) transfer_block, 0, 1383 sizeof(struct s_bkpinfo) + BKPINFO_LOC_OFFSET + 64); 1333 transfer_block = malloc(sizeof(struct s_bkpinfo) + BKPINFO_LOC_OFFSET + 64); 1334 memset((void *) transfer_block, 0, sizeof(struct s_bkpinfo) + BKPINFO_LOC_OFFSET + 64); 1384 1335 p_last_set_archived = (int *) transfer_block; 1385 1336 p_archival_threads_running = (int *) (transfer_block + 4); 1386 1337 p_next_set_to_archive = (int *) (transfer_block + 8); 1387 1338 p_list_of_fileset_flags = (char *) (transfer_block + 12); 1388 memcpy((void *) (transfer_block + BKPINFO_LOC_OFFSET), 1389 (void *) bkpinfo, sizeof(struct s_bkpinfo)); 1339 memcpy((void *) (transfer_block + BKPINFO_LOC_OFFSET), (void *) bkpinfo, sizeof(struct s_bkpinfo)); 1390 1340 pvp = &vp; 1391 1341 vp = (void *) result_str; … … 1399 1349 "Please wait. This may take a couple of hours.", 1400 1350 "Working...", 1401 get_last_filelist_number() + 1);1351 (long)get_last_filelist_number() + 1L); 1402 1352 1403 1353 log_msg(5, "We're gonna party like it's your birthday."); … … 1438 1388 if (!get_bit_N_of_array 1439 1389 (p_list_of_fileset_flags, storing_set_no)) { 1440 misc_counter_that_is_not_important = 1441 (misc_counter_that_is_not_important + 1) % 5; 1390 misc_counter_that_is_not_important = (misc_counter_that_is_not_important + 1) % 5; 1442 1391 /* BCO the media_usage_comment is not really initialized there ! 1443 1392 if (!misc_counter_that_is_not_important) { … … 1446 1395 */ 1447 1396 sleep(1); 1448 } else 1397 } else { 1449 1398 // store set N 1450 { 1451 sprintf(storing_filelist_fname, FILELIST_FNAME_RAW_SZ, 1452 bkpinfo->tmpdir, storing_set_no); 1453 sprintf(storing_afioball_fname, AFIOBALL_FNAME_RAW_SZ, 1454 bkpinfo->tmpdir, storing_set_no, bkpinfo->zip_suffix); 1399 mr_asprintf(storing_filelist_fname, FILELIST_FNAME_RAW_SZ, bkpinfo->tmpdir, storing_set_no); 1400 mr_asprintf(storing_afioball_fname, AFIOBALL_FNAME_RAW_SZ, bkpinfo->tmpdir, storing_set_no, bkpinfo->zip_suffix); 1455 1401 if (g_getfattr) { 1456 sprintf(curr_xattr_list_fname, XATTR_LIST_FNAME_RAW_SZ, 1457 bkpinfo->tmpdir, storing_set_no); 1402 mr_asprintf(curr_xattr_list_fname, XATTR_LIST_FNAME_RAW_SZ, bkpinfo->tmpdir, storing_set_no); 1458 1403 } 1459 1404 if (g_getfacl) { 1460 sprintf(curr_acl_list_fname, ACL_LIST_FNAME_RAW_SZ, 1461 bkpinfo->tmpdir, storing_set_no); 1405 mr_asprintf(curr_acl_list_fname, ACL_LIST_FNAME_RAW_SZ, bkpinfo->tmpdir, storing_set_no); 1462 1406 } 1463 1407 … … 1470 1414 sleep(5); 1471 1415 } 1472 mr_asprintf(media_usage_comment, "%s", percent_media_full_comment());1473 1416 /* copy to CD (scratchdir) ... and an actual CD-R if necessary */ 1474 1417 if (IS_THIS_A_STREAMING_BACKUP(bkpinfo->backup_media_type)) { 1475 1418 register_in_tape_catalog(fileset, storing_set_no, -1, 1476 1419 storing_afioball_fname); 1477 maintain_collection_of_recent_archives(bkpinfo->tmpdir, 1478 storing_afioball_fname); 1420 maintain_collection_of_recent_archives(bkpinfo->tmpdir, storing_afioball_fname); 1479 1421 log_it("Writing EXAT files"); 1480 1422 res += … … 1510 1452 retval += res; 1511 1453 g_current_progress++; 1454 mr_asprintf(media_usage_comment, "%s", percent_media_full_comment()); 1512 1455 update_progress_form(media_usage_comment); 1513 1456 mr_free(media_usage_comment); 1514 1457 if (res) { 1515 mr_asprintf(tmp, "Failed to add archive %ld's files to CD dir\n", 1516 storing_set_no); 1517 log_to_screen(tmp); 1518 paranoid_free(tmp); 1519 fatal_error 1520 ("Is your hard disk full? If not, please send the author the logfile."); 1458 log_to_screen("Failed to add archive %ld's files to CD dir\n", storing_set_no); 1459 fatal_error("Is your hard disk full? If not, please send the author the logfile."); 1521 1460 } 1522 1461 storing_set_no++; 1523 1462 // sleep(2); 1463 if (g_getfacl) { 1464 mr_free(curr_acl_list_fname); 1465 } 1466 if (g_getfattr) { 1467 mr_free(curr_xattr_list_fname); 1468 } 1469 mr_free(storing_filelist_fname); 1470 mr_free(storing_afioball_fname); 1524 1471 } 1525 1472 } … … 1540 1487 } 1541 1488 log_to_screen(tmp); 1542 paranoid_free(tmp);1489 mr_free(tmp); 1543 1490 1544 1491 paranoid_free(transfer_block); 1545 1492 paranoid_free(result_str); 1546 paranoid_free(storing_filelist_fname);1547 paranoid_free(storing_afioball_fname);1548 paranoid_free(curr_xattr_list_fname);1549 paranoid_free(curr_acl_list_fname);1550 1493 return (retval); 1551 1494 } … … 1598 1541 mr_asprintf(tmp, "chmod 700 %s", bkpinfo->scratchdir); 1599 1542 run_program_and_log_output(tmp, FALSE); 1600 paranoid_free(tmp);1543 mr_free(tmp); 1601 1544 if (chdir(bkpinfo->scratchdir)) { 1602 1545 // FIXME … … 1608 1551 log_msg(1, message_to_screen); 1609 1552 1610 mr_asprintf(tmp1, "%s1", bkpinfo->media_device); 1553 if (bkpinfo->media_device) { 1554 mr_asprintf(tmp1, "%s1", bkpinfo->media_device); 1555 } else { 1556 mr_asprintf(tmp1, ""); 1557 } 1611 1558 if (is_this_device_mounted(tmp1)) { 1612 1559 log_msg(1, "USB device mounted. Remounting it at the right place"); 1613 1560 mr_asprintf(tmp, "umount %s", tmp1); 1614 1561 run_program_and_log_output(tmp, FALSE); 1615 paranoid_free(tmp);1616 } 1617 paranoid_free(tmp1);1562 mr_free(tmp); 1563 } 1564 mr_free(tmp1); 1618 1565 1619 1566 log_msg(1, "Mounting USB device."); … … 1621 1568 mr_asprintf(tmp, "mkdir -p %s", tmp1); 1622 1569 run_program_and_log_output(tmp, FALSE); 1623 paranoid_free(tmp); 1570 mr_free(tmp); 1571 1624 1572 1625 1573 /* Mindi always create one single parition on the USB dev */ 1626 1574 mr_asprintf(tmp, "mount %s1 %s", bkpinfo->media_device, tmp1); 1627 1575 run_program_and_log_output(tmp, FALSE); 1628 paranoid_free(tmp);1576 mr_free(tmp); 1629 1577 1630 1578 if (bkpinfo->nonbootable_backup) { … … 1642 1590 } 1643 1591 log_to_screen(result_sz); 1644 paranoid_free(result_sz);1645 paranoid_free(tmp);1592 mr_free(result_sz); 1593 mr_free(tmp); 1646 1594 retval += res; 1647 1595 … … 1649 1597 mr_asprintf(tmp,"mkdir %s/archive", bkpinfo->scratchdir); 1650 1598 run_program_and_log_output(tmp, FALSE); 1651 paranoid_free(tmp);1599 mr_free(tmp); 1652 1600 } 1653 1601 paranoid_free(message_to_screen); … … 1657 1605 mr_asprintf(tmp, "umount %s1", bkpinfo->media_device); 1658 1606 run_program_and_log_output(tmp, FALSE); 1659 paranoid_free(tmp);1607 mr_free(tmp); 1660 1608 } 1661 1609 … … 1695 1643 1696 1644 /*@ buffers ****************************************** */ 1697 char *tmp; 1645 char *tmp = NULL; 1646 char *tmp2 = NULL; 1698 1647 char *old_pwd; 1699 1648 char *result_sz = NULL; 1700 1649 char *message_to_screen = NULL; 1701 1650 char *sz_blank_disk = NULL; 1702 char *fnam; 1703 char *tmp2; 1704 char *tmp3; 1651 char *fnam = NULL; 1652 char *tmp3 = NULL; 1705 1653 char *isofs_cmd = NULL; 1706 1654 char *full_isofs_cmd = NULL; … … 1710 1658 malloc_string(old_pwd); 1711 1659 malloc_string(fnam); 1712 tmp = malloc(1200);1713 tmp2 = malloc(1200);1714 tmp3 = malloc(1200);1715 1660 assert(bkpinfo != NULL); 1716 1661 assert_string_is_neither_NULL_nor_zerolength(destfile); 1717 1662 1718 sprintf(tmp, "%s/isolinux.bin", bkpinfo->scratchdir); 1719 sprintf(tmp2, "%s/isolinux.bin", bkpinfo->tmpdir); 1663 /* Copy the files needed by isolinux in the right dir */ 1664 mr_asprintf(tmp, "%s/isolinux.bin", bkpinfo->scratchdir); 1665 mr_asprintf(tmp2, "%s/isolinux.bin", bkpinfo->tmpdir); 1720 1666 if (does_file_exist(tmp)) { 1721 sprintf(tmp3, "cp -f %s %s", tmp, tmp2);1667 mr_asprintf(tmp3, "cp -f %s %s", tmp, tmp2); 1722 1668 paranoid_system(tmp3); 1669 mr_free(tmp3); 1723 1670 } 1724 1671 if (!does_file_exist(tmp) && does_file_exist(tmp2)) { 1725 sprintf(tmp3, "cp -f %s %s", tmp2, tmp);1672 mr_asprintf(tmp3, "cp -f %s %s", tmp2, tmp); 1726 1673 paranoid_system(tmp3); 1727 } 1728 free(tmp2); 1729 free(tmp3); 1730 tmp2 = NULL; 1731 tmp3 = NULL; 1674 mr_free(tmp3); 1675 } 1676 mr_free(tmp2); 1677 mr_free(tmp3); 1732 1678 if (bkpinfo->backup_media_type == iso && bkpinfo->manual_cd_tray) { 1733 1679 popup_and_OK("Please insert new media and press Enter."); 1734 1680 } 1735 1681 1736 log_msg(2, "make_iso_fs --- scratchdir=%s --- destfile=%s", 1737 bkpinfo->scratchdir, destfile); 1682 log_msg(2, "make_iso_fs --- scratchdir=%s --- destfile=%s", bkpinfo->scratchdir, destfile); 1738 1683 tmp2 = getcwd(old_pwd, MAX_STR_LEN - 1); 1739 sprintf(tmp, "chmod 700 %s", bkpinfo->scratchdir); 1684 if (! tmp2) { 1685 //FIXME 1686 } 1687 mr_asprintf(tmp, "chmod 700 %s", bkpinfo->scratchdir); 1740 1688 run_program_and_log_output(tmp, FALSE); 1689 mr_free(tmp); 1690 1741 1691 if (chdir(bkpinfo->scratchdir)) { 1742 1692 // FIXME … … 1744 1694 1745 1695 if (bkpinfo->call_before_iso[0] != '\0') { 1746 mr_asprintf(message_to_screen, "Running pre-ISO call for CD#%d", 1747 g_current_media_number); 1748 res = 1749 eval_call_to_make_ISO(bkpinfo->call_before_iso, 1750 destfile, g_current_media_number, 1751 MONDO_LOGFILE, message_to_screen); 1696 mr_asprintf(message_to_screen, "Running pre-ISO call for CD#%d", g_current_media_number); 1697 res = eval_call_to_make_ISO(bkpinfo->call_before_iso, destfile, g_current_media_number, MONDO_LOGFILE, message_to_screen); 1752 1698 if (res) { 1753 1699 mr_strcat(message_to_screen, "...failed"); … … 1763 1709 if (bkpinfo->call_make_iso[0] != '\0') { 1764 1710 log_msg(2, "bkpinfo->call_make_iso = %s", bkpinfo->call_make_iso); 1765 sprintf(tmp, "%s/archives/NOT-THE-LAST", bkpinfo->scratchdir);1766 1711 mds = media_descriptor_string(bkpinfo->backup_media_type); 1767 1712 mr_asprintf(message_to_screen, "Making an ISO (%s #%d)", mds, g_current_media_number); … … 1774 1719 } else { 1775 1720 res = 1776 eval_call_to_make_ISO(bkpinfo->call_make_iso, 1777 bkpinfo->scratchdir, 1778 g_current_media_number, 1779 MONDO_LOGFILE, message_to_screen); 1721 eval_call_to_make_ISO(bkpinfo->call_make_iso, bkpinfo->scratchdir, g_current_media_number, MONDO_LOGFILE, message_to_screen); 1780 1722 if (res) { 1781 1723 log_to_screen("%s...failed to write", message_to_screen); 1782 1724 } else { 1783 1725 log_to_screen("%s...OK", message_to_screen); 1784 sprintf(tmp, "tail -n10 %s | grep -F ':-('", MONDO_LOGFILE);1726 mr_asprintf(tmp, "tail -n10 %s | grep -F ':-('", MONDO_LOGFILE); 1785 1727 if (!run_program_and_log_output(tmp, 1)) { 1786 1728 log_to_screen 1787 1729 ("Despite nonfatal errors, growisofs confirms the write was successful."); 1788 1730 } 1731 mr_free(tmp); 1789 1732 } 1790 1733 retval += res; 1791 1734 #ifdef DVDRWFORMAT 1792 sprintf(tmp, 1793 "tail -n8 %s | grep 'blank=full.*dvd-compat.*DAO'", 1794 MONDO_LOGFILE); 1735 mr_asprintf(tmp, "tail -n8 %s | grep 'blank=full.*dvd-compat.*DAO'", MONDO_LOGFILE); 1795 1736 if (g_backup_media_type == dvd 1796 1737 && (res || !run_program_and_log_output(tmp, 1))) { … … 1800 1741 /* reset error counter before trying to blank DVD */ 1801 1742 retval -= res; 1802 paranoid_system("sync");1743 sync(); 1803 1744 pause_for_N_seconds(5, "Letting DVD drive settle"); 1804 1745 … … 1810 1751 } 1811 1752 pause_for_N_seconds(5, "Letting DVD drive settle"); 1812 mr_asprintf(sz_blank_disk, "dvd+rw-format -force %s", bkpinfo->media_device); 1753 if (bkpinfo->media_device) { 1754 mr_asprintf(sz_blank_disk, "dvd+rw-format -force %s", bkpinfo->media_device); 1755 } else { 1756 mr_asprintf(sz_blank_disk, "dvd+rw-format"); 1757 } 1813 1758 log_msg(3, "sz_blank_disk = '%s'", sz_blank_disk); 1814 res = 1815 run_external_binary_with_percentage_indicator_NEW 1816 ("Blanking DVD disk", sz_blank_disk); 1759 res = run_external_binary_with_percentage_indicator_NEW("Blanking DVD disk", sz_blank_disk); 1817 1760 if (res) { 1818 log_to_screen 1819 ("Warning - format failed. (Was it a DVD-R?) Sleeping for 5 seconds to take a breath..."); 1820 pause_for_N_seconds(5, 1821 "Letting DVD drive settle... and trying again."); 1822 res = 1823 run_external_binary_with_percentage_indicator_NEW 1824 ("Blanking DVD disk", sz_blank_disk); 1761 log_to_screen("Warning - format failed. (Was it a DVD-R?) Sleeping for 5 seconds to take a breath..."); 1762 pause_for_N_seconds(5, "Letting DVD drive settle... and trying again."); 1763 res = run_external_binary_with_percentage_indicator_NEW("Blanking DVD disk", sz_blank_disk); 1825 1764 if (res) { 1826 1765 log_to_screen("Format failed a second time."); … … 1838 1777 } 1839 1778 pause_for_N_seconds(5, "Letting DVD drive settle"); 1840 res = 1841 eval_call_to_make_ISO(bkpinfo->call_make_iso, 1842 bkpinfo->scratchdir, 1843 g_current_media_number, 1844 MONDO_LOGFILE, 1845 message_to_screen); 1779 res = eval_call_to_make_ISO(bkpinfo->call_make_iso, bkpinfo->scratchdir, g_current_media_number, MONDO_LOGFILE, message_to_screen); 1846 1780 retval += res; 1847 1781 if (!bkpinfo->please_dont_eject) { … … 1856 1790 } 1857 1791 } 1792 mr_free(tmp); 1858 1793 #endif 1859 1794 if (g_backup_media_type == dvd && !bkpinfo->please_dont_eject) { … … 1876 1811 log_msg(1, "Making nonbootable backup"); 1877 1812 mr_asprintf(full_isofs_cmd, "%s%s-o '_ISO_' -V _CD#_ .",isofs_cmd,MONDO_MKISOFS); 1878 res = eval_call_to_make_ISO(full_isofs_cmd, 1879 destfile, g_current_media_number, 1880 MONDO_LOGFILE, message_to_screen); 1813 res = eval_call_to_make_ISO(full_isofs_cmd, destfile, g_current_media_number, MONDO_LOGFILE, message_to_screen); 1881 1814 mr_free(full_isofs_cmd); 1882 1815 } else { … … 1888 1821 1889 1822 1890 log_msg(1, "make_cd_use_lilo is actually %d", 1891 bkpinfo->make_cd_use_lilo); 1823 log_msg(1, "make_cd_use_lilo is actually %d", bkpinfo->make_cd_use_lilo); 1892 1824 if (bkpinfo->make_cd_use_lilo) { 1893 1825 log_msg(1, "make_cd_use_lilo = TRUE"); … … 1895 1827 log_msg(1, "IA64 --> elilo"); 1896 1828 mr_asprintf(full_isofs_cmd, "%s%s-o '_ISO_' -V _CD#_ .",isofs_cmd,MONDO_MKISOFS_REGULAR_ELILO); 1897 res = eval_call_to_make_ISO(full_isofs_cmd, 1898 destfile, 1899 g_current_media_number, 1900 MONDO_LOGFILE, 1901 message_to_screen); 1829 res = eval_call_to_make_ISO(full_isofs_cmd, destfile, g_current_media_number, MONDO_LOGFILE, message_to_screen); 1902 1830 mr_free(full_isofs_cmd); 1903 1831 #else 1904 1832 log_msg(1, "Non-ia64 --> lilo"); 1905 1833 mr_asprintf(full_isofs_cmd, "%s%s-b images/mindi-bootroot.2880.img -c boot.cat -o '_ISO_' -J -V _CD#_ .",isofs_cmd,MONDO_MKISOFS); 1906 res = 1907 // FIXME: fixed boot size probably wrong. lilo to be removed 1908 eval_call_to_make_ISO(full_isofs_cmd, 1909 destfile, g_current_media_number, 1910 MONDO_LOGFILE, 1911 message_to_screen); 1834 // FIXME: fixed boot size probably wrong. lilo to be removed 1835 res = eval_call_to_make_ISO(full_isofs_cmd, destfile, g_current_media_number, MONDO_LOGFILE, message_to_screen); 1912 1836 mr_free(full_isofs_cmd); 1913 1837 #endif … … 1916 1840 log_msg(1, "Isolinux"); 1917 1841 mr_asprintf(full_isofs_cmd, "%s%s-o '_ISO_' -V _CD#_ .",isofs_cmd,MONDO_MKISOFS_REGULAR_SYSLINUX); 1918 res = 1919 eval_call_to_make_ISO(full_isofs_cmd, 1920 destfile, g_current_media_number, 1921 MONDO_LOGFILE, 1922 message_to_screen); 1842 res = eval_call_to_make_ISO(full_isofs_cmd, destfile, g_current_media_number, MONDO_LOGFILE, message_to_screen); 1923 1843 mr_free(full_isofs_cmd); 1924 1844 } … … 1940 1860 || bkpinfo->backup_media_type == cdrw) { 1941 1861 if (is_this_device_mounted(bkpinfo->media_device)) { 1942 log_msg(2, 1943 "Warning - %s mounted. I'm unmounting it before I burn to it.", 1944 bkpinfo->media_device); 1945 sprintf(tmp, "umount %s", bkpinfo->media_device); 1862 log_msg(2, "Warning - %s mounted. I'm unmounting it before I burn to it.", bkpinfo->media_device); 1863 mr_asprintf(tmp, "umount %s", bkpinfo->media_device); 1946 1864 run_program_and_log_output(tmp, FALSE); 1865 mr_free(tmp); 1947 1866 } 1948 1867 } … … 1954 1873 mr_free(mds); 1955 1874 pause_and_ask_for_cdr(2, &cd_is_mountable); 1956 res = 1957 eval_call_to_make_ISO(bkpinfo->call_burn_iso, 1958 destfile, g_current_media_number, 1959 MONDO_LOGFILE, message_to_screen); 1875 res = eval_call_to_make_ISO(bkpinfo->call_burn_iso, destfile, g_current_media_number, MONDO_LOGFILE, message_to_screen); 1960 1876 if (res) { 1961 1877 mr_strcat(message_to_screen, "...failed"); … … 1973 1889 mr_asprintf(message_to_screen, "Running post-ISO call (%s #%d)", mds, g_current_media_number); 1974 1890 mr_free(mds); 1975 res = 1976 eval_call_to_make_ISO(bkpinfo->call_after_iso, 1977 destfile, g_current_media_number, 1978 MONDO_LOGFILE, message_to_screen); 1891 res = eval_call_to_make_ISO(bkpinfo->call_after_iso, destfile, g_current_media_number, MONDO_LOGFILE, message_to_screen); 1979 1892 if (res) { 1980 1893 mr_strcat(message_to_screen, "...failed"); … … 2044 1957 2045 1958 /*@ pointers ******************************************* */ 2046 FILE *fin ;1959 FILE *fin = NULL; 2047 1960 char *p; 2048 1961 char *q; … … 2050 1963 /*@ buffers ******************************************** */ 2051 1964 char *tmp = NULL; 2052 char *bigfile_fname ;1965 char *bigfile_fname = NULL; 2053 1966 char *sz_devfile = NULL; 2054 1967 char *ntfsprog_fifo = NULL; … … 2086 1999 log_to_screen(tmp); 2087 2000 noof_biggie_files = count_lines_in_file(biggielist_fname); 2088 open_progress_form("Backing up big files", tmp, 2089 "Please wait. This may take some time.", "", 2090 estimated_total_noof_slices); 2091 paranoid_free(tmp); 2001 open_progress_form("Backing up big files", tmp, "Please wait. This may take some time.", "", estimated_total_noof_slices); 2002 mr_free(tmp); 2092 2003 2093 2004 if (!(fin = fopen(biggielist_fname, "r"))) { … … 2121 2032 log_msg(2, "bigfile_fname = %s", bigfile_fname); 2122 2033 use_ntfsprog = FALSE; 2123 if (!strncmp(bigfile_fname, "/dev/", 5) 2124 && is_dev_an_NTFS_dev(bigfile_fname)) { 2034 if (!strncmp(bigfile_fname, "/dev/", 5) && is_dev_an_NTFS_dev(bigfile_fname)) { 2125 2035 use_ntfsprog = TRUE; 2126 log_msg(2, 2127 "Calling ntfsclone in background because %s is an NTFS partition", 2128 bigfile_fname); 2129 mr_asprintf(sz_devfile, "%s/%d.%d.000", bkpinfo->tmpdir, 2130 (int) (random() % 32768), 2131 (int) (random() % 32768)); 2036 log_msg(2, "Calling ntfsclone in background because %s is an NTFS partition", bigfile_fname); 2037 mr_asprintf(sz_devfile, "%s/%d.%d.000", bkpinfo->tmpdir, (int) (random() % 32768), (int) (random() % 32768)); 2132 2038 mkfifo(sz_devfile, 0x770); 2133 2039 ntfsprog_fifo = sz_devfile; … … 2137 2043 fatal_error("Fork failure"); 2138 2044 case 0: 2139 log_msg(2, 2140 "CHILD - fip - calling feed_into_ntfsprog(%s, %s)", 2141 bigfile_fname, sz_devfile); 2045 log_msg(2, "CHILD - fip - calling feed_into_ntfsprog(%s, %s)", bigfile_fname, sz_devfile); 2142 2046 res = feed_into_ntfsprog(bigfile_fname, sz_devfile); 2143 2047 /* BCO/BERLIOS Does the child need to unalocate memory as well ? 2144 paranoid_free(bigfile_fname);2048 mr_free(bigfile_fname); 2145 2049 mr_free(sz_devfile); 2146 2050 */ … … 2148 2052 break; 2149 2053 default: 2150 log_msg(2, 2151 "feed_into_ntfsprog() called in background --- pid=%ld", 2152 (long int) (pid)); 2054 log_msg(2, "feed_into_ntfsprog() called in background --- pid=%ld", (long int) (pid)); 2153 2055 } 2154 2056 } … … 2160 2062 // Whether partition or biggiefile, just do your thang :-) 2161 2063 if (IS_THIS_A_STREAMING_BACKUP(bkpinfo->backup_media_type)) { 2162 write_header_block_to_stream(biggie_fsize, bigfile_fname, 2163 use_ntfsprog ? 2164 BLK_START_A_PIHBIGGIE : 2165 BLK_START_A_NORMBIGGIE); 2166 } 2167 res = 2168 slice_up_file_etc(bigfile_fname, 2169 ntfsprog_fifo, biggie_file_number, 2170 noof_biggie_files, use_ntfsprog); 2064 write_header_block_to_stream(biggie_fsize, bigfile_fname, use_ntfsprog ? BLK_START_A_PIHBIGGIE : BLK_START_A_NORMBIGGIE); 2065 } 2066 res = slice_up_file_etc(bigfile_fname, ntfsprog_fifo, biggie_file_number, noof_biggie_files, use_ntfsprog); 2171 2067 2172 2068 /* Free it here as ntfsprog_fifo is not used anymore */ … … 2197 2093 } 2198 2094 } 2199 #ifndef _XWIN2200 2095 if (!g_text_mode) { 2201 2096 newtDrawRootText(0, g_noof_rows - 2, tmp); 2202 2097 newtRefresh(); 2203 2098 } 2204 #endif 2205 paranoid_free(tmp); 2206 } 2099 mr_free(tmp); 2100 } 2101 mr_free(bigfile_fname); 2102 2207 2103 log_msg(1, "Finished backing up bigfiles"); 2208 2104 log_msg(1, "estimated slices = %ld; actual slices = %ld", … … 2210 2106 close_progress_form(); 2211 2107 paranoid_fclose(fin); 2212 paranoid_free(bigfile_fname);2213 2108 return (retval); 2214 2109 } … … 2271 2166 retval += res; 2272 2167 if (res) { 2273 mr_asprintf(tmp, "Errors occurred while archiving set %ld. Perhaps your live filesystem changed?", curr_set_no); 2274 log_to_screen(tmp); 2275 mr_free(tmp); 2276 } 2277 2278 mr_asprintf(media_usage_comment, "%s", percent_media_full_comment()); 2168 log_to_screen("Errors occurred while archiving set %ld. Perhaps your live filesystem changed?", curr_set_no); 2169 } 2279 2170 2280 2171 /* copy to CD (scratchdir) ... and an actual CD-R if necessary */ … … 2319 2210 retval += res; 2320 2211 g_current_progress++; 2212 2213 mr_asprintf(media_usage_comment, "%s", percent_media_full_comment()); 2321 2214 update_progress_form(media_usage_comment); 2322 2215 mr_free(media_usage_comment); 2323 2216 2324 2217 if (res) { 2325 mr_asprintf(tmp, "Failed to add archive %ld's files to CD dir\n", curr_set_no); 2326 log_to_screen(tmp); 2327 mr_free(tmp); 2328 fatal_error 2329 ("Is your hard disk is full? If not, please send the author the logfile."); 2218 log_to_screen("Failed to add archive %ld's files to CD dir\n", curr_set_no); 2219 fatal_error("Is your hard disk is full? If not, please send the author the logfile."); 2330 2220 } 2331 2221 mr_free(curr_filelist_fname); … … 2428 2318 } 2429 2319 2430 mr_asprintf(command, "cp %s/biggielist.txt %s", bkpinfo->tmpdir, 2431 biggielist); 2320 mr_asprintf(command, "cp %s/biggielist.txt %s", bkpinfo->tmpdir, biggielist); 2432 2321 paranoid_system(command); 2433 2322 mr_free(command); … … 2443 2332 if (g_getfattr) { 2444 2333 get_fattr_list(biggielist, xattr_fname); 2445 mr_asprintf(command, "cp %s %s/archives/", xattr_fname, 2446 bkpinfo->scratchdir); 2334 mr_asprintf(command, "cp %s %s/archives/", xattr_fname, bkpinfo->scratchdir); 2447 2335 paranoid_system(command); 2448 2336 mr_free(command); … … 2733 2621 /*@ buffers ********************************************* */ 2734 2622 char *tmp = NULL; 2735 char *cdrom_dev ;2736 char *cdrw_dev ;2623 char *cdrom_dev = NULL; 2624 char *cdrw_dev = NULL; 2737 2625 char *our_serial_str = NULL; 2738 2626 bool ok_go_ahead_burn_it; … … 2740 2628 int attempt_to_mount_returned_this = 999; 2741 2629 char *mtpt = NULL; 2742 char *szcdno ;2743 char *szserfname ;2744 char *szunmount ;2630 char *szcdno = NULL; 2631 char *szserfname = NULL; 2632 char *szunmount = NULL; 2745 2633 char *mds = NULL; 2746 2634 2747 2635 malloc_string(cdrom_dev); 2748 2636 malloc_string(cdrw_dev); 2749 malloc_string(szcdno);2750 malloc_string(szserfname);2751 malloc_string(szunmount);2752 malloc_string(mtpt);2753 2637 2754 2638 mds = media_descriptor_string(g_backup_media_type); 2755 mr_asprintf(tmp,"I am about to burn %s #%d", mds, g_current_media_number);2639 log_to_screen("I am about to burn %s #%d", mds, g_current_media_number); 2756 2640 mr_free(mds); 2757 log_to_screen(tmp);2758 mr_free(tmp);2759 2641 if (g_current_media_number < ask_for_one_if_more_than_this) { 2760 2642 return; 2761 2643 } 2762 2644 log_to_screen("Scanning CD-ROM drive..."); 2763 sprintf(mtpt, "%s/cd.mtpt", bkpinfo->tmpdir);2645 mr_asprintf(mtpt, "%s/cd.mtpt", bkpinfo->tmpdir); 2764 2646 make_hole_for_dir(mtpt); 2765 2647 … … 2767 2649 ok_go_ahead_burn_it = TRUE; 2768 2650 if (!find_cdrom_device(cdrom_dev, FALSE)) { 2769 /* When enabled, it made CD eject-and-retract when wrong CD inserted.. Weird2770 2771 2772 */2651 /* When enabled, it made CD eject-and-retract when wrong CD inserted.. Weird 2652 log_msg(2, "paafcd: Retracting CD-ROM drive if possible" ); 2653 retract_CD_tray_and_defeat_autorun(); 2654 */ 2773 2655 mr_asprintf(tmp, "umount %s", cdrom_dev); 2774 2656 run_program_and_log_output(tmp, 1); 2775 sprintf(szcdno, "%s/archives/THIS-CD-NUMBER", mtpt);2776 sprintf(szserfname, "%s/archives/SERIAL-STRING", mtpt);2777 sprintf(szunmount, "umount %s", mtpt);2657 mr_asprintf(szcdno, "%s/archives/THIS-CD-NUMBER", mtpt); 2658 mr_asprintf(szserfname, "%s/archives/SERIAL-STRING", mtpt); 2659 mr_asprintf(szunmount, "umount %s", mtpt); 2778 2660 cd_number = -1; 2779 2661 mr_asprintf(tmp, "mount %s %s", cdrom_dev, mtpt); … … 2781 2663 attempt_to_mount_returned_this = run_program_and_log_output(tmp, 1); 2782 2664 mr_free(tmp); 2665 2783 2666 if (attempt_to_mount_returned_this) { 2784 2667 log_msg(4, "Failed to mount %s at %s", cdrom_dev, mtpt); 2785 2668 log_to_screen("If there's a CD/DVD in the drive, it's blank."); 2786 /* 2787 if (interrogate_disk_currently_in_cdrw_drive(cdrw_dev, FALSE)) 2788 { 2789 ok_go_ahead_burn_it = FALSE; 2790 log_to_screen("There isn't a writable CD/DVD in the drive."); 2791 } 2792 else 2793 { 2794 log_to_screen("Confirmed. There is a blank CD/DVD in the drive."); 2795 } 2796 */ 2797 } else if (!does_file_exist(szcdno) 2798 || !does_file_exist(szserfname)) { 2669 } else if (!does_file_exist(szcdno) || !does_file_exist(szserfname)) { 2799 2670 mds = media_descriptor_string(g_backup_media_type); 2800 log_to_screen 2801 ("%s has data on it but it's probably not a Mondo CD.", mds); 2671 log_to_screen("%s has data on it but it's probably not a Mondo CD.", mds); 2802 2672 mr_free(mds); 2803 2673 } else { … … 2809 2679 mr_asprintf(tmp, "cat %s 2> /dev/null", szserfname); 2810 2680 mr_free(our_serial_str); 2811 mr_asprintf(our_serial_str, "%s", 2812 call_program_and_get_last_line_of_output(tmp)); 2681 mr_asprintf(our_serial_str, "%s", call_program_and_get_last_line_of_output(tmp)); 2813 2682 mr_free(tmp); 2814 2683 // FIXME - should be able to use last_line_of_file(), surely? 2815 2684 } 2685 mr_free(szcdno); 2686 mr_free(szserfname); 2687 2816 2688 run_program_and_log_output(szunmount, 1); 2689 mr_free(szunmount); 2690 2817 2691 log_msg(2, "paafcd: cd_number = %d", cd_number); 2818 log_msg(2, "our serial str = %s; g_serial_string = %s", 2819 our_serial_str, g_serial_string); 2692 log_msg(2, "our serial str = %s; g_serial_string = %s", our_serial_str, g_serial_string); 2820 2693 if (cd_number > 0 && !strcmp(our_serial_str, g_serial_string)) { 2821 2694 mds = media_descriptor_string(g_backup_media_type); … … 2849 2722 } 2850 2723 mds = media_descriptor_string(g_backup_media_type); 2851 mr_asprintf(tmp, "I am about to burn %s #%d of the backup set. Please insert %s and press Enter.", 2852 mds, g_current_media_number, mds); 2724 mr_asprintf(tmp, "I am about to burn %s #%d of the backup set. Please insert %s and press Enter.", mds, g_current_media_number, mds); 2853 2725 mr_free(mds); 2854 2726 … … 2861 2733 2862 2734 mds = media_descriptor_string(g_backup_media_type); 2863 log_msg(2, 2864 "paafcd: OK, I assume I have a blank/reusable %s in the drive...", mds); 2735 log_msg(2, "paafcd: OK, I assume I have a blank/reusable %s in the drive...", mds); 2865 2736 2866 2737 log_to_screen("Proceeding w/ %s in drive.", mds); … … 2869 2740 paranoid_free(cdrom_dev); 2870 2741 paranoid_free(cdrw_dev); 2871 paranoid_free(mtpt); 2872 paranoid_free(szcdno); 2873 paranoid_free(szserfname); 2874 paranoid_free(szunmount); 2742 mr_free(mtpt); 2875 2743 if (pmountable) { 2876 2744 if (attempt_to_mount_returned_this) { … … 2882 2750 2883 2751 } 2884 2885 2886 2887 2888 2889 2890 2752 2891 2753 … … 2917 2779 2918 2780 /* @} - end of utilityGroup */ 2919 2920 2921 2922 2923 2924 2925 2781 2926 2782 … … 2945 2801 */ 2946 2802 int 2947 slice_up_file_etc(char *biggie_filename, 2948 char *ntfsprog_fifo, long biggie_file_number, 2949 long noof_biggie_files, bool use_ntfsprog) 2950 { 2803 slice_up_file_etc(char *biggie_filename, char *ntfsprog_fifo, long biggie_file_number, long noof_biggie_files, bool use_ntfsprog) { 2951 2804 2952 2805 /*@ buffers ************************************************** */ 2953 2806 char *tmp = NULL; 2954 char *checksum_line, *command; 2955 char *tempblock; 2807 char *checksum_line = NULL; 2808 char *command = NULL; 2809 char *tempblock = NULL; 2956 2810 char *curr_slice_fname_uncompressed = NULL; 2957 2811 char *curr_slice_fname_compressed = NULL; 2958 2812 char *file_to_archive = NULL; 2959 char *file_to_openin ;2813 char *file_to_openin = NULL; 2960 2814 /*@ pointers ************************************************** */ 2961 char *pB; 2962 FILE *fin = NULL, *fout = NULL; 2815 char *pB = NULL; 2816 FILE *fin = NULL; 2817 FILE *fout = NULL; 2963 2818 2964 2819 /*@ bool ****************************************************** */ … … 2966 2821 2967 2822 /*@ long ****************************************************** */ 2968 size_t blksize = 0; 2969 long slice_num = 0; 2970 long i; 2971 long optimal_set_size; 2972 bool should_I_compress_slices; 2823 size_t blksize = (size_t)0; 2824 long slice_num = 0L; 2825 long i = 0L; 2826 bool should_I_compress_slices = TRUE; 2973 2827 char *suffix = NULL; // for compressed slices 2974 2828 … … 2983 2837 /*@ structures ************************************************** */ 2984 2838 struct s_filename_and_lstat_info biggiestruct; 2985 // struct stat statbuf;2986 2839 2987 2840 assert(bkpinfo != NULL); 2988 2841 assert_string_is_neither_NULL_nor_zerolength(biggie_filename); 2989 malloc_string(checksum_line);2990 2842 2991 2843 biggiestruct.for_backward_compatibility = '\n'; 2992 2844 biggiestruct.use_ntfsprog = use_ntfsprog; 2993 optimal_set_size = bkpinfo->optimal_set_size; 2994 if (is_this_file_compressed(biggie_filename) 2995 || bkpinfo->compression_level == 0) { 2845 if (is_this_file_compressed(biggie_filename) || bkpinfo->compression_level == 0) { 2996 2846 mr_asprintf(suffix, "%s", ""); 2997 // log_it("%s is indeed compressed :-)", filename);2998 2847 should_I_compress_slices = FALSE; 2999 2848 } else { … … 3002 2851 } 3003 2852 3004 if ( optimal_set_size < 999) {2853 if (bkpinfo->optimal_set_size < 999L) { 3005 2854 fatal_error("bkpinfo->optimal_set_size is insanely small"); 3006 2855 } 2856 3007 2857 if (ntfsprog_fifo) { 3008 2858 file_to_openin = ntfsprog_fifo; 3009 strcpy(checksum_line, "IGNORE"); 3010 log_msg(2, 3011 "Not calculating checksum for %s: it would take too long", 3012 biggie_filename); 2859 mr_asprintf(checksum_line, "IGNORE"); 2860 log_msg(2, "Not calculating checksum for %s: it would take too long", biggie_filename); 3013 2861 if ( !find_home_of_exe("ntfsresize")) { 3014 2862 fatal_error("ntfsresize not found"); … … 3020 2868 log_it("res of it = %s", tmp); 3021 2869 totallength = (off_t)atoll(tmp); 3022 paranoid_free(tmp);2870 mr_free(tmp); 3023 2871 } else { 3024 2872 file_to_openin = biggie_filename; … … 3034 2882 } 3035 2883 mr_free(command); 3036 tmp = fgets(checksum_line, MAX_STR_LEN, fin);2884 mr_getline(checksum_line, fin); 3037 2885 pclose(fin); 3038 2886 totallength = length_of_file (biggie_filename); … … 3048 2896 } 3049 2897 strcpy(biggiestruct.checksum, checksum_line); 2898 mr_free(checksum_line); 3050 2899 3051 2900 mr_asprintf(tmp, "%s", slice_fname(biggie_file_number, 0, bkpinfo->tmpdir, "")); … … 3053 2902 if (fout == NULL) { 3054 2903 log_msg(1, "Unable to open and write to %s\n", tmp); 3055 paranoid_free(tmp);2904 mr_free(tmp); 3056 2905 mr_free(suffix); 3057 2906 return (1); 3058 2907 } 3059 paranoid_free(tmp);2908 mr_free(tmp); 3060 2909 3061 2910 res = fwrite((void *) &biggiestruct, 1, sizeof(biggiestruct), fout); … … 3063 2912 paranoid_fclose(fout); 3064 2913 } 3065 log_msg(1, "Opening in %s; slicing it and writing to CD/tape", 3066 file_to_openin); 2914 log_msg(1, "Opening in %s; slicing it and writing to CD/tape", file_to_openin); 3067 2915 if (!(fin = fopen(file_to_openin, "r"))) { 3068 2916 log_OS_error("Unable to openin biggie_filename"); 3069 mr_asprintf(tmp, "Cannot archive bigfile '%s': not found", biggie_filename); 3070 log_to_screen(tmp); 3071 paranoid_free(tmp); 3072 3073 paranoid_free(checksum_line); 2917 log_to_screen("Cannot archive bigfile '%s': not found", biggie_filename); 2918 3074 2919 mr_free(suffix); 3075 2920 return (1); … … 3094 2939 mr_asprintf(tmp, "%s", percent_media_full_comment()); 3095 2940 update_progress_form(tmp); 3096 paranoid_free(tmp);2941 mr_free(tmp); 3097 2942 3098 2943 if (!(fout = fopen(curr_slice_fname_uncompressed, "w"))) { … … 3101 2946 return (1); 3102 2947 } 3103 if ((i == bkpinfo->optimal_set_size / 256) 3104 && (totalread < 1.1 * totallength)) { 3105 for (i = 0; i < bkpinfo->optimal_set_size / 256; i++) { 2948 if ((i == bkpinfo->optimal_set_size / 256) && (totalread < 1.1 * totallength)) { 2949 for (i = 0L; i < bkpinfo->optimal_set_size / 256; i++) { 3106 2950 blksize = fread(tempblock, 1, 256 * 1024, fin); 3107 2951 if (blksize > 0) { … … 3112 2956 } 3113 2957 } 2958 mr_free(tempblock); 3114 2959 } else { 3115 i = 0 ;2960 i = 0L; 3116 2961 } 3117 2962 paranoid_fclose(fout); 3118 if (i > 0 ) // length_of_file (curr_slice_fname_uncompressed)2963 if (i > 0L) // length_of_file (curr_slice_fname_uncompressed) 3119 2964 { 3120 2965 if (!does_file_exist(curr_slice_fname_uncompressed)) { 3121 log_msg(2, 3122 "Warning - '%s' doesn't exist. How can I compress slice?", 3123 curr_slice_fname_uncompressed); 2966 log_msg(2, "Warning - '%s' doesn't exist. How can I compress slice?", curr_slice_fname_uncompressed); 3124 2967 } 3125 2968 if (should_I_compress_slices && bkpinfo->compression_level > 0) { … … 3141 2984 log_msg(2, "Failed to compress the slice"); 3142 2985 } 3143 if (bkpinfo->use_lzo 3144 && strcmp(curr_slice_fname_compressed, 3145 curr_slice_fname_uncompressed)) { 2986 if (bkpinfo->use_lzo && strcmp(curr_slice_fname_compressed, curr_slice_fname_uncompressed)) { 3146 2987 unlink(curr_slice_fname_uncompressed); 3147 2988 } … … 3149 2990 mr_asprintf(tmp, "Problem with slice # %ld", slice_num); 3150 2991 } else { 3151 mr_asprintf(tmp, "%s - Bigfile #%ld, slice #%ld compressed OK ", biggie_filename, biggie_file_number + 1, 3152 slice_num); 3153 } 3154 #ifndef _XWIN 2992 mr_asprintf(tmp, "%s - Bigfile #%ld, slice #%ld compressed OK ", biggie_filename, biggie_file_number + 1, slice_num); 2993 } 3155 2994 if (!g_text_mode) { 3156 2995 newtDrawRootText(0, g_noof_rows - 2, tmp); … … 3159 2998 log_msg(2, tmp); 3160 2999 } 3161 #else 3162 log_msg(2, tmp); 3163 #endif 3164 paranoid_free(tmp); 3000 mr_free(tmp); 3165 3001 3166 3002 mr_asprintf(file_to_archive, "%s", curr_slice_fname_compressed); … … 3178 3014 3179 3015 if (IS_THIS_A_STREAMING_BACKUP(bkpinfo->backup_media_type)) { 3180 register_in_tape_catalog(biggieslice, biggie_file_number, 3181 slice_num, file_to_archive); 3182 maintain_collection_of_recent_archives(bkpinfo->tmpdir, 3183 file_to_archive); 3016 register_in_tape_catalog(biggieslice, biggie_file_number, slice_num, file_to_archive); 3017 maintain_collection_of_recent_archives(bkpinfo->tmpdir, file_to_archive); 3184 3018 res = move_files_to_stream(file_to_archive, NULL); 3185 3019 } else { … … 3190 3024 retval += res; 3191 3025 if (res) { 3192 mr_asprintf(tmp, "Failed to add slice %ld of bigfile %ld to scratchdir", slice_num, biggie_file_number + 1); 3193 log_to_screen(tmp); 3194 paranoid_free(tmp); 3195 fatal_error 3196 ("Hard disk full. You should have bought a bigger one."); 3197 } 3198 } 3199 mr_free(tempblock); 3026 log_to_screen("Failed to add slice %ld of bigfile %ld to scratchdir", slice_num, biggie_file_number + 1); 3027 fatal_error("Hard disk full. You should have bought a bigger one."); 3028 } 3029 } 3200 3030 mr_free(suffix); 3201 3031 paranoid_fclose(fin); … … 3207 3037 } 3208 3038 log_msg(1, tmp); 3209 paranoid_free(tmp); 3210 3211 paranoid_free(checksum_line); 3039 mr_free(tmp); 3040 3212 3041 return (retval); 3213 3042 } … … 3288 3117 log_msg(2, tmp); 3289 3118 center_string(tmp, 80); 3290 #ifndef _XWIN3291 3119 if (!g_text_mode) { 3292 3120 newtPushHelpLine(tmp); 3293 3121 } 3294 #endif3295 3122 res = write_iso_and_go_on(TRUE); 3296 #ifndef _XWIN3297 3123 if (!g_text_mode) { 3298 3124 newtPopHelpLine(); 3299 3125 } 3300 #endif3301 3126 log_msg(2, "Returning from writing final ISO (res=%d)", res); 3302 3127 paranoid_free(tmp); … … 3327 3152 3328 3153 /*@ buffers ***************************************************** */ 3329 char *tmp; 3330 char *cdno_fname; 3331 char *lastcd_fname; 3332 char *isofile; 3154 char *tmp = NULL; 3155 char *tmp1 = NULL; 3156 char *cdno_fname = NULL; 3157 char *lastcd_fname = NULL; 3158 char *isofile = NULL; 3333 3159 char *mds = NULL; 3334 3160 … … 3341 3167 3342 3168 malloc_string(tmp); 3343 malloc_string(cdno_fname);3344 malloc_string(lastcd_fname);3345 malloc_string(isofile);3346 3169 3347 3170 assert(bkpinfo != NULL); … … 3357 3180 /* label the ISO with its number */ 3358 3181 3359 sprintf(cdno_fname, "%s/archives/THIS-CD-NUMBER", bkpinfo->scratchdir);3182 mr_asprintf(cdno_fname, "%s/archives/THIS-CD-NUMBER", bkpinfo->scratchdir); 3360 3183 fout = fopen(cdno_fname, "w"); 3184 mr_free(cdno_fname); 3185 3361 3186 fprintf(fout, "%d", g_current_media_number); 3362 3187 paranoid_fclose(fout); 3363 3188 3364 sprintf(tmp, "cp -f %s/autorun %s/", g_mondo_home, 3365 bkpinfo->scratchdir); 3366 if (run_program_and_log_output(tmp, FALSE)) { 3189 mr_asprintf(tmp1, "cp -f %s/autorun %s/", g_mondo_home, bkpinfo->scratchdir); 3190 if (run_program_and_log_output(tmp1, FALSE)) { 3367 3191 log_msg(2, "Warning - unable to copy autorun to scratchdir"); 3368 3192 } 3193 mr_free(tmp1); 3369 3194 3370 3195 /* last CD or not? Label accordingly */ 3371 sprintf(lastcd_fname, "%s/archives/NOT-THE-LAST", bkpinfo->scratchdir);3196 mr_asprintf(lastcd_fname, "%s/archives/NOT-THE-LAST", bkpinfo->scratchdir); 3372 3197 if (last_cd) { 3373 3198 unlink(lastcd_fname); … … 3380 3205 paranoid_fclose(fout); 3381 3206 } 3207 mr_free(lastcd_fname); 3208 3382 3209 if (space_occupied_by_cd(bkpinfo->scratchdir) / 1024 > bkpinfo->media_size) { 3383 sprintf(tmp, 3384 "Warning! CD is too big. It occupies %ld KB, which is more than the %ld KB allowed.", 3385 (long) space_occupied_by_cd(bkpinfo->scratchdir), 3386 (long) bkpinfo->media_size); 3387 log_to_screen(tmp); 3388 } 3389 sprintf(isofile, "%s/%s/%s-%d.iso", bkpinfo->isodir, 3210 log_to_screen("Warning! CD is too big. It occupies %ld KB, which is more than the %ld KB allowed.",(long) space_occupied_by_cd(bkpinfo->scratchdir),(long) bkpinfo->media_size); 3211 } 3212 mr_asprintf(isofile, "%s/%s/%s-%d.iso", bkpinfo->isodir, 3390 3213 bkpinfo->netfs_remote_dir, bkpinfo->prefix, 3391 3214 g_current_media_number); … … 3402 3225 { 3403 3226 log_msg(3, "*Sigh* Mike, I hate your computer."); 3227 // if it can't be found then force pausing 3404 3228 bkpinfo->manual_cd_tray = TRUE; 3405 } // if it can't be found then force pausing 3406 else { 3229 } else { 3407 3230 log_msg(3, "Great. Found Mike's CD-ROM drive."); 3408 3231 } … … 3410 3233 if (bkpinfo->verify_data && !res) { 3411 3234 mds = media_descriptor_string(g_backup_media_type); 3412 log_to_screen 3413 ("Please reboot from the 1st %s in Compare Mode, as a precaution.", mds); 3235 log_to_screen("Please reboot from the 1st %s in Compare Mode, as a precaution.", mds); 3414 3236 mr_free(mds); 3415 3237 if (chdir("/")) { … … 3428 3250 } else { 3429 3251 mds = media_descriptor_string(bkpinfo->backup_media_type); 3430 sprintf(tmp, "Failed to create %s #%d. Retry?", mds, g_current_media_number);3252 mr_asprintf(tmp1, "Failed to create %s #%d. Retry?", mds, g_current_media_number); 3431 3253 mr_free(mds); 3432 res = ask_me_yes_or_no(tmp); 3254 res = ask_me_yes_or_no(tmp1); 3255 mr_free(tmp1); 3256 3433 3257 if (!res) { 3434 3258 if (ask_me_yes_or_no("Abort the backup?")) { … … 3443 3267 } 3444 3268 } 3269 mr_free(isofile); 3270 3445 3271 g_current_media_number++; 3446 3272 wipe_archives(bkpinfo->scratchdir); 3447 sprintf(tmp, "rm -Rf %s/images/*gz %s/images/*data*img", 3448 bkpinfo->scratchdir, bkpinfo->scratchdir); 3449 if (system(tmp)) { 3450 log_msg 3451 (2, 3452 "Error occurred when I tried to delete the redundant IMGs and GZs"); 3453 } 3273 mr_asprintf(tmp1, "rm -Rf %s/images/*gz %s/images/*data*img", bkpinfo->scratchdir, bkpinfo->scratchdir); 3274 if (system(tmp1)) { 3275 log_msg(2, "Error occurred when I tried to delete the redundant IMGs and GZs"); 3276 } 3277 mr_free(tmp1); 3454 3278 3455 3279 if (last_cd) { … … 3461 3285 bkpinfo->verify_data = orig_vfy_flag_val; 3462 3286 paranoid_free(tmp); 3463 paranoid_free(cdno_fname);3464 paranoid_free(lastcd_fname);3465 paranoid_free(isofile);3466 3287 return (0); 3467 3288 } … … 3532 3353 if (res) { 3533 3354 mds = media_descriptor_string(bkpinfo->backup_media_type); 3534 mr_asprintf(tmp,"Warnings/errors were reported while checking %s #%d", mds, g_current_media_number);3355 log_to_screen("Warnings/errors were reported while checking %s #%d", mds, g_current_media_number); 3535 3356 mr_free(mds); 3536 log_to_screen(tmp);3537 mr_free(tmp);3538 3357 3539 3358 }
Note:
See TracChangeset
for help on using the changeset viewer.