Ignore:
Timestamp:
Aug 21, 2009, 1:47:12 AM (15 years ago)
Author:
Bruno Cornec
Message:
  • Adds LZMA support (Fix #309)
  • Change
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/2.2.10/mondo/src/common/libmondo-archive.c

    r2334 r2338  
    509509    char *use_lzo_sz = NULL;
    510510    char *use_gzip_sz = NULL;
     511    char *use_lzma_sz = NULL;
    511512    char *use_comp_sz = NULL;
    512513    char *use_star_sz = NULL;
     
    544545    }
    545546
    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");
    548548    mr_asprintf(tmp, "%s/filelist.full", bkpinfo->tmpdir);
    549549    if (!does_file_exist(tmp)) {
     
    594594    } else {
    595595        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");
    596601    }
    597602    if (bkpinfo->use_star) {
     
    83584011=\"%s\" 12=%s 13=%ld 14=\"%s\" 15=\"%s\" 16=\"%s\" 17=\"%s\" 18=%ld 19=%d",*/
    836841    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
    838845            bkpinfo->scratchdir,    // parameter #3
    839846            bkpinfo->kernel_path,   // parameter #4
     
    843850            use_lzo_sz,         // parameter #8
    844851            cd_recovery_sz,     // parameter #9
    845             bkpinfo->image_devs,    // parameter #10
     852            (bkpinfo->image_devs == NULL) ? "\"\"" : bkpinfo->image_devs,   // parameter #10
    846853            broken_bios_sz,     // parameter #11
    847854            last_filelist_number,   // parameter #12 (STRING)
     
    853860            bkpinfo->internal_tape_block_size,  // parameter #18 (LONG)
    854861            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);
    856865
    857866    mr_free(tmp2);
     
    861870    mr_free(use_lzo_sz);
    862871    mr_free(use_gzip_sz);
     872    mr_free(use_lzma_sz);
    863873    mr_free(use_star_sz);
    864874    mr_free(use_comp_sz);
     
    868878    mr_free(tape_size_sz);
    869879
     880    /* This parameter is always the last one and optional */
    870881    if (bkpinfo->nonbootable_backup) {
    871882        mr_strcat(command, " NONBOOTABLE");
     
    875886//  popup_and_OK("Pausing");
    876887
    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);
    878889    paranoid_free(command);
    879890
     
    16671678    if (bkpinfo->call_before_iso) {
    16681679        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);
    16701681        if (res) {
    16711682            mr_strcat(message_to_screen, "...failed");
     
    16911702        } else {
    16921703            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);
    16941705            if (res) {
    16951706                log_to_screen("%s...failed to write", message_to_screen);
     
    17291740                res = run_external_binary_with_percentage_indicator_NEW("Blanking DVD disk", sz_blank_disk);
    17301741                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);
    17381745                    if (res) {
    17391746                        log_to_screen("Format failed a second time.");
     
    17511758                }
    17521759                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);
    17541761                retval += res;
    17551762                if (!bkpinfo->please_dont_eject) {
     
    17801787            log_msg(1, "Making nonbootable backup");
    17811788// 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);
    17861790        } else {
    17871791            log_msg(1, "Making bootable backup");
     
    18001804#ifdef __IA64__
    18011805                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);
    18091807#else
    18101808// FIXME --- change mkisofs string to MONDO_MKISOFS_REGULAR_SYSLINUX/LILO depending on bkpinfo->make_cd_usE_lilo
     
    18121810                log_msg(1, "Non-ia64 --> lilo");
    18131811                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);
    18181813#endif
    18191814            } else {
    18201815                log_msg(1, "make_cd_use_lilo = FALSE");
    18211816                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);
    18271818            }
    18281819        }
     
    18551846        mr_free(mds);
    18561847        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);
    18581849        if (res) {
    18591850            mr_strcat(message_to_screen, "...failed");
     
    18711862        mr_asprintf(message_to_screen, "Running post-ISO call (%s #%d)", mds, g_current_media_number);
    18721863        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);
    18741865        if (res) {
    18751866            mr_strcat(message_to_screen, "...failed");
     
    20132004                && is_dev_an_NTFS_dev(bigfile_fname)) {
    20142005                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);
    20182007                mr_asprintf(sz_devfile, "%s/%d.%d.000", bkpinfo->tmpdir, (int) (random() % 32768), (int) (random() % 32768));
    20192008                mkfifo(sz_devfile, 0x770);
     
    20242013                    fatal_error("Fork failure");
    20252014                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);
    20292016                    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);
    20322019                    mr_free(sz_devfile);
    2033                     */
    20342020                    exit(res);
    20352021                    break;
    20362022                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));
    20402024                    mr_free(sz_devfile);
    20412025                }
     
    20532037                                             BLK_START_A_NORMBIGGIE);
    20542038            }
    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);
    20592040            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);
    20642042            }
    20652043            retval += res;
     
    28202798 */
    28212799int
    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 {
     2800slice_up_file_etc(char *biggie_filename, char *ntfsprog_fifo, long biggie_file_number, long noof_biggie_files, bool use_ntfsprog) {
    28262801
    28272802    /*@ buffers ************************************************** */
    28282803    char *tmp = NULL;
    28292804    char *checksum_line = NULL;
    2830     char *command;
     2805    char *command = NULL;
    28312806    char *tempblock;
    28322807    char *curr_slice_fname_uncompressed = NULL;
    28332808    char *curr_slice_fname_compressed = NULL;
    28342809    char *file_to_archive = NULL;
    2835     char *file_to_openin;
     2810    char *file_to_openin = NULL;
    28362811    /*@ pointers ************************************************** */
    2837     char *pB;
    2838     FILE *fin = NULL, *fout = NULL;
     2812    char *pB = NULL;
     2813    FILE *fin = NULL;
     2814    FILE *fout = NULL;
    28392815
    28402816    /*@ bool ****************************************************** */
     
    28422818
    28432819    /*@ 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;
    28492824    char *suffix = NULL;                // for compressed slices
    28502825
     
    28522827    off_t totalread = (off_t)0;
    28532828    off_t totallength = (off_t)0;
    2854     off_t length;
    28552829
    28562830    /*@ int ******************************************************** */
     
    28602834    /*@ structures ************************************************** */
    28612835    struct s_filename_and_lstat_info biggiestruct;
    2862 //  struct stat statbuf;
    28632836
    28642837    assert(bkpinfo != NULL);
     
    28672840    biggiestruct.for_backward_compatibility = '\n';
    28682841    biggiestruct.use_ntfsprog = use_ntfsprog;
    2869     optimal_set_size = bkpinfo->optimal_set_size;
    28702842    if (is_this_file_compressed(biggie_filename) || bkpinfo->compression_level == 0) {
    28712843        mr_asprintf(suffix, "%s", "");
     
    28762848    }
    28772849
    2878     if (optimal_set_size < 999) {
     2850    if (bkpinfo->optimal_set_size < 999L) {
    28792851        fatal_error("bkpinfo->optimal_set_size is insanely small");
    28802852    }
     2853
    28812854    if (ntfsprog_fifo) {
    28822855        file_to_openin = ntfsprog_fifo;
     
    28962869        log_it("res of it = %s", tmp);
    28972870        totallength = (off_t)atoll(tmp);
    2898         paranoid_free(tmp);
     2871        mr_free(tmp);
    28992872    } else {
    29002873        file_to_openin = biggie_filename;
     
    29302903    if (fout == NULL) {
    29312904        log_msg(1, "Unable to open and write to %s\n", tmp);
    2932         paranoid_free(tmp);
     2905        mr_free(tmp);
    29332906        mr_free(suffix);
    29342907        return (1);
    29352908    }
    2936     paranoid_free(tmp);
     2909    mr_free(tmp);
    29372910
    29382911    (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);
    29452915    if (!(fin = fopen(file_to_openin, "r"))) {
    29462916        log_OS_error("Unable to openin biggie_filename");
     
    29602930    }
    29612931    i = bkpinfo->optimal_set_size / 256;
    2962     if (!(tempblock = (char *) malloc(256 * 1024))) {
    2963         fatal_error("malloc error 256*1024");
    2964     }
    29652932    for (slice_num = 1; !finished; slice_num++) {
    29662933        mr_asprintf(curr_slice_fname_uncompressed, "%s", slice_fname(biggie_file_number, slice_num, bkpinfo->tmpdir, ""));
     
    29772944            return (1);
    29782945        }
    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++) {
    29822949                blksize = fread(tempblock, 1, 256 * 1024, fin);
    29832950                if (blksize > 0) {
     
    29882955                }
    29892956            }
     2957            mr_free(tempblock);
    29902958        } 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)
    29952963        {
    29962964            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);
    30002966            }
    30012967            if (should_I_compress_slices && bkpinfo->compression_level > 0) {
     
    30172983                log_msg(2, "Failed to compress the slice");
    30182984            }
    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)) {
    30222986                unlink(curr_slice_fname_uncompressed);
    30232987            }
     
    30373001            log_msg(2, tmp);
    30383002#endif
    3039             paranoid_free(tmp);
     3003            mr_free(tmp);
    30403004
    30413005            mr_asprintf(file_to_archive, "%s", curr_slice_fname_compressed);
     
    30533017
    30543018        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);
    30573020            maintain_collection_of_recent_archives(file_to_archive);
    30583021            res = move_files_to_stream(file_to_archive, NULL);
     
    30683031        }
    30693032    }
    3070     mr_free(tempblock);
    30713033    mr_free(suffix);
    30723034    paranoid_fclose(fin);
Note: See TracChangeset for help on using the changeset viewer.