Changeset 45 in MondoRescue for trunk/mondo/mondo/common/libmondo-archive.c
- Timestamp:
- Oct 5, 2005, 12:51:47 AM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/mondo/mondo/common/libmondo-archive.c
r41 r45 1 /* libmondo-archive.c 2 $Id$ 1 /* $Id$ 3 2 4 3 subroutines to handle the archiving of files 5 4 6 7 8 07/149 - moved all ACL, xattr stuff here from libmondo-filelist.c10 11 07/1212 - when trying to find boot loader, look for /boot's /dev, not just /'s dev13 14 07/1015 - better detection of changed files16 - added ACL, xattr support for afio17 18 06/1719 - backup with partimagehack if NTFS device; dd, if non-NTFS device20 21 06/1422 - use mondorescue.iso instead of mindi.iso23 24 04/2825 - cleaned up if/then architecture-specific stuff re: CD-R(W)s26 27 04/0328 - added star support29 30 03/1231 - modified offer_to_write_floppies() to support dual-disk boot/root thing32 33 01/20/200434 - reformat dvd twice if necessary35 36 12/01/200337 - added pause_for_N_seconds(5, "Letting DVD drive settle");38 39 11/2340 - added #define DVDRWFORMAT41 42 11/2043 - use --no-emul-boot -b isolinux.bin instead of -b mindi-boot.2880.img44 45 10/2346 - wipe DVD at start, whether or not disk is DVD-RW; this is47 just a test, to see why dvd+rw-format followed by growiosfs48 locks up the drive49 - use the singlethreaded make_afioballs_and_images_OLD()50 instead of the multithreaded make_afioballs_and_images()51 if backing up to tape52 53 10/2154 - if backing up to dvd, look for relevant tools;55 abort if missing56 57 10/1558 - UI tweaks59 60 10/1061 - eject/inject DVD after wiping it62 63 09/2764 - pause_and_ask_for_cdr() will now blank DVD if necessary65 66 09/2667 - proper reporting of media type in displayed strings68 (i.e. DVD if DVD, CD if CD, etc.)69 70 09/2571 - add DVD support72 73 09/2374 - malloc/free global strings in new subroutines - malloc_libmondo_global_strings()75 and free_libmondo_global_strings() - which are in libmondo-tools.c76 77 09/1578 - changed a bunch of char[MAX_STR_LEN]'s to char*; malloc; free;79 80 09/1481 - cosmetic bug re: call to 'which dvdrecord'82 83 09/0984 - copy `locate isolinux.bin | tail -n1` to CD before calling mkisfso85 if file is missing (in which case, bug in Mindi.pl!)86 - reduced noof_threads from 3 to 287 - fixed cosmetic bug in make_slices_and_images()88 89 09/0290 - fixed cosmetic bug in verify_data()91 92 05/01 - 08/3193 - added partimagehack hooks94 - make twice as many archives at once as before95 - fixed syntax error re: system(xxx,FALSE)96 - unmount CD-ROM before burning (necessary for RH8/9)97 - only ask for new media if sensible98 - fixed mondoarchive -Vi multi-CD verify bug (Tom Mortell)99 - use single-threaded make_afioballs_and_images() if FreeBSD100 - fixed bug on line 476 (Joshua Oreman)101 - re-enabled the pause, for people w/ weird CD-ROM drives102 - added Joshua Oreman's FreeBSD patches103 - don't listen to please_dont_eject_when_restoring104 ...after all, we're not restoring :)105 106 04/01 - 04/30107 - cleaned up archive_this_fileset()108 - decreased ARCH_THREADS from 3 to 2109 - pause_and_ask_for_cd() --- calls retract_CD_tray_and_defeat_autorun()110 - call assert() and log_OS_error() in various places111 - cleaned up code a bit112 - increased ARCH_THREADS from 2 to 3113 - misc clean-up (Tom Mortell)114 115 03/15/2003116 - fixed problem w/ multi-ISO verify cycle (Tom Mortell)117 118 11/01 - 12/31/2002119 - removed references to make_afioballs_and_images_OLD()120 - added some error-checking to make_afioballs_in_background121 - make_iso_and_go_on() now copies Mondo's autorun file to CD122 - set scratchdir dir to 1744 when burning CD123 - cleaned up code a bit124 - in call_mindi_...(), gracefully handle the user's input125 if they specify the boot loader but not the boot device126 - offer to abort if GRUB is boot loader and /dev/md* is127 the boot device (bug in grub-install)128 - if boot loader is R then write RAW as bootloader.name129 - multithreaded make_afioballs_and_images()130 - fixed slice_up_file_etc() for 0-compression users131 - line 1198: added call to is_this_file_compressed() to stop132 slice_up_file_etc() from compressing files which are133 already compressed134 - other hackery related to the above enhancement135 - afio no longer forcibly compresses all files (i.e. I dropped136 the -U following suggestions from users); let's see if137 it works :)138 139 10/01 - 10/31140 - mondoarchive (with no parameters) wasn't working141 if user said yes when asked if BurnProof drive; FIXED142 - if manual CD tray and writing to ISO's then prompt143 for each & every new CD144 - moved a lot of subroutines here145 from mondo-archive.c and mondo-floppies.c146 147 09/01 - 09/30148 - if CD not burned OK then don't try to verify149 - change 64k to TAPE_BLOCK_SIZE150 - run_program_and_log_output() now takes boolean operator to specify151 whether it will log its activities in the event of _success_152 - orig_vfy_flag_val added to write_iso_and_go_on, to restore bkpinfo->verify_data's153 value if altered by verify_cd_image()154 155 08/01 - 08/31156 - use data structure to store the fname, checksum, mods & perms of each bigfile157 ... biggiestruct :)158 - bigger tmp[]'s in a few places159 - cleaned up the (user-friendly) counting of biggiefiles a bit160 - if media_size[N]<=0 then catch it & abort, unless it's tape,161 in which case, allow it162 - cleaned up a lot of log_it() calls163 - fixed NULL filename-related bug in can_we_fit_these_files_on_media()164 - deleted can_we_fit.....() subroutine because it was causing problems165 --- moved its code into the one subroutine which called it166 - created [08/01/2002]167 5 */ 168 6 … … 352 190 int 353 191 archive_this_fileset_with_star(struct s_bkpinfo *bkpinfo, char *filelist, 354 char *fname, int setno)192 char *fname, int setno) 355 193 { 356 194 int retval = 0; … … 396 234 asprintf(&tmp, "%s", last_line_of_file(MONDO_LOGFILE)); 397 235 log_msg(1, "res=%d; tmp='%s'", res, tmp); 398 paranoid_free(tmp);399 236 if (bkpinfo->use_star && (res == 254 || res == 65024) 400 237 && strstr(tmp, "star: Processed all possible files") … … 403 240 res = 0; 404 241 } 242 paranoid_free(tmp); 405 243 if (res) { 406 244 log_OS_error(command); … … 417 255 } 418 256 } 257 paranoid_free(command); 258 419 259 retval += res; 420 260 if (retval) { … … 425 265 } 426 266 427 paranoid_free(command);428 paranoid_free(tmp);429 267 return (retval); 430 268 } … … 475 313 if (!does_file_exist(filelist)) { 476 314 asprintf(&tmp, 477 "(archive_this_fileset) - filelist %s does not exist",478 filelist);315 "(archive_this_fileset) - filelist %s does not exist", 316 filelist); 479 317 log_to_screen(tmp); 480 318 paranoid_free(tmp) 481 return (1);319 return (1); 482 320 } 483 321 asprintf(&tmp, "echo hi > %s 2> /dev/null", fname); … … 488 326 489 327 490 if (bkpinfo->compression_level > 0) {328 if (bkpinfo->compression_level > 0) { 491 329 asprintf(&tmp, "%s/do-not-compress-these", g_mondo_home); 492 330 // -b %ld, TAPE_BLOCK_SIZE … … 496 334 asprintf(&tmp1, "%s -E %s", zipparams, tmp); 497 335 paranoid_free(zipparams) 498 zipparams = tmp1;336 zipparams = tmp1; 499 337 } else { 338 asprintf(&zipparams, "%s", ""); 500 339 log_msg(3, "%s not found. Cannot exclude zipfiles, etc.", tmp); 501 340 } … … 541 380 } 542 381 } 382 paranoid_free(command); 383 543 384 retval += res; 544 385 if (retval) { … … 564 405 } 565 406 } 566 paranoid_free(command);567 407 return (retval); 568 408 } 569 570 571 572 573 409 574 410 … … 617 453 { fatal_error("Failed to count filelist.full"); } 618 454 */ 619 asprintf(&tmp, "gzip -9 %s/archives/filelist.full", bkpinfo->scratchdir); 455 asprintf(&tmp, "gzip -9 %s/archives/filelist.full", 456 bkpinfo->scratchdir); 620 457 if (run_program_and_log_output(tmp, 2)) { 621 458 fatal_error("Failed to gzip filelist.full"); … … 623 460 paranoid_free(tmp); 624 461 asprintf(&tmp, "cp -f %s/archives/*list*.gz %s", bkpinfo->scratchdir, 625 bkpinfo->tmpdir);462 bkpinfo->tmpdir); 626 463 if (run_program_and_log_output(tmp, 2)) { 627 464 fatal_error("Failed to copy to tmpdir"); … … 659 496 return (retval); 660 497 } 661 662 663 498 664 499 … … 724 559 725 560 asprintf(&tmp, 726 "echo \"%s\" | tr -s ' ' '\n' | grep -x \"/dev/.*\" | tr -s '\n' ' ' | awk '{print $0\"\\n\";}'", 727 bkpinfo->exclude_paths); 728 asprintf(&devs_to_exclude, call_program_and_get_last_line_of_output(tmp)); 561 "echo \"%s\" | tr -s ' ' '\n' | grep -x \"/dev/.*\" | tr -s '\n' ' ' | awk '{print $0\"\\n\";}'", 562 bkpinfo->exclude_paths); 563 asprintf(&devs_to_exclude, 564 call_program_and_get_last_line_of_output(tmp)); 729 565 paranoid_free(tmp); 730 566 asprintf(&tmp, "devs_to_exclude = '%s'", devs_to_exclude); … … 732 568 paranoid_free(tmp); 733 569 mvaddstr_and_log_it(g_currentY, 0, 734 "Calling MINDI to create boot+data disks");570 "Calling MINDI to create boot+data disks"); 735 571 asprintf(&tmp, "%s/filelist.full", bkpinfo->tmpdir); 736 572 if (!does_file_exist(tmp)) { … … 777 613 asprintf(&cd_recovery_sz, "no"); 778 614 } 779 /* BCO:shared between LILO/ELILO */615 /* Field shared between LILO/ELILO */ 780 616 if (bkpinfo->make_cd_use_lilo) { 781 617 asprintf(&use_lilo_sz, "yes"); … … 790 626 #ifdef __FreeBSD__ 791 627 asprintf(&bootdev, call_program_and_get_last_line_of_output 792 628 ("mount | grep ' /boot ' | head -1 | cut -d' ' -f1 | sed 's/\\([0-9]\\).*/\\1/'")); 793 629 if (!bootdev[0]) { 794 630 paranoid_free(bootdev); 795 631 asprintf(&bootdev, call_program_and_get_last_line_of_output 796 632 ("mount | grep ' / ' | head -1 | cut -d' ' -f1 | sed 's/\\([0-9]\\).*/\\1/'")); 797 633 } 798 634 #else 799 635 asprintf(&bootdev, call_program_and_get_last_line_of_output 800 636 ("mount | grep ' /boot ' | head -1 | cut -d' ' -f1 | sed 's/[0-9].*//'")); 801 637 if (strstr(bootdev, "/dev/cciss/")) { 802 638 paranoid_free(bootdev); 803 639 asprintf(&bootdev, call_program_and_get_last_line_of_output 804 640 ("mount | grep ' /boot ' | head -1 | cut -d' ' -f1 | cut -dp -f1")); 805 641 } 806 642 if (!bootdev[0]) { 807 643 paranoid_free(bootdev); 808 644 asprintf(&bootdev, call_program_and_get_last_line_of_output 809 645 ("mount | grep ' / ' | head -1 | cut -d' ' -f1 | sed 's/[0-9].*//'")); 810 646 if (strstr(bootdev, "/dev/cciss/")) { 811 647 paranoid_free(bootdev); 812 648 asprintf(&bootdev, call_program_and_get_last_line_of_output 813 649 ("mount | grep ' / ' | head -1 | cut -d' ' -f1 | cut -dp -f1")); 814 650 } 815 651 } … … 821 657 if (bkpinfo->boot_loader != '\0') { 822 658 asprintf(&tmp, "User specified boot loader. It is '%c'.", 823 bkpinfo->boot_loader);659 bkpinfo->boot_loader); 824 660 log_msg(2, tmp); 825 661 paranoid_free(tmp); … … 829 665 if (bkpinfo->boot_device[0] != '\0') { 830 666 asprintf(&tmp, "User specified boot device. It is '%s'.", 831 bkpinfo->boot_device);667 bkpinfo->boot_device); 832 668 log_msg(2, tmp); 833 669 paranoid_free(tmp); … … 849 685 { 850 686 fatal_error 851 ("Please specify your boot loader and device, e.g. -l GRUB -f /dev/hda. 687 ("Please specify your boot loader and device, e.g. -l GRUB -f /dev/hda.\nType 'man mondoarchive' to read the manual."); 852 688 } 853 689 if (bkpinfo->boot_loader == 'L') { … … 855 691 if (!does_file_exist("/etc/lilo.conf")) { 856 692 fatal_error 857 ("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?");693 ("The de facto standard location for your boot loader's config file is /etc/lilo.conf.\nBut I cannot find it there. What is wrong with your Linux distribution?"); 858 694 } 859 695 } else if (bkpinfo->boot_loader == 'G') { … … 872 708 if (!does_file_exist("/etc/grub.conf")) { 873 709 fatal_error 874 ("The de facto standard location for your boot loader's config file is /etc/grub.conf but I cannot find it there. What is wrong with your Linux distribution?Try 'ln -s /boot/grub/menu.lst /etc/grub.conf'...");710 ("The de facto standard location for your boot loader's config file is /etc/grub.conf.\nBut I cannot find it there. What is wrong with your Linux distribution?\nTry 'ln -s /boot/grub/menu.lst /etc/grub.conf'..."); 875 711 } 876 712 } else if (bkpinfo->boot_loader == 'E') { 877 713 asprintf(&bootldr_str, "ELILO"); 878 /* B CO: fix it for SuSE, Debian, Mandrake, ... */714 /* BERLIOS: fix it for SuSE, Debian, Mandrake, ... */ 879 715 if (!does_file_exist("/etc/elilo.conf") 880 716 && does_file_exist("/boot/efi/efi/redhat/elilo.conf")) { … … 885 721 if (!does_file_exist("/etc/elilo.conf")) { 886 722 fatal_error 887 ("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'");723 ("The de facto mondo standard location for your boot loader's config file is /etc/elilo.conf\nBut I cannot find it there. What is wrong with your Linux distribution?\nTry finding it under /boot/efi and do 'ln -s /boot/efi/..../elilo.conf /etc/elilo.conf'"); 888 724 } 889 725 } else if (bkpinfo->boot_loader == 'R') { … … 903 739 } 904 740 asprintf(&tmp, "Your boot loader is %s and it boots from %s", 905 bootldr_str, bkpinfo->boot_device);741 bootldr_str, bkpinfo->boot_device); 906 742 log_to_screen(tmp); 907 743 paranoid_free(tmp); … … 982 818 983 819 asprintf(&tmp, "BTW, I'm telling Mindi your kernel is '%s'", 984 bkpinfo->kernel_path);820 bkpinfo->kernel_path); 985 821 log_to_screen(tmp); 986 822 paranoid_free(tmp); 987 823 988 824 log_msg(1, "lines_in_filelist = %ld", lines_in_filelist); 989 825 990 826 // Watch it! This next line adds a parameter... 991 827 if (bkpinfo->nonbootable_backup) { … … 999 835 6=\"%s\" 7=%ld 8=\"%s\" 9=\"%s\" 10=\"%s\" \ 1000 836 11=\"%s\" 12=%s 13=%ld 14=\"%s\" 15=\"%s\" 16=\"%s\" 17=\"%s\" 18=%ld 19=%d",*/ 1001 "mindi --custom %s %s/images \"%s\" \"%s\" \837 "mindi --custom %s %s/images \"%s\" \"%s\" \ 1002 838 \"%s\" %ld \"%s\" \"%s\" \"%s\" \ 1003 \"%s\" %s %ld \"%s\" \"%s\" \"%s\" \"%s\" %ld %d %s", 1004 bkpinfo->tmpdir, // parameter #2 1005 bkpinfo->scratchdir, // parameter #3 1006 bkpinfo->kernel_path, // parameter #4 1007 tape_device, // parameter #5 1008 tape_size_sz, // parameter #6 1009 lines_in_filelist, // parameter #7 (INT) 1010 use_lzo_sz, // parameter #8 1011 cd_recovery_sz, // parameter #9 1012 bkpinfo->image_devs, // parameter #10 1013 broken_bios_sz, // parameter #11 1014 last_filelist_number, // parameter #12 (STRING) 1015 estimated_total_noof_slices, // parameter #13 (INT) 1016 devs_to_exclude, // parameter #14 1017 use_comp_sz, // parameter #15 1018 use_lilo_sz, // parameter #16 1019 use_star_sz, // parameter #17 1020 bkpinfo->internal_tape_block_size, // parameter #18 (LONG) 1021 bkpinfo->differential, // parameter #19 (INT) 1022 tmp); 839 \"%s\" %s %ld \"%s\" \"%s\" \"%s\" \"%s\" %ld %d %s", bkpinfo->tmpdir, // parameter #2 840 bkpinfo->scratchdir, // parameter #3 841 bkpinfo->kernel_path, // parameter #4 842 tape_device, // parameter #5 843 tape_size_sz, // parameter #6 844 lines_in_filelist, // parameter #7 (INT) 845 use_lzo_sz, // parameter #8 846 cd_recovery_sz, // parameter #9 847 bkpinfo->image_devs, // parameter #10 848 broken_bios_sz, // parameter #11 849 last_filelist_number, // parameter #12 (STRING) 850 estimated_total_noof_slices, // parameter #13 (INT) 851 devs_to_exclude, // parameter #14 852 use_comp_sz, // parameter #15 853 use_lilo_sz, // parameter #16 854 use_star_sz, // parameter #17 855 bkpinfo->internal_tape_block_size, // parameter #18 (LONG) 856 bkpinfo->differential, // parameter #19 (INT) 857 tmp); 1023 858 paranoid_free(tmp); 1024 859 paranoid_free(tape_size_sz); … … 1038 873 1039 874 res = run_program_and_log_to_screen(command, 1040 875 "Generating boot+data disks"); 1041 876 paranoid_free(command); 1042 877 … … 1052 887 1053 888 asprintf(&command, 1054 "cp -f %s/images/mindi.iso /root/images/mindi/mondorescue.iso",1055 bkpinfo->scratchdir);889 "cp -f %s/images/mindi.iso /root/images/mindi/mondorescue.iso", 890 bkpinfo->scratchdir); 1056 891 log_msg(2, command); 1057 892 run_program_and_log_output(command, FALSE); … … 1060 895 if (bkpinfo->nonbootable_backup) { 1061 896 asprintf(&command, "cp -f %s/all.tar.gz %s/images", 1062 bkpinfo->tmpdir, bkpinfo->scratchdir);897 bkpinfo->tmpdir, bkpinfo->scratchdir); 1063 898 if (system(command)) { 1064 899 fatal_error("Unable to create temporary duff tarball"); 1065 paranoid_free(command);900 paranoid_free(command); 1066 901 } 1067 902 } 1068 903 asprintf(&command, "cp -f %s/mindi-*oot*.img %s/images", 1069 bkpinfo->tmpdir, bkpinfo->scratchdir);904 bkpinfo->tmpdir, bkpinfo->scratchdir); 1070 905 log_msg(2, command); 1071 906 run_program_and_log_output(command, FALSE); 1072 907 paranoid_free(command); 1073 908 1074 asprintf(&tmp, "cp -f %s/images/all.tar.gz %s", 1075 bkpinfo->scratchdir, bkpinfo->tmpdir);909 asprintf(&tmp, "cp -f %s/images/all.tar.gz %s", 910 bkpinfo->scratchdir, bkpinfo->tmpdir); 1076 911 if (system(tmp)) { 1077 912 fatal_error("Cannot find all.tar.gz in tmpdir"); … … 1087 922 log_to_screen("Mindi failed to create your boot+data disks."); 1088 923 asprintf(&command, "cat %s | grep \"Fatal error\"", 1089 "/var/log/mindi.log");924 "/var/log/mindi.log"); 1090 925 asprintf(&tmp, call_program_and_get_last_line_of_output(command)); 1091 926 paranoid_free(command); … … 1097 932 return (res); 1098 933 } 1099 1100 934 1101 935 … … 1160 994 1161 995 asprintf(&archiving_filelist_fname, FILELIST_FNAME_RAW_SZ, 1162 bkpinfo->tmpdir, 0L);996 bkpinfo->tmpdir, 0L); 1163 997 archiving_set_no = 0; 1164 998 while (does_file_exist(archiving_filelist_fname)) { … … 1185 1019 /* backup this set of files */ 1186 1020 asprintf(&archiving_afioball_fname, AFIOBALL_FNAME_RAW_SZ, 1187 bkpinfo->tmpdir, archiving_set_no, bkpinfo->zip_suffix);1021 bkpinfo->tmpdir, archiving_set_no, bkpinfo->zip_suffix); 1188 1022 asprintf(&archiving_filelist_fname, FILELIST_FNAME_RAW_SZ, 1189 bkpinfo->tmpdir, archiving_set_no);1023 bkpinfo->tmpdir, archiving_set_no); 1190 1024 if (!does_file_exist(archiving_filelist_fname)) { 1191 1025 log_msg(3, 1192 "%s[%d:%d] - well, I would archive %d, except that it doesn't exist. I'll stop now.",1193 FORTY_SPACES, getpid(), this_thread_no,1194 archiving_set_no);1026 "%s[%d:%d] - well, I would archive %d, except that it doesn't exist. I'll stop now.", 1027 FORTY_SPACES, getpid(), this_thread_no, 1028 archiving_set_no); 1195 1029 paranoid_free(archiving_filelist_fname); 1196 1030 paranoid_free(archiving_afioball_fname); … … 1199 1033 1200 1034 asprintf(&tmp, AFIOBALL_FNAME_RAW_SZ, bkpinfo->tmpdir, 1201 archiving_set_no - ARCH_BUFFER_NUM, bkpinfo->zip_suffix);1035 archiving_set_no - ARCH_BUFFER_NUM, bkpinfo->zip_suffix); 1202 1036 if (does_file_exist(tmp)) { 1203 log_msg(4, "%s[%d:%d] - waiting for storer", 1037 log_msg(4, "%s[%d:%d] - waiting for storer", 1204 1038 FORTY_SPACES, getpid(), this_thread_no); 1205 1039 while (does_file_exist(tmp)) { … … 1213 1047 this_thread_no, archiving_set_no); 1214 1048 asprintf(&curr_xattr_list_fname, XATTR_LIST_FNAME_RAW_SZ, 1215 bkpinfo->tmpdir, archiving_set_no);1049 bkpinfo->tmpdir, archiving_set_no); 1216 1050 asprintf(&curr_acl_list_fname, ACL_LIST_FNAME_RAW_SZ, 1217 bkpinfo->tmpdir, archiving_set_no);1051 bkpinfo->tmpdir, archiving_set_no); 1218 1052 get_fattr_list(archiving_filelist_fname, curr_xattr_list_fname); 1219 1053 paranoid_free(curr_xattr_list_fname); … … 1224 1058 this_thread_no, archiving_set_no); 1225 1059 res = archive_this_fileset(bkpinfo, archiving_filelist_fname, 1226 archiving_afioball_fname,1227 archiving_set_no);1060 archiving_afioball_fname, 1061 archiving_set_no); 1228 1062 paranoid_free(archiving_afioball_fname); 1229 1063 paranoid_free(archiving_filelist_fname); … … 1232 1066 if (res) { 1233 1067 asprintf(&tmp, 1234 "Errors occurred while archiving set %ld. Please review logs.",1235 archiving_set_no);1068 "Errors occurred while archiving set %ld. Please review logs.", 1069 archiving_set_no); 1236 1070 log_to_screen(tmp); 1237 1071 paranoid_free(tmp); … … 1268 1102 pthread_exit(NULL); 1269 1103 } 1270 1271 1272 1273 1104 1274 1105 … … 1296 1127 1297 1128 log_msg(1, "Closing tape/CD ... "); 1298 if (IS_THIS_A_STREAMING_BACKUP(bkpinfo->backup_media_type)) 1129 if (IS_THIS_A_STREAMING_BACKUP(bkpinfo->backup_media_type)) { 1299 1130 /* write tape/cdstream */ 1300 {1301 1131 closeout_tape(bkpinfo); 1302 } else 1132 } else { 1303 1133 /* write final ISO */ 1304 {1305 1134 res = write_final_iso_if_necessary(bkpinfo); 1306 1135 retval += res; … … 1359 1188 hexdump | tr -s ' ' '0' | head -n1")); 1360 1189 strip_spaces(g_serial_string); 1361 asprintf(&tmp, "%s...word.", g_serial_string);1190 asprintf(&tmp, "%s...word.", g_serial_string); 1362 1191 paranoid_free(g_serial_string); 1363 1192 g_serial_string = tmp; … … 1389 1218 1390 1219 asprintf(&command, "rm -f %s/%s-[1-9]*.iso", bkpinfo->prefix, 1391 bkpinfo->isodir);1220 bkpinfo->isodir); 1392 1221 paranoid_system(command); 1393 1222 paranoid_free(command); … … 1396 1225 if (IS_THIS_A_STREAMING_BACKUP(bkpinfo->backup_media_type)) { 1397 1226 write_header_block_to_stream(0, "start-of-tape", 1398 BLK_START_OF_TAPE);1227 BLK_START_OF_TAPE); 1399 1228 write_header_block_to_stream(0, "start-of-backup", 1400 BLK_START_OF_BACKUP);1229 BLK_START_OF_BACKUP); 1401 1230 } 1402 1231 return (retval); … … 1434 1263 assert_string_is_neither_NULL_nor_zerolength(title); 1435 1264 1436 malloc_string(command);1437 1265 #ifdef __FreeBSD__ 1438 1266 /* Ugh. FreeBSD fdformat prints out this pretty progress indicator that's … … 1450 1278 } 1451 1279 /* if not Debian then go ahead & use fdformat */ 1452 asprintf(&tempfile, "%s",1453 1454 1455 asprintf(&command, "%s >> %s 2>> %s; rm -f %s", cmd, tempfile, tempfile,1456 tempfile);1280 asprintf(&tempfile, "%s", 1281 call_program_and_get_last_line_of_output 1282 ("mktemp -q /tmp/mondo.XXXXXXXX")); 1283 asprintf(&command, "%s >> %s 2>> %s; rm -f %s", cmd, tempfile, 1284 tempfile, tempfile); 1457 1285 log_msg(3, command); 1458 1286 open_evalcall_form(title); … … 1466 1294 maxtracks = 80; 1467 1295 } 1296 paranoid_free(command); 1297 1468 1298 for (sleep(1); does_file_exist(tempfile); sleep(1)) { 1469 1299 trackno = get_trackno_from_logfile(tempfile); … … 1487 1317 } 1488 1318 unlink(tempfile); 1489 paranoid_free(command);1490 1319 paranoid_free(tempfile); 1491 1320 return (res); 1492 1321 } 1322 1493 1323 1494 1324 /** … … 1534 1364 return (res); 1535 1365 } 1366 1536 1367 1537 1368 /** … … 1632 1463 log_msg(5, "Go, Shorty. It's your birthday."); 1633 1464 open_progress_form("Backing up filesystem", 1634 "I am backing up your live filesystem now.",1635 "Please wait. This may take a couple of hours.",1636 "Working...",1637 get_last_filelist_number(bkpinfo) + 1);1465 "I am backing up your live filesystem now.", 1466 "Please wait. This may take a couple of hours.", 1467 "Working...", 1468 get_last_filelist_number(bkpinfo) + 1); 1638 1469 1639 1470 log_msg(5, "We're gonna party like it's your birthday."); … … 1654 1485 if ((res = 1655 1486 pthread_create(&archival_thread[noof_threads], NULL, 1656 create_afio_files_in_background,1657 (void *) transfer_block))) {1487 create_afio_files_in_background, 1488 (void *) transfer_block))) { 1658 1489 fatal_error("Unable to create an archival thread"); 1659 1490 } 1660 1491 } 1492 paranoid_free(transfer_block); 1661 1493 1662 1494 log_msg(8, "About to enter while() loop"); … … 1668 1500 && *p_last_set_archived == storing_set_no - 1) { 1669 1501 log_msg(2, 1670 "No archival threads are running. The last stored set was %d and I'm looking for %d. Take off your make-up; the party's over... :-)",1671 *p_last_set_archived, storing_set_no);1502 "No archival threads are running. The last stored set was %d and I'm looking for %d. Take off your make-up; the party's over... :-)", 1503 *p_last_set_archived, storing_set_no); 1672 1504 done_storing = TRUE; 1673 } else if (!get_bit_N_of_array(p_list_of_fileset_flags, storing_set_no)) { 1505 } else 1506 if (!get_bit_N_of_array 1507 (p_list_of_fileset_flags, storing_set_no)) { 1674 1508 misc_counter_that_is_not_important = 1675 1509 (misc_counter_that_is_not_important + 1) % 5; … … 1677 1511 /* maybe : */ 1678 1512 asprintf(&media_usage_comment, "%s", 1679 1513 percent_media_full_comment(bkpinfo)); 1680 1514 if (!misc_counter_that_is_not_important) { 1681 1515 update_progress_form(media_usage_comment); … … 1686 1520 // store set N 1687 1521 asprintf(&storing_filelist_fname, FILELIST_FNAME_RAW_SZ, 1688 bkpinfo->tmpdir, storing_set_no);1522 bkpinfo->tmpdir, storing_set_no); 1689 1523 asprintf(&storing_afioball_fname, AFIOBALL_FNAME_RAW_SZ, 1690 bkpinfo->tmpdir, storing_set_no, bkpinfo->zip_suffix);1524 bkpinfo->tmpdir, storing_set_no, bkpinfo->zip_suffix); 1691 1525 asprintf(&curr_xattr_list_fname, XATTR_LIST_FNAME_RAW_SZ, 1692 bkpinfo->tmpdir, storing_set_no);1526 bkpinfo->tmpdir, storing_set_no); 1693 1527 asprintf(&curr_acl_list_fname, ACL_LIST_FNAME_RAW_SZ, 1694 bkpinfo->tmpdir, storing_set_no);1528 bkpinfo->tmpdir, storing_set_no); 1695 1529 1696 1530 log_msg(2, "Storing set %d", storing_set_no); … … 1703 1537 } 1704 1538 asprintf(&media_usage_comment, "%s", 1705 1539 percent_media_full_comment(bkpinfo)); 1706 1540 /* copy to CD (scratchdir) ... and an actual CD-R if necessary */ 1707 1541 if (IS_THIS_A_STREAMING_BACKUP(bkpinfo->backup_media_type)) { 1708 1542 register_in_tape_catalog(fileset, storing_set_no, -1, 1709 storing_afioball_fname);1543 storing_afioball_fname); 1710 1544 maintain_collection_of_recent_archives(bkpinfo->tmpdir, 1711 storing_afioball_fname);1545 storing_afioball_fname); 1712 1546 iamhere("Writing EXAT files"); 1713 res += 1714 write_EXAT_files_to_tape(bkpinfo, 1715 curr_xattr_list_fname, 1716 curr_acl_list_fname); 1547 res += write_EXAT_files_to_tape(bkpinfo, 1548 curr_xattr_list_fname, 1549 curr_acl_list_fname); 1717 1550 // archives themselves 1718 1551 res += 1719 1552 move_files_to_stream(bkpinfo, storing_afioball_fname, 1720 NULL);1553 NULL); 1721 1554 } else { 1722 res = 1723 move_files_to_cd(bkpinfo, storing_filelist_fname, 1724 curr_xattr_list_fname, 1725 curr_acl_list_fname, 1726 storing_afioball_fname, NULL); 1555 res = move_files_to_cd(bkpinfo, storing_filelist_fname, 1556 curr_xattr_list_fname, 1557 curr_acl_list_fname, 1558 storing_afioball_fname, NULL); 1727 1559 } 1728 1560 paranoid_free(storing_filelist_fname); … … 1737 1569 if (res) { 1738 1570 asprintf(&tmp, 1739 "Failed to add archive %ld's files to CD dir\n",1740 storing_set_no);1571 "Failed to add archive %ld's files to CD dir\n", 1572 storing_set_no); 1741 1573 log_to_screen(tmp); 1742 1574 paranoid_free(tmp); 1743 fatal_error("Is your hard disk full? If not, please send the author the logfile."); 1575 fatal_error 1576 ("Is your hard disk full? If not, please send the author the logfile."); 1744 1577 } 1745 1578 storing_set_no++; … … 1757 1590 log_msg(2, "Done."); 1758 1591 if (retval) { 1759 asprintf(&tmp, "Your regular files have been archived (with errors)."); 1592 asprintf(&tmp, 1593 "Your regular files have been archived (with errors)."); 1760 1594 } else { 1761 asprintf(&tmp, "Your regular files have been archived successfully"); 1595 asprintf(&tmp, 1596 "Your regular files have been archived successfully"); 1762 1597 } 1763 1598 log_to_screen(tmp); 1764 1599 paranoid_free(tmp); 1765 paranoid_free(transfer_block);1766 1600 paranoid_free(result_str); 1767 1601 return (retval); … … 1779 1613 close_evalcall_form(); 1780 1614 } 1781 1782 1783 1615 1784 1616 … … 1851 1683 if (bkpinfo->call_before_iso[0] != '\0') { 1852 1684 asprintf(&message_to_screen, "Running pre-ISO call for CD#%d", 1853 g_current_media_number);1685 g_current_media_number); 1854 1686 res = eval_call_to_make_ISO(bkpinfo, bkpinfo->call_before_iso, 1855 1856 1687 destfile, g_current_media_number, 1688 MONDO_LOGFILE, message_to_screen); 1857 1689 if (res) { 1858 1690 log_to_screen("%s...failed", message_to_screen); … … 1868 1700 asprintf(&tmp, "%s/archives/NOT-THE-LAST", bkpinfo->scratchdir); 1869 1701 asprintf(&message_to_screen, "Making an ISO (%s #%d)", 1870 media_descriptor_string(bkpinfo->backup_media_type),1871 g_current_media_number);1702 media_descriptor_string(bkpinfo->backup_media_type), 1703 g_current_media_number); 1872 1704 1873 1705 /* if g_current_media_number >= 2 then pause & ask */ 1874 pause_and_ask_for_cdr(2, &cd_is_mountable); 1706 pause_and_ask_for_cdr(2, &cd_is_mountable); 1875 1707 if (retval) { 1876 1708 log_to_screen 1877 1709 ("Serious error(s) occurred already. I shan't try to write to media."); 1878 1710 } else { 1879 res = 1880 eval_call_to_make_ISO(bkpinfo, bkpinfo->call_make_iso, 1881 bkpinfo->scratchdir, 1882 g_current_media_number, 1883 MONDO_LOGFILE, message_to_screen); 1711 res = eval_call_to_make_ISO(bkpinfo, bkpinfo->call_make_iso, 1712 bkpinfo->scratchdir, 1713 g_current_media_number, 1714 MONDO_LOGFILE, message_to_screen); 1884 1715 if (res) { 1885 1716 log_to_screen("%s...failed to write", message_to_screen); … … 1896 1727 #ifdef DVDRWFORMAT 1897 1728 asprintf(&tmp, 1898 "cat %s | tail -n8 | grep \"blank=full.*dvd-compat.*DAO\"",1899 MONDO_LOGFILE);1729 "cat %s | tail -n8 | grep \"blank=full.*dvd-compat.*DAO\"", 1730 MONDO_LOGFILE); 1900 1731 if (g_backup_media_type == dvd 1901 1732 && (res || !run_program_and_log_output(tmp, 1))) { … … 1913 1744 } 1914 1745 pause_for_N_seconds(5, "Letting DVD drive settle"); 1915 asprintf(&sz_blank_disk, "dvd+rw-format %s", bkpinfo->media_device); 1746 asprintf(&sz_blank_disk, "dvd+rw-format %s", 1747 bkpinfo->media_device); 1916 1748 log_msg(3, "sz_blank_disk = '%s'", sz_blank_disk); 1917 res = 1918 run_external_binary_with_percentage_indicator_NEW 1749 res = run_external_binary_with_percentage_indicator_NEW 1919 1750 ("Blanking DVD disk", sz_blank_disk); 1920 1751 if (res) { … … 1923 1754 pause_for_N_seconds(5, 1924 1755 "Letting DVD drive settle... and trying again."); 1925 res = 1926 run_external_binary_with_percentage_indicator_NEW 1756 res = run_external_binary_with_percentage_indicator_NEW 1927 1757 ("Blanking DVD disk", sz_blank_disk); 1928 1758 if (res) { … … 1968 1798 } else { 1969 1799 asprintf(&message_to_screen, "Running mkisofs to make %s #%d", 1970 media_descriptor_string(bkpinfo->backup_media_type),1971 g_current_media_number);1800 media_descriptor_string(bkpinfo->backup_media_type), 1801 g_current_media_number); 1972 1802 log_msg(1, message_to_screen); 1973 1803 asprintf(&result_sz, "Call to mkisofs to make ISO (%s #%d) ", 1974 media_descriptor_string(bkpinfo->backup_media_type),1975 g_current_media_number);1804 media_descriptor_string(bkpinfo->backup_media_type), 1805 g_current_media_number); 1976 1806 if (bkpinfo->nonbootable_backup) { 1977 1807 log_msg(1, "Making nonbootable backup"); 1978 1808 // FIXME --- change mkisofs string to MONDO_MKISOFS_NONBOOTABLE and add ' .' at end 1979 res = 1980 eval_call_to_make_ISO(bkpinfo, 1981 "mkisofs -o _ISO_ -r -p MondoRescue -publisher www.mondorescue.org -A Mondo_Rescue_GPL -V _CD#_ .", 1982 destfile, g_current_media_number, 1983 MONDO_LOGFILE, message_to_screen); 1809 res = eval_call_to_make_ISO(bkpinfo, 1810 "mkisofs -o _ISO_ -r -p MondoRescue -publisher www.mondorescue.org -A Mondo_Rescue_GPL -V _CD#_ .", 1811 destfile, g_current_media_number, 1812 MONDO_LOGFILE, message_to_screen); 1984 1813 } else { 1985 1814 log_msg(1, "Making bootable backup"); … … 2010 1839 // and add ' .' at end 2011 1840 log_msg(1, "Non-ia64 --> lilo"); 2012 res = 2013 eval_call_to_make_ISO(bkpinfo,2014 "mkisofs -b images/mindi-bootroot.2880.img -c boot.cat -o _ISO_ -J -r -p MondoRescue -publisher www.mondorescue.org -A Mondo_Rescue_GPL -V _CD#_ .",2015 destfile,g_current_media_number,2016 2017 1841 res = eval_call_to_make_ISO(bkpinfo, 1842 "mkisofs -b images/mindi-bootroot.2880.img -c boot.cat -o _ISO_ -J -r -p MondoRescue -publisher www.mondorescue.org -A Mondo_Rescue_GPL -V _CD#_ .", 1843 destfile, 1844 g_current_media_number, 1845 MONDO_LOGFILE, 1846 message_to_screen); 2018 1847 #endif 2019 1848 } else { … … 2021 1850 log_msg(1, "Isolinux"); 2022 1851 res = eval_call_to_make_ISO(bkpinfo, 2023 "mkisofs -no-emul-boot -b isolinux.bin -boot-load-size 4 -boot-info-table -c boot.cat -o _ISO_ -J -r -p MondoRescue -publisher www.mondorescue.org -A Mondo_Rescue_GPL -V _CD#_ .", 2024 destfile, g_current_media_number, 2025 MONDO_LOGFILE, 2026 message_to_screen); 1852 "mkisofs -no-emul-boot -b isolinux.bin -boot-load-size 4 -boot-info-table -c boot.cat -o _ISO_ -J -r -p MondoRescue -publisher www.mondorescue.org -A Mondo_Rescue_GPL -V _CD#_ .", 1853 destfile, 1854 g_current_media_number, 1855 MONDO_LOGFILE, 1856 message_to_screen); 2027 1857 } 2028 1858 } … … 2052 1882 log_msg(2, "bkpinfo->call_burn_iso = %s", bkpinfo->call_burn_iso); 2053 1883 asprintf(&message_to_screen, "Burning %s #%d", 2054 media_descriptor_string(bkpinfo->backup_media_type),2055 g_current_media_number);1884 media_descriptor_string(bkpinfo->backup_media_type), 1885 g_current_media_number); 2056 1886 pause_and_ask_for_cdr(2, &cd_is_mountable); 2057 1887 res = eval_call_to_make_ISO(bkpinfo, bkpinfo->call_burn_iso, 2058 2059 1888 destfile, g_current_media_number, 1889 MONDO_LOGFILE, message_to_screen); 2060 1890 if (res) { 2061 1891 log_to_screen("%s...failed", message_to_screen); … … 2069 1899 if (bkpinfo->call_after_iso[0] != '\0') { 2070 1900 asprintf(&message_to_screen, "Running post-ISO call (%s #%d)", 2071 media_descriptor_string(bkpinfo->backup_media_type),2072 g_current_media_number);1901 media_descriptor_string(bkpinfo->backup_media_type), 1902 g_current_media_number); 2073 1903 res = eval_call_to_make_ISO(bkpinfo, bkpinfo->call_after_iso, 2074 2075 1904 destfile, g_current_media_number, 1905 MONDO_LOGFILE, message_to_screen); 2076 1906 if (res) { 2077 1907 log_to_screen("%s...failed", message_to_screen); … … 2097 1927 char *command; 2098 1928 asprintf(&command, 2099 "dd if=%s bs=512 count=1 2> /dev/null | strings | head -n1",2100 bigfile_fname);1929 "dd if=%s bs=512 count=1 2> /dev/null | strings | head -n1", 1930 bigfile_fname); 2101 1931 log_msg(1, "command = '%s'", command); 2102 asprintf(&tmp, "%s", call_program_and_get_last_line_of_output(command)); 1932 asprintf(&tmp, "%s", 1933 call_program_and_get_last_line_of_output(command)); 2103 1934 log_msg(1, "--> tmp = '%s'", tmp); 2104 1935 paranoid_free(command); … … 2139 1970 /*@ buffers ******************************************** */ 2140 1971 char *tmp; 2141 char *bigfile_fname ;1972 char *bigfile_fname = NULL; 2142 1973 char *sz_devfile; 2143 1974 char *partimagehack_fifo = NULL; … … 2150 1981 int retval = 0; 2151 1982 int res = 0; 1983 int n = 0; 2152 1984 pid_t pid; 2153 1985 FILE *ftmp = NULL; … … 2160 1992 assert_string_is_neither_NULL_nor_zerolength(biggielist_fname); 2161 1993 2162 malloc_string(bigfile_fname);2163 1994 estimated_total_noof_slices = 2164 1995 size_of_all_biggiefiles_K(bkpinfo) / bkpinfo->optimal_set_size + 1; … … 2184 2015 return (1); 2185 2016 } 2186 for (fgets(bigfile_fname, MAX_STR_LEN, fin); !feof(fin); 2187 fgets(bigfile_fname, MAX_STR_LEN, fin), biggie_file_number++) { 2017 for (getline(&bigfile_fname, (size_t) & n, fin); !feof(fin); 2018 getline(&bigfile_fname, (size_t) & n, fin), 2019 biggie_file_number++) { 2188 2020 use_partimagehack = FALSE; 2189 2021 if (bigfile_fname[strlen(bigfile_fname) - 1] < 32) { … … 2197 2029 paranoid_fclose(ftmp); 2198 2030 asprintf(&tmp, "bigfile %s was deleted - creating a dummy", 2199 bigfile_fname);2031 bigfile_fname); 2200 2032 delete_when_done = TRUE; 2201 2033 } else { … … 2210 2042 bigfile_fname); 2211 2043 asprintf(&sz_devfile, "/tmp/%d.%d.000", 2212 (int) (random() % 32768),2213 (int) (random() % 32768));2044 (int) (random() % 32768), 2045 (int) (random() % 32768)); 2214 2046 mkfifo(sz_devfile, 0x770); 2215 2047 partimagehack_fifo = sz_devfile; … … 2229 2061 (long int) (pid)); 2230 2062 2231 paranoid_free(sz_devfile);2063 paranoid_free(sz_devfile); 2232 2064 } 2233 2065 } … … 2248 2080 } 2249 2081 res = slice_up_file_etc(bkpinfo, bigfile_fname, 2250 2251 2082 partimagehack_fifo, biggie_file_number, 2083 noof_biggie_files, use_partimagehack); 2252 2084 if (IS_THIS_A_STREAMING_BACKUP(bkpinfo->backup_media_type)) { 2253 2085 write_header_block_to_stream(0, … … 2283 2115 } 2284 2116 paranoid_free(tmp); 2117 paranoid_free(bigfile_fname); 2118 paranoid_fclose(fin); 2119 2285 2120 log_msg(1, "Finished backing up bigfiles"); 2286 2121 log_msg(1, "estimated slices = %ld; actual slices = %ld", 2287 2122 estimated_total_noof_slices, g_current_progress); 2288 2123 close_progress_form(); 2289 paranoid_fclose(fin);2290 paranoid_free(bigfile_fname);2291 2124 return (retval); 2292 2125 } 2293 2294 2295 2126 2296 2127 … … 2316 2147 2317 2148 /* BERLIOS: Useless ? 2318 asprintf(&tmp, "%s/archives/filelist.full", bkpinfo->scratchdir);2319 */2149 asprintf(&tmp, "%s/archives/filelist.full", bkpinfo->scratchdir); 2150 */ 2320 2151 2321 2152 log_to_screen("Archiving regular files"); … … 2328 2159 2329 2160 asprintf(&curr_filelist_fname, FILELIST_FNAME_RAW_SZ, bkpinfo->tmpdir, 2330 0L);2161 0L); 2331 2162 2332 2163 curr_set_no = 0; … … 2334 2165 /* backup this set of files */ 2335 2166 asprintf(&curr_afioball_fname, AFIOBALL_FNAME_RAW_SZ, 2336 bkpinfo->tmpdir, curr_set_no, bkpinfo->zip_suffix);2167 bkpinfo->tmpdir, curr_set_no, bkpinfo->zip_suffix); 2337 2168 2338 2169 log_msg(1, "EXAT'g set %ld", curr_set_no); 2339 2170 asprintf(&curr_xattr_list_fname, XATTR_LIST_FNAME_RAW_SZ, 2340 bkpinfo->tmpdir, curr_set_no);2171 bkpinfo->tmpdir, curr_set_no); 2341 2172 asprintf(&curr_acl_list_fname, ACL_LIST_FNAME_RAW_SZ, 2342 bkpinfo->tmpdir, curr_set_no);2173 bkpinfo->tmpdir, curr_set_no); 2343 2174 get_fattr_list(curr_filelist_fname, curr_xattr_list_fname); 2344 2175 get_acl_list(curr_filelist_fname, curr_acl_list_fname); … … 2346 2177 log_msg(1, "Archiving set %ld", curr_set_no); 2347 2178 res = archive_this_fileset(bkpinfo, curr_filelist_fname, 2348 curr_afioball_fname, curr_set_no);2179 curr_afioball_fname, curr_set_no); 2349 2180 retval += res; 2350 2181 if (res) { 2351 2182 asprintf(&tmp, 2352 "Errors occurred while archiving set %ld. Perhaps your live filesystem changed?",2353 curr_set_no);2183 "Errors occurred while archiving set %ld. Perhaps your live filesystem changed?", 2184 curr_set_no); 2354 2185 log_to_screen(tmp); 2355 2186 paranoid_free(tmp); 2356 2187 } 2357 2188 2358 asprintf(&media_usage_comment, "%s", percent_media_full_comment(bkpinfo)); 2189 asprintf(&media_usage_comment, "%s", 2190 percent_media_full_comment(bkpinfo)); 2359 2191 2360 2192 /* copy to CD (scratchdir) ... and an actual CD-R if necessary */ … … 2366 2198 iamhere("Writing EXAT files"); 2367 2199 res += write_EXAT_files_to_tape(bkpinfo, curr_xattr_list_fname, 2368 2200 curr_acl_list_fname); 2369 2201 // archives themselves 2370 2202 res = move_files_to_stream(bkpinfo, curr_afioball_fname, NULL); 2371 2203 } else { 2372 2204 res = move_files_to_cd(bkpinfo, curr_filelist_fname, 2373 curr_xattr_list_fname,2374 curr_acl_list_fname, curr_afioball_fname,2375 NULL);2205 curr_xattr_list_fname, 2206 curr_acl_list_fname, 2207 curr_afioball_fname, NULL); 2376 2208 } 2377 2209 retval += res; … … 2382 2214 if (res) { 2383 2215 asprintf(&tmp, "Failed to add archive %ld's files to CD dir\n", 2384 curr_set_no);2216 curr_set_no); 2385 2217 log_to_screen(tmp); 2386 2218 paranoid_free(tmp); … … 2398 2230 close_progress_form(); 2399 2231 if (retval) { 2400 log_to_screen("Your regular files have been archived (with errors)."); 2232 log_to_screen 2233 ("Your regular files have been archived (with errors)."); 2401 2234 } else { 2402 log_to_screen("Your regular files have been archived successfully."); 2403 } 2404 return(retval); 2235 log_to_screen 2236 ("Your regular files have been archived successfully."); 2237 } 2238 return (retval); 2405 2239 } 2406 2240 … … 2480 2314 mvaddstr_and_log_it(g_currentY, 0, 2481 2315 "Archiving large files to media "); 2482 asprintf(&biggielist, "%s/archives/biggielist.txt", bkpinfo->scratchdir); 2316 asprintf(&biggielist, "%s/archives/biggielist.txt", 2317 bkpinfo->scratchdir); 2483 2318 asprintf(&xattr_fname, XATTR_BIGGLST_FNAME_RAW_SZ, bkpinfo->tmpdir); 2484 2319 asprintf(&acl_fname, ACL_BIGGLST_FNAME_RAW_SZ, bkpinfo->tmpdir); 2485 2320 2486 2321 asprintf(&command, "cp %s/biggielist.txt %s", bkpinfo->tmpdir, 2487 biggielist);2322 biggielist); 2488 2323 paranoid_system(command); 2489 2324 paranoid_free(command); 2325 2490 2326 asprintf(&blah, "biggielist = %s", biggielist); 2491 2327 log_msg(2, blah); … … 2499 2335 get_acl_list(biggielist, acl_fname); 2500 2336 asprintf(&command, "cp %s %s/archives/", xattr_fname, 2501 bkpinfo->scratchdir);2337 bkpinfo->scratchdir); 2502 2338 paranoid_system(command); 2503 2339 paranoid_free(command); 2504 asprintf(&command, "cp %s %s/archives/", acl_fname, bkpinfo->scratchdir); 2340 2341 asprintf(&command, "cp %s %s/archives/", acl_fname, 2342 bkpinfo->scratchdir); 2505 2343 paranoid_system(command); 2506 2344 paranoid_free(command); … … 2514 2352 paranoid_free(xattr_fname); 2515 2353 paranoid_free(acl_fname); 2354 2516 2355 res = make_slices_and_images(bkpinfo, biggielist); 2517 2356 paranoid_free(biggielist); 2357 2518 2358 if (IS_THIS_A_STREAMING_BACKUP(bkpinfo->backup_media_type)) { 2519 2359 write_header_block_to_stream(0, "end-of-biggiefiles", … … 2529 2369 return (retval); 2530 2370 } 2531 2532 2371 2533 2372 … … 2577 2416 2578 2417 assert(bkpinfo != NULL); 2579 tmp = malloc(1200);2580 2418 would_occupy = space_occupied_by_cd(bkpinfo->scratchdir); 2581 2419 va_start(ap, files_to_add); // initialize the variable arguments … … 2602 2440 if (would_occupy / 1024 > bkpinfo->media_size[g_current_media_number]) { 2603 2441 /* FALSE because this is not the last CD we'll write */ 2604 res = write_iso_and_go_on(bkpinfo, FALSE); 2442 res = write_iso_and_go_on(bkpinfo, FALSE); 2605 2443 retval += res; 2606 2444 if (res) { … … 2617 2455 2618 2456 asprintf(&tmp, "mv -f %s %s/archives/", curr_file, 2619 bkpinfo->scratchdir);2457 bkpinfo->scratchdir); 2620 2458 res = run_program_and_log_output(tmp, 5); 2621 2459 retval += res; … … 2639 2477 2640 2478 /* @} - end of LLarchiveGroup */ 2641 2642 2643 2644 2645 2646 2647 2479 2648 2480 … … 2716 2548 res += write_image_to_floppy(bootdisk_dev, tmp); 2717 2549 paranoid_free(tmp); 2550 2718 2551 if (ask_me_OK_or_cancel("About to write 1.44MB mfsroot disk")) { 2719 2552 log_to_screen("Writing mfsroot floppy"); … … 2751 2584 format_disk(datadisk_dev); 2752 2585 } 2753 /*2754 asprintf(&tmp, "cat %s > %s", bootdisk_file, datadisk_dev);2755 res += run_external_binary_with_percentage_indicator_NEW("Writing boot floppy", tmp);2756 */2757 2586 res += write_image_to_floppy(datadisk_dev, bootdisk_file); 2758 2587 if (ask_me_OK_or_cancel("About to write root disk")) { … … 2806 2635 2807 2636 2808 2809 2810 2637 /** 2811 2638 * Wrapper around @c offer_to_write_floppies(). … … 2839 2666 if (does_file_exist("/root/images/mindi/mondorescue.iso")) { 2840 2667 popup_and_OK 2841 ("Boot+data floppy creation failed. However, FYI, you may burn /root/images/mindi/mondorescue.iso to a CDand boot from that instead if you wish.");2668 ("Boot+data floppy creation failed.\nHowever, you may burn /root/images/mindi/mondorescue.iso to a CD\nand boot from that instead if you wish."); 2842 2669 res++; 2843 2670 } … … 2853 2680 return (res); 2854 2681 } 2855 2856 2857 2682 2858 2683 … … 2943 2768 2944 2769 /* @} - end of LLarchiveGroup */ 2945 2946 2770 2947 2771 … … 3000 2824 3001 2825 3002 3003 2826 /** 3004 2827 * Asks the user to put a CD-R(W) in the drive. … … 3029 2852 3030 2853 asprintf(&szmsg, "I am about to burn %s #%d", 3031 media_descriptor_string(g_backup_media_type),3032 g_current_media_number);2854 media_descriptor_string(g_backup_media_type), 2855 g_current_media_number); 3033 2856 log_to_screen(szmsg); 3034 2857 paranoid_free(szmsg); … … 3038 2861 log_to_screen("Scanning CD-ROM drive..."); 3039 2862 asprintf(&mtpt, "/tmp/cd.mtpt.%ld.%ld", (long int) random(), 3040 (long int) random());2863 (long int) random()); 3041 2864 make_hole_for_dir(mtpt); 3042 2865 … … 3056 2879 cd_number = -1; 3057 2880 asprintf(&tmp, "mount %s %s", cdrom_dev, mtpt); 3058 if ((attempt_to_mount_returned_this = run_program_and_log_output(tmp, 1))) { 2881 if ((attempt_to_mount_returned_this = 2882 run_program_and_log_output(tmp, 1))) { 3059 2883 log_msg(4, "Failed to mount %s at %s", cdrom_dev, mtpt); 3060 2884 log_to_screen("If there's a CD/DVD in the drive, it's blank."); … … 3071 2895 } 3072 2896 */ 3073 } else if (!does_file_exist(szcdno) || !does_file_exist(szserfname)) { 3074 log_to_screen("%s has data on it but it's probably not a Mondo CD.", 2897 } else if (!does_file_exist(szcdno) 2898 || !does_file_exist(szserfname)) { 2899 log_to_screen 2900 ("%s has data on it but it's probably not a Mondo CD.", 3075 2901 media_descriptor_string(g_backup_media_type)); 3076 2902 asprintf(&our_serial_str, "%s", ""); … … 3081 2907 asprintf(&tmp1, "cat %s 2> /dev/null", szserfname); 3082 2908 asprintf(&our_serial_str, "%s", 3083 2909 call_program_and_get_last_line_of_output(tmp1)); 3084 2910 paranoid_free(tmp1); 3085 2911 // FIXME - should be able to use last_line_of_file(), surely? … … 3135 2961 eject_device(cdrom_dev); 3136 2962 asprintf(&tmp, 3137 "I am about to burn %s #%d of the backup set. Please insert %s and press Enter.",3138 media_descriptor_string(g_backup_media_type),3139 g_current_media_number,3140 media_descriptor_string(g_backup_media_type));2963 "I am about to burn %s #%d of the backup set. Please insert %s and press Enter.", 2964 media_descriptor_string(g_backup_media_type), 2965 g_current_media_number, 2966 media_descriptor_string(g_backup_media_type)); 3141 2967 popup_and_OK(tmp); 3142 2968 paranoid_free(tmp); … … 3165 2991 3166 2992 3167 3168 2993 /** 3169 2994 * Set the <tt>N</tt>th bit of @c array to @c true_or_false. … … 3193 3018 3194 3019 /* @} - end of utilityGroup */ 3195 3196 3020 3197 3021 … … 3251 3075 int retval = 0; 3252 3076 int res = 0; 3077 int n = 0; 3253 3078 3254 3079 /*@ structures ************************************************** */ … … 3258 3083 assert(bkpinfo != NULL); 3259 3084 assert_string_is_neither_NULL_nor_zerolength(biggie_filename); 3260 3261 malloc_string(checksum_line);3262 3085 3263 3086 biggiestruct.for_backward_compatibility = '\n'; … … 3279 3102 if (partimagehack_fifo) { 3280 3103 file_to_openin = partimagehack_fifo; 3281 strcpy(checksum_line, "IGNORE");3104 asprintf(&checksum_line, "IGNORE"); 3282 3105 log_msg(2, 3283 3106 "Not calculating checksum for %s: it would take too long", … … 3292 3115 } 3293 3116 paranoid_free(command); 3294 (void) fgets(checksum_line, MAX_STR_LEN, fin);3117 (void) getline(&checksum_line, (size_t) & n, fin); 3295 3118 pclose(fin); 3296 3119 } … … 3307 3130 paranoid_free(checksum_line); 3308 3131 3309 asprintf(&tmp, "%s", slice_fname(biggie_file_number, 0, bkpinfo->tmpdir, "")); 3132 asprintf(&tmp, "%s", 3133 slice_fname(biggie_file_number, 0, bkpinfo->tmpdir, "")); 3310 3134 fout = fopen(tmp, "w"); 3311 3135 paranoid_free(tmp); … … 3319 3143 log_OS_error("Unable to openin biggie_filename"); 3320 3144 asprintf(&tmp, "Cannot archive bigfile '%s': not found", 3321 biggie_filename);3145 biggie_filename); 3322 3146 log_to_screen(tmp); 3323 3147 paranoid_free(tmp); … … 3328 3152 if (IS_THIS_A_STREAMING_BACKUP(bkpinfo->backup_media_type)) { 3329 3153 res = move_files_to_stream(bkpinfo, 3330 slice_fname(biggie_file_number, 0,3331 bkpinfo->tmpdir, ""), NULL);3154 slice_fname(biggie_file_number, 0, 3155 bkpinfo->tmpdir, ""), NULL); 3332 3156 } else { 3333 3157 res = move_files_to_cd(bkpinfo, 3334 slice_fname(biggie_file_number, 0, bkpinfo->tmpdir, ""),3335 NULL);3158 slice_fname(biggie_file_number, 0, 3159 bkpinfo->tmpdir, ""), NULL); 3336 3160 } 3337 3161 i = bkpinfo->optimal_set_size / 256; 3338 3162 for (slice_num = 1; !finished; slice_num++) { 3339 3163 asprintf(&curr_slice_fname_uncompressed, "%s", 3340 slice_fname(biggie_file_number, slice_num, bkpinfo->tmpdir, "")); 3164 slice_fname(biggie_file_number, slice_num, 3165 bkpinfo->tmpdir, "")); 3341 3166 asprintf(&curr_slice_fname_compressed, "%s", 3342 slice_fname(biggie_file_number, slice_num, bkpinfo->tmpdir, suffix)); 3167 slice_fname(biggie_file_number, slice_num, 3168 bkpinfo->tmpdir, suffix)); 3343 3169 3344 3170 asprintf(&tmp, "%s", percent_media_full_comment(bkpinfo)); … … 3382 3208 if (should_I_compress_slices && bkpinfo->compression_level > 0) { 3383 3209 asprintf(&command, "%s -%d %s", bkpinfo->zip_exe, 3384 bkpinfo->compression_level,3385 curr_slice_fname_uncompressed);3210 bkpinfo->compression_level, 3211 curr_slice_fname_uncompressed); 3386 3212 log_msg(2, command); 3387 3213 if ((res = system(command))) { … … 3391 3217 } else { 3392 3218 /* BERLIOS: Useless 3393 asprintf(&command, "mv %s %s 2>> %s",3394 3395 3396 */3219 asprintf(&command, "mv %s %s 2>> %s", 3220 curr_slice_fname_uncompressed, 3221 curr_slice_fname_compressed, MONDO_LOGFILE); 3222 */ 3397 3223 res = 0; // don't do it :) 3398 3224 // did_I_compress_slice = FALSE; … … 3411 3237 } else { 3412 3238 asprintf(&tmp, 3413 "%s - Bigfile #%ld, slice #%ld compressed OK ",3414 biggie_filename, biggie_file_number + 1,3415 slice_num);3239 "%s - Bigfile #%ld, slice #%ld compressed OK ", 3240 biggie_filename, biggie_file_number + 1, 3241 slice_num); 3416 3242 } 3417 3243 #ifndef _XWIN … … 3431 3257 3432 3258 finished = TRUE; 3433 asprintf(&file_to_archive, "%s", curr_slice_fname_uncompressed); 3259 asprintf(&file_to_archive, "%s", 3260 curr_slice_fname_uncompressed); 3434 3261 if (IS_THIS_A_STREAMING_BACKUP(bkpinfo->backup_media_type)) { 3435 3262 break; … … 3450 3277 if (res) { 3451 3278 asprintf(&tmp, 3452 "Failed to add slice %ld of bigfile %ld to scratchdir",3453 slice_num, biggie_file_number + 1);3279 "Failed to add slice %ld of bigfile %ld to scratchdir", 3280 slice_num, biggie_file_number + 1); 3454 3281 log_to_screen(tmp); 3455 3282 paranoid_free(tmp); … … 3463 3290 paranoid_fclose(fin); 3464 3291 if (retval) { 3465 asprintf(&tmp, "Sliced bigfile #%ld...FAILED", biggie_file_number + 1); 3292 asprintf(&tmp, "Sliced bigfile #%ld...FAILED", 3293 biggie_file_number + 1); 3466 3294 } else { 3467 asprintf(&tmp, "Sliced bigfile #%ld...OK!", biggie_file_number + 1); 3295 asprintf(&tmp, "Sliced bigfile #%ld...OK!", 3296 biggie_file_number + 1); 3468 3297 } 3469 3298 log_msg(1, tmp); … … 3498 3327 paranoid_free(tmp); 3499 3328 3500 asprintf(&tmp, "find %s -name '*list.[0-9]*' -exec rm -f '{}' \\;", dir); 3329 asprintf(&tmp, "find %s -name '*list.[0-9]*' -exec rm -f '{}' \\;", 3330 dir); 3501 3331 run_program_and_log_output(tmp, FALSE); 3502 3332 paranoid_free(tmp); … … 3552 3382 log_msg(2, tmp); 3553 3383 /* BERLIOS: that function seems strange to me 3554 center_string(tmp, 80);3555 */3384 center_string(tmp, 80); 3385 */ 3556 3386 #ifndef _XWIN 3557 3387 if (!g_text_mode) { … … 3624 3454 /* label the ISO with its number */ 3625 3455 3626 asprintf(&cdno_fname, "%s/archives/THIS-CD-NUMBER", bkpinfo->scratchdir); 3456 asprintf(&cdno_fname, "%s/archives/THIS-CD-NUMBER", 3457 bkpinfo->scratchdir); 3627 3458 fout = fopen(cdno_fname, "w"); 3628 3459 fprintf(fout, "%d", g_current_media_number); … … 3631 3462 3632 3463 asprintf(&tmp, "cp -f %s/autorun %s/", g_mondo_home, 3633 bkpinfo->scratchdir);3464 bkpinfo->scratchdir); 3634 3465 if (run_program_and_log_output(tmp, FALSE)) { 3635 3466 log_msg(2, "Warning - unable to copy autorun to scratchdir"); … … 3638 3469 3639 3470 /* last CD or not? Label accordingly */ 3640 asprintf(&lastcd_fname, "%s/archives/NOT-THE-LAST", bkpinfo->scratchdir); 3471 asprintf(&lastcd_fname, "%s/archives/NOT-THE-LAST", 3472 bkpinfo->scratchdir); 3641 3473 if (last_cd) { 3642 3474 unlink(lastcd_fname); … … 3654 3486 bkpinfo->media_size[g_current_media_number]) { 3655 3487 asprintf(&tmp, 3656 "Warning! CD is too big. It occupies %ld KB, which is more than the %ld KB allowed.",3657 (long) space_occupied_by_cd(bkpinfo->scratchdir),3658 (long) bkpinfo->media_size[g_current_media_number]);3488 "Warning! CD is too big. It occupies %ld KB, which is more than the %ld KB allowed.", 3489 (long) space_occupied_by_cd(bkpinfo->scratchdir), 3490 (long) bkpinfo->media_size[g_current_media_number]); 3659 3491 log_to_screen(tmp); 3660 3492 paranoid_free(tmp); 3661 3493 } 3662 3494 asprintf(&isofile, "%s/%s/%s-%d.iso", bkpinfo->isodir, 3663 bkpinfo->nfs_remote_dir, bkpinfo->prefix,3664 g_current_media_number);3495 bkpinfo->nfs_remote_dir, bkpinfo->prefix, 3496 g_current_media_number); 3665 3497 for (that_one_was_ok = FALSE; !that_one_was_ok;) { 3666 3498 res = make_iso_fs(bkpinfo, isofile); … … 3689 3521 } else { 3690 3522 asprintf(&tmp, "Failed to burn %s #%d. Retry?", 3691 media_descriptor_string(bkpinfo->backup_media_type),3692 g_current_media_number);3523 media_descriptor_string(bkpinfo->backup_media_type), 3524 g_current_media_number); 3693 3525 res = ask_me_yes_or_no(tmp); 3694 3526 paranoid_free(tmp); … … 3721 3553 wipe_archives(bkpinfo->scratchdir); 3722 3554 asprintf(&tmp, "rm -Rf %s/images/*gz %s/images/*data*img", 3723 bkpinfo->scratchdir, bkpinfo->scratchdir);3555 bkpinfo->scratchdir, bkpinfo->scratchdir); 3724 3556 if (system(tmp)) { 3725 3557 log_msg(2, 3726 3558 "Error occurred when I tried to delete the redundant IMGs and GZs"); 3727 3559 } 3728 3560 paranoid_free(tmp); … … 3795 3627 if (res) { 3796 3628 asprintf(&tmp, 3797 "Warnings/errors were reported while checking %s #%d", 3798 media_descriptor_string(bkpinfo->backup_media_type), 3799 g_current_media_number); 3629 "Warnings/errors were reported while checking %s #%d", 3630 media_descriptor_string(bkpinfo-> 3631 backup_media_type), 3632 g_current_media_number); 3800 3633 log_to_screen(tmp); 3801 3634 paranoid_free(tmp); … … 3810 3643 */ 3811 3644 asprintf(&tmp, 3812 "cat %s | grep \"afio: \" | sed 's/afio: //' | grep -vx \"/dev/.*\" >> /tmp/changed.files",3813 MONDO_LOGFILE);3645 "cat %s | grep \"afio: \" | sed 's/afio: //' | grep -vx \"/dev/.*\" >> /tmp/changed.files", 3646 MONDO_LOGFILE); 3814 3647 system(tmp); 3815 3648 paranoid_free(tmp); 3816 3649 3817 3650 asprintf(&tmp, 3818 "cat %s | grep \"star: \" | sed 's/star: //' | grep -vx \"/dev/.*\" >> /tmp/changed.files",3819 MONDO_LOGFILE);3651 "cat %s | grep \"star: \" | sed 's/star: //' | grep -vx \"/dev/.*\" >> /tmp/changed.files", 3652 MONDO_LOGFILE); 3820 3653 system(tmp); 3821 3654 paranoid_free(tmp); … … 3925 3758 3926 3759 3927 3928 3760 /** 3929 3761 * Wrapper around @c write_image_to_floppy_SUB().
Note:
See TracChangeset
for help on using the changeset viewer.