Changeset 3190 in MondoRescue for branches/3.1


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
Location:
branches/3.1/mondo/src/common
Files:
18 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);
  • branches/3.1/mondo/src/common/libmondo-cli.c

    r3161 r3190  
    3939
    4040extern void setup_tmpdir(char *path);
     41extern void setup_scratchdir(char *path);
    4142void mr_make_devlist_from_pathlist(char *pathlist, char mode);
    4243extern double g_kernel_version;
     
    8586        flag_set[i] = FALSE;
    8687    }
    87     for (j = 1; j <= MAX_NOOF_MEDIA; j++) {
    88         bkpinfo->media_size[j] = 650;
    89     }                           /* default */
     88    bkpinfo->media_size = 650; /* default */
    9089    res = retrieve_switches_from_command_line(argc, argv, flag_val, flag_set);
    9190    retval += res;
     
    9493        retval += res;
    9594    }
     95
    9696    log_msg(3, "Switches:-");
    9797    for (i = 0; i < 128; i++) {
     
    100100        }
    101101    }
    102     mr_asprintf(tmp, "mkdir -p %s/tmpfs", bkpinfo->tmpdir);
    103     paranoid_system(tmp);
    104     mr_free(tmp);
    105 
    106     /*  Before erasing dirs go into a safe place */
    107     if (chdir("/tmp")) {
    108         // FIXME
    109     }
    110     mr_asprintf(tmp, "rm -Rf %s/tmp.mondo.*", bkpinfo->tmpdir);
    111     paranoid_system(tmp);
    112     mr_free(tmp);
    113 
    114     mr_asprintf(tmp, "mkdir -p %s", bkpinfo->scratchdir);
    115     paranoid_system(tmp);
    116     mr_free(tmp);
     102
    117103    return (retval);
    118104}
    119 
    120 
    121105
    122106
     
    130114int process_the_s_switch(char *value)
    131115{
    132     int j;
    133     char tmp[MAX_STR_LEN], *p;
    134 
    135116    assert(bkpinfo != NULL);
    136117    assert(value != NULL);
    137118
    138     bkpinfo->media_size[0] = -1;    /* dummy value */
    139     for (j = 1, p = value; j < MAX_NOOF_MEDIA && strchr(p, ',');
    140          j++, p = strchr(p, ',') + 1) {
    141         strncpy(tmp, p, MAX_STR_LEN);
    142         *(strchr(tmp, ',')) = '\0';
    143         bkpinfo->media_size[j] = friendly_sizestr_to_sizelong(tmp);
    144         log_msg(3, "media_size[%d] = %ld", j, bkpinfo->media_size[j]);
    145     }
    146     for (; j <= MAX_NOOF_MEDIA; j++) {
    147         bkpinfo->media_size[j] = friendly_sizestr_to_sizelong(p);
    148     }
    149     for (j = 1; j <= MAX_NOOF_MEDIA; j++) {
    150         if (bkpinfo->media_size[j] <= 0) {
    151             log_msg(1, "You gave media #%d an invalid size\n", j);
    152             return (-1);
    153         }
     119    bkpinfo->media_size = -1;   /* dummy value */
     120    bkpinfo->media_size = friendly_sizestr_to_sizelong(value);
     121    log_msg(3, "media_size = %ld", bkpinfo->media_size);
     122    if (bkpinfo->media_size <= 0) {
     123        log_msg(1, "You gave media an invalid size %s\n", value);
     124        return (-1);
    154125    }
    155126    return (0);
     
    269240            retval++;
    270241            log_to_screen("Please supply a sensible value with '-I'\n");
     242        }
     243        if (!strcmp(bkpinfo->include_paths, "/")) {
     244            log_msg(2, "'/' is pleonastic.");
     245            bkpinfo->include_paths[0] = '\0';
     246        }
     247        if (bkpinfo->include_paths[0]) {
     248            strcat(bkpinfo->include_paths, "|");
    271249        }
    272250
     
    361339        mr_free(tmp1);
    362340        flag_set['d'] = TRUE;
    363         strcpy(flag_val['d'], p);
    364         mr_free(p);
    365341        log_to_screen("You didn't specify a tape streamer device. I'm assuming %s", flag_val['d']);
    366342    }
     
    429405                }
    430406            } else if (flag_set['u'] || flag_set['t']) {
    431                 for (i = 0; i <= MAX_NOOF_MEDIA; i++) {
    432                     bkpinfo->media_size[i] = 0;
    433                 }
     407                bkpinfo->media_size = 0;
    434408            } else {
    435409                retval++;
     
    483457        /* p points on to the string server:/path */
    484458        /* Store the 2 values */
     459        /*  using memmove instead of strcpy as per #584 */
     460        /* memmove(bkpinfo->netfs_mount, p, MAX_STR_LEN); */
    485461        bkpinfo->netfs_mount = p;
    486462
     
    492468            p++;
    493469            /* new netfs mount */
    494             bkpinfo->netfs_mount = p;
     470            mr_asprintf(bkpinfo->netfs_mount, "%s", p);
     471            /* now that user is computed, create the right value by removing end of string */
    495472            p--;
    496473            *p = '\0';
     
    506483                if (strstr(bkpinfo->netfs_proto, "sshfs")) {
    507484                    mr_asprintf(tmp1, "sshfs %s@%s", bkpinfo->netfs_user, bkpinfo->netfs_mount);
    508                 } else if (strstr(bkpinfo->netfs_proto, "smbfs")) {
    509                     mr_asprintf(tmp1, "mount -t cifs %s -o user=%s", bkpinfo->netfs_mount, bkpinfo->netfs_user);
    510485                } else if (strstr(bkpinfo->netfs_proto, "smbfs")) {
    511486                    mr_asprintf(tmp1, "mount -t cifs %s -o user=%s", bkpinfo->netfs_mount, bkpinfo->netfs_user);
     
    521496                } else if (strstr(bkpinfo->netfs_proto, "smbfs")) {
    522497                    mr_asprintf(tmp1, "mount -t cifs %s", bkpinfo->netfs_mount);
    523                 } else if (strstr(bkpinfo->netfs_proto, "smbfs")) {
    524                     mr_asprintf(tmp1, "mount -t cifs %s", bkpinfo->netfs_mount);
    525498                } else if (strstr(bkpinfo->netfs_proto, "nfs")) {
    526499                    mr_asprintf(tmp1, "mount %s", bkpinfo->netfs_mount);
     
    611584
    612585    if (flag_set['E']) {
    613         if (bkpinfo->exclude_paths && bkpinfo->exclude_paths[0] == '-') {
     586        if (bkpinfo->exclude_paths && (bkpinfo->exclude_paths[0] == '-')) {
    614587            retval++;
    615588            log_to_screen("Please supply a sensible value with '-E'\n");
     
    758731        if (i) {
    759732            retval++;
    760             log_to_screen(tmp2, "Are you sure directory '%s' exists in remote dir '%s'?\nIf so, do you have rights to write to it?\n", bkpinfo->netfs_remote_dir, bkpinfo->netfs_mount);
     733            log_to_screen("Are you sure directory '%s' exists in remote dir '%s'?\nIf so, do you have rights to write to it?\n", bkpinfo->netfs_remote_dir, bkpinfo->netfs_mount);
    761734        }
    762735        unlink(tmp1);
     
    805778            mr_free(tmp1);
    806779        }
    807         mr_asprintf(bkpinfo->scratchdir, "%s/mondo.scratch.%ld", flag_val['S'], random() % 32768);
     780
     781        mr_asprintf(tmp1, "ln -sf %s/.foo.dat %s/.bar.dat", bkpinfo->scratchdir, bkpinfo->scratchdir);
     782        if (run_program_and_log_output(tmp1, 1)) {
     783            retval++;
     784            mr_free(tmp1);
     785            log_to_screen("Please don't specify a SAMBA or VFAT or NFS scratchdir.");
     786            fatal_error("I cannot write to the scratchdir you specified.");
     787        }
     788        mr_free(tmp1);
    808789    }
    809790
     
    815796
    816797        if (i) {
     798            retval++;
    817799            log_to_screen("Please specify a tempdir which I can write to. :)");
    818800            fatal_error("I cannot write to the tempdir you specified.");
  • branches/3.1/mondo/src/common/libmondo-devices-EXT.h

    r2715 r3190  
    4848extern char *list_of_NETFS_mounts_only(void);
    4949
    50 extern void sensibly_set_scratchdir();
    51 
    52 
    5350extern char *set_dev_to_this_if_rx_OK(char *);
    5451
  • branches/3.1/mondo/src/common/libmondo-devices.c

    r3161 r3190  
    5050extern char *g_selfmounted_isodir;
    5151extern char *MONDO_LOGFILE;
     52
     53extern void setup_tmpdir(char *path);
     54extern void setup_scratchdir(char *path);
    5255
    5356static char g_cdrw_drive_is_here[MAX_STR_LEN / 4] = "";
     
    330333    char *incoming = NULL;
    331334    char *searchstr = NULL;
     335    char *tmp = NULL;
    332336
    333337    /*@ ints ******************************************************* */
     
    349353    res = system(program);
    350354    mr_free(program);
    351     return (res);
     355    return(res);
    352356#endif
    353357
     
    400404    assert_string_is_neither_NULL_nor_zerolength(str);
    401405
     406    /* For UEFI detection, this should be extended to count=2 */
    402407    mr_asprintf(command, "dd if=%s bs=446 count=1 2> /dev/null | strings | grep \"%s\" > /dev/null 2> /dev/null", dev, str);
    403408    i = system(command);
     
    845850    tmp = call_program_and_get_last_line_of_output("dvdrecord -scanbus 2> /dev/null | grep -E '\)\ \'' | grep -n '' | grep -E '[D|C][V|D]' | cut -d':' -f1",TRUE);
    846851    log_msg(5, "tmp = '%s'", tmp);
    847     if (!tmp[0])
     852    if (!tmp[0]) {
    848853        mr_free(tmp);
    849854        tmp = call_program_and_get_last_line_of_output("cdrecord -scanbus 2> /dev/null | grep \)\ \' | grep -n '' | grep -E '[D|C][V|D]' | cut -d':' -f1",TRUE);
     855    }
    850856    if (tmp[0]) {
    851857        devno = atoi(tmp) - 1;
     
    14331439
    14341440    if (g_ISO_restore_mode || bkpinfo->backup_media_type == iso || bkpinfo->backup_media_type == netfs) {
    1435         // BERLIOS --- I'm tempted to do something about this...
    1436         // Why unmount and remount again and again?
    14371441        g_ISO_restore_mode = TRUE;
    1438         if (!is_this_device_mounted(MNT_CDROM)) {
    1439             log_msg(3, "Mounting media");
    1440             g_current_media_number = cd_number_i_want;
    1441             mount_media();
    1442         }
    14431442    }
    14441443    if ((res = what_number_cd_is_this()) != cd_number_i_want) {
     
    17331732            log_msg (4, "Found partition: %s", token);
    17341733            partitions[i++] = token;
     1734            mr_free(token);
    17351735        }
    17361736        mr_asprintf(ndsf, "%s", dsf);
     
    19391939                if ((DSFptr = find_device_in_list(token)) == NULL) {
    19401940                    log_msg (4, "Can't find device %s in mounted file systems list", token);
     1941                    mr_free(tmp);
    19411942                    mr_free(token);
    19421943                    return (1);
     
    27342735            sz_size = p;
    27352736
    2736             for (i = 0; i <= MAX_NOOF_MEDIA; i++) {
    2737                 bkpinfo->media_size[i] = atoi(sz_size);
    2738             }
    2739 
    2740             if (bkpinfo->media_size[0] <= 0) {
     2737            bkpinfo->media_size = atoi(sz_size);
     2738
     2739            if (bkpinfo->media_size <= 0) {
    27412740                log_to_screen("User has chosen not to backup the PC");
    27422741                finish(1);
     
    28042803
    28052804        if (bkpinfo->backup_media_type == cdstream) {
    2806             for (i = 0; i <= MAX_NOOF_MEDIA; i++) {
    2807                 bkpinfo->media_size[i] = 650;
    2808             }
     2805            bkpinfo->media_size = 650;
    28092806        }
    28102807        break;
     
    28662863            bkpinfo->media_size[0] = 0;
    28672864        }
    2868         for (i = 1; i <= MAX_NOOF_MEDIA; i++) {
    2869             bkpinfo->media_size[i] = bkpinfo->media_size[0];
    2870         }
     2865
     2866        bkpinfo->media_size = 0;
     2867        log_msg(4, "media_size = %ld", bkpinfo->media_size);
     2868
    28712869        bkpinfo->use_obdr = ask_me_yes_or_no
    28722870            ("Do you want to activate OBDR support for your tapes ?");
     
    29602958                mr_asprintf(sz_size, "0");
    29612959            }
    2962             for (i = 0; i <= MAX_NOOF_MEDIA; i++) {
    2963                 bkpinfo->media_size[i] = atoi(sz_size);
    2964             }
     2960            bkpinfo->media_size = atoi(sz_size);
    29652961            mr_free(sz_size);
    2966             if (bkpinfo->media_size[0] < 0) {
     2962
     2963            if (bkpinfo->media_size < 0) {
    29672964                log_to_screen("User has chosen not to backup the PC");
    29682965                finish(1);
     
    31723169        }
    31733170        bkpinfo->boot_loader = i;
     3171
    31743172        mr_free(bkpinfo->include_paths);
    31753173        mr_asprintf(p, "/");
     
    32373235                mr_asprintf(g_getfacl,"getfacl");
    32383236            }
     3237            log_it("Backup of extended attributes");
    32393238        }
    32403239// Interactive mode:
     
    33023301
    33033302    log_it("media device = %s", bkpinfo->media_device);
    3304     log_it("media size = %ld", bkpinfo->media_size[1]);
     3303    log_it("media size = %ld", bkpinfo->media_size);
    33053304    tmp = bkptype_to_string(bkpinfo->backup_media_type);
    33063305    log_it("media type = %s", tmp);
     
    33163315    /* Handle devices passed in bkpinfo and print result */
    33173316    /*  the mr_make_devlist_from_pathlist function appends
    3318     *  to the *_paths variables so copy before */
    3319     mr_asprintf(tmp, "%s|", bkpinfo->exclude_paths);
    3320     mr_make_devlist_from_pathlist(tmp, 'E');
    3321     mr_free(tmp);
    3322     mr_asprintf(tmp, "%s|", bkpinfo->include_paths);
    3323     mr_make_devlist_from_pathlist(tmp, 'I');
    3324     mr_free(tmp);
     3317    /*  to the *_paths variables so copy before */
     3318    mr_make_devlist_from_pathlist(bkpinfo->exclude_paths, 'E');
     3319    mr_make_devlist_from_pathlist(bkpinfo->include_paths, 'I');
    33253320
    33263321    log_it("scratchdir = '%s'", bkpinfo->scratchdir);
     
    33303325    }
    33313326    log_it("boot_device = '%s' (loader=%c)", bkpinfo->boot_device, bkpinfo->boot_loader);
    3332     if (bkpinfo->media_size[0] < 0) {
     3327    if (bkpinfo->media_size < 0) {
    33333328        if (archiving_to_media) {
    33343329            fatal_error("Media size is less than zero.");
    33353330        } else {
    33363331            log_msg(2, "Warning - media size is less than zero.");
    3337             bkpinfo->media_size[0] = 0;
     3332            bkpinfo->media_size = 0;
    33383333        }
    33393334    }
  • branches/3.1/mondo/src/common/libmondo-devices.h

    r2715 r3190  
    4040char *list_of_NETFS_mounts_only();
    4141
    42 void sensibly_set_scratchdir();
    43 
    44 
    4542char *set_dev_to_this_if_rx_OK(char *dev);
    4643
  • branches/3.1/mondo/src/common/libmondo-filelist.c

    r3161 r3190  
    2929
    3030
     31extern ssize_t getline(char **lineptr, size_t * n, FILE * stream);
    3132extern char *MONDO_LOGFILE;
    3233
     
    451452        }
    452453        log_msg(8, "Analyzing %s", file_to_analyze);
    453         tmp = mr_stresc(file_to_analyze, " `$\\\"(){}[]'*?&|!#~", '\\');
    454         mr_asprintf(strtmp, syscall_sprintf, tmp);
     454        tmp = mr_stresc(file_to_analyze, "'", '\\', '\'');
     455        mr_asprintf(syscall, "%s '%s' 2>> /dev/null", syscall_sprintf, tmp);    // " MONDO_LOGFILE);
    455456        mr_free(tmp);
    456 
    457         mr_asprintf(syscall, "%s 2>> /dev/null", strtmp);   // " MONDO_LOGFILE);
    458         mr_free(strtmp);
    459 
    460457        log_msg(20,"calling %s\n",syscall);
    461458        call_exe_and_pipe_output_to_fd(syscall, pout);
     
    480477        mr_free(command);
    481478
    482         retval =
    483             gen_aux_list(filelist, "getfacl --all-effective -P \"%s\"", facl_fname);
     479        retval = gen_aux_list(filelist, "getfacl --all-effective -P ", facl_fname);
    484480    }
    485481    return (retval);
     
    496492        run_program_and_log_output(command, 8);
    497493        mr_free(command);
    498         retval =
    499             gen_aux_list(filelist, "getfattr --en=hex -m - -h -d \"%s\"", fattr_fname);
     494        retval = gen_aux_list(filelist, "getfattr --en=hex -m - -h -d ", fattr_fname);
    500495    }
    501496    return (retval);
     
    13381333
    13391334    /* dir is needed when we pass it to the shell */
    1340     dir = mr_stresc(dir1, "`$\\\"(){}'[]&*?|!#~", '\\');
     1335    dir = mr_stresc(dir1, "'", '\\', '\'');
    13411336    p = strrchr(dir1, '/');
    13421337    if (p) {
     
    13461341        }
    13471342    }
    1348     mr_asprintf(find_excludes, "|");
     1343    mr_asprintf(find_excludes, " ");
    13491344
    13501345    if (!depth) {
    1351         mr_asprintf(find_excludes, "|");
    13521346        if (sth != NULL) {
    1353             while((token = mr_strtok(sth, delims, &lastpos))) {
     1347            while((token = mr_strtok(sth, delims, &lastpos)) != NULL) {
    13541348                mr_strcat(find_excludes," -path %s -prune -o", token);
    13551349                mr_free(token);
     
    13651359#if linux
    13661360        // 2.6 has /sys as a proc-type thing -- must be excluded
    1367         mr_asprintf(strtmp, "find '%s' -maxdepth %d -fstype mvfs -prune -o -fstype devpts -prune -o -fstype tmpfs -prune -o fstype devtmpfs -prune -o -fstype proc -prune -o -fstype selinuxfs -prune -o -fstype securityfs -prune -o -fstype hugetlbfs -o -fstype cgroup -prune -prune -o -fstype mqueue -prune -o -fstype debugfs -prune -o -fstype sysfs -prune -o -fstype rpc_pipefs -prune -o -fstype none -prune -o %s -type d -print > %s 2> /dev/null", dir, MAX_SKEL_DEPTH, find_excludes, g_skeleton_filelist);
     1361        mr_asprintf(strtmp, "find '%s' -maxdepth %d -fstype mvfs -prune -o -fstype devpts -prune -o -fstype tmpfs -prune -o -fstype devtmpfs -prune -o -fstype proc -prune -o -fstype selinuxfs -prune -o -fstype securityfs -prune -o -fstype hugetlbfs -o -fstype cgroup -prune -prune -o -fstype mqueue -prune -o -fstype debugfs -prune -o -fstype sysfs -prune -o -fstype rpc_pipefs -prune -o -fstype none -prune -o %s -type d -print > %s 2> /dev/null", dir, MAX_SKEL_DEPTH, find_excludes, g_skeleton_filelist);
    13681362#else
    13691363        // On BSD, for example, /sys is the kernel sources -- don't exclude
     
    14221416//  log_msg(0, "Cataloguing %s", dir);
    14231417    mr_asprintf(skip_these, "|%s|", sth);
     1418   
    14241419    mr_asprintf(new_with_pipe, "|%s|", dir1);
    14251420    if ((dip = opendir(dir1)) == NULL) {
     
    14411436            }
    14421437            mr_free(new_with_pipe);
     1438            mr_asprintf(new_with_pipe, "|%s|", new);
    14431439            if (strstr(skip_these, new_with_pipe)) {
    14441440                fprintf(fout, "%s\n", new);
     
    14931489
    14941490
    1495 
    14961491/**
    14971492 * Create the filelist for the backup. It will be stored in [scratchdir]/archives/filelist.full.
     
    15921587        mr_asprintf(g_skeleton_filelist, "%s/tmpfs/skeleton.txt", bkpinfo->tmpdir);
    15931588        make_hole_for_file(g_skeleton_filelist);
     1589
    15941590        log_msg(4, "g_skeleton_entries = %ld", g_skeleton_entries);
    15951591        log_msg(2, "Opening out filelist to %s", sz_filelist);
     
    15971593            fatal_error("Cannot openout to sz_filelist");
    15981594        }
    1599         if ((!include_paths) || (strlen(include_paths) == 0)) {
     1595        if ((include_paths != NULL) && (strlen(include_paths) == 0)) {
    16001596            log_msg(1, "Including only '/' in %s", sz_filelist);
    16011597            open_and_list_dir("/", exclude_paths, fout,
     
    16681664
    16691665    if (bkpinfo->make_filelist) {
    1670         res =
    1671             mondo_makefilelist(MONDO_LOGFILE, bkpinfo->include_paths, bkpinfo->exclude_paths, bkpinfo->differential, NULL);
     1666        res = mondo_makefilelist(MONDO_LOGFILE, bkpinfo->include_paths, bkpinfo->exclude_paths, bkpinfo->differential, NULL);
    16721667    } else {
    1673         res =
    1674             mondo_makefilelist(MONDO_LOGFILE, NULL, bkpinfo->exclude_paths, bkpinfo->differential, bkpinfo->include_paths);
     1668        res = mondo_makefilelist(MONDO_LOGFILE, NULL, bkpinfo->exclude_paths, bkpinfo->differential, bkpinfo->include_paths);
    16751669    }
    16761670
     
    17991793                }
    18001794                log_msg(5, "Found '%s'", fname);
    1801                 tmp = mr_stresc(fname, "[]*?", '\\');
     1795                tmp = mr_stresc(fname, "[]*?", '\\', "'");
    18021796                mr_free(fname);
    18031797                fname = tmp;
  • branches/3.1/mondo/src/common/libmondo-files.c

    r3161 r3190  
    145145    fin = popen(command, "r");
    146146    mr_free(command);
     147
    147148    if (fin) {
    148149        if (feof(fin)) {
     
    216217    assert_string_is_neither_NULL_nor_zerolength(inout);
    217218    mr_asprintf(infname, "%s.in", inout);
    218     mr_asprintf(outfname, "%s", inout);
    219219    mr_asprintf(tmp, "cp -f %s %s", inout, infname);
    220220    run_program_and_log_output(tmp, FALSE);
     
    226226        return;
    227227    }
     228
     229    mr_asprintf(outfname, "%s", inout);
    228230    if (!(fout = fopen(outfname, "w"))) {
    229231        log_OS_error("Unable to openout outfname");
     232        mr_free(infname);
    230233        mr_free(outfname);
    231234        return;
     
    252255    mr_free(infname);
    253256}
    254 
    255 
    256 
    257 
    258 
    259 
    260 
    261257
    262258
     
    271267
    272268    char *tmp = NULL;
    273     char *command = NULL;;
    274     char *kernel = NULL;;
     269    char *command = NULL;
     270    char *kernel = NULL;
    275271
    276272    kernel = call_program_and_get_last_line_of_output("mindi --findkernel 2> /dev/null",TRUE);
     
    308304
    309305
    310 
    311 
    312 
    313 
    314306/**
    315307 * Find location of specified executable in user's PATH.
     
    358350    return (output);
    359351}
    360 
    361 
    362 
    363 
    364 
    365 
    366352
    367353
     
    659645    return (0);
    660646}
    661 
    662 
    663647
    664648
     
    10281012        fatal_error("Failed to copy LAST-FILELIST-NUMBER to scratchdir");
    10291013    }
     1014    mr_free(command);
    10301015
    10311016    tmp = call_program_and_get_last_line_of_output("which mondorestore",TRUE);
     
    10991084
    11001085    /* BERLIOS : there is a bug #67 here as it only considers the first NIC */
    1101     mr_asprintf(command, "ifconfig | tr '\n' '#' | sed s/##// | tr '#' ' ' | tr '' '\n' | head -n1 | cut -d' ' -f1");
     1086    mr_asprintf(command, "%s", "ifconfig | tr '\n' '#' | sed s/##// | tr '#' ' ' | tr '' '\n' | head -n1 | cut -d' ' -f1");
    11021087    netfs_dev = call_program_and_get_last_line_of_output(command,TRUE);
    11031088    mr_free(command);
     
    11191104    mr_free(command);
    11201105
     1106    mr_asprintf(command, "ifconfig %s | head -1 | awk '{print $5}'", netfs_dev);
     1107    netfs_client_hwaddr = call_program_and_get_last_line_of_output(command);
     1108    mr_free(command);
     1109
     1110    log_it("netfs_client_hwaddr=%s; netfs_client_ipaddr=%s; netfs_server_ipaddr=%s; netfs_mount=%s", netfs_client_hwaddr, netfs_client_ipaddr, netfs_server_ipaddr, netfs_mount);
    11211111    if (strlen(netfs_dev) < 2) {
    11221112        fatal_error("Unable to find ethN (eth0, eth1, ...) adapter via Network mount you specified.");
     
    11241114
    11251115    /********
    1126     * If the Network device that found above is a bonded device,
     1116    * If the Network device found above is a bonded device,
    11271117    * we need to replace it with an ethN device or the
    11281118    * networking will not start during an Network restore.
     
    11531143    mr_free(tmp);
    11541144
    1155     mr_asprintf(tmp, "%s/NETFS-SERVER-MOUNT", bkpinfo->tmpdir);
    1156     write_one_liner_data_file(tmp, bkpinfo->netfs_mount);
    1157     mr_free(tmp);
    1158     mr_free(netfs_mount);
     1145    mr_asprintf(tmp, "%s/NETFS-CLIENT-HWADDR", bkpinfo->tmpdir);
     1146    write_one_liner_data_file(tmp, netfs_client_hwaddr);
     1147    mr_free(netfs_client_hwaddr);
     1148    mr_free(tmp);
    11591149
    11601150    mr_asprintf(tmp, "%s/NETFS-CLIENT-IPADDR", bkpinfo->tmpdir);
    11611151    write_one_liner_data_file(tmp, netfs_client_ipaddr);
    1162     mr_free(tmp);
    1163 
    1164     mr_asprintf(tmp, "%s/NETFS-CLIENT-HWADDR", bkpinfo->tmpdir);
    1165     write_one_liner_data_file(tmp, netfs_client_hwaddr);
     1152    mr_free(netfs_client_ipaddr);
    11661153    mr_free(tmp);
    11671154
    11681155    mr_asprintf(tmp, "%s/NETFS-CLIENT-NETMASK", bkpinfo->tmpdir);
    11691156    write_one_liner_data_file(tmp, netfs_client_netmask);
     1157    mr_free(netfs_client_netmask);
    11701158    mr_free(tmp);
    11711159
    11721160    mr_asprintf(tmp, "%s/NETFS-CLIENT-BROADCAST", bkpinfo->tmpdir);
    11731161    write_one_liner_data_file(tmp, netfs_client_broadcast);
     1162    mr_free(netfs_client_broadcast);
    11741163    mr_free(tmp);
    11751164
    11761165    mr_asprintf(tmp, "%s/NETFS-CLIENT-DEFGW", bkpinfo->tmpdir);
    11771166    write_one_liner_data_file(tmp, netfs_client_defgw);
     1167    mr_free(netfs_client_defgw);
    11781168    mr_free(tmp);
    11791169
    11801170    mr_asprintf(tmp, "%s/NETFS-SERVER-IPADDR", bkpinfo->tmpdir);
    11811171    write_one_liner_data_file(tmp, netfs_server_ipaddr);
     1172    mr_free(netfs_server_ipaddr);
    11821173    mr_free(tmp);
    11831174
     
    11981189    write_one_liner_data_file(tmp, bkpinfo->prefix);
    11991190    mr_free(tmp);
     1191
     1192    sprintf(tmp, "%s/NETFS-PROTO", bkpinfo->tmpdir);
     1193    write_one_liner_data_file(tmp, bkpinfo->netfs_proto);
     1194    mr_free(tmp);
     1195
    12001196
    12011197    log_it("Finished storing Network configuration");
     
    12281224    long long scratchLL;
    12291225
    1230     if (bkpinfo->media_size[1] <= 0) {
     1226    if (bkpinfo->media_size <= 0) {
    12311227        log_to_screen("Number of media required: UNKNOWN");
    12321228        return;
     
    12341230
    12351231    log_it("Estimating number of media required...");
    1236     scratchLL =
    1237         (long long) (noof_sets) * (long long) (bkpinfo->optimal_set_size)
    1238         + (long long) (size_of_all_biggiefiles_K());
    1239     scratchLL = (scratchLL / 1024) / bkpinfo->media_size[1];
     1232    scratchLL = (long long) (noof_sets) * (long long) (bkpinfo->optimal_set_size) + (long long) (size_of_all_biggiefiles_K());
     1233    scratchLL = (scratchLL / 1024) / bkpinfo->media_size;
    12401234    scratchLL++;
    12411235    if (bkpinfo->use_lzo) {
  • branches/3.1/mondo/src/common/libmondo-fork.c

    r3161 r3190  
    123123    char *cd_number_str = NULL;
    124124    char *command = NULL;
    125     char *p;
     125    char *p= NULL;
    126126    char *tmp1 = NULL;
    127127    char *tmp2 = NULL;
     
    140140
    141141    mr_asprintf(cd_number_str, "%d", cd_no);
     142    midway_call = resolve_naff_tokens(tmp1, isofile, "_ISO_");
    142143    log_msg(4, "basic call = '%s'", tmp1);
    143     midway_call = resolve_naff_tokens(tmp1, isofile, "_ISO_");
    144144    mr_free(tmp1);
    145145
     146    tmp = resolve_naff_tokens(midway_call, cd_number_str, "_CD#_");
    146147    log_msg(4, "midway_call = '%s'", midway_call);
    147     tmp = resolve_naff_tokens(midway_call, cd_number_str, "_CD#_");
    148148    mr_free(cd_number_str);
    149149    mr_free(midway_call);
    150150
    151     log_msg(4, "tmp = '%s'", tmp);
    152151    ultimate_call = resolve_naff_tokens(tmp, MONDO_LOGFILE, "_ERR_");
     152    log_msg(4, "ultimate call = '%s'", ultimate_call);
    153153    mr_free(tmp);
    154154
    155     log_msg(4, "ultimate call = '%s'", ultimate_call);
    156155    mr_asprintf(command, "%s >> %s", ultimate_call, MONDO_LOGFILE);
    157156    mr_free(ultimate_call);
    158157
    159     log_to_screen
    160         ("Please be patient. Do not be alarmed by on-screen inactivity.");
    161     log_msg(4, "Calling open_evalcall_form() with what_i_am_doing='%s'",
    162             what_i_am_doing);
     158    log_to_screen("Please be patient. Do not be alarmed by on-screen inactivity.");
     159    log_msg(4, "Calling open_evalcall_form() with what_i_am_doing='%s'", what_i_am_doing);
    163160    if (bkpinfo->manual_cd_tray) {
    164161        mr_asprintf(tmp2, "%s", command);
    165162        p = strstr(tmp2, "2>>");
    166163        if (p) {
    167             *p++ = ' ';
    168             *p++ = ' ';
    169             *p++ = ' ';
     164            sprintf(p, "   ");
    170165            while (*p == ' ') {
    171166                p++;
     
    376371        return (1);
    377372    }
    378     mr_free(command);
    379373
    380374    if (!does_file_exist(lockfile)) {
     
    384378        }
    385379    }
     380    mr_free(command);
    386381
    387382    for (; does_file_exist(lockfile); sleep(1)) {
     
    535530            bytes_to_be_read = atol(tmp1);
    536531        }
     532    }
     533
     534    if (direction == 'w') {
     535        mr_asprintf(tmp, "%-64s", PIMP_END_SZ);
     536        if (fwrite(tmp, 1, 64, fout) != 64) {
     537            mr_free(tmp);
     538            fatal_error("Can't write the final block");
     539        }
     540        mr_free(tmp);
     541    } else {
    537542        log_msg(1, "tmpA is %s", tmp1);
    538543        if (!strstr(tmp1, PIMP_END_SZ)) {
     
    554559                }
    555560
    556                 sprintf(tmp, "I am here - %lld", (long long)ftello(fin));
     561                mr_asprintf(tmp, "I am here - %lld", (long long)ftello(fin));
    557562                if (fread(tmp, 1, tmpcap, fin)) {
     563                    mr_free(tmp);
    558564                    fatal_error("Can't fread here");
    559565                }
    560566                log_msg(0, "tmp = '%s'", tmp);
    561567                if (fwrite(tmp, 1, tmpcap, ftmp)) {
     568                    mr_free(tmp);
    562569                    fatal_error("Can't fwrite there");
    563570                }
    564571                fclose(ftmp);
    565                 mr_free(tmp1);
     572                mr_free(tmp);
    566573                fatal_error("Missing terminating block");
    567574            }
    568575        }
    569         mr_free(tmp1);
    570     }
     576    }
     577    mr_free(tmp1);
    571578
    572579    paranoid_free(buf);
     
    595602    command = find_home_of_exe("ntfsclone");
    596603    if (!command) {
    597         mr_free(command);
    598604        fatal_error("ntfsclone not found");
    599605    }
     
    641647    /*@ buffers *********************************************************** */
    642648    char *command = NULL;
    643     char *title = NULL;
    644649    /*@ pointers ********************************************************** */
    645650    static int chldres = 0;
     
    659664
    660665    log_msg(8, "Parent running");
    661     mr_asprintf(title, "%s", tt);
    662     open_evalcall_form(title);
    663     mr_free(title);
     666    open_evalcall_form(tt);
    664667
    665668    for (sleep(1); command[0] != '\0'; sleep(1)) {
     
    672675        if (pcno <= 5 && last_pcno >= 40) {
    673676            close_evalcall_form();
    674             mr_asprintf(title, "Verifying...");
    675             open_evalcall_form(title);
    676             mr_free(title);
     677            open_evalcall_form("Verifying...");
    677678        }
    678679        if (counter++ >= 5) {
  • branches/3.1/mondo/src/common/libmondo-mountlist.c

    r3161 r3190  
    587587
    588588    /* Look for duplicate mountpoints in mountlist. */
    589 
    590589    for (currline = 0; currline < mountlist->entries; currline++) {
    591590        mr_asprintf(curr_mountpoint, "%s", mountlist->el[currline].mountpoint);
     
    743742    for (i = 0; i < mountlist->entries; i++) {
    744743        if (strstr(mountlist->el[i].mountpoint, "raid")) {
    745             used_by = which_raid_device_is_using_this_partition(raidlist,
    746                                                           mountlist->el[i].
    747                                                           device);
     744            used_by = which_raid_device_is_using_this_partition(raidlist, mountlist->el[i].device);
    748745            if (used_by < 0) {
    749746                memcpy((void *) &output_list->el[items++],
  • branches/3.1/mondo/src/common/libmondo-raid.c

    r3161 r3190  
    12331233    row++;
    12341234    }
    1235 // free string
    1236 mr_free(string);
     1235    // free string
     1236    mr_free(string);
    12371237}
    12381238// close file
  • branches/3.1/mondo/src/common/libmondo-stream.c

    r3161 r3190  
    193193        }
    194194        if (should_we_write_to_next_tape
    195             (bkpinfo->media_size[g_current_media_number], (off_t)256 * 1024)) {
     195            (bkpinfo->media_size, (off_t)256 * 1024)) {
    196196            start_to_write_to_next_tape();
    197197        }
     
    206206      {
    207207        fwrite (blk, 1, 256*1024, g_tape_stream);
    208         if (should_we_write_to_next_tape (bkpinfo->media_size[g_current_media_number], 256*1024))
     208        if (should_we_write_to_next_tape (bkpinfo->media_size, 256*1024))
    209209          {
    210210            start_to_write_to_next_tape ();
     
    278278        mr_asprintf(dev, "%s", VANILLA_SCSI_TAPE);
    279279        mr_free(tmp);
     280        mr_free(cdr_exe);
    280281        return(dev);
    281282    }
     
    288289    if (strlen(tmp) < 2) {
    289290        log_it("Could not find tape device");
     291        mr_free(cdr_exe);
    290292        mr_free(tmp);
    291293        return(NULL);
     
    295297    mr_asprintf(command, "%s -scanbus 2> /dev/null | tr -s '\t' ' ' | grep \"[0-9]*,[0-9]*,[0-9]*\" | grep -v \"[0-9]*) \\*\" | grep -i TAPE | cut -d' ' -f3 | cut -d')' -f1 | head -n1", cdr_exe);
    296298    mr_free(cdr_exe);
     299
    297300    tmp = call_program_and_get_last_line_of_output(command,TRUE);
    298301    mr_free(command);
     
    812815    log_to_screen("Reading stream");
    813816    log_it("stream device = '%s'", bkpinfo->media_device);
    814 /* skip data disks */
     817    /* skip data disks */
    815818    open_evalcall_form("Skipping data disks on stream");
    816819    log_to_screen("Skipping data disks on stream");
     
    937940}
    938941if (bkpinfo->media_device == NULL) {
    939     log_it("Unable to openout NULL dvice");
     942    log_it("Unable to openout NULL device");
    940943    return(1);
    941944}
     
    13051308    char *pA;
    13061309    char *pB;
     1310    int res;
    13071311    int ctrl_chr;
    1308     int res;
    13091312    char *temp_fname;
    13101313    char *datablock;
     
    13251328    while (ctrl_chr != BLK_START_AN_AFIO_OR_SLICE) {
    13261329        res = read_header_block_from_stream(&temp_size, temp_fname, &ctrl_chr);
     1330        if (res) {
     1331            // FIXME
     1332        }
    13271333        if (ctrl_chr == BLK_START_AN_AFIO_OR_SLICE) {
    13281334            break;
     
    14721478    log_it("New tape requested.");
    14731479    insist_on_this_tape_number(g_current_media_number + 1); // will increment g_current_media, too
    1474     if (g_current_media_number > MAX_NOOF_MEDIA) {
    1475         res++;
    1476         log_to_screen("Too many tapes. Man, you need to use nfs!");
    1477     }
    14781480    if (bkpinfo->backup_media_type == cdstream) {
    14791481        mr_asprintf(command, "cdrecord -eject dev=%s speed=%d fs=24m -waiti - >> %s 2>> %s", bkpinfo->media_device, bkpinfo->cdrw_speed, MONDO_LOGFILE, MONDO_LOGFILE);
     
    16631665    filesize = length_of_file(infile);
    16641666    if (should_we_write_to_next_tape
    1665         (bkpinfo->media_size[g_current_media_number], filesize)) {
     1667        (bkpinfo->media_size, filesize)) {
    16661668        start_to_write_to_next_tape();
    16671669        write_backcatalog_to_tape();
  • branches/3.1/mondo/src/common/libmondo-string.c

    r3147 r3190  
    141141
    142142
    143 
    144 
    145 
    146 
    147 
    148 
    149 
    150143/**
    151144 * Turn an entry from the RAID editor's disklist into a GUI-friendly string.
     
    186179    long outval;
    187180    int i;
    188     char *tmp1 = NULL;
     181    char *tmp = NULL;
    189182    char ch;
    190183
     
    198191    }
    199192
    200     mr_asprintf(tmp1, "%s", incoming);
    201     i = (int) strlen(tmp1);
    202     if (tmp1[i - 1] == 'B' || tmp1[i - 1] == 'b') {
    203         tmp1[i - 1] = '\0';
    204     }
    205     for (i = 0; i < (int) strlen(tmp1) && isdigit(tmp1[i]); i++);
    206     ch = tmp1[i];
    207     tmp1[i] = '\0';
    208     outval = atol(tmp1);
    209     paranoid_free(tmp1);
     193    mr_asprintf(tmp, "%s", incoming);
     194    i = (int) strlen(tmp);
     195    if (tmp[i - 1] == 'B' || tmp[i - 1] == 'b') {
     196        tmp[i - 1] = '\0';
     197    }
     198    for (i = 0; i < (int) strlen(tmp) && isdigit(tmp[i]); i++);
     199    ch = tmp[i];
     200    tmp[i] = '\0';
     201    outval = atol(tmp);
     202    mr_free(tmp);
    210203
    211204    if (ch == 'g' || ch == 'G') {
     
    224217        fatal_error("Integer overflow.");
    225218    } else if (ch != 'm' && ch != 'M') {
    226         mr_asprintf(tmp1, "Re: parameter '%s' - bad multiplier ('%c')", incoming, ch);
    227         fatal_error(tmp1);
     219        mr_asprintf(tmp, "Re: parameter '%s' - bad multiplier ('%c')", incoming, ch);
     220        fatal_error(tmp);
    228221    }
    229222    return (outval);
     
    10431036    assert(bkpinfo != NULL);
    10441037
    1045     if (bkpinfo->media_size[g_current_media_number] <= 0) {
     1038    if (bkpinfo->media_size <= 0) {
    10461039        mr_asprintf(tmp, "%lld", g_tape_posK);
    10471040        mr_asprintf(pos_w_commas, "%s", commarize(tmp));
     
    10521045    }
    10531046
    1054 /* update screen */
     1047    /* update screen */
    10551048    if (IS_THIS_A_STREAMING_BACKUP(bkpinfo->backup_media_type)) {
    1056         percentage =
    1057             (int) (g_tape_posK / 10 /
    1058                    bkpinfo->media_size[g_current_media_number]);
     1049        percentage = (int) (g_tape_posK / 10 / bkpinfo->media_size);
    10591050        if (percentage > 100) {
    10601051            percentage = 100;
     
    10621053        mr_asprintf(outstr, "Volume %d: [", g_current_media_number);
    10631054    } else {
    1064         percentage =
    1065             (int) (space_occupied_by_cd(bkpinfo->scratchdir) * 100 / 1024 /
    1066                    bkpinfo->media_size[g_current_media_number]);
     1055        percentage = (int) (space_occupied_by_cd(bkpinfo->scratchdir) * 100 / 1024 / bkpinfo->media_size);
    10671056        mds = media_descriptor_string(bkpinfo->backup_media_type);
    10681057        mr_asprintf(outstr, "%s %d: [", mds, g_current_media_number);
  • branches/3.1/mondo/src/common/libmondo-tools-EXT.h

    r2508 r3190  
    33extern void clean_up_KDE_desktop_if_necessary(void);
    44extern long get_time();
     5extern char *mr_date(void);
    56extern void (*log_debug_msg) (int debug_level, const char *szFile,
    67                              const char *szFunction, int nLine,
  • branches/3.1/mondo/src/common/libmondo-tools.c

    r3161 r3190  
    5757 */
    5858char *g_mondo_home = NULL;
     59
     60/**
     61 * The serial string (used to differentiate between backups) of the current backup.
     62 */
     63char *g_serial_string = NULL;
    5964
    6065/**
     
    363368    assert(bkpinfo != NULL);
    364369
    365     if (!bkpinfo->tmpdir) {
    366         fatal_error("Tmpdir set to NULL !");
    367     }
    368 
    369370    bkpinfo->optimal_set_size =
    370371        (IS_THIS_A_STREAMING_BACKUP(bkpinfo->backup_media_type) ? 16 : 16) *
    371372        1024;
    372 
    373     if (strlen(bkpinfo->tmpdir) < 2) {
    374         log_it("tmpdir is blank/missing");
    375         retval++;
    376     }
    377373
    378374    log_msg(1, "Post-param");
     
    393389        }
    394390        mr_free(tmp);
    395     }
    396     if (bkpinfo->scratchdir) {
    397         make_hole_for_dir(bkpinfo->scratchdir);
    398         chmod(bkpinfo->scratchdir, 0700);
    399     } else {
    400         fatal_error("Scratchdir set to NULL !");
    401391    }
    402392    if (bkpinfo->backup_media_type == iso)
     
    461451    }
    462452#endif
    463         else
    464         {
     453        else {
    465454            mr_asprintf(mondo_mkisofs_sz, MONDO_GROWISOFS_REGULAR_SYSLINUX);
    466455        }
    467456        if (bkpinfo->manual_cd_tray) {
    468             paranoid_free(mondo_mkisofs_sz);
    469457            fatal_error("Manual CD tray + DVD not supported yet.");
    470458            // -m isn't supported by growisofs, BTW...
    471         } else {
    472             if (bkpinfo->media_device == NULL) {
    473                 return(1);
    474             }
     459        } else {}
    475460            mr_free(bkpinfo->call_make_iso);
    476461            mr_asprintf(bkpinfo->call_make_iso, "%s %s -Z %s . 2>> _ERR_", mondo_mkisofs_sz, "", bkpinfo->media_device);
    477             paranoid_free(mondo_mkisofs_sz);
    478         }
     462        }
     463        mr_free(mondo_mkisofs_sz);
    479464        if (getenv ("SUDO_COMMAND")) {
    480465            mr_asprintf(command, "strings `which growisofs` | grep -c SUDO_COMMAND");
     
    506491        }
    507492        if (find_home_of_exe("cdrecord")) {
    508             strcpy(cdr_exe, "cdrecord");
     493            mr_asprintf(cdr_exe, "cdrecord");
    509494        } else if (find_home_of_exe("dvdrecord")) {
    510             strcpy(cdr_exe, "dvdrecord");
     495            mr_asprintf(cdr_exe, "dvdrecord");
    511496        } else {
    512497            mr_free(tmp);
     
    569554        }
    570555        mr_free(cdr_exe);
    571         paranoid_free(mondo_mkisofs_sz);
    572         paranoid_free(extra_cdrom_params);
     556        mr_free(mondo_mkisofs_sz);
     557        mr_free(extra_cdrom_params);
    573558    }                           // end of CD code
    574559
     
    587572        iso_dev = call_program_and_get_last_line_of_output(command,TRUE);
    588573        log_it("res of it = %s", iso_dev);
     574        mr_asprintf(tmp, "%s/ISO-DEV", bkpinfo->tmpdir);
     575        write_one_liner_data_file(tmp, iso_dev);
     576        mr_free(tmp);
    589577        mr_free(command);
    590578
     
    595583        iso_mnt = call_program_and_get_last_line_of_output(command,TRUE);
    596584        log_it("res of it = %s", iso_mnt);
     585        mr_asprintf(tmp, "%s/ISO-MNT", bkpinfo->tmpdir);
     586        write_one_liner_data_file(tmp, iso_mnt);
     587        mr_free(tmp);
    597588        mr_free(command);
    598589
     
    602593            mr_asprintf(iso_path, "%s", "");
    603594        } else {
    604             // If iso_mnt is only / then iso_path is the full dir 
     595            // If iso_mnt is only / then iso_path is the full dir
    605596            // (the formula bellow doesn't work in this case)
    606597            if (strcmp(iso_mnt, "/") == 0) {
     
    614605        mr_free(iso_tmp);
    615606
     607        mr_asprintf(tmp, "%s/ISODIR", bkpinfo->tmpdir);
     608        write_one_liner_data_file(tmp, iso_path);
     609        mr_free(tmp);
     610
    616611        log_it("isodir: %s", iso_path);
    617612        mr_free(iso_path);
     613
     614        mr_asprintf(tmp, "%s/ISO-PREFIX", bkpinfo->tmpdir);
     615        write_one_liner_data_file(tmp, bkpinfo->prefix);
     616        mr_free(tmp);
    618617
    619618        log_it("iso-prefix: %s",  bkpinfo->prefix);
     
    666665    }
    667666    if (bkpinfo->include_paths == NULL) {
    668         mr_asprintf(p, "/");
    669         bkpinfo->include_paths = p;
     667        mr_asprintf(bkpinfo->include_paths, "/");
    670668    }
    671669    g_backup_media_type = bkpinfo->backup_media_type;
     
    731729    if ((bkpinfo->tmpdir != NULL) && (strstr(bkpinfo->tmpdir,"mondo.tmp.") != NULL)) {
    732730        /* purging a potential old tmpdir */
    733         log_it("Purging old tmpdir %s", bkpinfo->tmpdir);
    734731        if (chdir("/tmp")) {
    735732            // FIXME
     
    757754        finish(-1);
    758755    }
    759 
    760756    bkpinfo->tmpdir = p;
    761757    log_it("bkpinfo->tmpdir is being set to %s", bkpinfo->tmpdir);
     758
     759    mr_asprintf(tmp, "mkdir -p %s/tmpfs", bkpinfo->tmpdir);
     760    paranoid_system(tmp);
     761    mr_free(tmp);
     762}
     763
     764
     765void setup_scratchdir(char *path) {
     766
     767    char *tmp = NULL;
     768    char *p = NULL;
     769
     770    if (bkpinfo->scratchdir != NULL) {
     771        /* purging a potential old scratchdir */
     772        if (chdir("/tmp")) {
     773            // FIXME
     774        }
     775        if (strstr(bkpinfo->scratchdir,"mondo.scratch.") != NULL) {
     776            log_it("Purging old scratchdir %s", bkpinfo->scratchdir);
     777            mr_asprintf(tmp,"rm -Rf %s",bkpinfo->scratchdir);
     778        } else {
     779            log_it("Purging old scratchdir %s/mondo.scratch.*", bkpinfo->scratchdir);
     780            mr_asprintf(tmp,"rm -Rf %s/mondo.scratch.*",bkpinfo->scratchdir);
     781        }
     782        paranoid_system(tmp);
     783        mr_free(tmp);
     784    }
     785
     786    /* Always take in account arg first, then env, then default */
     787    if (path != NULL) {
     788        mr_asprintf(tmp, "%s/mondo.scratch.XXXXXX", path);
     789    } else if (getenv("MRSCRATCH")) {
     790        mr_asprintf(tmp, "%s/mondo.scratch.XXXXXX", getenv("MRSCRATCH"));
     791    } else {
     792        mr_asprintf(tmp, "/tmp/mondo.scratch.XXXXXX");
     793    }
     794    p = mkdtemp(tmp);
     795    if (p == NULL) {
     796        log_it("Failed to create global scratch directory %s for Mondo.",tmp);
     797        finish(-1);
     798    }
     799    strcpy(bkpinfo->scratchdir,p);
     800    log_it("bkpinfo->scratchdir is being set to %s", bkpinfo->scratchdir);
     801    paranoid_free(tmp);
     802
     803    mr_asprintf(tmp, "mkdir -p %s", bkpinfo->scratchdir);
     804    paranoid_system(tmp);
     805    mr_free(tmp);
    762806}
    763807
     
    805849    bkpinfo = (struct s_bkpinfo *)mr_malloc(sizeof(struct s_bkpinfo));
    806850
    807     /*  We need tmpdir as early as possible for further function calls */
    808     bkpinfo->tmpdir = NULL;         // Really setup after
    809     setup_tmpdir(NULL);
    810 
    811851    /* Initialized in same order as in the structure declaration to detect errors more easily */
    812852    bkpinfo->media_device = NULL;
    813     for (i = 0; i <= MAX_NOOF_MEDIA; i++) {
    814         bkpinfo->media_size[i] = -1;
    815     }
     853    bkpinfo->media_size = -1;
    816854    bkpinfo->boot_loader = '\0';
    817855    bkpinfo->boot_device = NULL;
     
    828866    bkpinfo->use_star = FALSE;
    829867    bkpinfo->internal_tape_block_size = DEFAULT_INTERNAL_TAPE_BLOCK_SIZE;
     868   
     869/*  We need tmpdir as early as possible for further function calls */
     870    bkpinfo->tmpdir = NULL;         // Really setup after
     871    setup_tmpdir(NULL);
     872    setup_scratchdir(NULL);
     873
    830874    bkpinfo->disaster_recovery = am_I_in_disaster_recovery_mode();
    831875    if (bkpinfo->disaster_recovery) {
     
    835879    }
    836880    mr_asprintf(bkpinfo->prefix, "%s", STD_PREFIX);
    837     /*   bkpinfo->tmpdir is here in the struct */
    838     bkpinfo->scratchdir = NULL;     // Really setup after
    839881    bkpinfo->optimal_set_size = 0;
    840882    bkpinfo->backup_media_type = none;
    841883    bkpinfo->make_filelist = TRUE;  // unless -J supplied to mondoarchive
     884    bkpinfo->exclude_paths = NULL;
    842885    bkpinfo->include_paths = NULL;
    843     bkpinfo->exclude_paths = NULL;
    844886    bkpinfo->exclude_devs = NULL;
    845887    bkpinfo->restore_path = NULL;
     
    850892    bkpinfo->kernel_path = NULL;
    851893    bkpinfo->netfs_mount = NULL;
     894    bkpinfo->netfs_proto = NULL;
     895    bkpinfo->netfs_user = NULL;
    852896    bkpinfo->netfs_remote_dir = NULL;
    853     bkpinfo->netfs_user = NULL;
    854     bkpinfo->netfs_proto = NULL;
    855897    bkpinfo->postnuke_tarball = NULL;
    856898    bkpinfo->subdir = NULL;
     
    864906    bkpinfo->use_obdr = FALSE;
    865907    bkpinfo->restore_mode = interactive;
    866 
    867     sensibly_set_scratchdir();
    868 }
    869 
    870 
     908}
    871909
    872910
     
    12181256    mr_asprintf(command, "mount | grep -Ew '/boot'");
    12191257    mr_free(tmp);
     1258
    12201259    tmp = call_program_and_get_last_line_of_output(command,TRUE);
    12211260    mr_free(command);
    12221261
    12231262    if (!strcmp(tmp,"")) {
    1224         if ((strstr(tmp, "LABEL=") != NULL) || (strstr(tmp,"UUID=")!= NULL)) {
     1263        if ((strstr(tmp, "LABEL=") != NULL) || (strstr(tmp,"UUID=") != NULL)) {
    12251264            if (!run_program_and_log_output("mount /boot", 5)) {
    12261265                strcpy(g_boot_mountpt, "/boot");
  • branches/3.1/mondo/src/common/libmondo-tools.h

    r2508 r3190  
    66
    77long get_time();
    8 extern void (*log_debug_msg) (int debug_level, const char *szFile,
     8char *mr_date(void);
     9extern void (*log_debsug_msg) (int debug_level, const char *szFile,
    910                              const char *szFunction, int nLine,
    1011                              const char *fmt, ...);
  • branches/3.1/mondo/src/common/libmondo-verify.c

    r3161 r3190  
    161161    if (g_last_afioball_number != set_number - 1) {
    162162        if (set_number == 0) {
    163             log_msg(1,
    164                     "Weird error in verify_afioballs_on_CD() but it's really a cosmetic error, nothing more");
     163            log_msg(1, "Weird error in verify_afioballs_on_CD() but it's really a cosmetic error, nothing more");
    165164        } else {
    166165            retval++;
     
    305304                    log_to_screen("%s/%s not found on live filesystem", bkpinfo->restore_path, biggiestruct.filename);
    306305                    mr_asprintf(tmp, "echo \"%s/%s not found\" >> %s/biggies.changed", bkpinfo->restore_path, biggiestruct.filename, bkpinfo->tmpdir);
    307                     if (system(tmp)) {
    308                         //FIXME
    309                     }
     306                    paranoid_system(tmp);
    310307                    mr_free(tmp);
    311308
     
    637634    char *orig_cksum = NULL;
    638635    char *tmp = NULL;
    639     char *slice_fnam;
     636    char *slice_fnam = NULL;
    640637
    641638    /*@ pointers ******************************************************** */
  • branches/3.1/mondo/src/common/mondostructures.h

    r3147 r3190  
    2323 */
    2424
    25 
    26 /** @def MAX_NOOF_MEDIA The maximum number of media that can be used in any one backup. */
    27 ///* So we can override it in config.h: */
    28 //#ifndef MAX_NOOF_MEDIA
    29 #define MAX_NOOF_MEDIA 50
    30 //#endif
    3125
    3226/**
     
    343337
    344338  /**
    345    * An array containing the sizes of each media in our backup set, in MB.
    346    * For example, media 1's size would be stored in media_size[1].
    347    * Element 0 is unused.
     339   * A field containing the sizes of the media in our backup set, in MB.
    348340   * If the size should be autodetected, make it -1 (preferable) or 0.
    349    * @bug This should probably be only one variable, not an array.
    350    */
    351     long media_size[MAX_NOOF_MEDIA + 1];
     341   */
     342    long media_size;
    352343
    353344  /**
  • branches/3.1/mondo/src/common/newt-specific.c

    r3161 r3190  
    122122
    123123        /*@ buffers ********************************************************** */
    124         int i;
    125         char *tmp;
     124        int i = 0;
     125        char *tmp = NULL;
    126126
    127127        assert_string_is_neither_NULL_nor_zerolength(prompt);
     
    173173        int i;
    174174
     175        assert_string_is_neither_NULL_nor_zerolength(prompt);
    175176        if (g_fail_immediately) {
    176177            // We consider the user aborted by using the -F option
     
    326327        paranoid_system("killall mindi 2> /dev/null");
    327328        kill_anything_like_this("/mondo/do-not");
    328         kill_anything_like_this("tmp.mondo");
     329        kill_anything_like_this("mondo.tmp");
    329330        kill_anything_like_this("ntfsclone");
    330331        sync();
     
    420421        free_newt_stuff();
    421422        if (!g_text_mode) {
    422             log_msg(1, "Calling newtFinished()");
    423             newtFinished();
     423            if (does_file_exist("/THIS-IS-A-RAMDISK")) {
     424                log_msg(1, "Calling newtFinished()");
     425                newtFinished();
     426            } else {
     427                log_msg(1, "Calling newtSuspend()");
     428                newtSuspend();
     429            }
    424430        }
    425431        printf("Execution run ended; result=%d\n", signal);
     
    440446        char *command = NULL;
    441447        char *tmp = NULL;
     448        char *p = NULL;
    442449
    443450        /*@ pointers ********************************************************* */
     
    465472                for (err_log_lines[i][0] = '\0';
    466473                     strlen(err_log_lines[i]) < 2 && !feof(fin);) {
    467                     if (fgets(err_log_lines[i], MAX_NEWT_COMMENT_LEN, fin)) {
    468                         //FIXME
     474                    p = fgets(err_log_lines[i], MAX_NEWT_COMMENT_LEN, fin);
     475                    if (!p) {
     476                        // FIXME
    469477                    }
    470478                    /* Commented to make valgrind happy and avoid crash
     
    571579
    572580        /*@ buffers ********************************************************* */
    573         char *title = NULL;
    574581        char *tmp = NULL;
    575582
     
    580587        assert(ttl != NULL);
    581588        malloc_string(tmp);
    582         mr_asprintf(title, "%s", ttl);
    583         strcpy(g_isoform_header_str, title);
    584         if (g_text_mode) {
    585             log_msg(0, title);
    586         } else {
    587             strcpy(tmp, title);
     589        strcpy(g_isoform_header_str, ttl);
     590        if (g_text_mode) {
     591            log_msg(0, ttl);
     592        } else {
     593            strcpy(tmp, ttl);
    588594            center_string(tmp, 80);
    589595            newtPushHelpLine(tmp);
     
    596602            g_isoform_header = newtLabel(1, 1, g_isoform_header_str);
    597603            g_isoform_scale = newtScale(3, 3, 34, 100);
    598             newtCenteredWindow(40, 7, title);
     604            newtCenteredWindow(40, 7, ttl);
    599605            g_isoform_main = newtForm(NULL, NULL, 0);
    600606            g_isoform_timeline = newtLabel(1, 5, "                    ");
     
    607613        }
    608614        update_evalcall_form(0);
    609         mr_free(title);
    610615        paranoid_free(tmp);
    611616    }
     
    971976                }
    972977                if (percentage >= 3) {
    973                     mr_strcat(taskprogress, "] %3d%% done; %2ld:%02ld to go", percentage, time_remaining / 60, time_remaining % 60);
     978                    mr_strcat(taskprogress, "] %3d%% done; %2ld:%02ld to go", percentage, (long) time_remaining / 60, (long) time_remaining % 60);
    974979                    printf("---evalcall---1--- %s\n", g_isoform_header_str);
    975980                    printf("---evalcall---2--- %s\n", taskprogress);
     
    12251230        mr_free(title_sz);
    12261231        mr_free(minimsg_sz);
    1227         paranoid_free(outstr);
    12281232        return (output);
    12291233    }
     
    13691373        log_msg(2, "Loading %s", source_file);
    13701374        for (filelist->entries = 0; filelist->entries <= ARBITRARY_MAXIMUM; ) {
    1371             if (tmp != NULL) {
    1372                 mr_free(tmp);
    1373             }
     1375            mr_free(tmp);
    13741376            if (feof(fin)) {
    13751377                break;
     
    15681570            }
    15691571        }
    1570 
    15711572        newtFormDestroy(myForm);
    15721573        newtPopWindow();
Note: See TracChangeset for help on using the changeset viewer.