Changeset 2338 in MondoRescue for branches/2.2.10/mondo/src/common/libmondo-archive.c
- Timestamp:
- Aug 21, 2009, 1:47:12 AM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2.2.10/mondo/src/common/libmondo-archive.c
r2334 r2338 509 509 char *use_lzo_sz = NULL; 510 510 char *use_gzip_sz = NULL; 511 char *use_lzma_sz = NULL; 511 512 char *use_comp_sz = NULL; 512 513 char *use_star_sz = NULL; … … 544 545 } 545 546 546 mvaddstr_and_log_it(g_currentY, 0, 547 "Calling MINDI to create boot+data disks"); 547 mvaddstr_and_log_it(g_currentY, 0, "Calling MINDI to create boot+data disks"); 548 548 mr_asprintf(tmp, "%s/filelist.full", bkpinfo->tmpdir); 549 549 if (!does_file_exist(tmp)) { … … 594 594 } else { 595 595 mr_asprintf(use_gzip_sz, "no"); 596 } 597 if (bkpinfo->use_lzma) { 598 mr_asprintf(use_lzma_sz, "yes"); 599 } else { 600 mr_asprintf(use_lzma_sz, "no"); 596 601 } 597 602 if (bkpinfo->use_star) { … … 835 840 11=\"%s\" 12=%s 13=%ld 14=\"%s\" 15=\"%s\" 16=\"%s\" 17=\"%s\" 18=%ld 19=%d",*/ 836 841 mr_asprintf(command, "mindi %s --custom %s %s/images '%s' '%s' '%s' %ld '%s' '%s' '%s' \ 837 '%s' %s %ld '%s' '%s' '%s' '%s' %ld %d '%s'", tmp2, bkpinfo->tmpdir, // parameter #2 842 '%s' %s %ld '%s' '%s' '%s' '%s' %ld %d '%s' >> %s", 843 tmp2, // parameter #1 844 bkpinfo->tmpdir, // parameter #2 838 845 bkpinfo->scratchdir, // parameter #3 839 846 bkpinfo->kernel_path, // parameter #4 … … 843 850 use_lzo_sz, // parameter #8 844 851 cd_recovery_sz, // parameter #9 845 bkpinfo->image_devs, // parameter #10852 (bkpinfo->image_devs == NULL) ? "\"\"" : bkpinfo->image_devs, // parameter #10 846 853 broken_bios_sz, // parameter #11 847 854 last_filelist_number, // parameter #12 (STRING) … … 853 860 bkpinfo->internal_tape_block_size, // parameter #18 (LONG) 854 861 bkpinfo->differential, // parameter #19 (INT) 855 use_gzip_sz); // parameter #20 (STRING) 862 use_gzip_sz, // parameter #20 (STRING) 863 use_lzma_sz, // parameter #21 (STRING) 864 MONDO_LOGFILE); 856 865 857 866 mr_free(tmp2); … … 861 870 mr_free(use_lzo_sz); 862 871 mr_free(use_gzip_sz); 872 mr_free(use_lzma_sz); 863 873 mr_free(use_star_sz); 864 874 mr_free(use_comp_sz); … … 868 878 mr_free(tape_size_sz); 869 879 880 /* This parameter is always the last one and optional */ 870 881 if (bkpinfo->nonbootable_backup) { 871 882 mr_strcat(command, " NONBOOTABLE"); … … 875 886 // popup_and_OK("Pausing"); 876 887 877 res = run_ program_and_log_to_screen(command, "Generating boot+data disks");888 res = run_external_binary_with_percentage_indicator_NEW("Generating boot+data disks", command); 878 889 paranoid_free(command); 879 890 … … 1667 1678 if (bkpinfo->call_before_iso) { 1668 1679 mr_asprintf(message_to_screen, "Running pre-ISO call for CD#%d", g_current_media_number); 1669 res = eval_call_to_make_ISO(bkpinfo->call_before_iso, destfile, g_current_media_number, MONDO_LOGFILE,message_to_screen);1680 res = eval_call_to_make_ISO(bkpinfo->call_before_iso, destfile, g_current_media_number, message_to_screen); 1670 1681 if (res) { 1671 1682 mr_strcat(message_to_screen, "...failed"); … … 1691 1702 } else { 1692 1703 res = 1693 eval_call_to_make_ISO(bkpinfo->call_make_iso, bkpinfo->scratchdir, g_current_media_number, MONDO_LOGFILE,message_to_screen);1704 eval_call_to_make_ISO(bkpinfo->call_make_iso, bkpinfo->scratchdir, g_current_media_number, message_to_screen); 1694 1705 if (res) { 1695 1706 log_to_screen("%s...failed to write", message_to_screen); … … 1729 1740 res = run_external_binary_with_percentage_indicator_NEW("Blanking DVD disk", sz_blank_disk); 1730 1741 if (res) { 1731 log_to_screen 1732 ("Warning - format failed. (Was it a DVD-R?) Sleeping for 5 seconds to take a breath..."); 1733 pause_for_N_seconds(5, 1734 "Letting DVD drive settle... and trying again."); 1735 res = 1736 run_external_binary_with_percentage_indicator_NEW 1737 ("Blanking DVD disk", sz_blank_disk); 1742 log_to_screen("Warning - format failed. (Was it a DVD-R?) Sleeping for 5 seconds to take a breath..."); 1743 pause_for_N_seconds(5, "Letting DVD drive settle... and trying again."); 1744 res = run_external_binary_with_percentage_indicator_NEW("Blanking DVD disk", sz_blank_disk); 1738 1745 if (res) { 1739 1746 log_to_screen("Format failed a second time."); … … 1751 1758 } 1752 1759 pause_for_N_seconds(5, "Letting DVD drive settle"); 1753 res = eval_call_to_make_ISO(bkpinfo->call_make_iso, bkpinfo->scratchdir, g_current_media_number, MONDO_LOGFILE,message_to_screen);1760 res = eval_call_to_make_ISO(bkpinfo->call_make_iso, bkpinfo->scratchdir, g_current_media_number, message_to_screen); 1754 1761 retval += res; 1755 1762 if (!bkpinfo->please_dont_eject) { … … 1780 1787 log_msg(1, "Making nonbootable backup"); 1781 1788 // FIXME --- change mkisofs string to MONDO_MKISOFS_NONBOOTABLE and add ' .' at end 1782 res = 1783 eval_call_to_make_ISO("mkisofs -o '_ISO_' -r -p MondoRescue -publisher www.mondorescue.org -A MondoRescue_GPL -V _CD#_ .", 1784 destfile, g_current_media_number, 1785 MONDO_LOGFILE, message_to_screen); 1789 res = eval_call_to_make_ISO("mkisofs -o '_ISO_' -r -p MondoRescue -publisher www.mondorescue.org -A MondoRescue_GPL -V _CD#_ .", destfile, g_current_media_number, message_to_screen); 1786 1790 } else { 1787 1791 log_msg(1, "Making bootable backup"); … … 1800 1804 #ifdef __IA64__ 1801 1805 log_msg(1, "IA64 --> elilo"); 1802 res = eval_call_to_make_ISO("mkisofs -no-emul-boot -b images/mindi-bootroot." 1803 IA64_BOOT_SIZE 1804 ".img -c boot.cat -o '_ISO_' -J -r -p MondoRescue -publisher www.mondorescue.org -A Mondo_Rescue_GPL -V _CD#_ .", 1805 destfile, 1806 g_current_media_number, 1807 MONDO_LOGFILE, 1808 message_to_screen); 1806 res = eval_call_to_make_ISO("mkisofs -no-emul-boot -b images/mindi-bootroot." IA64_BOOT_SIZE ".img -c boot.cat -o '_ISO_' -J -r -p MondoRescue -publisher www.mondorescue.org -A Mondo_Rescue_GPL -V _CD#_ .", destfile, g_current_media_number, message_to_screen); 1809 1807 #else 1810 1808 // FIXME --- change mkisofs string to MONDO_MKISOFS_REGULAR_SYSLINUX/LILO depending on bkpinfo->make_cd_usE_lilo … … 1812 1810 log_msg(1, "Non-ia64 --> lilo"); 1813 1811 res = 1814 eval_call_to_make_ISO("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#_ .", 1815 destfile, g_current_media_number, 1816 MONDO_LOGFILE, 1817 message_to_screen); 1812 eval_call_to_make_ISO("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#_ .", destfile, g_current_media_number, message_to_screen); 1818 1813 #endif 1819 1814 } else { 1820 1815 log_msg(1, "make_cd_use_lilo = FALSE"); 1821 1816 log_msg(1, "Isolinux"); 1822 res = 1823 eval_call_to_make_ISO("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#_ .", 1824 destfile, g_current_media_number, 1825 MONDO_LOGFILE, 1826 message_to_screen); 1817 res = eval_call_to_make_ISO("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#_ .", destfile, g_current_media_number, message_to_screen); 1827 1818 } 1828 1819 } … … 1855 1846 mr_free(mds); 1856 1847 pause_and_ask_for_cdr(2, &cd_is_mountable); 1857 res = eval_call_to_make_ISO(bkpinfo->call_burn_iso, destfile, g_current_media_number, MONDO_LOGFILE,message_to_screen);1848 res = eval_call_to_make_ISO(bkpinfo->call_burn_iso, destfile, g_current_media_number, message_to_screen); 1858 1849 if (res) { 1859 1850 mr_strcat(message_to_screen, "...failed"); … … 1871 1862 mr_asprintf(message_to_screen, "Running post-ISO call (%s #%d)", mds, g_current_media_number); 1872 1863 mr_free(mds); 1873 res = eval_call_to_make_ISO(bkpinfo->call_after_iso, destfile, g_current_media_number, MONDO_LOGFILE,message_to_screen);1864 res = eval_call_to_make_ISO(bkpinfo->call_after_iso, destfile, g_current_media_number, message_to_screen); 1874 1865 if (res) { 1875 1866 mr_strcat(message_to_screen, "...failed"); … … 2013 2004 && is_dev_an_NTFS_dev(bigfile_fname)) { 2014 2005 use_ntfsprog = TRUE; 2015 log_msg(2, 2016 "Calling ntfsclone in background because %s is an NTFS partition", 2017 bigfile_fname); 2006 log_msg(2, "Calling ntfsclone in background because %s is an NTFS partition", bigfile_fname); 2018 2007 mr_asprintf(sz_devfile, "%s/%d.%d.000", bkpinfo->tmpdir, (int) (random() % 32768), (int) (random() % 32768)); 2019 2008 mkfifo(sz_devfile, 0x770); … … 2024 2013 fatal_error("Fork failure"); 2025 2014 case 0: 2026 log_msg(2, 2027 "CHILD - fip - calling feed_into_ntfsprog(%s, %s)", 2028 bigfile_fname, sz_devfile); 2015 log_msg(2, "CHILD - fip - calling feed_into_ntfsprog(%s, %s)", bigfile_fname, sz_devfile); 2029 2016 res = feed_into_ntfsprog(bigfile_fname, sz_devfile); 2030 /* BCO/BERLIOS Does the child need to unalocate memory as well ?2031 paranoid_free(bigfile_fname);2017 /* The child needs to unalocate memory as well */ 2018 mr_free(bigfile_fname); 2032 2019 mr_free(sz_devfile); 2033 */2034 2020 exit(res); 2035 2021 break; 2036 2022 default: 2037 log_msg(2, 2038 "feed_into_ntfsprog() called in background --- pid=%ld", 2039 (long int) (pid)); 2023 log_msg(2, "feed_into_ntfsprog() called in background --- pid=%ld", (long int) (pid)); 2040 2024 mr_free(sz_devfile); 2041 2025 } … … 2053 2037 BLK_START_A_NORMBIGGIE); 2054 2038 } 2055 res = 2056 slice_up_file_etc(bigfile_fname, 2057 ntfsprog_fifo, biggie_file_number, 2058 noof_biggie_files, use_ntfsprog); 2039 res = slice_up_file_etc(bigfile_fname, ntfsprog_fifo, biggie_file_number, noof_biggie_files, use_ntfsprog); 2059 2040 if (IS_THIS_A_STREAMING_BACKUP(bkpinfo->backup_media_type)) { 2060 write_header_block_to_stream((off_t)0, 2061 calc_checksum_of_file 2062 (bigfile_fname), 2063 BLK_STOP_A_BIGGIE); 2041 write_header_block_to_stream((off_t)0, calc_checksum_of_file(bigfile_fname), BLK_STOP_A_BIGGIE); 2064 2042 } 2065 2043 retval += res; … … 2820 2798 */ 2821 2799 int 2822 slice_up_file_etc(char *biggie_filename, 2823 char *ntfsprog_fifo, long biggie_file_number, 2824 long noof_biggie_files, bool use_ntfsprog) 2825 { 2800 slice_up_file_etc(char *biggie_filename, char *ntfsprog_fifo, long biggie_file_number, long noof_biggie_files, bool use_ntfsprog) { 2826 2801 2827 2802 /*@ buffers ************************************************** */ 2828 2803 char *tmp = NULL; 2829 2804 char *checksum_line = NULL; 2830 char *command ;2805 char *command = NULL; 2831 2806 char *tempblock; 2832 2807 char *curr_slice_fname_uncompressed = NULL; 2833 2808 char *curr_slice_fname_compressed = NULL; 2834 2809 char *file_to_archive = NULL; 2835 char *file_to_openin ;2810 char *file_to_openin = NULL; 2836 2811 /*@ pointers ************************************************** */ 2837 char *pB; 2838 FILE *fin = NULL, *fout = NULL; 2812 char *pB = NULL; 2813 FILE *fin = NULL; 2814 FILE *fout = NULL; 2839 2815 2840 2816 /*@ bool ****************************************************** */ … … 2842 2818 2843 2819 /*@ long ****************************************************** */ 2844 size_t blksize = 0; 2845 long slice_num = 0; 2846 long i; 2847 long optimal_set_size; 2848 bool should_I_compress_slices; 2820 size_t blksize = (size_t)0; 2821 long slice_num = 0L; 2822 long i = 0L; 2823 bool should_I_compress_slices = TRUE; 2849 2824 char *suffix = NULL; // for compressed slices 2850 2825 … … 2852 2827 off_t totalread = (off_t)0; 2853 2828 off_t totallength = (off_t)0; 2854 off_t length;2855 2829 2856 2830 /*@ int ******************************************************** */ … … 2860 2834 /*@ structures ************************************************** */ 2861 2835 struct s_filename_and_lstat_info biggiestruct; 2862 // struct stat statbuf;2863 2836 2864 2837 assert(bkpinfo != NULL); … … 2867 2840 biggiestruct.for_backward_compatibility = '\n'; 2868 2841 biggiestruct.use_ntfsprog = use_ntfsprog; 2869 optimal_set_size = bkpinfo->optimal_set_size;2870 2842 if (is_this_file_compressed(biggie_filename) || bkpinfo->compression_level == 0) { 2871 2843 mr_asprintf(suffix, "%s", ""); … … 2876 2848 } 2877 2849 2878 if ( optimal_set_size < 999) {2850 if (bkpinfo->optimal_set_size < 999L) { 2879 2851 fatal_error("bkpinfo->optimal_set_size is insanely small"); 2880 2852 } 2853 2881 2854 if (ntfsprog_fifo) { 2882 2855 file_to_openin = ntfsprog_fifo; … … 2896 2869 log_it("res of it = %s", tmp); 2897 2870 totallength = (off_t)atoll(tmp); 2898 paranoid_free(tmp);2871 mr_free(tmp); 2899 2872 } else { 2900 2873 file_to_openin = biggie_filename; … … 2930 2903 if (fout == NULL) { 2931 2904 log_msg(1, "Unable to open and write to %s\n", tmp); 2932 paranoid_free(tmp);2905 mr_free(tmp); 2933 2906 mr_free(suffix); 2934 2907 return (1); 2935 2908 } 2936 paranoid_free(tmp);2909 mr_free(tmp); 2937 2910 2938 2911 (void) fwrite((void *) &biggiestruct, 1, sizeof(biggiestruct), fout); 2939 if (fout) { 2940 paranoid_fclose(fout); 2941 } 2942 length = totallength / optimal_set_size / 1024; 2943 log_msg(1, "Opening in %s; slicing it and writing to CD/tape", 2944 file_to_openin); 2912 fclose(fout); 2913 2914 log_msg(1, "Opening in %s; slicing it and writing to CD/tape", file_to_openin); 2945 2915 if (!(fin = fopen(file_to_openin, "r"))) { 2946 2916 log_OS_error("Unable to openin biggie_filename"); … … 2960 2930 } 2961 2931 i = bkpinfo->optimal_set_size / 256; 2962 if (!(tempblock = (char *) malloc(256 * 1024))) {2963 fatal_error("malloc error 256*1024");2964 }2965 2932 for (slice_num = 1; !finished; slice_num++) { 2966 2933 mr_asprintf(curr_slice_fname_uncompressed, "%s", slice_fname(biggie_file_number, slice_num, bkpinfo->tmpdir, "")); … … 2977 2944 return (1); 2978 2945 } 2979 if ((i == bkpinfo->optimal_set_size / 256) 2980 && (totalread < 1.1 * totallength)) {2981 for (i = 0 ; i < bkpinfo->optimal_set_size / 256; i++) {2946 if ((i == bkpinfo->optimal_set_size / 256) && (totalread < 1.1 * totallength)) { 2947 tempblock = mr_malloc(256 * 1024); 2948 for (i = 0L; i < bkpinfo->optimal_set_size / 256; i++) { 2982 2949 blksize = fread(tempblock, 1, 256 * 1024, fin); 2983 2950 if (blksize > 0) { … … 2988 2955 } 2989 2956 } 2957 mr_free(tempblock); 2990 2958 } else { 2991 i = 0 ;2992 } 2993 paranoid_fclose(fout);2994 if (i > 0 ) // length_of_file (curr_slice_fname_uncompressed)2959 i = 0L; 2960 } 2961 fclose(fout); 2962 if (i > 0L) // length_of_file (curr_slice_fname_uncompressed) 2995 2963 { 2996 2964 if (!does_file_exist(curr_slice_fname_uncompressed)) { 2997 log_msg(2, 2998 "Warning - '%s' doesn't exist. How can I compress slice?", 2999 curr_slice_fname_uncompressed); 2965 log_msg(2, "Warning - '%s' doesn't exist. How can I compress slice?", curr_slice_fname_uncompressed); 3000 2966 } 3001 2967 if (should_I_compress_slices && bkpinfo->compression_level > 0) { … … 3017 2983 log_msg(2, "Failed to compress the slice"); 3018 2984 } 3019 if (bkpinfo->use_lzo 3020 && strcmp(curr_slice_fname_compressed, 3021 curr_slice_fname_uncompressed)) { 2985 if (bkpinfo->use_lzo && strcmp(curr_slice_fname_compressed, curr_slice_fname_uncompressed)) { 3022 2986 unlink(curr_slice_fname_uncompressed); 3023 2987 } … … 3037 3001 log_msg(2, tmp); 3038 3002 #endif 3039 paranoid_free(tmp);3003 mr_free(tmp); 3040 3004 3041 3005 mr_asprintf(file_to_archive, "%s", curr_slice_fname_compressed); … … 3053 3017 3054 3018 if (IS_THIS_A_STREAMING_BACKUP(bkpinfo->backup_media_type)) { 3055 register_in_tape_catalog(biggieslice, biggie_file_number, 3056 slice_num, file_to_archive); 3019 register_in_tape_catalog(biggieslice, biggie_file_number, slice_num, file_to_archive); 3057 3020 maintain_collection_of_recent_archives(file_to_archive); 3058 3021 res = move_files_to_stream(file_to_archive, NULL); … … 3068 3031 } 3069 3032 } 3070 mr_free(tempblock);3071 3033 mr_free(suffix); 3072 3034 paranoid_fclose(fin);
Note:
See TracChangeset
for help on using the changeset viewer.