Changeset 1161 in MondoRescue for trunk


Ignore:
Timestamp:
Feb 14, 2007, 1:13:49 PM (17 years ago)
Author:
Bruno Cornec
Message:

Update trunk with the latest feedback from stable (obtained with meld) - First pass

Location:
trunk/mondo/src/common
Files:
7 edited

Legend:

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

    r1106 r1161  
    1313#include <sys/ipc.h>
    1414#include <stdarg.h>
     15#include <stdlib.h>
    1516#include <unistd.h>
    1617
     
    1920#include "mr_conf.h"
    2021#include "mr_mem.h"
     22#include "mr_msg.h"
    2123#include "mr_err.h"
    2224#include "mr_str.h"
     
    207209    unsigned int res = 0;
    208210    int tries = 0;
    209     char *command;
    210     char *tmp;
    211     char *p;
     211    char *command = NULL;
     212    char *tmp = NULL;
     213    char *p =NULL;
     214    char *tmp1 = NULL;
    212215
    213216    if (!does_file_exist(filelist)) {
     
    330333        log_to_screen(tmp);
    331334        mr_free(tmp);
    332             return (1);
     335        return (1);
    333336    }
    334337    mr_asprintf(&tmp, "echo hi > %s 2> /dev/null", fname);
     
    349352            zipparams = tmp1;
    350353        } else {
    351             mr_asprintf(&zipparams, " ");
    352354            mr_msg(3, "%s not found. Cannot exclude zipfiles, etc.", tmp);
    353355        }
     
    440442{
    441443    int retval = 0, res = 0;
    442     char *tmp;
     444    char *tmp = NULL;
    443445
    444446    assert(bkpinfo != NULL);
    445447    set_g_cdrom_and_g_dvd_to_bkpinfo_value(bkpinfo);
     448
    446449    if (bkpinfo->backup_media_type == dvd) {
    447450#ifdef DVDRWFORMAT
     
    468471    }
    469472
    470 /*
    471       mr_asprintf(&tmp, "wc -l %s/archives/filelist.full > %s/archives/filelist.count",bkpinfo->scratchdir, bkpinfo->scratchdir);
    472       if (run_program_and_log_output(tmp, 2))
    473         { fatal_error("Failed to count filelist.full"); }
    474 */
    475473    mr_asprintf(&tmp, "gzip -9 %s/archives/filelist.full",
    476474             bkpinfo->scratchdir);
     
    507505    run_program_and_log_output(tmp, 1);
    508506    mr_free(tmp);
     507    retval += make_those_afios_phase(bkpinfo);  // backup regular files
    509508    retval += make_those_slices_phase(bkpinfo); // backup BIG files
    510509    retval += do_that_final_phase(bkpinfo); // clean up
     
    577576
    578577    mr_asprintf(&tmp,
    579              "echo '%s' | tr -s ' ' '\n' | grep -E '^/dev/.*$' | tr -s '\n' ' ' | awk '{print $0\"\\n\";}'",
    580              bkpinfo->exclude_paths);
     578            "echo '%s' | tr -s ' ' '\n' | grep -E '^/dev/.*$' | tr -s '\n' ' ' | awk '{print $0\"\\n\";}'",
     579            bkpinfo->exclude_paths);
     580
    581581    devs_to_exclude = call_program_and_get_last_line_of_output(tmp);
    582582    mr_free(tmp);
     583
    583584    mr_asprintf(&tmp, "devs_to_exclude = '%s'", devs_to_exclude);
    584585    mr_msg(2, tmp);
     
    596597    }
    597598    lines_in_filelist = count_lines_in_file(tmp);
    598     mr_free(tmp);
    599     mr_asprintf(&tmp, "%s/LAST-FILELIST-NUMBER", bkpinfo->tmpdir);
    600599    last_filelist_number = last_line_of_file(tmp);
    601600    mr_free(tmp);
     601
    602602    if (IS_THIS_A_STREAMING_BACKUP(bkpinfo->backup_media_type)) {
    603603        mr_asprintf(&tape_size_sz, "%ld", bkpinfo->media_size[1]);
     
    675675        if (bkpinfo->boot_loader != '\0') {
    676676            mr_asprintf(&tmp, "User specified boot loader. It is '%c'.",
    677                      bkpinfo->boot_loader);
     677                    bkpinfo->boot_loader);
    678678            mr_msg(2, tmp);
    679679            mr_free(tmp);
     
    683683        if (bkpinfo->boot_device != NULL) {
    684684            mr_asprintf(&tmp, "User specified boot device. It is '%s'.",
    685                      bkpinfo->boot_device);
     685                    bkpinfo->boot_device);
    686686            mr_msg(2, tmp);
    687687            mr_free(tmp);
     
    757757    }
    758758    mr_asprintf(&tmp, "Your boot loader is %s and it boots from %s",
    759              bootldr_str, bkpinfo->boot_device);
     759            bootldr_str, bkpinfo->boot_device);
    760760    log_to_screen(tmp);
    761761    mr_free(tmp);
     
    780780        log_OS_error("Unable to make mnt floppy directory");
    781781    }
     782    mr_free(command);
    782783
    783784    /* Prepare interface with mindi through a configuration file
     
    927928    mr_msg(2, command);
    928929
    929 
    930930    res = run_program_and_log_to_screen(command, "Generating boot+data disks");
    931931    mr_free(command);
     
    941941
    942942        mr_asprintf(&command,
    943                  "cp -f %s/images/mindi.iso /var/cache/mindi/mondorescue.iso",
    944                  bkpinfo->scratchdir);
     943                "cp -f %s/images/mindi.iso /var/cache/mindi/mondorescue.iso",
     944                bkpinfo->scratchdir);
    945945        mr_msg(2, command);
    946946        run_program_and_log_output(command, FALSE);
     
    949949        if (bkpinfo->nonbootable_backup) {
    950950            mr_asprintf(&command, "cp -f %s/all.tar.gz %s/images",
    951                      bkpinfo->tmpdir, bkpinfo->scratchdir);
     951                    bkpinfo->tmpdir, bkpinfo->scratchdir);
    952952            if (system(command)) {
    953953                fatal_error("Unable to create temporary duff tarball");
    954                 mr_free(command);
    955             }
    956         }
     954            }
     955            mr_free(command);
     956           
     957        }
     958/*
    957959        mr_asprintf(&command, "cp -f %s/mindi-*oot*.img %s/images",
    958960                 bkpinfo->tmpdir, bkpinfo->scratchdir);
     
    960962        run_program_and_log_output(command, FALSE);
    961963        mr_free(command);
    962 
     964*/
    963965        mr_asprintf(&tmp, "cp -f %s/images/all.tar.gz %s",
    964966                 bkpinfo->scratchdir, bkpinfo->tmpdir);
     
    10321034
    10331035    struct s_bkpinfo *bkpinfo;
    1034     char *tmp;
     1036    char *tmp = NULL;
    10351037    int res = 0, retval = 0;
    10361038    int *p_archival_threads_running;
     
    11151117                this_thread_no, archiving_set_no);
    11161118        res = archive_this_fileset(bkpinfo, archiving_filelist_fname,
    1117                                    archiving_afioball_fname,
    1118                                    archiving_set_no);
     1119                                 archiving_afioball_fname,
     1120                                 archiving_set_no);
    11191121        mr_free(archiving_afioball_fname);
    11201122        mr_free(archiving_filelist_fname);
     
    11571159            this_thread_no);
    11581160    mr_free(archiving_filelist_fname);
     1161    mr_free(archiving_afioball_fname);
    11591162    pthread_exit(NULL);
    11601163}
     
    12761279    paranoid_system(command);
    12771280    mr_free(command);
     1281
    12781282    wipe_archives(bkpinfo->scratchdir);
    12791283    mvaddstr_and_log_it(g_currentY++, 74, "Done.");
     
    13091313
    13101314    /*@ buffers *********************************************************** */
    1311     char *command;
     1315    char *command = NULL;
    13121316    char *tempfile;
    13131317
     
    13341338/* if not Debian then go ahead & use fdformat */
    13351339    tempfile = call_program_and_get_last_line_of_output("mktemp -q /tmp/mondo.XXXXXXXX");
    1336     mr_asprintf(&command, "%s >> %s 2>> %s; rm -f %s", cmd, tempfile,
    1337              tempfile, tempfile);
     1340    mr_asprintf(&command, "%s >> %s 2>> %s; rm -f %s", cmd, tempfile, tempfile, tempfile);
    13381341    mr_msg(3, command);
    13391342    open_evalcall_form(title);
     
    13951398    char *title;
    13961399
    1397 
    13981400    assert_string_is_neither_NULL_nor_zerolength(device);
     1401
    13991402    if (!system("which superformat > /dev/null 2> /dev/null")) {
    14001403        mr_asprintf(&command, "superformat %s", device);
     
    14411444    }
    14421445}
     1446
    14431447
    14441448/**
     
    14801484    char *storing_filelist_fname;
    14811485    char *storing_afioball_fname;
    1482     char *tmp;
     1486    char *tmp = NULL;
    14831487    char *media_usage_comment;
    14841488    pthread_t archival_thread[ARCH_THREADS];
     
    17141718
    17151719    /*@ buffers ****************************************** */
    1716     char *tmp;
     1720    char *tmp = NULL;
    17171721    char *old_pwd;
    1718     char *result_sz;
    1719     char *message_to_screen;
    1720     char *sz_blank_disk;
    1721     char *tmp2;
    1722     char *tmp3;
     1722    char *result_sz = NULL;
     1723    char *message_to_screen = NULL;
     1724    char *sz_blank_disk = NULL;
     1725    char *tmp2 = NULL;
     1726    char *tmp3 = NULL;
    17231727    bool cd_is_mountable;
    17241728
     
    17571761    if (bkpinfo->call_before_iso != NULL) {
    17581762        mr_asprintf(&message_to_screen, "Running pre-ISO call for CD#%d",
    1759                  g_current_media_number);
     1763                g_current_media_number);
    17601764        res = eval_call_to_make_ISO(bkpinfo, bkpinfo->call_before_iso,
    1761                                     destfile, g_current_media_number,
    1762                                     MONDO_LOGFILE, message_to_screen);
     1765                                destfile, g_current_media_number,
     1766                                MONDO_LOGFILE, message_to_screen);
    17631767        if (res) {
    17641768            log_to_screen("%s...failed", message_to_screen);
     
    17721776    if (bkpinfo->call_make_iso != NULL) {
    17731777        mr_msg(2, "bkpinfo->call_make_iso = %s", bkpinfo->call_make_iso);
     1778/* Useless ?
    17741779        mr_asprintf(&tmp, "%s/archives/NOT-THE-LAST", bkpinfo->scratchdir);
     1780*/
    17751781        mr_asprintf(&message_to_screen, "Making an ISO (%s #%d)",
    17761782                 bkpinfo->backup_media_string,
     
    19301936            }
    19311937        }
     1938        mr_free(message_to_screen);
    19321939        if (res) {
    19331940            log_to_screen("%s...failed", result_sz);
     
    19361943        }
    19371944        retval += res;
    1938         mr_free(message_to_screen);
    19391945        mr_free(result_sz);
    19401946    }
     
    20372043
    20382044    /*@ pointers ******************************************* */
    2039     FILE *fin;
    2040     char *p;
     2045    FILE *fin = NULL;
     2046    char *p = NULL;
    20412047
    20422048    /*@ buffers ******************************************** */
    2043     char *tmp;
     2049    char *tmp = NULL;
    20442050    char *bigfile_fname = NULL;
    2045     char *sz_devfile;
     2051    char *sz_devfile = NULL;
    20462052    char *ntfsprog_fifo = NULL;
    20472053    /*@ long *********************************************** */
     
    21002106            ftmp = fopen(bigfile_fname, "w");
    21012107            paranoid_fclose(ftmp);
    2102             mr_asprintf(&tmp, "bigfile %s was deleted - creating a dummy",
    2103                      bigfile_fname);
    21042108            delete_when_done = TRUE;
    21052109        } else {
     
    21162120                mr_asprintf(&sz_devfile, "%s/%d.%d.000",
    21172121                        bkpinfo->tmpdir,
    2118                          (int) (random() % 32768),
    2119                          (int) (random() % 32768));
     2122                        (int) (random() % 32768),
     2123                        (int) (random() % 32768));
    21202124                mkfifo(sz_devfile, 0x770);
    21212125                ntfsprog_fifo = sz_devfile;
     
    21282132                            bigfile_fname, sz_devfile);
    21292133                    res = feed_into_ntfsprog(bigfile_fname, sz_devfile);
     2134                    mr_free(sz_devfile);
    21302135                    exit(res);
    21312136                    break;
     
    21342139                            "feed_into_ntfsprog() called in background --- pid=%ld",
    21352140                            (long int) (pid));
    2136 
    21372141                    mr_free(sz_devfile);
     2142                    break;
    21382143                }
    21392144            }
     
    21442149
    21452150            // Whether partition or biggiefile, just do your thang :-)
    2146             mr_msg(2, "Bigfile #%ld is '%s' (%ld KB)",
     2151            mr_msg(5, "Bigfile #%ld is '%s' (%ld KB)",
    21472152                    biggie_file_number + 1, bigfile_fname,
    21482153                    (long) biggie_fsize >> 10);
     
    21742179                mr_asprintf(&tmp, "Archiving %s ... OK!", bigfile_fname);
    21752180            }
    2176 
     2181            mr_msg(4,tmp);
     2182            mr_free(tmp);
    21772183            if (delete_when_done) {
    21782184                unlink(bigfile_fname);
     
    21802186            }
    21812187        }
    2182 #ifndef _XWIN
    21832188        if (!g_text_mode) {
    21842189            newtDrawRootText(0, g_noof_rows - 2, tmp);
    21852190            newtRefresh();
    21862191        }
    2187 #endif
    2188     }
    2189     mr_free(tmp);
     2192    }
    21902193    mr_free(bigfile_fname);
    21912194    paranoid_fclose(fin);
     
    22122215
    22132216    /*@ buffers ********************************************** */
    2214     char *curr_filelist_fname;
    2215     char *curr_afioball_fname;
    2216     char *curr_xattr_list_fname;
    2217     char *curr_acl_list_fname;
    2218     char *tmp;
    2219     char *media_usage_comment;
     2217    char *curr_filelist_fname = NULL;
     2218    char *curr_afioball_fname = NULL;
     2219    char *curr_xattr_list_fname = NULL;
     2220    char *curr_acl_list_fname = NULL;
     2221    char *media_usage_comment = NULL;
     2222    char *tmp = NULL;
    22202223
    22212224    /* BERLIOS: Useless ?
     
    22542257        mr_msg(1, "Archiving set %ld", curr_set_no);
    22552258        res = archive_this_fileset(bkpinfo, curr_filelist_fname,
    2256                                    curr_afioball_fname, curr_set_no);
     2259                                 curr_afioball_fname, curr_set_no);
    22572260        retval += res;
    22582261        if (res) {
     
    23992402
    24002403    /*@ buffers ************************************************** */
    2401     char *biggielist;
    2402     char *command;
    2403     char *blah;
    2404     char *xattr_fname;
    2405     char *acl_fname;
     2404    char *biggielist = NULL;
     2405    char *command = NULL;
     2406    char *blah = NULL;
     2407    char *xattr_fname = NULL;
     2408    char *acl_fname = NULL;
    24062409
    24072410    assert(bkpinfo != NULL);
     
    24192422
    24202423    mr_asprintf(&command, "cp %s/biggielist.txt %s", bkpinfo->tmpdir,
    2421              biggielist);
     2424            biggielist);
    24222425    paranoid_system(command);
    24232426    mr_free(command);
     
    25152518
    25162519    /*@ buffers ******************************************************** */
    2517     char *tmp, *curr_file, *cf;
     2520    char *tmp = NULL;
     2521    char *curr_file = NULL;
     2522    char *cf = NULL;
    25182523
    25192524    /*@ long ************************************************************ */
     
    25282533            continue;
    25292534        }
    2530         mr_asprintf(&curr_file, "%s", cf);
     2535        mr_asprintf(&curr_file, cf);
    25312536        if (!does_file_exist(curr_file)) {
    25322537            mr_msg(1,
     
    25582563            continue;
    25592564        }
    2560         mr_asprintf(&curr_file, "%s", cf);
     2565        mr_asprintf(&curr_file, cf);
    25612566
    25622567        mr_asprintf(&tmp, "mv -f %s %s/archives/", curr_file,
     
    26002605{
    26012606    /*@ buffer ************************************************************ */
    2602     char *tmp;
    2603     char *comment;
    2604     char *bootdisk_dev;
    2605     char *datadisk_dev;
    2606     char *bootdisk_file;
    2607     char *rootdisk_file;
     2607    char *tmp = NULL;
     2608    char *comment = NULL;
     2609    char *bootdisk_dev =NULL;
     2610    char *datadisk_dev = NULL;
     2611    char *bootdisk_file = NULL;
     2612    char *rootdisk_file = NULL;
    26082613
    26092614    /*@ int *************************************************************** */
     
    26172622    assert(bkpinfo != NULL);
    26182623    assert_string_is_neither_NULL_nor_zerolength(imagesdir);
    2619 
    26202624
    26212625    if (!ask_me_yes_or_no
     
    26282632        system("/usr/sbin/fdcontrol -F 1722 /dev/fd0.1722");
    26292633#endif
    2630         mr_asprintf(&bootdisk_dev, "%s", DEFAULT_1722MB_DISK);
     2634        mr_asprintf(&bootdisk_dev, DEFAULT_1722MB_DISK);
    26312635    } else if (does_device_exist(BACKUP_1722MB_DISK)) {
    26322636        mr_asprintf(&bootdisk_dev, "/dev/fd0H1722");
     
    26352639        mr_asprintf(&bootdisk_dev, DEFAULT_1722MB_DISK);
    26362640    }
    2637     mr_asprintf(&datadisk_dev, "%s", "/dev/fd0");
     2641    mr_asprintf(&datadisk_dev, "/dev/fd0");
    26382642    if (!does_device_exist(datadisk_dev)) {
    26392643        mr_msg(1, "Warning - can't find a 1.44MB floppy device *sigh*");
    2640         mr_free(datadisk_dev);
    2641         mr_asprintf(&datadisk_dev, "%s", "/dev/fd0");
    26422644    }
    26432645    format_first = ask_me_yes_or_no
    26442646        ("Do you want me to format the disks before I write to them?");
    26452647
    2646 /* boot disk */
     2648    /* boot disk */
    26472649    if (ask_me_OK_or_cancel("About to write boot disk")) {
    26482650        log_to_screen("Writing boot floppy");
     
    27052707            }
    27062708            mr_free(rootdisk_file);
    2707             mr_free(bootdisk_file);
    2708         }
     2709           
     2710        }
     2711        mr_free(bootdisk_file);
    27092712#endif
    27102713    }
     
    27342737            res += write_image_to_floppy(datadisk_dev, tmp);
    27352738        }
    2736     }
     2739        mr_free(tmp);
     2740    }
     2741    /* In case of break free mem as well */
    27372742    mr_free(tmp);
    27382743    mr_free(datadisk_dev);
     
    27512756 */
    27522757
    2753 int
    2754 offer_to_write_boot_floppies_to_physical_disks(struct s_bkpinfo *bkpinfo)
    2755 {
     2758int offer_to_write_boot_floppies_to_physical_disks(struct s_bkpinfo *bkpinfo) {
     2759   
    27562760    int res = 0;
    27572761
     
    28272831    char start_chr;
    28282832    char stop_chr;
    2829     char *curr_file, *cf;
     2833    char *curr_file = NULL;
     2834    char *cf = NULL;
    28302835    /*@ long long ****************************************************** */
    28312836    off_t length_of_incoming_file = (off_t)0;
     
    28392844            continue;
    28402845        }
    2841         mr_asprintf(&curr_file, "%s", cf);
     2846        mr_asprintf(&curr_file, cf);
    28422847        if (!does_file_exist(curr_file)) {
    28432848            mr_msg(1,
     
    31153120
    31163121    /*@ buffers ************************************************** */
    3117     char *tmp, *checksum_line = NULL, *command;
    3118     char *tempblock;
    3119     char *curr_slice_fname_uncompressed;
    3120     char *curr_slice_fname_compressed;
    3121     char *file_to_archive;
    3122     char *file_to_openin;
     3122    char *tmp = NULL;
     3123    char *checksum_line = NULL;
     3124    char *command = NULL;
     3125    char *tempblock = NULL;
     3126    char *curr_slice_fname_uncompressed = NULL;
     3127    char *curr_slice_fname_compressed = NULL;
     3128    char *file_to_archive = NULL;
     3129    char *file_to_openin = NULL;
    31233130    /*@ pointers ************************************************** */
    3124     char *pB;
    3125     FILE *fin, *fout;
     3131    char *pB = NULL;
     3132    FILE *fin = NULL;
     3133    FILE *fout = NULL;
    31263134
    31273135    /*@ bool ****************************************************** */
     
    31343142    long optimal_set_size;
    31353143    bool should_I_compress_slices;
    3136     char *suffix;               // for compressed slices
     3144    char *suffix = NULL;                // for compressed slices
    31373145
    31383146    /*@ long long ************************************************** */
     
    31583166    if (is_this_file_compressed(biggie_filename)
    31593167        || bkpinfo->compression_level == 0) {
    3160         mr_asprintf(&suffix, "%s", "");
     3168        mr_asprintf(&suffix, "");
    31613169        //      log_it("%s is indeed compressed :-)", filename);
    31623170        should_I_compress_slices = FALSE;
    31633171    } else {
    3164         mr_asprintf(&suffix, "%s", bkpinfo->zip_suffix);
     3172        mr_asprintf(&suffix, bkpinfo->zip_suffix);
    31653173        should_I_compress_slices = TRUE;
    31663174    }
     
    31993207            log_OS_error("Unable to popen-in command");
    32003208            mr_free(command);
     3209            mr_free(suffix);
    32013210            return (1);
    32023211        }
     
    32073216    }
    32083217    lstat(biggie_filename, &biggiestruct.properties);
    3209     if (strlen(checksum_line) <= MAX_STR_LEN) {
     3218    if (strlen(biggie_filename) <= MAX_STR_LEN) {
    32103219        strcpy(biggiestruct.filename, biggie_filename);
    32113220    } else {
     
    32293238    fout = fopen(tmp, "w");
    32303239    mr_free(tmp);
     3240
    32313241    (void) fwrite((void *) &biggiestruct, 1, sizeof(biggiestruct), fout);
    32323242    paranoid_fclose(fout);
     
    32403250        log_to_screen(tmp);
    32413251        mr_free(tmp);
    3242 
    32433252        mr_free(suffix);
    32443253        return (1);
     
    32623271        if (!(fout = fopen(curr_slice_fname_uncompressed, "w"))) {
    32633272            log_OS_error(curr_slice_fname_uncompressed);
    3264 
    32653273            mr_free(curr_slice_fname_uncompressed);
    32663274            mr_free(curr_slice_fname_compressed);
     
    32683276            return (1);
    32693277        }
    3270         if (!(tempblock = (char *) malloc(256 * 1024))) {
    3271             fatal_error("malloc error 256*1024");
    3272         }
     3278        tempblock = mr_malloc(256 * 1024);
    32733279        if ((i == bkpinfo->optimal_set_size / 256)
    32743280            && (totalread < 1.1 * totallength)) {
     
    32793285                    (void) fwrite(tempblock, 1, blksize, fout);
    32803286                } else {
     3287                    mr_free(tempblock);
     3288                    mr_free(curr_slice_fname_uncompressed);
     3289                    mr_free(curr_slice_fname_compressed);
    32813290                    break;
    32823291                }
     
    33023311                    log_OS_error(command);
    33033312                }
    3304                 //              did_I_compress_slice = TRUE;
     3313                mr_free(command);
     3314                //          did_I_compress_slice = TRUE;
    33053315            } else {
    33063316                /* BERLIOS: Useless
     
    33103320                 */
    33113321                res = 0;        // don't do it :)
    3312                 //              did_I_compress_slice = FALSE;
     3322                //          did_I_compress_slice = FALSE;
    33133323            }
    33143324            retval += res;
     
    33293339                         slice_num);
    33303340            }
    3331 #ifndef _XWIN
    33323341            if (!g_text_mode) {
    33333342                newtDrawRootText(0, g_noof_rows - 2, tmp);
     
    33363345                mr_msg(2, tmp);
    33373346            }
    3338 #else
    3339             mr_msg(2, tmp);
    3340 #endif
    33413347            mr_free(tmp);
    3342             mr_asprintf(&file_to_archive, "%s", curr_slice_fname_compressed);
     3348            mr_asprintf(&file_to_archive, curr_slice_fname_compressed);
    33433349            g_current_progress++;
    33443350        } else {                /* if i==0 then ... */
    33453351
    33463352            finished = TRUE;
    3347             mr_asprintf(&file_to_archive, "%s",
    3348                      curr_slice_fname_uncompressed);
     3353            mr_asprintf(&file_to_archive, curr_slice_fname_uncompressed);
    33493354            if (IS_THIS_A_STREAMING_BACKUP(bkpinfo->backup_media_type)) {
    33503355                break;
     
    34053410{
    34063411    /*@ buffers ********************************************* */
    3407     char *tmp;
    3408     char *dir;
     3412    char *tmp = NULL;
     3413    char *dir = NULL;
    34093414
    34103415    assert_string_is_neither_NULL_nor_zerolength(d);
     
    34613466
    34623467    /*@ buffers ************************************************** */
    3463     char *tmp;
     3468    char *tmp = NULL;
    34643469
    34653470    assert(bkpinfo != NULL);
     
    36343639        }
    36353640    }
    3636 /*
    3637   if (using_nfs)
    3638     {
    3639       mr_asprintf(&tmp,"mv -f %s %s/%s/", isofile, bkpinfo->isodir, bkpinfo->nfs_remote_dir);
    3640       if (run_program_and_log_output(tmp, FALSE))
    3641         { log_to_screen("Unable to move ISO to NFS dir"); }
    3642     }
    3643 */
    36443641    mr_free(isofile);
    36453642
     
    36843681{
    36853682    int res = 0, retval = 0, cdno = 0;
    3686     char *tmp;
     3683    char *tmp = NULL;
    36873684    long diffs = 0;
    36883685
     
    38693866/* @} - end of utilityGroup */
    38703867
    3871 void setenv_mondo_share(void) {
    3872 
    3873 setenv("MONDO_SHARE", MONDO_SHARE, 1);
    3874 setenv("MONDORESTORECFG", MONDORESTORECFG, 1);
    3875 setenv("MONDO_CACHE", MONDO_CACHE, 1);
     3868void setenv_mondo_var(void) {
     3869
     3870    char *tmp = NULL;
     3871    char *p = NULL;
     3872    char *path_min = "/bin:/usr/bin:/sbin:/usr/sbin:/usr/local/sbin:/usr/local/bin";
     3873
     3874    mr_setenv("MONDO_SHARE",MONDO_SHARE);
     3875    mr_setenv("MONDORESTORECFG",MONDORESTORECFG);
     3876    mr_setenv("MONDO_CACHE",MONDO_CACHE);
     3877
     3878    if ((p = getenv("PATH")) == NULL) {
     3879        mr_asprintf(&p,path_min);
     3880    }
     3881    mr_asprintf(&tmp, "%s:%s",p, path_min);
     3882    mr_free(p);
     3883    mr_setenv("PATH",tmp);
     3884    mr_free(tmp);
    38763885}
    38773886
  • trunk/mondo/src/common/libmondo-devices.c

    r1086 r1161  
    1818#include "libmondo-stream-EXT.h"
    1919#include "mr_mem.h"
     20#include "mr_msg.h"
    2021
    2122#include <sys/ioctl.h>
     
    169170bool am_I_in_disaster_recovery_mode(void)
    170171{
    171     char *tmp, *comment;
     172    char *tmp = NULL;
     173    char *comment = NULL;
    172174    bool is_this_a_ramdisk = FALSE;
    173175
     
    219221 * @ingroup stringGroup
    220222 */
    221 char *bkptype_to_string(t_bkptype bt)
     223static char *bkptype_to_string(t_bkptype bt)
    222224{
    223225    char *output = NULL;
    224 
    225     mr_free(output);
    226226
    227227    switch (bt) {
     
    250250        mr_asprintf(&output, _("udev"));
    251251        break;
     252    case usb:
     253        mr_asprintf(&output, _("usb"));
     254        break;
    252255    default:
    253256        mr_asprintf(&output, _("default"));
     
    268271int eject_device(char *dev)
    269272{
    270     char *command;
     273    char *command = NULL;
    271274    int res1 = 0, res2 = 0;
    272275
     
    309312int inject_device(char *dev)
    310313{
    311     char *command;
     314    char *command = NULL;
    312315    int i;
    313316
     
    337340
    338341    /*@ buffers *********************************************************** */
    339     char *tmp;
    340     bool ret;
     342    char *tmp = NULL;
     343    bool ret = FALSE;
    341344
    342345    assert_string_is_neither_NULL_nor_zerolength(device);
     
    380383{
    381384    /*@ buffers **************************************************** */
    382     char *program;
     385    char *program = NULL;
    383386    char *incoming = NULL;
    384     char *searchstr;
    385     char *tmp;
     387    char *searchstr = NULL;
     388    char *tmp = NULL;
    386389
    387390    /*@ ints ******************************************************* */
     
    444447{
    445448    /*@ buffers **************************************************** */
    446     char *command;
     449    char *command = NULL;
    447450
    448451    /*@ end vars *************************************************** */
     
    475478{
    476479    /*@ buffers **************************************************** */
    477     char *command;
     480    char *command = NULL;
    478481    /*@ end vars *************************************************** */
    479482    int ret;
     
    11481151    /*@ buffers ***************************************************** */
    11491152    char *incoming = NULL;
    1150     char *device_with_tab;
    1151     char *device_with_space;
    1152     char *tmp;
     1153    char *device_with_tab = NULL;
     1154    char *device_with_space = NULL;
     1155    char *tmp = NULL;
    11531156    size_t n = 0;
    11541157
     
    11901193        {
    11911194            paranoid_pclose(fin);
     1195            mr_free(incoming);
    11921196            return(TRUE);
    11931197        }
     
    12321236            mr_free(mddevice);
    12331237            mr_asprintf(&mddevice, "vn%ic", vndev++);
    1234 
    12351238            mr_free(command);
    12361239            mr_asprintf(&command, "vnconfig %s %s", mddevice, fname);
     
    12811284         ("/sbin/sysctl -n kern.osreldate")) < 500000) {
    12821285        mr_asprintf(&command, "vnconfig -d %s", dname);
    1283         ret = system(command);
    1284         mr_free(command);
    1285         return(ret);
    12861286    } else {
    12871287        mr_asprintf(&command, "mdconfig -d -u %s", dname);
    1288         ret = system(command);
    1289         mr_free(command);
    1290         return(ret);
    1291     }
    1292      /*NOTREACHED*/ return 255;
     1288    }
     1289    ret = system(command);
     1290    mr_free(command);
     1291    return(ret);
    12931292}
    12941293#endif
     
    13151314
    13161315    /*@ buffers ********************************************************* */
    1317     char *tmp;
    1318     char *request;
     1316    char *tmp = NULL;
     1317    char *request = NULL;
    13191318
    13201319    assert(bkpinfo != NULL);
     
    13281327        return;
    13291328    }
    1330 
    13311329    mr_asprintf(&tmp, "mkdir -p " MNT_CDROM);
    13321330    run_program_and_log_output(tmp, 5);
     
    17081706            mr_asprintf(&comment,
    17091707                    _("How much data (in Megabytes) will each media store?"));
    1710             if (!popup_and_get_string(_("Size"), comment, sz_size)) {
     1708            if (!popup_and_get_string(_("Size"), comment, sz_size, 5)) {
    17111709                log_to_screen(_("User has chosen not to backup the PC"));
    17121710                finish(1);
    17131711            }
     1712            mr_free(comment);
    17141713            for (i = 0; i <= MAX_NOOF_MEDIA; i++) {
    17151714                bkpinfo->media_size[i] = atoi(sz_size);
     
    17191718                finish(1);
    17201719            }
    1721             mr_free(comment);
    17221720        }
    17231721        if (bkpinfo->disaster_recovery) {
     
    17691767
    17701768            mr_free(command);
    1771             mr_asprintf(&command, "echo hi > %s/%s/.dummy.txt",
    1772                      bkpinfo->isodir, bkpinfo->nfs_remote_dir);
     1769            mr_asprintf(&command, "echo hi > '%s/%s/.dummy.txt'", bkpinfo->isodir,
     1770                    bkpinfo->nfs_remote_dir);
    17731771        }
    17741772        mr_free(command);
     
    19841982    log_it("media size = %ld", bkpinfo->media_size[1]);
    19851983    log_it("media type = %s", bkpinfo->backup_media_string);
    1986     mr_free(tmp);
    19871984    log_it("prefix = %s", bkpinfo->prefix);
    19881985    log_it("compression = %ld", bkpinfo->compression_level);
     
    20212018           */
    20222019}
    2023 
    2024 
    20252020/* @} - end of utilityGroup */
     2021
    20262022
    20272023/**
     
    20342030{
    20352031    char *tmp = NULL;
    2036     char *command = NULL;
    2037     char *sz = NULL;
     2032    char *command = NULL;
     2033    char *sz = NULL;
    20382034    int i = 0;
    20392035
     
    20862082bool set_dev_to_this_if_rx_OK(char *output, char *dev)
    20872083{
    2088     char *command;
     2084    char *command = NULL;
    20892085
    20902086    mr_free(output);
     
    21422138        mr_free(mountdev);
    21432139        mr_free(tmp);
    2144 
    21452140        return (cd_number);
    21462141    }
     
    22002195 * @note Under Linux, all drives are examined, not just @p which_device.
    22012196 */
     2197char which_boot_loader(char *which_device)
     2198{
    22022199#ifdef __FreeBSD__
    2203 char which_boot_loader(char *which_device)
    2204 {
    22052200    int count_lilos = 0;
    22062201    int count_grubs = 0;
     
    22412236        return ('U');
    22422237    }
    2243 }
    2244 
    22452238#else
    2246 
    2247 char which_boot_loader(char *which_device)
    2248         /* which_device is allocated here and needs to be freed by caller */
    2249 {
    22502239    /*@ buffer ***************************************************** */
    22512240    char *list_drives_cmd;
     
    23102299        return ('U');
    23112300    }
    2312 }
    2313 #endif
     2301#endif
     2302}
    23142303
    23152304
     
    24352424    mr_free(tmp);
    24362425    mr_msg(0, "Found %s partition table format type", output);
    2437     return (output);
    2438 }
    2439 
     2426    return(output);
     2427}
    24402428/* @} - end of deviceGroup */
  • trunk/mondo/src/common/libmondo-fifo.c

    r1086 r1161  
    2828#include "libmondo.h"
    2929#include "mr_mem.h"
     30#include "mr_msg.h"
    3031
    3132/**
     
    155156void kill_buffer()
    156157{
    157     char *tmp;
    158     char *command;
     158    char *tmp = NULL;
     159    char *command = NULL;
    159160
    160161    sync();
     
    175176    mr_asprintf(&command, "kill %s", tmp);
    176177    mr_msg(2, "kill_buffer() --- command = %s", command);
    177 
    178178    if (strlen(tmp) > 0) {
    179179        run_program_and_log_output(command, TRUE);
  • trunk/mondo/src/common/libmondo-filelist.c

    r1106 r1161  
    1919#include "mr_str.h"
    2020#include "mr_mem.h"
     21#include "mr_msg.h"
    2122
    2223#include <time.h>
     
    332333       then update_progress_form() won't show the "time taken / time remaining"
    333334       line. The bug only crops up AFTER the call to chop_filelist(). Weird. */
    334 #ifndef _XWIN
    335335    if (!g_text_mode) {
    336336        open_progress_form("", "", "", "", 100);
     
    339339        newtPopWindow();
    340340    }
    341 #endif
    342341    return (curr_set_no + 1);
    343342}
     
    386385    }
    387386    filelist->ch = '\0';
    388     mr_free((void *)filelist);
     387    mr_free(filelist);
    389388    depth--;
    390389    if (depth == 0) {
     
    490489{
    491490    char *command = NULL;
    492     char *tmp = NULL;
    493491    int retval = 0;
    494492
     
    542540    mr_asprintf(&masklist, "/tmp/%d.%d.mask", (int) (random() % 32768),
    543541             (int) (random() % 32768));
     542
    544543    mr_asprintf(&command, "cp -f %s %s", orig_msklist, masklist);
    545544    run_program_and_log_output(command, 1);
     
    752751        return (add_string_at_node(node->right, string_to_add));
    753752    }
     753
    754754    // walk down tree if appropriate
    755755    if (node->down != NULL && node->ch == char_to_add) {
     
    765765        return (1);
    766766    }
     767
    767768    // add here
    768769    newnode = (struct s_node *) mr_malloc(sizeof(struct s_node));
     
    12161217long g_skeleton_entries = 0;
    12171218
    1218 
    12191219/**
    12201220 * Wrapper around mondo_makefilelist().
     
    12341234    /*@ int **************************************************** */
    12351235    int res = 0;
    1236     /*@ buffers ************************************************ */
    12371236
    12381237    assert(bkpinfo != NULL);
     
    13431342        system(strtmp);
    13441343        mr_free(strtmp);
    1345         mr_free(tmp);
    1346 
    13471344        mr_asprintf(&tmp, "wc -l %s | awk '{print $1;}'", skeleton_filelist);
    13481345        tmp1 = call_program_and_get_last_line_of_output(tmp);
     
    15221519    char *tmp1 = NULL;
    15231520    char *tmp2 = NULL;
    1524     char *sz_datefile;
     1521    char *sz_datefile = NULL;
    15251522    char *sz_filelist = NULL;
    15261523    char *exclude_paths = NULL;
     
    17341731    size_t len = 0;             // Scrub's patch doesn't work without that
    17351732
    1736 //  mr_msg(1, "use_star = %s", (use_star)?"TRUE":"FALSE");
    17371733    mr_msg(5, "starting");
    17381734    mr_msg(5, "needles_list_fname = %s", needles_list_fname);
  • trunk/mondo/src/common/libmondo-files.c

    r1106 r1161  
    4545    /*@ buffers ***************************************************** */
    4646    static char *output = NULL;
    47     char *command;
    48     char *tmp;
     47
     48    char *command = NULL;
     49    char *tmp = NULL;
    4950    size_t n = 0;
    5051
     
    9495
    9596    /*@ buffers ***************************************************** */
    96     char *command;
     97    char *command = NULL;
    9798    char *incoming = NULL;
    98     char *tmp;
     99    char *tmp = NULL;
    99100
    100101    /*@ long ******************************************************** */
     
    207208    if (!(fout = fopen(outfname, "w"))) {
    208209        log_OS_error("Unable to openout outfname");
     210        mr_free(infname);
    209211        mr_free(outfname);
    210212        return;
     
    600602void register_pid(pid_t pid, char *name_str)
    601603{
    602     char *tmp;
    603     char *lockfile_fname;
     604    char *tmp = NULL;
     605    char *lockfile_fname = NULL;
    604606    int res;
    605607    size_t n = 0;
     
    754756}
    755757
    756 
    757758/**
    758759 * Determine the amount of space (in KB) occupied by a mounted CD.
     
    942943{
    943944    /*@ Char buffers ** */
    944     char *command;
     945    char *command = NULL;
    945946    char *tmp;
    946947    char old_pwd[MAX_STR_LEN];
     
    964965    mr_free(command);
    965966
    966     mr_asprintf(&tmp, "%s/payload.tgz", g_mondo_home);
    967 
    968967    /* i18n */
    969968    mr_asprintf(&command, CP_BIN " --parents /usr/share/locale/*/LC_MESSAGES/mondo.mo %s",bkpinfo->scratchdir);
     
    972971    mr_free(command);
    973972
     973    mr_asprintf(&tmp, "%s/payload.tgz", g_mondo_home);
    974974    if (does_file_exist(tmp)) {
    975975        log_it("Untarring payload %s to scratchdir %s", tmp,
     
    11141114                "ifconfig %s | awk '{print $5}' | head -n1", nfs_dev);
    11151115        mac_addr = call_program_and_get_last_line_of_output(command);
     1116        mr_free(command);
     1117
    11161118        mr_asprintf(&command,
    1117                 "ifconfig | grep -E '%s' | grep -v '%s' | head -n1  | cut -d' ' -f1", mac_addr);
     1119                "ifconfig | grep -E '%s' | grep -v '%s' | head -n1  | cut -d' ' -f1", mac_addr, nfs_dev);
    11181120        mr_free(nfs_dev);
    11191121        nfs_dev = call_program_and_get_last_line_of_output(command);
     
    11251127
    11261128    mr_free(nfs_dev);
    1127     mr_free(tmp);
    1128 
    11291129    fd1 = mr_fopen(MONDORESTORECFG, "a");
    11301130    mr_fprintf(fd1, "nfs-dev %s\n", nfs_dev);
     
    12661266int make_grub_install_scriptlet(char *outfile)
    12671267{
    1268     FILE *fout;
    1269     char *tmp;
     1268    FILE *fout = NULL;
     1269    char *tmp = NULL;
    12701270    int retval = 0;
    12711271
  • trunk/mondo/src/common/libmondo-fork.c

    r1086 r1161  
    6969
    7070    /*@ buffers      *** */
    71     char *midway_call, *ultimate_call, *tmp, *command,
    72         *cd_number_str;
    73     char *p;
     71    char *midway_call, *ultimate_call, *tmp;
     72    char *p = NULL;
     73    char *cd_number_str = NULL;
     74    char *command = NULL;
     75   
    7476
    7577/*@***********   End Variables ***************************************/
     
    8082    assert_string_is_neither_NULL_nor_zerolength(isofile);
    8183    assert_string_is_neither_NULL_nor_zerolength(logstub);
     84
    8285    midway_call = mr_malloc(1200);
    8386    ultimate_call = mr_malloc(1200);
     
    260263
    261264    /*@ buffers **************************************************** */
    262     char *tmp;
    263     char *command;
    264     char *lockfile;
     265    char *tmp = NULL;
     266    char *command = NULL;
     267    char *lockfile = NULL;
    265268
    266269    /*@ end vars *************************************************** */
     
    304307    res = pclose(fin);
    305308    /* Log actual pclose errors. */
    306     if (errno)
     309    if (errno) {
    307310        mr_msg(5, "pclose err: %d", errno);
     311    }
    308312    /* Check if we have a valid status. If we do, extract the called program's exit code. */
    309313    /* If we don't, highlight this fact by returning -1. */
     
    590594
    591595    /*@ buffers *********************************************************** */
    592     char *command;
     596    char *command = NULL;
    593597    /*@ pointers ********************************************************** */
    594598    static int chldres = 0;
  • trunk/mondo/src/common/libmondo-mountlist.c

    r1086 r1161  
    1717#include "newt-specific-EXT.h"
    1818#include "mr_mem.h"
    19 #include "mr_mem.h"
     19#include "mr_msg.h"
    2020
    2121/*@unused@*/
Note: See TracChangeset for help on using the changeset viewer.