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