Ignore:
Timestamp:
Sep 25, 2013, 8:55:43 AM (11 years ago)
Author:
Bruno Cornec
Message:
  • Modification to 3.1 branch to make it extremely similar to 3.0. What remains are function rewrite with allocation in the function and desallocation outside of the function. Will be next step
File:
1 edited

Legend:

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

    r3161 r3190  
    503503    /*@ buffer ************************************************************ */
    504504    char *tmp = NULL;
     505    char *tmp1 = NULL;
    505506    char *tmp2 = NULL;
    506507    char *command = NULL;
     
    513514    char *bootldr_ver = NULL;
    514515    char *tape_device = NULL;
     516    char *last_filelist_number = NULL;
    515517    char *broken_bios_sz = NULL;
    516518    char *cd_recovery_sz = NULL;
     
    535537    assert(bkpinfo != NULL);
    536538
     539    mvaddstr_and_log_it(g_currentY, 0, "Calling MINDI to create boot+data disks");
     540    open_evalcall_form("Calling MINDI to create boot+data disks");
    537541    mr_asprintf(tmp, "%s/filelist.full", bkpinfo->tmpdir);
    538542    if (!does_file_exist(tmp)) {
     
    547551    mr_free(tmp);
    548552
     553    mr_asprintf(tmp, "%s/LAST-FILELIST-NUMBER", bkpinfo->tmpdir);
     554    mr_asprintf(last_filelist_number, "%s", last_line_of_file(tmp));
     555    mr_free(tmp);
     556
    549557    if (IS_THIS_A_STREAMING_BACKUP(bkpinfo->backup_media_type)) {
    550         mr_asprintf(tape_size_sz, "%ld", bkpinfo->media_size[1]);
     558        mr_asprintf(tape_size_sz, "%ld", bkpinfo->media_size);
    551559        if (bkpinfo->media_device) {
    552560            ntapedev = get_non_rewind_dev(bkpinfo->media_device);
     
    721729    }
    722730    log_to_screen("Your boot loader is %s and it boots from %s", bootldr_str, bkpinfo->boot_device);
     731
    723732    if (bootldr_ver != NULL) {
    724         mr_asprintf(tmp, "Boot loader version string: %s", bootldr_ver);
    725         log_to_screen(tmp);
    726         mr_free(tmp);
    727     }
    728     if (bootldr_ver != NULL) {
    729         mr_asprintf(tmp, "Boot loader version string: %s", bootldr_ver);
    730         log_to_screen(tmp);
    731         mr_free(tmp);
     733        log_to_screen("Boot loader version string: %s", bootldr_ver);
    732734    }
    733735
     
    776778    }
    777779
     780    mr_asprintf(tmp, "%s/BACKUP-MEDIA-TYPE", bkpinfo->tmpdir);
     781    if (write_one_liner_data_file(tmp, value)) {
     782        res++;
     783        log_msg(1, "%ld: Unable to write one-liner backup-media-type", __LINE__);
     784    }
     785    mr_free(value);
     786    mr_free(tmp);
     787
    778788    mr_asprintf(tmp, "%s/BOOTLOADER.NAME", bkpinfo->tmpdir);
    779789    if (write_one_liner_data_file(tmp, bootldr_str)) {
     
    784794    mr_free(tmp);
    785795
     796    mr_asprintf(tmp, "%s/BOOTLOADER.VER", bkpinfo->tmpdir);
     797    if (write_one_liner_data_file(tmp, bootldr_ver)) {
     798        res++;
     799        log_msg(1, "%ld: Unable to write one-liner bootloader.ver",
     800                __LINE__);
     801    }
     802    mr_free(bootldr_ver);
     803    mr_free(tmp);
     804
     805    mr_asprintf(tmp, "%s/DIFFERENTIAL", bkpinfo->tmpdir);
     806    if (bkpinfo->differential) {
     807        res += write_one_liner_data_file(tmp, "1");
     808    } else {
     809        res += write_one_liner_data_file(tmp, "0");
     810    }
     811    mr_free(tmp);
     812
     813    if (g_getfattr) {
     814        mr_asprintf(tmp1, "%s/XATTR", bkpinfo->tmpdir);
     815        if (write_one_liner_data_file(tmp1, "TRUE")) {
     816            log_msg(1, "%ld: Unable to write one-liner XATTR",
     817                __LINE__);
     818        }
     819        paranoid_free(tmp1);
     820    }
     821    if (g_getfacl) {
     822        mr_asprintf(tmp1, "%s/ACL", bkpinfo->tmpdir);
     823        if (write_one_liner_data_file(tmp1, "TRUE")) {
     824            log_msg(1, "%ld: Unable to write one-liner ACL",
     825                __LINE__);
     826        }
     827        paranoid_free(tmp1);
     828    }
     829    if (bkpinfo->use_obdr) {
     830        mr_asprintf(tmp1, "%s/OBDR", bkpinfo->tmpdir);
     831        if (write_one_liner_data_file(tmp1, "TRUE")) {
     832            log_msg(1, "%ld: Unable to write one-liner OBDR",
     833                __LINE__);
     834        }
     835        paranoid_free(tmp1);
     836    }
     837
    786838    estimated_total_noof_slices = size_of_all_biggiefiles_K(bkpinfo) / bkpinfo->optimal_set_size + 1;
    787839
    788     /* BERLIOS: add netfs stuff here? */
     840    /* TODO: add netfs stuff here? */
    789841    mr_asprintf(command, "mkdir -p %s/images", bkpinfo->scratchdir);
    790842    if (system(command)) {
     
    796848    update_evalcall_form(3);
    797849
    798     /*                          1           2  3          4    5    6    7   8    9    10 */
    799     mr_asprintf(command, "mindi %s --custom %s %s/images '%s' '%s' '%s' %ld '%s' '%s' '%s' \
    800 '%s' %ld '%s' '%s' '%s' '%s' %ld %d '%s' '%s' '%s' >> %s",
    801 /* 11 12  13   14   15   16  17  18  19   20   21     last */
    802             tmp2,               // parameter #1
    803             bkpinfo->tmpdir,    // parameter #2
     850/*     "mindi --custom 2=%s 3=%s/images 4=\"%s\" 5=\"%s\" \
     8516=\"%s\" 7=%ld 8=\"%s\" 9=\"%s\" 10=\"%s\" \
     85211=\"%s\" 12=%s 13=%ld 14=\"%s\" 15=\"%s\" 16=\"%s\" 17=\"%s\" 18=%ld 19=%d",*/
     853    mr_asprintf(command, "mindi %s --custom %s %s/images '%s' '%s' \
     854'%s' %ld '%s' '%s' '%s' \
     855'%s' %s %ld '%s' '%s' '%s' '%s' %ld %d '%s'", tmp2, bkpinfo->tmpdir,    // parameter #2
    804856            bkpinfo->scratchdir,    // parameter #3
    805857            bkpinfo->kernel_path,   // parameter #4
     
    811863            (bkpinfo->image_devs == NULL) ? "\"\"" : bkpinfo->image_devs,   // parameter #10
    812864            broken_bios_sz,     // parameter #11
    813             estimated_total_noof_slices,    // parameter #12 (INT)
    814             (bkpinfo->exclude_devs == NULL) ? "\"\"" : bkpinfo->exclude_devs,   // parameter #13
    815             use_comp_sz,        // parameter #14
    816             use_lilo_sz,        // parameter #15
    817             use_star_sz,        // parameter #16
    818             bkpinfo->internal_tape_block_size,  // parameter #17 (LONG)
    819             bkpinfo->differential,  // parameter #18 (INT)
     865            last_filelist_number,   // parameter #12 (STRING)
     866            estimated_total_noof_slices,    // parameter #13 (INT)
     867            (bkpinfo->exclude_devs == NULL) ? "\"\"" : bkpinfo->exclude_devs,   // parameter #14
     868            use_comp_sz,        // parameter #15
     869            use_lilo_sz,        // parameter #16
     870            use_star_sz,        // parameter #17
     871            bkpinfo->internal_tape_block_size,  // parameter #18 (LONG)
     872            bkpinfo->differential,  // parameter #19 (INT)
    820873            use_gzip_sz,        // parameter #19 (STRING)
    821874            use_lzma_sz,        // parameter #20 (STRING)
     
    823876            MONDO_LOGFILE);
    824877
    825     mr_free(value);
    826     mr_free(tmp2);
     878    mr_free(last_filelist_number);
    827879    mr_free(tape_device);
    828880    mr_free(use_lzo_sz);
     
    844896//  popup_and_OK("Pausing");
    845897
    846     mvaddstr_and_log_it(g_currentY, 0, "Calling MINDI to create boot+data disks");
    847     open_evalcall_form("Calling MINDI to create boot+data disks");
    848898    res = run_external_binary_with_percentage_indicator_NEW("Generating boot+data disks", command);
    849899    update_evalcall_form(99);
     
    872922            run_program_and_log_output(command, FALSE);
    873923            mr_free(command);
     924        } else {
     925            mr_asprintf(tmp, "cp -f %s/images/all.tar.gz %s", bkpinfo->scratchdir, bkpinfo->tmpdir);
     926            if (system(tmp)) {
     927                fatal_error("Cannot find all.tar.gz in tmpdir");
     928            }
     929            mr_free(tmp);
    874930        }
    875931        if (res) {
     
    9821038        mr_asprintf(archiving_filelist_fname, FILELIST_FNAME_RAW_SZ, bkpinfo->tmpdir, archiving_set_no);
    9831039        if (!does_file_exist(archiving_filelist_fname)) {
    984             log_msg(3, "[%d:%d] - well, I would archive %d, except that it doesn't exist. I'll stop now.", getpid(), this_thread_no, archiving_set_no);
     1040            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);
    9851041            mr_free(archiving_afioball_fname);
    9861042            break;
     
    9891045        mr_asprintf(tmp, AFIOBALL_FNAME_RAW_SZ, bkpinfo->tmpdir, archiving_set_no - ARCH_BUFFER_NUM, bkpinfo->zip_suffix);
    9901046        if (does_file_exist(tmp)) {
    991             log_msg(4, "[%d:%d] - waiting for storer", getpid(), this_thread_no);
     1047            log_msg(4, "%s[%d:%d] - waiting for storer", FORTY_SPACES, getpid(), this_thread_no);
    9921048            while (does_file_exist(tmp)) {
    9931049                sleep(1);
     
    9971053        mr_free(tmp);
    9981054
    999         log_msg(4, "[%d:%d] - EXATing %d...", getpid(), this_thread_no, archiving_set_no);
     1055        log_msg(4, "%s[%d:%d] - EXATing %d...", FORTY_SPACES, getpid(), this_thread_no, archiving_set_no);
    10001056
    10011057        if (g_getfattr) {
     
    10101066        }
    10111067
    1012         log_msg(4, "[%d:%d] - archiving %d...", getpid(), this_thread_no, archiving_set_no);
     1068        log_msg(4, "%s[%d:%d] - archiving %d...", FORTY_SPACES, getpid(), this_thread_no, archiving_set_no);
    10131069        res = archive_this_fileset(archiving_filelist_fname, archiving_afioball_fname, archiving_set_no);
    10141070        mr_free(archiving_afioball_fname);
     
    10351091            fatal_error("Cannot get semaphore V");
    10361092        }
    1037         log_msg(4, "[%d:%d] - archived %d OK", getpid(), this_thread_no, archiving_set_no);
     1093        log_msg(4, "%s[%d:%d] - archived %d OK", FORTY_SPACES, getpid(), this_thread_no, archiving_set_no);
    10381094        archiving_set_no++;
    10391095
     
    10501106        fatal_error("Cannot get semaphore V");
    10511107    }
    1052     log_msg(3, "[%d:%d] - exiting", getpid(), this_thread_no);
     1108    log_msg(3, "%s[%d:%d] - exiting", FORTY_SPACES, getpid(), this_thread_no);
    10531109    pthread_exit(NULL);
    10541110}
     
    13381394            if (!get_bit_N_of_array
    13391395                (p_list_of_fileset_flags, storing_set_no)) {
    1340                 misc_counter_that_is_not_important = (misc_counter_that_is_not_important + 1) % 5;
    1341                 sleep(1);
     1396            misc_counter_that_is_not_important = (misc_counter_that_is_not_important + 1) % 5;
     1397            /* BCO the media_usage_comment is not really initialized there !
     1398            if (!misc_counter_that_is_not_important) {
     1399                update_progress_form(media_usage_comment);
     1400            }
     1401            */
     1402            sleep(1);
    13421403            } else {
    13431404                // store set N
     
    17651826                log_msg(1, "Non-ia64 --> lilo");
    17661827                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);
    1767                     // FIXME: fixed boot size probably wrong. lilo to be removed
     1828                // FIXME: fixed boot size probably wrong. lilo to be removed
    17681829                res = eval_call_to_make_ISO(full_isofs_cmd, destfile, g_current_media_number, message_to_screen);
     1830                mr_free(full_isofs_cmd);
    17691831#endif
    17701832            } else {
     
    17731835                mr_asprintf(full_isofs_cmd, "%s%s-o '_ISO_' -V _CD#_ .",isofs_cmd,MONDO_MKISOFS_REGULAR_SYSLINUX);
    17741836                res = eval_call_to_make_ISO(full_isofs_cmd, destfile, g_current_media_number, message_to_screen);
    1775             }
    1776             mr_free(full_isofs_cmd);
     1837                mr_free(full_isofs_cmd);
     1838            }
    17771839        }
    17781840        mr_free(isofs_cmd);
     
    20022064            }
    20032065            retval += res;
     2066            p = strrchr(bigfile_fname, '/');
     2067            if (p) {
     2068                p++;
     2069            } else {
     2070                p = bigfile_fname;
     2071            }
    20042072            mr_asprintf(tmp, "Archiving %s ... ", bigfile_fname);
    20052073            if (res) {
     
    22392307    }
    22402308
     2309    mr_asprintf(command, "cp %s/biggielist.txt %s", bkpinfo->tmpdir, biggielist);
     2310    paranoid_system(command);
     2311    mr_free(command);
     2312
    22412313    mr_asprintf(blah, "biggielist = %s", biggielist);
    22422314    log_msg(2, blah);
     
    23512423    va_end(ap);
    23522424
    2353     if (bkpinfo->media_size[g_current_media_number] <= 0) {
     2425    if (bkpinfo->media_size <= 0) {
    23542426        fatal_error("move_files_to_cd() - unknown media size");
    23552427    }
    2356     if (would_occupy / 1024 > bkpinfo->media_size[g_current_media_number]) {
     2428    if (would_occupy / 1024 > bkpinfo->media_size) {
    23572429        res = write_iso_and_go_on(FALSE);   /* FALSE because this is not the last CD we'll write */
    23582430        retval += res;
     
    27072779    char *checksum_line = NULL;
    27082780    char *command = NULL;
    2709     char *tempblock;
     2781    char *tempblock = NULL;
    27102782    char *curr_slice_fname_uncompressed = NULL;
    27112783    char *curr_slice_fname_compressed = NULL;
     
    28342906    }
    28352907    i = bkpinfo->optimal_set_size / 256;
     2908    if (!(tempblock = (char *) malloc(256 * 1024))) {
     2909        fatal_error("malloc error 256*1024");
     2910    }
    28362911    for (slice_num = 1; !finished; slice_num++) {
    28372912        mr_asprintf(curr_slice_fname_uncompressed, "%s", slice_fname(biggie_file_number, slice_num, bkpinfo->tmpdir, ""));
     
    28492924        }
    28502925        if ((i == bkpinfo->optimal_set_size / 256) && (totalread < 1.1 * totallength)) {
    2851             tempblock = mr_malloc(256 * 1024);
    28522926            for (i = 0L; i < bkpinfo->optimal_set_size / 256; i++) {
    28532927                blksize = fread(tempblock, 1, 256 * 1024, fin);
     
    30713145    assert(bkpinfo != NULL);
    30723146    orig_vfy_flag_val = bkpinfo->verify_data;
    3073     if (bkpinfo->media_size[g_current_media_number] <= 0) {
     3147    if (bkpinfo->media_size <= 0) {
    30743148        fatal_error("write_iso_and_go_on() - unknown media size");
    30753149    }
     
    31083182    mr_free(lastcd_fname);
    31093183
    3110     if (space_occupied_by_cd(bkpinfo->scratchdir) / 1024 >
    3111         bkpinfo->media_size[g_current_media_number]) {
    3112         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[g_current_media_number]);
     3184    if (space_occupied_by_cd(bkpinfo->scratchdir) / 1024 > bkpinfo->media_size) {
     3185        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);
    31133186    }
    31143187    if (((bkpinfo->isodir == NULL) && (bkpinfo->netfs_remote_dir == NULL)) || (bkpinfo->prefix == NULL)) {
     
    31813254
    31823255    g_current_media_number++;
    3183     if (g_current_media_number > MAX_NOOF_MEDIA) {
    3184         fatal_error("Too many media. Use tape or net.");
    3185     }
    31863256    wipe_archives(bkpinfo->scratchdir);
    31873257    mr_asprintf(tmp1, "rm -Rf %s/images/*gz %s/images/*data*img", bkpinfo->scratchdir, bkpinfo->scratchdir);
Note: See TracChangeset for help on using the changeset viewer.