Changeset 3192 in MondoRescue


Ignore:
Timestamp:
Sep 25, 2013, 9:03:25 AM (11 years ago)
Author:
Bruno Cornec
Message:
  • revert r3188 & r3189 as I started to work on branch 3.0 before deciding it was much better to do it in 3.2. This will allow some small maintenance work on 3.0 if needed, while pushing all the rest to 3.2 and providing early access to it.
Location:
branches/3.0/mondo/src
Files:
23 edited

Legend:

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

    r3188 r3192  
    6464extern bool g_cd_recovery;
    6565extern char *g_mondo_home;
    66 
    67 /**
    68  * The serial string (used to differentiate between backups) of the current backup.
    69  */
    70 char *g_serial_string = NULL;
    71 
     66/*
     67extern char *g_tmpfs_mountpt;
     68*/
     69extern char *g_serial_string;
    7270extern char *g_getfacl;
    7371extern char *g_getfattr;
     
    202200
    203201    if (!does_file_exist(filelist)) {
    204         log_to_screen("(archive_this_fileset) - filelist %s does not exist", filelist);
     202        mr_asprintf(tmp, "(archive_this_fileset) - filelist %s does not exist", filelist);
     203        log_to_screen(tmp);
     204        paranoid_free(tmp);
    205205        return (1);
    206206    }
     
    208208    mr_asprintf(tmp, "echo hi > %s 2> /dev/null", fname);
    209209    if (system(tmp)) {
    210         mr_free(tmp);
     210        paranoid_free(tmp);
    211211        fatal_error("Unable to write tarball to scratchdir");
    212212    }
    213213    paranoid_free(tmp);
    214214
    215     mr_asprintf(command, "star H=exustar list=%s -c -sparse " STAR_ACL_SZ " file=%s", filelist, fname);
     215    mr_asprintf(command, "star H=exustar list=%s -c -sparse " STAR_ACL_SZ " file=%s",
     216            filelist, fname);
    216217    if (bkpinfo->use_lzo) {
    217         mr_free(command);
    218218        fatal_error("Can't use lzop");
    219219    }
     
    235235            res = 0;
    236236        }
    237         mr_free(tmp);
     237        paranoid_free(tmp);
    238238
    239239        if (res) {
     
    251251        }
    252252    }
    253     mr_free(command);
     253    paranoid_free(command);
    254254
    255255    retval += res;
     
    307307
    308308    if (!does_file_exist(filelist)) {
    309         log_to_screen("(archive_this_fileset) - filelist %s does not exist", filelist);
     309        mr_asprintf(tmp, "(archive_this_fileset) - filelist %s does not exist",
     310                filelist);
     311        log_to_screen(tmp);
     312        paranoid_free(tmp);
    310313        return (1);
    311314    }
    312315    mr_asprintf(tmp, "echo hi > %s 2> /dev/null", fname);
    313316    if (system(tmp)) {
    314         mr_free(tmp);
     317        paranoid_free(tmp);
    315318        fatal_error("Unable to write tarball to scratchdir");
    316319    }
    317     mr_free(tmp);
     320    paranoid_free(tmp);
    318321
    319322
     
    321324        mr_asprintf(tmp, "%s/do-not-compress-these", g_mondo_home);
    322325        //       -b %ld, TAPE_BLOCK_SIZE
    323         mr_asprintf(zipparams, "-Z -P %s -G %d -T 3k", bkpinfo->zip_exe, bkpinfo->compression_level);
     326        mr_asprintf(zipparams, "-Z -P %s -G %d -T 3k", bkpinfo->zip_exe,
     327                bkpinfo->compression_level);
    324328        if (does_file_exist(tmp)) {
    325329            mr_strcat(zipparams, " -E %s",tmp);
     
    327331            log_msg(3, "%s not found. Cannot exclude zipfiles, etc.", tmp);
    328332        }
    329         mr_free(tmp);
     333        paranoid_free(tmp);
    330334    } else {
    331335        mr_asprintf(zipparams, "");
    332336    }
     337
     338//  make_hole_for_file(fname);
    333339
    334340    if (!does_file_exist(bkpinfo->tmpdir)) {
     
    340346        fatal_error("scratchdir not found");
    341347    }
    342     mr_asprintf(command, "rm -f %s %s. %s.gz %s.%s", fname, fname, fname, fname, bkpinfo->zip_suffix);
     348    mr_asprintf(command, "rm -f %s %s. %s.gz %s.%s", fname, fname, fname,
     349            fname, bkpinfo->zip_suffix);
    343350    paranoid_system(command);
    344     mr_free(command);
    345 
    346     mr_asprintf(command, "afio -o -b %ld -M 16m %s %s < %s 2>> %s", TAPE_BLOCK_SIZE, zipparams, fname, filelist, MONDO_LOGFILE);
    347     mr_free(zipparams);
     351    paranoid_free(command);
     352
     353    mr_asprintf(command, "afio -o -b %ld -M 16m %s %s < %s 2>> %s",
     354            TAPE_BLOCK_SIZE, zipparams, fname, filelist, MONDO_LOGFILE);
     355    paranoid_free(zipparams);
    348356
    349357    mr_asprintf(tmp, "echo hi > %s 2> /dev/null", fname);
    350358    if (system(tmp)) {
    351         mr_free(tmp);
     359        paranoid_free(tmp);
    352360        fatal_error("Unable to write tarball to scratchdir");
    353361    }
    354     mr_free(tmp);
     362    paranoid_free(tmp);
    355363
    356364    for (res = 99, tries = 0; tries < 3 && res != 0; tries++) {
     
    398406{
    399407    int retval = 0, res = 0;
    400     char *tmp = NULL;
     408    char *tmp;
    401409
    402410    assert(bkpinfo != NULL);
    403411    set_g_cdrom_and_g_dvd_to_bkpinfo_value();
     412    malloc_string(tmp);
    404413    if (bkpinfo->backup_media_type == dvd) {
    405414#ifdef DVDRWFORMAT
     
    422431    }
    423432
    424     mr_asprintf(tmp, "gzip -9 %s/archives/filelist.full", bkpinfo->scratchdir);
     433/*
     434      sprintf(tmp, "wc -l %s/archives/filelist.full > %s/archives/filelist.count",bkpinfo->scratchdir, bkpinfo->scratchdir);
     435      if (run_program_and_log_output(tmp, 2))
     436        { fatal_error("Failed to count filelist.full"); }
     437*/
     438    sprintf(tmp, "gzip -9 %s/archives/filelist.full", bkpinfo->scratchdir);
    425439    if (run_program_and_log_output(tmp, 2)) {
    426         mr_free(tmp);
    427440        fatal_error("Failed to gzip filelist.full");
    428441    }
    429     mr_free(tmp);
    430 
    431     mr_asprintf(tmp, "cp -f %s/archives/*list*.gz %s", bkpinfo->scratchdir, bkpinfo->tmpdir);
     442    sprintf(tmp, "cp -f %s/archives/*list*.gz %s", bkpinfo->scratchdir,
     443            bkpinfo->tmpdir);
    432444    if (run_program_and_log_output(tmp, 2)) {
    433         mr_free(tmp);
    434445        fatal_error("Failed to copy to tmpdir");
    435446    }
    436     mr_free(tmp);
    437447
    438448    copy_mondo_and_mindi_stuff_to_scratchdir(); // payload, too, if it exists
     
    454464    }
    455465    retval += do_that_initial_phase();  // prepare
    456     mr_asprintf(tmp, "rm -f %s/images/*.iso", bkpinfo->scratchdir);
     466    sprintf(tmp, "rm -f %s/images/*.iso", bkpinfo->scratchdir);
    457467    run_program_and_log_output(tmp, 1);
    458     mr_free(tmp);
    459 
    460468    retval += make_those_afios_phase(); // backup regular files
    461469    retval += make_those_slices_phase();    // backup BIG files
     
    465473        sleep(2);
    466474    }
     475    paranoid_free(tmp);
    467476    return (retval);
    468477}
     
    505514    char *use_lzo_sz = NULL;
    506515    char *use_gzip_sz = NULL;
    507     char *use_lzma_sz = NULL;
    508516    char *use_comp_sz = NULL;
    509517    char *use_star_sz = NULL;
     
    534542    assert(bkpinfo != NULL);
    535543
    536     mvaddstr_and_log_it(g_currentY, 0, "Calling MINDI to create boot+data disks");
     544    mvaddstr_and_log_it(g_currentY, 0,
     545                        "Calling MINDI to create boot+data disks");
    537546    open_evalcall_form("Calling MINDI to create boot+data disks");
    538547    mr_asprintf(tmp, "%s/filelist.full", bkpinfo->tmpdir);
     
    541550        mr_asprintf(tmp, "%s/tmpfs/filelist.full", bkpinfo->tmpdir);
    542551        if (!does_file_exist(tmp)) {
    543             mr_free(tmp);
    544             fatal_error ("Cannot find filelist.full, so I cannot count its lines");
     552            fatal_error
     553                ("Cannot find filelist.full, so I cannot count its lines");
    545554        }
    546555    }
     
    562571            }
    563572        }
    564         mr_free(ntapedev);
     573        paranoid_free(ntapedev);
    565574        mr_asprintf(tape_device, "%s", bkpinfo->media_device);
    566575    } else {
     
    577586    } else {
    578587        mr_asprintf(use_gzip_sz, "no");
    579     }
    580     if (bkpinfo->use_lzma) {
    581         mr_asprintf(use_lzma_sz, "yes");
    582     } else {
    583         mr_asprintf(use_lzma_sz, "no");
    584588    }
    585589    if (bkpinfo->use_star) {
     
    656660            ch = 'U';
    657661        if (bkpinfo->boot_loader != '\0') {
    658             log_msg(2, "User specified boot loader. It is '%c'.", bkpinfo->boot_loader);
     662            mr_asprintf(tmp, "User specified boot loader. It is '%c'.", bkpinfo->boot_loader);
     663            log_msg(2, tmp);
     664            mr_free(tmp);
    659665        } else {
    660666            bkpinfo->boot_loader = ch;
    661667        }
    662668        if (bkpinfo->boot_device[0] != '\0') {
    663             log_msg(2, "User specified boot device. It is '%s'.", bkpinfo->boot_device);
     669            mr_asprintf(tmp, "User specified boot device. It is '%s'.", bkpinfo->boot_device);
     670            log_msg(2, tmp);
     671            mr_free(tmp);
    664672        } else {
    665673            strcpy(bkpinfo->boot_device, bootdev);
     
    684692        mr_asprintf(bootldr_str, "LILO");
    685693        if (!does_file_exist("/etc/lilo.conf")) {
    686             fatal_error("The de facto standard location for your boot loader's config file is /etc/lilo.conf but I cannot find it there. What is wrong with your Linux distribution?");
     694            fatal_error
     695                ("The de facto standard location for your boot loader's config file is /etc/lilo.conf but I cannot find it there. What is wrong with your Linux distribution?");
    687696        }
    688697    } else if (bkpinfo->boot_loader == 'G') {
    689698        mr_asprintf(bootldr_str, "GRUB");
    690         if (!does_file_exist("/boot/grub/menu.lst") && does_file_exist("/boot/grub/grub.conf")) {
    691             run_program_and_log_output("ln -sf /boot/grub/grub.conf /boot/grub/menu.lst", 5);
     699        if (!does_file_exist("/boot/grub/menu.lst")
     700            && does_file_exist("/boot/grub/grub.conf")) {
     701            run_program_and_log_output
     702                ("ln -sf /boot/grub/grub.conf /boot/grub/menu.lst", 5);
    692703        }
    693704        if ((!does_file_exist("/boot/grub/menu.lst")) && (!does_file_exist("/boot/grub/grub.cfg")) && (!does_file_exist("/boot/grub2/grub.cfg"))) {
    694             fatal_error("The de facto standard location for your boot loader's config file is /boot/grub/menu.lst, /boot/grub/grub.cfg, or /boot/grub2/grub.cfg but I cannot find it there. What is wrong with your Linux distribution?");
     705            fatal_error
     706                ("The de facto standard location for your boot loader's config file is /boot/grub/menu.lst, /boot/grub/grub.cfg, or /boot/grub2/grub.cfg but I cannot find it there. What is wrong with your Linux distribution?");
    695707        }
    696708        mr_asprintf(bootldr_ver, "%s", call_program_and_get_last_line_of_output("grub --version"));
     
    698710        mr_asprintf(bootldr_str, "ELILO");
    699711        /* BCO: fix it for Debian, Mandrake, ... */
    700         if (!does_file_exist("/etc/elilo.conf") && does_file_exist("/boot/efi/efi/redhat/elilo.conf")) {
    701             run_program_and_log_output("ln -sf /boot/efi/efi/redhat/elilo.conf /etc/elilo.conf", 5);
    702         }
    703         if (!does_file_exist("/etc/elilo.conf") && does_file_exist("/boot/efi/efi/SuSE/elilo.conf")) {
    704             run_program_and_log_output("ln -sf /boot/efi/efi/SuSE/elilo.conf /etc/elilo.conf", 5);
    705         }
    706         if (!does_file_exist("/etc/elilo.conf") && does_file_exist("/boot/efi/efi/debian/elilo.conf")) {
    707             run_program_and_log_output ("ln -sf /boot/efi/efi/debian/elilo.conf /etc/elilo.conf", 5);
    708         }
    709         if (!does_file_exist("/etc/elilo.conf") && does_file_exist("/boot/efi/debian/elilo.conf")) {
    710             run_program_and_log_output ("ln -sf /boot/efi/debian/elilo.conf /etc/elilo.conf", 5);
     712        if (!does_file_exist("/etc/elilo.conf")
     713            && does_file_exist("/boot/efi/efi/redhat/elilo.conf")) {
     714            run_program_and_log_output
     715                ("ln -sf /boot/efi/efi/redhat/elilo.conf /etc/elilo.conf",
     716                 5);
     717        }
     718        if (!does_file_exist("/etc/elilo.conf")
     719            && does_file_exist("/boot/efi/efi/SuSE/elilo.conf")) {
     720            run_program_and_log_output
     721                ("ln -sf /boot/efi/efi/SuSE/elilo.conf /etc/elilo.conf",
     722                 5);
     723        }
     724        if (!does_file_exist("/etc/elilo.conf")
     725            && does_file_exist("/boot/efi/efi/debian/elilo.conf")) {
     726            run_program_and_log_output
     727                ("ln -sf /boot/efi/efi/debian/elilo.conf /etc/elilo.conf",
     728                 5);
     729        }
     730        if (!does_file_exist("/etc/elilo.conf")
     731            && does_file_exist("/boot/efi/debian/elilo.conf")) {
     732            run_program_and_log_output
     733                ("ln -sf /boot/efi/debian/elilo.conf /etc/elilo.conf",
     734                 5);
    711735        }
    712736        if (!does_file_exist("/etc/elilo.conf")) {
    713             fatal_error("The de facto mondo standard location for your boot loader's config file is /etc/elilo.conf but I cannot find it there. What is wrong with your Linux distribution? Try finding it under /boot/efi and do 'ln -s /boot/efi/..../elilo.conf /etc/elilo.conf'");
     737            fatal_error
     738                ("The de facto mondo standard location for your boot loader's config file is /etc/elilo.conf but I cannot find it there. What is wrong with your Linux distribution? Try finding it under /boot/efi and do 'ln -s /boot/efi/..../elilo.conf /etc/elilo.conf'");
    714739        }
    715740    } else if (bkpinfo->boot_loader == 'R') {
     
    728753        mr_asprintf(bootldr_str, "unknown");
    729754    }
    730     log_to_screen("Your boot loader is %s and it boots from %s", bootldr_str, bkpinfo->boot_device);
    731 
     755    mr_asprintf(tmp, "Your boot loader is %s and it boots from %s", bootldr_str, bkpinfo->boot_device);
     756    log_to_screen(tmp);
     757    mr_free(tmp);
    732758    if (bootldr_ver != NULL) {
    733         log_to_screen("Boot loader version string: %s", bootldr_ver);
     759        mr_asprintf(tmp, "Boot loader version string: %s", bootldr_ver);
     760        log_to_screen(tmp);
     761        mr_free(tmp);
    734762    }
    735763
     
    771799        fatal_error("Unknown backup_media_type");
    772800    }
    773 
    774     if ((bkpinfo->backup_media_type == usb) && (bkpinfo->media_device)) {
     801    if (bkpinfo->backup_media_type == usb) {
    775802        mr_asprintf(tmp2, "--usb %s", bkpinfo->media_device);
    776803    } else {
     
    781808    if (write_one_liner_data_file(tmp, value)) {
    782809        res++;
    783         log_msg(1, "%ld: Unable to write one-liner backup-media-type", __LINE__);
     810        log_msg(1, "%ld: Unable to write one-liner backup-media-type",
     811                __LINE__);
    784812    }
    785813    mr_free(value);
     
    789817    if (write_one_liner_data_file(tmp, bootldr_str)) {
    790818        res++;
    791         log_msg(1, "%ld: Unable to write one-liner bootloader.name", __LINE__);
     819        log_msg(1, "%ld: Unable to write one-liner bootloader.name",
     820                __LINE__);
    792821    }
    793822    mr_free(bootldr_str);
     
    836865    }
    837866
    838     estimated_total_noof_slices = size_of_all_biggiefiles_K(bkpinfo) / bkpinfo->optimal_set_size + 1;
    839 
    840     /* TODO: add netfs stuff here? */
     867    estimated_total_noof_slices =
     868        size_of_all_biggiefiles_K(bkpinfo) / bkpinfo->optimal_set_size + 1;
     869    /* add netfs stuff here? */
    841870    mr_asprintf(command, "mkdir -p %s/images", bkpinfo->scratchdir);
    842871    if (system(command)) {
     
    844873        log_OS_error("Unable to make images directory");
    845874    }
    846     mr_free(command);
     875    paranoid_free(command);
    847876    log_msg(1, "lines_in_filelist = %ld", lines_in_filelist);
    848877    update_evalcall_form(3);
     
    861890            use_lzo_sz,         // parameter #8
    862891            cd_recovery_sz,     // parameter #9
    863             (bkpinfo->image_devs == NULL) ? "\"\"" : bkpinfo->image_devs,   // parameter #10
     892            bkpinfo->image_devs,    // parameter #10
    864893            broken_bios_sz,     // parameter #11
    865894            last_filelist_number,   // parameter #12 (STRING)
     
    871900            bkpinfo->internal_tape_block_size,  // parameter #18 (LONG)
    872901            bkpinfo->differential,  // parameter #19 (INT)
    873             use_gzip_sz,        // parameter #19 (STRING)
    874             use_lzma_sz,        // parameter #20 (STRING)
    875             value,              // parameter #21 (STRING)
    876             MONDO_LOGFILE);
     902            use_gzip_sz);       // parameter #20 (STRING)
    877903
    878904    mr_free(last_filelist_number);
     
    880906    mr_free(use_lzo_sz);
    881907    mr_free(use_gzip_sz);
    882     mr_free(use_lzma_sz);
    883908    mr_free(use_star_sz);
    884909    mr_free(use_comp_sz);
     
    888913    mr_free(tape_size_sz);
    889914
    890     /* This parameter is always the last one and optional */
    891915    if (bkpinfo->nonbootable_backup) {
    892916        mr_strcat(command, " NONBOOTABLE");
     
    905929    if (!res) {
    906930        log_to_screen("Boot+data disks were created OK");
    907         mr_asprintf(command, "cp -f %s/images/mindi.iso %s/mondorescue.iso", bkpinfo->scratchdir, MINDI_CACHE);
     931        mr_asprintf(command, "cp -f %s/images/mindi.iso %s/mondorescue.iso",
     932                bkpinfo->scratchdir, MINDI_CACHE);
    908933        log_msg(2, command);
    909934        run_program_and_log_output(command, FALSE);
    910         mr_free(command);
     935        paranoid_free(command);
    911936
    912937        if (bkpinfo->nonbootable_backup) {
    913             mr_asprintf(command, "cp -f %s/all.tar.gz %s/images", bkpinfo->tmpdir, bkpinfo->scratchdir);
     938            mr_asprintf(command, "cp -f %s/all.tar.gz %s/images",
     939                    bkpinfo->tmpdir, bkpinfo->scratchdir);
    914940            if (system(command)) {
    915                 mr_free(command);
     941                paranoid_free(command);
    916942                fatal_error("Unable to create temporary all tarball");
    917943            }
    918             mr_free(command);
     944            paranoid_free(command);
    919945        }
    920946        /* For USB we already have everything on the key */
     
    922948            mr_asprintf(command, "rm -rf %s/images", bkpinfo->scratchdir);
    923949            run_program_and_log_output(command, FALSE);
    924             mr_free(command);
     950            paranoid_free(command);
    925951        } else {
    926             mr_asprintf(tmp, "cp -f %s/images/all.tar.gz %s", bkpinfo->scratchdir, bkpinfo->tmpdir);
     952            mr_asprintf(tmp, "cp -f %s/images/all.tar.gz %s", bkpinfo->scratchdir,
     953                bkpinfo->tmpdir);
    927954            if (system(tmp)) {
    928955                fatal_error("Cannot find all.tar.gz in tmpdir");
     
    939966        mr_asprintf(command, "grep 'Fatal error' /var/log/mindi.log");
    940967        mr_asprintf(tmp, "%s", call_program_and_get_last_line_of_output(command));
    941         mr_free(command);
     968        paranoid_free(command);
    942969
    943970        if (strlen(tmp) > 1) {
     
    9901017void *create_afio_files_in_background(void *inbuf)
    9911018{
    992     long int archiving_set_no = 0L;
    993     char *archiving_filelist_fname = NULL;
    994     char *archiving_afioball_fname = NULL;
     1019    long int archiving_set_no;
     1020    char *archiving_filelist_fname;
     1021    char *archiving_afioball_fname;
    9951022    char *curr_xattr_list_fname = NULL;
    996     char *curr_acl_list_fname = NULL;
    997 
    998     char *tmp = NULL;
     1023    char *curr_acl_list_fname;
     1024
     1025    char *tmp;
    9991026    int res = 0, retval = 0;
    10001027    int *p_archival_threads_running;
     
    10041031    int this_thread_no = g_current_thread_no++;
    10051032
     1033    malloc_string(curr_xattr_list_fname);
     1034    malloc_string(curr_acl_list_fname);
     1035    malloc_string(archiving_filelist_fname);
     1036    malloc_string(archiving_afioball_fname);
     1037    malloc_string(tmp);
    10061038    p_last_set_archived = (int *) inbuf;
    10071039    p_archival_threads_running = (int *) (inbuf + 4);
     
    10091041    p_list_of_fileset_flags = (char *) (inbuf + 12);
    10101042
    1011     mr_asprintf(archiving_filelist_fname, FILELIST_FNAME_RAW_SZ, bkpinfo->tmpdir, 0L);
    1012 
    1013     while (does_file_exist(archiving_filelist_fname)) {
     1043    sprintf(archiving_filelist_fname, FILELIST_FNAME_RAW_SZ,
     1044            bkpinfo->tmpdir, 0L);
     1045    for (archiving_set_no = 0L; does_file_exist(archiving_filelist_fname);
     1046         sprintf(archiving_filelist_fname, FILELIST_FNAME_RAW_SZ,
     1047                 bkpinfo->tmpdir, archiving_set_no)) {
    10141048        if (g_exiting) {
    1015             mr_free(archiving_filelist_fname);
    10161049            fatal_error("Execution run aborted (pthread)");
    10171050        }
    10181051        if (archiving_set_no >= MAX_NOOF_SETS_HERE) {
    1019             mr_free(archiving_filelist_fname);
    1020             fatal_error("Maximum number of filesets exceeded. Adjust MAX_NOOF_SETS_HERE, please.");
     1052            fatal_error
     1053                ("Maximum number of filesets exceeded. Adjust MAX_NOOF_SETS_HERE, please.");
    10211054        }
    10221055        if (!semaphore_p()) {
    10231056            log_msg(3, "P sem failed (pid=%d)", (int) getpid());
    1024             mr_free(archiving_filelist_fname);
    10251057            fatal_error("Cannot get semaphore P");
    10261058        }
     
    10301062        *p_next_set_to_archive = *p_next_set_to_archive + 1;
    10311063        if (!semaphore_v()) {
    1032             mr_free(archiving_filelist_fname);
    10331064            fatal_error("Cannot get semaphore V");
    10341065        }
    10351066
    10361067        /* backup this set of files */
    1037         mr_asprintf(archiving_afioball_fname, AFIOBALL_FNAME_RAW_SZ, bkpinfo->tmpdir, archiving_set_no, bkpinfo->zip_suffix);
    1038         mr_free(archiving_filelist_fname);
    1039         mr_asprintf(archiving_filelist_fname, FILELIST_FNAME_RAW_SZ, bkpinfo->tmpdir, archiving_set_no);
     1068        sprintf(archiving_afioball_fname, AFIOBALL_FNAME_RAW_SZ,
     1069                bkpinfo->tmpdir, archiving_set_no, bkpinfo->zip_suffix);
     1070        sprintf(archiving_filelist_fname, FILELIST_FNAME_RAW_SZ,
     1071                bkpinfo->tmpdir, archiving_set_no);
    10401072        if (!does_file_exist(archiving_filelist_fname)) {
    1041             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);
    1042             mr_free(archiving_afioball_fname);
     1073            log_msg(3,
     1074                    "%s[%d:%d] - well, I would archive %d, except that it doesn't exist. I'll stop now.",
     1075                    FORTY_SPACES, getpid(), this_thread_no,
     1076                    archiving_set_no);
    10431077            break;
    10441078        }
    10451079
    1046         mr_asprintf(tmp, AFIOBALL_FNAME_RAW_SZ, bkpinfo->tmpdir, archiving_set_no - ARCH_BUFFER_NUM, bkpinfo->zip_suffix);
     1080        sprintf(tmp, AFIOBALL_FNAME_RAW_SZ, bkpinfo->tmpdir,
     1081                archiving_set_no - ARCH_BUFFER_NUM, bkpinfo->zip_suffix);
    10471082        if (does_file_exist(tmp)) {
    1048             log_msg(4, "%s[%d:%d] - waiting for storer", FORTY_SPACES, getpid(), this_thread_no);
     1083            log_msg(4, "%s[%d:%d] - waiting for storer", FORTY_SPACES,
     1084                    getpid(), this_thread_no);
    10491085            while (does_file_exist(tmp)) {
    10501086                sleep(1);
     
    10521088            log_msg(4, "[%d] - continuing", getpid());
    10531089        }
    1054         mr_free(tmp);
    1055 
    1056         log_msg(4, "%s[%d:%d] - EXATing %d...", FORTY_SPACES, getpid(), this_thread_no, archiving_set_no);
    1057 
     1090
     1091        log_msg(4, "%s[%d:%d] - EXATing %d...", FORTY_SPACES, getpid(),
     1092                this_thread_no, archiving_set_no);
    10581093        if (g_getfattr) {
    1059             mr_asprintf(curr_xattr_list_fname, XATTR_LIST_FNAME_RAW_SZ, bkpinfo->tmpdir, archiving_set_no);
     1094            sprintf(curr_xattr_list_fname, XATTR_LIST_FNAME_RAW_SZ,
     1095                bkpinfo->tmpdir, archiving_set_no);
    10601096            get_fattr_list(archiving_filelist_fname, curr_xattr_list_fname);
    1061             mr_free(curr_xattr_list_fname);
    10621097        }
    10631098        if (g_getfacl) {
    1064             mr_asprintf(curr_acl_list_fname, ACL_LIST_FNAME_RAW_SZ, bkpinfo->tmpdir, archiving_set_no);
     1099            sprintf(curr_acl_list_fname, ACL_LIST_FNAME_RAW_SZ,
     1100                bkpinfo->tmpdir, archiving_set_no);
    10651101            get_acl_list(archiving_filelist_fname, curr_acl_list_fname);
    1066             mr_free(curr_acl_list_fname);
    1067         }
    1068 
    1069         log_msg(4, "%s[%d:%d] - archiving %d...", FORTY_SPACES, getpid(), this_thread_no, archiving_set_no);
    1070         res = archive_this_fileset(archiving_filelist_fname, archiving_afioball_fname, archiving_set_no);
    1071         mr_free(archiving_afioball_fname);
    1072 
     1102        }
     1103
     1104        log_msg(4, "%s[%d:%d] - archiving %d...", FORTY_SPACES, getpid(),
     1105                this_thread_no, archiving_set_no);
     1106        res =
     1107            archive_this_fileset(archiving_filelist_fname,
     1108                                 archiving_afioball_fname,
     1109                                 archiving_set_no);
    10731110        retval += res;
    10741111
    10751112        if (res) {
    1076             log_to_screen("Errors occurred while archiving set %ld. Please review logs.", archiving_set_no);
    1077         }
    1078 
     1113            sprintf(tmp,
     1114                    "Errors occurred while archiving set %ld. Please review logs.",
     1115                    archiving_set_no);
     1116            log_to_screen(tmp);
     1117        }
    10791118        if (!semaphore_p()) {
    1080             mr_free(archiving_filelist_fname);
    10811119            fatal_error("Cannot get semaphore P");
    10821120        }
     
    10891127
    10901128        if (!semaphore_v()) {
    1091             mr_free(archiving_filelist_fname);
    10921129            fatal_error("Cannot get semaphore V");
    10931130        }
    1094         log_msg(4, "%s[%d:%d] - archived %d OK", FORTY_SPACES, getpid(), this_thread_no, archiving_set_no);
     1131        log_msg(4, "%s[%d:%d] - archived %d OK", FORTY_SPACES, getpid(),
     1132                this_thread_no, archiving_set_no);
    10951133        archiving_set_no++;
    1096 
    1097         mr_free(archiving_filelist_fname);
    1098         mr_asprintf(archiving_filelist_fname, FILELIST_FNAME_RAW_SZ, bkpinfo->tmpdir, archiving_set_no);
    1099     }
    1100     mr_free(archiving_filelist_fname);
    1101 
     1134    }
    11021135    if (!semaphore_p()) {
    11031136        fatal_error("Cannot get semaphore P");
     
    11071140        fatal_error("Cannot get semaphore V");
    11081141    }
    1109     log_msg(3, "%s[%d:%d] - exiting", FORTY_SPACES, getpid(), this_thread_no);
     1142    log_msg(3, "%s[%d:%d] - exiting", FORTY_SPACES, getpid(),
     1143            this_thread_no);
     1144    paranoid_free(archiving_filelist_fname);
     1145    paranoid_free(archiving_afioball_fname);
     1146    paranoid_free(curr_xattr_list_fname);
     1147    paranoid_free(curr_acl_list_fname);
     1148    paranoid_free(tmp);
    11101149    pthread_exit(NULL);
    11111150}
     
    11891228
    11901229    /*@ buffers *********************************** */
    1191     char *command = NULL;
    1192     char *tmpfile = NULL;
    1193     char *data_disks_file = NULL;
     1230    char *command, *tmpfile, *data_disks_file;
    11941231
    11951232    assert(bkpinfo != NULL);
    1196     mr_asprintf(data_disks_file, "%s/all.tar.gz", bkpinfo->tmpdir);
    1197 
    1198     snprintf(g_serial_string, MAX_STR_LEN - 8, "%s", call_program_and_get_last_line_of_output("dd if=/dev/urandom bs=16 count=1 2> /dev/null | hexdump | tr -s ' ' '0' | head -n1"));
     1233    malloc_string(command);
     1234    malloc_string(tmpfile);
     1235    malloc_string(data_disks_file);
     1236    sprintf(data_disks_file, "%s/all.tar.gz", bkpinfo->tmpdir);
     1237
     1238    snprintf(g_serial_string, MAX_STR_LEN - 8, "%s",
     1239             call_program_and_get_last_line_of_output("dd \
     1240if=/dev/urandom bs=16 count=1 2> /dev/null | \
     1241hexdump | tr -s ' ' '0' | head -n1"));
    11991242    strip_spaces(g_serial_string);
    12001243    strcat(g_serial_string, "...word.");
     
    12021245    assert(strlen(g_serial_string) < MAX_STR_LEN);
    12031246
    1204     mr_asprintf(tmpfile, "%s/archives/SERIAL-STRING", bkpinfo->scratchdir);
     1247    sprintf(tmpfile, "%s/archives/SERIAL-STRING", bkpinfo->scratchdir);
    12051248    if (write_one_liner_data_file(tmpfile, g_serial_string)) {
    12061249        log_msg(1, "%ld: Failed to write serial string", __LINE__);
    12071250    }
    1208     mr_free(tmpfile);
    12091251
    12101252    mvaddstr_and_log_it(g_currentY, 0, "Preparing to archive your data");
     
    12271269        }
    12281270    }
    1229     mr_free(data_disks_file);
    1230 
    1231     mr_asprintf(command, "rm -f %s/%s/%s-[1-9]*.iso", bkpinfo->isodir, bkpinfo->netfs_remote_dir, bkpinfo->prefix);
     1271
     1272    sprintf(command, "rm -f %s/%s/%s-[1-9]*.iso", bkpinfo->isodir,
     1273            bkpinfo->netfs_remote_dir, bkpinfo->prefix);
    12321274    paranoid_system(command);
    1233     mr_free(command);
    1234 
    12351275    wipe_archives(bkpinfo->scratchdir);
    12361276    mvaddstr_and_log_it(g_currentY++, 74, "Done.");
     
    12411281                                     BLK_START_OF_BACKUP);
    12421282    }
     1283    paranoid_free(command);
     1284    paranoid_free(tmpfile);
     1285    paranoid_free(data_disks_file);
    12431286    return (retval);
    12441287}
     
    13131356
    13141357    /*@ buffers ********************************************** */
    1315     char *storing_filelist_fname = NULL;
    1316     char *storing_afioball_fname = NULL;
     1358    char *storing_filelist_fname;
     1359    char *storing_afioball_fname;
    13171360    char *tmp = NULL;
    13181361    char *media_usage_comment = NULL;
     
    13311374    assert(bkpinfo != NULL);
    13321375    malloc_string(result_str);
    1333     transfer_block = malloc(sizeof(struct s_bkpinfo) + BKPINFO_LOC_OFFSET + 64);
    1334     memset((void *) transfer_block, 0, sizeof(struct s_bkpinfo) + BKPINFO_LOC_OFFSET + 64);
     1376    malloc_string(curr_xattr_list_fname);
     1377    malloc_string(curr_acl_list_fname);
     1378    malloc_string(storing_filelist_fname);
     1379    malloc_string(storing_afioball_fname);
     1380    transfer_block =
     1381        malloc(sizeof(struct s_bkpinfo) + BKPINFO_LOC_OFFSET + 64);
     1382    memset((void *) transfer_block, 0,
     1383           sizeof(struct s_bkpinfo) + BKPINFO_LOC_OFFSET + 64);
    13351384    p_last_set_archived = (int *) transfer_block;
    13361385    p_archival_threads_running = (int *) (transfer_block + 4);
    13371386    p_next_set_to_archive = (int *) (transfer_block + 8);
    13381387    p_list_of_fileset_flags = (char *) (transfer_block + 12);
    1339     memcpy((void *) (transfer_block + BKPINFO_LOC_OFFSET), (void *) bkpinfo, sizeof(struct s_bkpinfo));
     1388    memcpy((void *) (transfer_block + BKPINFO_LOC_OFFSET),
     1389           (void *) bkpinfo, sizeof(struct s_bkpinfo));
    13401390    pvp = &vp;
    13411391    vp = (void *) result_str;
     
    13491399                       "Please wait. This may take a couple of hours.",
    13501400                       "Working...",
    1351                        (long)get_last_filelist_number() + 1L);
     1401                       get_last_filelist_number() + 1);
    13521402
    13531403    log_msg(5, "We're gonna party like it's your birthday.");
     
    13881438            if (!get_bit_N_of_array
    13891439                (p_list_of_fileset_flags, storing_set_no)) {
    1390             misc_counter_that_is_not_important = (misc_counter_that_is_not_important + 1) % 5;
     1440            misc_counter_that_is_not_important =
     1441                (misc_counter_that_is_not_important + 1) % 5;
    13911442            /* BCO the media_usage_comment is not really initialized there !
    13921443            if (!misc_counter_that_is_not_important) {
     
    13951446            */
    13961447            sleep(1);
    1397             } else {
     1448            } else
    13981449                // store set N
    1399                 mr_asprintf(storing_filelist_fname, FILELIST_FNAME_RAW_SZ, bkpinfo->tmpdir, storing_set_no);
    1400                 mr_asprintf(storing_afioball_fname, AFIOBALL_FNAME_RAW_SZ, bkpinfo->tmpdir, storing_set_no, bkpinfo->zip_suffix);
     1450            {
     1451                sprintf(storing_filelist_fname, FILELIST_FNAME_RAW_SZ,
     1452                        bkpinfo->tmpdir, storing_set_no);
     1453                sprintf(storing_afioball_fname, AFIOBALL_FNAME_RAW_SZ,
     1454                        bkpinfo->tmpdir, storing_set_no, bkpinfo->zip_suffix);
    14011455                if (g_getfattr) {
    1402                     mr_asprintf(curr_xattr_list_fname, XATTR_LIST_FNAME_RAW_SZ, bkpinfo->tmpdir, storing_set_no);
     1456                    sprintf(curr_xattr_list_fname, XATTR_LIST_FNAME_RAW_SZ,
     1457                        bkpinfo->tmpdir, storing_set_no);
    14031458                }
    14041459                if (g_getfacl) {
    1405                     mr_asprintf(curr_acl_list_fname, ACL_LIST_FNAME_RAW_SZ, bkpinfo->tmpdir, storing_set_no);
     1460                    sprintf(curr_acl_list_fname, ACL_LIST_FNAME_RAW_SZ,
     1461                        bkpinfo->tmpdir, storing_set_no);
    14061462                }
    14071463
     
    14141470                    sleep(5);
    14151471                }
     1472                mr_asprintf(media_usage_comment, "%s", percent_media_full_comment());
    14161473                /* copy to CD (scratchdir) ... and an actual CD-R if necessary */
    14171474                if (IS_THIS_A_STREAMING_BACKUP(bkpinfo->backup_media_type)) {
    14181475                    register_in_tape_catalog(fileset, storing_set_no, -1,
    14191476                                         storing_afioball_fname);
    1420                     maintain_collection_of_recent_archives(bkpinfo->tmpdir, storing_afioball_fname);
     1477                    maintain_collection_of_recent_archives(bkpinfo->tmpdir,
     1478                                                       storing_afioball_fname);
    14211479                    log_it("Writing EXAT files");
    14221480                    res +=
     
    14521510                retval += res;
    14531511                g_current_progress++;
    1454                 mr_asprintf(media_usage_comment, "%s", percent_media_full_comment());
    14551512                update_progress_form(media_usage_comment);
    14561513                mr_free(media_usage_comment);
    14571514                if (res) {
    1458                     log_to_screen("Failed to add archive %ld's files to CD dir\n", storing_set_no);
    1459                     fatal_error("Is your hard disk full? If not, please send the author the logfile.");
     1515                    mr_asprintf(tmp, "Failed to add archive %ld's files to CD dir\n",
     1516                        storing_set_no);
     1517                    log_to_screen(tmp);
     1518                    paranoid_free(tmp);
     1519                    fatal_error
     1520                        ("Is your hard disk full? If not, please send the author the logfile.");
    14601521                }
    14611522                storing_set_no++;
    14621523                //      sleep(2);
    1463                 if (g_getfacl) {
    1464                     mr_free(curr_acl_list_fname);
    1465                 }
    1466                 if (g_getfattr) {
    1467                     mr_free(curr_xattr_list_fname);
    1468                 }
    1469                 mr_free(storing_filelist_fname);
    1470                 mr_free(storing_afioball_fname);
    14711524        }
    14721525    }
     
    14871540    }
    14881541    log_to_screen(tmp);
    1489     mr_free(tmp);
     1542    paranoid_free(tmp);
    14901543
    14911544    paranoid_free(transfer_block);
    14921545    paranoid_free(result_str);
     1546    paranoid_free(storing_filelist_fname);
     1547    paranoid_free(storing_afioball_fname);
     1548    paranoid_free(curr_xattr_list_fname);
     1549    paranoid_free(curr_acl_list_fname);
    14931550    return (retval);
    14941551}
     
    15411598    mr_asprintf(tmp, "chmod 700 %s", bkpinfo->scratchdir);
    15421599    run_program_and_log_output(tmp, FALSE);
    1543     mr_free(tmp);
     1600    paranoid_free(tmp);
    15441601    if (chdir(bkpinfo->scratchdir)) {
    15451602        // FIXME
     
    15511608    log_msg(1, message_to_screen);
    15521609
    1553     if (bkpinfo->media_device) {
    1554         mr_asprintf(tmp1, "%s1", bkpinfo->media_device);
    1555     } else {
    1556         mr_asprintf(tmp1, "");
    1557     }
     1610    mr_asprintf(tmp1, "%s1", bkpinfo->media_device);
    15581611    if (is_this_device_mounted(tmp1)) {
    15591612        log_msg(1, "USB device mounted. Remounting it at the right place");
    15601613        mr_asprintf(tmp, "umount %s", tmp1);
    15611614        run_program_and_log_output(tmp, FALSE);
    1562         mr_free(tmp);
    1563     }
    1564     mr_free(tmp1);
     1615        paranoid_free(tmp);
     1616    }
     1617    paranoid_free(tmp1);
    15651618
    15661619    log_msg(1, "Mounting USB device.");
     
    15681621    mr_asprintf(tmp, "mkdir -p %s", tmp1);
    15691622    run_program_and_log_output(tmp, FALSE);
    1570     mr_free(tmp);
    1571 
     1623    paranoid_free(tmp);
    15721624
    15731625    /* Mindi always create one single parition on the USB dev */
    15741626    mr_asprintf(tmp, "mount %s1 %s", bkpinfo->media_device, tmp1);
    15751627    run_program_and_log_output(tmp, FALSE);
    1576     mr_free(tmp);
     1628    paranoid_free(tmp);
    15771629
    15781630    if (bkpinfo->nonbootable_backup) {
     
    15901642        }
    15911643        log_to_screen(result_sz);
    1592         mr_free(result_sz);
    1593         mr_free(tmp);
     1644        paranoid_free(result_sz);
     1645        paranoid_free(tmp);
    15941646        retval += res;
    15951647
     
    15971649        mr_asprintf(tmp,"mkdir %s/archive", bkpinfo->scratchdir);
    15981650        run_program_and_log_output(tmp, FALSE);
    1599         mr_free(tmp);
     1651        paranoid_free(tmp);
    16001652    }
    16011653    paranoid_free(message_to_screen);
     
    16051657        mr_asprintf(tmp, "umount %s1", bkpinfo->media_device);
    16061658        run_program_and_log_output(tmp, FALSE);
    1607         mr_free(tmp);
     1659        paranoid_free(tmp);
    16081660    }
    16091661
     
    16431695
    16441696    /*@ buffers ****************************************** */
    1645     char *tmp = NULL;
    1646     char *tmp2 = NULL;
     1697    char *tmp;
    16471698    char *old_pwd;
    16481699    char *result_sz = NULL;
    16491700    char *message_to_screen = NULL;
    16501701    char *sz_blank_disk = NULL;
    1651     char *fnam = NULL;
    1652     char *tmp3 = NULL;
     1702    char *fnam;
     1703    char *tmp2;
     1704    char *tmp3;
    16531705    char *isofs_cmd = NULL;
    16541706    char *full_isofs_cmd = NULL;
     
    16581710    malloc_string(old_pwd);
    16591711    malloc_string(fnam);
     1712    tmp = malloc(1200);
     1713    tmp2 = malloc(1200);
     1714    tmp3 = malloc(1200);
    16601715    assert(bkpinfo != NULL);
    16611716    assert_string_is_neither_NULL_nor_zerolength(destfile);
    16621717
    1663     /* Copy the files needed by isolinux in the right dir */
    1664     mr_asprintf(tmp, "%s/isolinux.bin", bkpinfo->scratchdir);
    1665     mr_asprintf(tmp2, "%s/isolinux.bin", bkpinfo->tmpdir);
     1718    sprintf(tmp, "%s/isolinux.bin", bkpinfo->scratchdir);
     1719    sprintf(tmp2, "%s/isolinux.bin", bkpinfo->tmpdir);
    16661720    if (does_file_exist(tmp)) {
    1667         mr_asprintf(tmp3, "cp -f %s %s", tmp, tmp2);
     1721        sprintf(tmp3, "cp -f %s %s", tmp, tmp2);
    16681722        paranoid_system(tmp3);
    1669         mr_free(tmp3);
    16701723    }
    16711724    if (!does_file_exist(tmp) && does_file_exist(tmp2)) {
    1672         mr_asprintf(tmp3, "cp -f %s %s", tmp2, tmp);
     1725        sprintf(tmp3, "cp -f %s %s", tmp2, tmp);
    16731726        paranoid_system(tmp3);
    1674         mr_free(tmp3);
    1675     }
    1676     mr_free(tmp2);
    1677     mr_free(tmp3);
     1727    }
     1728    free(tmp2);
     1729    free(tmp3);
     1730    tmp2 = NULL;
     1731    tmp3 = NULL;
    16781732    if (bkpinfo->backup_media_type == iso && bkpinfo->manual_cd_tray) {
    16791733        popup_and_OK("Please insert new media and press Enter.");
    16801734    }
    16811735
    1682     log_msg(2, "make_iso_fs --- scratchdir=%s --- destfile=%s", bkpinfo->scratchdir, destfile);
     1736    log_msg(2, "make_iso_fs --- scratchdir=%s --- destfile=%s",
     1737            bkpinfo->scratchdir, destfile);
    16831738    tmp2 = getcwd(old_pwd, MAX_STR_LEN - 1);
    1684     if (! tmp2) {
    1685         //FIXME
    1686     }
    1687     mr_asprintf(tmp, "chmod 700 %s", bkpinfo->scratchdir);
     1739    sprintf(tmp, "chmod 700 %s", bkpinfo->scratchdir);
    16881740    run_program_and_log_output(tmp, FALSE);
    1689     mr_free(tmp);
    1690 
    16911741    if (chdir(bkpinfo->scratchdir)) {
    16921742        // FIXME
     
    16941744
    16951745    if (bkpinfo->call_before_iso[0] != '\0') {
    1696         mr_asprintf(message_to_screen, "Running pre-ISO call for CD#%d", g_current_media_number);
    1697         res = eval_call_to_make_ISO(bkpinfo->call_before_iso, destfile, g_current_media_number, MONDO_LOGFILE, message_to_screen);
     1746        mr_asprintf(message_to_screen, "Running pre-ISO call for CD#%d",
     1747                g_current_media_number);
     1748        res =
     1749            eval_call_to_make_ISO(bkpinfo->call_before_iso,
     1750                                  destfile, g_current_media_number,
     1751                                  MONDO_LOGFILE, message_to_screen);
    16981752        if (res) {
    16991753            mr_strcat(message_to_screen, "...failed");
     
    17091763    if (bkpinfo->call_make_iso[0] != '\0') {
    17101764        log_msg(2, "bkpinfo->call_make_iso = %s", bkpinfo->call_make_iso);
     1765        sprintf(tmp, "%s/archives/NOT-THE-LAST", bkpinfo->scratchdir);
    17111766        mds = media_descriptor_string(bkpinfo->backup_media_type);
    17121767        mr_asprintf(message_to_screen, "Making an ISO (%s #%d)", mds, g_current_media_number);
     
    17191774        } else {
    17201775            res =
    1721                 eval_call_to_make_ISO(bkpinfo->call_make_iso, bkpinfo->scratchdir, g_current_media_number, MONDO_LOGFILE, message_to_screen);
     1776                eval_call_to_make_ISO(bkpinfo->call_make_iso,
     1777                                      bkpinfo->scratchdir,
     1778                                      g_current_media_number,
     1779                                      MONDO_LOGFILE, message_to_screen);
    17221780            if (res) {
    17231781                log_to_screen("%s...failed to write", message_to_screen);
    17241782            } else {
    17251783                log_to_screen("%s...OK", message_to_screen);
    1726                 mr_asprintf(tmp, "tail -n10 %s | grep -F ':-('", MONDO_LOGFILE);
     1784                sprintf(tmp, "tail -n10 %s | grep -F ':-('", MONDO_LOGFILE);
    17271785                if (!run_program_and_log_output(tmp, 1)) {
    17281786                    log_to_screen
    17291787                        ("Despite nonfatal errors, growisofs confirms the write was successful.");
    17301788                }
    1731                 mr_free(tmp);
    17321789            }
    17331790            retval += res;
    17341791#ifdef DVDRWFORMAT
    1735             mr_asprintf(tmp, "tail -n8 %s | grep 'blank=full.*dvd-compat.*DAO'", MONDO_LOGFILE);
     1792            sprintf(tmp,
     1793                    "tail -n8 %s | grep 'blank=full.*dvd-compat.*DAO'",
     1794                    MONDO_LOGFILE);
    17361795            if (g_backup_media_type == dvd
    17371796                && (res || !run_program_and_log_output(tmp, 1))) {
     
    17411800                /* reset error counter before trying to blank DVD */
    17421801                retval -= res;
    1743                 sync();
     1802                paranoid_system("sync");
    17441803                pause_for_N_seconds(5, "Letting DVD drive settle");
    17451804
     
    17511810                }
    17521811                pause_for_N_seconds(5, "Letting DVD drive settle");
    1753                 if (bkpinfo->media_device) {
    1754                     mr_asprintf(sz_blank_disk, "dvd+rw-format -force %s", bkpinfo->media_device);
    1755                 } else {
    1756                     mr_asprintf(sz_blank_disk, "dvd+rw-format");
    1757                 }
     1812                mr_asprintf(sz_blank_disk, "dvd+rw-format -force %s", bkpinfo->media_device);
    17581813                log_msg(3, "sz_blank_disk = '%s'", sz_blank_disk);
    1759                 res = run_external_binary_with_percentage_indicator_NEW("Blanking DVD disk", sz_blank_disk);
     1814                res =
     1815                    run_external_binary_with_percentage_indicator_NEW
     1816                    ("Blanking DVD disk", sz_blank_disk);
    17601817                if (res) {
    1761                     log_to_screen("Warning - format failed. (Was it a DVD-R?) Sleeping for 5 seconds to take a breath...");
    1762                     pause_for_N_seconds(5, "Letting DVD drive settle... and trying again.");
    1763                     res = run_external_binary_with_percentage_indicator_NEW("Blanking DVD disk", sz_blank_disk);
     1818                    log_to_screen
     1819                        ("Warning - format failed. (Was it a DVD-R?) Sleeping for 5 seconds to take a breath...");
     1820                    pause_for_N_seconds(5,
     1821                                        "Letting DVD drive settle... and trying again.");
     1822                    res =
     1823                        run_external_binary_with_percentage_indicator_NEW
     1824                        ("Blanking DVD disk", sz_blank_disk);
    17641825                    if (res) {
    17651826                        log_to_screen("Format failed a second time.");
     
    17771838                }
    17781839                pause_for_N_seconds(5, "Letting DVD drive settle");
    1779                 res = eval_call_to_make_ISO(bkpinfo->call_make_iso, bkpinfo->scratchdir, g_current_media_number, MONDO_LOGFILE, message_to_screen);
     1840                res =
     1841                    eval_call_to_make_ISO(bkpinfo->call_make_iso,
     1842                                          bkpinfo->scratchdir,
     1843                                          g_current_media_number,
     1844                                          MONDO_LOGFILE,
     1845                                          message_to_screen);
    17801846                retval += res;
    17811847                if (!bkpinfo->please_dont_eject) {
     
    17901856                }
    17911857            }
    1792             mr_free(tmp);
    17931858#endif
    17941859            if (g_backup_media_type == dvd && !bkpinfo->please_dont_eject) {
     
    18111876            log_msg(1, "Making nonbootable backup");
    18121877            mr_asprintf(full_isofs_cmd, "%s%s-o '_ISO_' -V _CD#_ .",isofs_cmd,MONDO_MKISOFS);
    1813             res = eval_call_to_make_ISO(full_isofs_cmd, destfile, g_current_media_number, MONDO_LOGFILE, message_to_screen);
     1878            res = eval_call_to_make_ISO(full_isofs_cmd,
     1879                                      destfile, g_current_media_number,
     1880                                      MONDO_LOGFILE, message_to_screen);
    18141881            mr_free(full_isofs_cmd);
    18151882        } else {
     
    18211888
    18221889
    1823             log_msg(1, "make_cd_use_lilo is actually %d", bkpinfo->make_cd_use_lilo);
     1890            log_msg(1, "make_cd_use_lilo is actually %d",
     1891                    bkpinfo->make_cd_use_lilo);
    18241892            if (bkpinfo->make_cd_use_lilo) {
    18251893                log_msg(1, "make_cd_use_lilo = TRUE");
     
    18271895                log_msg(1, "IA64 --> elilo");
    18281896                mr_asprintf(full_isofs_cmd, "%s%s-o '_ISO_' -V _CD#_ .",isofs_cmd,MONDO_MKISOFS_REGULAR_ELILO);
    1829                 res = eval_call_to_make_ISO(full_isofs_cmd, destfile, g_current_media_number, MONDO_LOGFILE, message_to_screen);
     1897                res = eval_call_to_make_ISO(full_isofs_cmd,
     1898                                            destfile,
     1899                                            g_current_media_number,
     1900                                            MONDO_LOGFILE,
     1901                                            message_to_screen);
    18301902                mr_free(full_isofs_cmd);
    18311903#else
    18321904                log_msg(1, "Non-ia64 --> lilo");
    18331905                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);
    1834                 // FIXME: fixed boot size probably wrong. lilo to be removed
    1835                 res = eval_call_to_make_ISO(full_isofs_cmd, destfile, g_current_media_number, MONDO_LOGFILE, message_to_screen);
     1906                res =
     1907                    // FIXME: fixed boot size probably wrong. lilo to be removed
     1908                    eval_call_to_make_ISO(full_isofs_cmd,
     1909                                          destfile, g_current_media_number,
     1910                                          MONDO_LOGFILE,
     1911                                          message_to_screen);
    18361912                mr_free(full_isofs_cmd);
    18371913#endif
     
    18401916                log_msg(1, "Isolinux");
    18411917                mr_asprintf(full_isofs_cmd, "%s%s-o '_ISO_' -V _CD#_ .",isofs_cmd,MONDO_MKISOFS_REGULAR_SYSLINUX);
    1842                 res = eval_call_to_make_ISO(full_isofs_cmd, destfile, g_current_media_number, MONDO_LOGFILE, message_to_screen);
     1918                res =
     1919                    eval_call_to_make_ISO(full_isofs_cmd,
     1920                                          destfile, g_current_media_number,
     1921                                          MONDO_LOGFILE,
     1922                                          message_to_screen);
    18431923                mr_free(full_isofs_cmd);
    18441924            }
     
    18601940        || bkpinfo->backup_media_type == cdrw) {
    18611941        if (is_this_device_mounted(bkpinfo->media_device)) {
    1862             log_msg(2, "Warning - %s mounted. I'm unmounting it before I burn to it.", bkpinfo->media_device);
    1863             mr_asprintf(tmp, "umount %s", bkpinfo->media_device);
     1942            log_msg(2,
     1943                    "Warning - %s mounted. I'm unmounting it before I burn to it.",
     1944                    bkpinfo->media_device);
     1945            sprintf(tmp, "umount %s", bkpinfo->media_device);
    18641946            run_program_and_log_output(tmp, FALSE);
    1865             mr_free(tmp);
    18661947        }
    18671948    }
     
    18731954        mr_free(mds);
    18741955        pause_and_ask_for_cdr(2, &cd_is_mountable);
    1875         res = eval_call_to_make_ISO(bkpinfo->call_burn_iso, destfile, g_current_media_number, MONDO_LOGFILE, message_to_screen);
     1956        res =
     1957            eval_call_to_make_ISO(bkpinfo->call_burn_iso,
     1958                                  destfile, g_current_media_number,
     1959                                  MONDO_LOGFILE, message_to_screen);
    18761960        if (res) {
    18771961            mr_strcat(message_to_screen, "...failed");
     
    18891973        mr_asprintf(message_to_screen, "Running post-ISO call (%s #%d)", mds, g_current_media_number);
    18901974        mr_free(mds);
    1891         res = eval_call_to_make_ISO(bkpinfo->call_after_iso, destfile, g_current_media_number, MONDO_LOGFILE, message_to_screen);
     1975        res =
     1976            eval_call_to_make_ISO(bkpinfo->call_after_iso,
     1977                                  destfile, g_current_media_number,
     1978                                  MONDO_LOGFILE, message_to_screen);
    18921979        if (res) {
    18931980            mr_strcat(message_to_screen, "...failed");
     
    19572044
    19582045    /*@ pointers ******************************************* */
    1959     FILE *fin = NULL;
     2046    FILE *fin;
    19602047    char *p;
    19612048    char *q;
     
    19632050    /*@ buffers ******************************************** */
    19642051    char *tmp = NULL;
    1965     char *bigfile_fname = NULL;
     2052    char *bigfile_fname;
    19662053    char *sz_devfile = NULL;
    19672054    char *ntfsprog_fifo = NULL;
     
    19992086    log_to_screen(tmp);
    20002087    noof_biggie_files = count_lines_in_file(biggielist_fname);
    2001     open_progress_form("Backing up big files", tmp, "Please wait. This may take some time.", "", estimated_total_noof_slices);
    2002     mr_free(tmp);
     2088    open_progress_form("Backing up big files", tmp,
     2089                       "Please wait. This may take some time.", "",
     2090                       estimated_total_noof_slices);
     2091    paranoid_free(tmp);
    20032092
    20042093    if (!(fin = fopen(biggielist_fname, "r"))) {
     
    20322121            log_msg(2, "bigfile_fname = %s", bigfile_fname);
    20332122            use_ntfsprog = FALSE;
    2034             if (!strncmp(bigfile_fname, "/dev/", 5) && is_dev_an_NTFS_dev(bigfile_fname)) {
     2123            if (!strncmp(bigfile_fname, "/dev/", 5)
     2124                && is_dev_an_NTFS_dev(bigfile_fname)) {
    20352125                use_ntfsprog = TRUE;
    2036                 log_msg(2, "Calling ntfsclone in background because %s is an NTFS partition", bigfile_fname);
    2037                 mr_asprintf(sz_devfile, "%s/%d.%d.000", bkpinfo->tmpdir, (int) (random() % 32768), (int) (random() % 32768));
     2126                log_msg(2,
     2127                        "Calling ntfsclone in background because %s is an NTFS partition",
     2128                        bigfile_fname);
     2129                mr_asprintf(sz_devfile, "%s/%d.%d.000", bkpinfo->tmpdir,
     2130                        (int) (random() % 32768),
     2131                        (int) (random() % 32768));
    20382132                mkfifo(sz_devfile, 0x770);
    20392133                ntfsprog_fifo = sz_devfile;
     
    20432137                    fatal_error("Fork failure");
    20442138                case 0:
    2045                     log_msg(2, "CHILD - fip - calling feed_into_ntfsprog(%s, %s)", bigfile_fname, sz_devfile);
     2139                    log_msg(2,
     2140                            "CHILD - fip - calling feed_into_ntfsprog(%s, %s)",
     2141                            bigfile_fname, sz_devfile);
    20462142                    res = feed_into_ntfsprog(bigfile_fname, sz_devfile);
    20472143                    /* BCO/BERLIOS Does the child need to unalocate memory as well ?
    2048                     mr_free(bigfile_fname);
     2144                    paranoid_free(bigfile_fname);
    20492145                    mr_free(sz_devfile);
    20502146                    */
     
    20522148                    break;
    20532149                default:
    2054                     log_msg(2, "feed_into_ntfsprog() called in background --- pid=%ld", (long int) (pid));
     2150                    log_msg(2,
     2151                            "feed_into_ntfsprog() called in background --- pid=%ld",
     2152                            (long int) (pid));
    20552153                }
    20562154            }
     
    20622160            // Whether partition or biggiefile, just do your thang :-)
    20632161            if (IS_THIS_A_STREAMING_BACKUP(bkpinfo->backup_media_type)) {
    2064                 write_header_block_to_stream(biggie_fsize, bigfile_fname, use_ntfsprog ?  BLK_START_A_PIHBIGGIE : BLK_START_A_NORMBIGGIE);
     2162                write_header_block_to_stream(biggie_fsize, bigfile_fname,
     2163                                             use_ntfsprog ?
     2164                                             BLK_START_A_PIHBIGGIE :
     2165                                             BLK_START_A_NORMBIGGIE);
    20652166            }
    2066             res = slice_up_file_etc(bigfile_fname, ntfsprog_fifo, biggie_file_number, noof_biggie_files, use_ntfsprog);
     2167            res =
     2168                slice_up_file_etc(bigfile_fname,
     2169                                  ntfsprog_fifo, biggie_file_number,
     2170                                  noof_biggie_files, use_ntfsprog);
    20672171
    20682172            /* Free it here as ntfsprog_fifo is not used anymore */
     
    20932197            }
    20942198        }
     2199#ifndef _XWIN
    20952200        if (!g_text_mode) {
    20962201            newtDrawRootText(0, g_noof_rows - 2, tmp);
    20972202            newtRefresh();
    20982203        }
    2099         mr_free(tmp);
    2100     }
    2101     mr_free(bigfile_fname);
    2102 
     2204#endif
     2205        paranoid_free(tmp);
     2206    }
    21032207    log_msg(1, "Finished backing up bigfiles");
    21042208    log_msg(1, "estimated slices = %ld; actual slices = %ld",
     
    21062210    close_progress_form();
    21072211    paranoid_fclose(fin);
     2212    paranoid_free(bigfile_fname);
    21082213    return (retval);
    21092214}
     
    21662271        retval += res;
    21672272        if (res) {
    2168             log_to_screen("Errors occurred while archiving set %ld. Perhaps your live filesystem changed?", curr_set_no);
    2169         }
     2273            mr_asprintf(tmp, "Errors occurred while archiving set %ld. Perhaps your live filesystem changed?", curr_set_no);
     2274            log_to_screen(tmp);
     2275            mr_free(tmp);
     2276        }
     2277
     2278        mr_asprintf(media_usage_comment, "%s", percent_media_full_comment());
    21702279
    21712280        /* copy to CD (scratchdir) ... and an actual CD-R if necessary */
     
    22102319        retval += res;
    22112320        g_current_progress++;
    2212 
    2213         mr_asprintf(media_usage_comment, "%s", percent_media_full_comment());
    22142321        update_progress_form(media_usage_comment);
    22152322        mr_free(media_usage_comment);
    22162323
    22172324        if (res) {
    2218             log_to_screen("Failed to add archive %ld's files to CD dir\n", curr_set_no);
    2219             fatal_error("Is your hard disk is full? If not, please send the author the logfile.");
     2325            mr_asprintf(tmp, "Failed to add archive %ld's files to CD dir\n", curr_set_no);
     2326            log_to_screen(tmp);
     2327            mr_free(tmp);
     2328            fatal_error
     2329                ("Is your hard disk is full? If not, please send the author the logfile.");
    22202330        }
    22212331        mr_free(curr_filelist_fname);
     
    23182428    }
    23192429
    2320     mr_asprintf(command, "cp %s/biggielist.txt %s", bkpinfo->tmpdir, biggielist);
     2430    mr_asprintf(command, "cp %s/biggielist.txt %s", bkpinfo->tmpdir,
     2431            biggielist);
    23212432    paranoid_system(command);
    23222433    mr_free(command);
     
    23322443    if (g_getfattr) {
    23332444        get_fattr_list(biggielist, xattr_fname);
    2334         mr_asprintf(command, "cp %s %s/archives/", xattr_fname, bkpinfo->scratchdir);
     2445        mr_asprintf(command, "cp %s %s/archives/", xattr_fname,
     2446            bkpinfo->scratchdir);
    23352447        paranoid_system(command);
    23362448        mr_free(command);
     
    26212733    /*@ buffers ********************************************* */
    26222734    char *tmp = NULL;
    2623     char *cdrom_dev = NULL;
    2624     char *cdrw_dev = NULL;
     2735    char *cdrom_dev;
     2736    char *cdrw_dev;
    26252737    char *our_serial_str = NULL;
    26262738    bool ok_go_ahead_burn_it;
     
    26282740    int attempt_to_mount_returned_this = 999;
    26292741    char *mtpt = NULL;
    2630     char *szcdno = NULL;
    2631     char *szserfname = NULL;
    2632     char *szunmount = NULL;
     2742    char *szcdno;
     2743    char *szserfname;
     2744    char *szunmount;
    26332745    char *mds = NULL;
    26342746
    26352747    malloc_string(cdrom_dev);
    26362748    malloc_string(cdrw_dev);
     2749    malloc_string(szcdno);
     2750    malloc_string(szserfname);
     2751    malloc_string(szunmount);
     2752    malloc_string(mtpt);
    26372753
    26382754    mds = media_descriptor_string(g_backup_media_type);
    2639     log_to_screen("I am about to burn %s #%d", mds, g_current_media_number);
     2755    mr_asprintf(tmp, "I am about to burn %s #%d", mds, g_current_media_number);
    26402756    mr_free(mds);
     2757    log_to_screen(tmp);
     2758    mr_free(tmp);
    26412759    if (g_current_media_number < ask_for_one_if_more_than_this) {
    26422760        return;
    26432761    }
    26442762    log_to_screen("Scanning CD-ROM drive...");
    2645     mr_asprintf(mtpt, "%s/cd.mtpt", bkpinfo->tmpdir);
     2763    sprintf(mtpt, "%s/cd.mtpt", bkpinfo->tmpdir);
    26462764    make_hole_for_dir(mtpt);
    26472765
     
    26492767    ok_go_ahead_burn_it = TRUE;
    26502768    if (!find_cdrom_device(cdrom_dev, FALSE)) {
    2651         /* When enabled, it made CD eject-and-retract when wrong CD inserted.. Weird
    2652         log_msg(2, "paafcd: Retracting CD-ROM drive if possible" );
    2653         retract_CD_tray_and_defeat_autorun();
    2654         */
     2769/* When enabled, it made CD eject-and-retract when wrong CD inserted.. Weird
     2770      log_msg(2, "paafcd: Retracting CD-ROM drive if possible" );
     2771      retract_CD_tray_and_defeat_autorun();
     2772*/
    26552773        mr_asprintf(tmp, "umount %s", cdrom_dev);
    26562774        run_program_and_log_output(tmp, 1);
    2657         mr_asprintf(szcdno, "%s/archives/THIS-CD-NUMBER", mtpt);
    2658         mr_asprintf(szserfname, "%s/archives/SERIAL-STRING", mtpt);
    2659         mr_asprintf(szunmount, "umount %s", mtpt);
     2775        sprintf(szcdno, "%s/archives/THIS-CD-NUMBER", mtpt);
     2776        sprintf(szserfname, "%s/archives/SERIAL-STRING", mtpt);
     2777        sprintf(szunmount, "umount %s", mtpt);
    26602778        cd_number = -1;
    26612779        mr_asprintf(tmp, "mount %s %s", cdrom_dev, mtpt);
     
    26632781        attempt_to_mount_returned_this = run_program_and_log_output(tmp, 1);
    26642782        mr_free(tmp);
    2665 
    26662783        if (attempt_to_mount_returned_this) {
    26672784            log_msg(4, "Failed to mount %s at %s", cdrom_dev, mtpt);
    26682785            log_to_screen("If there's a CD/DVD in the drive, it's blank.");
    2669         } else if (!does_file_exist(szcdno) || !does_file_exist(szserfname)) {
     2786            /*
     2787               if (interrogate_disk_currently_in_cdrw_drive(cdrw_dev, FALSE))
     2788               {
     2789               ok_go_ahead_burn_it = FALSE;
     2790               log_to_screen("There isn't a writable CD/DVD in the drive.");
     2791               }
     2792               else
     2793               {
     2794               log_to_screen("Confirmed. There is a blank CD/DVD in the drive.");
     2795               }
     2796             */
     2797        } else if (!does_file_exist(szcdno)
     2798                   || !does_file_exist(szserfname)) {
    26702799            mds = media_descriptor_string(g_backup_media_type);
    2671             log_to_screen("%s has data on it but it's probably not a Mondo CD.", mds);
     2800            log_to_screen
     2801                ("%s has data on it but it's probably not a Mondo CD.", mds);
    26722802            mr_free(mds);
    26732803        } else {
     
    26792809            mr_asprintf(tmp, "cat %s 2> /dev/null", szserfname);
    26802810            mr_free(our_serial_str);
    2681             mr_asprintf(our_serial_str, "%s", call_program_and_get_last_line_of_output(tmp));
     2811            mr_asprintf(our_serial_str, "%s",
     2812                   call_program_and_get_last_line_of_output(tmp));
    26822813            mr_free(tmp);
    26832814            // FIXME - should be able to use last_line_of_file(), surely?
    26842815        }
    2685         mr_free(szcdno);
    2686         mr_free(szserfname);
    2687 
    26882816        run_program_and_log_output(szunmount, 1);
    2689         mr_free(szunmount);
    2690 
    26912817        log_msg(2, "paafcd: cd_number = %d", cd_number);
    2692         log_msg(2, "our serial str = %s; g_serial_string = %s", our_serial_str, g_serial_string);
     2818        log_msg(2, "our serial str = %s; g_serial_string = %s",
     2819                our_serial_str, g_serial_string);
    26932820        if (cd_number > 0 && !strcmp(our_serial_str, g_serial_string)) {
    26942821            mds = media_descriptor_string(g_backup_media_type);
     
    27222849        }
    27232850        mds = media_descriptor_string(g_backup_media_type);
    2724         mr_asprintf(tmp, "I am about to burn %s #%d of the backup set. Please insert %s and press Enter.", mds, g_current_media_number, mds);
     2851        mr_asprintf(tmp, "I am about to burn %s #%d of the backup set. Please insert %s and press Enter.",
     2852                mds, g_current_media_number, mds);
    27252853        mr_free(mds);
    27262854
     
    27332861
    27342862    mds = media_descriptor_string(g_backup_media_type);
    2735     log_msg(2, "paafcd: OK, I assume I have a blank/reusable %s in the drive...", mds);
     2863    log_msg(2,
     2864            "paafcd: OK, I assume I have a blank/reusable %s in the drive...", mds);
    27362865
    27372866    log_to_screen("Proceeding w/ %s in drive.", mds);
     
    27402869    paranoid_free(cdrom_dev);
    27412870    paranoid_free(cdrw_dev);
    2742     mr_free(mtpt);
     2871    paranoid_free(mtpt);
     2872    paranoid_free(szcdno);
     2873    paranoid_free(szserfname);
     2874    paranoid_free(szunmount);
    27432875    if (pmountable) {
    27442876        if (attempt_to_mount_returned_this) {
     
    27502882
    27512883}
     2884
     2885
     2886
     2887
     2888
     2889
    27522890
    27532891
     
    27792917
    27802918/* @} - end of utilityGroup */
     2919
     2920
     2921
     2922
     2923
     2924
    27812925
    27822926
     
    28012945 */
    28022946int
    2803 slice_up_file_etc(char *biggie_filename, char *ntfsprog_fifo, long biggie_file_number, long noof_biggie_files, bool use_ntfsprog) {
     2947slice_up_file_etc(char *biggie_filename,
     2948                  char *ntfsprog_fifo, long biggie_file_number,
     2949                  long noof_biggie_files, bool use_ntfsprog)
     2950{
    28042951
    28052952    /*@ buffers ************************************************** */
    28062953    char *tmp = NULL;
    2807     char *checksum_line = NULL;
    2808     char *command = NULL;
    2809     char *tempblock = NULL;
     2954    char *checksum_line, *command;
     2955    char *tempblock;
    28102956    char *curr_slice_fname_uncompressed = NULL;
    28112957    char *curr_slice_fname_compressed = NULL;
    28122958    char *file_to_archive = NULL;
    2813     char *file_to_openin = NULL;
     2959    char *file_to_openin;
    28142960    /*@ pointers ************************************************** */
    2815     char *pB = NULL;
    2816     FILE *fin = NULL;
    2817     FILE *fout = NULL;
     2961    char *pB;
     2962    FILE *fin = NULL, *fout = NULL;
    28182963
    28192964    /*@ bool ****************************************************** */
     
    28212966
    28222967    /*@ long ****************************************************** */
    2823     size_t blksize = (size_t)0;
    2824     long slice_num = 0L;
    2825     long i = 0L;
    2826     bool should_I_compress_slices = TRUE;
     2968    size_t blksize = 0;
     2969    long slice_num = 0;
     2970    long i;
     2971    long optimal_set_size;
     2972    bool should_I_compress_slices;
    28272973    char *suffix = NULL;                // for compressed slices
    28282974
     
    28372983    /*@ structures ************************************************** */
    28382984    struct s_filename_and_lstat_info biggiestruct;
     2985//  struct stat statbuf;
    28392986
    28402987    assert(bkpinfo != NULL);
    28412988    assert_string_is_neither_NULL_nor_zerolength(biggie_filename);
     2989    malloc_string(checksum_line);
    28422990
    28432991    biggiestruct.for_backward_compatibility = '\n';
    28442992    biggiestruct.use_ntfsprog = use_ntfsprog;
    2845     if (is_this_file_compressed(biggie_filename) || bkpinfo->compression_level == 0) {
     2993    optimal_set_size = bkpinfo->optimal_set_size;
     2994    if (is_this_file_compressed(biggie_filename)
     2995        || bkpinfo->compression_level == 0) {
    28462996        mr_asprintf(suffix, "%s", "");
     2997        //      log_it("%s is indeed compressed :-)", filename);
    28472998        should_I_compress_slices = FALSE;
    28482999    } else {
     
    28513002    }
    28523003
    2853     if (bkpinfo->optimal_set_size < 999L) {
     3004    if (optimal_set_size < 999) {
    28543005        fatal_error("bkpinfo->optimal_set_size is insanely small");
    28553006    }
    2856 
    28573007    if (ntfsprog_fifo) {
    28583008        file_to_openin = ntfsprog_fifo;
    2859         mr_asprintf(checksum_line, "IGNORE");
    2860         log_msg(2, "Not calculating checksum for %s: it would take too long", biggie_filename);
     3009        strcpy(checksum_line, "IGNORE");
     3010        log_msg(2,
     3011                "Not calculating checksum for %s: it would take too long",
     3012                biggie_filename);
    28613013        if ( !find_home_of_exe("ntfsresize")) {
    28623014            fatal_error("ntfsresize not found");
     
    28683020        log_it("res of it = %s", tmp);
    28693021        totallength = (off_t)atoll(tmp);
    2870         mr_free(tmp);
     3022        paranoid_free(tmp);
    28713023    } else {
    28723024        file_to_openin = biggie_filename;
     
    28823034        }
    28833035        mr_free(command);
    2884         mr_getline(checksum_line, fin);
     3036        tmp = fgets(checksum_line, MAX_STR_LEN, fin);
    28853037        pclose(fin);
    28863038        totallength = length_of_file (biggie_filename);
     
    28963048    }
    28973049    strcpy(biggiestruct.checksum, checksum_line);
    2898     mr_free(checksum_line);
    28993050
    29003051    mr_asprintf(tmp, "%s", slice_fname(biggie_file_number, 0, bkpinfo->tmpdir, ""));
     
    29023053    if (fout == NULL) {
    29033054        log_msg(1, "Unable to open and write to %s\n", tmp);
    2904         mr_free(tmp);
     3055        paranoid_free(tmp);
    29053056        mr_free(suffix);
    29063057        return (1);
    29073058    }
    2908     mr_free(tmp);
     3059    paranoid_free(tmp);
    29093060
    29103061    res = fwrite((void *) &biggiestruct, 1, sizeof(biggiestruct), fout);
     
    29123063        paranoid_fclose(fout);
    29133064    }
    2914     log_msg(1, "Opening in %s; slicing it and writing to CD/tape", file_to_openin);
     3065    log_msg(1, "Opening in %s; slicing it and writing to CD/tape",
     3066            file_to_openin);
    29153067    if (!(fin = fopen(file_to_openin, "r"))) {
    29163068        log_OS_error("Unable to openin biggie_filename");
    2917         log_to_screen("Cannot archive bigfile '%s': not found", biggie_filename);
    2918 
     3069        mr_asprintf(tmp, "Cannot archive bigfile '%s': not found", biggie_filename);
     3070        log_to_screen(tmp);
     3071        paranoid_free(tmp);
     3072
     3073        paranoid_free(checksum_line);
    29193074        mr_free(suffix);
    29203075        return (1);
     
    29393094        mr_asprintf(tmp, "%s", percent_media_full_comment());
    29403095        update_progress_form(tmp);
    2941         mr_free(tmp);
     3096        paranoid_free(tmp);
    29423097
    29433098        if (!(fout = fopen(curr_slice_fname_uncompressed, "w"))) {
     
    29463101            return (1);
    29473102        }
    2948         if ((i == bkpinfo->optimal_set_size / 256) && (totalread < 1.1 * totallength)) {
    2949             for (i = 0L; i < bkpinfo->optimal_set_size / 256; i++) {
     3103        if ((i == bkpinfo->optimal_set_size / 256)
     3104            && (totalread < 1.1 * totallength)) {
     3105            for (i = 0; i < bkpinfo->optimal_set_size / 256; i++) {
    29503106                blksize = fread(tempblock, 1, 256 * 1024, fin);
    29513107                if (blksize > 0) {
     
    29563112                }
    29573113            }
    2958             mr_free(tempblock);
    29593114        } else {
    2960             i = 0L;
     3115            i = 0;
    29613116        }
    29623117        paranoid_fclose(fout);
    2963         if (i > 0L)             // length_of_file (curr_slice_fname_uncompressed)
     3118        if (i > 0)              // length_of_file (curr_slice_fname_uncompressed)
    29643119        {
    29653120            if (!does_file_exist(curr_slice_fname_uncompressed)) {
    2966                 log_msg(2, "Warning - '%s' doesn't exist. How can I compress slice?", curr_slice_fname_uncompressed);
     3121                log_msg(2,
     3122                        "Warning - '%s' doesn't exist. How can I compress slice?",
     3123                        curr_slice_fname_uncompressed);
    29673124            }
    29683125            if (should_I_compress_slices && bkpinfo->compression_level > 0) {
     
    29843141                log_msg(2, "Failed to compress the slice");
    29853142            }
    2986             if (bkpinfo->use_lzo && strcmp(curr_slice_fname_compressed, curr_slice_fname_uncompressed)) {
     3143            if (bkpinfo->use_lzo
     3144                && strcmp(curr_slice_fname_compressed,
     3145                          curr_slice_fname_uncompressed)) {
    29873146                unlink(curr_slice_fname_uncompressed);
    29883147            }
     
    29903149                mr_asprintf(tmp, "Problem with slice # %ld", slice_num);
    29913150            } else {
    2992                 mr_asprintf(tmp, "%s - Bigfile #%ld, slice #%ld compressed OK          ", biggie_filename, biggie_file_number + 1, slice_num);
     3151                mr_asprintf(tmp, "%s - Bigfile #%ld, slice #%ld compressed OK          ", biggie_filename, biggie_file_number + 1,
     3152                        slice_num);
    29933153            }
     3154#ifndef _XWIN
    29943155            if (!g_text_mode) {
    29953156                newtDrawRootText(0, g_noof_rows - 2, tmp);
     
    29983159                log_msg(2, tmp);
    29993160            }
    3000             mr_free(tmp);
     3161#else
     3162            log_msg(2, tmp);
     3163#endif
     3164            paranoid_free(tmp);
    30013165
    30023166            mr_asprintf(file_to_archive, "%s", curr_slice_fname_compressed);
     
    30143178
    30153179        if (IS_THIS_A_STREAMING_BACKUP(bkpinfo->backup_media_type)) {
    3016             register_in_tape_catalog(biggieslice, biggie_file_number, slice_num, file_to_archive);
    3017             maintain_collection_of_recent_archives(bkpinfo->tmpdir, file_to_archive);
     3180            register_in_tape_catalog(biggieslice, biggie_file_number,
     3181                                     slice_num, file_to_archive);
     3182            maintain_collection_of_recent_archives(bkpinfo->tmpdir,
     3183                                                   file_to_archive);
    30183184            res = move_files_to_stream(file_to_archive, NULL);
    30193185        } else {
     
    30243190        retval += res;
    30253191        if (res) {
    3026             log_to_screen("Failed to add slice %ld of bigfile %ld to scratchdir", slice_num, biggie_file_number + 1);
    3027             fatal_error("Hard disk full. You should have bought a bigger one.");
    3028         }
    3029     }
     3192            mr_asprintf(tmp, "Failed to add slice %ld of bigfile %ld to scratchdir", slice_num, biggie_file_number + 1);
     3193            log_to_screen(tmp);
     3194            paranoid_free(tmp);
     3195            fatal_error
     3196                ("Hard disk full. You should have bought a bigger one.");
     3197        }
     3198    }
     3199    mr_free(tempblock);
    30303200    mr_free(suffix);
    30313201    paranoid_fclose(fin);
     
    30373207    }
    30383208    log_msg(1, tmp);
    3039     mr_free(tmp);
    3040 
     3209    paranoid_free(tmp);
     3210
     3211    paranoid_free(checksum_line);
    30413212    return (retval);
    30423213}
     
    31173288    log_msg(2, tmp);
    31183289    center_string(tmp, 80);
     3290#ifndef _XWIN
    31193291    if (!g_text_mode) {
    31203292        newtPushHelpLine(tmp);
    31213293    }
     3294#endif
    31223295    res = write_iso_and_go_on(TRUE);
     3296#ifndef _XWIN
    31233297    if (!g_text_mode) {
    31243298        newtPopHelpLine();
    31253299    }
     3300#endif
    31263301    log_msg(2, "Returning from writing final ISO (res=%d)", res);
    31273302    paranoid_free(tmp);
     
    31523327
    31533328    /*@ buffers ***************************************************** */
    3154     char *tmp = NULL;
    3155     char *tmp1 = NULL;
    3156     char *cdno_fname = NULL;
    3157     char *lastcd_fname = NULL;
    3158     char *isofile = NULL;
     3329    char *tmp;
     3330    char *cdno_fname;
     3331    char *lastcd_fname;
     3332    char *isofile;
    31593333    char *mds = NULL;
    31603334
     
    31673341
    31683342    malloc_string(tmp);
     3343    malloc_string(cdno_fname);
     3344    malloc_string(lastcd_fname);
     3345    malloc_string(isofile);
    31693346
    31703347    assert(bkpinfo != NULL);
     
    31803357    /* label the ISO with its number */
    31813358
    3182     mr_asprintf(cdno_fname, "%s/archives/THIS-CD-NUMBER", bkpinfo->scratchdir);
     3359    sprintf(cdno_fname, "%s/archives/THIS-CD-NUMBER", bkpinfo->scratchdir);
    31833360    fout = fopen(cdno_fname, "w");
    3184     mr_free(cdno_fname);
    3185 
    31863361    fprintf(fout, "%d", g_current_media_number);
    31873362    paranoid_fclose(fout);
    31883363
    3189     mr_asprintf(tmp1, "cp -f %s/autorun %s/", g_mondo_home, bkpinfo->scratchdir);
    3190     if (run_program_and_log_output(tmp1, FALSE)) {
     3364    sprintf(tmp, "cp -f %s/autorun %s/", g_mondo_home,
     3365            bkpinfo->scratchdir);
     3366    if (run_program_and_log_output(tmp, FALSE)) {
    31913367        log_msg(2, "Warning - unable to copy autorun to scratchdir");
    31923368    }
    3193     mr_free(tmp1);
    31943369
    31953370    /* last CD or not? Label accordingly */
    3196     mr_asprintf(lastcd_fname, "%s/archives/NOT-THE-LAST", bkpinfo->scratchdir);
     3371    sprintf(lastcd_fname, "%s/archives/NOT-THE-LAST", bkpinfo->scratchdir);
    31973372    if (last_cd) {
    31983373        unlink(lastcd_fname);
     
    32053380        paranoid_fclose(fout);
    32063381    }
    3207     mr_free(lastcd_fname);
    3208 
    32093382    if (space_occupied_by_cd(bkpinfo->scratchdir) / 1024 > bkpinfo->media_size) {
    3210         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);
    3211     }
    3212     mr_asprintf(isofile, "%s/%s/%s-%d.iso", bkpinfo->isodir,
     3383        sprintf(tmp,
     3384                "Warning! CD is too big. It occupies %ld KB, which is more than the %ld KB allowed.",
     3385                (long) space_occupied_by_cd(bkpinfo->scratchdir),
     3386                (long) bkpinfo->media_size);
     3387        log_to_screen(tmp);
     3388    }
     3389    sprintf(isofile, "%s/%s/%s-%d.iso", bkpinfo->isodir,
    32133390            bkpinfo->netfs_remote_dir, bkpinfo->prefix,
    32143391            g_current_media_number);
     
    32253402            {
    32263403                log_msg(3, "*Sigh* Mike, I hate your computer.");
    3227                 // if it can't be found then force pausing
    32283404                bkpinfo->manual_cd_tray = TRUE;
    3229             } else {
     3405            }                   // if it can't be found then force pausing
     3406            else {
    32303407                log_msg(3, "Great. Found Mike's CD-ROM drive.");
    32313408            }
     
    32333410        if (bkpinfo->verify_data && !res) {
    32343411            mds = media_descriptor_string(g_backup_media_type);
    3235             log_to_screen("Please reboot from the 1st %s in Compare Mode, as a precaution.", mds);
     3412            log_to_screen
     3413                ("Please reboot from the 1st %s in Compare Mode, as a precaution.", mds);
    32363414            mr_free(mds);
    32373415            if (chdir("/")) {
     
    32503428        } else {
    32513429            mds = media_descriptor_string(bkpinfo->backup_media_type);
    3252             mr_asprintf(tmp1, "Failed to create %s #%d. Retry?", mds, g_current_media_number);
     3430            sprintf(tmp, "Failed to create %s #%d. Retry?", mds, g_current_media_number);
    32533431            mr_free(mds);
    3254             res = ask_me_yes_or_no(tmp1);
    3255             mr_free(tmp1);
    3256 
     3432            res = ask_me_yes_or_no(tmp);
    32573433            if (!res) {
    32583434                if (ask_me_yes_or_no("Abort the backup?")) {
     
    32673443        }
    32683444    }
    3269     mr_free(isofile);
    3270 
    32713445    g_current_media_number++;
    32723446    wipe_archives(bkpinfo->scratchdir);
    3273     mr_asprintf(tmp1, "rm -Rf %s/images/*gz %s/images/*data*img", bkpinfo->scratchdir, bkpinfo->scratchdir);
    3274     if (system(tmp1)) {
    3275         log_msg(2, "Error occurred when I tried to delete the redundant IMGs and GZs");
    3276     }
    3277     mr_free(tmp1);
     3447    sprintf(tmp, "rm -Rf %s/images/*gz %s/images/*data*img",
     3448            bkpinfo->scratchdir, bkpinfo->scratchdir);
     3449    if (system(tmp)) {
     3450        log_msg
     3451            (2,
     3452             "Error occurred when I tried to delete the redundant IMGs and GZs");
     3453    }
    32783454
    32793455    if (last_cd) {
     
    32853461    bkpinfo->verify_data = orig_vfy_flag_val;
    32863462    paranoid_free(tmp);
     3463    paranoid_free(cdno_fname);
     3464    paranoid_free(lastcd_fname);
     3465    paranoid_free(isofile);
    32873466    return (0);
    32883467}
     
    33533532            if (res) {
    33543533                mds = media_descriptor_string(bkpinfo->backup_media_type);
    3355                 log_to_screen("Warnings/errors were reported while checking %s #%d", mds, g_current_media_number);
     3534                mr_asprintf(tmp, "Warnings/errors were reported while checking %s #%d", mds, g_current_media_number);
    33563535                mr_free(mds);
     3536                log_to_screen(tmp);
     3537                mr_free(tmp);
    33573538
    33583539            }
  • branches/3.0/mondo/src/common/libmondo-cli.c

    r3188 r3192  
    9797    for (i = 0; i < 128; i++) {
    9898        if (flag_set[i]) {
    99             log_msg(3, "-%c %s", i, flag_val[i]);
     99            mr_asprintf(tmp, "-%c %s", i, flag_val[i]);
     100            log_msg(3, tmp);
     101            mr_free(tmp);
    100102        }
    101103    }
     
    148150    char *tmp = NULL;
    149151    char *tmp1 = NULL;
    150     char *tmp2 = NULL;
    151152    char *psz = NULL;
    152153    char *p = NULL;
     
    207208            log_msg(1, "Using star instead of afio");
    208209        } else {
    209             fatal_error("Neither afio nor star is installed. Please install at least one.");
     210            fatal_error
     211                ("Neither afio nor star is installed. Please install at least one.");
    210212        }
    211213    }
     
    217219        }
    218220        if (!find_home_of_exe("star")) {
    219             fatal_error("Please install 'star' RPM or tarball if you are going to use -R. Thanks.");
     221            fatal_error
     222                ("Please install 'star' RPM or tarball if you are going to use -R. Thanks.");
    220223        }
    221224    }
     
    231234
    232235    if (flag_set['I']) {
    233         if (bkpinfo->include_paths && bkpinfo->include_paths[0] == '-') {
     236        if (bkpinfo->include_paths[0] == '-') {
    234237            retval++;
    235238            log_to_screen("Please supply a sensible value with '-I'\n");
     
    265268            }
    266269        }
    267         mr_free(tmp1);
     270        paranoid_free(tmp1);
    268271        mr_make_devlist_from_pathlist(flag_val['I'], 'I');
    269272        log_msg(4, "Finished with the -I option");
    270273    }
    271274
    272     if (g_kernel_version >= 2.6 && !flag_set['d'] && (flag_set['c'] || flag_set['w']) && (! bkpinfo->restore_data)) {
    273         fatal_error("If you are using the 2.6.x kernel, please specify the CD-R(W) device.");
     275    if (g_kernel_version >= 2.6 && !flag_set['d']
     276        && (flag_set['c'] || flag_set['w']) && (! bkpinfo->restore_data)) {
     277        fatal_error
     278            ("If you are using the 2.6.x kernel, please specify the CD-R(W) device.");
    274279    }
    275280
     
    278283        if (flag_set['I']) {
    279284            retval++;
    280             log_to_screen("Please do not use -J in combination with -I. If you want to make a list of files to backup, that's fine, use -J <filename> but please don't muddy the waters by combining -J with -I. Thanks. :-)");
     285            log_to_screen
     286                ("Please do not use -J in combination with -I. If you want to make a list of files to backup, that's fine, use -J <filename> but please don't muddy the waters by combining -J with -I. Thanks. :-)");
    281287        }
    282288        bkpinfo->make_filelist = FALSE;
    283         mr_asprintf(bkpinfo->include_paths, "%s", flag_val['J']);
     289        strcpy(bkpinfo->include_paths, flag_val['J']);
    284290    }
    285291
    286292    if ((flag_set['c'] || flag_set['w'] || flag_set['C'] || flag_set['r']) && (! bkpinfo->restore_data)) {
    287         if (!flag_set['r'] && g_kernel_version <= 2.5 && strstr(flag_val['d'], "/dev/")) {
    288             fatal_error("Please don't give a /dev entry. Give a SCSI node for the parameter of the -d flag.");
    289         }
    290         if (flag_set['r'] && g_kernel_version <= 2.5 && !strstr(flag_val['d'], "/dev/")) {
    291             fatal_error("Please give a /dev entry, not a SCSI node, as the parameter of the -d flag.");
     293        if (!flag_set['r'] && g_kernel_version <= 2.5
     294            && strstr(flag_val['d'], "/dev/")) {
     295            fatal_error
     296                ("Please don't give a /dev entry. Give a SCSI node for the parameter of the -d flag.");
     297        }
     298        if (flag_set['r'] && g_kernel_version <= 2.5
     299            && !strstr(flag_val['d'], "/dev/")) {
     300            fatal_error
     301                ("Please give a /dev entry, not a SCSI node, as the parameter of the -d flag.");
    292302        }
    293303        if (g_kernel_version >= 2.6 && !strstr(flag_val['d'], "/dev/")) {
    294             log_to_screen("Linus says 2.6 has a broken ide-scsi module. Proceed at your own risk...");
    295         }
    296 
    297         if (system("which cdrecord > /dev/null 2> /dev/null") && system("which dvdrecord > /dev/null 2> /dev/null")) {
    298             fatal_error("Please install dvdrecord/cdrecord and try again.");
     304            log_to_screen
     305                ("Linus says 2.6 has a broken ide-scsi module. Proceed at your own risk...");
     306        }
     307
     308        if (system("which cdrecord > /dev/null 2> /dev/null")
     309            && system("which dvdrecord > /dev/null 2> /dev/null")) {
     310            fatal_error
     311                ("Please install dvdrecord/cdrecord and try again.");
    299312        }
    300313        if (flag_set['C']) {
    301314            bkpinfo->cdrw_speed = atoi(flag_val['C']);
    302315            if (bkpinfo->cdrw_speed < 1) {
    303                 fatal_error("You specified a silly speed for a CD-R[W] drive");
     316                fatal_error
     317                    ("You specified a silly speed for a CD-R[W] drive");
    304318            }
    305319            if (!flag_set['L']) {
    306                 log_to_screen("You must use -L with -C. Therefore I am setting it for you.");
     320                log_to_screen
     321                    ("You must use -L with -C. Therefore I am setting it for you.");
    307322                flag_set['L'] = 1;
    308323                flag_val['L'][0] = '\0';
     
    311326            log_msg(3, "flag_val['c'] = %s", flag_val['c']);
    312327            log_msg(3, "flag_val['w'] = %s", flag_val['w']);
     328//    log_msg(3, "flag_set['r'] = %i", flag_set['r'] );
    313329            if (flag_set['c']) {
    314330                bkpinfo->cdrw_speed = atoi(flag_val['c']);
     
    320336
    321337            if (bkpinfo->cdrw_speed < 1) {
    322                 fatal_error("You specified a silly speed for a CD-R[W] drive");
     338                fatal_error
     339                    ("You specified a silly speed for a CD-R[W] drive");
    323340            }
    324341        }
     
    328345        log_it("Hmm! No tape drive specified. Let's see what we can do.");
    329346        if (find_tape_device_and_size(flag_val['d'], tmp)) {
    330             fatal_error("Tape device not specified. I couldn't find it either.");
     347            fatal_error
     348                ("Tape device not specified. I couldn't find it either.");
    331349        }
    332350        flag_set['d'] = TRUE;
    333         log_to_screen("You didn't specify a tape streamer device. I'm assuming %s", flag_val['d']);
     351        sprintf(tmp,
     352                "You didn't specify a tape streamer device. I'm assuming %s",
     353                flag_val['d']);
     354        log_to_screen(tmp);
    334355    }
    335356
     
    337358    {
    338359        if (! flag_set['d']) {
    339             fatal_error("You need to specify a device file with -d for bootable USB device usage");
     360            fatal_error
     361                ("You need to specify a device file with -d for bootable USB device usage");
    340362        }
    341363        if ((!flag_set['s']) && (! bkpinfo->restore_data)) {
     
    347369    {
    348370        if (flag_set['m']) {
    349             fatal_error("Manual CD tray (-m) not yet supported in conjunction w/ DVD drives. Drop -m.");
     371            fatal_error
     372                ("Manual CD tray (-m) not yet supported in conjunction w/ DVD drives. Drop -m.");
    350373        }
    351374        if (!flag_set['d']) {
     
    356379        }
    357380        if (strchr(flag_val['d'], ',')) {
    358             fatal_error("Please don't give a SCSI node. Give a _device_, preferably a /dev entry, for the parameter of the -d flag.");
     381            fatal_error
     382                ("Please don't give a SCSI node. Give a _device_, preferably a /dev entry, for the parameter of the -d flag.");
    359383        }
    360384        if (! bkpinfo->restore_data) {
    361385            if (!find_home_of_exe("growisofs")) {
    362                 fatal_error("Please install growisofs (probably part of dvd+rw-tools). If you want DVD support, you need it.");
     386                fatal_error
     387                    ("Please install growisofs (probably part of dvd+rw-tools). If you want DVD support, you need it.");
    363388            }
    364389            if (!find_home_of_exe("dvd+rw-format")) {
    365                 fatal_error("Please install dvd+rw-format (probably part of dvd+rw-tools). If you want DVD support, you need it.");
     390                fatal_error
     391                    ("Please install dvd+rw-format (probably part of dvd+rw-tools). If you want DVD support, you need it.");
    366392            }
    367393            if (!flag_set['s']) {
    368394                sprintf(flag_val['s'], "%d", DEFAULT_DVD_DISK_SIZE);    // 4.7 salesman's GB = 4.482 real GB = 4582 MB
    369395                strcat(flag_val['s'], "m");
    370                 log_to_screen("You did not specify a size (-s) for DVD. I'm guessing %s.", flag_val['s']);
     396                log_to_screen
     397                    ("You did not specify a size (-s) for DVD. I'm guessing %s.",
     398                    flag_val['s']);
    371399                flag_set['s'] = 1;
    372400            }
    373401        }
     402/*
     403      if (flag_set['Z']) {
     404      bkpinfo->blank_dvd_first = TRUE;
     405      }
     406*/
    374407    }
    375408
    376409    if (flag_set['t'] || flag_set['u']) {   /* tape size */
    377410        if (strchr(flag_val['d'], ',')) {
    378             fatal_error("Please don't give a SCSI node. Give a _device_, preferably a /dev entry, for the parameter of the -d flag.");
     411            fatal_error
     412                ("Please don't give a SCSI node. Give a _device_, preferably a /dev entry, for the parameter of the -d flag.");
    379413        }
    380414        if ((flag_set['O']) && (! bkpinfo->restore_data)) {
    381415            if (flag_set['s']) {
    382416                if (flag_set['t']) {
    383                     fatal_error("For the moment, please don't specify a tape size. Mondo should handle end-of-tape gracefully anyway.");
     417                    fatal_error
     418                        ("For the moment, please don't specify a tape size. Mondo should handle end-of-tape gracefully anyway.");
    384419                }
    385420                if (process_the_s_switch(flag_val['s'])) {
     
    405440
    406441    if (flag_set['n']) {
    407         mr_free(bkpinfo->netfs_mount);
    408         mr_asprintf(bkpinfo->netfs_mount, "%s", flag_val['n']);
     442        strncpy(bkpinfo->netfs_mount, flag_val['n'], MAX_STR_LEN);
    409443        if (!flag_set['d']) {
    410             mr_free(bkpinfo->netfs_remote_dir);
    411             mr_asprintf(bkpinfo->netfs_remote_dir, "/");
     444            strncpy(bkpinfo->netfs_remote_dir, "/", MAX_STR_LEN);
    412445        }
    413446        /* test for protocol */
     
    440473        /* Store the 2 values */
    441474        /*  using memmove instead of strcpy as per #584 */
    442         /* memmove(bkpinfo->netfs_mount, p, MAX_STR_LEN); */
    443         bkpinfo->netfs_mount = p;
     475        memmove(bkpinfo->netfs_mount, p, MAX_STR_LEN);
    444476
    445477        /* test if we specified a user */
     
    447479        if (p != NULL) {
    448480            /* User found. Store the 2 values */
    449             bkpinfo->netfs_user = bkpinfo->netfs_mount;
    450481            p++;
    451482            /* new netfs mount */
    452             mr_asprintf(bkpinfo->netfs_mount, "%s", p);
    453             /* now that user is computed, create the right value by removing end of string */
     483            strcpy(tmp,p);
    454484            p--;
    455485            *p = '\0';
    456         }
    457         mr_asprintf(tmp1, "mount | grep -E \"^[a-z]*#*[%s@]*%s[/]* .*\" | cut -d' ' -f3", bkpinfo->netfs_user, bkpinfo->netfs_mount);
    458         strncpy(bkpinfo->isodir, call_program_and_get_last_line_of_output(tmp), MAX_STR_LEN / 4);
    459         mr_free(tmp1);
    460 
     486            mr_asprintf(q,"%s",bkpinfo->netfs_mount);
     487            bkpinfo->netfs_user = q;
     488            strcpy(bkpinfo->netfs_mount,tmp);
     489        }
     490        sprintf(tmp, "mount | grep -E \"^[a-z]*#*[%s@]*%s[/]* .*\" | cut -d' ' -f3", bkpinfo->netfs_user,
     491                bkpinfo->netfs_mount);
     492        strncpy(bkpinfo->isodir,
     493                call_program_and_get_last_line_of_output(tmp),
     494                MAX_STR_LEN / 4);
    461495        if (strlen(bkpinfo->isodir) < 3) {
    462496            log_to_screen("Network share is not mounted. Trying to mount it for you.\n");
    463497            if (bkpinfo->netfs_user) {
    464498                if (strstr(bkpinfo->netfs_proto, "sshfs")) {
    465                     mr_asprintf(tmp1, "sshfs %s@%s", bkpinfo->netfs_user, bkpinfo->netfs_mount);
     499                    sprintf(tmp, "sshfs %s@%s", bkpinfo->netfs_user, bkpinfo->netfs_mount);
    466500                } else if (strstr(bkpinfo->netfs_proto, "smbfs")) {
    467                     mr_asprintf(tmp1, "mount -t cifs %s -o user=%s", bkpinfo->netfs_mount, bkpinfo->netfs_user);
     501                    sprintf(tmp, "mount -t cifs %s -o user=%s", bkpinfo->netfs_mount, bkpinfo->netfs_user);
    468502                } else if (strstr(bkpinfo->netfs_proto, "nfs")) {
    469                     mr_asprintf(tmp1, "mount %s@%s", bkpinfo->netfs_user, bkpinfo->netfs_mount);
     503                    sprintf(tmp, "mount %s@%s", bkpinfo->netfs_user, bkpinfo->netfs_mount);
    470504                } else {
    471505                    log_to_screen("Protocol %s not supported yet for network backups.\n", bkpinfo->netfs_proto);
     
    474508            } else {
    475509                if (strstr(bkpinfo->netfs_proto, "sshfs")) {
    476                     mr_asprintf(tmp1, "sshfs %s", bkpinfo->netfs_mount);
     510                    sprintf(tmp, "sshfs %s", bkpinfo->netfs_mount);
    477511                } else if (strstr(bkpinfo->netfs_proto, "smbfs")) {
    478                     mr_asprintf(tmp1, "mount -t cifs %s", bkpinfo->netfs_mount);
     512                    sprintf(tmp, "mount -t cifs %s", bkpinfo->netfs_mount);
    479513                } else if (strstr(bkpinfo->netfs_proto, "nfs")) {
    480                     mr_asprintf(tmp1, "mount %s", bkpinfo->netfs_mount);
     514                    sprintf(tmp, "mount %s", bkpinfo->netfs_mount);
    481515                } else {
    482516                    log_to_screen("Protocol %s not supported yet for network backups.\n", bkpinfo->netfs_proto);
     
    484518                }
    485519            }
    486             i = system(tmp1);
    487             mr_free(tmp1);
    488 
    489             if (i) {
     520            if (system(tmp)) {
    490521                log_to_screen("Unable to mount Network share %s. Please mount manually.\n", bkpinfo->netfs_mount);
    491522                retval++;
    492523            } else {
    493524                if (bkpinfo->netfs_user) {
    494                     mr_asprintf(tmp1, "mount | grep -E \"^[%s@]*%s[/]* .*\" | cut -d' ' -f3", bkpinfo->netfs_user, bkpinfo->netfs_mount);
     525                    sprintf(tmp, "mount | grep -E \"^[%s@]*%s[/]* .*\" | cut -d' ' -f3", bkpinfo->netfs_user,
     526                        bkpinfo->netfs_mount);
    495527                } else {
    496                     mr_asprintf(tmp1, "mount | grep -E \"^%s[/]* .*\" | cut -d' ' -f3", bkpinfo->netfs_mount);
     528                    sprintf(tmp, "mount | grep -E \"^%s[/]* .*\" | cut -d' ' -f3", bkpinfo->netfs_mount);
    497529                }
    498                 strncpy(bkpinfo->isodir, call_program_and_get_last_line_of_output(tmp), MAX_STR_LEN / 4);
     530                strncpy(bkpinfo->isodir,
     531                        call_program_and_get_last_line_of_output(tmp),
     532                        MAX_STR_LEN / 4);
    499533                if (strlen(bkpinfo->isodir) < 3) {
    500534                    retval++;
     
    590624            }
    591625        }
    592         mr_free(tmp1);
     626        paranoid_free(tmp1);
    593627
    594628        mr_make_devlist_from_pathlist(flag_val['E'], 'E');
     
    634668        log_msg(1, "Internal tape block size is now %ld bytes", itbs);
    635669        if (itbs % 512 != 0 || itbs < 256 || itbs > 1024L * 1024) {
    636             fatal_error("Are you nuts? Silly, your internal tape block size is. Abort, I shall.");
     670            fatal_error
     671                ("Are you nuts? Silly, your internal tape block size is. Abort, I shall.");
    637672        }
    638673        bkpinfo->internal_tape_block_size = itbs;
     
    643678//      bkpinfo->differential = atoi (flag_val['D']);
    644679        if ((bkpinfo->differential < 1) || (bkpinfo->differential > 9)) {
    645             fatal_error("The D option should be between 1 and 9 inclusive");
     680            fatal_error
     681                ("The D option should be between 1 and 9 inclusive");
    646682        }
    647683    }
     
    666702            && !does_file_exist(bkpinfo->kernel_path)) {
    667703            retval++;
    668             log_to_screen("You specified kernel '%s', which does not exist\n", bkpinfo->kernel_path);
     704            sprintf(tmp,
     705                    "You specified kernel '%s', which does not exist\n",
     706                    bkpinfo->kernel_path);
     707            log_to_screen(tmp);
    669708        }
    670709    }
     
    684723            }
    685724        } else if (flag_set['n']) {
    686             mr_free(bkpinfo->netfs_remote_dir);
    687             mr_asprintf(bkpinfo->netfs_remote_dir, "%s", flag_val['d']);
     725            strncpy(bkpinfo->netfs_remote_dir, flag_val['d'], MAX_STR_LEN);
    688726        } else {                /* backup device (if tape/CD-R/CD-RW) */
    689727            strncpy(bkpinfo->media_device, flag_val['d'], MAX_STR_LEN / 4);
     
    694732        mr_asprintf(tmp1,"%s/%s/.dummy.txt", bkpinfo->isodir,bkpinfo->netfs_remote_dir);
    695733        if ((bkpinfo->netfs_user) && (strstr(bkpinfo->netfs_proto,"nfs"))) {
    696             mr_asprintf(tmp2, "su - %s -c \"echo hi > %s\"", bkpinfo->netfs_user, tmp1);
     734            sprintf(tmp, "su - %s -c \"echo hi > %s\"", bkpinfo->netfs_user, tmp1);
    697735        } else {
    698             mr_asprintf(tmp2, "echo hi > %s", tmp1);
    699         }
    700         i = run_program_and_log_output(tmp2, 2);
    701         mr_free(tmp2);
    702 
    703         if (i) {
    704             retval++;
    705             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);
     736            sprintf(tmp, "echo hi > %s", tmp1);
     737        }
     738        if (run_program_and_log_output(tmp, 2)) {
     739            retval++;
     740            sprintf(tmp,
     741                    "Are you sure directory '%s' exists in remote dir '%s'?\nIf so, do you have rights to write to it?\n",
     742                    bkpinfo->netfs_remote_dir, bkpinfo->netfs_mount);
     743            log_to_screen(tmp);
    706744        }
    707745        unlink(tmp1);
    708         mr_free(tmp1);
    709     }
    710 
    711     if (!flag_set['d'] && (flag_set['c'] || flag_set['w'] || flag_set['C'])) {
     746        paranoid_free(tmp1);
     747    }
     748
     749    if (!flag_set['d']
     750        && (flag_set['c'] || flag_set['w'] || flag_set['C'])) {
    712751        if (g_kernel_version >= 2.6) {
    713752            if (popup_and_get_string
     
    730769        retval++;
    731770        log_to_screen("Please specify the backup device/directory.\n");
    732         fatal_error("You didn't use -d to specify the backup device/directory.");
     771        fatal_error
     772            ("You didn't use -d to specify the backup device/directory.");
    733773    }
    734774
     
    741781    if (flag_set['S']) {
    742782        setup_scratchdir(flag_val['S']);
    743         mr_asprintf(tmp1, "touch %s/.foo.dat", bkpinfo->scratchdir);
    744         if (run_program_and_log_output(tmp1, 1)) {
    745             retval++;
    746             mr_free(tmp1);
     783        sprintf(tmp, "touch %s/.foo.dat", bkpinfo->scratchdir);
     784        if (run_program_and_log_output(tmp, 1)) {
     785            retval++;
    747786            log_to_screen("Please specify a scratchdir which I can write to. :)");
    748787            fatal_error("I cannot write to the scratchdir you specified.");
    749788        }
    750         mr_free(tmp1);
    751 
    752         mr_asprintf(tmp1, "ln -sf %s/.foo.dat %s/.bar.dat", bkpinfo->scratchdir, bkpinfo->scratchdir);
    753         if (run_program_and_log_output(tmp1, 1)) {
    754             retval++;
    755             mr_free(tmp1);
     789        sprintf(tmp, "ln -sf %s/.foo.dat %s/.bar.dat", bkpinfo->scratchdir, bkpinfo->scratchdir);
     790        if (run_program_and_log_output(tmp, 1)) {
     791            retval++;
    756792            log_to_screen("Please don't specify a SAMBA or VFAT or NFS scratchdir.");
    757793            fatal_error("I cannot write to the scratchdir you specified.");
    758794        }
    759         mr_free(tmp1);
    760795    }
    761796
    762797    if (flag_set['T']) {
    763798        setup_tmpdir(flag_val['T']);
    764         mr_asprintf(tmp1, "touch %s/.foo.dat", bkpinfo->tmpdir);
    765         i = run_program_and_log_output(tmp1, 1);
    766         mr_free(tmp1);
    767 
    768         if (i) {
     799        sprintf(tmp, "touch %s/.foo.dat", bkpinfo->tmpdir);
     800        if (run_program_and_log_output(tmp, 1)) {
    769801            retval++;
    770802            log_to_screen("Please specify a tempdir which I can write to. :)");
    771803            fatal_error("I cannot write to the tempdir you specified.");
    772804        }
    773         mr_asprintf(tmp1, "ln -sf %s/.foo.dat %s/.bar.dat", bkpinfo->tmpdir, bkpinfo->tmpdir);
    774         i = run_program_and_log_output(tmp1, 1);
    775         mr_free(tmp1);
    776 
    777         if (i) {
     805        sprintf(tmp, "ln -sf %s/.foo.dat %s/.bar.dat", bkpinfo->tmpdir, bkpinfo->tmpdir);
     806        if (run_program_and_log_output(tmp, 1)) {
    778807            retval++;
    779808            log_to_screen("Please don't specify a SAMBA or VFAT or NFS tmpdir.");
     
    804833#  endif
    805834#endif
    806         if (!strchr(BOOT_LOADER_CHARS, (bkpinfo->boot_loader = flag_val['l'][0]))) {
    807             log_msg(1, "%c? What is %c? I need G, L, E or R.", bkpinfo->boot_loader, bkpinfo->boot_loader);
    808             fatal_error("Please specify GRUB, LILO, ELILO  or RAW with the -l switch");
     835        if (!strchr
     836            (BOOT_LOADER_CHARS,
     837             (bkpinfo->boot_loader = flag_val['l'][0]))) {
     838            log_msg(1, "%c? WTF is %c? I need G, L, E or R.",
     839                    bkpinfo->boot_loader, bkpinfo->boot_loader);
     840            fatal_error
     841                ("Please specify GRUB, LILO, ELILO  or RAW with the -l switch");
    809842        }
    810843#undef BOOT_LOADER_CHARS
     
    812845
    813846    if (flag_set['f']) {
    814         strncpy(bkpinfo->boot_device, resolve_softlinks_to_get_to_actual_device_file(flag_val['f']),MAX_STR_LEN / 4);
     847        strncpy(bkpinfo->boot_device,
     848                resolve_softlinks_to_get_to_actual_device_file(flag_val
     849                                                               ['f']),
     850                MAX_STR_LEN / 4);
    815851    }
    816852
     
    830866        if (run_program_and_log_output("which lzop", 2)) {
    831867            retval++;
    832             log_to_screen("Please install LZOP. You can't use '-L' until you do.\n");
     868            log_to_screen
     869                ("Please install LZOP. You can't use '-L' until you do.\n");
    833870        }
    834871    }
     
    843880        if (run_program_and_log_output("which gzip", 2)) {
    844881            retval++;
    845             log_to_screen("Please install gzip. You can't use '-G' until you do.\n");
    846         }
    847     }
    848 
    849     if ((flag_set['Y']) && (! bkpinfo->restore_data)) {
    850         bkpinfo->use_lzma = TRUE;
    851         if (run_program_and_log_output("which lzma", 2)) {
    852             retval++;
    853             log_to_screen("Please install lzma. You can't use '-Y' until you do.\n");
     882            log_to_screen
     883                ("Please install gzip. You can't use '-G' until you do.\n");
    854884        }
    855885    }
     
    867897    if ((!is_this_a_valid_disk_format("vfat")) && (! bkpinfo->restore_data)) {
    868898        bkpinfo->make_cd_use_lilo = TRUE;
    869         log_to_screen("Your kernel appears not to support vfat filesystems. I am therefore");
    870         log_to_screen("using LILO instead of SYSLINUX as the media boot loader.");
     899        log_to_screen
     900            ("Your kernel appears not to support vfat filesystems. I am therefore");
     901        log_to_screen
     902            ("using LILO instead of SYSLINUX as the media boot loader.");
    871903    }
    872904    if ((run_program_and_log_output("which mkfs.vfat", 2)) && (! bkpinfo->restore_data)) {
    873905        bkpinfo->make_cd_use_lilo = TRUE;
    874906#ifdef __IA32__
    875         log_to_screen("Your filesystem is missing 'mkfs.vfat', so I cannot use SYSLINUX as");
    876         log_to_screen("your boot loader. I shall therefore use LILO instead.");
     907        log_to_screen
     908            ("Your filesystem is missing 'mkfs.vfat', so I cannot use SYSLINUX as");
     909        log_to_screen
     910            ("your boot loader. I shall therefore use LILO instead.");
    877911#endif
    878912#ifdef __IA64__
    879         log_to_screen("Your filesystem is missing 'mkfs.vfat', so I cannot prepare the EFI");
     913        log_to_screen
     914            ("Your filesystem is missing 'mkfs.vfat', so I cannot prepare the EFI");
    880915        log_to_screen("environment correctly. Please install it.");
    881916        fatal_error("Aborting");
     
    897932
    898933    if ((! bkpinfo->restore_data) && (flag_set['Z'])) {
    899             fatal_error("The -Z switch is only valid in restore mode");
     934            fatal_error
     935                ("The -Z switch is only valid in restore mode");
    900936    }
    901937
     
    937973 * @return The number of problems with the command line (0 for success).
    938974 */
    939 int retrieve_switches_from_command_line(int argc, char *argv[], char flag_val[128][MAX_STR_LEN], bool flag_set[128])
     975int
     976retrieve_switches_from_command_line(int argc, char *argv[],
     977                                    char flag_val[128][MAX_STR_LEN],
     978                                    bool flag_set[128])
    940979{
    941980    /*@ ints ** */
    942981    int opt = 0;
     982    char *tmp = NULL;
    943983    int i = 0;
    944984    int len;
     
    954994        flag_set[i] = FALSE;
    955995    }
    956     while ((opt = getopt(argc, argv, MONDO_OPTIONS)) != -1) {
     996    while ((opt =
     997            getopt(argc, argv, MONDO_OPTIONS))
     998           != -1) {
    957999        if (opt == '?') {
    9581000            bad_switches = TRUE;
     1001            /*log_it("Invalid option: %c\n",optopt); */
    9591002        } else {
    9601003            if (flag_set[opt]) {
    9611004                bad_switches = TRUE;
    962                 log_to_screen("Switch -%c previously defined as %s\n", opt, flag_val[opt]);
     1005                mr_asprintf(tmp, "Switch -%c previously defined as %s\n", opt, flag_val[opt]);
     1006                log_to_screen(tmp);
     1007                paranoid_free(tmp);
    9631008            } else {
    9641009                flag_set[opt] = TRUE;
     
    9741019                        if (strchr(flag_val[opt], '/')
    9751020                            && flag_val[opt][0] != '/') {
    976                             log_to_screen("-%c flag --- must be absolute path --- '%s' isn't absolute", opt, flag_val[opt]);
     1021                            mr_asprintf(tmp, "-%c flag --- must be absolute path --- '%s' isn't absolute", opt, flag_val[opt]);
     1022                            log_to_screen(tmp);
     1023                            paranoid_free(tmp);
    9771024                            bad_switches = TRUE;
    9781025                        }
     
    9851032    for (i = optind; i < argc; i++) {
    9861033        bad_switches = TRUE;
    987         log_to_screen("Invalid arg -- %s\n", argv[i]);
     1034        mr_asprintf(tmp, "Invalid arg -- %s\n", argv[i]);
     1035        log_to_screen(tmp);
     1036        paranoid_free(tmp);
    9881037    }
    9891038    return (bad_switches);
     
    10481097    mr_strcat(tmp, " signal received from OS");
    10491098    log_to_screen(tmp);
    1050     mr_free(tmp);
     1099    paranoid_free(tmp);
    10511100
    10521101    log_to_screen(tmp2);
    1053     mr_free(tmp2);
     1102    paranoid_free(tmp2);
    10541103    if (sig == SIGABRT) {
    10551104        sleep(10);
     
    10591108    free_MR_global_filenames();
    10601109
    1061     fatal_error("MondoRescue is terminating in response to a signal from the OS");
     1110    fatal_error
     1111        ("MondoRescue is terminating in response to a signal from the OS");
    10621112    finish(254);                // just in case
    10631113}
     
    10721122void set_signals(int on)
    10731123{
    1074     int signals[] = { SIGTERM, SIGHUP, SIGTRAP, SIGABRT, SIGINT, SIGKILL, SIGSTOP, 0 };
     1124    int signals[] =
     1125        { SIGTERM, SIGHUP, SIGTRAP, SIGABRT, SIGINT, SIGKILL, SIGSTOP, 0 };
    10751126    int i;
    10761127
  • branches/3.0/mondo/src/common/libmondo-devices-EXT.h

    r3188 r3192  
    1616extern int find_device_in_mountlist(struct mountlist_itself *mountlist,
    1717                                    char *device);
    18 extern int mount_CDROM_here(char *device, const char *mountpoint);
     18extern int mount_CDROM_here(char *device, char *mountpoint);
    1919extern long long size_of_specific_device_in_mountlist(struct
    2020                                                      mountlist_itself
     
    5757extern int inject_device(char *dev);
    5858extern bool does_nonMS_partition_exist(void);
    59 extern char *resolve_softlinks_to_get_to_actual_device_file(char *incoming);
     59extern char *resolve_softlinks_to_get_to_actual_device_file(char
     60                                                            *incoming);
    6061
    6162extern void set_g_cdrom_and_g_dvd_to_bkpinfo_value();
  • branches/3.0/mondo/src/common/libmondo-devices.c

    r3188 r3192  
    2121#include "libmondo-stream-EXT.h"
    2222
    23 extern void mr_strip_spaces(char *);
    24 
    2523#include <sys/types.h>
    2624#ifdef __FreeBSD__
     
    129127{
    130128    char *tmp = NULL;
     129    char *comment;
    131130    bool is_this_a_ramdisk = FALSE;
    132131
     132    malloc_string(comment);
    133133    mr_asprintf(tmp, "%s", where_is_root_mounted());
    134     log_msg(0, "root is mounted at %s\n", tmp);
    135     log_msg(0, "That doesn't mean %s is the root partition. It's just a debugging message. Relax. It's part of am_I_in_disaster_recovery_mode().", tmp);
     134    sprintf(comment, "root is mounted at %s\n", tmp);
     135    log_msg(0, comment);
     136    log_msg(0,
     137            "No, Schlomo, that doesn't mean %s is the root partition. It's just a debugging message. Relax. It's part of am_I_in_disaster_recovery_mode().",
     138            tmp);
    136139
    137140#ifdef __FreeBSD__
     
    153156    if (is_this_a_ramdisk) {
    154157        if (!does_file_exist("/THIS-IS-A-RAMDISK")) {
    155             log_to_screen("Using /dev/root is stupid of you but I'll forgive you.");
     158            log_to_screen
     159                ("Using /dev/root is stupid of you but I'll forgive you.");
    156160            is_this_a_ramdisk = FALSE;
    157161        }
     
    160164        is_this_a_ramdisk = TRUE;
    161165    }
    162 
    163     log_msg(1, "Is this a ramdisk? result = %s", (is_this_a_ramdisk) ? "TRUE" : "FALSE");
     166    paranoid_free(comment);
     167    log_msg(1, "Is this a ramdisk? result = %d", is_this_a_ramdisk);
    164168    return (is_this_a_ramdisk);
    165169}
     
    225229int eject_device(char *dev)
    226230{
    227     char *command = NULL;
     231    char *command;
    228232    int res1 = 0, res2 = 0;
    229233
    230     if (dev == NULL) {
    231         return (1);
    232     }
     234    malloc_string(command);
    233235
    234236    if (IS_THIS_A_STREAMING_BACKUP(g_backup_media_type)
    235237        && g_backup_media_type != udev) {
    236         mr_asprintf(command, "mt -f %s offline", dev);
     238        sprintf(command, "mt -f %s offline", dev);
    237239        res1 = run_program_and_log_output(command, 1);
    238         mr_free(command);
    239240    } else {
    240241        res1 = 0;
     
    243244#ifdef __FreeBSD__
    244245    if (strstr(dev, "acd")) {
    245         mr_asprintf(command, "cdcontrol -f %s eject", dev);
     246        sprintf(command, "cdcontrol -f %s eject", dev);
    246247    } else {
    247         mr_asprintf(command, "camcontrol eject `echo %s | sed 's|/dev/||'`", dev);
     248        sprintf(command, "camcontrol eject `echo %s | sed 's|/dev/||'`",
     249                dev);
    248250    }
    249251#else
    250     mr_asprintf(command, "eject %s", dev);
     252    sprintf(command, "eject %s", dev);
    251253#endif
    252254
    253255    log_msg(3, "Ejecting %s", dev);
    254256    res2 = run_program_and_log_output(command, 1);
    255     mr_free(command);
     257    paranoid_free(command);
    256258    if (res1 && res2) {
    257259        return (1);
     
    268270int inject_device(char *dev)
    269271{
    270     char *command = NULL;
     272    char *command;
    271273    int i;
    272274
    273     if (dev == NULL) {
    274         return (1);
    275     }
     275    malloc_string(command);
     276
    276277
    277278#ifdef __FreeBSD__
    278279    if (strstr(dev, "acd")) {
    279         mr_asprintf(command, "cdcontrol -f %s close", dev);
     280        sprintf(command, "cdcontrol -f %s close", dev);
    280281    } else {
    281         mr_asprintf(command, "camcontrol load `echo %s | sed 's|/dev/||'`", dev);
     282        sprintf(command, "camcontrol load `echo %s | sed 's|/dev/||'`",
     283                dev);
    282284    }
    283285#else
    284     mr_asprintf(command, "eject -t %s", dev);
     286    sprintf(command, "eject -t %s", dev);
    285287#endif
    286288    i = run_program_and_log_output(command, FALSE);
    287     mr_free(command);
     289    paranoid_free(command);
    288290    return (i);
    289291}
     
    299301
    300302    /*@ buffers *********************************************************** */
    301     char *tmp = NULL;
     303    char *tmp;
    302304    bool ret;
    303305
     306    malloc_string(tmp);
    304307    assert_string_is_neither_NULL_nor_zerolength(device);
    305308
    306     mr_asprintf(tmp, "ls %s > /dev/null 2> /dev/null", device);
     309    sprintf(tmp, "ls %s > /dev/null 2> /dev/null", device);
    307310
    308311    if (system(tmp)) {
     
    311314        ret = TRUE;
    312315    }
    313     mr_free(tmp);
     316    paranoid_free(tmp);
    314317    return (ret);
    315318}
     
    342345{
    343346    /*@ buffers **************************************************** */
    344     char *program = NULL;
    345     char *incoming = NULL;
     347    char *program;
     348    char *incoming;
    346349    char *searchstr = NULL;
     350    char *tmp;
     351    char *p;
    347352
    348353    /*@ ints ******************************************************* */
     
    351356    /*@ pointers *************************************************** */
    352357    FILE *fin;
     358
    353359
    354360    /*@ end vars *************************************************** */
     
    356362    assert(partno >= 0 && partno < 999);
    357363
     364    malloc_string(program);
     365    malloc_string(incoming);
    358366    malloc_string(searchstr);
     367    malloc_string(tmp);
    359368
    360369#ifdef __FreeBSD__
    361370    // We assume here that this is running from mondorestore. (It is.)
    362     mr_asprintf(program, "ls %s %s >/dev/null 2>&1", drive, build_partition_name(tmp, drive, partno));
    363     res = system(program);
    364     mr_free(program);
    365     return(res);
    366 #endif
    367 
    368     mr_asprintf(program, "parted2fdisk -l %s 2> /dev/null", drive);
     371    sprintf(program, "ls %s %s >/dev/null 2>&1", drive,
     372            build_partition_name(tmp, drive, partno));
     373    return system(program);
     374#else
     375    tmp[0] = '\0';
     376#endif
     377
     378    sprintf(program, "parted2fdisk -l %s 2> /dev/null", drive);
    369379    fin = popen(program, "r");
    370380    if (!fin) {
    371381        log_it("program=%s", program);
    372382        log_OS_error("Cannot popen-in program");
    373         mr_free(program);
    374383        return (0);
    375384    }
    376     mr_free(program);
    377 
    378385    (void) build_partition_name(searchstr, drive, partno);
    379386    strcat(searchstr, " ");
    380     for (res = 0, mr_getline(incoming, fin); !res && !feof(fin) ; mr_getline(incoming, fin)) {
     387    for (res = 0; !res && (p = fgets(incoming, MAX_STR_LEN - 1, fin));) {
    381388        if (strstr(incoming, searchstr)) {
    382389            res = 1;
    383390        }
    384         mr_free(incoming);
    385     }
    386     mr_free(incoming);
    387 
     391    }
    388392    if (pclose(fin)) {
    389393        log_OS_error("Cannot pclose fin");
    390394    }
     395    paranoid_free(program);
     396    paranoid_free(incoming);
    391397    paranoid_free(searchstr);
     398    paranoid_free(tmp);
    392399    return (res);
    393400}
     
    406413{
    407414    /*@ buffers **************************************************** */
    408     char *command = NULL;
     415    char *command;
    409416
    410417    /*@ end vars *************************************************** */
     
    414421    assert_string_is_neither_NULL_nor_zerolength(str);
    415422
    416     /* For UEFI detection, this should be extended to count=2 */
    417     mr_asprintf(command, "dd if=%s bs=446 count=1 2> /dev/null | strings | grep \"%s\" > /dev/null 2> /dev/null", dev, str);
     423    malloc_string(command);
     424    sprintf(command,
     425            "dd if=%s bs=446 count=1 2> /dev/null | strings | grep \"%s\" > /dev/null 2> /dev/null",
     426            dev, str);
    418427    i = system(command);
    419     mr_free(command);
     428    paranoid_free(command);
    420429    if (i) {
    421430        return (FALSE);
     
    435444{
    436445    /*@ buffers **************************************************** */
    437     char *command = NULL;
     446    char *command;
    438447    /*@ end vars *************************************************** */
    439448    int i;
    440449
    441     mr_asprintf(command, "dd if=%s bs=512 count=%i 2> /dev/null | strings | grep \"%s\" > /dev/null 2> /dev/null", dev, n, str);
     450    malloc_string(command);
     451    sprintf(command,
     452            "dd if=%s bs=512 count=%i 2> /dev/null | strings | grep \"%s\" > /dev/null 2> /dev/null",
     453            dev, n, str);
    442454    i = system(command);
    443     mr_free(command);
     455    paranoid_free(command);
    444456    if (i) {
    445457        return (FALSE);
     
    454466 * Try to mount CD-ROM at @p mountpoint. If the CD-ROM is not found or has
    455467 * not been specified, call find_cdrom_device() to find it.
     468 * @param bkpinfo The backup information structure. The only field used is @c bkpinfo->media_device.
    456469 * @param mountpoint Where to mount the CD-ROM.
    457470 * @return 0 for success, nonzero for failure.
    458471 * @see mount_CDROM_here
    459472 */
    460 int find_and_mount_actual_cd(char *mountpoint) {
    461 
     473int find_and_mount_actual_cd(char *mountpoint)
     474{
    462475    /*@ buffers ***************************************************** */
    463476
    464477    /*@ int's  ****************************************************** */
    465478    int res;
    466     char *dev = NULL;
     479    char *dev;
    467480
    468481    /*@ end vars **************************************************** */
     
    519532{
    520533    /*@ buffers ************************ */
     534    char *comment;
    521535    char *tmp = NULL;
    522536    char *cdr_exe = NULL;
    523     char *command = NULL;
    524 
     537    char *command;
     538
     539    malloc_string(comment);
     540    malloc_string(command);
    525541    if (g_cdrw_drive_is_here[0]) {
    526542        strcpy(cdrw_device, g_cdrw_drive_is_here);
    527543        log_msg(3, "Been there, done that. Returning %s", cdrw_device);
     544        paranoid_free(comment);
     545        paranoid_free(command);
    528546        return (0);
    529547    }
    530548    if (g_backup_media_type == dvd) {
    531         log_msg(1, "This is dumb. You're calling find_cdrw_device() but you're backing up to DVD. WTF?");
     549        log_msg(1,
     550                "This is dumb. You're calling find_cdrw_device() but you're backing up to DVD. WTF?");
     551        paranoid_free(comment);
     552        paranoid_free(command);
    532553        return (1);
    533554    }
     
    539560    }
    540561    if (find_home_of_exe(cdr_exe)) {
    541         mr_asprintf(command, "%s -scanbus 2> /dev/null | tr -s '\t' ' ' | grep \"[0-9]*,[0-9]*,[0-9]*\" | grep -v \"[0-9]*) \\*\" | grep -E '[D|C][V|D]' | cut -d' ' -f2 | head -n1", cdr_exe);
     562        sprintf(command,
     563                "%s -scanbus 2> /dev/null | tr -s '\t' ' ' | grep \"[0-9]*,[0-9]*,[0-9]*\" | grep -v \"[0-9]*) \\*\" | grep -E '[D|C][V|D]' | cut -d' ' -f2 | head -n1",
     564                cdr_exe);
    542565        mr_asprintf(tmp, "%s", call_program_and_get_last_line_of_output(command));
    543         mr_free(command);
    544566    }
    545567    if ((tmp == NULL) || (strlen(tmp) < 2)) {
     568        paranoid_free(comment);
    546569        mr_free(tmp);
    547570        mr_free(cdr_exe);
     571        paranoid_free(command);
    548572        return 1;
    549573    } else {
    550574        strcpy(cdrw_device, tmp);
    551         log_it("Found CDRW device - %s", cdrw_device);
     575        sprintf(comment, "Found CDRW device - %s", cdrw_device);
     576        log_it(comment);
    552577        strcpy(g_cdrw_drive_is_here, cdrw_device);
     578        paranoid_free(comment);
    553579        mr_free(tmp);
    554580        mr_free(cdr_exe);
     581        paranoid_free(command);
    555582        return (0);
    556583    }
    557584}
     585
     586
    558587
    559588
     
    580609
    581610    /*@ buffers ***************************************************** */
    582     char *tmp = NULL;
     611    char *tmp;
    583612    char *tmp1 = NULL;
    584613    char *cdr_exe = NULL;
    585614    char *phrase_one;
    586     char *phrase_two = NULL;
    587     char *command = NULL;
    588 #ifndef __FreeBSD__
    589     char *dvd_last_resort = NULL;
    590 #endif
    591     char *mountpoint = NULL;
     615    char *phrase_two;
     616    char *command;
     617    char *dvd_last_resort;
     618    char *mountpoint;
    592619    static char the_last_place_i_found_it[MAX_STR_LEN] = "";
    593620
     
    595622    malloc_string(tmp);
    596623    malloc_string(phrase_one);
     624    malloc_string(phrase_two);
     625    malloc_string(command);
     626    malloc_string(dvd_last_resort);
    597627    malloc_string(mountpoint);
    598628
    599629    output[0] = '\0';
    600630    phrase_one[0] = '\0';
     631    phrase_two[0] = '\0';
     632    dvd_last_resort[0] = '\0';
    601633
    602634    /*@ end vars **************************************************** */
     
    610642    if (the_last_place_i_found_it[0] != '\0' && !try_to_mount) {
    611643        strcpy(output, the_last_place_i_found_it);
    612         log_msg(3, "find_cdrom_device() --- returning last found location - '%s'", output);
     644        log_msg(3,
     645                "find_cdrom_device() --- returning last found location - '%s'",
     646                output);
    613647        retval = 0;
    614648        goto end_of_find_cdrom_device;
     
    637671    }
    638672
    639     mr_asprintf(command, "%s -scanbus 2> /dev/null", cdr_exe);
     673    sprintf(command, "%s -scanbus 2> /dev/null", cdr_exe);
    640674    fin = popen(command, "r");
    641675    if (!fin) {
     
    643677        log_OS_error("Cannot popen command");
    644678        mr_free(cdr_exe);
    645         mr_free(command);
    646679        return (1);
    647680    }
    648     mr_free(command);
    649 
    650681    for (tmp1 = fgets(tmp, MAX_STR_LEN, fin); !feof(fin) && (tmp1 != NULL);
    651682         tmp1 = fgets(tmp, MAX_STR_LEN, fin)) {
     
    665696                        }
    666697                        *q = '\0';
    667                         mr_asprintf(phrase_two, "%s", p);
     698                        strcpy(phrase_two, p);
    668699                    }
    669700                }
     
    674705
    675706#ifndef __FreeBSD__
    676     if (!phrase_two || strlen(phrase_two) == 0) {
     707    if (strlen(phrase_two) == 0) {
    677708        log_msg(4, "Not running phase two. String is empty.");
    678709    } else {
    679         mr_asprintf(command, "dmesg | grep \"%s\" 2> /dev/null", phrase_two);
     710        sprintf(command, "dmesg | grep \"%s\" 2> /dev/null", phrase_two);
    680711        fin = popen(command, "r");
    681         mr_free(command);
    682 
    683712        if (!fin) {
    684713            log_msg(4, "Cannot run 2nd command - non-fatal, fortunately");
     
    692721                        *p = '\0';
    693722                        if (strstr(tmp, "DVD")) {
    694                             mr_free(dvd_last_resort);
    695                             mr_asprintf(dvd_last_resort, "/dev/%s", tmp);
    696                             log_msg(4, "Ignoring '%s' because it's a DVD drive", tmp);
     723                            sprintf(dvd_last_resort, "/dev/%s", tmp);
     724                            log_msg(4,
     725                                    "Ignoring '%s' because it's a DVD drive",
     726                                    tmp);
    697727                        } else {
    698728                            sprintf(output, "/dev/%s", tmp);
     
    745775#else
    746776    if (!found_it && strlen(dvd_last_resort) > 0) {
    747         log_msg(4, "Well, I'll use the DVD - %s - as a last resort", dvd_last_resort);
     777        log_msg(4, "Well, I'll use the DVD - %s - as a last resort",
     778                dvd_last_resort);
    748779        strcpy(output, dvd_last_resort);
    749780        found_it = TRUE;
    750781    }
    751782    if (found_it) {
    752         sprintf(tmp, "grep \"%s=ide-scsi\" /proc/cmdline &> /dev/null", strrchr(output, '/') + 1);
     783        sprintf(tmp, "grep \"%s=ide-scsi\" /proc/cmdline &> /dev/null",
     784                strrchr(output, '/') + 1);
    753785        if (system(tmp) == 0) {
    754             log_msg(4, "%s is not right. It's being SCSI-emulated. Continuing.", output);
     786            log_msg(4,
     787                    "%s is not right. It's being SCSI-emulated. Continuing.",
     788                    output);
    755789            found_it = FALSE;
    756790            output[0] = '\0';
     
    818852                found_it = FALSE;
    819853            } else {
    820                 mr_asprintf(command, "umount %s", output);
     854                sprintf(command, "umount %s", output);
    821855                paranoid_system(command);
    822                 mr_free(command);
    823 
    824856                log_msg(4, "I'm confident the Mondo CD is in %s", output);
    825857            }
     
    840872    }
    841873
    842     mr_asprintf(command, "%s -scanbus | grep \"[0-9],[0-9],[0-9]\" | grep -E \"[D|C][V|D]\" | grep -n \"\" | grep \"%s\" | cut -d':' -f2", cdr_exe, g_cdrw_drive_is_here);
    843 
     874    sprintf(command,
     875            "%s -scanbus | grep \"[0-9],[0-9],[0-9]\" | grep -E \"[D|C][V|D]\" | grep -n \"\" | grep \"%s\" | cut -d':' -f2",
     876            cdr_exe, g_cdrw_drive_is_here);
    844877    log_msg(1, "command=%s", command);
    845878    mr_asprintf(tmp1, "%s", call_program_and_get_last_line_of_output(command));
    846     mr_free(command);
    847 
    848879    if (strlen(tmp1) > 0) {
    849880        strcpy(output, tmp1);
     
    857888
    858889  end_of_find_cdrom_device:
     890    paranoid_free(tmp);
    859891    mr_free(cdr_exe);
    860     mr_free(phrase_two);
    861     mr_free(dvd_last_resort);
    862 
    863     paranoid_free(tmp);
    864892    paranoid_free(phrase_one);
     893    paranoid_free(phrase_two);
     894    paranoid_free(command);
     895    paranoid_free(dvd_last_resort);
    865896    paranoid_free(mountpoint);
    866897    return (retval);
     
    868899
    869900
     901
     902
     903
    870904int find_dvd_device(char *output, bool try_to_mount)
    871905{
     906    char *command;
    872907    char *tmp;
    873908    int retval = 0, devno = -1;
     909
     910    malloc_string(command);
     911    malloc_string(tmp);
    874912
    875913    if (g_dvd_drive_is_here[0]) {
     
    879917    }
    880918
    881     malloc_string(tmp);
    882     mr_asprintf(tmp, "%s", 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"));
     919    sprintf(tmp, "%s", 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"));
    883920    log_msg(5, "tmp = '%s'", tmp);
    884     if (!tmp[0]) {
    885         mr_free(tmp);
    886         mr_asprintf(tmp, "%s", 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"));
    887     }
     921    if (!tmp[0])
     922        sprintf(tmp, "%s", call_program_and_get_last_line_of_output
     923                ("cdrecord -scanbus 2> /dev/null | grep \)\ \' | grep -n '' | grep -E '[D|C][V|D]' | cut -d':' -f1")
     924            );
    888925    if (tmp[0]) {
    889926        devno = atoi(tmp) - 1;
    890927    }
    891     mr_free(tmp);
    892 
    893928    if (devno >= 0) {
    894929        retval = 0;
     
    901936    }
    902937
     938    if (try_to_mount) {
     939        log_msg(1, "Ignoring the fact that try_to_mount==TRUE");
     940    }
    903941    return (retval);
    904942}
     
    10151053{
    10161054    char *good_formats = NULL;
    1017     char *command = NULL;
    1018     char *format_sz = NULL;
     1055    char *command;
     1056    char *format_sz;
    10191057    char *p;
    10201058
     
    10221060    int retval;
    10231061    malloc_string(good_formats);
     1062    malloc_string(command);
     1063    malloc_string(format_sz);
    10241064
    10251065    assert_string_is_neither_NULL_nor_zerolength(format);
    10261066
    1027     mr_asprintf(format_sz, "%s ", format);
     1067    sprintf(format_sz, "%s ", format);
    10281068
    10291069#ifdef __FreeBSD__
    1030     mr_asprintf(command, "lsvfs | tr -s '\t' ' ' | grep -v Filesys | grep -v -- -- | cut -d' ' -f1 | tr -s '\n' ' '");
     1070    sprintf(command,
     1071            "lsvfs | tr -s '\t' ' ' | grep -v Filesys | grep -v -- -- | cut -d' ' -f1 | tr -s '\n' ' '");
    10311072#else
    1032     mr_asprintf(command, "grep -v nodev /proc/filesystems | tr -s '\t' ' ' | cut -d' ' -f2 | tr -s '\n' ' '");
     1073    sprintf(command,
     1074            "grep -v nodev /proc/filesystems | tr -s '\t' ' ' | cut -d' ' -f2 | tr -s '\n' ' '");
    10331075#endif
    10341076
    10351077    pin = popen(command, "r");
    1036     mr_free(command);
    1037 
    10381078    if (!pin) {
    10391079        log_OS_error("Unable to read good formats");
     
    10541094    }
    10551095    paranoid_free(good_formats);
    1056     mr_free(format_sz);
    1057 
     1096    paranoid_free(command);
     1097    paranoid_free(format_sz);
    10581098    return (retval);
    10591099}
     
    10741114
    10751115    /*@ buffers ***************************************************** */
    1076     char *incoming = NULL;
     1116    char *incoming;
    10771117    char *device_with_tab = NULL;
    10781118    char *device_with_space = NULL;
     
    10881128    /*@ end vars **************************************************** */
    10891129
    1090     if (device_raw == NULL) {
    1091         return(FALSE);
    1092     }
    1093 
     1130    malloc_string(incoming);
     1131    assert(device_raw != NULL);
     1132//  assert_string_is_neither_NULL_nor_zerolength(device_raw);
    10941133    if (device_raw[0] != '/' && !strstr(device_raw, ":/")) {
    10951134        log_msg(1, "%s needs to have a '/' prefixed - I'll do it",
     
    11141153        return(FALSE);
    11151154    }
    1116 
    1117     for (mr_getline(incoming, fin); !feof(fin); mr_getline(incoming, fin)) {
    1118         if (strstr(incoming, device_with_space) || strstr(incoming, device_with_tab)) {
     1155    for (tmp = fgets(incoming, MAX_STR_LEN - 1, fin); !feof(fin) && (tmp != NULL);
     1156         tmp = fgets(incoming, MAX_STR_LEN - 1, fin)) {
     1157        if (strstr(incoming, device_with_space) //> incoming
     1158            || strstr(incoming, device_with_tab))   // > incoming)
     1159        {
    11191160            paranoid_pclose(fin);
    1120             mr_free(incoming);
     1161            paranoid_free(incoming);
    11211162            return(TRUE);
    11221163        }
    1123         mr_free(incoming);
    1124     }
    1125     mr_free(incoming);
     1164    }
    11261165    mr_free(device_with_tab);
    11271166    paranoid_pclose(fin);
     
    11331172    }
    11341173    mr_free(tmp);
     1174    paranoid_free(incoming);
    11351175    return(retval);
    11361176}
     
    11491189    char command[MAX_STR_LEN];
    11501190    int vndev = 2;
    1151     if (atoi(call_program_and_get_last_line_of_output("/sbin/sysctl -n kern.osreldate")) < 500000) {
     1191    if (atoi
     1192        (call_program_and_get_last_line_of_output
     1193         ("/sbin/sysctl -n kern.osreldate")) < 500000) {
    11521194        do {
    11531195            sprintf(mddevice, "vn%ic", vndev++);
     
    11811223int kick_vn(char *dname)
    11821224{
    1183     char *command = NULL;
    1184     int res = 0;
     1225    char command[MAX_STR_LEN];
    11851226
    11861227    if (strncmp(dname, "/dev/", 5) == 0) {
     
    11881229    }
    11891230
    1190     if (atoi(call_program_and_get_last_line_of_output("/sbin/sysctl -n kern.osreldate")) < 500000) {
    1191         mr_asprintf(command, "vnconfig -d %s", dname);
     1231    if (atoi
     1232        (call_program_and_get_last_line_of_output
     1233         ("/sbin/sysctl -n kern.osreldate")) < 500000) {
     1234        sprintf(command, "vnconfig -d %s", dname);
     1235        return system(command);
    11921236    } else {
    1193         mr_asprintf(command, "mdconfig -d -u %s", dname);
    1194     }
    1195     res = system(command);
    1196     mr_free(command);
    1197     return(res);
     1237        sprintf(command, "mdconfig -d -u %s", dname);
     1238        return system(command);
     1239    }
     1240     /*NOTREACHED*/ return 255;
    11981241}
    11991242#endif
     
    12091252{
    12101253    /*@ buffer ****************************************************** */
    1211     char *command = NULL;
     1254    char *command;
    12121255    int retval;
    12131256
     1257    malloc_string(command);
    12141258    assert_string_is_neither_NULL_nor_zerolength(device);
    12151259    assert_string_is_neither_NULL_nor_zerolength(mountpoint);
     
    12191263        return(1);
    12201264    }
    1221     log_msg(4, "(mount_USB_here --- device=%s, mountpoint=%s", device, mountpoint);
     1265    log_msg(4, "(mount_USB_here --- device=%s, mountpoint=%s", device,
     1266            mountpoint);
    12221267
    12231268#ifdef __FreeBSD__
    1224     mr_asprintf(command, "mount_vfat %s %s 2>> %s", device, mountpoint, MONDO_LOGFILE);
     1269    sprintf(command, "mount_vfat %s %s 2>> %s",
     1270            device, mountpoint, MONDO_LOGFILE);
    12251271
    12261272#else
    1227     mr_asprintf(command, "mount %s -t vfat %s 2>> %s", device, mountpoint, MONDO_LOGFILE);
     1273    sprintf(command, "mount %s -t vfat %s 2>> %s",
     1274            device, mountpoint, MONDO_LOGFILE);
    12281275#endif
    12291276
     
    12311278    retval = system(command);
    12321279    log_msg(1, "system(%s) returned %d", command, retval);
    1233     mr_free(command);
    1234 
     1280
     1281    paranoid_free(command);
    12351282    return (retval);
    12361283}
     
    12421289 * @return 0 for success, nonzero for failure.
    12431290 */
    1244 int mount_CDROM_here(char *device, const char *mountpoint)
     1291int mount_CDROM_here(char *device, char *mountpoint)
    12451292{
    12461293    /*@ buffer ****************************************************** */
     
    12801327
    12811328    }
    1282     log_msg(4, "(mount_CDROM_here --- device=%s, mountpoint=%s", device, mountpoint);
     1329    log_msg(4, "(mount_CDROM_here --- device=%s, mountpoint=%s", device,
     1330            mountpoint);
    12831331    /*@ end vars *************************************************** */
    12841332
     
    12971345    retval = system(command);
    12981346    log_msg(1, "system(%s) returned %d", command, retval);
    1299     mr_free(command);
     1347    paranoid_free(command);
    13001348
    13011349    return (retval);
     
    13141362int mount_media()
    13151363{
    1316 char *mount_cmd = NULL;
     1364char *mount_cmd;
    13171365char *mountdir = NULL;
    13181366int i, res;
    13191367#ifdef __FreeBSD__
    1320     char mdd[32];
    1321     char *mddev = mdd;
    1322 #endif
    1323 
    1324     if (bkpinfo->backup_media_type == tape || bkpinfo->backup_media_type == udev) {
     1368char mdd[32];
     1369char *mddev = mdd;
     1370#endif
     1371
     1372malloc_string(mount_cmd);
     1373assert(bkpinfo != NULL);
     1374
     1375    if (bkpinfo->backup_media_type == tape
     1376        || bkpinfo->backup_media_type == udev) {
    13251377        log_msg(8, "Tape/udev. Therefore, no need to mount a media.");
     1378        paranoid_free(mount_cmd);
    13261379        return 0;
    13271380    }
     
    13291382    if (!run_program_and_log_output("mount | grep -F " MNT_CDROM, FALSE)) {
    13301383        log_msg(2, "mount_media() - media already mounted. Fair enough.");
     1384        paranoid_free(mount_cmd);
    13311385        return (0);
    13321386    }
     
    13351389        log_msg(2, "Mounting for Network thingy");
    13361390        log_msg(2, "isodir = %s", bkpinfo->isodir);
    1337         if ((!bkpinfo->isodir[0] || !strcmp(bkpinfo->isodir, "/")) && am_I_in_disaster_recovery_mode()) {
     1391        if ((!bkpinfo->isodir[0] || !strcmp(bkpinfo->isodir, "/"))
     1392            && am_I_in_disaster_recovery_mode()) {
    13381393            strcpy(bkpinfo->isodir, "/tmp/isodir");
    13391394            log_msg(1, "isodir is being set to %s", bkpinfo->isodir);
    13401395        }
    13411396#ifdef __FreeBSD__
    1342         mr_asprintf(mount_cmd, "/mnt/isodir/%s/%s/%s-%d.iso", bkpinfo->isodir,
     1397        sprintf(mount_cmd, "/mnt/isodir/%s/%s/%s-%d.iso", bkpinfo->isodir,
    13431398            bkpinfo->netfs_remote_dir, bkpinfo->prefix, g_current_media_number);
    13441399        mddev = make_vn(mount_cmd);
    1345         mr_free(mount_cmd);
    1346 
    1347         mr_asprintf(mount_cmd, "mount_cd9660 -r %s " MNT_CDROM, mddev);
     1400        sprintf(mount_cmd, "mount_cd9660 -r %s " MNT_CDROM, mddev);
    13481401#else
    1349         mr_asprintf(mount_cmd, "mount %s/%s/%s-%d.iso -t iso9660 -o loop,ro %s", bkpinfo->isodir, bkpinfo->netfs_remote_dir, bkpinfo->prefix, g_current_media_number, MNT_CDROM);
     1402        sprintf(mount_cmd, "mount %s/%s/%s-%d.iso -t iso9660 -o loop,ro %s",
     1403            bkpinfo->isodir, bkpinfo->netfs_remote_dir,
     1404            bkpinfo->prefix, g_current_media_number, MNT_CDROM);
    13501405#endif
    13511406
     
    13571412        }
    13581413#ifdef __FreeBSD__
    1359         mr_asprintf(mount_cmd, "%s/%s-%d.iso", mountdir, bkpinfo->prefix, g_current_media_number);
     1414        sprintf(mount_cmd, "%s/%s-%d.iso", mountdir,
     1415            bkpinfo->prefix, g_current_media_number);
    13601416        mddev = make_vn(mount_cmd);
    1361         mr_free(mount_cmd);
    1362 
    1363         mr_asprintf(mount_cmd, "mount_cd9660 -r %s %s", mddev, MNT_CDROM);
     1417        sprintf(mount_cmd, "mount_cd9660 -r %s %s", mddev, MNT_CDROM);
    13641418#else
    1365         mr_asprintf(mount_cmd, "mount %s/%s-%d.iso -t iso9660 -o loop,ro %s", mountdir, bkpinfo->prefix, g_current_media_number, MNT_CDROM);
     1419        sprintf(mount_cmd, "mount %s/%s-%d.iso -t iso9660 -o loop,ro %s",
     1420            mountdir, bkpinfo->prefix, g_current_media_number, MNT_CDROM);
    13661421#endif
    13671422        mr_free(mountdir);
    13681423    } else if (bkpinfo->backup_media_type == usb) {
    1369         mr_asprintf(mount_cmd, "mount -t vfat %s %s", bkpinfo->media_device, MNT_CDROM);
     1424        sprintf(mount_cmd, "mount -t vfat %s %s", bkpinfo->media_device, MNT_CDROM);
    13701425    } else if (strstr(bkpinfo->media_device, "/dev/")) {
    13711426#ifdef __FreeBSD__
    1372         mr_asprintf(mount_cmd, "mount_cd9660 -r %s %s", bkpinfo->media_device, MNT_CDROM);
     1427        sprintf(mount_cmd, "mount_cd9660 -r %s %s", bkpinfo->media_device,
     1428        MNT_CDROM);
    13731429#else
    1374         mr_asprintf(mount_cmd, "mount %s -t iso9660 -o ro %s", bkpinfo->media_device, MNT_CDROM);
     1430        sprintf(mount_cmd, "mount %s -t iso9660 -o ro %s",
     1431        bkpinfo->media_device, MNT_CDROM);
    13751432#endif
    13761433    } else {
     
    13841441
    13851442#ifdef __FreeBSD__
    1386         mr_asprintf(mount_cmd, "mount_cd9660 -r %s %s", bkpinfo->media_device, MNT_CDROM);
     1443    sprintf(mount_cmd, "mount_cd9660 -r %s %s", bkpinfo->media_device,
     1444        MNT_CDROM);
    13871445#else
    1388         mr_asprintf(mount_cmd, "mount %s -t iso9660 -o ro %s", bkpinfo->media_device, MNT_CDROM);
     1446    sprintf(mount_cmd, "mount %s -t iso9660 -o ro %s",
     1447        bkpinfo->media_device, MNT_CDROM);
    13891448#endif
    13901449    }
     
    13981457            log_msg(2, "Failed to mount device.");
    13991458            sleep(5);
    1400             sync();
    1401         }
    1402     }
    1403     mr_free(mount_cmd);
     1459            run_program_and_log_output("sync", FALSE);
     1460        }
     1461    }
    14041462
    14051463    if (res) {
     
    14081466        log_msg(2, "Mounted media drive OK");
    14091467    }
     1468    paranoid_free(mount_cmd);
    14101469    return (res);
    14111470}
     
    14371496
    14381497    /*@ buffers ********************************************************* */
    1439     char *tmp = NULL;
     1498    char *tmp;
    14401499    char *mds = NULL;
    1441     char *request = NULL;
     1500    char *request;
    14421501
    14431502    assert(bkpinfo != NULL);
     
    14511510        return;
    14521511    }
    1453     mr_asprintf(tmp, "mkdir -p " MNT_CDROM);
     1512    if (g_ISO_restore_mode || bkpinfo->backup_media_type == iso
     1513        || bkpinfo->backup_media_type == netfs) {
     1514        g_ISO_restore_mode = TRUE;
     1515    }
     1516    malloc_string(tmp);
     1517    malloc_string(request);
     1518    sprintf(tmp, "mkdir -p " MNT_CDROM);
    14541519    run_program_and_log_output(tmp, 5);
    1455     mr_free(tmp);
    1456 
    1457     if (g_ISO_restore_mode || bkpinfo->backup_media_type == iso || bkpinfo->backup_media_type == netfs) {
    1458         g_ISO_restore_mode = TRUE;
    1459     }
    14601520    if ((res = what_number_cd_is_this()) != cd_number_i_want) {
    1461         log_msg(3, "Currently, we hold %d but we want %d", res, cd_number_i_want);
     1521        log_msg(3, "Currently, we hold %d but we want %d", res,
     1522                cd_number_i_want);
    14621523
    14631524        /* Now we need to umount the current media to have the next mounted after */
     
    14681529
    14691530        mds = media_descriptor_string(bkpinfo->backup_media_type);
    1470         log_msg(3, "Insisting on %s #%d", mds, cd_number_i_want);
    1471         mr_asprintf(request, "Please insert %s #%d and press Enter.", mds, cd_number_i_want);
     1531        sprintf(tmp, "Insisting on %s #%d", mds, cd_number_i_want);
     1532        sprintf(request, "Please insert %s #%d and press Enter.", mds, cd_number_i_want);
    14721533        mr_free(mds);
    1473 
     1534        log_msg(3, tmp);
    14741535        while (what_number_cd_is_this() != cd_number_i_want) {
    1475             sync();
     1536            paranoid_system("sync");
    14761537            if (is_this_device_mounted(MNT_CDROM)) {
    14771538                res =
     
    14951556                inject_device(bkpinfo->media_device);
    14961557            }
    1497             sync();
    1498         }
    1499         mr_free(request);
    1500 
     1558            paranoid_system("sync");
     1559        }
    15011560        log_msg(1, "Thankyou. Proceeding...");
    15021561        g_current_media_number = cd_number_i_want;
    15031562    }
     1563    paranoid_free(tmp);
     1564    paranoid_free(request);
    15041565}
    15051566
     
    16151676    log_msg(5, "Running: %s", command);
    16161677    mr_asprintf(mounted_file_system, "%s", call_program_and_get_last_line_of_output(command));
    1617     mr_free(command);
     1678    paranoid_free(command);
    16181679
    16191680    mount_cnt = atoi(mounted_file_system);
    16201681    log_msg (5, "mount_cnt: %d", mount_cnt);
    1621     mr_free(mounted_file_system);
     1682    paranoid_free(mounted_file_system);
    16221683
    16231684    for (i=mount_cnt; i > 0; i--) {
     
    16251686        log_msg(5, "Running: %s", command);
    16261687        mr_asprintf(mounted_file_system, "%s", call_program_and_get_last_line_of_output(command));
    1627         mr_free(command);
     1688        paranoid_free(command);
    16281689
    16291690        log_msg (5, "mounted_file_system: %s", mounted_file_system);
    16301691        if ((token = mr_strtok(mounted_file_system, token_chars, &lastpos)) == NULL) {
    16311692            log_msg (4, "Could not get the list of mounted file systems");
    1632             mr_free(mounted_file_system);
     1693            paranoid_free(mounted_file_system);
    16331694            mr_free(token);
    16341695            return (1);
     
    16581719        mr_free(mounted_file_system);
    16591720    }
     1721    /********
     1722    * DSFptr = DSF_Head;
     1723    * while (DSFptr != NULL) {
     1724    * printf ("Dev: %s  MP: %s  Check: %d\n", DSFptr->device, DSFptr->mount_point, DSFptr->check);
     1725    * DSFptr = DSFptr->next;
     1726    * }
     1727    ********/
    16601728    return (0);
    16611729}
     
    17051773    log_msg(5, "  Executing: %s", command);
    17061774    mr_asprintf(tmp, "%s", call_program_and_get_last_line_of_output(command));
    1707     mr_free(command);
     1775    paranoid_free(command);
    17081776
    17091777    log_msg(5, "  Return value: %s", tmp);
    17101778    c = atoi(tmp);
    1711     mr_free(tmp);
     1779    paranoid_free(tmp);
    17121780
    17131781    if (!c) {
     
    17311799    log_msg(5, "Executing: %s", command);
    17321800    mr_asprintf(partition_list, "%s", call_program_and_get_last_line_of_output(command));
    1733     mr_free(command);
     1801    paranoid_free(command);
    17341802    log_msg(4, "Partition list for %s: %s", dsf, partition_list);
    17351803    if (!strlen(partition_list)) {
     
    17941862        log_msg(4, "Processing partition: %s", partitions[i]);
    17951863        /* See if it's swap. If it is, ignore it. */
    1796         mr_asprintf(command, "parted2fdisk -l %s 2>/dev/null | awk '{if(($1==\"%s\")&&(toupper($0) ~ \"SWAP\")){print $1;exit}}'", ndsf, partitions[i]);
     1864        mr_asprintf(command, "parted2fdisk -l %s 2>/dev/null | awk '{if(($1==\"%s\")&&(toupper($0) ~ \"SWAP\")){print $1;exit}}'",
     1865          ndsf, partitions[i]);
    17971866        log_msg(5, "  Running: %s", command);
    17981867        mr_asprintf(tmp, "%s", call_program_and_get_last_line_of_output(command));
    1799         mr_free(command);
    1800 
     1868        paranoid_free(command);
    18011869        log_msg(5, "  Return value: %s", tmp);
    18021870        c = strlen(tmp);
    1803         mr_free(tmp);
    1804 
     1871        paranoid_free(tmp);
    18051872        if (c) {
    18061873            log_msg(4, "It's swap. Ignoring partition %s", partitions[i]);
    18071874            continue;
    18081875        }
    1809 
    18101876        /* It's not swap. See if we can find the mount point from the mount command. */
    18111877        mr_asprintf(command, "mount 2>/dev/null | awk '{if((NF>0)&&($1==\"%s\")){print $3}}'", partitions[i]);
    18121878        mr_asprintf(tmp, "%s", call_program_and_get_last_line_of_output(command));
    1813         mr_free(command);
    1814 
     1879        paranoid_free(command);
    18151880        if (strlen(tmp)) {
    18161881            log_msg(4, "  %s is mounted: %s", partitions[i], tmp);
    18171882            if ((DSFptr = find_mount_point_in_list(tmp)) == NULL) {
    18181883                log_msg (4, "Can't find mount point %s in mounted file systems list", tmp);
    1819                 mr_free(tmp);
     1884                paranoid_free(tmp);
    18201885                return (1);
    18211886            }
    18221887            DSFptr->check = 1;
    1823             mr_free(tmp);
     1888            paranoid_free(tmp);
    18241889            continue;
    18251890        }
    1826         mr_free(tmp);
    1827 
     1891        paranoid_free(tmp);
    18281892        /* It's not swap and it's not mounted. See if it's LVM */
    18291893        log_msg(4, "  It's not mounted. Checking to see if it's LVM...");
    1830 
    18311894        /* Check for LVM */
    18321895        mr_asprintf(command, "pvdisplay -c %s 2> /dev/null", partitions[i]);
    18331896        log_msg(5, "  Running: %s", command);
    18341897        mr_asprintf(tmp, "%s", call_program_and_get_last_line_of_output(command));
    1835         mr_free(command);
    1836 
     1898        paranoid_free(command);
    18371899        if (strlen(tmp)) {
    18381900            log_msg(4, "Found an LVM partition at %s. Find the VG it's in...", partitions[i]);
     
    18411903            log_msg(5, "  Running: %s", command);
    18421904            strcpy(VG, call_program_and_get_last_line_of_output(command));
    1843             mr_free(command);
    1844 
     1905            paranoid_free(command);
    18451906            log_msg(4, "  Volume Group: %s", VG);
    18461907            if (strlen(VG)) {
     
    18501911                log_msg(5, "  Running: %s", command);
    18511912                mr_asprintf(mount_list, "%s", call_program_and_get_last_line_of_output(command));
    1852                 mr_free(command);
    1853 
     1913                paranoid_free(command);
    18541914                log_msg(4, "  VG %s mount_list: %s", VG, mount_list);
    18551915                lastpos = 0;
     
    18581918                    if ((DSFptr = find_mount_point_in_list(token)) == NULL) {
    18591919                        log_msg (4, "Can't find mount point %s in mounted file systems list", token);
    1860                         mr_free(tmp);
     1920                        paranoid_free(tmp);
    18611921                        mr_free(token);
    18621922                        return (1);
     
    18691929                 * any of the Logical Volumes on the Volume Group.
    18701930                 *******/
    1871                 mr_free(mount_list);
     1931                paranoid_free(mount_list);
    18721932
    18731933                mr_asprintf(command, "%s", "cat /proc/mdstat|grep -iv Personal|awk '{if($0~\"^.*[ ]+:\"){printf(\"/dev/%s \", $1)}}END{print \"\"}'");
    18741934                log_msg (5, "Running: %s", command);
    18751935                mr_asprintf(mount_list, "%s", call_program_and_get_last_line_of_output(command));
    1876                 mr_free(command);
     1936                paranoid_free(command);
    18771937                log_msg(4, "  Software raid device list: %s", mount_list);
    18781938                lastpos = 0;
     
    18801940                    mr_asprintf(command, "mdadm --detail %s 2>/dev/null | grep -c %s", token, VG);
    18811941                    log_msg (5, "Running: %s", command);
    1882                     mr_free(tmp);
     1942                    paranoid_free(tmp);
    18831943                    mr_asprintf(tmp, "%s", call_program_and_get_last_line_of_output(command));
    1884                     mr_free(command);
     1944                    paranoid_free(command);
    18851945                    log_msg(4, "Number of Software raid device: %s", tmp);
    18861946                    if (atoi(tmp)) {
     
    18881948                        if ((DSFptr = find_device_in_list(token)) == NULL) {
    18891949                            log_msg (4, "Can't find device %s in mounted file systems list", token);
    1890                             mr_free(tmp);
     1950                            paranoid_free(tmp);
    18911951                            mr_free(token);
    18921952                            return (1);
     
    18991959            } else {
    19001960                log_msg (4, "Error finding Volume Group for partition %s", partitions[i]);
    1901                 mr_free(tmp);
     1961                paranoid_free(tmp);
    19021962                return (1);
    19031963            }
    1904             mr_free(tmp);
     1964            paranoid_free(tmp);
    19051965            continue;
    19061966        } else {
    19071967            log_msg (4, "Error finding partition type for the partition %s", partitions[i]);
    19081968        }
    1909         mr_free(tmp);
    1910 
     1969        paranoid_free(tmp);
    19111970        /********
    19121971         * It's not swap, mounted, or LVM. See if it's used in a software raid device.
     
    19161975        log_msg(4, "  Running: %s", command);
    19171976        mr_asprintf(tmp, "%s", call_program_and_get_last_line_of_output(command));
    1918         mr_free(command);
    1919 
     1977        paranoid_free(command);
    19201978        if (!strlen(tmp)) {
    19211979            log_msg(4, "  Partition %s is not used in a non-LVM software raid device", partitions[i]);
    1922             mr_free(tmp);
     1980            paranoid_free(tmp);
    19231981            continue;
    19241982        }
    19251983        log_msg (5, "  UUID: %s", tmp);
    1926 
    19271984        /* Get the Software raid device list */
    19281985        mr_asprintf(command, "%s", "cat /proc/mdstat|grep -iv Personal|awk '{if($0~\"^.*[ ]+:\"){printf(\"/dev/%s \", $1)}}END{print \"\"}'");
    19291986        log_msg (5, "  Running: %s", command);
    19301987        mr_asprintf(mount_list, "%s", call_program_and_get_last_line_of_output(command));
    1931         mr_free(command);
    1932 
     1988        paranoid_free(command);
    19331989        log_msg(4, "  Software raid device list: %s", mount_list);
    19341990        /* Loop through the software raid device list to see if we can find the partition */
     
    19371993            mr_asprintf(command, "mdadm --detail %s 2>/dev/null | grep -c %s", token, tmp);
    19381994            log_msg(4, "  Running: %s", command);
    1939             mr_free(tmp);
     1995            paranoid_free(tmp);
    19401996            mr_asprintf(tmp, "%s", call_program_and_get_last_line_of_output(command));
    1941             mr_free(command);
    1942 
     1997            paranoid_free(command);
    19431998            if (!atoi(tmp)) {
    19441999                log_msg (4,"  Didn't find partition %s in software raid device %s", partitions[i], token);
     
    19462001                if ((DSFptr = find_device_in_list(token)) == NULL) {
    19472002                    log_msg (4, "Can't find device %s in mounted file systems list", token);
    1948                     mr_free(tmp);
     2003                    paranoid_free(tmp);
    19492004                    mr_free(token);
    19502005                    return (1);
     
    19552010            mr_free(token);
    19562011        }
    1957         mr_free(tmp);
    1958         mr_free(mount_list);
     2012        paranoid_free(tmp);
     2013        paranoid_free(mount_list);
    19592014    }
    19602015
     
    19922047    return (0);
    19932048}
     2049
     2050
     2051
    19942052
    19952053
     
    20412099            log_to_screen("Archiving only the following file systems on %s:", token);
    20422100            log_to_screen("==> %s", mounted_on_dsf);
    2043             mr_free(bkpinfo->include_paths);
    2044             mr_asprintf(bkpinfo->include_paths, "%s", "/");
     2101            strcpy(bkpinfo->include_paths, "/");
    20452102            if (strlen(not_mounted_on_dsf)) {
    20462103                log_msg (5, "Adding to bkpinfo->exclude_paths due to -I option: %s", not_mounted_on_dsf);
     
    20792136            mr_asprintf(tmp,"|%s|",bkpinfo->include_paths);
    20802137            if (strstr(tmp,tmp2) == NULL) {
    2081                 mr_strcat(bkpinfo->include_paths, "%s", tmp1);
     2138                strcat(bkpinfo->include_paths,tmp1);
    20822139            }
    20832140            mr_free(tmp1);
     
    21242181    char *q = NULL;
    21252182    char p[16*MAX_STR_LEN];
    2126     char *sz_size = NULL;
    2127     char *command = NULL;
     2183    char *sz_size;
     2184    char *command;
    21282185    char *compression_type = NULL;
    2129     char *comment = NULL;
     2186    char *comment;
     2187    char *prompt;
    21302188    int i;
    21312189    FILE *fin;
    21322190
     2191    malloc_string(sz_size);
     2192    malloc_string(command);
     2193    malloc_string(comment);
     2194    malloc_string(prompt);
    21332195    malloc_string(tmp1);
    21342196    assert(bkpinfo != NULL);
     2197    sz_size[0] = '\0';
    21352198    bkpinfo->nonbootable_backup = FALSE;
    21362199
     
    21692232        setup_scratchdir(tmp);
    21702233    }
    2171     log_msg(3, "media type = %s", bkptype_to_string(bkpinfo->backup_media_type));
     2234    log_msg(3, "media type = %s",
     2235            bkptype_to_string(bkpinfo->backup_media_type));
    21722236    bkpinfo->cdrw_speed = (bkpinfo->backup_media_type == cdstream) ? 2 : 4;
    2173     bkpinfo->compression_level = (bkpinfo->backup_media_type == cdstream) ? 1 : 5;
    2174     bkpinfo->use_lzo = (bkpinfo->backup_media_type == cdstream) ? TRUE : FALSE;
     2237    bkpinfo->compression_level =
     2238        (bkpinfo->backup_media_type == cdstream) ? 1 : 5;
     2239    bkpinfo->use_lzo =
     2240        (bkpinfo->backup_media_type == cdstream) ? TRUE : FALSE;
    21752241    mvaddstr_and_log_it(2, 0, " ");
    21762242
     
    21872253        if (archiving_to_media) {
    21882254            if ((bkpinfo->backup_media_type != dvd) && (bkpinfo->backup_media_type != usb)) {
    2189                 if (ask_me_yes_or_no("Is your computer a laptop, or does the CD writer incorporate BurnProof technology?")) {
     2255                if (ask_me_yes_or_no
     2256                    ("Is your computer a laptop, or does the CD writer incorporate BurnProof technology?"))
     2257                {
    21902258                    bkpinfo->manual_cd_tray = TRUE;
    21912259                }
     
    21952263                finish(1);
    21962264            }
    2197 
    2198             if ((bkpinfo->compression_level = which_compression_level()) == -1) {
     2265            if ((bkpinfo->compression_level =
     2266                which_compression_level()) == -1) {
    21992267                log_to_screen("User has chosen not to backup the PC");
    22002268                finish(1);
    22012269            }
    22022270            mds = media_descriptor_string(bkpinfo->backup_media_type);
    2203             mr_asprintf(comment, "What speed is your %s (re)writer?", mds);
     2271            sprintf(comment, "What speed is your %s (re)writer?", mds);
    22042272            if (bkpinfo->backup_media_type == dvd) {
    22052273                find_dvd_device(bkpinfo->media_device, FALSE);
    22062274                strcpy(tmp1, "1");
    2207                 mr_asprintf(sz_size, "%d", DEFAULT_DVD_DISK_SIZE);  // 4.7 salesman's GB = 4.482 real GB = 4482 MB
     2275                sprintf(sz_size, "%d", DEFAULT_DVD_DISK_SIZE);  // 4.7 salesman's GB = 4.482 real GB = 4482 MB
    22082276                log_msg(1, "Setting to DVD defaults");
    22092277            } else {
    22102278                strcpy(bkpinfo->media_device, VANILLA_SCSI_CDROM);
    22112279                strcpy(tmp1, "4");
    2212                 mr_asprintf(sz_size, "%d", 650);
     2280                strcpy(sz_size, "650");
    22132281                log_msg(1, "Setting to CD defaults");
    22142282            }
     
    22162284                if (!popup_and_get_string("Speed", comment, tmp1, 4)) {
    22172285                    log_to_screen("User has chosen not to backup the PC");
    2218                     mr_free(comment);
    22192286                    finish(1);
    22202287                }
    22212288            }
    2222             mr_free(comment);
    22232289            bkpinfo->cdrw_speed = atoi(tmp1);   // if DVD then this shouldn't ever be used anyway :)
    22242290
    2225             strcpy(tmp1, sz_size);
    2226             mr_asprintf(comment, "How much data (in Megabytes) will each %s store?", mds);
     2291            sprintf(comment,
     2292                    "How much data (in Megabytes) will each %s store?", mds);
    22272293            mr_free(mds);
    2228             if (!popup_and_get_string("Size", comment, tmp1, 5)) {
     2294            if (!popup_and_get_string("Size", comment, sz_size, 5)) {
    22292295                log_to_screen("User has chosen not to backup the PC");
    22302296                finish(1);
    22312297            }
    2232             mr_asprintf(sz_size, "%s", tmp1);
    22332298            bkpinfo->media_size = atoi(sz_size);
    2234 
    22352299            if (bkpinfo->media_size <= 0) {
    22362300                log_to_screen("User has chosen not to backup the PC");
     
    22442308        if ((bkpinfo->disaster_recovery) && (bkpinfo->backup_media_type != usb)) {
    22452309            strcpy(bkpinfo->media_device, "/dev/cdrom");
    2246             log_msg(2, "CD-ROM device assumed to be at %s", bkpinfo->media_device);
    2247         } else if ((bkpinfo->restore_data && (bkpinfo->backup_media_type != usb))  || bkpinfo->backup_media_type == dvd) {
     2310            log_msg(2, "CD-ROM device assumed to be at %s",
     2311                    bkpinfo->media_device);
     2312        } else if ((bkpinfo->restore_data && (bkpinfo->backup_media_type != usb))
     2313                   || bkpinfo->backup_media_type == dvd) {
    22482314            if (!bkpinfo->media_device[0]) {
    22492315                strcpy(bkpinfo->media_device, "/dev/cdrom");
    22502316            }                   // just for the heck of it :)
    2251             log_msg(1, "bkpinfo->media_device = %s", bkpinfo->media_device);
    2252             if (bkpinfo->backup_media_type == dvd || find_cdrom_device(bkpinfo->media_device, FALSE)) {
    2253                 log_msg(1, "bkpinfo->media_device = %s", bkpinfo->media_device);
    2254                 mr_asprintf(comment, "Please specify your %s drive's /dev entry", mds);
    2255                 if (!popup_and_get_string("Device?", comment, bkpinfo->media_device, MAX_STR_LEN / 4)) {
     2317            log_msg(1, "bkpinfo->media_device = %s",
     2318                    bkpinfo->media_device);
     2319            if (bkpinfo->backup_media_type == dvd
     2320                || find_cdrom_device(bkpinfo->media_device, FALSE)) {
     2321                log_msg(1, "bkpinfo->media_device = %s",
     2322                        bkpinfo->media_device);
     2323                sprintf(comment,
     2324                        "Please specify your %s drive's /dev entry", mds);
     2325                if (!popup_and_get_string
     2326                    ("Device?", comment, bkpinfo->media_device,
     2327                     MAX_STR_LEN / 4)) {
    22562328                    log_to_screen("User has chosen not to backup the PC");
    22572329                    finish(1);
     
    23272399            } else {
    23282400                if (does_file_exist("/tmp/mondo-restore.cfg")) {
    2329                     read_cfg_var("/tmp/mondo-restore.cfg", "media-dev", bkpinfo->media_device);
     2401                    read_cfg_var("/tmp/mondo-restore.cfg", "media-dev",
     2402                                 bkpinfo->media_device);
    23302403                }
    23312404            }
     
    23822455                finish(1);
    23832456            }
    2384             if ((bkpinfo->compression_level = which_compression_level()) == -1) {
     2457            if ((bkpinfo->compression_level =
     2458                 which_compression_level()) == -1) {
    23852459                log_to_screen("User has chosen not to backup the PC");
    23862460                finish(1);
     
    23942468        /* Never try to eject a NETFS device */
    23952469        bkpinfo->please_dont_eject = TRUE;
    2396         /*  Force NFS to be the protocol by default */
    2397         if (bkpinfo->netfs_proto == NULL) {
    2398             mr_asprintf(bkpinfo->netfs_proto, "nfs");
    2399         }
    24002470
    24012471        /* Initiate bkpinfo netfs_mount path from running environment if not already done */
    2402         if (!bkpinfo->netfs_mount == NULL) {
    2403             mr_asprintf(bkpinfo->netfs_mount, call_program_and_get_last_line_of_output("mount | grep \":\" | cut -d' ' -f1 | head -n1"));
     2472        if (!bkpinfo->netfs_mount[0]) {
     2473            strcpy(bkpinfo->netfs_mount,
     2474                   call_program_and_get_last_line_of_output
     2475                   ("mount | grep \":\" | cut -d' ' -f1 | head -n1"));
    24042476        }
    24052477#ifdef __FreeBSD__
     
    24122484                ("Network shared dir.",
    24132485                 "Please enter path and directory where archives are stored remotely. (Mondo has taken a guess at the correct value. If it is incorrect, delete it and type the correct one.)",
    2414                  p, MAX_STR_LEN / 4)) {
     2486                 bkpinfo->netfs_mount, MAX_STR_LEN / 4)) {
    24152487                log_to_screen("User has chosen not to backup the PC");
    24162488                finish(1);
    24172489            }
    2418             mr_free(bkpinfo->netfs_mount);
    2419             mr_asprintf(bkpinfo->netfs_mount, "%s", p;
    24202490            if (!bkpinfo->restore_data) {
    24212491                if ((compression_type = which_compression_type()) == NULL) {
     
    24232493                    finish(1);
    24242494                }
    2425 
    2426                 if ((bkpinfo->compression_level = which_compression_level()) == -1) {
     2495                if ((bkpinfo->compression_level =
     2496                    which_compression_level()) == -1) {
    24272497                    log_to_screen("User has chosen not to backup the PC");
    24282498                    finish(1);
     
    24312501            // check whether already mounted - we better remove
    24322502            // surrounding spaces and trailing '/' for this
    2433             mr_strip_spaces(bkpinfo->netfs_mount);
     2503            strip_spaces(bkpinfo->netfs_mount);
    24342504            if (bkpinfo->netfs_mount[strlen(bkpinfo->netfs_mount) - 1] == '/')
    24352505                bkpinfo->netfs_mount[strlen(bkpinfo->netfs_mount) - 1] = '\0';
     
    24432513                strcpy(tmp1,bkpinfo->netfs_mount);
    24442514            }
    2445             mr_asprintf(command, "mount | grep \"%s \" | cut -d' ' -f3", tmp1);
     2515            sprintf(command, "mount | grep \"%s \" | cut -d' ' -f3", tmp1);
    24462516            strcpy(bkpinfo->isodir, call_program_and_get_last_line_of_output(command));
    2447             mr_free(command);
    24482517
    24492518            if (!bkpinfo->restore_data) {
    2450                 mr_sprintf(sz_size, "%d", DEFAULT_DVD_DISK_SIZE);   // 4.7 salesman's GB = 4.482 real GB = 4482 MB
    2451                 mr_asprintf(comment, "How much data (in Megabytes) will each media store?");
    2452                 strcpy(tmp1, sz_size);
    2453                 mr_free(sz_size);
    2454                 if (!popup_and_get_string("Size", comment, tmp1, 5)) {
     2519                sprintf(sz_size, "%d", DEFAULT_DVD_DISK_SIZE);  // 4.7 salesman's GB = 4.482 real GB = 4482 MB
     2520                sprintf(comment,
     2521                    "How much data (in Megabytes) will each media store?");
     2522                if (!popup_and_get_string("Size", comment, sz_size, 5)) {
    24552523                    log_to_screen("User has chosen not to backup the PC");
    24562524                    finish(1);
    24572525                }
    2458                 mr_free(comment);
    2459                 mr_asprintf(sz_size, "%s", tmp1);
    24602526            } else {
    2461                 mr_asprintf(sz_size, "0");
     2527                strcpy(sz_size, "0");
    24622528            }
    24632529            bkpinfo->media_size = atoi(sz_size);
    2464             mr_free(sz_size);
    2465 
    24662530            if (bkpinfo->media_size < 0) {
    24672531                log_to_screen("User has chosen not to backup the PC");
     
    24692533            }
    24702534        }
     2535        /*  Force NFS to be the protocol by default */
     2536        if (bkpinfo->netfs_proto == NULL) {
     2537            mr_asprintf(bkpinfo->netfs_proto, "nfs");
     2538        }
    24712539        if (bkpinfo->disaster_recovery) {
    2472             mr_asprintf(command ,"umount %s/isodir 2> /dev/null", bkpinfo->tmpdir);
     2540            sprintf(command ,"umount %s/isodir 2> /dev/null", bkpinfo->tmpdir);
    24732541            paranoid_system(command);
    2474             mr_free(command);
    2475 
    24762542        }
    24772543        strcpy(tmp1, bkpinfo->netfs_proto);
    2478         if (!popup_and_get_string("Network protocol", "Which protocol should I use (nfs/sshfs/smbfs) ?",tmp1, MAX_STR_LEN)) {
     2544        if (!popup_and_get_string
     2545            ("Network protocol", "Which protocol should I use (nfs/sshfs/smbfs) ?",
     2546             tmp1, MAX_STR_LEN)) {
    24792547            log_to_screen("User has chosen not to backup the PC");
    24802548            finish(1);
     
    24822550        mr_free(bkpinfo->netfs_proto);
    24832551        mr_asprintf(bkpinfo->netfs_proto, "%s", tmp1);
    2484 
    2485         strcpy(tmp1, bkpinfo->netfs_mount);
    2486         if (!popup_and_get_string("Network share", "Which remote share should I mount?", tmp1, MAX_STR_LEN)) {
     2552        if (!popup_and_get_string
     2553            ("Network share", "Which remote share should I mount?",
     2554             bkpinfo->netfs_mount, MAX_STR_LEN)) {
    24872555            log_to_screen("User has chosen not to backup the PC");
    24882556            finish(1);
    24892557        }
    2490         mr_free(bkpinfo->netfs_mount);
    2491         mr_asprintf(bkpinfo->netfs_mount, "%s", tmp1);
    24922558
    24932559        if (bkpinfo->netfs_user) {
     
    24962562            strcpy(tmp1, "");
    24972563        }
    2498         if (!popup_and_get_string("Network user", "Which user should I use if any ?",tmp1)) {
     2564        if (!popup_and_get_string
     2565            ("Network user", "Which user should I use if any ?",
     2566             tmp1, MAX_STR_LEN)) {
    24992567            log_to_screen("User has chosen not to backup the PC");
    25002568            finish(1);
     
    25072575        /* Initiate bkpinfo isodir path from running environment if mount already done */
    25082576        if (is_this_device_mounted(bkpinfo->netfs_mount)) {
    2509             strcpy(bkpinfo->isodir, call_program_and_get_last_line_of_output("mount | grep \":\" | cut -d' ' -f3 | head -n1"));
     2577            strcpy(bkpinfo->isodir,
     2578                   call_program_and_get_last_line_of_output
     2579                   ("mount | grep \":\" | cut -d' ' -f3 | head -n1"));
    25102580        } else {
    25112581            sprintf(bkpinfo->isodir, "%s/netfsdir", bkpinfo->tmpdir);
    2512             mr_asprintf(command, "mkdir -p %s", bkpinfo->isodir);
     2582            sprintf(command, "mkdir -p %s", bkpinfo->isodir);
    25132583            run_program_and_log_output(command, 5);
    2514             mr_free(command);
    25152584
    25162585            if (bkpinfo->restore_data) {
     
    25462615        }
    25472616        if (!is_this_device_mounted(bkpinfo->netfs_mount)) {
    2548             popup_and_OK("Please mount that partition before you try to backup to or restore from it.");
     2617            popup_and_OK
     2618                ("Please mount that partition before you try to backup to or restore from it.");
    25492619            finish(1);
    25502620        }
     
    25702640        log_msg(3, "prefix set to %s", bkpinfo->prefix);
    25712641
    2572         log_msg(3, "Just set netfs_remote_dir to %s", bkpinfo->netfs_remote_dir);
     2642        log_msg(3, "Just set netfs_remote_dir to %s",
     2643                bkpinfo->netfs_remote_dir);
    25732644        log_msg(3, "isodir is still %s", bkpinfo->isodir);
    25742645        break;
     
    25882659                    finish(1);
    25892660                }
    2590                 if ((bkpinfo->compression_level = which_compression_level()) == -1) {
     2661                if ((bkpinfo->compression_level =
     2662                     which_compression_level()) == -1) {
    25912663                    log_to_screen("User has chosen not to backup the PC");
    25922664                    finish(1);
    25932665                }
    2594                 sprintf(tmp1, "%d", DEFAULT_DVD_DISK_SIZE); // 4.7 salesman's GB = 4.482 real GB = 4482 MB
     2666                sprintf(sz_size, "%d", DEFAULT_DVD_DISK_SIZE);  // 4.7 salesman's GB = 4.482 real GB = 4482 MB
    25952667                if (!popup_and_get_string
    25962668                    ("ISO size.",
    25972669                     "Please enter how big you want each ISO image to be (in megabytes). This should be less than or equal to the size of the CD-R[W]'s (700) or DVD's (4480) you plan to backup to.",
    2598                      tmp1, 16)) {
     2670                     sz_size, 16)) {
    25992671                    log_to_screen("User has chosen not to backup the PC");
    26002672                    finish(1);
    26012673                }
    2602                 bkpinfo->media_size = atoi(tmp1);
     2674                bkpinfo->media_size = atoi(sz_size);
    26032675            } else {
    26042676                bkpinfo->media_size = 650;
     
    26512723                finish(1);
    26522724            }
    2653             if (does_string_exist_in_boot_block(bkpinfo->boot_device, "LILO")) {
     2725            if (does_string_exist_in_boot_block
     2726                (bkpinfo->boot_device, "LILO")) {
    26542727                i = 'L';
    26552728            } else
    2656                 if (does_string_exist_in_boot_block(bkpinfo->boot_device, "ELILO")) {
     2729                if (does_string_exist_in_boot_block
     2730                    (bkpinfo->boot_device, "ELILO")) {
    26572731                i = 'E';
    26582732            } else
    2659                 if (does_string_exist_in_boot_block(bkpinfo->boot_device, "GRUB")) {
     2733                if (does_string_exist_in_boot_block
     2734                    (bkpinfo->boot_device, "GRUB")) {
    26602735                i = 'G';
    26612736            } else {
     
    26642739#endif
    26652740            if (i == 'U') {
    2666                 if (ask_me_yes_or_no("Unidentified boot loader. Shall I restore it byte-for-byte at restore time and hope for the best?")) {
     2741                if (ask_me_yes_or_no
     2742                    ("Unidentified boot loader. Shall I restore it byte-for-byte at restore time and hope for the best?"))
     2743                {
    26672744                    i = 'R';    // raw
    26682745                } else {
    2669                     log_to_screen("I cannot find your boot loader. Please run mondoarchive with parameters.");
     2746                    log_to_screen
     2747                        ("I cannot find your boot loader. Please run mondoarchive with parameters.");
    26702748                    finish(1);
    26712749                }
     
    26732751        }
    26742752        bkpinfo->boot_loader = i;
    2675 
    2676         mr_free(bkpinfo->include_paths);
    2677         strcpy(tmp1, "/");
     2753        strcpy(bkpinfo->include_paths, "/");
    26782754        if (!popup_and_get_string
    26792755            ("Backup paths",
    26802756             "Please enter paths (separated by '|') which you want me to backup. The default is '/' (i.e. everything).",
    2681              tmp1, MAX_STR_LEN)) {
     2757             bkpinfo->include_paths, MAX_STR_LEN)) {
    26822758            log_to_screen("User has chosen not to backup the PC");
    26832759            finish(1);
    26842760        }
    2685         mr_asprintf(bkpinfo->include_paths, "%s", tmp1);
    2686 
    26872761        tmp = list_of_NETFS_mounts_only();
    26882762        if (strlen(tmp) > 2) {
     
    27412815        if (ask_me_yes_or_no("Do you want to backup extended attributes?")) {
    27422816            if (find_home_of_exe("getfattr")) {
    2743                 mr_free(g_getfattr);
    27442817                mr_asprintf(g_getfattr,"getfattr");
    27452818            }
    27462819            if (find_home_of_exe("getfacl")) {
    2747                 mr_free(g_getfacl);
    27482820                mr_asprintf(g_getfacl,"getfacl");
    27492821            }
     
    27632835            strcpy(bkpinfo->zip_exe, "gzip");
    27642836            strcpy(bkpinfo->zip_suffix, "gz");
    2765         } else if (strcmp(compression_type,"lzma") == 0) {
     2837        //} else if (strcmp(compression_type,"lzma") == 0) {
    27662838            //strcpy(bkpinfo->zip_exe, "xy");
    27672839            //strcpy(bkpinfo->zip_suffix, "xy");
     
    27772849            ("Will you want to verify your backups after Mondo has created them?");
    27782850
     2851#ifndef __FreeBSD__
     2852        if (!ask_me_yes_or_no
     2853            ("Are you confident that your kernel is a sane, sensible, standard Linux kernel? Say 'no' if you are using a Gentoo <1.4 or Debian <3.0, please."))
     2854#endif
     2855        {
     2856            strcpy(bkpinfo->kernel_path, "FAILSAFE");
     2857        }
     2858
    27792859        if (!ask_me_yes_or_no
    27802860            ("Are you sure you want to proceed? Hit 'no' to abort.")) {
     
    27952875#else
    27962876    if (bkpinfo->backup_media_type == netfs) {
    2797         log_msg(3, "I think the Remote mount is mounted at %s", bkpinfo->isodir);
     2877        log_msg(3, "I think the Remote mount is mounted at %s",
     2878                bkpinfo->isodir);
    27982879    }
    27992880    log_it("isodir = %s", bkpinfo->isodir);
    2800     if (bkpinfo->netfs_mount) {
    2801         log_it("netfs_mount = '%s'", bkpinfo->netfs_mount);
     2881    log_it("netfs_mount = '%s'", bkpinfo->netfs_mount);
     2882    if (bkpinfo->netfs_proto) {
     2883        log_it("netfs_proto = '%s'", bkpinfo->netfs_proto);
    28022884    }
    28032885    if (bkpinfo->netfs_user) {
    28042886        log_it("netfs_user = '%s'", bkpinfo->netfs_user);
    2805     }
    2806     if (bkpinfo->netfs_proto) {
    2807         log_it("netfs_proto = '%s'", bkpinfo->netfs_proto);
    28082887    }
    28092888#endif
     
    28122891    log_it("media size = %ld", bkpinfo->media_size);
    28132892    log_it("media type = %s", bkptype_to_string(bkpinfo->backup_media_type));
    2814     if (bkpinfo->prefix) {
    2815         log_it("prefix = %s", bkpinfo->prefix);
    2816     }
     2893    log_it("prefix = %s", bkpinfo->prefix);
    28172894    log_it("compression = %ld", bkpinfo->compression_level);
    28182895    log_it("exclude_path = %s", bkpinfo->exclude_paths);
     
    28202897
    28212898    /* Handle devices passed in bkpinfo and print result */
    2822     /*  the mr_make_devlist_from_pathlist function appends
    2823     /*  to the *_paths variables so copy before */
     2899    /*  the mr_make_devlist_from_pathlist function appends 
     2900     *  to the *_paths variables so copy before */
    28242901    mr_make_devlist_from_pathlist(bkpinfo->exclude_paths, 'E');
    28252902    mr_make_devlist_from_pathlist(bkpinfo->include_paths, 'I');
     
    28272904    log_it("scratchdir = '%s'", bkpinfo->scratchdir);
    28282905    log_it("tmpdir = '%s'", bkpinfo->tmpdir);
    2829     if (bkpinfo->image_devs) {
    2830         log_it("image_devs = '%s'", bkpinfo->image_devs);
    2831     }
    2832     log_it("boot_device = '%s' (loader=%c)", bkpinfo->boot_device, bkpinfo->boot_loader);
     2906    log_it("image_devs = '%s'", bkpinfo->image_devs);
     2907    log_it("boot_device = '%s' (loader=%c)", bkpinfo->boot_device,
     2908           bkpinfo->boot_loader);
    28332909    if (bkpinfo->media_size < 0) {
    28342910        if (archiving_to_media) {
     
    28412917    paranoid_free(sz_size);
    28422918    paranoid_free(tmp1);
     2919    paranoid_free(command);
     2920    paranoid_free(comment);
     2921    paranoid_free(prompt);
    28432922    return (0);
    28442923}
     
    30913170
    30923171    malloc_string(current_drive);
    3093 
    3094     /* UEFI is not supported here - but should be managed as a BIOS/UEFI option not a Boot Loader one per se */
    30953172
    30963173#ifdef __IA64__
  • branches/3.0/mondo/src/common/libmondo-fifo.c

    r3188 r3192  
    8585    wise_upper_limit = (am_I_in_disaster_recovery_mode()? 8 : 32);
    8686    wise_lower_limit = 1;       // wise_upper_limit/2 + 1;
    87     sync();
     87    paranoid_system("sync");
    8888    for (bufsize = wise_upper_limit, res = -1;
    8989         res != 0 && bufsize >= wise_lower_limit; bufsize--) {
    90         mr_asprintf(tmp,"dd if=/dev/zero bs=1024 count=16k 2> /dev/null | buffer -o /dev/null -s %ld -m %d%c", internal_tape_block_size, bufsize, 'm');
     90        mr_asprintf(tmp,
     91                "dd if=/dev/zero bs=1024 count=16k 2> /dev/null | buffer -o /dev/null -s %ld -m %d%c",
     92                internal_tape_block_size, bufsize, 'm');
    9193        res = run_program_and_log_output(tmp, 2);
    9294        mr_free(tmp);
     
    9496    if (!res) {
    9597        bufsize++;
    96         log_to_screen(tmp, "Negotiated max buffer of %d MB ", bufsize);
     98        mr_asprintf(tmp, "Negotiated max buffer of %d MB ", bufsize);
     99        log_to_screen(tmp);
     100        mr_free(tmp);
    97101    } else {
    98102        bufsize = 0;
     
    162166        return;
    163167    }
    164     sync();
     168    paranoid_system("sync");
    165169    mr_asprintf(command, "ps %s | grep -F \"%s\" | grep -Fv grep | awk '{print $2;}' | grep -v PID | head -1", ps_options, g_sz_call_to_buffer);
    166170    log_msg(2, "kill_buffer() --- command = %s", command);
  • branches/3.0/mondo/src/common/libmondo-filelist.c

    r3188 r3192  
    8686
    8787    /*@ pointers ********************** */
    88     char *ptr = NULL;
     88    char *ptr;
    8989    FILE *fout;
    9090
     
    116116    mr_free(tempfile);
    117117
    118     if (bkpinfo->image_devs) {
    119         log_it("image_devs : %s", bkpinfo->image_devs);
    120 
    121         ptr = bkpinfo->image_devs;
    122 
    123         while (ptr && *ptr) {
    124             mr_asprintf(dev, "%s", ptr);
    125             log_it("Examining imagedev %s", dev);
    126             for (i = 0; i < (int) strlen(dev) && dev[i] != ' '; i++);
    127             dev[i] = '\0';
    128             if (!strlen(dev)) {
    129                 mr_free(dev);
    130                 continue;
    131             }
    132             fprintf(fout, "%s\n", dev);
    133             log_it("Adding '%s' to biggielist", dev);
    134             if ((ptr = strchr(ptr, ' '))) {
    135                 ptr++;
    136             }
    137             mr_free(dev);
     118    log_it(bkpinfo->image_devs);
     119
     120    ptr = bkpinfo->image_devs;
     121
     122    malloc_string(dev);
     123    while (ptr && *ptr) {
     124        strcpy(dev, ptr);
     125        log_it("Examining imagedev %s", dev);
     126        for (i = 0; i < (int) strlen(dev) && dev[i] != ' '; i++);
     127        dev[i] = '\0';
     128        if (!strlen(dev)) {
     129            continue;
     130        }
     131        fprintf(fout, "%s\n", dev);
     132        log_it("Adding '%s' to biggielist", dev);
     133        if ((ptr = strchr(ptr, ' '))) {
     134            ptr++;
    138135        }
    139136    }
     
    141138    mvaddstr_and_log_it(g_currentY++, 74, "Done.");
    142139
     140    paranoid_free(dev);
    143141    return (retval);
    144142}
     
    160158
    161159    mr_asprintf(tmp_fname, "%s/sortfile", bkpinfo->tmpdir);
     160
    162161    mr_asprintf(command, "sort %s > %s 2>> %s", orig_fname, tmp_fname, MONDO_LOGFILE);
    163162    retval = system(command);
     
    332331
    333332    if (curr_set_no == 0) {
    334         log_msg(1, "Only one fileset. Fine.");
     333        mr_asprintf(tmp, "Only one fileset. Fine.");
    335334    } else {
    336         log_msg(1, "Filelist divided into %ld sets", curr_set_no + 1);
    337     }
     335        mr_asprintf(tmp, "Filelist divided into %ld sets", curr_set_no + 1);
     336    }
     337    log_msg(1, tmp);
     338    mr_free(tmp);
    338339    close_evalcall_form();
    339340    /* This is to work around an obscure bug in Newt; open a form, close it,
     
    341342       then update_progress_form() won't show the "time taken / time remaining"
    342343       line. The bug only crops up AFTER the call to chop_filelist(). Weird. */
     344#ifndef _XWIN
    343345    if (!g_text_mode) {
    344346        open_progress_form("", "", "", "", 100);
     
    347349        newtPopWindow();
    348350    }
     351#endif
    349352    return (err ? 0 : curr_set_no + 1);
    350353}
     
    407410int call_exe_and_pipe_output_to_fd(char *syscall, FILE * pout)
    408411{
    409     FILE *pattr = NULL;
    410     char *tmp = NULL;
     412    FILE *pattr;
     413    char *tmp;
     414    char *p;
    411415
    412416    pattr = popen(syscall, "r");
     
    420424        return (2);
    421425    }
    422     for (mr_getline(tmp, pattr); !feof(pattr); mr_getline(tmp, pattr)) {
     426    malloc_string(tmp);
     427    for (p = fgets(tmp, MAX_STR_LEN, pattr); !feof(pattr) && (p != NULL);
     428         p = fgets(tmp, MAX_STR_LEN, pattr)) {
    423429        fputs(tmp, pout);
    424         mr_free(tmp);
    425     }
    426     mr_free(tmp);
     430    }
    427431    paranoid_pclose(pattr);
     432    paranoid_free(tmp);
    428433    return (0);
    429434}
     
    434439                 char *auxlist_fname)
    435440{
    436     FILE *fin = NULL;
    437     FILE *pout = NULL;
     441    FILE *fin;
     442    FILE *pout;
    438443    char *pout_command = NULL;
    439     char *syscall = NULL;
    440     char *file_to_analyze = NULL;
     444    char *syscall;
     445    char *file_to_analyze;
    441446    char *strtmp = NULL;
    442447    char *tmp = NULL;
     448    char *p = NULL;
    443449    int i;
    444450
     
    456462    mr_free(pout_command);
    457463
    458     for (mr_getline(file_to_analyze, fin); !feof(fin); mr_getline(file_to_analyze, fin)) {
     464    malloc_string(file_to_analyze);
     465    for (p = fgets(file_to_analyze, MAX_STR_LEN, fin); !feof(fin) && (p != NULL);
     466         p = fgets(file_to_analyze, MAX_STR_LEN, fin)) {
    459467        i = strlen(file_to_analyze);
    460468        if (i > 0 && file_to_analyze[i - 1] < 32) {
     
    464472        tmp = mr_stresc(file_to_analyze, "'", '\\', '\'');
    465473        mr_asprintf(syscall, "%s '%s' 2>> /dev/null", syscall_sprintf, tmp);    // " MONDO_LOGFILE);
    466         mr_free(tmp);
     474        paranoid_free(tmp);
    467475        log_msg(20,"calling %s\n",syscall);
    468476        call_exe_and_pipe_output_to_fd(syscall, pout);
    469         mr_free(syscall);
    470         mr_free(file_to_analyze);
    471     }
    472     mr_free(file_to_analyze);
     477        paranoid_free(syscall);
     478    }
    473479    paranoid_fclose(fin);
    474480    paranoid_pclose(pout);
     481    paranoid_free(file_to_analyze);
    475482    return (0);
    476483}
     
    515522    char *syscall_pin = NULL;
    516523    char *syscall_pout = NULL;
    517     char *incoming = NULL;
    518     char *current_subset_file = NULL;
    519     char *current_master_file = NULL;
     524    char *incoming;
     525    char *current_subset_file, *current_master_file;
    520526    char *masklist = NULL;
    521527    int retval = 0;
    522528    int i;
    523     char *p, *q;
     529    char *p, *q, *r;
    524530    char *tmp = NULL;
    525531    FILE *pin, *pout, *faclin;
    526532
    527     log_msg(1, "set_EXAT_list(%s, %s, %s)", orig_msklist, original_exat_fname, executable);
     533    log_msg(1, "set_EXAT_list(%s, %s, %s)", orig_msklist,
     534            original_exat_fname, executable);
    528535    if (!orig_msklist || !orig_msklist[0]
    529536        || !does_file_exist(orig_msklist)) {
     
    545552    }
    546553    if (length_of_file(original_exat_fname) <= 0) {
    547         log_msg(1, "original_exat_fname %s is empty or missing, so no need to set EXAT list", original_exat_fname);
     554        log_msg(1,
     555                "original_exat_fname %s is empty or missing, so no need to set EXAT list",
     556                original_exat_fname);
    548557        return (0);
    549558    }
     559    malloc_string(incoming);
     560    malloc_string(current_subset_file);
     561    malloc_string(current_master_file);
    550562    mr_asprintf(masklist, "%s/masklist", bkpinfo->tmpdir);
    551563    mr_asprintf(command, "cp -f %s %s", orig_msklist, masklist);
     
    554566
    555567    sort_file(masklist);
     568    current_subset_file[0] = current_master_file[0] = '\0';
    556569
    557570    mr_asprintf(syscall_pout, "%s --restore - 2>> %s", executable, MONDO_LOGFILE);
     
    586599//  printf("Hi there. Starting the loop\n");
    587600
    588     mr_getline(current_subset_file, faclin);
    589     mr_getline(incoming, pin);
    590     while (!feof(pin) && !feof(faclin)) {
    591         mr_asprintf(current_master_file, "%s", incoming + 8);
     601    r = fgets(current_subset_file, MAX_STR_LEN, faclin);
     602    r = fgets(incoming, MAX_STR_LEN, pin);
     603    while (!feof(pin) && !feof(faclin) && (r != NULL)) {
     604//      printf("incoming = %s", incoming);
     605
     606        strcpy(current_master_file, incoming + 8);
    592607
    593608        p = current_subset_file;
     
    617632        if (i < 0) {            // read another subset file in.
    618633            log_msg(my_depth, "Reading next subset line in\n\n");
    619             mr_free(current_subset_file);
    620             mr_getline(current_subset_file, faclin);
     634            r = fgets(current_subset_file, MAX_STR_LEN, faclin);
    621635            continue;
    622636        }
     
    625639            fputs(incoming, pout);
    626640        }
    627         mr_free(incoming);
    628         mr_getline(incoming, pin);
     641        r = fgets(incoming, MAX_STR_LEN, pin);
    629642        if (!i) {
    630643            log_msg(my_depth, "Copying master %s", q);
    631644        }
     645//      if (!i) { printf("Match --- %s\n", q); }
    632646
    633647        while (!feof(pin) && strncmp(incoming, "# file: ", 8)) {
    634648            if (!i) {
     649
     650//    printf("%s", incoming);
     651
    635652                fputs(incoming, pout);
    636653            }
    637             mr_free(incoming);
    638             mr_getline(incoming, pin);
     654            r = fgets(incoming, MAX_STR_LEN, pin);
    639655        }
    640656        if (!i) {
    641             mr_free(current_subset_file);
    642             mr_getline(current_subset_file, faclin);
    643         }
    644         mr_free(current_master_file);
    645     }
    646     mr_free(current_subset_file);
    647     mr_free(incoming);
     657            r = fgets(current_subset_file, MAX_STR_LEN, faclin);
     658        }
     659    }
     660    while (!feof(pin)) {
     661        r = fgets(incoming, MAX_STR_LEN, pin);
     662    }
    648663    fclose(faclin);
    649664    pclose(pin);
    650665    pclose(pout);
    651666
     667//  printf("OK, loop is done\n");
     668
    652669    unlink(masklist);
    653670    mr_free(masklist);
    654671
     672    paranoid_free(current_subset_file);
     673    paranoid_free(current_master_file);
     674    paranoid_free(incoming);
    655675    return (retval);
    656676}
     
    750770    noof_chars = strlen(string_to_add) + 1; /* we include the '\0' */
    751771
    752     /* walk across tree if necessary */
     772/* walk across tree if necessary */
    753773    node = startnode;
    754774    char_to_add = string_to_add[0];
     
    759779    }
    760780
    761     /* walk down tree if appropriate */
     781/* walk down tree if appropriate */
    762782    if (node->down != NULL && node->ch == char_to_add) {
    763783        log_msg(7, "depth=%d char=%c --- going DOWN", depth, char_to_add);
     
    773793    }
    774794
    775     /* add here */
     795/* add here */
    776796    if (!(newnode = (struct s_node *) malloc(sizeof(struct s_node)))) {
    777797        log_to_screen("failed to malloc");
     
    844864    /*@ buffers **************************************************** */
    845865    char *command_to_open_fname = NULL;
    846     char *fname = NULL;
    847     char *tmp = NULL;
     866    char fname[MAX_STR_LEN];
     867    char tmp[MAX_STR_LEN];
    848868    char *tmp1 = NULL;
    849869    int pos_in_fname;
     
    891911
    892912    open_evalcall_form("Loading filelist from disk");
    893     for (mr_getline(fname, pin); !feof(pin); mr_getline(fname, pin)) {
    894         if ((strlen(fname) > 0) && (fname[strlen(fname) - 1] == 13 || fname[strlen(fname) - 1] == 10)) {
     913    for (tmp1 = fgets(fname, MAX_STR_LEN, pin); !feof(pin);
     914         tmp1 = fgets(fname, MAX_STR_LEN, pin)) {
     915        if (((fname[strlen(fname) - 1] == 13) || (fname[strlen(fname) - 1] == 10)) && (strlen(fname) > 0)) {
    895916            fname[strlen(fname) - 1] = '\0';
    896917        }
     918//      strip_spaces (fname);
    897919        if (!strlen(fname)) {
    898             mr_free(fname);
    899920            continue;
    900921        }
     
    903924                continue;
    904925            }
    905             mr_asprintf(tmp, "%s", fname);
     926            strcpy(tmp, fname);
    906927            tmp[pos_in_fname] = '\0';
    907928            if (strlen(tmp)) {
    908929                add_string_at_node(filelist, tmp);
    909930            }
    910             mr_free(tmp);
    911931        }
    912932        add_string_at_node(filelist, fname);
    913 
    914933        if (!(++lino % 1111)) {
    915934            percentage = (int) (lino * 100 / lines_in_filelist);
    916935            update_evalcall_form(percentage);
    917936        }
    918         mr_free(fname);
    919     }
    920     mr_free(fname);
    921 
     937    }
    922938    paranoid_pclose(pin);
    923939    close_evalcall_form();
     
    12811297
    12821298
     1299
     1300
    12831301/**
    12841302 * Number of entries in the skeleton filelist.
     
    12961314 * @bug Return value should be @c void.
    12971315 */
    1298 int open_and_list_dir(char *dir1, char *sth, FILE * fout, time_t time_of_last_full_backup) {
    1299 
     1316int open_and_list_dir(char *dir1, char *sth, FILE * fout,
     1317                      time_t time_of_last_full_backup)
     1318{
    13001319    const char delims[] = "|";
    13011320
     
    13041323    struct stat statbuf;
    13051324    char *new;
    1306     char *tmp = NULL;
     1325    char *tmp;
    13071326    char *dir = NULL;
    13081327    static int percentage = 0;
    1309     char *skip_these = NULL;
     1328    char *skip_these;
    13101329    char *new_with_pipe;
    13111330    char *strtmp = NULL;
    13121331    char *token = NULL;
    13131332    char *find_excludes = NULL;
    1314     char *name_of_evalcall_form = NULL;
    1315     char *find_skeleton_marker = NULL;
     1333    static char *name_of_evalcall_form;
    13161334    int i;
    13171335    int lastpos = 0;
     
    13201338    static int counter = 0;
    13211339    static int uberctr = 0;
    1322     static long skeleton_lino = 0L;
    1323     static time_t last_time = (time_t)0;
     1340    static char *find_skeleton_marker;
     1341    static long skeleton_lino = 0;
     1342    static time_t last_time = 0;
    13241343    time_t this_time;
    13251344
     
    13361355
    13371356    if (!depth) {
     1357        malloc_string(name_of_evalcall_form);
     1358        malloc_string(find_skeleton_marker);
    13381359        while((token = mr_strtok(sth, delims, &lastpos)) != NULL) {
    13391360          mr_strcat(find_excludes," -path %s -prune -o", token);
     
    13541375        mr_asprintf(strtmp, "find '%s' -maxdepth %d -fstype mvfs -prune -o -path /proc -prune -o %s -type d -print > %s 2> /dev/null", dir, MAX_SKEL_DEPTH, find_excludes, g_skeleton_filelist);
    13551376#endif
    1356         mr_free(find_excludes);
    1357 
     1377        paranoid_free(find_excludes);
    13581378        log_msg(5, "find command = %s", strtmp);
    13591379        paranoid_system(strtmp);
    1360         mr_free(strtmp);
    1361 
     1380        paranoid_free(strtmp);
    13621381        mr_asprintf(tmp, "wc -l %s | awk '{print $1;}'", g_skeleton_filelist);
    1363         g_skeleton_entries = 1 + atol(call_program_and_get_last_line_of_output(tmp));
    1364         mr_free(tmp);
    1365 
    1366         mr_asprintf(name_of_evalcall_form, "Making catalog of %s", dir1);
     1382        g_skeleton_entries =
     1383            1 + atol(call_program_and_get_last_line_of_output(tmp));
     1384        paranoid_free(tmp);
     1385        sprintf(name_of_evalcall_form, "Making catalog of %s", dir1);
    13671386        open_evalcall_form(name_of_evalcall_form);
    1368         mr_free(name_of_evalcall_form);
    1369 
     1387        find_skeleton_marker[0] = '\0';
    13701388        skeleton_lino = 1;
    13711389        log_msg(5, "entries = %ld", g_skeleton_entries);
     
    13731391    } else if (depth <= MAX_SKEL_DEPTH) // update evalcall form if appropriate
    13741392    {
    1375         mr_asprintf(find_skeleton_marker, "grep -Fv '%s' %s > %s.new 2> /dev/null", dir, g_skeleton_filelist, g_skeleton_filelist);
     1393        sprintf(find_skeleton_marker,
     1394                "grep -Fv '%s' %s > %s.new 2> /dev/null", dir,
     1395                g_skeleton_filelist, g_skeleton_filelist);
     1396//    log_msg(0, "fsm = %s", find_skeleton_marker);
    13761397        if (!system(find_skeleton_marker)) {
    13771398            percentage = (int) (skeleton_lino * 100 / g_skeleton_entries);
    13781399            skeleton_lino++;
    1379             mr_free(find_skeleton_marker);
    1380 
    1381             mr_asprintf(find_skeleton_marker, "mv -f %s.new %s", g_skeleton_filelist, g_skeleton_filelist);
     1400//        log_msg(5, "Found %s", dir);
     1401//        log_msg(2, "Incrementing skeleton_lino; now %ld/%ld (%d%%)", skeleton_lino, g_skeleton_entries, percentage);
     1402            sprintf(find_skeleton_marker, "mv -f %s.new %s",
     1403                    g_skeleton_filelist, g_skeleton_filelist);
     1404//        log_msg(6, "fsm = %s", find_skeleton_marker);
    13821405            paranoid_system(find_skeleton_marker);
    13831406            time(&this_time);
    13841407            if (this_time != last_time) {
    13851408                last_time = this_time;
     1409#ifndef _XWIN
    13861410                if (!g_text_mode) {
    13871411                    int cols, rows;
     
    13911415                    mr_free(tmp);
    13921416                }
     1417#endif
    13931418                update_evalcall_form(percentage);
    13941419            }
    13951420        }
    1396         mr_free(find_skeleton_marker);
    13971421    }
    13981422
     
    14061430        mr_asprintf(tmp,"opendir %s", dir1);
    14071431        log_OS_error(tmp);
    1408         mr_free(tmp);
     1432        paranoid_free(tmp);
    14091433    } else if (strstr(skip_these, new_with_pipe)) {
    14101434        log_msg(10, "Found dir ***%s**** excluded", dir1);
     
    14201444                mr_asprintf(new,"%s%s",dir1,dit->d_name);
    14211445            }
    1422             mr_free(new_with_pipe);
     1446            paranoid_free(new_with_pipe);
    14231447            mr_asprintf(new_with_pipe, "|%s|", new);
    14241448            if (strstr(skip_these, new_with_pipe)) {
    14251449                fprintf(fout, "%s\n", new);
    14261450                log_msg(10, "Found child dir ***%s**** excluded", new);
    1427                 mr_free(new_with_pipe);
     1451                paranoid_free(new_with_pipe);
    14281452            } else {
    1429                 mr_free(new_with_pipe);
     1453                paranoid_free(new_with_pipe);
    14301454                if (!lstat(new, &statbuf)) {
    14311455                    if (!S_ISLNK(statbuf.st_mode)
    14321456                        && S_ISDIR(statbuf.st_mode)) {
    14331457                        log_msg(10, "Found child dir ***%s**** parsed", new);
    1434                         open_and_list_dir(new, skip_these, fout, time_of_last_full_backup);
     1458                        open_and_list_dir(new, skip_these, fout,
     1459                                          time_of_last_full_backup);
    14351460                    } else {
    1436                         if (time_of_last_full_backup == 0 || time_of_last_full_backup < statbuf.st_ctime) {
     1461                        if (time_of_last_full_backup == 0
     1462                            || time_of_last_full_backup <
     1463                            statbuf.st_ctime) {
    14371464                            log_msg(10, "Found child file ***%s**** parsed", new);
    14381465                            fprintf(fout, "%s\n", new);
     
    14411468                                uberctr++;
    14421469                                mr_asprintf(tmp, " %c ", special_dot_char(uberctr));
     1470#ifndef _XWIN
    14431471                                if (!g_text_mode) {
    1444                                     newtDrawRootText(77, g_noof_rows - 3, tmp);
     1472                                    newtDrawRootText(77, g_noof_rows - 3,
     1473                                                     tmp);
    14451474                                    newtRefresh();
    14461475                                }
    1447                                 mr_free(tmp);
     1476#endif
     1477                                paranoid_free(tmp);
    14481478                            }
    14491479                        }
     
    14511481                }
    14521482            }
    1453             mr_free(new);
    1454         }
    1455     }
    1456     mr_free(new_with_pipe);
    1457     mr_free(skip_these);
     1483            paranoid_free(new);
     1484        }
     1485    }
     1486    paranoid_free(new_with_pipe);
     1487    paranoid_free(skip_these);
    14581488    mr_free(dir);
    14591489
     
    14661496    if (!depth) {
    14671497        close_evalcall_form();
     1498        paranoid_free(name_of_evalcall_form);
     1499        paranoid_free(find_skeleton_marker);
    14681500        unlink(g_skeleton_filelist);
    14691501        log_msg(5, "g_skeleton_entries = %ld", g_skeleton_entries);
     
    14931525    char *p, *q;
    14941526    char *sz_datefile;
    1495     char *sz_filelist;
     1527    char *sz_filelist, *tmp;
    14961528    char *exclude_paths = NULL;
    14971529    FILE *fout;
     
    15021534    char *tmp2 = NULL;
    15031535
     1536    malloc_string(tmp);
     1537    malloc_string(g_skeleton_filelist);
    15041538    mr_asprintf(sz_datefile,MONDO_CACHE"/difflevel.%d" , 0);
    15051539    if (!include_paths && !userdef_filelist) {
    1506         fatal_error("Please supply either include_paths or userdef_filelist");
    1507     }
    1508     // make hole for filelist
     1540        fatal_error
     1541            ("Please supply either include_paths or userdef_filelist");
     1542    }
     1543// make hole for filelist
    15091544    mr_asprintf(command, "mkdir -p %s/archives", scratchdir);
    15101545    paranoid_system(command);
     
    15221557        // backup last known good datefile just in case :)
    15231558        if (does_file_exist(sz_datefile)) {
    1524             mr_asprintf(command, "mv -f %s %s.aborted", sz_datefile, sz_datefile);
     1559            mr_asprintf(command, "mv -f %s %s.aborted", sz_datefile,
     1560                    sz_datefile);
    15251561            paranoid_system(command);
    15261562            mr_free(command);
     
    15311567                                  ("date +%s"));
    15321568    } else if (lstat(sz_datefile, &statbuf)) {
    1533         log_msg(2, "Warning - unable to find date of previous backup. Full backup instead.");
     1569        log_msg(2,
     1570                "Warning - unable to find date of previous backup. Full backup instead.");
    15341571        differential = 0;
    15351572        time_of_last_full_backup = 0;
     
    15421579// use user-specified filelist (if specified)
    15431580    if (userdef_filelist) {
    1544         log_msg(1, "Using the user-specified filelist - %s - instead of calculating one", userdef_filelist);
     1581        log_msg(1,
     1582                "Using the user-specified filelist - %s - instead of calculating one",
     1583                userdef_filelist);
    15451584        mr_asprintf(command, "cp -f %s %s", userdef_filelist, sz_filelist);
    15461585        if (run_program_and_log_output(command, 3)) {
     
    15501589        mr_free(command);
    15511590    } else {
    1552         if (include_paths) {
    1553             log_msg(2, "include_paths = '%s'", include_paths);
    1554         }
     1591        log_msg(2, "include_paths = '%s'", include_paths);
    15551592        log_msg(1, "Calculating filelist");
    15561593        mr_asprintf(tmp2, "%s", call_program_and_get_last_line_of_output("mount | grep -Ew 'ntfs|ntfs-3g|fat|vfat|dos' | awk '{print $3}'"));
     
    15601597            log_msg(2, "Found windows FS: %s",tmp2);
    15611598            mr_asprintf(tmp1, "find %s -name '/win386.swp' -o -name '/hiberfil.sys' -o -name '/pagefile.sys' 2> /dev/null\n",tmp2);
    1562             mr_free(tmp2);
     1599            paranoid_free(tmp2);
    15631600            mr_asprintf(tmp2, "%s", call_program_and_get_last_line_of_output(tmp1));
    15641601            log_msg(2, "Found windows files: %s",tmp2);
    15651602        }
    1566         mr_free(tmp1);
     1603        paranoid_free(tmp1);
    15671604
    15681605        mr_asprintf(exclude_paths, MONDO_CACHE"|%s|%s|%s|.|..|"MNT_CDROM"|"MNT_FLOPPY"|/media|/tmp|/proc|/sys|/run|/dev/shm|"MINDI_CACHE, tmp2, (tmpdir[0] == '/' && tmpdir[1] == '/') ? (tmpdir + 1) : tmpdir, (scratchdir[0] == '/' && scratchdir[1] == '/') ? (scratchdir + 1) : scratchdir);
     
    15701607            mr_strcat(exclude_paths,"|%s",excp);
    15711608        }
    1572         mr_free(tmp2);
     1609        paranoid_free(tmp2);
    15731610
    15741611        log_msg(2, "Excluding paths = '%s'", exclude_paths);
    1575         log_msg(2, "Generating skeleton filelist so that we can track our progress");
    1576         mr_asprintf(g_skeleton_filelist, "%s/tmpfs/skeleton.txt", tmpdir);
     1612        log_msg(2,
     1613                "Generating skeleton filelist so that we can track our progress");
     1614        sprintf(g_skeleton_filelist, "%s/tmpfs/skeleton.txt", tmpdir);
    15771615        make_hole_for_file(g_skeleton_filelist);
    1578 
    15791616        log_msg(4, "g_skeleton_entries = %ld", g_skeleton_entries);
    15801617        log_msg(2, "Opening out filelist to %s", sz_filelist);
     
    15821619            fatal_error("Cannot openout to sz_filelist");
    15831620        }
    1584         if ((include_paths != NULL) && (strlen(include_paths) == 0)) {
     1621        if (strlen(include_paths) == 0) {
    15851622            log_msg(1, "Including only '/' in %s", sz_filelist);
    15861623            open_and_list_dir("/", exclude_paths, fout,
     
    16001637            }
    16011638        }
    1602         mr_free(exclude_paths);
    16031639        paranoid_fclose(fout);
    16041640    }
     
    16181654    paranoid_free(sz_filelist);
    16191655    log_msg(2, "Freeing variables");
    1620     mr_free(g_skeleton_filelist);
     1656    paranoid_free(exclude_paths);
     1657    paranoid_free(tmp);
     1658    paranoid_free(g_skeleton_filelist);
    16211659    log_msg(2, "Exiting");
    16221660    return (0);
    16231661}
    1624 
    16251662
    16261663/**
     
    16431680
    16441681    assert(bkpinfo != NULL);
    1645     log_it("tmpdir=%s; scratchdir=%s", bkpinfo->tmpdir, bkpinfo->scratchdir);
     1682    log_it("tmpdir=%s; scratchdir=%s", bkpinfo->tmpdir,
     1683           bkpinfo->scratchdir);
    16461684    if (bkpinfo->make_filelist) {
    16471685        mvaddstr_and_log_it(g_currentY, 0,
     
    17541792    FILE *fin;
    17551793    FILE *fout;
    1756     char *fname = NULL;
    1757     char *tmp = NULL;
    1758 
     1794    char *fname;
     1795    char *tmp;
     1796    size_t len = 0;             // Scrub's patch doesn't work without that
     1797
     1798//  log_msg(1, "use_star = %s", (use_star)?"TRUE":"FALSE");
     1799    malloc_string(fname);
     1800    malloc_string(tmp);
    17591801    log_msg(5, "starting");
    17601802    log_msg(5, "needles_list_fname = %s", needles_list_fname);
     
    17671809    }
    17681810    while (!feof(fin)) {
    1769         mr_getline(fname, fin);
     1811//      fscanf(fin, "%s\n", fname);
     1812        len = MAX_STR_LEN - 1;
     1813        if (getline(&fname, &len, fin)) {
     1814            // FIXME
     1815        }
    17701816        if (!use_star) {
    17711817            if (fname[0] == '/') {
    1772                 mr_asprintf(tmp, "%s", fname);
     1818                strcpy(tmp, fname);
    17731819            } else {
    1774                 mr_asprintf(tmp, "/%s", fname);
     1820                tmp[0] = '/';
     1821                strcpy(tmp + 1, fname);
    17751822            }
    1776             mr_free(fname);
    1777             fname = tmp;
     1823            strcpy(fname, tmp);
    17781824        }
    17791825        while (strlen(fname) > 0 && fname[strlen(fname) - 1] < 32) {
     
    17861832            if (found_node->selected) {
    17871833                if (fname[0] == '/') {
    1788                     mr_asprintf(tmp, "%s", fname + 1);
    1789                     mr_free(fname);
    1790                     fname = tmp;
     1834                    strcpy(tmp, fname + 1);
     1835                    strcpy(fname, tmp);
    17911836                }
    17921837                log_msg(5, "Found '%s'", fname);
    1793                 tmp = mr_stresc(fname, "[]*?", '\\', "'");
    1794                 mr_free(fname);
    1795                 fname = tmp;
    1796                 fprintf(fout, "%s\n", fname);
     1838                turn_wildcard_chars_into_literal_chars(tmp, fname);
     1839                fprintf(fout, "%s\n", tmp);
    17971840                retval++;
    17981841            }
    17991842        }
    1800         mr_free(fname);
    18011843    }
    18021844    paranoid_fclose(fout);
    18031845    paranoid_fclose(fin);
     1846    paranoid_free(fname);
     1847    paranoid_free(tmp);
    18041848    return (retval);
    18051849}
     1850
     1851
     1852
    18061853
    18071854
     
    18181865                                  char *list_of_files_fname, bool flag_em)
    18191866{
    1820     FILE *fin = NULL;
    1821     char *tmp = NULL;
    1822     struct s_node *nod = NULL;
    1823 
     1867    FILE *fin;
     1868    char *tmp;
     1869    char *p;
     1870    struct s_node *nod;
     1871
     1872    malloc_string(tmp);
    18241873    log_msg(3, "Adding %s to filelist", list_of_files_fname);
    18251874    if (!(fin = fopen(list_of_files_fname, "r"))) {
     
    18271876        return (1);
    18281877    }
    1829     for (mr_getline(tmp, fin); !feof(fin); mr_getline(tmp, fin)) {
     1878    for (p = fgets(tmp, MAX_STR_LEN, fin); !feof(fin) && (p != NULL);
     1879         p = fgets(tmp, MAX_STR_LEN, fin)) {
    18301880        if (!tmp[0]) {
    1831             mr_free(tmp);
    18321881            continue;
    18331882        }
    1834         if ((strlen(tmp) > 0) && (tmp[strlen(tmp) - 1] == 13 || tmp[strlen(tmp) - 1] == 10)) {
     1883        if ((tmp[strlen(tmp) - 1] == 13 || tmp[strlen(tmp) - 1] == 10)
     1884            && strlen(tmp) > 0) {
    18351885            tmp[strlen(tmp) - 1] = '\0';
    18361886        }
    18371887        log_msg(2, "tmp = '%s'", tmp);
    18381888        if (!tmp[0]) {
    1839             mr_free(tmp);
    18401889            continue;
    18411890        }
     
    18511900            log_msg(5, "Flagged '%s'", tmp);
    18521901        }
    1853         mr_free(tmp);
    1854     }
    1855     mr_free(tmp);
     1902    }
    18561903    paranoid_fclose(fin);
     1904    paranoid_free(tmp);
    18571905    return (0);
    18581906}
  • branches/3.0/mondo/src/common/libmondo-files-EXT.h

    r3188 r3192  
    4141
    4242
    43 extern int make_hole_for_dir(const char *outdir_fname);
     43extern int make_hole_for_dir(char *outdir_fname);
    4444
    4545extern long size_of_partition_in_mountlist_K(char *tmpdir, char *dev);
  • branches/3.0/mondo/src/common/libmondo-files.c

    r3188 r3192  
    4747    /*@ buffers ***************************************************** */
    4848    static char output[MAX_STR_LEN];
    49     char *command = NULL;
     49    char command[MAX_STR_LEN * 2];
     50    char tmp[MAX_STR_LEN];
    5051
    5152    /*@ pointers **************************************************** */
    52     char *p = NULL;
     53    char *p;
    5354    char *q;
    5455    FILE *fin;
     
    6263    assert_string_is_neither_NULL_nor_zerolength(filename);
    6364    if (does_file_exist(filename)) {
    64         mr_asprintf(command, "md5sum \"%s\"", filename);
     65        sprintf(command, "md5sum \"%s\"", filename);
    6566        fin = popen(command, "r");
    6667        if (fin) {
     
    7273            paranoid_pclose(fin);
    7374        }
    74         mr_free(command);
    7575    } else {
    76         log_it("File '%s' not found; cannot calc checksum", filename);
     76        sprintf(tmp, "File '%s' not found; cannot calc checksum",
     77                filename);
     78        log_it(tmp);
    7779    }
    7880    if (p) {
     
    128130
    129131    /*@ buffers ***************************************************** */
    130     char *command = NULL;
    131     char *incoming = NULL;
     132    char command[MAX_STR_LEN * 2];
     133    char incoming[MAX_STR_LEN];
     134    char tmp[MAX_STR_LEN];
     135    char *q;
    132136
    133137    /*@ long ******************************************************** */
     
    137141    FILE *fin;
    138142
     143    /*@ initialize [0] to null ******************************************** */
     144    incoming[0] = '\0';
     145
    139146    assert_string_is_neither_NULL_nor_zerolength(filename);
    140147    if (!does_file_exist(filename)) {
    141         log_it("%s does not exist, so I cannot found the number of lines in it", filename);
     148        sprintf(tmp,
     149                "%s does not exist, so I cannot found the number of lines in it",
     150                filename);
     151        log_it(tmp);
    142152        return (0);
    143153    }
    144     mr_asprintf(command, "cat %s | wc -l", filename);
     154    sprintf(command, "cat %s | wc -l", filename);
    145155    if (!does_file_exist(filename)) {
    146         mr_free(command);
    147156        return (-1);
    148157    }
    149158    fin = popen(command, "r");
    150     mr_free(command);
    151 
    152159    if (fin) {
    153160        if (feof(fin)) {
    154161            noof_lines = 0;
    155162        } else {
    156             mr_getline(incoming, fin);
    157             while (strlen(incoming) > 0 && incoming[strlen(incoming) - 1] < 32) {
     163            q = fgets(incoming, MAX_STR_LEN - 1, fin);
     164            if (!q) {
     165                // FIXME
     166            }
     167            while (strlen(incoming) > 0 && (q != NULL)
     168                   && incoming[strlen(incoming) - 1] < 32) {
    158169                incoming[strlen(incoming) - 1] = '\0';
    159170            }
    160171            noof_lines = atol(incoming);
    161             mr_free(incoming);
    162172        }
    163173        paranoid_pclose(fin);
     
    205215void exclude_nonexistent_files(char *inout)
    206216{
    207     char *infname = NULL;
    208     char *outfname = NULL;
    209     char *tmp = NULL;
    210     char *incoming = NULL;
     217    char infname[MAX_STR_LEN];
     218    char outfname[MAX_STR_LEN];
     219    char tmp[MAX_STR_LEN];
     220    char incoming[MAX_STR_LEN];
     221    char *q;
    211222
    212223    /*@ int ********************************************************* */
     
    220231
    221232    assert_string_is_neither_NULL_nor_zerolength(inout);
    222     mr_asprintf(infname, "%s.in", inout);
    223     mr_asprintf(tmp, "cp -f %s %s", inout, infname);
     233    sprintf(infname, "%s.in", inout);
     234    sprintf(outfname, "%s", inout);
     235    sprintf(tmp, "cp -f %s %s", inout, infname);
    224236    run_program_and_log_output(tmp, FALSE);
    225     mr_free(tmp);
    226 
    227237    if (!(fin = fopen(infname, "r"))) {
    228238        log_OS_error("Unable to openin infname");
    229         mr_free(infname);
    230239        return;
    231240    }
    232 
    233     mr_asprintf(outfname, "%s", inout);
    234241    if (!(fout = fopen(outfname, "w"))) {
    235242        log_OS_error("Unable to openout outfname");
    236         mr_free(infname);
    237         mr_free(outfname);
    238243        return;
    239244    }
    240     mr_free(outfname);
    241 
    242     for (mr_getline(incoming, fin); !feof(fin); mr_getline(incoming, fin)) {
     245    for (q = fgets(incoming, MAX_STR_LEN, fin); !feof(fin) && (q != NULL);
     246         q = fgets(incoming, MAX_STR_LEN, fin)) {
    243247        i = strlen(incoming) - 1;
    244248        if (i >= 0 && incoming[i] < 32) {
     
    248252            fprintf(fout, "%s\n", incoming);
    249253        } else {
    250             log_it("Excluding '%s'-nonexistent\n", incoming);
    251         }
    252         mr_free(incoming);
    253     }
    254     mr_free(incoming);
    255 
     254            sprintf(tmp, "Excluding '%s'-nonexistent\n", incoming);
     255            log_it(tmp);
     256        }
     257    }
    256258    paranoid_fclose(fout);
    257259    paranoid_fclose(fin);
    258260    unlink(infname);
    259     mr_free(infname);
    260 }
     261}
     262
     263
     264
     265
     266
     267
     268
    261269
    262270
     
    270278int figure_out_kernel_path_interactively_if_necessary(char *kernel)
    271279{
    272     char *tmp = NULL;
    273     char *command = NULL;
     280    char tmp[MAX_STR_LEN];
     281    char *command;
    274282
    275283    if (!kernel[0]) {
    276         strcpy(kernel, call_program_and_get_last_line_of_output("mindi --findkernel 2> /dev/null"));
     284        strcpy(kernel,
     285               call_program_and_get_last_line_of_output
     286               ("mindi --findkernel 2> /dev/null"));
    277287    }
    278288    // If we didn't get anything back, check whether mindi raised a fatal error
    279289    if (!kernel[0]) {
    280         mr_asprintf(command, "%s", "grep 'Fatal error' /var/log/mindi.log");
    281         mr_asprintf(tmp, "%s", call_program_and_get_last_line_of_output(command));
     290        malloc_string(command);
     291        strcpy(command, "grep 'Fatal error' /var/log/mindi.log");
     292        strcpy(tmp, call_program_and_get_last_line_of_output(command));
    282293        if (strlen(tmp) > 1) {
    283294            popup_and_OK(tmp);
    284             mr_free(tmp);
    285             mr_free(command);
    286295            fatal_error("Mindi gave a fatal error. Please check '/var/log/mindi.log'.");
    287296        }
    288         mr_free(tmp);
    289         mr_free(command);
     297        paranoid_free(command);
    290298    }
    291299    log_it("Calling Mindi with kernel path of '%s'", kernel);
     
    302310                ("Kernel not found. Please specify with the '-k' flag.");
    303311        }
    304         log_it("User says kernel is at %s", kernel);
     312        sprintf(tmp, "User says kernel is at %s", kernel);
     313        log_it(tmp);
    305314    }
    306315    return (0);
    307316}
     317
     318
     319
     320
    308321
    309322
     
    321334    /*@ buffers ********************* */
    322335    static char output[MAX_STR_LEN];
    323     char *incoming = NULL;
    324     char *command = NULL;
    325 
     336    char *incoming;
     337    char *command;
     338
     339    malloc_string(incoming);
     340    malloc_string(command);
     341    incoming[0] = '\0';
    326342    /*@******************************* */
    327343
    328344    assert_string_is_neither_NULL_nor_zerolength(fname);
    329     mr_asprintf(command, "which %s 2> /dev/null", fname);
    330     mr_asprintf(incoming, call_program_and_get_last_line_of_output(command));
    331     mr_free(command);
    332 
     345    sprintf(command, "which %s 2> /dev/null", fname);
     346    strcpy(incoming, call_program_and_get_last_line_of_output(command));
    333347    if (incoming[0] == '\0') {
    334348        if (system("which file > /dev/null 2> /dev/null")) {
    335             mr_free(incoming);
     349            paranoid_free(incoming);
     350            paranoid_free(command);
    336351            output[0] = '\0';
    337352            return (NULL);      // forget it :)
    338353        }
    339         mr_asprintf(command, "file %s 2> /dev/null | cut -d':' -f1 2> /dev/null", incoming);
    340         mr_free(incomig);
    341 
    342         mr_asprintf(incoming, "%s", call_program_and_get_last_line_of_output(command));
    343         mr_free(command);
    344     }
    345     if (incoming[0] == '\0') {
    346         mr_asprintf(command, "dirname %s 2> /dev/null", incoming);
    347         mr_free(incoming);
    348 
    349         mr_asprintf(incoming, "%s", call_program_and_get_last_line_of_output(command));
    350         mr_free(command);
     354        sprintf(command,
     355                "file %s 2> /dev/null | cut -d':' -f1 2> /dev/null",
     356                incoming);
     357        strcpy(incoming,
     358               call_program_and_get_last_line_of_output(command));
     359    }
     360    if (incoming[0] == '\0')    // yes, it is == '\0' twice, not once :)
     361    {
     362        sprintf(command, "dirname %s 2> /dev/null", incoming);
     363        strcpy(incoming,
     364               call_program_and_get_last_line_of_output(command));
    351365    }
    352366    strcpy(output, incoming);
    353367    if (output[0] != '\0' && does_file_exist(output)) {
    354         log_msg(4, "find_home_of_exe () --- Found %s at %s", fname, incoming);
     368        log_msg(4, "find_home_of_exe () --- Found %s at %s", fname,
     369                incoming);
    355370    } else {
    356371        output[0] = '\0';
    357372        log_msg(4, "find_home_of_exe() --- Could not find %s", fname);
    358373    }
    359     mr_free(incoming);
     374    paranoid_free(incoming);
     375    paranoid_free(command);
    360376    if (!output[0]) {
    361377        return (NULL);
     
    366382
    367383
     384
     385
     386
     387
     388
     389
    368390/**
    369391 * Get the last sequence of digits surrounded by non-digits in the first 32k of
     
    399421    for (; len > 0 && isdigit(datablock[len - 1]); len--);
    400422    trackno = atoi(datablock + len);
     423    /*
     424       sprintf(tmp,"datablock=%s; trackno=%d",datablock+len, trackno);
     425       log_it(tmp);
     426     */
    401427    return (trackno);
    402428}
     
    418444
    419445    /*@ buffers ***************************************************** */
    420     char *lastline = NULL;
    421     char *command = NULL;
     446    char tmp[MAX_STR_LEN];
     447    char lastline[MAX_STR_LEN];
     448    char command[MAX_STR_LEN];
    422449    /*@ pointers **************************************************** */
    423     char *p = NULL;
     450    char *p;
    424451
    425452    /*@ int's ******************************************************* */
    426     int i = 0;
    427 
    428     for (i = NOOF_ERR_LINES - 1; i >= 0 && !strstr(err_log_lines[i], "% Done") && !strstr(err_log_lines[i], "% done"); i--);
     453    int i;
     454
     455    for (i = NOOF_ERR_LINES - 1;
     456         i >= 0 && !strstr(err_log_lines[i], "% Done")
     457         && !strstr(err_log_lines[i], "% done"); i--);
    429458    if (i < 0) {
    430         mr_asprintf(command, "tail -n3 %s | grep -Fi \"%c\" | tail -n1 | awk '{print $0;}'", filename, '%');
    431         mr_asprintf(lastline, "%s", call_program_and_get_last_line_of_output(command));
    432         mr_free(command);
     459        sprintf(command,
     460                "tail -n3 %s | grep -Fi \"%c\" | tail -n1 | awk '{print $0;}'",
     461                filename, '%');
     462        strcpy(lastline,
     463               call_program_and_get_last_line_of_output(command));
    433464        if (!lastline[0]) {
    434             mr_free(lastline);
    435465            return (0);
    436466        }
    437467    } else {
    438         mr_asprintf(lastline, "%s", err_log_lines[i]);
     468        strcpy(lastline, err_log_lines[i]);
    439469    }
    440470
     
    442472    if (p) {
    443473        *p = '\0';
    444     } else {
    445         mr_free(lastline);
     474    }
     475//  log_msg(2, "lastline='%s', ", p, lastline);
     476    if (!p) {
    446477        return (0);
    447478    }
    448 
    449     for (p--; isdigit(*p) && p != lastline; p--);
     479    *p = '\0';
     480    for (p--; *p != ' ' && p != lastline; p--);
    450481    if (p != lastline) {
    451482        p++;
    452483    }
    453484    i = atoi(p);
    454     mr_free(lastline);
     485
     486    sprintf(tmp, "'%s' --> %d", p, i);
     487//     log_to_screen(tmp);
     488
    455489    return (i);
    456490}
     
    470504    /*@ buffers ***************************************************** */
    471505    static char output[MAX_STR_LEN];
    472     char *command = NULL;
     506    static char command[MAX_STR_LEN * 2];
     507    static char tmp[MAX_STR_LEN];
     508    char *p = NULL;
    473509
    474510    /*@ pointers **************************************************** */
     
    478514
    479515    if (!does_file_exist(filename)) {
    480         log_it("Tring to get last line of nonexistent file (%s)", filename);
     516        sprintf(tmp, "Tring to get last line of nonexistent file (%s)",
     517                filename);
     518        log_it(tmp);
    481519        output[0] = '\0';
    482520        return (output);
    483521    }
    484     mr_asprintf(command, "tail -n1 %s", filename);
     522    sprintf(command, "tail -n1 %s", filename);
    485523    fin = popen(command, "r");
    486     mr_free(command);
    487524    p = fgets(output, MAX_STR_LEN, fin);
    488525    if (p == NULL) {
     
    527564 * @bug I don't know what this function does. However, it seems orphaned, so it should probably be removed.
    528565 */
    529 int make_checksum_list_file(char *filelist, char *cksumlist, char *comppath) {
     566int
     567make_checksum_list_file(char *filelist, char *cksumlist, char *comppath)
     568{
    530569    /*@ pointers **************************************************** */
    531570    FILE *fin;
     
    538577
    539578    /*@ buffer ****************************************************** */
    540     char *stub_fname = NULL;
    541     char *curr_fname = NULL;
    542     char *curr_cksum = NULL;
    543     char *tmp = NULL;
     579    char stub_fname[1000];
     580    char curr_fname[1000];
     581    char curr_cksum[1000];
     582    char tmp[1000];
     583    char *q;
    544584
    545585    /*@ long [long] ************************************************* */
     
    555595    start_time = get_time();
    556596    filelist_length = length_of_file(filelist);
    557     log_it("filelist = %s; cksumlist = %s", filelist, cksumlist);
    558 
     597    sprintf(tmp, "filelist = %s; cksumlist = %s", filelist, cksumlist);
     598    log_it(tmp);
    559599    fin = fopen(filelist, "r");
    560600    if (fin == NULL) {
     
    570610        return (1);
    571611    }
    572     for (mr_getline(stub_fname, fin); !feof(fin); mr_getline(stub_fname, fin)) {
     612    for (q = fgets(stub_fname, 999, fin); !feof(fin) && (q != NULL);
     613         q = fgets(stub_fname, 999, fin)) {
    573614        if (stub_fname[(i = strlen(stub_fname) - 1)] < 32) {
    574615            stub_fname[i] = '\0';
    575616        }
    576         mr_asprintf(tmp, "%s%s", comppath, stub_fname);
    577         mr_free(stub_fname);
    578 
    579         mr_asprintf(curr_fname, "%s", tmp + 1);
    580         mr_free(tmp);
    581 
    582         mr_asprintf(curr_cksum, "%s", calc_file_ugly_minichecksum(curr_fname));
     617        sprintf(tmp, "%s%s", comppath, stub_fname);
     618        strcpy(curr_fname, tmp + 1);
     619        strcpy(curr_cksum, calc_file_ugly_minichecksum(curr_fname));
    583620        fprintf(fout, "%s\t%s\n", curr_fname, curr_cksum);
    584         mr_free(curr_cksum);
    585 
    586621        if (counter++ > 12) {
    587622            current_time = get_time();
    588623            counter = 0;
    589             /* BERLIOS: 37 really ? */
    590624            curr_fname[37] = '\0';
    591625            curr_pos = ftello(fin) / 1024;
    592626            percentage = (int) (curr_pos * 100 / filelist_length);
    593627            time_taken = current_time - start_time;
    594             if (percentage != 0) {
    595                 time_remaining = time_taken * 100 / (long) (percentage) - time_taken;
    596                 log_to_screen("%02d%% done   %02d:%02d taken   %02d:%02d remaining  %-37s\r", percentage, (int) (time_taken / 60), (int) (time_taken % 60), (int) (time_remaining / 60), (int) (time_remaining % 60), curr_fname);
     628            if (percentage == 0) {
     629                /*              printf("%0d%% done      \r",percentage); */
     630            } else {
     631                time_remaining =
     632                    time_taken * 100 / (long) (percentage) - time_taken;
     633                sprintf(tmp,
     634                        "%02d%% done   %02d:%02d taken   %02d:%02d remaining  %-37s\r",
     635                        percentage, (int) (time_taken / 60),
     636                        (int) (time_taken % 60),
     637                        (int) (time_remaining / 60),
     638                        (int) (time_remaining % 60), curr_fname);
     639                log_to_screen(tmp);
    597640            }
    598641            sync();
    599642        }
    600         mr_free(curr_fname);
    601     }
    602     mr_free(stub_fname);
    603 
     643    }
    604644    paranoid_fclose(fout);
    605645    paranoid_fclose(fin);
     
    614654 * @return The return value of @c mkdir.
    615655 */
    616 int make_hole_for_dir(const char *outdir_fname)
    617 {
    618     char *tmp = NULL;
     656int make_hole_for_dir(char *outdir_fname)
     657{
     658    char tmp[MAX_STR_LEN * 2];
    619659    int res = 0;
    620660
    621661    assert_string_is_neither_NULL_nor_zerolength(outdir_fname);
    622     mr_asprintf(tmp, "mkdir -p %s", outdir_fname);
     662    sprintf(tmp, "mkdir -p %s", outdir_fname);
    623663    res = system(tmp);
    624     mr_free(tmp);
    625664    return (res);
    626665}
     
    636675{
    637676    /*@ buffer ****************************************************** */
    638     char *command = NULL;
     677    char command[MAX_STR_LEN * 2];
    639678
    640679    /*@ int  ******************************************************** */
     
    646685    assert(!strstr(outfile_fname, MNT_CDROM));
    647686    assert(!strstr(outfile_fname, "/dev/cdrom"));
    648     mr_asprintf(command, "mkdir -p \"%s\" 2> /dev/null", outfile_fname);
     687    sprintf(command, "mkdir -p \"%s\" 2> /dev/null", outfile_fname);
    649688    res += system(command);
    650     mr_free(command);
    651 
    652     mr_asprintf(command, "rmdir \"%s\" 2> /dev/null", outfile_fname);
     689    sprintf(command, "rmdir \"%s\" 2> /dev/null", outfile_fname);
    653690    res += system(command);
    654     mr_free(command);
    655 
    656     mr_asprintf(command, "rm -f \"%s\" 2> /dev/null", outfile_fname);
     691    sprintf(command, "rm -f \"%s\" 2> /dev/null", outfile_fname);
    657692    res += system(command);
    658     mr_free(command);
    659 
    660693    unlink(outfile_fname);
    661694    return (0);
    662695}
     696
     697
    663698
    664699
     
    678713
    679714    /*@ buffers **************************************************** */
    680     char *incoming = NULL;
     715    char incoming[MAX_STR_LEN];
     716    char *p = NULL;
    681717
    682718    /*@ end vars *************************************************** */
     
    689725        return (0);
    690726    }
    691     mr_getline(incoming, fin);
    692     while (!feof(fin)) {
     727    p = fgets(incoming, MAX_STR_LEN - 1, fin);
     728    while (!feof(fin) && (p != NULL)) {
    693729        if (strstr(incoming, wildcard)) {
    694730            matches++;
    695731        }
    696         mr_free(incoming);
    697         mr_getline(incoming, fin);
    698     }
    699     mr_free(incoming);
     732        p = fgets(incoming, MAX_STR_LEN - 1, fin);
     733    }
    700734    paranoid_fclose(fin);
    701735    return (matches);
     
    712746long size_of_partition_in_mountlist_K(char *tmpdir, char *dev)
    713747{
    714     char *command = NULL;
    715     char *mountlist = NULL;
    716     char *sz_res = NULL;
     748    char command[MAX_STR_LEN];
     749    char mountlist[MAX_STR_LEN];
     750    char sz_res[MAX_STR_LEN];
    717751    long file_len_K;
    718752
    719     mr_asprintf(mountlist, "%s/mountlist.txt", tmpdir);
    720     mr_asprintf(command, "grep \"%s \" %s/mountlist.txt | head -n1 | awk '{print $4}'", dev, tmpdir);
    721     mr_free(mountlist);
    722 
     753    sprintf(mountlist, "%s/mountlist.txt", tmpdir);
     754    sprintf(command,
     755            "grep \"%s \" %s/mountlist.txt | head -n1 | awk '{print $4}'",
     756            dev, tmpdir);
    723757    log_it(command);
    724     mr_asprintf(sz_res, "%s", call_program_and_get_last_line_of_output(command));
     758    strcpy(sz_res, call_program_and_get_last_line_of_output(command));
    725759    file_len_K = atol(sz_res);
    726760    log_msg(4, "%s --> %s --> %ld", command, sz_res, file_len_K);
    727     mr_free(sz_res);
    728     mr_free(command);
    729 
    730761    return (file_len_K);
    731762}
     
    739770{
    740771    /*@ buffers ***************************************************** */
    741     char *fname = NULL;
    742     char *biggielist = NULL;
    743     char *tmp = NULL;
    744     char *command = NULL;
     772    char *fname;
     773    char *biggielist;
     774    char *comment;
     775    char *tmp;
     776    char *q;
     777    char *command;
    745778
    746779    /*@ long ******************************************************** */
     
    753786    /*@ end vars *************************************************** */
    754787
     788    malloc_string(fname);
     789    malloc_string(biggielist);
     790    malloc_string(comment);
     791    malloc_string(tmp);
     792    malloc_string(command);
    755793    log_it("Calculating size of all biggiefiles (in total)");
    756     mr_asprintf(biggielist, "%s/biggielist.txt", bkpinfo->tmpdir);
     794    sprintf(biggielist, "%s/biggielist.txt", bkpinfo->tmpdir);
    757795    log_it("biggielist = %s", biggielist);
    758     fin = fopen(biggielist, "r");
    759     mr_free(biggielist);
    760 
    761     if (!(fin)) {
    762         log_OS_error("Cannot open biggielist. OK, so estimate is based on filesets only.");
     796    if (!(fin = fopen(biggielist, "r"))) {
     797        log_OS_error
     798            ("Cannot open biggielist. OK, so estimate is based on filesets only.");
    763799    } else {
    764800        log_msg(4, "Reading it...");
    765         for (mr_getline(fname, fin); !feof(fin); mr_getline(fname, fin)) {
     801        for (q = fgets(fname, MAX_STR_LEN, fin); !feof(fin) && (q != NULL);
     802             q = fgets(fname, MAX_STR_LEN, fin)) {
    766803            if (fname[strlen(fname) - 1] <= 32) {
    767804                fname[strlen(fname) - 1] = '\0';
     
    770807                if (is_dev_an_NTFS_dev(fname)) {
    771808                    if ( !find_home_of_exe("ntfsresize")) {
    772                         mr_free(tmp);
    773                         mr_free(fname);
    774809                        fatal_error("ntfsresize not found");
    775810                    }
    776                     mr_free(tmp);
    777 
    778                     mr_asprintf(command, "ntfsresize --force --info %s|grep '^You might resize at '|cut -d' ' -f5", fname);
     811                    sprintf(command, "ntfsresize --force --info %s|grep '^You might resize at '|cut -d' ' -f5", fname);
    779812                    log_it("command = %s", command);
    780                     mr_asprintf(tmp, "%s", call_program_and_get_last_line_of_output(command));
    781                     mr_free(command);
    782 
     813                    strcpy (tmp, call_program_and_get_last_line_of_output(command));
    783814                    log_it("res of it = %s", tmp);
    784815                    file_len_K = atoll(tmp) / 1024L;
    785                     mr_free(tmp);
    786816                } else {
    787817                    file_len_K = get_phys_size_of_drive(fname) * 1024L;
     
    795825                log_msg(4, "%s --> %ld K", fname, file_len_K);
    796826            }
    797             log_msg(4, "After adding %s, scratchL+%ld now equals %ld", fname, file_len_K, scratchL);
     827            sprintf(comment,
     828                    "After adding %s, scratchL+%ld now equals %ld", fname,
     829                    file_len_K, scratchL);
     830            log_msg(4, comment);
    798831            if (feof(fin)) {
    799832                break;
    800833            }
    801             mr_free(fname);
    802         }
    803         mr_free(fname);
     834        }
    804835    }
    805836    log_it("Closing...");
    806837    paranoid_fclose(fin);
    807838    log_it("Finished calculating total size of all biggiefiles");
     839    paranoid_free(fname);
     840    paranoid_free(biggielist);
     841    paranoid_free(comment);
     842    paranoid_free(tmp);
     843    paranoid_free(command);
    808844    return (scratchL);
    809845}
     
    818854{
    819855    /*@ buffer ****************************************************** */
    820     char *tmp = NULL;
    821     char *command = NULL;
     856    char tmp[MAX_STR_LEN];
     857    char command[MAX_STR_LEN * 2];
    822858    long long llres;
    823859    /*@ pointers **************************************************** */
     
    827863    /*@ end vars *************************************************** */
    828864
    829     mr_asprintf(command, "du -sk %s", mountpt);
     865    sprintf(command, "du -sk %s", mountpt);
    830866    errno = 0;
    831867    fin = popen(command, "r");
     
    834870      llres = 0;
    835871    } else {
    836       mr_getline(tmp, fin);
     872      p = fgets(tmp, MAX_STR_LEN, fin);
    837873      paranoid_pclose(fin);
    838874      p = strchr(tmp, '\t');
     
    844880        llres += (int) (*p - '0');
    845881      }
    846       mr_free(tmp);
    847     }
    848     mr_free(command);
     882    }
    849883
    850884    return (llres);
     
    894928{
    895929    /*@ buffers *** */
    896     char *command = NULL;
    897     int res = 0;
    898 
    899     mr_asprintf(command, "which %s > /dev/null 2> /dev/null", fname);
    900     res = system(command);
    901     mr_free(command);
    902 
    903     if (res) {
    904         log_to_screen("Please install '%s'. I cannot find it on your system.", fname);
    905         log_to_screen("There may be hyperlink at http://www.mondorescue.org which");
     930    char command[MAX_STR_LEN * 2];
     931    char errorstr[MAX_STR_LEN];
     932
     933
     934    sprintf(command, "which %s > /dev/null 2> /dev/null", fname);
     935    sprintf(errorstr,
     936            "Please install '%s'. I cannot find it on your system.",
     937            fname);
     938    if (system(command)) {
     939        log_to_screen(errorstr);
     940        log_to_screen
     941            ("There may be hyperlink at http://www.mondorescue.org/downloads.shtml which");
    906942        log_to_screen("will take you to the relevant (missing) package.");
    907943        return (1);
     
    10021038{
    10031039    /*@ Char buffers ** */
    1004     char *command = NULL;
    1005     char *tmp = NULL;
     1040    char command[MAX_STR_LEN * 2];
     1041    char tmp[MAX_STR_LEN];
    10061042    char old_pwd[MAX_STR_LEN];
    1007     int res = 0;
    1008 
    1009     mvaddstr_and_log_it(g_currentY, 0, "Copying Mondo's core files to the scratch directory");
     1043
     1044    mvaddstr_and_log_it(g_currentY, 0,
     1045                        "Copying Mondo's core files to the scratch directory");
    10101046
    10111047    log_msg(4, "g_mondo_home='%s'", g_mondo_home);
     
    10131049        find_and_store_mondoarchives_home(g_mondo_home);
    10141050    }
    1015     mr_asprintf(command, CP_BIN " --parents -pRdf %s %s", g_mondo_home, bkpinfo->scratchdir);
     1051    sprintf(command, CP_BIN " --parents -pRdf %s %s", g_mondo_home,
     1052            bkpinfo->scratchdir);
    10161053
    10171054    log_msg(4, "command = %s", command);
    1018     res = run_program_and_log_output(command, 1);
    1019     mr_free(command);
    1020 
    1021     if (res) {
     1055    if (run_program_and_log_output(command, 1)) {
    10221056        fatal_error("Failed to copy Mondo's stuff to scratchdir");
    10231057    }
    10241058
    1025     mr_asprintf(tmp, "%s/payload.tgz", g_mondo_home);
     1059    sprintf(tmp, "%s/payload.tgz", g_mondo_home);
    10261060    if (does_file_exist(tmp)) {
    1027         log_it("Untarring payload %s to scratchdir %s", tmp, bkpinfo->scratchdir);
     1061        log_it("Untarring payload %s to scratchdir %s", tmp,
     1062               bkpinfo->scratchdir);
    10281063        if (getcwd(old_pwd, MAX_STR_LEN - 1)) {
    10291064            // FIXME
     
    10321067            // FIXME
    10331068        }
    1034         mr_asprintf(command, "tar -zxvf %s", tmp);
    1035         res = run_program_and_log_output(command, FALSE);
    1036         if (res) {
    1037             mr_free(command);
    1038             mr_free(tmp);
     1069        sprintf(command, "tar -zxvf %s", tmp);
     1070        if (run_program_and_log_output(command, FALSE)) {
    10391071            fatal_error("Failed to untar payload");
    10401072        }
    1041         mr_free(command);
    10421073        if (chdir(old_pwd)) {
    10431074            // FIXME
    10441075        }
    10451076    }
    1046     mr_free(tmp);
    1047 
    1048     mr_asprintf(command, "cp -f %s/LAST-FILELIST-NUMBER %s", bkpinfo->tmpdir, bkpinfo->scratchdir);
     1077
     1078    sprintf(command, "cp -f %s/LAST-FILELIST-NUMBER %s", bkpinfo->tmpdir,
     1079            bkpinfo->scratchdir);
    10491080
    10501081    if (run_program_and_log_output(command, FALSE)) {
    10511082        fatal_error("Failed to copy LAST-FILELIST-NUMBER to scratchdir");
    10521083    }
    1053     mr_free(command);
    1054 
    1055     mr_asprintf(tmp, "%s", call_program_and_get_last_line_of_output("which mondorestore"));
     1084
     1085    strcpy(tmp,
     1086          call_program_and_get_last_line_of_output("which mondorestore"));
    10561087    if (!tmp[0]) {
    1057         mr_free(tmp);
    1058         fatal_error("'which mondorestore' returned null. Where's your mondorestore? `which` can't find it. That's odd. Did you install mondorestore?");
    1059     }
    1060 
    1061     mr_asprintf(command, "cp -f %s %s", tmp, bkpinfo->tmpdir);
    1062     mr_free(tmp);
    1063     res = run_program_and_log_output(command, FALSE);
    1064     if (res) {
    1065         mr_free(command);
     1088        fatal_error
     1089            ("'which mondorestore' returned null. Where's your mondorestore? `which` can't find it. That's odd. Did you install mondorestore?");
     1090    }
     1091    sprintf(command, "cp -f %s %s", tmp, bkpinfo->tmpdir);
     1092    if (run_program_and_log_output(command, FALSE)) {
    10661093        fatal_error("Failed to copy mondorestore to tmpdir");
    10671094    }
    1068     mr_free(command);
    1069 
    1070     mr_asprintf(command, "hostname > %s/HOSTNAME", bkpinfo->scratchdir);
     1095
     1096    sprintf(command, "hostname > %s/HOSTNAME", bkpinfo->scratchdir);
    10711097    paranoid_system(command);
    1072     mr_free(command);
    10731098
    10741099    if (bkpinfo->postnuke_tarball[0]) {
    1075         mr_asprintf(command, "cp -f %s %s/post-nuke.tgz", bkpinfo->postnuke_tarball, bkpinfo->tmpdir);
    1076         res = run_program_and_log_output(command, FALSE);
    1077         mr_free(command);
    1078 
    1079         if (res) {
     1100        sprintf(command, "cp -f %s %s/post-nuke.tgz",
     1101                bkpinfo->postnuke_tarball, bkpinfo->tmpdir);
     1102        if (run_program_and_log_output(command, FALSE)) {
    10801103            fatal_error("Unable to copy post-nuke tarball to tmpdir");
    10811104        }
    10821105    }
     1106
    10831107
    10841108    mvaddstr_and_log_it(g_currentY++, 74, "Done.");
     
    11011125
    11021126    /*@ buffers ******** */
    1103     char *netfs_dev = NULL;
    1104     char *netfs_client_hwaddr = NULL;
    1105     char *netfs_mount = NULL;
    1106     char *netfs_client_ipaddr = NULL;
    1107     char *netfs_client_netmask = NULL;
    1108     char *netfs_client_broadcast = NULL;
    1109     char *netfs_client_defgw = NULL;
    1110     char *netfs_server_ipaddr = NULL;
    1111     char *tmp = NULL;
    1112     char *command = NULL;
     1127    char netfs_dev[MAX_STR_LEN];
     1128    char netfs_mount[MAX_STR_LEN];
     1129    char netfs_client_hwaddr[MAX_STR_LEN];
     1130    char netfs_client_ipaddr[MAX_STR_LEN];
     1131    char netfs_client_netmask[MAX_STR_LEN];
     1132    char netfs_client_broadcast[MAX_STR_LEN];
     1133    char netfs_client_defgw[MAX_STR_LEN];
     1134    char netfs_server_ipaddr[MAX_STR_LEN];
     1135    char tmp[MAX_STR_LEN];
     1136    char command[MAX_STR_LEN * 2];
    11131137
    11141138    /*@ pointers ***** */
    11151139    char *p;
    11161140
    1117     if (! bkpinfo->netfs_mount) {
    1118         fatal_error("No netfs_mount found !");
    1119     }
    1120 
    11211141    log_it("Storing Network configuration");
    1122     mr_asprintf(tmp, "%s", bkpinfo->netfs_mount);
     1142    strcpy(tmp, bkpinfo->netfs_mount);
    11231143    p = strchr(tmp, ':');
    11241144    if (!p) {
    1125         fatal_error("Network mount doesn't have a colon in it, e.g. 192.168.1.4:/home/nfs");
     1145        fatal_error
     1146            ("Network mount doesn't have a colon in it, e.g. 192.168.1.4:/home/nfs");
    11261147    }
    11271148    *(p++) = '\0';
    1128     mr_asprintf(netfs_server_ipaddr, "%s", tmp);
    1129     mr_asprintf(netfs_mount, "%s", p);
    1130     mr_free(tmp);
     1149    strcpy(netfs_server_ipaddr, tmp);
     1150    strcpy(netfs_mount, p);
    11311151
    11321152    /* BERLIOS : there is a bug #67 here as it only considers the first NIC */
    1133     mr_asprintf(command, "%s", "ifconfig | tr '\n' '#' | sed s/##// | tr '#' ' ' | tr '' '\n' | head -n1 | cut -d' ' -f1");
    1134     mr_asprintf(netfs_dev, "%s", call_program_and_get_last_line_of_output(command));
    1135     mr_free(command);
    1136 
    1137     mr_asprintf(command, "%s", "ifconfig | tr '\n' '#' | sed s/##// | tr '#' ' ' | tr '' '\\n' | head -n1 | tr -s '\t' ' ' | cut -d' ' -f7 | cut -d':' -f2");
    1138     mr_asprintf(netfs_client_ipaddr, "%s", call_program_and_get_last_line_of_output(command));
    1139     mr_free(command);
    1140 
    1141     mr_asprintf(command, "%s", "ifconfig | tr '\n' '#' | sed s/##// | tr '#' ' ' | tr '' '\\n' | head -n1 | tr -s '\t' ' ' | cut -d' ' -f9 | cut -d':' -f2");
    1142     mr_asprintf(netfs_client_netmask, "%s", call_program_and_get_last_line_of_output(command));
    1143     mr_free(command);
    1144 
    1145     mr_asprintf(command, "%s", "ifconfig | tr '\n' '#' | sed s/##// | tr '#' ' ' | tr '' '\\n' | head -n1 | tr -s '\t' ' ' | cut -d' ' -f8 | cut -d':' -f2");
    1146     mr_asprintf(netfs_client_broadcast, "%s", call_program_and_get_last_line_of_output(command));
    1147     mr_free(command);
    1148 
    1149     mr_asprintf(command, "%s", "route -n | grep '^0.0.0.0' | awk '{print $2}'");
    1150     mr_asprintf(netfs_client_defgw, "%s", call_program_and_get_last_line_of_output(command));
    1151     mr_free(command);
    1152 
    1153     mr_asprintf(command, "ifconfig %s | head -1 | awk '{print $5}'", netfs_dev);
    1154     mr_asprintf(netfs_client_hwaddr, "%s" call_program_and_get_last_line_of_output(command));
    1155     mr_free(command);
    1156 
    1157     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);
     1153    sprintf(command,
     1154            "ifconfig | tr '\n' '#' | sed s/##// | tr '#' ' ' | tr '' '\n' | head -n1 | cut -d' ' -f1");
     1155    strcpy(netfs_dev, call_program_and_get_last_line_of_output(command));
     1156    sprintf(command,
     1157            "ifconfig %s | head -1 | awk '{print $5}'", netfs_dev);
     1158    strcpy(netfs_client_hwaddr, call_program_and_get_last_line_of_output(command));
     1159    sprintf(command,
     1160            "ifconfig | tr '\n' '#' | sed s/##// | tr '#' ' ' | tr '' '\\n' | head -n1 | tr -s '\t' ' ' | cut -d' ' -f7 | cut -d':' -f2");
     1161    strcpy(netfs_client_ipaddr,
     1162          call_program_and_get_last_line_of_output(command));
     1163    sprintf(command,
     1164            "ifconfig | tr '\n' '#' | sed s/##// | tr '#' ' ' | tr '' '\\n' | head -n1 | tr -s '\t' ' ' | cut -d' ' -f9 | cut -d':' -f2");
     1165    strcpy(netfs_client_netmask,
     1166          call_program_and_get_last_line_of_output(command));
     1167    sprintf(command,
     1168            "ifconfig | tr '\n' '#' | sed s/##// | tr '#' ' ' | tr '' '\\n' | head -n1 | tr -s '\t' ' ' | cut -d' ' -f8 | cut -d':' -f2");
     1169    strcpy(netfs_client_broadcast,
     1170          call_program_and_get_last_line_of_output(command));
     1171    sprintf(command,
     1172            "route -n | grep '^0.0.0.0' | awk '{print $2}'");
     1173    strcpy(netfs_client_defgw,
     1174          call_program_and_get_last_line_of_output(command));
     1175    sprintf(tmp,
     1176            "netfs_client_hwaddr=%s; netfs_client_ipaddr=%s; netfs_server_ipaddr=%s; netfs_mount=%s",
     1177            netfs_client_hwaddr, netfs_client_ipaddr, netfs_server_ipaddr, netfs_mount);
    11581178    if (strlen(netfs_dev) < 2) {
    1159         fatal_error("Unable to find ethN (eth0, eth1, ...) adapter via Network mount you specified.");
    1160     }
    1161 
     1179        fatal_error
     1180            ("Unable to find ethN (eth0, eth1, ...) adapter via Network mount you specified.");
     1181    }
    11621182    /********
    1163     * If the Network device found above is a bonded device,
     1183    * If the Network device that found above is a bonded device,
    11641184    * we need to replace it with an ethN device or the
    11651185    * networking will not start during an Network restore.
     
    11711191    if (!strncmp(netfs_dev, "bond", 4) || !strncmp(netfs_dev, "alb", 3) || !strncmp(netfs_dev, "aft", 3)) {
    11721192        log_to_screen("Found bonding device %s; looking for corresponding ethN slave device\n", netfs_dev);
    1173         mr_asprintf(command, "ifconfig | grep -E '%s' | grep -v '%s' | head -n1 | cut -d' ' -f1",netfs_client_hwaddr,netfs_dev);
    1174         mr_asprintf(netfs_dev, "%s", call_program_and_get_last_line_of_output(command));
    1175         mr_free(command);
     1193        sprintf(command,
     1194                "ifconfig | grep -E '%s' | grep -v '%s' | head -n1 | cut -d' ' -f1",netfs_client_hwaddr,netfs_dev);
     1195        strcpy(netfs_dev, call_program_and_get_last_line_of_output(command));
    11761196        log_to_screen("Replacing it with %s\n", netfs_dev);
    11771197    }
    11781198
    1179     mr_asprintf(tmp, "%s/NETFS-DEV", bkpinfo->tmpdir);
     1199    sprintf(tmp, "%s/NETFS-DEV", bkpinfo->tmpdir);
    11801200    write_one_liner_data_file(tmp, netfs_dev);
    1181     mr_free(netfs_dev);
    1182     mr_free(tmp);
    1183 
    1184     mr_asprintf(tmp, "%s/NETFS-CLIENT-HWADDR", bkpinfo->tmpdir);
    1185     write_one_liner_data_file(tmp, netfs_client_hwaddr);
    1186     mr_free(netfs_client_hwaddr);
    1187     mr_free(tmp);
    1188 
    1189     mr_asprintf(tmp, "%s/NETFS-CLIENT-IPADDR", bkpinfo->tmpdir);
    1190     write_one_liner_data_file(tmp, netfs_client_ipaddr);
    1191     mr_free(netfs_client_ipaddr);
    1192     mr_free(tmp);
    1193 
    1194     mr_asprintf(tmp, "%s/NETFS-CLIENT-NETMASK", bkpinfo->tmpdir);
    1195     write_one_liner_data_file(tmp, netfs_client_netmask);
    1196     mr_free(netfs_client_netmask);
    1197     mr_free(tmp);
    1198 
    1199     mr_asprintf(tmp, "%s/NETFS-CLIENT-BROADCAST", bkpinfo->tmpdir);
    1200     write_one_liner_data_file(tmp, netfs_client_broadcast);
    1201     mr_free(netfs_client_broadcast);
    1202     mr_free(tmp);
    1203 
    1204     mr_asprintf(tmp, "%s/NETFS-CLIENT-DEFGW", bkpinfo->tmpdir);
    1205     write_one_liner_data_file(tmp, netfs_client_defgw);
    1206     mr_free(netfs_client_defgw);
    1207     mr_free(tmp);
    1208 
    1209     mr_asprintf(tmp, "%s/NETFS-SERVER-IPADDR", bkpinfo->tmpdir);
    1210     write_one_liner_data_file(tmp, netfs_server_ipaddr);
    1211     mr_free(netfs_server_ipaddr);
    1212     mr_free(tmp);
    1213 
    1214     mr_asprintf(tmp, "%s/NETFS-SERVER-MOUNT", bkpinfo->tmpdir);
    1215     write_one_liner_data_file(tmp, bkpinfo->netfs_mount);
    1216     mr_free(tmp);
    1217 
    1218     if (bkpinfo->netfs_user) {
    1219         mr_asprintf(tmp, "%s/NETFS-SERVER-USER", bkpinfo->tmpdir);
    1220         write_one_liner_data_file(tmp, bkpinfo->netfs_user);
    1221         mr_free(tmp);
    1222     }
    1223     mr_asprintf(tmp, "%s/NETFS-SERVER-PATH", bkpinfo->tmpdir);
    1224     write_one_liner_data_file(tmp, bkpinfo->netfs_remote_dir);
    1225     mr_free(tmp);
    1226 
    1227     mr_asprintf(tmp, "%s/ISO-PREFIX", bkpinfo->tmpdir);
    1228     write_one_liner_data_file(tmp, bkpinfo->prefix);
    1229     mr_free(tmp);
    12301201
    12311202    sprintf(tmp, "%s/NETFS-PROTO", bkpinfo->tmpdir);
    12321203    write_one_liner_data_file(tmp, bkpinfo->netfs_proto);
    1233     mr_free(tmp);
    1234 
    1235 
     1204
     1205    sprintf(tmp, "%s/NETFS-CLIENT-HWADDR", bkpinfo->tmpdir);
     1206    write_one_liner_data_file(tmp, netfs_client_hwaddr);
     1207    sprintf(tmp, "%s/NETFS-CLIENT-IPADDR", bkpinfo->tmpdir);
     1208    write_one_liner_data_file(tmp, netfs_client_ipaddr);
     1209    sprintf(tmp, "%s/NETFS-CLIENT-NETMASK", bkpinfo->tmpdir);
     1210    write_one_liner_data_file(tmp, netfs_client_netmask);
     1211    sprintf(tmp, "%s/NETFS-CLIENT-BROADCAST", bkpinfo->tmpdir);
     1212    write_one_liner_data_file(tmp, netfs_client_broadcast);
     1213    sprintf(tmp, "%s/NETFS-CLIENT-DEFGW", bkpinfo->tmpdir);
     1214    write_one_liner_data_file(tmp, netfs_client_defgw);
     1215    sprintf(tmp, "%s/NETFS-SERVER-IPADDR", bkpinfo->tmpdir);
     1216    write_one_liner_data_file(tmp, netfs_server_ipaddr);
     1217    sprintf(tmp, "%s/NETFS-SERVER-MOUNT", bkpinfo->tmpdir);
     1218    write_one_liner_data_file(tmp, bkpinfo->netfs_mount);
     1219    if (bkpinfo->netfs_user) {
     1220        sprintf(tmp, "%s/NETFS-SERVER-USER", bkpinfo->tmpdir);
     1221        write_one_liner_data_file(tmp, bkpinfo->netfs_user);
     1222    }
     1223    sprintf(tmp, "%s/NETFS-SERVER-PATH", bkpinfo->tmpdir);
     1224    write_one_liner_data_file(tmp, bkpinfo->netfs_remote_dir);
     1225    sprintf(tmp, "%s/ISO-PREFIX", bkpinfo->tmpdir);
     1226    write_one_liner_data_file(tmp, bkpinfo->prefix);
    12361227    log_it("Finished storing Network configuration");
    12371228}
     1229
     1230
     1231
     1232
    12381233
    12391234
     
    12581253{
    12591254    /*@ buffers *************** */
    1260     char *tmp = NULL;
     1255    char tmp[MAX_STR_LEN];
    12611256    char *mds = NULL;
    12621257
     
    12701265
    12711266    log_it("Estimating number of media required...");
    1272     scratchLL = (long long) (noof_sets) * (long long) (bkpinfo->optimal_set_size) + (long long) (size_of_all_biggiefiles_K());
     1267    scratchLL =
     1268        (long long) (noof_sets) * (long long) (bkpinfo->optimal_set_size)
     1269        + (long long) (size_of_all_biggiefiles_K());
    12731270    scratchLL = (scratchLL / 1024) / bkpinfo->media_size;
    12741271    scratchLL++;
     
    12771274    } else if (bkpinfo->use_gzip) {
    12781275        scratchLL = (scratchLL * 2) / 3;
    1279     } else if (bkpinfo->use_lzma) {
    1280         scratchLL = (scratchLL * 2) / 3;
    12811276    } else {
    12821277        scratchLL = scratchLL / 2;
     
    12871282    if (scratchLL <= 1) {
    12881283        mds = media_descriptor_string(bkpinfo->backup_media_type);
    1289         mr_asprintf(tmp, "Your backup will probably occupy a single %s. Maybe two.", mds);
     1284        sprintf(tmp,
     1285                "Your backup will probably occupy a single %s. Maybe two.", mds);
    12901286        mr_free(mds);
    12911287    } else if (scratchLL > 4) {
    1292         mr_asprintf(tmp, "Your backup will occupy one meeeeellion media! (maybe %s)", number_to_text((int) (scratchLL + 1)));
     1288        sprintf(tmp,
     1289                "Your backup will occupy one meeeeellion media! (maybe %s)",
     1290                number_to_text((int) (scratchLL + 1)));
    12931291    } else {
    1294         mr_asprintf(tmp, "Your backup will occupy approximately %s media.", number_to_text((int) (scratchLL + 1)));
    1295     }
    1296     if (scratchLL < 50) {
     1292        sprintf(tmp, "Your backup will occupy approximately %s media.",
     1293                number_to_text((int) (scratchLL + 1)));
     1294    }
     1295    if (!bkpinfo->image_devs[0] && (scratchLL < 50)) {
    12971296        log_to_screen(tmp);
    12981297    }
    1299     mr_free(tmp);
     1298}
     1299
     1300
     1301/**
     1302 * Get the last suffix of @p instr.
     1303 * If @p instr was "httpd.log.gz", we would return "gz".
     1304 * @param instr The filename to get the suffix of.
     1305 * @return The suffix (without a dot), or "" if none.
     1306 * @note The returned string points to static storage that will be overwritten with each call.
     1307 */
     1308char *sz_last_suffix(char *instr)
     1309{
     1310    static char outstr[MAX_STR_LEN];
     1311    char *p;
     1312
     1313    p = strrchr(instr, '.');
     1314    if (!p) {
     1315        outstr[0] = '\0';
     1316    } else {
     1317        strcpy(outstr, p);
     1318    }
     1319    return (outstr);
    13001320}
    13011321
     
    13091329bool is_this_file_compressed(char *filename)
    13101330{
    1311     char *do_not_compress_these = NULL;
    1312     char *tmp = NULL;
     1331    char do_not_compress_these[MAX_STR_LEN];
     1332    char tmp[MAX_STR_LEN];
    13131333    char *p;
    13141334    char *q = NULL;
     
    13191339    }
    13201340
    1321     mr_asprintf(tmp, "%s/do-not-compress-these", g_mondo_home);
     1341    sprintf(tmp, "%s/do-not-compress-these", g_mondo_home);
    13221342    if (!does_file_exist(tmp)) {
    1323         mr_free(tmp);
    13241343        return (FALSE);
    13251344    }
    13261345    /* BERLIOS: This is just plain WRONG !! */
    1327     mr_asprintf(do_not_compress_these,"%s", last_line_of_file(tmp));
    1328     mr_free(tmp);
     1346    strcpy(do_not_compress_these,last_line_of_file(tmp));
    13291347
    13301348    for (p = do_not_compress_these; p != NULL; p++) {
    1331         mr_asprintf(tmp, "%s", p);
     1349        strcpy(tmp, p);
    13321350        if (strchr(tmp, ' ')) {
    13331351            *(strchr(tmp, ' ')) = '\0';
    13341352        }
    13351353        if (!strcmp(q, tmp)) {
    1336             mr_free(tmp);
    1337             mr_free(do_not_compress_these);
    13381354            return (TRUE);
    13391355        }
     
    13411357            break;
    13421358        }
    1343         mr_free(tmp);
    1344     }
    1345     mr_free(do_not_compress_these);
     1359    }
    13461360    return (FALSE);
    13471361}
  • branches/3.0/mondo/src/common/libmondo-files.h

    r3188 r3192  
    4242
    4343
    44 int make_hole_for_dir(const char *outdir_fname);
     44int make_hole_for_dir(char *outdir_fname);
    4545long size_of_partition_in_mountlist_K(char *tmpdir, char *dev);
    4646int read_one_liner_data_file(char *fname, char *contents);
  • branches/3.0/mondo/src/common/libmondo-fork.c

    r3188 r3192  
    88#include "my-stuff.h"
    99#include "mr_mem.h"
    10 #include "mr_str.h"
    1110#include "mondostructures.h"
    1211#include "libmondo-fork.h"
     
    3938    /*@ buffers ***************************************************** */
    4039    static char result[MAX_STR_LEN];
    41     char *tmp = NULL;
     40    char *tmp;
     41    char *p;
    4242
    4343    /*@ pointers **************************************************** */
    44     FILE *fin = NULL;
    45     int res = 0;
     44    FILE *fin;
    4645
    4746    /*@ initialize data ********************************************* */
     47    malloc_string(tmp);
    4848    result[0] = '\0';
     49    tmp[0] = '\0';
    4950
    5051    /*@******************************************************************** */
     
    5253    assert_string_is_neither_NULL_nor_zerolength(call);
    5354    if ((fin = popen(call, "r"))) {
    54         for (mr_getline(tmp, fin); !feof(fin); mr_getline(tmp, fin)) {
     55        for (p = fgets(tmp, MAX_STR_LEN, fin); !feof(fin) && (p != NULL);
     56             p = fgets(tmp, MAX_STR_LEN, fin)) {
    5557            if (strlen(tmp) > 1) {
    5658                strcpy(result, tmp);
    5759            }
    58             mr_free(tmp);
    5960        }
    6061        paranoid_pclose(fin);
    6162    } else {
    62         log_OS_error("Unable to open resulting file");
     63        log_OS_error("Unable to popen call");
    6364    }
    6465    strip_spaces(result);
    65     mr_free(tmp);
    66     return(result);
    67 }
     66    paranoid_free(tmp);
     67    return (result);
     68}
     69
     70
     71
     72
    6873
    6974
     
    8186 * @param isofile Replaces @c _ISO_ in @p basic_call. Should probably be the ISO image to create (-o parameter to mkisofs).
    8287 * @param cd_no Replaces @c _CD#_ in @p basic_call. Should probably be the CD number.
     88 * @param logstub Unused.
    8389 * @param what_i_am_doing The action taking place (e.g. "Making ISO #1"). Used as the title of the progress dialog.
    8490 * @return Exit code of @c mkisofs (0 is success, anything else indicates failure).
     91 * @bug @p logstub is unused.
    8592 */
    8693int
     
    94101
    95102    /*@ buffers      *** */
    96     char *midway_call = NULL;
    97     char *ultimate_call = NULL;
    98     char *tmp = NULL;
    99        
    100     char *cd_number_str = NULL;
    101     char *command = NULL;
    102     char *p= NULL;
     103    char *midway_call, *ultimate_call, *tmp, *command, *incoming,
     104        *old_stderr, *cd_number_str;
     105    char *p;
    103106    char *tmp1 = NULL;
    104     char *tmp2 = NULL;
    105107
    106108/*@***********   End Variables ***************************************/
     
    108110    log_msg(3, "Starting");
    109111    assert(bkpinfo != NULL);
     112    // BERLIOS: doesn't work even if the string is correct !
     113    //assert_string_is_neither_NULL_nor_zerolength(basic_call);
    110114    assert_string_is_neither_NULL_nor_zerolength(isofile);
    111 
     115    assert_string_is_neither_NULL_nor_zerolength(logstub);
    112116    if (!(midway_call = malloc(1200))) {
    113117        fatal_error("Cannot malloc midway_call");
     
    119123        fatal_error("Cannot malloc tmp");
    120124    }
     125    if (!(command = malloc(1200))) {
     126        fatal_error("Cannot malloc command");
     127    }
     128    malloc_string(incoming);
     129    malloc_string(old_stderr);
     130    malloc_string(cd_number_str);
     131
     132    incoming[0] = '\0';
     133    old_stderr[0] = '\0';
    121134
    122135    if ((bkpinfo->netfs_user) && (strstr(bkpinfo->netfs_proto,"nfs"))) {
     
    126139    }
    127140
    128     mr_asprintf(cd_number_str, "%d", cd_no);
     141    sprintf(cd_number_str, "%d", cd_no);
    129142    resolve_naff_tokens(midway_call, tmp1, isofile, "_ISO_");
     143    resolve_naff_tokens(tmp, midway_call, cd_number_str, "_CD#_");
     144    resolve_naff_tokens(ultimate_call, tmp, MONDO_LOGFILE, "_ERR_");
    130145    log_msg(4, "basic call = '%s'", tmp1);
    131     mr_free(tmp1);
    132 
    133     resolve_naff_tokens(tmp, midway_call, cd_number_str, "_CD#_");
    134146    log_msg(4, "midway_call = '%s'", midway_call);
    135     mr_free(cd_number_str);
    136 
    137     resolve_naff_tokens(ultimate_call, tmp, MONDO_LOGFILE, "_ERR_");
     147    log_msg(4, "tmp = '%s'", tmp);
    138148    log_msg(4, "ultimate call = '%s'", ultimate_call);
    139     mr_asprintf(command, "%s >> %s", ultimate_call, MONDO_LOGFILE);
    140 
    141     log_to_screen("Please be patient. Do not be alarmed by on-screen inactivity.");
    142     log_msg(4, "Calling open_evalcall_form() with what_i_am_doing='%s'", what_i_am_doing);
     149    sprintf(command, "%s >> %s", ultimate_call, MONDO_LOGFILE);
     150
     151    log_to_screen
     152        ("Please be patient. Do not be alarmed by on-screen inactivity.");
     153    log_msg(4, "Calling open_evalcall_form() with what_i_am_doing='%s'",
     154            what_i_am_doing);
     155    strcpy(tmp, command);
    143156    if (bkpinfo->manual_cd_tray) {
    144         mr_asprintf(tmp2, "%s", command);
    145         p = strstr(tmp2, "2>>");
     157        p = strstr(tmp, "2>>");
    146158        if (p) {
    147159            sprintf(p, "   ");
     
    149161                p++;
    150162            }
    151             for (; (*p != ' ') && (*p != '\0'); p++) {
     163            for (; *p != ' '; p++) {
    152164                *p = ' ';
    153165            }
    154166        }
    155         mr_free(command);
    156         command = tmp2;
     167        strcpy(command, tmp);
     168#ifndef _XWIN
    157169        if (!g_text_mode) {
    158170            newtSuspend();
    159171        }
     172#endif
    160173        log_msg(1, "command = '%s'", command);
    161174        retval += system(command);
     
    164177        }
    165178        if (retval) {
    166             popup_and_OK("mkisofs and/or cdrecord returned an error. CD was not created");
     179            log_msg(2, "Basic call '%s' returned an error.", tmp1);
     180            popup_and_OK("Press ENTER to continue.");
     181            popup_and_OK
     182                ("mkisofs and/or cdrecord returned an error. CD was not created");
    167183        }
    168184    }
     
    170186    else {
    171187        log_msg(3, "command = '%s'", command);
    172         retval = run_external_binary_with_percentage_indicator_NEW(what_i_am_doing, command);
    173     }
    174     mr_free(command);
     188//      yes_this_is_a_goto:
     189        retval =
     190            run_external_binary_with_percentage_indicator_NEW
     191            (what_i_am_doing, command);
     192    }
     193
     194    mr_free(tmp1);
    175195    paranoid_free(midway_call);
    176196    paranoid_free(ultimate_call);
    177197    paranoid_free(tmp);
     198    paranoid_free(command);
     199    paranoid_free(incoming);
     200    paranoid_free(old_stderr);
     201    paranoid_free(cd_number_str);
    178202    return (retval);
    179203}
     
    208232    log_msg(1, "command = '%s'", command);
    209233    if (!g_text_mode) {
    210         retval = run_external_binary_with_percentage_indicator_NEW(what_i_am_doing, command);
     234        retval = run_external_binary_with_percentage_indicator_NEW
     235            (what_i_am_doing, command);
    211236    } else {
    212237        retval += system(command);
     
    252277        return (1);
    253278    }
     279//  if (debug_level == TRUE) { debug_level=5; }
     280
     281    //  assert_string_is_neither_NULL_nor_zerolength(program);
    254282
    255283    if (debug_level <= g_loglevel) {
     
    294322                }
    295323            }
     324            /* end of patch */
    296325            strip_spaces(incoming);
    297326            if ((res == 0 && log_if_success) || (res != 0 && log_if_failure)) {
     
    313342        }
    314343    }
     344//  else
     345//    { log_msg (0, "-------------------------------ran w/ res=%d------------------------------", res); }
    315346    return (res);
    316347}
     
    337368
    338369    /*@ buffers **************************************************** */
     370    char *tmp = NULL;
    339371    char *command = NULL;
    340     char *lockfile = NULL;
     372    char lockfile[MAX_STR_LEN];
    341373
    342374    /*@ end vars *************************************************** */
     
    344376    assert_string_is_neither_NULL_nor_zerolength(basic_call);
    345377
    346     mr_asprintf(lockfile, "%s/mojo-jojo.bla.bla", bkpinfo->tmpdir);
    347 
    348     mr_asprintf(command, "echo hi > %s ; %s >> %s 2>> %s; res=$?; sleep 1; rm -f %s; exit $res", lockfile, basic_call, MONDO_LOGFILE, MONDO_LOGFILE, lockfile);
     378    sprintf(lockfile, "%s/mojo-jojo.bla.bla", bkpinfo->tmpdir);
     379
     380    mr_asprintf(command,
     381            "echo hi > %s ; %s >> %s 2>> %s; res=$?; sleep 1; rm -f %s; exit $res",
     382            lockfile, basic_call, MONDO_LOGFILE, MONDO_LOGFILE, lockfile);
    349383    open_evalcall_form(what_i_am_doing);
    350     log_msg(2, "Executing %s", basic_call);
     384    mr_asprintf(tmp, "Executing %s", basic_call);
     385    log_msg(2, tmp);
     386    mr_free(tmp);
    351387
    352388    if (!(fin = popen(command, "r"))) {
    353389        log_OS_error("Unable to popen-in command");
    354         log_to_screen("Failed utterly to call '%s'", command);
     390        mr_asprintf(tmp, "Failed utterly to call '%s'", command);
     391        log_to_screen(tmp);
     392        mr_free(tmp);
    355393        mr_free(command);
    356         mr_free(lockfile);
    357394        return (1);
    358395    }
    359 
    360396    if (!does_file_exist(lockfile)) {
    361397        log_to_screen("Waiting for '%s' to start",command);
     
    365401    }
    366402    mr_free(command);
    367 
     403#ifdef _XWIN
     404    /* This only can update when newline goes into the file,
     405       but it's *much* prettier/faster on Qt. */
     406    while (does_file_exist(lockfile)) {
     407        while (!feof(fin)) {
     408            /* TODO: Dead and wrong code */
     409            if (!fgets(tmp, 512, fin))
     410                break;
     411            log_to_screen(tmp);
     412        }
     413        usleep(500000);
     414    }
     415#else
     416    /* This works on Newt, and it gives quicker updates. */
    368417    for (; does_file_exist(lockfile); sleep(1)) {
    369418        log_file_end_to_screen(MONDO_LOGFILE, "");
    370419        update_evalcall_form(1);
    371420    }
    372 
     421#endif
    373422    /* Evaluate the status returned by pclose to get the exit code of the called program. */
    374423    errno = 0;
     
    385434    close_evalcall_form();
    386435    unlink(lockfile);
    387     mr_free(lockfile);
    388 
    389436    return (retval);
    390437}
     
    406453// if dir=='w' then copy from orig to archived
    407454// if dir=='r' then copy from archived to orig
    408     char *tmp = NULL;
    409     char *tmp1 = NULL;
    410     char *buf = NULL;
    411     char *filestr = NULL;
     455    char *tmp;
     456    char *buf;
     457    char filestr[MAX_STR_LEN];
    412458    long int bytes_to_be_read, bytes_read_in, bytes_written_out =
    413459        0, bufcap, subsliceno = 0;
     
    419465
    420466    log_msg(5, "Opening.");
    421 
     467    if (!(tmp = malloc(tmpcap))) {
     468        fatal_error("Failed to malloc() tmp");
     469    }
     470    tmp[0] = '\0';
    422471    bufcap = 256L * 1024L;
    423472    if (!(buf = malloc(bufcap))) {
     
    428477        fin = f_orig;
    429478        fout = f_archived;
    430         mr_asprintf(tmp, "%-64s", PIMP_START_SZ);
     479        sprintf(tmp, "%-64s", PIMP_START_SZ);
    431480        if (fwrite(tmp, 1, 64, fout) != 64) {
    432             mr_free(tmp);
    433481            fatal_error("Can't write the introductory block");
    434482        }
    435         mr_free(tmp);
    436 
    437483        while (1) {
    438484            bytes_to_be_read = bytes_read_in = fread(buf, 1, bufcap, fin);
     
    440486                break;
    441487            }
    442             mr_asprintf(tmp, "%-64ld", bytes_read_in);
     488            sprintf(tmp, "%-64ld", bytes_read_in);
    443489            if (fwrite(tmp, 1, 64, fout) != 64) {
    444                 mr_free(tmp);
    445490                fatal_error("Cannot write introductory block");
    446491            }
    447             mr_free(tmp);
    448 
    449492            log_msg(7,
    450493                    "subslice #%ld --- I have read %ld of %ld bytes in from f_orig",
    451494                    subsliceno, bytes_read_in, bytes_to_be_read);
    452495            bytes_written_out += fwrite(buf, 1, bytes_read_in, fout);
    453             mr_asprintf(tmp, "%-64ld", subsliceno);
     496            sprintf(tmp, "%-64ld", subsliceno);
    454497            if (fwrite(tmp, 1, 64, fout) != 64) {
    455                 mr_free(tmp);
    456498                fatal_error("Cannot write post-thingy block");
    457499            }
    458             mr_free(tmp);
    459500            log_msg(7, "Subslice #%d written OK", subsliceno);
    460501            subsliceno++;
    461502        }
    462         mr_asprintf(tmp, "%-64ld", 0L);
     503        sprintf(tmp, "%-64ld", 0L);
    463504        if (fwrite(tmp, 1, 64L, fout) != 64L) {
    464             mr_free(tmp);
    465505            fatal_error("Cannot write final introductory block");
    466506        }
    467         mr_free(tmp);
    468 
    469         mr_asprintf(tmp, "%-64s", PIMP_END_SZ);
    470         if (fwrite(tmp, 1, 64, fout) != 64) {
    471             mr_free(tmp);
    472             fatal_error("Can't write the final block");
    473         }
    474         mr_free(tmp);
    475507    } else {
    476508        fin = f_archived;
    477509        fout = f_orig;
    478         if (!(tmp1 = malloc(tmpcap))) {
    479             fatal_error("Failed to malloc() tmp");
    480         }
    481         if (fread(tmp1, 1, 64L, fin) != 64L) {
    482             mr_free(tmp1);
     510        if (fread(tmp, 1, 64L, fin) != 64L) {
    483511            fatal_error("Cannot read the introductory block");
    484512        }
    485         log_msg(5, "tmp1 is %s", tmp1);
    486         if (!strstr(tmp1, PIMP_START_SZ)) {
    487             mr_free(tmp1);
     513        log_msg(5, "tmp is %s", tmp);
     514        if (!strstr(tmp, PIMP_START_SZ)) {
    488515            fatal_error("Can't find intro blk");
    489516        }
    490         if (fread(tmp1, 1, 64L, fin) != 64L) {
    491             mr_free(tmp1);
     517        if (fread(tmp, 1, 64L, fin) != 64L) {
    492518            fatal_error("Cannot read introductory blk");
    493519        }
    494         bytes_to_be_read = atol(tmp1);
     520        bytes_to_be_read = atol(tmp);
    495521        while (bytes_to_be_read > 0) {
    496             log_msg(7, "subslice#%ld, bytes=%ld", subsliceno, bytes_to_be_read);
     522            log_msg(7, "subslice#%ld, bytes=%ld", subsliceno,
     523                    bytes_to_be_read);
    497524            bytes_read_in = fread(buf, 1, bytes_to_be_read, fin);
    498525            if (bytes_read_in != bytes_to_be_read) {
    499                 mr_free(tmp1);
    500                 fatal_error("Danger, WIll Robinson. Failed to read whole subvol from archives.");
     526                fatal_error
     527                    ("Danger, WIll Robinson. Failed to read whole subvol from archives.");
    501528            }
    502529            bytes_written_out += fwrite(buf, 1, bytes_read_in, fout);
    503             if (fread(tmp1, 1, 64, fin) != 64) {
    504                 mr_free(tmp1);
     530            if (fread(tmp, 1, 64, fin) != 64) {
    505531                fatal_error("Cannot read post-thingy block");
    506532            }
    507             if (atol(tmp1) != subsliceno) {
    508                 log_msg(1, "Wanted subslice %ld but got %ld ('%s')", subsliceno, atol(tmp1), tmp1);
     533            if (atol(tmp) != subsliceno) {
     534                log_msg(1, "Wanted subslice %ld but got %ld ('%s')",
     535                        subsliceno, atol(tmp), tmp);
    509536            }
    510537            log_msg(7, "Subslice #%ld read OK", subsliceno);
    511538            subsliceno++;
    512             if (fread(tmp1, 1, 64, fin) != 64) {
    513                 mr_free(tmp1);
     539            if (fread(tmp, 1, 64, fin) != 64) {
    514540                fatal_error("Cannot read introductory block");
    515541            }
    516             bytes_to_be_read = atol(tmp1);
    517         }
    518     }
     542            bytes_to_be_read = atol(tmp);
     543        }
     544    }
     545
     546//  log_msg(4, "Written %ld of %ld bytes", bytes_written_out, bytes_read_in);
    519547
    520548    if (direction == 'w') {
    521         mr_asprintf(tmp, "%-64s", PIMP_END_SZ);
     549        sprintf(tmp, "%-64s", PIMP_END_SZ);
    522550        if (fwrite(tmp, 1, 64, fout) != 64) {
    523             mr_free(tmp);
    524551            fatal_error("Can't write the final block");
    525552        }
    526         mr_free(tmp);
    527553    } else {
    528         log_msg(1, "tmpA is %s", tmp1);
    529         if (!strstr(tmp1, PIMP_END_SZ)) {
    530             if (fread(tmp1, 1, 64, fin) != 64) {
    531                 mr_free(tmp1);
     554        log_msg(1, "tmpA is %s", tmp);
     555        if (!strstr(tmp, PIMP_END_SZ)) {
     556            if (fread(tmp, 1, 64, fin) != 64) {
    532557                fatal_error("Can't read the final block");
    533558            }
    534             log_msg(5, "tmpB is %s", tmp1);
    535             if (!strstr(tmp1, PIMP_END_SZ)) {
    536                 mr_asprintf(filestr, "%s/out.leftover", bkpinfo->tmpdir);
     559            log_msg(5, "tmpB is %s", tmp);
     560            if (!strstr(tmp, PIMP_END_SZ)) {
     561                sprintf(filestr, "%s/out.leftover", bkpinfo->tmpdir);
    537562                ftmp = fopen(filestr, "w");
    538                 mr_free(filestr);
    539 
    540                 bytes_read_in = fread(tmp1, 1, 64, fin);
     563                bytes_read_in = fread(tmp, 1, 64, fin);
    541564                log_msg(1, "bytes_read_in = %ld", bytes_read_in);
    542 
     565//      if (bytes_read_in!=128+64) { fatal_error("Can't read the terminating block"); }
    543566                if (fwrite(tmp, 1, bytes_read_in, ftmp)) {
    544567                    fatal_error("Can't fwrite here");
    545568                }
    546 
    547                 mr_asprintf(tmp, "I am here - %lld", (long long)ftello(fin));
     569                sprintf(tmp, "I am here - %lld", (long long)ftello(fin));
     570//    log_msg(0, tmp);
    548571                if (fread(tmp, 1, tmpcap, fin)) {
    549                     mr_free(tmp);
    550572                    fatal_error("Can't fread here");
    551573                }
    552574                log_msg(0, "tmp = '%s'", tmp);
    553575                if (fwrite(tmp, 1, tmpcap, ftmp)) {
    554                     mr_free(tmp);
    555576                    fatal_error("Can't fwrite there");
    556577                }
    557578                fclose(ftmp);
    558                 mr_free(tmp);
    559579                fatal_error("Missing terminating block");
    560580            }
    561581        }
    562582    }
    563     mr_free(tmp1);
    564583
    565584    paranoid_free(buf);
     585    paranoid_free(tmp);
    566586    log_msg(3, "Successfully copied %ld bytes", bytes_written_out);
    567587    return (retval);
     
    581601// BACKUP
    582602    int res = -1;
    583     char *command = NULL;
     603    char*command;
    584604
    585605    if (!does_file_exist(input_device)) {
     
    589609        fatal_error("ntfsclone not found");
    590610    }
    591     mr_asprintf(command, "ntfsclone --rescue --force --save-image --overwrite %s %s", output_fname, input_device);
     611    malloc_string(command);
     612    sprintf(command, "ntfsclone --rescue --force --save-image --overwrite %s %s", output_fname, input_device);
    592613    res = run_program_and_log_output(command, 5);
    593     mr_free(command);
    594 
     614    paranoid_free(command);
    595615    unlink(output_fname);
    596616    return (res);
     
    618638
    619639
    620 int run_external_binary_with_percentage_indicator_NEW(char *tt, char *cmd) {
     640int run_external_binary_with_percentage_indicator_NEW(char *tt, char *cmd)
     641{
    621642
    622643    /*@ int *************************************************************** */
     
    629650
    630651    /*@ buffers *********************************************************** */
    631     char *command = NULL;
     652    char *command;
     653    char *title;
    632654    /*@ pointers ********************************************************** */
    633655    static int chldres = 0;
     
    640662    *pchild_result = 999;
    641663
    642     mr_asprintf(command, "%s 2>> %s", cmd, MONDO_LOGFILE);
     664    malloc_string(title);
     665    malloc_string(command);
     666    strcpy(title, tt);
     667    sprintf(command, "%s 2>> %s", cmd, MONDO_LOGFILE);
    643668    log_msg(3, "command = '%s'", command);
    644     if ((res = pthread_create(&childthread, NULL, run_prog_in_bkgd_then_exit, (void *) command))) {
     669    if ((res =
     670         pthread_create(&childthread, NULL, run_prog_in_bkgd_then_exit,
     671                        (void *) command))) {
    645672        fatal_error("Unable to create an archival thread");
    646673    }
    647674
    648675    log_msg(8, "Parent running");
    649     open_evalcall_form(tt);
    650 
     676    open_evalcall_form(title);
    651677    for (sleep(1); command[0] != '\0'; sleep(1)) {
    652678        pcno = grab_percentage_from_last_line_of_file(MONDO_LOGFILE);
    653         if (pcno < 0 || pcno > 100) {
    654             log_msg(8, "Weird pc# %d", pcno);
     679        if (pcno <= 0 || pcno > 100) {
     680            log_msg(8, "Weird pc#");
    655681            continue;
    656682        }
     
    658684        if (pcno <= 5 && last_pcno >= 40) {
    659685            close_evalcall_form();
    660             open_evalcall_form("Verifying...");
     686            strcpy(title, "Verifying...");
     687            open_evalcall_form(title);
    661688        }
    662689        if (counter++ >= 5) {
     
    667694        update_evalcall_form(percentage);
    668695    }
    669     mr_free(command);
    670 
    671696    log_file_end_to_screen(MONDO_LOGFILE, "");
    672697    close_evalcall_form();
     
    678703    }
    679704    log_msg(3, "Parent res = %d", res);
     705    paranoid_free(command);
     706    paranoid_free(title);
    680707    return (res);
    681708}
     709
     710
    682711
    683712
     
    692721// RESTORE
    693722    int res = -1;
    694     char *command = NULL;
     723    char *command;
    695724
    696725    if ( !find_home_of_exe("ntfsclone")) {
    697726        fatal_error("ntfsclone not found");
    698727    }
    699     mr_asprintf(command, "ntfsclone --rescue --force --restore-image --overwrite %s %s", output_device, input_fifo);
     728    malloc_string(command);
     729    sprintf(command, "ntfsclone --rescue --force --restore-image --overwrite %s %s", output_device, input_fifo);
    700730    res = run_program_and_log_output(command, 5);
    701     mr_free(command);
     731    paranoid_free(command);
    702732    return (res);
    703733}
  • branches/3.0/mondo/src/common/libmondo-gui-EXT.h

    r3188 r3192  
    11/* libmondo-gui-EXT.h */
    22
     3#ifdef _XWIN
     4#include "X-specific-EXT.h"
     5#else
    36#include "newt-specific-EXT.h"
     7#endif
  • branches/3.0/mondo/src/common/libmondo-gui.c

    r3188 r3192  
    99 */
    1010
     11#ifdef _XWIN
     12#include "X-specific.c"
     13#else
    1114#include "newt-specific.c"
     15#endif
  • branches/3.0/mondo/src/common/libmondo-gui.h

    r3188 r3192  
    33 */
    44
     5#ifdef _XWIN
     6#include "X-specific.h"
     7#else
    58#include "newt-specific.h"
     9#endif
  • branches/3.0/mondo/src/common/libmondo-mountlist.c

    r3188 r3192  
    5959    char tmp = NULL;
    6060    char device[MAX_STR_LEN];
     61    char mountpoint[MAX_STR_LEN];
    6162
    6263    char *flaws_str = NULL;
     
    99100                continue;
    100101            }
     102            strcpy(mountpoint, mountlist->el[pos].mountpoint);
    101103            /* is it too big? */
    102104            if (curr_part_no > 'h') {
     
    174176
    175177        build_partition_name(device, drive, curr_part_no);
     178        strcpy(mountpoint, mountlist->el[pos].mountpoint);
    176179        if (pos > 0 && !npos) {
    177180            /* gap in the partition list? */
     
    257260                    continue;
    258261                }
     262                strcpy(mountpoint, mountlist->el[pos].mountpoint);
    259263                /* is it too big? */
    260264                if (curr_part_no > 'h') {
     
    323327        if (amount_allocated > physical_drive_size) {
    324328            // Used to be +1, but what if you're 1 MB too high?
    325             mr_asprintf(tmp, " %ld MB over-allocated on %s.",amount_allocated - physical_drive_size, drive);
     329            mr_asprintf(tmp, " %ld MB over-allocated on %s.",
     330                    amount_allocated - physical_drive_size, drive);
    326331            log_it(tmp);
    327332
     
    343348
    344349    /* Over-allocated the disk? Unallocated space on disk? */
    345     if (amount_allocated > physical_drive_size) // Used to be +1, but what if you're 1 MB too high?
    346     {
    347         mr_asprintf(tmp, " %ld MB over-allocated on %s.", amount_allocated - physical_drive_size, drive);
    348         log_it(tmp);
    349         mr_strcat(flaws_str, "%s", tmp);
    350         mr_free(tmp);
    351         res++;
    352     } else if (amount_allocated < physical_drive_size - 1) {    /* NOT AN ERROR, JUST A WARNING :-) */
    353         mr_asprintf(tmp, " %ld MB unallocated on %s.", physical_drive_size - amount_allocated, drive);
     350    if (amount_allocated < physical_drive_size - 1) {   /* NOT AN ERROR, JUST A WARNING :-) */
     351        mr_asprintf(tmp, " %ld MB unallocated on %s.",
     352                physical_drive_size - amount_allocated, drive);
    354353        log_it(tmp);
    355354        mr_strcat(flaws_str, "%s", tmp);
     
    406405            goto endoffunc;
    407406        } else {
    408             log_it(" %s (dm) will be setup later on", drive);
     407            mr_asprintf(tmp, " %s (dm) will be setup later on", drive);
     408            log_it(tmp);
     409            mr_free(tmp);
    409410        }
    410411    } else {
    411         log_it("%s is %ld MB", drive, physical_drive_size);
     412        mr_asprintf(tmp, "%s is %ld MB", drive, physical_drive_size);
     413        log_it(tmp);
     414        mr_free(tmp);
    412415    }
    413416
     
    429432            } else if (curr_part_no > 5
    430433                       || (curr_part_no <= 4 && prev_part_no > 0)) {
    431                 mr_asprintf(tmp, " Gap on %s between %d and %d.", drive, prev_part_no, curr_part_no);
     434                mr_asprintf(tmp, " Gap on %s between %d and %d.", drive,
     435                        prev_part_no, curr_part_no);
    432436                log_it(tmp);
    433437                mr_strcat(flaws_str, "%s", tmp);
     
    439443        part_table_fmt = which_partition_format(drive);
    440444        /* no spare primary partitions to help accommodate the logical(s)? */
    441         if ((curr_part_no >= 5 && prev_part_no == 4) && (strcmp(part_table_fmt, "MBR") == 0)) {
     445        if ((curr_part_no >= 5 && prev_part_no == 4)
     446            && (strcmp(part_table_fmt, "MBR") == 0)) {
    442447            mr_asprintf(tmp, " Partition 4 of %s is occupied.", drive);
    443448            log_it(tmp);
     
    446451            res++;
    447452        }
    448         mr_free(part_table_fmt);
    449 
    450453        /* does partition /dev/hdNX exist more than once in the mountlist? */
    451454        for (i = 0, device_copies = 0;
     
    456459        }
    457460        if (device_copies > 1) {
    458             mr_asprintf(tmp, " %s %s's.", number_to_text(device_copies), device);
     461            mr_asprintf(tmp, " %s %s's.", number_to_text(device_copies),
     462                    device);
    459463            if (!strstr(flaws_str, tmp)) {
    460464                log_it(tmp);
     
    500504    /* Over-allocated the disk? Unallocated space on disk? */
    501505    if (amount_allocated > physical_drive_size + 1) {
    502         mr_asprintf(tmp, " %ld MB over-allocated on %s.", amount_allocated - physical_drive_size, drive);
     506        mr_asprintf(tmp, " %ld MB over-allocated on %s.",
     507                amount_allocated - physical_drive_size, drive);
    503508        log_it(tmp);
    504509        mr_strcat(flaws_str, "%s", tmp);
     
    506511        res++;
    507512    } else if (amount_allocated < physical_drive_size - 1) {    /* NOT AN ERROR, JUST A WARNING :-) */
    508         mr_asprintf(tmp, " %ld MB unallocated on %s.", physical_drive_size - amount_allocated, drive);
     513        mr_asprintf(tmp, " %ld MB unallocated on %s.",
     514                physical_drive_size - amount_allocated, drive);
    509515        log_it(tmp);
    510516        mr_strcat(flaws_str, "%s", tmp);
     
    564570            (drivelist->el[i].device,
    565571             DONT_KNOW_HOW_TO_EVALUATE_THIS_DEVICE_TYPE)) {
    566             log_it(" Not evaluating %s (I don't know how yet)", drivelist->el[i].device);
     572            mr_asprintf(tmp, " Not evaluating %s (I don't know how yet)", drivelist->el[i].device);
     573            log_it(tmp);
     574            paranoid_free(tmp);
    567575        } else {
    568576            log_msg(8, "Evaluating drive #%d (%s) within mountlist", i, drivelist->el[i].device);
     
    574582            log_msg(8,"Adding: %s to flaws_str", tmp);
    575583            mr_strcat(flaws_str, "%s", tmp);
    576             mr_free(tmp);
     584            paranoid_free(tmp);
    577585        }
    578586    }
     
    594602            mr_strcat(flaws_str, "%s", tmp);
    595603            log_msg(8,"Adding: %s to flaws_str", tmp);
    596             mr_free(tmp);
    597         }
    598         mr_free(curr_mountpoint);
     604            paranoid_free(tmp);
     605        }
     606        paranoid_free(curr_mountpoint);
    599607    }
    600608
     
    661669        if (!strncmp(drive, RAID_DEVICE_STUB, strlen(RAID_DEVICE_STUB))) {
    662670            log_msg(8, "Not putting %s in list of drives: it's a virtual drive", drive);
    663             mr_free(drive);
     671            paranoid_free(drive);
    664672            continue;
    665673        }
     
    668676        if (size == 0) {
    669677            log_msg(8, "Not putting %s in list of drives: it has zero size (maybe an LVM volume)", drive);
    670             mr_free(drive);
     678            paranoid_free(drive);
    671679            continue;
    672680        }
     
    676684        /* memory allocation */
    677685        truncdrive = truncate_to_drive_name(drive);
    678         mr_free(drive);
     686        paranoid_free(drive);
    679687
    680688        log_msg(8, "drive truncated to %s", truncdrive);
     
    725733    int used_by = 0;
    726734
     735    /*@ buffers ********************************************************* */
     736    char *tmp = NULL;
     737
    727738    assert(output_list != NULL);
    728739    assert(mountlist != NULL);
     
    734745    for (i = 0; i < mountlist->entries; i++) {
    735746        if (strstr(mountlist->el[i].mountpoint, "raid")) {
    736             used_by = which_raid_device_is_using_this_partition(raidlist, mountlist->el[i].device);
     747            used_by =
     748                which_raid_device_is_using_this_partition(raidlist,
     749                                                          mountlist->el[i].
     750                                                          device);
    737751            if (used_by < 0) {
    738752                memcpy((void *) &output_list->el[items++],
    739753                       (void *) &mountlist->el[i],
    740754                       sizeof(struct mountlist_line));
    741                 log_it("%s is available; user may choose to add it to raid device", output_list->el[items - 1].device);
     755                mr_asprintf(tmp, "%s is available; user may choose to add it to raid device", output_list->el[items - 1].device);
     756                log_it(tmp);
     757                paranoid_free(tmp);
    742758            }
    743759        }
     
    794810    char *tmp = NULL;
    795811    char *p = NULL;
     812    char *q = NULL;
    796813
    797814    int items = 0;
     
    807824        return (1);
    808825    }
     826    malloc_string(incoming);
    809827    malloc_string(siz);
     828    q = fgets(incoming, MAX_STR_LEN - 1, fin);
    810829    log_it("Loading mountlist...");
    811     mr_getline(incoming, fin);
    812     while (!feof(fin)) {
     830    while (!feof(fin) && (q != NULL)) {
    813831#if linux
    814         res = sscanf(incoming, "%s %s %s %s %s", mountlist->el[items].device, mountlist->el[items].mountpoint, mountlist->el[items].format, siz, mountlist->el[items].label);
     832        res = sscanf(incoming,
     833               "%s %s %s %s %s",
     834               mountlist->el[items].device,
     835               mountlist->el[items].mountpoint,
     836               mountlist->el[items].format,
     837               siz, mountlist->el[items].label);
    815838        if (res < 5) {
    816839            /* no label found */
     
    819842        }
    820843#elif __FreeBSD__
    821         res = sscanf(incoming, "%s %s %s %s", mountlist->el[items].device, mountlist->el[items].mountpoint, mountlist->el[items].format, siz);
     844        res = sscanf(incoming,
     845               "%s %s %s %s",
     846               mountlist->el[items].device,
     847               mountlist->el[items].mountpoint,
     848               mountlist->el[items].format, siz);
    822849        strcpy(mountlist->el[items].label,"");
    823850#endif
     
    832859            !strcmp(mountlist->el[items].device, "devpts")
    833860            ) {
    834             log_msg(1, "Ignoring %s in mountlist - not loading that line :) ", mountlist->el[items].device);
    835             mr_free(incoming);
    836             mr_getline(incoming, fin);
     861            log_msg(1,
     862                    "Ignoring %s in mountlist - not loading that line :) ",
     863                    mountlist->el[items].device);
     864            q = fgets(incoming, MAX_STR_LEN - 1, fin);
    837865            continue;
    838866        }
     
    846874            if (j < items) {
    847875                strcat(mountlist->el[items].device, "_dup");
    848                 log_it("Duplicate entry in mountlist - renaming to %s", mountlist->el[items].device);
     876                mr_asprintf(tmp, "Duplicate entry in mountlist - renaming to %s", mountlist->el[items].device);
     877                log_it(tmp);
     878                paranoid_free(tmp);
    849879            }
    850880            mr_asprintf(tmp, "%s", mountlist->el[items].device);
     
    857887                    *(p + 2) = *(p + 3);
    858888                }
    859                 log_it("It was %s; it is now %s", mountlist->el[items].device, tmp);
     889                log_it("It was %s; it is now %s",
     890                       mountlist->el[items].device, tmp);
    860891                strcpy(mountlist->el[items].device, tmp);
    861892            }
    862893            paranoid_free(tmp);
    863894
    864             log_it("%s %s %s %lld %s", mountlist->el[items].device, mountlist->el[items].mountpoint, mountlist->el[items].format, mountlist->el[items].size, mountlist->el[items].label);
     895            log_it("%s %s %s %lld %s",
     896                     mountlist->el[items].device,
     897                     mountlist->el[items].mountpoint,
     898                     mountlist->el[items].format,
     899                     mountlist->el[items].size,
     900                     mountlist->el[items].label);
    865901            items++;
    866902            if (items >= MAX_MOUNTLIST_ENTRIES) {
     
    869905            }
    870906        }
    871         mr_free(incoming);
    872         mr_getline(incoming, fin);
    873     }
    874     mr_free(incoming);
     907        q = fgets(incoming, MAX_STR_LEN - 1, fin);
     908    }
    875909    paranoid_fclose(fin);
    876910    mountlist->entries = items;
     
    879913    log_it("%d entries in mountlist", items);
    880914
     915    paranoid_free(incoming);
    881916    paranoid_free(siz);
    882917    return (0);
     
    10151050
    10161051    mountlist->el[b].size = size;
    1017     mr_free(device);
    1018     mr_free(mountpoint);
    1019     mr_free(format);
     1052    paranoid_free(device);
     1053    paranoid_free(mountpoint);
     1054    paranoid_free(format);
    10201055}
    10211056
  • branches/3.0/mondo/src/common/libmondo-raid.c

    r3188 r3192  
    335335#ifdef __FreeBSD__
    336336    int i, j;
    337     char *org = NULL;
    338337
    339338    fprintf(fout, "\nvolume %s\n", raidrec->volname);
    340339    for (i = 0; i < raidrec->plexes; ++i) {
     340        char org[24];
    341341        switch (raidrec->plex[i].raidlevel) {
    342342        case -1:
    343             mr_asprintf(org, "concat");
     343            strcpy(org, "concat");
    344344            break;
    345345        case 0:
    346             mr_asprintf(org, "striped");
     346            strcpy(org, "striped");
    347347            break;
    348348        case 5:
    349             mr_asprintf(org, "raid5");
     349            strcpy(org, "raid5");
    350350            break;
    351351        }
    352352        fprintf(fout, "  plex org %s", org);
    353         mr_free(org);
    354 
    355353        if (raidrec->plex[i].raidlevel != -1) {
    356354            fprintf(fout, " %ik", raidrec->plex[i].stripesize);
     
    359357
    360358        for (j = 0; j < raidrec->plex[i].subdisks; ++j) {
    361             fprintf(fout, "    sd drive %s size 0\n", raidrec->plex[i].sd[j].which_device);
     359            fprintf(fout, "    sd drive %s size 0\n",
     360                    raidrec->plex[i].sd[j].which_device);
    362361        }
    363362    }
     
    428427int get_next_raidtab_line(FILE * fin, char *label, char *value)
    429428{
    430     char *incoming = NULL;
     429    char *incoming;
    431430    char *p;
    432 
     431    char *q;
     432
     433    malloc_string(incoming);
    433434    assert(fin != NULL);
    434435    assert(label != NULL);
     
    437438    label[0] = value[0] = '\0';
    438439    if (feof(fin)) {
     440        paranoid_free(incoming);
    439441        return (1);
    440442    }
    441     for (mr_getline(incoming, fin); !feof(fin); mr_getline(incoming, fin)) {
    442         mr_strip_spaces(incoming);
     443    for (q = fgets(incoming, MAX_STR_LEN - 1, fin); !feof(fin) && (q != NULL);
     444         q = fgets(incoming, MAX_STR_LEN - 1, fin)) {
     445        strip_spaces(incoming);
    443446        p = strchr(incoming, ' ');
    444447        if (strlen(incoming) < 3 || incoming[0] == '#' || !p) {
    445             mr_free(incoming);
    446448            continue;
    447449        }
     
    452454        strcpy(label, incoming);
    453455        strcpy(value, p);
    454         mr_free(incoming);
     456        paranoid_free(incoming);
    455457        return (0);
    456458    }
    457     mr_free(incoming);
    458459    return (1);
    459460}
     
    472473{
    473474    FILE *fin;
     475    char *tmp1 = NULL;
    474476    int items;
    475477
     
    502504
    503505            if (get_option_state(argc, argv, "hotspare")) {
    504                 strcpy(raidlist->spares.el[raidlist->spares.entries].name, drivename);
    505                 strcpy(raidlist->spares.el[raidlist->spares.entries].  device, devname);
     506                strcpy(raidlist->spares.el[raidlist->spares.entries].name,
     507                       drivename);
     508                strcpy(raidlist->spares.el[raidlist->spares.entries].
     509                       device, devname);
    506510                raidlist->spares.el[raidlist->spares.entries].index =
    507511                    raidlist->disks.entries;
    508512                raidlist->spares.entries++;
    509513            } else {
    510                 strcpy(raidlist->disks.el[raidlist->disks.entries].name, drivename);
    511                 strcpy(raidlist->disks.el[raidlist->disks.entries].device, devname);
     514                strcpy(raidlist->disks.el[raidlist->disks.entries].name,
     515                       drivename);
     516                strcpy(raidlist->disks.el[raidlist->disks.entries].device,
     517                       devname);
    512518                raidlist->disks.el[raidlist->disks.entries].index =
    513519                    raidlist->disks.entries;
     
    581587    fclose(fin);
    582588    log_it("Raidtab loaded successfully.");
    583     log_it("%d RAID devices in raidtab", raidlist->entries);
     589    mr_asprintf(tmp1, "%d RAID devices in raidtab", raidlist->entries);
     590    log_it(tmp1);
     591    mr_free(tmp1);
    584592    return (0);
    585593}
     
    588596#else
    589597
    590 int load_raidtab_into_raidlist(struct raidlist_itself *raidlist, char *fname) {
    591 
    592     FILE *fin = NULL;
    593     char *label = NULL;
    594     char *value = NULL;
     598int load_raidtab_into_raidlist(struct raidlist_itself *raidlist,
     599                               char *fname)
     600{
     601    FILE *fin;
     602    char *label;
     603    char *value;
    595604    int items;
    596605    int v;
     
    671680
    672681    /*@ add mallocs * */
     682    char *tmp = NULL;
    673683    char *labelB;
    674684    char *valueB;
     
    729739        }
    730740        if (!disklist) {
    731             log_it("Ignoring '%s %s' pair of disk %s", labelB, valueB, label);
     741            mr_asprintf(tmp, "Ignoring '%s %s' pair of disk %s", labelB, valueB, label);
     742            log_it(tmp);
     743            mr_free(tmp);
    732744        } else {
    733745            index = atoi(valueB);
     
    799811    static char *argv[64];
    800812    char **ap;
    801     char *line = NULL;
    802 
    803     mr_getline(line, f);
    804     if (feof(f)) {
     813    char *q;
     814    char *line = (char *) malloc(MAX_STR_LEN);
     815
     816    if (!line)
     817        errx(1,
     818             "unable to allocate %i bytes of memory for `char *line' at %s:%i",
     819             MAX_STR_LEN, __FILE__, __LINE__);
     820    q = fgets(line, MAX_STR_LEN, f);
     821    if (feof(f) && (q != NULL)) {
    805822        log_it("[GNVCL] Uh... I reached the EOF.");
    806823        return 0;
     
    813830            cnt++;
    814831        }
    815     mr_free(line);
    816832
    817833    if (strchr(argv[cnt - 1], '\n')) {
     
    11031119            while((token = mr_strtok (string, delims, &lastpos))) {
    11041120                if ((pos = strstr(token, "("))) {
    1105                     type = *(pos+1);
     1121                    type = *(pos+1);
    11061122                } else {
    1107                     type = ' ';
     1123                    type = ' ';
    11081124                }
    11091125                pos = strstr(token, "[");
     
    11111127                switch(type) {
    11121128                case ' ': // normal data disks
    1113                     raidlist->el[raidlist->entries].data_disks.el[raidlist->el[raidlist->entries].data_disks.entries].index = atoi(pos + 1);
    1114                     mr_asprintf(strtmp,"%s%s", device_prefix, token);
    1115                     strcpy(raidlist->el[raidlist->entries].data_disks.el[raidlist->el[raidlist->entries].data_disks.entries].device, strtmp);
    1116                     mr_free(strtmp);
    1117                     raidlist->el[raidlist->entries].data_disks.entries++;
    1118                     break;
     1129                    raidlist->el[raidlist->entries].data_disks.el[raidlist->el[raidlist->entries].data_disks.entries].index = atoi(pos + 1);
     1130                    mr_asprintf(strtmp,"%s%s", device_prefix, token);
     1131                    strcpy(raidlist->el[raidlist->entries].data_disks.el[raidlist->el[raidlist->entries].data_disks.entries].device, strtmp);
     1132                    mr_free(strtmp);
     1133                    raidlist->el[raidlist->entries].data_disks.entries++;
     1134                    break;
    11191135                case 'S': // spare disks
    1120                     raidlist->el[raidlist->entries].spare_disks.el[raidlist->el[raidlist->entries].spare_disks.entries].index = atoi(pos + 1);
    1121                     mr_asprintf(strtmp,"%s%s", device_prefix, token);
    1122                     strcpy(raidlist->el[raidlist->entries].spare_disks.el[raidlist->el[raidlist->entries].spare_disks.entries].device, strtmp);
    1123                     mr_free(strtmp);
    1124                     raidlist->el[raidlist->entries].spare_disks.entries++;
    1125                     break;
     1136                    raidlist->el[raidlist->entries].spare_disks.el[raidlist->el[raidlist->entries].spare_disks.entries].index = atoi(pos + 1);
     1137                    mr_asprintf(strtmp,"%s%s", device_prefix, token);
     1138                    strcpy(raidlist->el[raidlist->entries].spare_disks.el[raidlist->el[raidlist->entries].spare_disks.entries].device, strtmp);
     1139                    mr_free(strtmp);
     1140                    raidlist->el[raidlist->entries].spare_disks.entries++;
     1141                    break;
    11261142                case 'F': // failed disks
    1127                     raidlist->el[raidlist->entries].failed_disks.el[raidlist->el[raidlist->entries].failed_disks.entries].index = atoi(pos + 1);
    1128                     mr_asprintf(strtmp,"%s%s", device_prefix, token);
    1129                     strcpy(raidlist->el[raidlist->entries].failed_disks.el[raidlist->el[raidlist->entries].failed_disks.entries].device, strtmp);
    1130                     mr_free(strtmp);
    1131                     raidlist->el[raidlist->entries].failed_disks.entries++;
    1132                     log_it("At least one failed disk found in RAID array.\n");
    1133                     break;
     1143                    raidlist->el[raidlist->entries].failed_disks.el[raidlist->el[raidlist->entries].failed_disks.entries].index = atoi(pos + 1);
     1144                    mr_asprintf(strtmp,"%s%s", device_prefix, token);
     1145                    strcpy(raidlist->el[raidlist->entries].failed_disks.el[raidlist->el[raidlist->entries].failed_disks.entries].device, strtmp);
     1146                    mr_free(strtmp);
     1147                    raidlist->el[raidlist->entries].failed_disks.entries++;
     1148                    log_it("At least one failed disk found in RAID array.\n");
     1149                    break;
    11341150                default: // error
    1135                     log_msg(1, "Unknown device type '%c'\n", type);
    1136                     mr_free(string);
    1137                     mr_free(token);
    1138                     return 1;
    1139                     break;
     1151                    log_msg(1, "Unknown device type '%c'\n", type);
     1152                    mr_free(string);
     1153                    mr_free(token);
     1154                    return 1;
     1155                    break;
    11401156                }
    11411157                mr_free(token);
     
    11461162            for (i=0; i<raidlist->el[raidlist->entries].data_disks.entries;i++) {
    11471163                if (raidlist->el[raidlist->entries].data_disks.el[i].index < index_min) {
    1148                     index_min = raidlist->el[raidlist->entries].data_disks.el[i].index;
     1164                    index_min = raidlist->el[raidlist->entries].data_disks.el[i].index;
    11491165                }
    11501166            }
    11511167            if (index_min > 0) {
    11521168                for (i=0; i<raidlist->el[raidlist->entries].data_disks.entries;i++) {
    1153                     raidlist->el[raidlist->entries].data_disks.el[i].index = raidlist->el[raidlist->entries].data_disks.el[i].index - index_min;   
     1169                    raidlist->el[raidlist->entries].data_disks.el[i].index = raidlist->el[raidlist->entries].data_disks.el[i].index - index_min;   
    11541170                }
    11551171            }
     
    11571173            for (i=0; i<raidlist->el[raidlist->entries].spare_disks.entries;i++) {
    11581174                if (raidlist->el[raidlist->entries].spare_disks.el[i].index < index_min) {
    1159                     index_min = raidlist->el[raidlist->entries].spare_disks.el[i].index;
     1175                    index_min = raidlist->el[raidlist->entries].spare_disks.el[i].index;
    11601176                }
    11611177            }
    11621178            if (index_min > 0) {
    11631179                for (i=0; i<raidlist->el[raidlist->entries].spare_disks.entries;i++) {
    1164                         raidlist->el[raidlist->entries].spare_disks.el[i].index = raidlist->el[raidlist->entries].spare_disks.el[i].index - index_min; 
     1180                    raidlist->el[raidlist->entries].spare_disks.el[i].index = raidlist->el[raidlist->entries].spare_disks.el[i].index - index_min; 
    11651181                }
    11661182            }
     
    11681184            for (i=0; i<raidlist->el[raidlist->entries].failed_disks.entries;i++) {
    11691185                if (raidlist->el[raidlist->entries].failed_disks.el[i].index < index_min) {
    1170                     index_min = raidlist->el[raidlist->entries].failed_disks.el[i].index;
     1186                    index_min = raidlist->el[raidlist->entries].failed_disks.el[i].index;
    11711187                }
    11721188            }
    11731189            if (index_min > 0) {
    11741190                for (i=0; i<raidlist->el[raidlist->entries].failed_disks.entries;i++) {
    1175                         raidlist->el[raidlist->entries].failed_disks.el[i].index = raidlist->el[raidlist->entries].failed_disks.el[i].index - index_min;   
     1191                    raidlist->el[raidlist->entries].failed_disks.el[i].index = raidlist->el[raidlist->entries].failed_disks.el[i].index - index_min;   
    11761192                }
    11771193            }
     
    11891205            } else {
    11901206                while (*pos != ' ') {
    1191                     pos -= 1;
    1192                     if (pos < string) {
    1193                         log_it("String underflow!\n");
    1194                         mr_free(string);
    1195                         return 1;
    1196                     }
     1207                    pos -= 1;
     1208                    if (pos < string) {
     1209                            log_it("String underflow!\n");
     1210                            mr_free(string);
     1211                            return 1;
     1212                    }
    11971213                }
    11981214                raidlist->el[raidlist->entries].chunk_size = atoi(pos + 1);
     
    12081224            if (!(pos = strchr(string, '\%'))) {
    12091225                if (strcasestr(string, "delayed")) {
    1210                     raidlist->el[raidlist->entries].progress = -1;  // delayed (therefore, stuck at 0%)
     1226                    raidlist->el[raidlist->entries].progress = -1;  // delayed (therefore, stuck at 0%)
    12111227                } else {
    1212                     raidlist->el[raidlist->entries].progress = 999; // not found
     1228                    raidlist->el[raidlist->entries].progress = 999; // not found
    12131229                }
    12141230            } else {
    12151231                while (*pos != ' ') {
    1216                     pos -= 1;
    1217                     if (pos < string) {
    1218                         printf("ERROR: String underflow!\n");
    1219                         mr_free(string);
    1220                         return 1;
    1221                     }
     1232                    pos -= 1;
     1233                    if (pos < string) {
     1234                        printf("ERROR: String underflow!\n");
     1235                            mr_free(string);
     1236                            return 1;
     1237                    }
    12221238                }
    12231239                raidlist->el[raidlist->entries].progress = atoi(pos);
    12241240            }
    12251241            break;
    1226         default: // error or IN PROGRESS
     1242        default: // error or IN PROGRESS
    12271243            if (raidlist->el[raidlist->entries].progress != -1 &&
    12281244                raidlist->el[raidlist->entries].progress != 999) {
     
    12301246            }
    12311247            break;
    1232         }
    1233     row++;
     1248        }
     1249        row++;
    12341250    }
    12351251    // free string
  • branches/3.0/mondo/src/common/libmondo-stream.c

    r3188 r3192  
    138138    }
    139139    sleep(1);
    140     sync();
     140    paranoid_system("sync");
    141141    sleep(1);
    142142    paranoid_pclose(g_tape_stream);
    143143    log_it("closein_tape() -- leaving");
     144/*
     145  for(i=0; i < g_tapecatalog->entries; i++)
     146    {
     147      log_it("i=%d type=%s num=%d aux=%ld", i, (g_tapecatalog->el[i].type==fileset)?"fileset":"bigslice", g_tapecatalog->el[i].number, g_tapecatalog->el[i].aux);
     148    }
     149*/
    144150    if (!bkpinfo->please_dont_eject) {
    145151        eject_device(bkpinfo->media_device);
     
    177183
    178184    sleep(1);
    179     sync();
     185    paranoid_system("sync");
    180186    sleep(1);
    181187    log_it("closeout_tape() -- entering");
     
    222228               g_tapecatalog->el[i].tape_posK);
    223229    }
     230    //  if (!bkpinfo->please_dont_eject)
     231    //    { eject_device(bkpinfo->media_device); }
    224232    paranoid_free(blk);
    225233    paranoid_free(g_tapecatalog);
     
    258266    char tmp[MAX_STR_LEN];
    259267    char *command = NULL;
    260     char *cdr_exe = NULL;
     268    char cdr_exe[MAX_STR_LEN];
    261269    int res;
    262270
     
    264272    dev[0] = siz[0] = '\0';
    265273    if (find_home_of_exe("cdrecord")) {
    266         mr_asprintf(cdr_exe, "cdrecord");
    267     } else {
    268         mr_asprintf(cdr_exe, "dvdrecord");
    269     }
    270     mr_asprintf(command, "%s -scanbus 2> /dev/null | grep -i tape | wc -l", cdr_exe);
    271     mr_asprintf(tmp, "%s", call_program_and_get_last_line_of_output(command));
     274        strcpy(cdr_exe, "cdrecord");
     275    } else {
     276        strcpy(cdr_exe, "dvdrecord");
     277    }
     278    mr_asprintf(command, "%s -scanbus 2> /dev/null | grep -i tape | wc -l",
     279            cdr_exe);
     280    strcpy(tmp, call_program_and_get_last_line_of_output(command));
    272281    mr_free(command);
    273282
    274283    if (atoi(tmp) != 1) {
    275         log_it("Either too few or too many tape streamers for me to detect...");
     284        log_it
     285            ("Either too few or too many tape streamers for me to detect...");
    276286        strcpy(dev, VANILLA_SCSI_TAPE);
    277         mr_free(tmp);
    278         mr_free(cdr_exe);
    279287        return 1;
    280288    }
    281     mr_free(tmp);
    282 
    283     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' ' -f2 | head -n1", cdr_exe);
    284     mr_asprintf(tmp, "%s", all_program_and_get_last_line_of_output(command));
     289    mr_asprintf(command,
     290            "%s -scanbus 2> /dev/null | tr -s '\t' ' ' | grep \"[0-9]*,[0-9]*,[0-9]*\" | grep -v \"[0-9]*) \\*\" | grep -i TAPE | cut -d' ' -f2 | head -n1",
     291            cdr_exe);
     292    strcpy(tmp, call_program_and_get_last_line_of_output(command));
    285293    mr_free(command);
    286294
    287295    if (strlen(tmp) < 2) {
    288296        log_it("Could not find tape device");
    289         mr_free(cdr_exe);
    290         mr_free(tmp);
    291297        return 1;
    292298    }
    293     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);
    294     mr_free(cdr_exe);
    295 
    296     mr_asprintf(tmp, "%s", call_program_and_get_last_line_of_output(command));
     299    mr_asprintf(command,
     300            "%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",
     301            cdr_exe);
     302    strcpy(tmp, call_program_and_get_last_line_of_output(command));
    297303    mr_free(command);
    298304
     
    300306    dev[strlen(dev) - 1] = '\0';
    301307    strcat(dev, tmp);           // e.g. '/dev/st0' becomes '/dev/stN'
    302     mr_free(tmp);
    303 
    304308    res = 0;
    305309    if (!mt_says_tape_exists(dev)) {
     
    320324    }
    321325
    322     if (dev) {
    323         log_it("At this point, dev = %s and res = %d", dev, res);
    324     } else {
    325         log_it("At this point, dev is NULL and res = %d", dev, res);
    326     }
    327 
    328     mr_asprintf(tmp, "%s", call_program_and_get_last_line_of_output("cdrecord -scanbus 2> /dev/null | tr -s '\t' ' ' | grep \"[0-9]*,[0-9]*,[0-9]*\" | grep -v \"[0-9]*) \\*\" | grep -i TAPE | awk '{for(i=1; i<NF; i++) { if (index($i, \"GB\")>0) { print $i;};};};'"));
     326    log_it("At this point, dev = %s and res = %d", dev, res);
     327
     328    strcpy(tmp, call_program_and_get_last_line_of_output("\
     329cdrecord -scanbus 2> /dev/null | tr -s '\t' ' ' | \
     330grep \"[0-9]*,[0-9]*,[0-9]*\" | grep -v \"[0-9]*) \\*\" | grep -i TAPE | \
     331awk '{for(i=1; i<NF; i++) { if (index($i, \"GB\")>0) { print $i;};};};'"));
    329332
    330333    if (mt_says_tape_exists(dev)) {
     
    332335    } else {
    333336        log_it("Turning %s", dev);
    334         mr_free(tmp);
    335         mr_asprintf(tmp, "%s", (strrchr(dev, '/') != NULL) ? strrchr(dev, '/') : dev);
     337        strcpy(tmp, (strrchr(dev, '/') != NULL) ? strrchr(dev, '/') : dev);
    336338        sprintf(dev, "/dev/os%s", tmp);
    337339        log_it("...into %s", dev);
     
    353355        siz[0] = '\0';
    354356        log_it("Warning - size of tape unknown");
     357        return (0);
    355358    } else {
    356359        strcpy(siz, tmp);
    357     }
    358     mr_free(tmp);
    359     return (0);
    360 }
     360        return (0);
     361    }
     362}
     363
     364
     365
     366
    361367
    362368
     
    473479    log_it("Insisting on tape #%d", tapeno);
    474480    if (g_current_media_number != tapeno) {
    475         mr_asprintf(tmp, "When the tape drive goes quiet, please insert volume %d in this series.", tapeno);
     481        mr_asprintf(tmp,
     482                "When the tape drive goes quiet, please insert volume %d in this series.",
     483                tapeno);
    476484        popup_and_OK(tmp);
    477485        mr_free(tmp);
     
    606614    int res;
    607615
    608     if (bkpinfo->media_device == NULL) {
    609         return(1);
    610     }
    611 
    612616    if (strncmp(bkpinfo->media_device, "/dev/", 5)) {
    613         log_msg(1, "Not using 'mt setblk'. This isn't an actual /dev entry.");
     617        log_msg(1,
     618                "Not using 'mt setblk'. This isn't an actual /dev entry.");
    614619        return (0);
    615620    }
     
    682687    int res = 0;
    683688
    684     if (bkpinfo->media_device == NULL) {
    685         return(1);
    686     }
    687 
    688689    log_it("Skipping OBDR headers");
    689690    mr_asprintf(command, "mt -f %s rewind",bkpinfo->media_device);
     
    711712    char *command = NULL;
    712713    int res = 0;
    713 
    714     if (bkpinfo->media_device == NULL) {
    715         return(1);
    716     }
    717714
    718715    log_it("Creating OBDR headers");
     
    783780    /*@ end vars *************************************************** */
    784781
    785     g_tapecatalog = mr_malloc(sizeof(struct s_tapecatalog));
     782    assert_string_is_neither_NULL_nor_zerolength(bkpinfo->media_device);
     783    if (!(g_tapecatalog = malloc(sizeof(struct s_tapecatalog)))) {
     784        fatal_error("Cannot alloc mem for tape catalog");
     785    }
    786786    g_tapecatalog->entries = 0;
    787787    g_tape_posK = 0;
     
    800800        if (bkpinfo->media_device == NULL) {
    801801            log_it("Not able to skip OBDR - Restore will have to be done manually");
    802             return (1);
    803802        }
    804803        set_tape_block_size_with_mt(bkpinfo->internal_tape_block_size);
     
    809808    make_hole_for_file(outfname);
    810809
     810//  start_buffer_process( bkpinfo->media_device, g_tape_fifo, FALSE);
    811811    log_it("Opening IN tape");
    812     if (!(g_tape_stream = open_device_via_buffer(bkpinfo->media_device, 'r', bkpinfo->internal_tape_block_size))) {
     812    if (!
     813        (g_tape_stream =
     814         open_device_via_buffer(bkpinfo->media_device, 'r',
     815                                bkpinfo->internal_tape_block_size))) {
    813816        log_OS_error(g_tape_fifo);
    814817        log_to_screen("Cannot openin stream device");
     
    818821    log_to_screen("Reading stream");
    819822    log_it("stream device = '%s'", bkpinfo->media_device);
    820     /* skip data disks */
     823/* skip data disks */
    821824    open_evalcall_form("Skipping data disks on stream");
    822825    log_to_screen("Skipping data disks on stream");
     
    871874        // FIXME
    872875    }
    873     mr_asprintf(tmp, "tar -zxf %s ./tmp/mondo-restore.cfg 2> /dev/null", outfname);
     876    mr_asprintf(tmp, "tar -zxf %s ./tmp/mondo-restore.cfg 2> /dev/null",
     877            outfname);
    874878    paranoid_system(tmp);
    875879    mr_free(tmp);
     
    899903    /*@ end vars *************************************************** */
    900904
    901     if (cddev == NULL) {
    902         log_to_screen("Failed to openout NULL cddev");
    903         return (1);
    904     }
    905905    /*  add 'dummy' if testing */
    906906    mr_asprintf(command, "cdrecord -eject dev=%s speed=%d fs=24m -waiti - >> %s 2>> %s", cddev, speed, MONDO_LOGFILE, MONDO_LOGFILE);
     
    942942    return (0);
    943943}
    944 if (bkpinfo->media_device == NULL) {
    945     log_it("Unable to openout NULL device");
    946     return(1);
    947 }
    948 g_tapecatalog = mr_malloc(sizeof(struct s_tapecatalog));
     944if (!(g_tapecatalog = malloc(sizeof(struct s_tapecatalog)))) {
     945    fatal_error("Cannot alloc mem for tape catalog");
     946}
    949947g_tapecatalog->entries = 0;
    950948g_tape_posK = 0;
     
    956954}
    957955log_it("Opening OUT tape");
    958 if (!(g_tape_stream = open_device_via_buffer(bkpinfo->media_device, 'w', bkpinfo->internal_tape_block_size))) {
     956if (!
     957    (g_tape_stream =
     958     open_device_via_buffer(bkpinfo->media_device, 'w', bkpinfo->internal_tape_block_size))) {
    959959    log_OS_error(g_tape_fifo);
    960960    log_to_screen("Cannot openin stream device");
     
    969969/**
    970970 * Copy a file from the opened stream (CD or tape) to @p outfile.
     971 * @param bkpinfo The backup information structure. @c bkpinfo->media_device is the only field used.
    971972 * @param outfile The file to write to.
    972973 * @param size The size of the file in the input stream.
     
    10301031{
    10311032    /*@ buffers ***************************************************** */
     1033    char *tmp = NULL;
    10321034    char *datablock;
    10331035    char *temp_fname;
    10341036    char *temp_cksum;
    10351037    char *actual_cksum = NULL;
     1038//  char *pA, *pB;
    10361039
    10371040    /*@ int ********************************************************* */
     
    10751078    }
    10761079    if (orig_size != temp_size && orig_size != -1) {
    1077         log_to_screen("output file's size should be %ld K but is apparently %ld K", (long) size >> 10, (long) temp_size >> 10);
     1080        mr_asprintf(tmp, "output file's size should be %ld K but is apparently %ld K", (long) size >> 10, (long) temp_size >> 10);
     1081        log_to_screen(tmp);
     1082        mr_free(tmp);
    10781083    }
    10791084    if (ctrl_chr != BLK_START_FILE) {
     
    11461151    }
    11471152    if (strcmp(temp_cksum, actual_cksum)) {
    1148         log_to_screen("actual cksum=%s; recorded cksum=%s", actual_cksum, temp_cksum);
    1149         log_to_screen("%s (%ld K) is corrupt on tape", temp_fname, (long) orig_size >> 10);
     1153        mr_asprintf(tmp, "actual cksum=%s; recorded cksum=%s", actual_cksum,
     1154                temp_cksum);
     1155        log_to_screen(tmp);
     1156        mr_free(tmp);
     1157
     1158        mr_asprintf(tmp, "%s (%ld K) is corrupt on tape", temp_fname,
     1159                (long) orig_size >> 10);
     1160        log_to_screen(tmp);
     1161        mr_free(tmp);
     1162
    11501163        retval++;
    11511164    }
     
    11911204        g_tape_posK += fread(tempblock, 1, (size_t) TAPE_BLOCK_SIZE, g_tape_stream) / 1024;
    11921205    }
     1206/*  memcpy((char*)plength_of_incoming_file,(char*)tempblock+7001,sizeof(long long)); */
     1207/*  for(*plen=0,i=7;i>=0;i--) {*plen<<=8; *plen |= tempblock[7001+i];} */
    11931208    memcpy((char *) plen, tempblock + 7001, sizeof(long long));
    11941209    if (strcmp(tempblock + 6000 + *pcontrol_char, STR_HEADER)) {
     
    11961211    }
    11971212    strcpy(filename, tempblock + 1000);
     1213/*  strcpy(cksum,tempblock+5555);*/
     1214/*  log_it( "%s  (reading) fname=%s, filesize=%ld K",
     1215       marker_to_string (*pcontrol_char), filename,
     1216       (long) ((*plen) >> 10));
     1217*/
    11981218    if (*pcontrol_char == BLK_ABORTED_BACKUP) {
    11991219        log_to_screen("I can't verify an aborted backup.");
     
    13431363    while (ctrl_chr != BLK_START_FILE) {
    13441364        res = read_header_block_from_stream(&temp_size, temp_fname, &ctrl_chr);
    1345         if (res) {
    1346             //FIXME
    1347         }
    13481365        if (ctrl_chr == BLK_START_FILE) {
    13491366            break;
     
    13661383    }
    13671384    while (strcmp(pA, pB)) {
    1368         log_msg(6, "Skipping %s (it's not %s)", temp_fname, the_file_I_was_reading);
     1385        log_msg(6, "Skipping %s (it's not %s)", temp_fname,
     1386                the_file_I_was_reading);
    13691387        for (size = temp_size; size > 0; size -= bytes_to_write) {
    13701388            bytes_to_write =
     
    14031421        }
    14041422    }
    1405     log_msg(2, "Reading %s (it matches %s)", temp_fname, the_file_I_was_reading);
     1423    log_msg(2, "Reading %s (it matches %s)", temp_fname,
     1424            the_file_I_was_reading);
    14061425    paranoid_free(temp_fname);
    14071426    paranoid_free(datablock);
     
    14251444    /*@ end vars *************************************************** */
    14261445
    1427     if (bkpinfo->media_device == NULL) {
    1428         log_it("Unable to open in from NULL device");
    1429         return (1);
    1430     }
    1431 
    14321446    paranoid_pclose(g_tape_stream);
    14331447    sync();
     
    14371451    insist_on_this_tape_number(g_current_media_number + 1); // will increment it, too
    14381452    log_it("Opening IN the next tape");
    1439     if (!(g_tape_stream = open_device_via_buffer(bkpinfo->media_device, 'r', bkpinfo->internal_tape_block_size))) {
     1453    if (!
     1454        (g_tape_stream =
     1455         open_device_via_buffer(bkpinfo->media_device, 'r',
     1456                                bkpinfo->internal_tape_block_size))) {
    14401457        log_OS_error(g_tape_fifo);
    14411458        log_to_screen("Cannot openin stream device");
     
    14701487    char *command = NULL;
    14711488
    1472     if (bkpinfo->media_device == NULL) {
    1473         log_it("Unable to open out from NULL device");
    1474         return (1);
    1475     }
    1476 
    14771489    paranoid_pclose(g_tape_stream);
    1478     sync();
    1479     sync();
    1480     sync();
     1490    paranoid_system("sync");
     1491    paranoid_system("sync");
     1492    paranoid_system("sync");
    14811493    log_it("New tape requested.");
    14821494    insist_on_this_tape_number(g_current_media_number + 1); // will increment g_current_media, too
    14831495    if (bkpinfo->backup_media_type == cdstream) {
    1484         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);
     1496        mr_asprintf(command,
     1497                "cdrecord -eject dev=%s speed=%d fs=24m -waiti - >> %s 2>> %s",
     1498                bkpinfo->media_device, bkpinfo->cdrw_speed, MONDO_LOGFILE,
     1499                MONDO_LOGFILE);
    14851500        log_it("Opening OUT to next CD with the command");
    14861501        log_it(command);
     
    14951510    } else {
    14961511        log_it("Opening OUT to next tape");
    1497         if (!(g_tape_stream = open_device_via_buffer(bkpinfo->media_device, 'w', bkpinfo->internal_tape_block_size))) {
     1512        if (!
     1513            (g_tape_stream =
     1514             open_device_via_buffer(bkpinfo->media_device, 'w',
     1515                                    bkpinfo->internal_tape_block_size))) {
    14981516            log_OS_error(g_tape_fifo);
    14991517            log_to_screen("Cannot openin stream device");
     
    15661584    /*@ pointers *************************************************** */
    15671585    FILE *fin;
     1586    char *tmp = NULL;
    15681587
    15691588    /*@ long ******************************************************* */
     
    15831602    log_it("Data disks = %s", fname);
    15841603    if (!does_file_exist(fname)) {
    1585         log_to_screen("Cannot find %s", fname);
     1604        mr_asprintf(tmp, "Cannot find %s", fname);
     1605        log_to_screen(tmp);
     1606        mr_free(tmp);
    15861607        return (1);
    15871608    }
     
    16261647{
    16271648    /*@ buffers **************************************************** */
     1649    char *tmp = NULL;
    16281650    char datablock[TAPE_BLOCK_SIZE];
    16291651    char *checksum = NULL;
     
    16781700        p++;
    16791701    }
    1680     log_it("Writing file '%s' to tape (%ld KB)", p, (long) filesize >> 10);
     1702    mr_asprintf(tmp, "Writing file '%s' to tape (%ld KB)", p,
     1703            (long) filesize >> 10);
     1704    log_it(tmp);
     1705    mr_free(tmp);
    16811706    write_header_block_to_stream(filesize, infile_basename,
    16821707                                 BLK_START_FILE);
     
    17501775    /*@ buffers **************************************************** */
    17511776    char tempblock[TAPE_BLOCK_SIZE];
     1777    char *tmp = NULL;
    17521778    char *p;
    17531779
     
    17681794    }
    17691795    if (!g_tape_stream) {
    1770         log_to_screen("You're not backing up to tape. Why write a tape header?");
     1796        log_to_screen
     1797            ("You're not backing up to tape. Why write a tape header?");
    17711798        return (1);
    17721799    }
     
    17781805    memcpy(tempblock + 7001, (char *) &olen, sizeof(off_t));
    17791806    strcpy(tempblock + 1000, filename);
    1780     g_tape_posK += fwrite(tempblock, 1, (size_t) TAPE_BLOCK_SIZE, g_tape_stream) / 1024;
    1781     log_msg(6, "%s (fname=%s, size=%ld K)", marker_to_string(control_char), p, (long) length_of_incoming_file >> 10);
     1807    g_tape_posK +=
     1808        fwrite(tempblock, 1, (size_t) TAPE_BLOCK_SIZE,
     1809               g_tape_stream) / 1024;
     1810    mr_asprintf(tmp, "%s (fname=%s, size=%ld K)",
     1811            marker_to_string(control_char), p,
     1812            (long) length_of_incoming_file >> 10);
     1813    log_msg(6, tmp);
     1814    mr_free(tmp);
    17821815    return (0);
    17831816}
     
    17991832void wrong_marker(int should_be, int it_is)
    18001833{
    1801     log_to_screen("Wrong marker! (Should be %s, is actually %s)", marker_to_string(should_be), marker_to_string(it_is));
     1834    /*@ buffer ***************************************************** */
     1835    char *tmp = NULL;
     1836
     1837
     1838    /*@ end vars *************************************************** */
     1839    mr_asprintf(tmp, "Wrong marker! (Should be %s, is actually %s)", marker_to_string(should_be), marker_to_string(it_is));
     1840    log_to_screen(tmp);
     1841    mr_free(tmp);
    18021842}
    18031843
  • branches/3.0/mondo/src/common/libmondo-string.c

    r3188 r3192  
    5151    if (c && strncmp(c, "/disc", 5) == 0) {
    5252        /* yup it's devfs, return the "part" path */
    53         /* This strcpy is safe */
    5453        strcpy(c + 1, "part");
    5554        p = c + 5;
     
    6665    }
    6766    sprintf(p, "%d", partno);
    68     return(partition);
    69 }
     67    return (partition);
     68}
     69
     70
     71
     72
     73
     74
     75
     76
     77
     78
     79
    7080
    7181
     
    108118
    109119
     120
     121
     122inline void turn_wildcard_chars_into_literal_chars(char *sout, char *sin)
     123{
     124    char *p, *q;
     125
     126    for (p = sin, q = sout; *p != '\0'; *(q++) = *(p++)) {
     127        if (strchr("[]*?", *p)) {
     128            *(q++) = '\\';
     129        }
     130    }
     131    *q = *p;                    // for the final '\0'
     132}
     133
     134
     135
    110136/**
    111137 * Add commas every third place in @p input.
     
    129155        tmp[j - 6] = ',';
    130156        strcpy(tmp + j - 5, pos_w_commas + j - 6);
     157//      tmp[j-2] = ',';
     158//      strcpy(tmp+j-1, pos_w_commas+j-3);
    131159        strcpy(pos_w_commas, tmp);
    132160    }
     
    142170    return (output);
    143171}
     172
     173
     174
     175
     176
     177
     178
    144179
    145180
     
    182217    long outval;
    183218    int i;
    184     char *tmp = NULL;
     219    char *tmp;
    185220    char ch;
    186221
     
    193228        fatal_error("Please use integers only. No decimal points.");
    194229    }
    195 
    196     mr_asprintf(tmp, "%s", incoming);
     230    malloc_string(tmp);
     231    strcpy(tmp, incoming);
    197232    i = (int) strlen(tmp);
    198233    if (tmp[i - 1] == 'B' || tmp[i - 1] == 'b') {
     
    203238    tmp[i] = '\0';
    204239    outval = atol(tmp);
    205     mr_free(tmp);
    206 
    207240    if (ch == 'g' || ch == 'G') {
    208241        outval = outval * 1024;
     
    220253        fatal_error("Integer overflow.");
    221254    } else if (ch != 'm' && ch != 'M') {
    222         mr_asprintf(tmp, "Re: parameter '%s' - bad multiplier ('%c')", incoming, ch);
     255        sprintf(tmp, "Re: parameter '%s' - bad multiplier ('%c')",
     256                incoming, ch);
    223257        fatal_error(tmp);
    224258    }
     259    paranoid_free(tmp);
    225260    return (outval);
    226261}
     
    481516
    482517    input = malloc(2000);
     518    // BERLIOS: seems to cause invalid errors
     519    //assert_string_is_neither_NULL_nor_zerolength(ip);
     520    assert_string_is_neither_NULL_nor_zerolength(token);
    483521    assert(value != NULL);
    484522
     
    519557    /*@ buffers **************************************************** */
    520558    static char output[MAX_STR_LEN];
    521     char *suffix = NULL;
     559    static char suffix[MAX_STR_LEN];
    522560
    523561    /*@ end vars *************************************************** */
     
    525563    assert_string_is_neither_NULL_nor_zerolength(path);
    526564    if (s[0] != '\0') {
    527         mr_asprintf(suffix, ".%s", s);
     565        sprintf(suffix, ".%s", s);
    528566    } else {
    529         mr_asprintf(suffix, "");
    530     }
    531     sprintf(output, "%s/slice-%07ld.%05ld.dat%s", path, bigfileno, sliceno, suffix);
    532     mr_free(suffix);
     567        suffix[0] = '\0';
     568    }
     569    sprintf(output, "%s/slice-%07ld.%05ld.dat%s", path, bigfileno, sliceno,
     570            suffix);
    533571    return (output);
    534572}
     
    608646    numA = atol(stringA + start_of_numbers_in_A);
    609647    numB = atol(stringB + start_of_numbers_in_B);
     648    /*
     649       sprintf(tmp,"Comparing %s and %s --> %ld,%ld\n",stringA,stringB,numA,numB);
     650       log_to_screen(tmp);
     651     */
    610652    return ((int) (numA - numB));
    611653}
     
    733775    in_out[i] = '\0';
    734776    paranoid_free(tmp);
     777/*  for(i=strlen(in_out); i>0 && in_out[i-1]<=32; i--) {in_out[i-1]='\0';} */
    735778}
    736779
     
    866909 * @return The severity (1-3).
    867910 */
    868 int severity_of_difference(char *fn, char *out_reason) {
    869 
    870     int sev = 3;
    871     char *reason = NULL;
    872     char *filename = NULL;
    873 
    874     // out_reason might be null on purpose, so don't bomb if it is :) OK?
     911int severity_of_difference(char *fn, char *out_reason)
     912{
     913    int sev;
     914    char *reason;
     915    char *filename;
     916
     917    malloc_string(reason);
     918    malloc_string(filename);
     919// out_reason might be null on purpose, so don't bomb if it is :) OK?
    875920    assert_string_is_neither_NULL_nor_zerolength(fn);
    876921    if (!strncmp(fn, MNT_RESTORING, strlen(MNT_RESTORING))) {
    877         mr_asprintf(filename, "%s", fn + strlen(MNT_RESTORING));
     922        strcpy(filename, fn + strlen(MNT_RESTORING));
    878923    } else if (fn[0] != '/') {
    879         mr_asprintf(filename, "/%s", fn);
     924        sprintf(filename, "/%s", fn);
    880925    } else {
    881         mr_asprintf(filename, "%s", fn);
    882     }
    883 
    884     mr_asprintf(reason, "Changed since backup. Consider running a differential backup in a day or two.");
    885 
     926        strcpy(filename, fn);
     927    }
     928
     929    sev = 3;
     930    sprintf(reason,
     931            "Changed since backup. Consider running a differential backup in a day or two.");
    886932    if (!strncmp(filename, "/var/", 5)) {
    887933        sev = 2;
    888         mr_free(reason);
    889         mr_asprintf(reason, "/var's contents will change regularly, inevitably.");
     934        sprintf(reason,
     935                "/var's contents will change regularly, inevitably.");
    890936    }
    891937    if (!strncmp(filename, "/home", 5)) {
    892938        sev = 2;
    893         mr_free(reason);
    894         mr_asprintf(reason, "It's in your /home directory. Therefore, it is important.");
     939        sprintf(reason,
     940                "It's in your /home directory. Therefore, it is important.");
    895941    }
    896942    if (!strncmp(filename, "/usr/", 5)) {
    897943        sev = 3;
    898         mr_free(reason);
    899         mr_asprintf(reason, "You may have installed/removed software during the backup.");
     944        sprintf(reason,
     945                "You may have installed/removed software during the backup.");
    900946    }
    901947    if (!strncmp(filename, "/etc/", 5)) {
    902948        sev = 3;
    903         mr_free(reason);
    904         mr_asprintf(reason, "Do not edit config files while backing up your PC.");
     949        sprintf(reason,
     950                "Do not edit config files while backing up your PC.");
    905951    }
    906952    if (!strcmp(filename, "/etc/adjtime")
    907953        || !strcmp(filename, "/etc/mtab")) {
    908954        sev = 1;
    909         mr_free(reason);
    910         mr_asprintf(reason, "This file changes all the time. It's OK.");
     955        sprintf(reason, "This file changes all the time. It's OK.");
    911956    }
    912957    if (!strncmp(filename, "/root/", 6)) {
    913958        sev = 3;
    914         mr_free(reason);
    915         mr_asprintf(reason, "Were you compiling/editing something in /root?");
     959        sprintf(reason, "Were you compiling/editing something in /root?");
    916960    }
    917961    if (!strncmp(filename, "/root/.", 7)) {
    918962        sev = 2;
    919         mr_free(reason);
    920         mr_asprintf(reason, "Temp or 'dot' files changed in /root.");
     963        sprintf(reason, "Temp or 'dot' files changed in /root.");
    921964    }
    922965    if (!strncmp(filename, "/var/lib/", 9)) {
    923966        sev = 2;
    924         mr_free(reason);
    925         mr_asprintf(reason, "Did you add/remove software during backing?");
     967        sprintf(reason, "Did you add/remove software during backing?");
    926968    }
    927969    if (!strncmp(filename, "/var/lib/rpm", 12)) {
    928970        sev = 3;
    929         mr_free(reason);
    930         mr_asprintf(reason, "Did you add/remove software during backing?");
     971        sprintf(reason, "Did you add/remove software during backing?");
    931972    }
    932973    if (!strncmp(filename, "/var/lib/slocate", 16)) {
    933974        sev = 1;
    934         mr_free(reason);
    935         mr_asprintf(reason, "The 'update' daemon ran during backup. This does not affect the integrity of your backup.");
     975        sprintf(reason,
     976                "The 'update' daemon ran during backup. This does not affect the integrity of your backup.");
    936977    }
    937978    if (!strncmp(filename, "/var/log/", 9)
     
    939980        || !strcmp(filename + strlen(filename) - 4, ".log")) {
    940981        sev = 1;
    941         mr_free(reason);
    942         mr_asprintf(reason, "Log files change frequently as the computer runs. Fret not.");
     982        sprintf(reason,
     983                "Log files change frequently as the computer runs. Fret not.");
    943984    }
    944985    if (!strncmp(filename, "/var/spool", 10)) {
    945986        sev = 1;
    946         mr_free(reason);
    947         mr_asprintf(reason, "Background processes or printers were active. This does not affect the integrity of your backup.");
     987        sprintf(reason,
     988                "Background processes or printers were active. This does not affect the integrity of your backup.");
    948989    }
    949990    if (!strncmp(filename, "/var/spool/mail", 10)) {
    950991        sev = 2;
    951         mr_free(reason);
    952         mr_asprintf(reason, "Mail was sent/received during backup.");
     992        sprintf(reason, "Mail was sent/received during backup.");
    953993    }
    954994    if (filename[strlen(filename) - 1] == '~') {
    955995        sev = 1;
    956         mr_free(reason);
    957         mr_asprintf(reason, "Backup copy of another file which was modified recently.");
     996        sprintf(reason,
     997                "Backup copy of another file which was modified recently.");
    958998    }
    959999    if (strstr(filename, "cache")) {
    9601000        sev = 1;
    961         mr_free(reason);
    962         mr_asprintf(reason, "Part of a cache of data. Caches change from time to time. Don't worry.");
     1001        sprintf(reason,
     1002                "Part of a cache of data. Caches change from time to time. Don't worry.");
    9631003    }
    9641004    if (!strncmp(filename, "/var/run/", 9)
     
    9671007        || strstr(filename, "/.Xauthority")) {
    9681008        sev = 1;
    969         mr_free(reason);
    970         mr_asprintf(reason, "Temporary file (a lockfile, perhaps) used by software such as X or KDE to register its presence.");
     1009        sprintf(reason,
     1010                "Temporary file (a lockfile, perhaps) used by software such as X or KDE to register its presence.");
    9711011    }
    9721012    if (out_reason) {
    9731013        strcpy(out_reason, reason);
    9741014    }
    975     mr_free(filename);
    976     mr_free(reason);
     1015    paranoid_free(filename);
     1016    paranoid_free(reason);
    9771017    return (sev);
    9781018}
     
    10241064    /*@ buffers ******************************************* */
    10251065    static char outstr[MAX_STR_LEN];
    1026     char *pos_w_commas = NULL;
     1066    char *pos_w_commas, *tmp;
    10271067    char *mds = NULL;
    1028     char *tmp = NULL;
    10291068
    10301069    assert(bkpinfo != NULL);
    1031 
    1032     if (bkpinfo->media_size <= 0) {
    1033         mr_asprintf(tmp, "%lld", g_tape_posK);
    1034         mr_asprintf(pos_w_commas, "%s", commarize(tmp));
    1035         mr_free(tmp);
    1036         sprintf(outstr, "Volume %d: %s kilobytes archived so far", g_current_media_number, pos_w_commas);
    1037         mr_free(pos_w_commas);
     1070    malloc_string(pos_w_commas);
     1071    malloc_string(tmp);
     1072    sprintf(tmp, "%lld", g_tape_posK);
     1073    strcpy(pos_w_commas, commarize(tmp));
     1074
     1075
     1076
     1077    if (bkpinfo->media_size <= 0)
     1078//    { fatal_error( "percentage_media_full_comment() - unknown media size"); }
     1079    {
     1080        sprintf(outstr, "Volume %d: %s kilobytes archived so far",
     1081                g_current_media_number, pos_w_commas);
    10381082        return (outstr);
    10391083    }
    10401084
    1041     /* update screen */
     1085/* update screen */
    10421086    if (IS_THIS_A_STREAMING_BACKUP(bkpinfo->backup_media_type)) {
    10431087        percentage = (int) (g_tape_posK / 10 / bkpinfo->media_size);
     
    10471091        sprintf(outstr, "Volume %d: [", g_current_media_number);
    10481092    } else {
    1049         percentage = (int) (space_occupied_by_cd(bkpinfo->scratchdir) * 100 / 1024 / bkpinfo->media_size);
     1093        percentage =
     1094            (int) (space_occupied_by_cd(bkpinfo->scratchdir) * 100 / 1024 / bkpinfo->media_size);
    10501095        mds = media_descriptor_string(bkpinfo->backup_media_type);
    10511096        sprintf(outstr, "%s %d: [", mds, g_current_media_number);
     
    10601105    j = (int) strlen(outstr);
    10611106    sprintf(outstr + j, "] %d%% used", percentage);
     1107    paranoid_free(pos_w_commas);
     1108    paranoid_free(tmp);
    10621109    return (outstr);
    10631110}
  • branches/3.0/mondo/src/common/libmondo-tools.c

    r3188 r3192  
    3030
    3131extern int g_tape_buffer_size_MB;
     32extern char *g_serial_string;
    3233extern bool g_text_mode;
    3334extern int g_currentY;
    3435extern int g_current_media_number;
    3536extern char *MONDO_LOGFILE;
    36 extern char *g_serial_string;
    3737
    3838/* Reference to global bkpinfo */
     
    113113        return;
    114114    }
     115#ifndef _XWIN
    115116    if (!g_text_mode)
    116117        newtSuspend();
     118#endif
    117119    printf("ASSERTION FAILED: `%s'\n", exp);
    118120    printf("\tat %s:%d in %s\n\n", file, line, function);
     
    161163    getchar();                  // skip \n
    162164
     165#ifndef _XWIN
    163166    if (!g_text_mode)
    164167        newtResume();
     168#endif
    165169}
    166170
     
    171175void clean_up_KDE_desktop_if_necessary(void)
    172176{
    173     char *tmp = NULL;
    174 
    175     mr_asprintf(tmp, "for i in `find /root /home -maxdepth 2 -type d -name Desktop -maxdepth 2`; do file=$i/.directory; if [ -f \"$file\" ] ; then mv -f $file $file.old ; awk '{if (index($0, \"rootimagesmindi\")) { while (length($0)>2) { getline;} ; } else { print $0;};}' $file.old  > $file ; fi ; done");
     177    char *tmp;
     178
     179    malloc_string(tmp);
     180    strcpy(tmp,
     181           "for i in `find /root /home -maxdepth 2 -type d -name Desktop`; do \
     182file=$i/.directory; if [ -f \"$file\" ] ; then mv -f $file $file.old ; \
     183awk '{if (index($0, \"rootimagesmindi\")) { while (length($0)>2) { getline;} ; } \
     184else { print $0;};}' $file.old  > $file ; fi ; done");
    176185    run_program_and_log_output(tmp, 5);
    177     mr_free(tmp);
     186    paranoid_free(tmp);
    178187}
    179188
     
    223232double get_kernel_version(void)
    224233{
    225     char *p = NULL;
    226     char *tmp = NULL;
     234    char *p, tmp[200];
    227235    double d;
    228236#ifdef __FreeBSD__
     
    230238    d = 5.2;                    // :-)
    231239#else
    232     mr_asprintf(tmp, "%s", call_program_and_get_last_line_of_output("uname -r"));
     240    strcpy(tmp, call_program_and_get_last_line_of_output("uname -r"));
    233241    p = strchr(tmp, '.');
    234242    if (p) {
     
    241249        }
    242250    }
     251//  log_msg(1, "tmp = '%s'", tmp);
    243252    d = atof(tmp);
    244     mr_free(tmp);
    245253#endif
    246254    log_msg(1, "g_kernel_version = %f", d);
     
    249257
    250258
     259
     260
     261
    251262/**
    252263 * Get the current time.
     
    257268    return (long) time((void *) 0);
    258269}
     270
     271
     272
     273
     274
    259275
    260276
     
    352368    char *mondo_mkisofs_sz = NULL;
    353369    char *command = NULL;
    354     char *hostname = NULL;
     370    char *mtpt;
     371    char *hostname;
    355372    char *isofs_cmd = NULL;
    356373    char *ip_address = NULL;
    357374    int retval = 0;
    358375    char *colon;
    359     char *cdr_exe = NULL;
     376    char *cdr_exe;
    360377    char *tmp = NULL;
    361     char *p = NULL;
    362     char *call_before_iso_user = NULL;
     378    char call_before_iso_user[MAX_STR_LEN] = "\0";
     379    /*
     380    long avm = 0;
     381    int rdsiz_MB;
     382    */
    363383    char *iso_dev = NULL;
    364384    char *iso_mnt = NULL;
     
    367387
    368388    assert(bkpinfo != NULL);
    369 
     389    malloc_string(mtpt);
     390    malloc_string(hostname);
     391    malloc_string(cdr_exe);
    370392    bkpinfo->optimal_set_size =
    371393        (IS_THIS_A_STREAMING_BACKUP(bkpinfo->backup_media_type) ? 16 : 16) *
     
    378400        }
    379401        log_msg(1, "Tape");
    380         if (bkpinfo->media_device == NULL) {
    381             return(1);
    382         }
    383402        mr_asprintf(tmp, "mt -f %s status", bkpinfo->media_device);
    384403        log_msg(1, "tmp = '%s'", tmp);
     
    410429        strcpy(bkpinfo->zip_exe, "gzip");
    411430        strcpy(bkpinfo->zip_suffix, "gz");
    412     } else if (bkpinfo->use_lzma) {
    413         strcpy(bkpinfo->zip_exe, "lzma");
    414         strcpy(bkpinfo->zip_suffix, "lzma");
    415431    } else if (bkpinfo->compression_level != 0) {
    416432        strcpy(bkpinfo->zip_exe, "bzip2");
     
    424440    if (bkpinfo->backup_media_type == dvd) {
    425441        if (find_home_of_exe("growisofs")) {
    426             mr_asprintf(cdr_exe, "growisofs");
     442            strcpy(cdr_exe, "growisofs");
    427443        }                       // unlikely to be used
    428444        else {
     
    446462    }
    447463#endif
    448         else {
     464        else
     465        {
    449466            mr_asprintf(mondo_mkisofs_sz, MONDO_GROWISOFS_REGULAR_SYSLINUX);
    450467        }
    451468        if (bkpinfo->manual_cd_tray) {
     469            paranoid_free(mondo_mkisofs_sz);
    452470            fatal_error("Manual CD tray + DVD not supported yet.");
    453471            // -m isn't supported by growisofs, BTW...
     
    457475                    mondo_mkisofs_sz,
    458476                    "", bkpinfo->media_device);
    459         }
    460         mr_free(mondo_mkisofs_sz);
     477            paranoid_free(mondo_mkisofs_sz);
     478        }
    461479        if (getenv ("SUDO_COMMAND")) {
    462480            mr_asprintf(command, "strings `which growisofs` | grep -c SUDO_COMMAND");
     
    468486            mr_free(command);
    469487        }
    470         log_msg(2, "call_make_iso (DVD res) is ... %s", bkpinfo->call_make_iso);
     488        log_msg(2, "call_make_iso (DVD res) is ... %s",
     489                bkpinfo->call_make_iso);
    471490    }                           // end of DVD code
    472491
     
    485504        }
    486505        if (find_home_of_exe("cdrecord")) {
    487             mr_asprintf(cdr_exe, "cdrecord");
     506            strcpy(cdr_exe, "cdrecord");
    488507        } else if (find_home_of_exe("dvdrecord")) {
    489             mr_asprintf(cdr_exe, "dvdrecord");
     508            strcpy(cdr_exe, "dvdrecord");
    490509        } else {
    491510            fatal_error("Please install either cdrecord or dvdrecord.");
     
    525544                        mondo_mkisofs_sz, bkpinfo->tmpdir);
    526545                } else {
    527                 mr_asprintf(call_before_iso_user, "%s", bkpinfo->call_before_iso);
    528                 sprintf(bkpinfo->call_before_iso, "( %s -o %s/"MONDO_TMPISOS" . 2>> _ERR_ ; %s )", mondo_mkisofs_sz, bkpinfo->tmpdir, call_before_iso_user);
    529                 mr_free(call_before_iso_user);
     546                strncpy(call_before_iso_user, bkpinfo->call_before_iso, MAX_STR_LEN);
     547                sprintf (bkpinfo->call_before_iso,
     548                                    "( %s -o %s/"MONDO_TMPISOS" . 2>> _ERR_ ; %s )",
     549                        mondo_mkisofs_sz, bkpinfo->tmpdir, call_before_iso_user);
    530550            }
    531551            log_it("bkpinfo->call_before_iso = %s", bkpinfo->call_before_iso);
    532             sprintf(bkpinfo->call_make_iso, "%s %s -v %s fs=4m dev=%s speed=%d %s/"MONDO_TMPISOS, cdr_exe, (bkpinfo->please_dont_eject) ? " " : "-eject", extra_cdrom_params, bkpinfo->media_device, bkpinfo->cdrw_speed, bkpinfo->tmpdir);
     552            sprintf(bkpinfo->call_make_iso,
     553                    "%s %s -v %s fs=4m dev=%s speed=%d %s/"MONDO_TMPISOS,
     554                    cdr_exe, (bkpinfo->please_dont_eject) ? " " : "-eject",
     555                    extra_cdrom_params, bkpinfo->media_device,
     556                    bkpinfo->cdrw_speed, bkpinfo->tmpdir);
    533557        } else {
    534             sprintf(bkpinfo->call_make_iso, "%s . 2>> _ERR_ | %s %s %s fs=4m dev=%s speed=%d -", mondo_mkisofs_sz, cdr_exe, (bkpinfo->please_dont_eject) ? " " : "-eject", extra_cdrom_params, bkpinfo->media_device, bkpinfo->cdrw_speed);
    535         }
    536         mr_free(cdr_exe);
    537         mr_free(mondo_mkisofs_sz);
    538         mr_free(extra_cdrom_params);
     558            sprintf(bkpinfo->call_make_iso,
     559                    "%s . 2>> _ERR_ | %s %s %s fs=4m dev=%s speed=%d -",
     560                    mondo_mkisofs_sz, cdr_exe,
     561                    (bkpinfo->please_dont_eject) ? " " : "-eject",
     562                    extra_cdrom_params, bkpinfo->media_device,
     563                    bkpinfo->cdrw_speed);
     564        }
     565        paranoid_free(mondo_mkisofs_sz);
     566        paranoid_free(extra_cdrom_params);
    539567    }                           // end of CD code
    540568
     
    549577
    550578        log_it("isodir = %s", bkpinfo->isodir);
    551         mr_asprintf(command, "df -P %s | tail -n1 | cut -d' ' -f1", bkpinfo->isodir);
     579        mr_asprintf(command, "df -P %s | tail -n1 | cut -d' ' -f1",
     580                bkpinfo->isodir);
    552581        log_it("command = %s", command);
     582        log_it("res of it = %s", call_program_and_get_last_line_of_output(command));
    553583        mr_asprintf(iso_dev, "%s", call_program_and_get_last_line_of_output(command));
    554         log_it("res of it = %s", iso_dev);
    555584        mr_asprintf(tmp, "%s/ISO-DEV", bkpinfo->tmpdir);
    556         write_one_liner_data_file(tmp, iso_dev);
     585        write_one_liner_data_file(tmp, call_program_and_get_last_line_of_output(command));
    557586        mr_free(tmp);
    558587        mr_free(command);
     
    562591
    563592        log_it("command = %s", command);
     593        log_it("res of it = %s", call_program_and_get_last_line_of_output(command));
    564594        mr_asprintf(iso_mnt, "%s", call_program_and_get_last_line_of_output(command));
    565         log_it("res of it = %s", iso_mnt);
    566595        mr_asprintf(tmp, "%s/ISO-MNT", bkpinfo->tmpdir);
    567         write_one_liner_data_file(tmp, iso_mnt);
     596        write_one_liner_data_file(tmp, call_program_and_get_last_line_of_output(command));
    568597        mr_free(tmp);
    569598        mr_free(command);
     
    583612            }
    584613        }
     614        mr_free(iso_tmp);
    585615        mr_free(iso_mnt);
    586         mr_free(iso_tmp);
    587616
    588617        mr_asprintf(tmp, "%s/ISODIR", bkpinfo->tmpdir);
     
    603632
    604633    if (bkpinfo->backup_media_type == netfs) {
    605         if (bkpinfo->netfs_mount) {
    606             mr_asprintf(hostname, "%s", bkpinfo->netfs_mount);
    607         } else {
    608             log_it("netfs_mount is NULL");
    609             retval++;
    610             mr_asprintf(hostname, "");
    611         }
     634        strcpy(hostname, bkpinfo->netfs_mount);
    612635        colon = strchr(hostname, ':');
    613636        if (!colon) {
     
    628651            }
    629652            if (!hent) {
    630                 log_it("Can't resolve Network mount (%s): %s", hostname, hstrerror(h_errno));
     653                log_it("Can't resolve Network mount (%s): %s", hostname,
     654                       hstrerror(h_errno));
    631655                retval++;
    632656            } else {
     
    634658                mr_strcat(ip_address, strchr(bkpinfo->netfs_mount, ':'));
    635659                strcpy(bkpinfo->netfs_mount, ip_address);
    636                 mr_free(ip_address);
     660                paranoid_free(ip_address);
    637661            }
    638662        }
    639         mr_free(hostname);
    640663        store_netfs_config();
    641664    }
     
    645668        fprintf(stderr, "Type 'man mondoarchive' for help.\n");
    646669    }
    647     if (bkpinfo->include_paths == NULL) {
    648         mr_asprintf(bkpinfo->include_paths, "/");
    649     }
     670    if (strlen(bkpinfo->tmpdir) < 2 || strlen(bkpinfo->scratchdir) < 2) {
     671        log_it("tmpdir or scratchdir are blank/missing");
     672        retval++;
     673    }
     674    if (bkpinfo->include_paths[0] == '\0') {
     675        //      fatal_error ("Why no backup path?");
     676        strcpy(bkpinfo->include_paths, "/");
     677    }
     678    chmod(bkpinfo->scratchdir, 0700);
    650679    g_backup_media_type = bkpinfo->backup_media_type;
     680    paranoid_free(mtpt);
     681    paranoid_free(hostname);
     682    paranoid_free(cdr_exe);
    651683    return (retval);
    652684}
     
    672704    if (bkpinfo->disaster_recovery) {
    673705        if (!does_nonMS_partition_exist()) {
    674             fatal_error("I am in disaster recovery mode\nPlease don't run mondoarchive.");
     706            fatal_error
     707                ("I am in disaster recovery mode\nPlease don't run mondoarchive.");
    675708        }
    676709    }
     
    680713    paranoid_free(tmp);
    681714    if (find_and_store_mondoarchives_home(g_mondo_home)) {
    682         fprintf(stderr, "Cannot find Mondo's homedir. I think you have >1 'mondo' directory on your hard disk. Please delete the superfluous 'mondo' directories and try again\n");
     715        fprintf(stderr,
     716                "Cannot find Mondo's homedir. I think you have >1 'mondo' directory on your hard disk. Please delete the superfluous 'mondo' directories and try again\n");
    683717        res++;
    684718        return (res);
     
    689723    }
    690724    g_current_media_number = 1;
    691     bkpinfo->postnuke_tarball[0] = '\0';
     725    bkpinfo->postnuke_tarball[0] = bkpinfo->netfs_mount[0] = '\0';
    692726    return (res);
    693727}
     
    738772    if (p == NULL) {
    739773        log_it("Failed to create global tmp directory %s for Mondo.",tmp);
    740         mr_free(tmp);
    741774        finish(-1);
    742775    }
    743     mr_free(tmp);
    744 
    745776    strcpy(bkpinfo->tmpdir,p);
    746     log_it("bkpinfo->tmpdir is being set to %s", bkpinfo->tmpdir);
     777    paranoid_free(tmp);
    747778
    748779    mr_asprintf(tmp, "mkdir -p %s/tmpfs", bkpinfo->tmpdir);
     
    786817    }
    787818    strcpy(bkpinfo->scratchdir,p);
    788     log_it("bkpinfo->scratchdir is being set to %s", bkpinfo->scratchdir);
    789819    paranoid_free(tmp);
    790820
     
    802832{
    803833    int i;
    804     log_msg(1, "Initializing bkpinfo");
    805 
     834
     835    log_msg(1, "Hi");
    806836    assert(bkpinfo != NULL);
    807837    memset((void *) bkpinfo, 0, sizeof(struct s_bkpinfo));
     
    817847    bkpinfo->use_lzo = FALSE;
    818848    bkpinfo->use_gzip = FALSE;
    819     bkpinfo->use_lzma = FALSE;
     849    bkpinfo->do_not_compress_these[0] = '\0';
    820850    bkpinfo->verify_data = FALSE;
    821851    bkpinfo->backup_data = FALSE;
     
    823853    bkpinfo->use_star = FALSE;
    824854    bkpinfo->internal_tape_block_size = DEFAULT_INTERNAL_TAPE_BLOCK_SIZE;
    825    
    826 /*  We need tmpdir as early as possible for further function calls */
    827     bkpinfo->tmpdir = NULL;         // Really setup after
    828     setup_tmpdir(NULL);
    829     setup_scratchdir(NULL);
    830 
    831     bkpinfo->disaster_recovery = am_I_in_disaster_recovery_mode();
     855    bkpinfo->disaster_recovery =
     856        (am_I_in_disaster_recovery_mode()? TRUE : FALSE);
    832857    if (bkpinfo->disaster_recovery) {
    833858        strcpy(bkpinfo->isodir, "/");
     
    836861    }
    837862    strcpy(bkpinfo->prefix, STD_PREFIX);
     863    setup_tmpdir(NULL);
     864    setup_scratchdir(NULL);
     865
    838866    bkpinfo->optimal_set_size = 0;
    839     bkpinfo->backup_media_type = none;
     867    strcpy(bkpinfo->include_paths, "/");
    840868    bkpinfo->make_filelist = TRUE;  // unless -J supplied to mondoarchive
    841     bkpinfo->exclude_paths = NULL;
    842     bkpinfo->include_paths = NULL;
     869    bkpinfo->include_paths[0] = '\0';
    843870    bkpinfo->exclude_devs = NULL;
    844871    bkpinfo->restore_path[0] = '\0';
     
    852879    bkpinfo->netfs_user = NULL;
    853880    bkpinfo->netfs_remote_dir[0] = '\0';
     881    bkpinfo->exclude_paths = NULL;
     882    bkpinfo->subdir = NULL;
    854883    bkpinfo->postnuke_tarball[0] = '\0';
    855     bkpinfo->subdir = NULL;
    856884    bkpinfo->wipe_media_first = FALSE;
    857885    bkpinfo->differential = 0;
     
    866894
    867895
     896
     897
    868898/**
    869899 * Get the remaining free space (in MB) on @p partition.
     
    886916    mr_free(command);
    887917
    888     mr_asprintf(command, "df -m -P %s | tail -n1 | tr -s ' ' '\t' | cut -f4", partition);
     918    mr_asprintf(command, "df -m -P %s | tail -n1 | tr -s ' ' '\t' | cut -f4",
     919            partition);
    889920    mr_asprintf(out_sz, "%s", call_program_and_get_last_line_of_output(command));
    890921    mr_free(command);
     
    926957    if (system("which mkfs.vfat 2> /dev/null 1> /dev/null")
    927958        && !system("which mkfs.msdos 2> /dev/null 1> /dev/null")) {
    928         log_it("OK, you've got mkfs.msdos but not mkfs.vfat; time for the fairy to wave her magic wand...");
    929         run_program_and_log_output("ln -sf `which mkfs.msdos` /sbin/mkfs.vfat", FALSE);
    930     }
    931     mr_asprintf(tmp, "%s", call_program_and_get_last_line_of_output("free | grep Mem | head -n1 | tr -s ' ' '\t' | cut -f2"));
     959        log_it
     960            ("OK, you've got mkfs.msdos but not mkfs.vfat; time for the fairy to wave her magic wand...");
     961        run_program_and_log_output
     962            ("ln -sf `which mkfs.msdos` /sbin/mkfs.vfat", FALSE);
     963    }
     964    mr_asprintf(tmp, "%s",
     965           call_program_and_get_last_line_of_output
     966           ("free | grep Mem | head -n1 | tr -s ' ' '\t' | cut -f2"));
    932967    if (atol(tmp) < 35000) {
    933968        retval++;
     
    935970    }
    936971    if (atol(tmp) < 66000) {
    937         log_to_screen("WARNING! You have very little RAM. Please upgrade to 64MB or more.");
     972        log_to_screen
     973            ("WARNING! You have very little RAM. Please upgrade to 64MB or more.");
    938974    }
    939975    mr_free(tmp);
     
    9901026        whine_if_not_found("cmp");
    9911027    }
    992     run_program_and_log_output("umount `mount | grep cdr | cut -d' ' -f3 | tr '\n' ' '`", 5);
    993     mr_asprintf(tmp, "%s", call_program_and_get_last_line_of_output("mount | grep -E \"cdr(om|w)\""));
     1028    run_program_and_log_output
     1029        ("umount `mount | grep cdr | cut -d' ' -f3 | tr '\n' ' '`", 5);
     1030    mr_asprintf(tmp, "%s",
     1031           call_program_and_get_last_line_of_output
     1032           ("mount | grep -E \"cdr(om|w)\""));
    9941033    if (strcmp("", tmp)) {
    9951034        if (strstr(tmp, "autofs")) {
     
    10651104    /*@ buffer ****************************************************** */
    10661105    char *command = NULL;
     1106    char *tmp = NULL;
    10671107
    10681108    /*@ end vars *************************************************** */
     
    10711111    assert_string_is_neither_NULL_nor_zerolength(label);
    10721112    if (!does_file_exist(config_file)) {
    1073         log_to_screen("(read_cfg_var) Cannot find %s config file", config_file);
     1113        mr_asprintf(tmp, "(read_cfg_var) Cannot find %s config file",
     1114                config_file);
     1115        log_to_screen(tmp);
     1116        mr_free(tmp);
     1117
    10741118        value[0] = '\0';
    10751119        return (1);
     
    10831127        mr_free(command);
    10841128
    1085         log_msg(4, "Configuration item %s is %s", label, value);
    10861129        if (strlen(value) == 0) {
    10871130            return (1);
     
    11991242 * If this is a distribution like Gentoo that doesn't keep /boot mounted, mount it.
    12001243 */
    1201 void mount_boot_if_necessary() {
     1244void mount_boot_if_necessary()
     1245{
    12021246    char *tmp = NULL;
    12031247    char *command = NULL;
     
    12071251    g_boot_mountpt[0] = '\0';
    12081252    log_msg(4, "Done. Great. Seeting command to something");
    1209     mr_asprintf(command, "%s", "grep -v \":\" /etc/fstab | grep -vE '^#.*$' | grep -E \"[   ]/boot[     ]\" | tr -s ' ' '\t' | cut -f1 | head -n1");
     1253    mr_asprintf(command, "%s",
     1254           "grep -v \":\" /etc/fstab | grep -vE '^#.*$' | grep -E \"[   ]/boot[     ]\" | tr -s ' ' '\t' | cut -f1 | head -n1");
    12101255    log_msg(4, "Cool. Command = '%s'", command);
    12111256    mr_asprintf(tmp, "%s", call_program_and_get_last_line_of_output(command));
     
    12131258
    12141259    log_msg(4, "tmp = '%s'", tmp);
    1215     log_it("/boot is at %s according to /etc/fstab", tmp);
    1216     mr_asprintf(command, "mount | grep -Ew '/boot'");
    1217     mr_free(tmp);
    1218 
    1219     mr_asprintf(tmp, call_program_and_get_last_line_of_output(command));
    1220     mr_free(command);
    1221 
    1222     if (!strcmp(tmp,"")) {
    1223         if ((strstr(tmp, "LABEL=") != NULL) || (strstr(tmp,"UUID=") != NULL)) {
    1224             if (!run_program_and_log_output("mount /boot", 5)) {
    1225                 strcpy(g_boot_mountpt, "/boot");
    1226                 log_msg(1, "Mounted /boot");
     1260    if (tmp[0]) {
     1261        log_it("/boot is at %s according to /etc/fstab", tmp);
     1262        mr_asprintf(command, "mount | grep -Ew '/boot'");
     1263        mr_free(tmp);
     1264        mr_asprintf(tmp, call_program_and_get_last_line_of_output(command));
     1265        mr_free(command);
     1266
     1267        if (!strcmp(tmp,"")) {
     1268            if (((strstr(tmp, "LABEL=") != NULL) || (strstr(tmp,"UUID=")) != NULL)) {
     1269                if (!run_program_and_log_output("mount /boot", 5)) {
     1270                    strcpy(g_boot_mountpt, "/boot");
     1271                    log_msg(1, "Mounted /boot");
     1272                } else {
     1273                    log_it("...ignored cos it's a label or uuid :-)");
     1274                }
    12271275            } else {
    1228                 log_it("...ignored cos it's a label or uuid :-)");
     1276                mr_asprintf(command, "mount | grep -E '^%s'", tmp);
     1277                log_msg(3, "command = %s", command);
     1278                if (run_program_and_log_output(command, 5)) {
     1279                    strcpy(g_boot_mountpt, tmp);
     1280                    mr_free(tmp);
     1281                    mr_asprintf(tmp,
     1282                            "%s (your /boot partition) is not mounted. I'll mount it before backing up",
     1283                            g_boot_mountpt);
     1284                    log_it(tmp);
     1285                    mr_free(tmp);
     1286
     1287                    mr_asprintf(tmp, "mount %s", g_boot_mountpt);
     1288                    if (run_program_and_log_output(tmp, 5)) {
     1289                        g_boot_mountpt[0] = '\0';
     1290                        log_msg(1, "Plan B");
     1291                        if (!run_program_and_log_output("mount /boot", 5)) {
     1292                            strcpy(g_boot_mountpt, "/boot");
     1293                            log_msg(1, "Plan B worked");
     1294                        } else {
     1295                            log_msg(1,
     1296                                "Plan B failed. Unable to mount /boot for backup purposes. This probably means /boot is mounted already, or doesn't have its own partition.");
     1297                        }
     1298                    }
     1299                    mr_free(tmp);
     1300                }
     1301                mr_free(command);
    12291302            }
    1230         } else {
    1231             mr_asprintf(command, "mount | grep -E '^%s'", tmp);
    1232             log_msg(3, "command = %s", command);
    1233             if (run_program_and_log_output(command, 5)) {
    1234                 strcpy(g_boot_mountpt, tmp);
    1235                 mr_free(tmp);
    1236                 log_it("%s (your /boot partition) is not mounted. I'll mount it before backing up", g_boot_mountpt);
    1237 
    1238                 mr_asprintf(tmp, "mount %s", g_boot_mountpt);
    1239                 if (run_program_and_log_output(tmp, 5)) {
    1240                     g_boot_mountpt[0] = '\0';
    1241                     log_msg(1, "Plan B");
    1242                     if (!run_program_and_log_output("mount /boot", 5)) {
    1243                         strcpy(g_boot_mountpt, "/boot");
    1244                         log_msg(1, "Plan B worked");
    1245                     } else {
    1246                         log_msg(1,
    1247                             "Plan B failed. Unable to mount /boot for backup purposes. This probably means /boot is mounted already, or doesn't have its own partition.");
    1248                     }
    1249                 }
    1250             }
    1251             mr_free(command);
    1252         }
    1253     }
    1254     mr_free(tmp);
     1303        }
     1304    }
    12551305    log_msg(1, "Ended sub");
    12561306}
     
    12901340    char *command = NULL;
    12911341    char *tempfile = NULL;
     1342    char *tmp = NULL;
    12921343
    12931344
     
    12971348    assert(value != NULL);
    12981349    if (!does_file_exist(config_file)) {
    1299         log_to_screen("(write_cfg_file) Cannot find %s config file", config_file);
     1350        mr_asprintf(tmp, "(write_cfg_file) Cannot find %s config file",
     1351                config_file);
     1352        log_to_screen(tmp);
     1353        mr_free(tmp);
    13001354        return (1);
    13011355    }
    13021356    mr_asprintf(tempfile, "%s/mojo-jojo.blah", bkpinfo->tmpdir);
    13031357    if (does_file_exist(config_file)) {
    1304         mr_asprintf(command, "grep -vE '^%s .*$' %s > %s", label, config_file, tempfile);
     1358        mr_asprintf(command, "grep -vE '^%s .*$' %s > %s",
     1359                label, config_file, tempfile);
    13051360        paranoid_system(command);
    13061361        mr_free(command);
     
    13231378 * information to the logfile.
    13241379 */
    1325 void standard_log_debug_msg(int debug_level, const char *szFile, const char *szFunction, int nLine, const char *fmt, ...) {
    1326 
     1380void standard_log_debug_msg(int debug_level, const char *szFile,
     1381                            const char *szFunction, int nLine,
     1382                            const char *fmt, ...)
     1383{
    13271384    va_list args;
     1385    int i;
    13281386    static int depth = 0;
    13291387    FILE *fout;
     
    13381396        if (!(fout = fopen(MONDO_LOGFILE, "a"))) {
    13391397            return;
    1340         }
     1398        }       // fatal_error("Failed to openout to logfile - sheesh..."); }
    13411399
    13421400        // add tabs to distinguish log levels
    13431401        if (debug_level > 0) {
    1344             fprintf(fout, "DBG%d: ", debug_level);
     1402            for (i = 1; i < debug_level; i++)
     1403                fprintf(fout, "\t");
    13451404            if (getpid() == g_main_pid)
    13461405                fprintf(fout, "[Main] %s->%s#%d: ", szFile, szFunction, nLine);
     
    13491408            else
    13501409                fprintf(fout, "[TH=%d] %s->%s#%d: ", getpid(), szFile, szFunction, nLine);
    1351         } else {
    1352             fprintf(fout, "INFO: ");
    13531410        }
    13541411        va_start(args, fmt);
     
    13561413        va_end(args);
    13571414
     1415        // do not slow down the progran if standard debug level
     1416        // must be enabled: if no flush, the log won't be up-to-date if there
     1417        // is a segfault
     1418        //if (g_dwDebugLevel != 1)
     1419
    13581420        fprintf(fout, "\n");
    13591421        paranoid_fclose(fout);
     
    13681430                       ...) = standard_log_debug_msg;
    13691431
     1432
     1433/**
     1434 * If @p y, malloc @p x, else free @p x.
     1435 * @bug This function seems orphaned. Please remove.
     1436 */
     1437#define do_alloc_or_free_depending(x,y) { if(y) {x=malloc(MAX_STR_LEN);} else {paranoid_free(x);} }
    13701438
    13711439/**
     
    13781446        malloc_string(g_boot_mountpt);
    13791447        malloc_string(g_mondo_home);
     1448        /*
     1449        malloc_string(g_tmpfs_mountpt);
     1450        */
    13801451        malloc_string(g_serial_string);
    13811452        malloc_string(g_magicdev_command);
     
    13831454        paranoid_free(g_boot_mountpt);
    13841455        paranoid_free(g_mondo_home);
     1456        /*
     1457        paranoid_free(g_tmpfs_mountpt);
     1458        */
     1459        paranoid_free(g_serial_string);
    13851460        paranoid_free(g_magicdev_command);
    13861461
    1387         mr_free(g_serial_string);
    1388     }
     1462    }
     1463
     1464    /*
     1465       char**list_of_arrays[] = {
     1466       &g_boot_mountpt,
     1467       &g_mondo_home,
     1468       &g_tmpfs_mountpt,
     1469       &g_serial_string,
     1470       &g_magicdev_command,
     1471       NULL};
     1472
     1473       char**ppcurr;
     1474       int i;
     1475
     1476       for(i=0;list_of_arrays[i];i++)
     1477       {
     1478       log_msg(5, "Allocating %d", i);
     1479       ppcurr = list_of_arrays[i];
     1480       if (mal)
     1481       { *ppcurr = malloc(MAX_STR_LEN); }
     1482       else
     1483       {
     1484       if (*ppcurr)
     1485       {
     1486       free(*ppcurr);
     1487       }
     1488       }
     1489       }
     1490       log_msg(5, "Returning");
     1491     */
    13891492}
    13901493
     
    14151518void stop_magicdev_if_necessary()
    14161519{
    1417     strcpy(g_magicdev_command, call_program_and_get_last_line_of_output("ps ax | grep -w magicdev | grep -v grep | tr -s '\t' ' '| cut -d' ' -f6-99"));
     1520    strcpy(g_magicdev_command,
     1521           call_program_and_get_last_line_of_output
     1522           ("ps ax | grep -w magicdev | grep -v grep | tr -s '\t' ' '| cut -d' ' -f6-99"));
    14181523    if (g_magicdev_command[0]) {
    14191524        log_msg(1, "g_magicdev_command = '%s'", g_magicdev_command);
  • branches/3.0/mondo/src/common/libmondo-verify.c

    r3188 r3192  
    5555    assert(bkpinfo != NULL);
    5656    assert_string_is_neither_NULL_nor_zerolength(mountpoint);
    57     sprintf(output, "%s/archives/%d.star.%s", mountpoint, setno, bkpinfo->zip_suffix);
     57    sprintf(output, "%s/archives/%d.star.%s", mountpoint, setno,
     58            bkpinfo->zip_suffix);
    5859    if (!does_file_exist(output)) {
    59         sprintf(output, "%s/archives/%d.afio.%s", mountpoint, setno, bkpinfo->zip_suffix);
     60        sprintf(output, "%s/archives/%d.afio.%s", mountpoint, setno,
     61                bkpinfo->zip_suffix);
    6062    }
    6163    return (output);
     
    7880{
    7981    /*@ buffer ********************************************************** */
    80     char *command = NULL;
    81     char *afio_found_changes = NULL;
     82    char *command;
     83    char *afio_found_changes;
    8284
    8385    /*@ int ************************************************************* */
     
    8789    long afio_diffs = 0;
    8890
     91    command = malloc(2000);
     92    afio_found_changes = malloc(500);
    8993    assert_string_is_neither_NULL_nor_zerolength(changedfiles_fname);
    9094    assert_string_is_neither_NULL_nor_zerolength(ignorefiles_fname);
    9195    assert_string_is_neither_NULL_nor_zerolength(stderr_fname);
    9296
    93     mr_asprintf(afio_found_changes, "%s.afio", ignorefiles_fname);
    94     sync();
     97    sprintf(afio_found_changes, "%s.afio", ignorefiles_fname);
     98    paranoid_system("sync");
     99
     100/*  sprintf (command,
     101       "grep \"afio: \" %s | awk '{j=substr($0,8); i=index(j,\": \");printf \"/%%s\\n\",substr(j,1,i-2);}' | sort -u | grep -v \"incheckentry.*xwait\" | grep -vx \"/afio:.*\" | grep -vx \"/dev/.*\" > %s",
     102       stderr_fname, afio_found_changes);
     103*/
    95104
    96105    log_msg(1, "Now scanning log file for 'afio: ' stuff");
    97     mr_asprintf(command, "grep \"afio: \" %s | sed 's/afio: //' | grep -vE '^/dev/.*$' >> %s", stderr_fname, afio_found_changes);
     106    sprintf(command,
     107            "grep \"afio: \" %s | sed 's/afio: //' | grep -vE '^/dev/.*$' >> %s",
     108            stderr_fname, afio_found_changes);
    98109    log_msg(2, command);
    99110    res = system(command);
    100     mr_free(command);
    101 
    102111    if (res) {
    103112        log_msg(2, "Warning - failed to think");
     
    105114
    106115    log_msg(1, "Now scanning log file for 'star: ' stuff");
    107     mr_asprintf(command, "grep \"star: \" %s | sed 's/star: //' | grep -vE '^/dev/.*$' >> %s", stderr_fname, afio_found_changes);
     116    sprintf(command,
     117            "grep \"star: \" %s | sed 's/star: //' | grep -vE '^/dev/.*$' >> %s",
     118            stderr_fname, afio_found_changes);
    108119    log_msg(2, command);
    109120    res = system(command);
    110     mr_free(command);
    111 
    112121    if (res) {
    113122        log_msg(2, "Warning - failed to think");
    114123    }
     124//  exclude_nonexistent_files (afio_found_changes);
    115125    afio_diffs = count_lines_in_file(afio_found_changes);
    116     mr_asprintf(command, "sort %s %s %s | uniq -c | awk '{ if ($1==\"2\") {print $2;};}' | grep -v \"incheckentry xwait()\" > %s", ignorefiles_fname, afio_found_changes, afio_found_changes, changedfiles_fname);
    117     mr_free(afio_found_changes);
     126    sprintf(command,
     127            "sort %s %s %s | uniq -c | awk '{ if ($1==\"2\") {print $2;};}' | grep -v \"incheckentry xwait()\" > %s",
     128            ignorefiles_fname, afio_found_changes, afio_found_changes,
     129            changedfiles_fname);
    118130    log_msg(2, command);
    119131    paranoid_system(command);
    120     mr_free(command);
     132    paranoid_free(command);
     133    paranoid_free(afio_found_changes);
    121134    return (afio_diffs);
    122135}
     
    138151
    139152    /*@ buffers ********************************************************* */
    140     char *tmp = NULL;
     153    char *tmp;
    141154    char *mds = NULL;
    142155
     
    149162    assert_string_is_neither_NULL_nor_zerolength(mountpoint);
    150163    assert(bkpinfo != NULL);
     164    malloc_string(tmp);
    151165
    152166    for (set_number = 0;
     
    161175    if (g_last_afioball_number != set_number - 1) {
    162176        if (set_number == 0) {
    163             log_msg(1, "Weird error in verify_afioballs_on_CD() but it's really a cosmetic error, nothing more");
     177            log_msg(1,
     178                    "Weird error in verify_afioballs_on_CD() but it's really a cosmetic error, nothing more");
    164179        } else {
    165180            retval++;
    166             log_to_screen("Warning - missing set(s) between %d and %d\n", g_last_afioball_number, set_number - 1);
     181            sprintf(tmp, "Warning - missing set(s) between %d and %d\n",
     182                    g_last_afioball_number, set_number - 1);
     183            log_to_screen(tmp);
    167184        }
    168185    }
    169186    mds = media_descriptor_string(bkpinfo->backup_media_type);
    170     mr_asprintf(tmp, "Verifying %s #%d's tarballs", mds, g_current_media_number);
     187    sprintf(tmp, "Verifying %s #%d's tarballs", mds, g_current_media_number);
    171188    mr_free(mds);
    172189
    173190    open_evalcall_form(tmp);
    174     mr_free(tmp);
    175191
    176192    for (total_sets = set_number;
     
    192208    g_last_afioball_number = set_number - 1;
    193209    close_evalcall_form();
     210    paranoid_free(tmp);
    194211    return (retval);
    195212}
     
    210227
    211228    /*@ buffer ********************************************************** */
    212     char *tmp = NULL;
    213     char *mountpoint = NULL;
    214     char *command = NULL;
     229    char *tmp;
     230    char *mountpoint;
     231//  char ca, cb;
     232    char *command;
    215233    char *mds = NULL;
    216     char *sz_exe = NULL;
     234    char *sz_exe;
    217235    static char *bufblkA = NULL;
    218236    static char *bufblkB = NULL;
     
    234252    FILE *fin;
    235253    int retval = 0;
    236 
     254//  long long outlen;
     255
     256    malloc_string(tmp);
     257    malloc_string(mountpoint);
     258    malloc_string(command);
     259    malloc_string(sz_exe);
    237260    if (!bufblkA) {
    238261        if (!(bufblkA = malloc(maxbufsize))) {
     
    251274    if (bkpinfo->compression_level > 0) {
    252275        if (bkpinfo->use_lzo) {
    253             mr_asprintf(sz_exe, "lzop");
     276            strcpy(sz_exe, "lzop");
    254277        } else if (bkpinfo->use_gzip) {
    255             mr_asprintf(sz_exe, "gzip");
    256         } else if (bkpinfo->use_lzma) {
    257             mr_asprintf(sz_exe, "lzma");
     278            strcpy(sz_exe, "gzip");
    258279        } else {
    259             mr_asprintf(sz_exe, "bzip2");
    260         }
     280            strcpy(sz_exe, "bzip2");
     281        }
     282    } else {
     283        sz_exe[0] = '\0';
    261284    }
    262285
    263286    log_it("before vsbf");
    264287    mds = media_descriptor_string(bkpinfo->backup_media_type);
    265     mr_asprintf(tmp, "Verifying %s#%d's big files", mds, g_current_media_number);
     288    sprintf(tmp, "Verifying %s#%d's big files", mds, g_current_media_number);
    266289    mr_free(mds);
    267290
    268291    open_evalcall_form(tmp);
    269     mr_free(tmp);
    270 
    271292    log_it("after vsbf");
    272     mr_asprintf(mountpoint, "%s/archives", mtpt);
     293    sprintf(mountpoint, "%s/archives", mtpt);
    273294    if (last_bigfile_num == -1) {
    274295        bigfile_num = 0;
     
    281302        slice_num = last_slice_num + 1;
    282303    }
    283     while (does_file_exist(slice_fname(bigfile_num, slice_num, mountpoint, bkpinfo->zip_suffix))
     304    while (does_file_exist
     305           (slice_fname
     306            (bigfile_num, slice_num, mountpoint, bkpinfo->zip_suffix))
    284307           ||
    285            does_file_exist(slice_fname(bigfile_num, slice_num, mountpoint, ""))) {
     308           does_file_exist(slice_fname
     309                           (bigfile_num, slice_num, mountpoint, ""))) {
    286310        // handle slices until end of CD
    287311        if (slice_num == 0) {
    288             log_msg(2, "ISO=%d  bigfile=%ld --START--", g_current_media_number, bigfile_num);
    289             if (! (fin = fopen(slice_fname(bigfile_num, slice_num, mountpoint, ""), "r"))) {
     312            log_msg(2, "ISO=%d  bigfile=%ld --START--",
     313                    g_current_media_number, bigfile_num);
     314            if (!
     315                (fin =
     316                 fopen(slice_fname(bigfile_num, slice_num, mountpoint, ""),
     317                       "r"))) {
    290318                log_msg(2, "Cannot open bigfile's info file");
    291319            } else {
    292                 if (fread ((void *) &biggiestruct, 1, sizeof(biggiestruct), fin) < sizeof(biggiestruct)) {
     320                if (fread
     321                    ((void *) &biggiestruct, 1, sizeof(biggiestruct),
     322                     fin) < sizeof(biggiestruct)) {
    293323                    log_msg(2, "Unable to get biggiestruct");
    294324                }
    295325                paranoid_fclose(fin);
    296326            }
    297             if (bkpinfo->restore_path) {
    298                 mr_asprintf(tmp, "%s/%s", bkpinfo->restore_path, biggiestruct.filename);
    299                 log_msg(2, "Opening biggiefile #%ld - '%s'", bigfile_num, tmp);
    300                 forig = fopen(tmp, "r");
    301                 mr_free(tmp);
    302    
    303                 if (!forig) {
    304                     log_msg(2, "Failed to open bigfile. Darn.");
    305                     log_to_screen("%s/%s not found on live filesystem", bkpinfo->restore_path, biggiestruct.filename);
    306                     mr_asprintf(tmp, "echo \"%s/%s not found\" >> %s/biggies.changed", bkpinfo->restore_path, biggiestruct.filename, bkpinfo->tmpdir);
    307                     paranoid_system(tmp);
    308                     mr_free(tmp);
    309 
    310                     bigfile_num++;
    311                     slice_num = 0;
    312                     retval++;
    313                 } else {
    314                     slice_num++;
    315                 }
     327            sprintf(tmp, "%s/%s", bkpinfo->restore_path,
     328                    biggiestruct.filename);
     329            log_msg(2, "Opening biggiefile #%ld - '%s'", bigfile_num, tmp);
     330            if (!(forig = fopen(tmp, "r"))) {
     331                log_msg(2, "Failed to open bigfile. Darn.");
     332                log_to_screen("%s/%s not found on live filesystem",
     333                            bkpinfo->restore_path,
     334                            biggiestruct.filename);
     335                mr_asprintf(mds, "echo \"%s/%s not found\" >> %s/biggies.changed",
     336                            bkpinfo->restore_path,
     337                            biggiestruct.filename,
     338                            bkpinfo->tmpdir);
     339                paranoid_system(mds);
     340                paranoid_free(mds);
     341
     342                bigfile_num++;
     343                slice_num = 0;
     344                retval++;
    316345            } else {
    317                 log_it("Unable to open bigfile as restore_path is NULL");
     346                slice_num++;
    318347            }
    319348        } else if (does_file_exist(slice_fname(bigfile_num, slice_num, mountpoint, "")) &&
     
    325354            slice_num = 0;
    326355        } else {
    327             log_msg(2, "ISO=%d  bigfile=%ld  slice=%ld", g_current_media_number, bigfile_num, slice_num);
    328             if ((!does_file_exist(slice_fname(bigfile_num, slice_num, mountpoint, ""))) && (sz_exe != NULL)) {
    329                 mr_asprintf(command, "%s -dc %s 2>> %s", sz_exe, slice_fname(bigfile_num, slice_num, mountpoint, bkpinfo->zip_suffix), MONDO_LOGFILE);
     356            log_msg(2, "ISO=%d  bigfile=%ld  slice=%ld",
     357                    g_current_media_number, bigfile_num, slice_num);
     358            if (!does_file_exist(slice_fname(bigfile_num, slice_num, mountpoint, ""))) {
     359                sprintf(command, "%s -dc %s 2>> %s",
     360                        sz_exe,
     361                        slice_fname(bigfile_num, slice_num, mountpoint, bkpinfo->zip_suffix),
     362                        MONDO_LOGFILE);
    330363            } else {
    331                 mr_asprintf(command, "cat %s 2>> %s", slice_fname(bigfile_num, slice_num, mountpoint, ""), MONDO_LOGFILE);
     364                sprintf(command, "cat %s 2>> %s",
     365                        slice_fname(bigfile_num, slice_num, mountpoint, ""), MONDO_LOGFILE);
    332366            }
    333             pin = popen(command, "r");
    334             mr_free(command);
    335             if (pin) {
     367            if ((pin = popen(command, "r"))) {
    336368                res = 0;
    337369                while (!feof(pin)) {
     
    372404        }
    373405    }
    374     mr_free(mountpoint);
    375     mr_free(sz_exe);
    376 
    377406    last_bigfile_num = bigfile_num;
    378407    last_slice_num = slice_num - 1;
     
    387416        paranoid_free(bufblkB);
    388417    }
     418    paranoid_free(tmp);
     419    paranoid_free(command);
     420    paranoid_free(sz_exe);
     421    paranoid_free(mountpoint);
    389422    return (0);
    390423}
     
    409442{
    410443    /*@ buffers ********************************************************* */
    411     char *command = NULL;
    412     char *outlog = NULL;
    413     char *tmp = NULL;
    414     char *p = NULL;
     444    char *command;
     445    char *outlog;
     446    char *tmp;
     447    char *p;
    415448
    416449    /*@ pointers ******************************************************* */
     
    429462
    430463    log_it("Verifying fileset '%s'", tarball_fname);
    431     mr_asprintf(outlog, "%s/afio.log", bkpinfo->tmpdir);
    432     /* if programmer forgot to say which compression thingy to use then find out */
    433     if (strstr(tarball_fname, ".lzo") && strcmp(bkpinfo->zip_suffix, "lzo")) {
     464    /*  chdir("/"); */
     465    sprintf(outlog, "%s/afio.log", bkpinfo->tmpdir);
     466/* if programmer forgot to say which compression thingy to use then find out */
     467    if (strstr(tarball_fname, ".lzo")
     468        && strcmp(bkpinfo->zip_suffix, "lzo")) {
    434469        log_msg(2, "OK, I'm going to start using lzop.");
    435470        strcpy(bkpinfo->zip_exe, "lzop");
     
    437472        bkpinfo->use_lzo = TRUE;
    438473        bkpinfo->use_gzip = FALSE;
    439         bkpinfo->use_lzma = FALSE;
    440     }
    441     if (strstr(tarball_fname, ".gz") && strcmp(bkpinfo->zip_suffix, "gz")) {
     474    }
     475    if (strstr(tarball_fname, ".gz")
     476        && strcmp(bkpinfo->zip_suffix, "gz")) {
    442477        log_msg(2, "OK, I'm going to start using gzip.");
    443478        strcpy(bkpinfo->zip_exe, "gzip");
     
    445480        bkpinfo->use_lzo = FALSE;
    446481        bkpinfo->use_gzip = TRUE;
    447         bkpinfo->use_lzma = FALSE;
    448     }
    449     if (strstr(tarball_fname, ".bz2") && strcmp(bkpinfo->zip_suffix, "bz2")) {
     482    }
     483    if (strstr(tarball_fname, ".bz2")
     484        && strcmp(bkpinfo->zip_suffix, "bz2")) {
    450485        log_msg(2, "OK, I'm going to start using bzip2.");
    451486        strcpy(bkpinfo->zip_exe, "bzip2");
     
    453488        bkpinfo->use_lzo = FALSE;
    454489        bkpinfo->use_gzip = FALSE;
    455         bkpinfo->use_lzma = FALSE;
    456     }
    457     if (strstr(tarball_fname, ".lzma") && strcmp(bkpinfo->zip_suffix, "lzma")) {
    458         log_msg(2, "OK, I'm going to start using lzma.");
    459         strcpy(bkpinfo->zip_exe, "lzma");
    460         strcpy(bkpinfo->zip_suffix, "lzma");
    461         bkpinfo->use_lzo = FALSE;
    462         bkpinfo->use_gzip = FALSE;
    463         bkpinfo->use_lzma = TRUE;
    464     }
    465     if (bkpinfo->zip_exe == NULL) {
    466         strcpy(bkpinfo->zip_exe, "none");
    467     }
    468     if (bkpinfo->zip_suffix == NULL) {
    469         strcpy(bkpinfo->zip_suffix, "");
    470490    }
    471491    unlink(outlog);
     
    473493        bkpinfo->use_star = TRUE;
    474494        if (strstr(tarball_fname, ".bz2"))
    475             mr_asprintf(command, "star -sparse -diff diffopts=mode,size,data file=%s %s >> %s 2>> %s", tarball_fname, (strstr(tarball_fname, ".bz2")) ? "-bz" : " ", outlog, outlog);
     495            sprintf(command,
     496                    "star -sparse -diff diffopts=mode,size,data file=%s %s >> %s 2>> %s",
     497                    tarball_fname,
     498                    (strstr(tarball_fname, ".bz2")) ? "-bz" : " ", outlog,
     499                    outlog);
    476500    } else {
    477501        bkpinfo->use_star = FALSE;
    478         /* Here we suppose that there is always a compression program called */
    479         if (bkpinfo->zip_exe) {
    480             mr_asprintf(command, "afio -r -P %s -Z %s >> %s 2>> %s", bkpinfo->zip_exe, tarball_fname, outlog, outlog);
    481         } else {
    482             mr_asprintf(command, "afio -r -Z %s >> %s 2>> %s", tarball_fname, outlog, outlog);
    483         }
     502        sprintf(command, "afio -r -P %s -Z %s >> %s 2>> %s",
     503                bkpinfo->zip_exe, tarball_fname, outlog, outlog);
    484504    }
    485505    log_msg(6, "command=%s", command);
    486506    paranoid_system(command);
    487     mr_free(command);
    488 
    489507    if (length_of_file(outlog) < 10) {
    490         mr_asprintf(command, "cat %s >> %s", outlog, MONDO_LOGFILE);
     508        sprintf(command, "cat %s >> %s", outlog, MONDO_LOGFILE);
    491509    } else {
    492         mr_asprintf(command, "cut -d: -f%d %s | sort -u", (bkpinfo->use_star) ? 1 : 2, outlog);
     510        sprintf(command, "cut -d: -f%d %s | sort -u",
     511                (bkpinfo->use_star) ? 1 : 2, outlog);
    493512        pin = popen(command, "r");
    494513        if (pin) {
    495             for (mr_getline(tmp, pin); !feof(pin); mr_getline(tmp, pin)) {
     514            for (p = fgets(tmp, MAX_STR_LEN, pin); !feof(pin) && (p != NULL);
     515                 p = fgets(tmp, MAX_STR_LEN, pin)) {
    496516                if (bkpinfo->use_star) {
    497517                    if (!strstr(tmp, "diffopts=")) {
    498                         while (strlen(tmp) > 0 && tmp[strlen(tmp) - 1] < 32) {
     518                        while (strlen(tmp) > 0
     519                               && tmp[strlen(tmp) - 1] < 32) {
    499520                            tmp[strlen(tmp) - 1] = '\0';
    500521                        }
    501522                        if (strchr(tmp, '/')) {
    502523                            if (!diffs) {
    503                                 log_msg(0, "'%s' - differences found", tarball_fname);
     524                                log_msg(0, "'%s' - differences found",
     525                                        tarball_fname);
    504526                            }
    505                             log_msg(0, "star: /%s", strip_afio_output_line(tmp));
     527                            log_msg(0, "star: /%s",
     528                                    strip_afio_output_line(tmp));
    506529                            diffs++;
    507530                        }
     
    509532                } else {
    510533                    if (!diffs) {
    511                         log_msg(0, "'%s' - differences found", tarball_fname);
     534                        log_msg(0, "'%s' - differences found",
     535                                tarball_fname);
    512536                    }
    513537                    log_msg(0, "afio: /%s", strip_afio_output_line(tmp));
    514538                    diffs++;
    515539                }
    516                 mr_free(tmp);
    517540            }
    518             mr_free(tmp);
    519541            paranoid_pclose(pin);
    520542        } else {
     
    522544        }
    523545    }
    524     mr_free(command);
    525     mr_free(outlog);
     546    /*  chdir(old_pwd); */
     547    //  sprintf (tmp, "uniq -u %s >> %s", "/tmp/mondo-verify.err", MONDO_LOGFILE);
     548    //  paranoid_system (tmp);
     549    //  unlink ("/tmp/mondo-verify.err");
     550    paranoid_free(command);
     551    paranoid_free(outlog);
     552    paranoid_free(tmp);
    526553    return (0);
    527554}
     
    577604
    578605    /*@ buffers ********************************************************** */
    579     char *tmp = NULL;
    580     char *tarball_fname = NULL;
     606    char *tmp;
     607    char *tarball_fname;
    581608
    582609    /*@ pointers ********************************************************* */
    583610    char *p;
    584611
     612    malloc_string(tmp);
     613    malloc_string(tarball_fname);
    585614    assert(bkpinfo != NULL);
    586615    assert_string_is_neither_NULL_nor_zerolength(orig_fname);
     
    592621        p++;
    593622    }
    594     mr_asprintf(tmp, "mkdir -p %s/tmpfs", bkpinfo->tmpdir);
     623    sprintf(tmp, "mkdir -p %s/tmpfs", bkpinfo->tmpdir);
    595624    paranoid_system(tmp);
    596     mr_free(tmp);
    597 
    598     mr_asprintf(tarball_fname, "%s/tmpfs/temporary-%s", bkpinfo->tmpdir, p);
     625    sprintf(tarball_fname, "%s/tmpfs/temporary-%s", bkpinfo->tmpdir, p);
     626    sprintf(tmp, "Temporarily copying file from tape to '%s'",
     627            tarball_fname);
     628/*  log_it(tmp); */
    599629    read_file_from_stream_to_file(tarball_fname, size);
    600630    res = verify_a_tarball(tarball_fname);
    601631    if (res) {
    602         log_msg(0, "Afioball '%s' no longer matches your live filesystem", p);
     632        sprintf(tmp,
     633                "Afioball '%s' no longer matches your live filesystem", p);
     634        log_msg(0, tmp);
    603635        retval++;
    604636    }
    605637    unlink(tarball_fname);
    606     mr_free(tarball_fname);
     638    paranoid_free(tmp);
     639    paranoid_free(tarball_fname);
    607640    return (retval);
    608641}
     
    627660
    628661    /*@ char ************************************************************ */
    629     char *test_file = NULL;
    630     char *biggie_cksum = NULL;
    631     char *orig_cksum = NULL;
    632     char *tmp = NULL;
    633     char *slice_fnam = NULL;
     662    char *test_file;
     663    char *biggie_cksum;
     664    char *orig_cksum;
     665    char *tmp;
     666    char *slice_fnam;
    634667
    635668    /*@ pointers ******************************************************** */
     
    639672    long long slice_siz;
    640673
     674    malloc_string(test_file);
     675    malloc_string(biggie_cksum);
     676    malloc_string(orig_cksum);
     677    malloc_string(tmp);
    641678    malloc_string(slice_fnam);
    642679    assert(bkpinfo != NULL);
     
    649686        p++;
    650687    }
    651     mr_asprintf(test_file, "%s/temporary-%s", bkpinfo->tmpdir, p);
     688    sprintf(test_file, "%s/temporary-%s", bkpinfo->tmpdir, p);
     689    sprintf(tmp,
     690            "Temporarily copying biggiefile %s's slices from tape to '%s'",
     691            p, test_file);
     692/*  log_it(tmp); */
    652693    for (res =
    653694         read_header_block_from_stream(&slice_siz, slice_fnam, &ctrl_chr);
    654695         ctrl_chr != BLK_STOP_A_BIGGIE;
    655696         res =
    656          read_header_block_from_stream(&slice_siz, slice_fnam, &ctrl_chr)) {
     697         read_header_block_from_stream(&slice_siz, slice_fnam,
     698                                       &ctrl_chr)) {
    657699        if (ctrl_chr != BLK_START_AN_AFIO_OR_SLICE) {
    658700            wrong_marker(BLK_START_AN_AFIO_OR_SLICE, ctrl_chr);
     
    661703        unlink(test_file);
    662704        res =
    663             read_header_block_from_stream(&slice_siz, slice_fnam, &ctrl_chr);
     705            read_header_block_from_stream(&slice_siz, slice_fnam,
     706                                          &ctrl_chr);
    664707        if (ctrl_chr != BLK_STOP_AN_AFIO_OR_SLICE) {
    665708            log_msg(2, "test_file = %s", test_file);
     
    669712        retval += res;
    670713    }
    671     mr_asprintf(biggie_cksum, "%s", slice_fnam);
     714    strcpy(biggie_cksum, slice_fnam);
    672715    if (biggie_cksum[0] != '\0') {
    673         mr_asprintf(orig_cksum, "%s", calc_checksum_of_file(biggie_fname));
     716        strcpy(orig_cksum, calc_checksum_of_file(biggie_fname));
    674717        if (strcmp(biggie_cksum, orig_cksum)) {
    675             log_msg(2, "orig cksum=%s; curr cksum=%s", biggie_cksum, orig_cksum);
    676             log_to_screen("%s has changed on live filesystem", biggie_fname);
    677 
    678             mr_asprintf(tmp, "echo \"%s\" >> %s/biggies.changed", biggie_fname, bkpinfo->tmpdir);
     718            sprintf(tmp, "orig cksum=%s; curr cksum=%s", biggie_cksum,
     719                    orig_cksum);
     720            log_msg(2, tmp);
     721            sprintf(tmp, "%s has changed on live filesystem",
     722                    biggie_fname);
     723            log_to_screen(tmp);
     724            sprintf(tmp, "echo \"%s\" >> %s/biggies.changed",
     725                    biggie_fname, bkpinfo->tmpdir);
    679726            paranoid_system(tmp);
    680             mr_free(tmp);
    681         }
    682         mr_free(orig_cksum);
    683     }
    684     mr_free(biggie_cksum);
    685     mr_free(test_file);
     727        }
     728    }
     729    paranoid_free(test_file);
     730    paranoid_free(biggie_cksum);
     731    paranoid_free(orig_cksum);
     732    paranoid_free(tmp);
    686733    paranoid_free(slice_fnam);
    687734    return (retval);
     
    692739 * Verify all afioballs from the opened tape/CD stream.
    693740 * @param bkpinfo The backup information structure. Fields used:
     741 * - @c bkpinfo->restore_path
    694742 * - @c bkpinfo->tmpdir
    695743 *
     
    706754
    707755    /*@ buffers ***************************************************** */
    708     char *tmp = NULL;
     756    char *tmp;
    709757    char *fname;
    710758    char *curr_xattr_list_fname;
     
    715763
    716764    assert(bkpinfo != NULL);
     765    malloc_string(tmp);
    717766    malloc_string(fname);
    718767    malloc_string(curr_xattr_list_fname);
     
    767816            wrong_marker(BLK_START_AN_AFIO_OR_SLICE, ctrl_chr);
    768817        }
    769         mr_asprintf(tmp, "Verifying fileset #%ld", current_afioball_number);
     818        sprintf(tmp, "Verifying fileset #%ld", current_afioball_number);
     819        /*log_it(tmp); */
    770820        update_progress_form(tmp);
    771         mr_free(tmp);
    772 
    773821        res = verify_an_afioball_from_stream(fname, size);
    774822        if (res) {
    775             log_to_screen("Afioball %ld differs from live filesystem", current_afioball_number);
     823            sprintf(tmp, "Afioball %ld differs from live filesystem",
     824                    current_afioball_number);
     825            log_to_screen(tmp);
    776826        }
    777827        retval += res;
     
    785835    log_msg(1, "All done with afioballs");
    786836    close_progress_form();
     837    paranoid_free(tmp);
    787838    paranoid_free(fname);
    788839    paranoid_free(curr_xattr_list_fname);
     
    812863
    813864    /*@ buffers ******************************************************** */
    814     char *orig_fname;
    815     char *logical_fname = NULL;
    816     char *comment = NULL;
    817     char *curr_xattr_list_fname = NULL;
    818     char *curr_acl_list_fname = NULL;
     865    char *tmp;
     866    char *orig_fname, *logical_fname;
     867    char *comment;
     868    char *curr_xattr_list_fname;
     869    char *curr_acl_list_fname;
    819870    /*@ pointers ******************************************************* */
    820871    char *p;
     
    824875
    825876    assert(bkpinfo != NULL);
     877    malloc_string(tmp);
    826878    malloc_string(orig_fname);
     879    malloc_string(logical_fname);
     880    malloc_string(comment);
    827881    malloc_string(curr_xattr_list_fname);
    828882    malloc_string(curr_acl_list_fname);
     
    836890            bkpinfo->tmpdir);
    837891    }
    838     mr_asprintf(comment, "Verifying all bigfiles.");
     892    sprintf(comment, "Verifying all bigfiles.");
    839893    log_to_screen(comment);
     894    sprintf(tmp, "%s/biggielist.txt", bkpinfo->tmpdir);
     895//  noof_biggiefiles = count_lines_in_file (tmp); // pointless
    840896    res = read_header_block_from_stream(&size, orig_fname, &ctrl_chr);
    841897    if (ctrl_chr != BLK_START_BIGGIEFILES) {
     
    855911                       "Please wait. This may take some time.", "",
    856912                       noof_biggiefiles);
    857     mr_free(comment);
    858 
    859913    for (res = read_header_block_from_stream(&size, orig_fname, &ctrl_chr);
    860914         ctrl_chr != BLK_STOP_BIGGIEFILES;
     
    871925            p++;
    872926        }
    873         mr_asprintf(comment, "Verifying bigfile #%ld (%ld K)", current_biggiefile_number, (long) size >> 10);
     927        sprintf(comment, "Verifying bigfile #%ld (%ld K)",
     928                current_biggiefile_number, (long) size >> 10);
    874929        update_progress_form(comment);
    875         mr_free(comment);
    876 
    877         if (bkpinfo->restore_path) {
    878             mr_asprintf(logical_fname, "%s/%s", bkpinfo->restore_path, orig_fname);
    879             res = verify_a_biggiefile_from_stream(logical_fname, size);
    880             mr_free(logical_fname);
    881             retval += res;
    882         } else {
    883             log_it("Unable to verify bigfile as restore_path is NULL");
    884         }
    885 
     930        sprintf(logical_fname, "%s/%s", bkpinfo->restore_path, orig_fname);
     931        res =
     932            verify_a_biggiefile_from_stream(logical_fname, size);
     933        retval += res;
    886934        current_biggiefile_number++;
    887935        g_current_progress++;
     
    889937    close_progress_form();
    890938    paranoid_free(orig_fname);
     939    paranoid_free(logical_fname);
    891940    paranoid_free(curr_xattr_list_fname);
    892941    paranoid_free(curr_acl_list_fname);
     942    paranoid_free(comment);
     943    paranoid_free(tmp);
    893944    return (retval);
    894945}
     
    900951 * Verify the USB device
    901952 * @param bkpinfo The backup information structure. Fields used:
     953 * - @c bkpinfo->isodir
    902954 * - @c bkpinfo->media_device
    903955 * - @c bkpinfo->tmpdir
     
    929981    assert(bkpinfo != NULL);
    930982
    931     if (bkpinfo->media_device == NULL) {
    932         return(1);
    933     }
    934 
    935983    mr_asprintf(fname, "%s1", bkpinfo->media_device);
    936984    if (is_this_device_mounted(fname)) {
     
    9841032#endif
    9851033    {
    986         log_to_screen("%s failed; unable to unmount USB device\n", tmp1);
     1034        mr_asprintf(tmp, "%s failed; unable to unmount USB device\n", tmp1);
     1035        log_to_screen(tmp);
     1036        paranoid_free(tmp);
    9871037        retval++;
    9881038    } else {
    9891039        log_msg(2, "OK, I've unmounted the USB device\n");
    9901040    }
    991     mr_free(tmp1);
    992     mr_free(mountpoint);
     1041    paranoid_free(tmp1);
     1042    paranoid_free(mountpoint);
    9931043    return (retval);
    9941044}
     
    10161066
    10171067    /*@ buffers ******************************************************** */
    1018     char *mountpoint = NULL;
    1019     char *command = NULL;
    1020     char *tmp = NULL;
    1021     char *fname = NULL;
     1068    char *mountpoint;
     1069    char *command;
     1070    char *tmp;
     1071    char *fname;
    10221072#ifdef __FreeBSD__
    10231073    char mdd[32];
     
    10291079#endif
    10301080
     1081    command = malloc(2000);
     1082    malloc_string(mountpoint);
     1083    malloc_string(tmp);
     1084    malloc_string(fname);
     1085
    10311086    assert(bkpinfo != NULL);
    10321087
    1033     if (bkpinfo->media_device == NULL) {
    1034         return(1);
    1035     }
    1036 
    1037     mr_asprintf(mountpoint, "%s/cdrom", bkpinfo->tmpdir);
    1038     if (((bkpinfo->isodir == NULL) && (bkpinfo->netfs_remote_dir == NULL)) || (bkpinfo->prefix == NULL)) {
    1039         fatal_error("No iso filename preparation possible");
    1040     }
    1041     if (bkpinfo->netfs_remote_dir) {
    1042         // NETFS
    1043         mr_asprintf(fname, "%s/%s/%s-%d.iso", bkpinfo->isodir, bkpinfo->netfs_remote_dir, bkpinfo->prefix, g_current_media_number);
    1044     } else {
    1045         // ISO
    1046         mr_asprintf(fname, "%s/%s-%d.iso", bkpinfo->isodir, bkpinfo->prefix, g_current_media_number);
    1047     }
     1088    sprintf(mountpoint, "%s/cdrom", bkpinfo->tmpdir);
     1089    sprintf(fname, "%s/%s/%s-%d.iso", bkpinfo->isodir, bkpinfo->netfs_remote_dir,
     1090            bkpinfo->prefix, g_current_media_number);
    10481091
    10491092    mkdir(mountpoint, 1777);
    10501093    sync();
    10511094    if (!does_file_exist(fname)) {
    1052         log_msg(2, "%s not found; assuming you backed up to CD; verifying CD...", fname);
     1095        sprintf(tmp,
     1096                "%s not found; assuming you backed up to CD; verifying CD...",
     1097                fname);
     1098        log_msg(2, tmp);
    10531099        if (bkpinfo->manual_cd_tray) {
    10541100            popup_and_OK("Please push CD tray closed.");
     
    10561102        if (find_and_mount_actual_cd(mountpoint)) {
    10571103            log_to_screen("failed to mount actual CD");
    1058             mr_free(mountpoint);
    1059             mr_free(fname);
    10601104            return (1);
    10611105        }
    10621106    } else {
    1063         log_msg(2, "%s found; verifying ISO...", fname);
     1107        sprintf(tmp, "%s found; verifying ISO...", fname);
    10641108#ifdef __FreeBSD__
    10651109        ret = 0;
     
    10671111        mddevice = make_vn(fname);
    10681112        if (ret) {
    1069             log_to_screen("make_vn of %s failed; unable to verify ISO\n", fname);
    1070             mr_free(mountpoint);
    1071             mr_free(fname);
     1113            sprintf(tmp, "make_vn of %s failed; unable to verify ISO\n",
     1114                    fname);
     1115            log_to_screen(tmp);
    10721116            return (1);
    10731117        }
    1074         mr_asprintf(command, "mount_cd9660 %s %s", mddevice, mountpoint);
     1118        sprintf(command, "mount_cd9660 %s %s", mddevice, mountpoint);
    10751119#else
    1076         mr_asprintf(command, "mount -o loop,ro -t iso9660 %s %s", fname, mountpoint);
     1120        sprintf(command, "mount -o loop,ro -t iso9660 %s %s", fname,
     1121                mountpoint);
    10771122#endif
    10781123        if (run_program_and_log_output(command, FALSE)) {
    1079             log_to_screen("%s failed; unable to mount ISO image\n", command);
    1080             mr_free(mountpoint);
    1081             mr_free(command);
    1082             mr_free(fname);
     1124            sprintf(tmp, "%s failed; unable to mount ISO image\n",
     1125                    command);
     1126            log_to_screen(tmp);
    10831127            return (1);
    10841128        }
    1085         mr_free(command);
    10861129    }
    10871130    log_msg(2, "OK, I've mounted the ISO/CD\n");
    1088     mr_asprintf(tmp, "%s/archives/NOT-THE-LAST", mountpoint);
     1131    sprintf(tmp, "%s/archives/NOT-THE-LAST", mountpoint);
    10891132    if (!does_file_exist(tmp)) {
    10901133        log_msg
     
    10981141*/
    10991142    }
    1100     mr_free(tmp);
    1101 
    11021143    verify_afioballs_on_CD(mountpoint);
    11031144    log_it("before verify_all_slices");
     
    11061147#ifdef __FreeBSD__
    11071148    ret = 0;
    1108     mr_asprintf(command, "umount -d %s", mountpoint);
     1149    sprintf(command, "umount -d %s", mountpoint);
    11091150    ret += system(command);
    11101151    ret += kick_vn(mddevice);
    1111     if (ret) {
     1152    if (ret)
    11121153#else
    1113     mr_asprintf(command, "umount -d %s", mountpoint);
    1114     if (system(command)) {
     1154    sprintf(command, "umount -d %s", mountpoint);
     1155    if (system(command))
    11151156#endif
    1116         log_to_screen("%s failed; unable to unmount ISO image\n", command);
    1117 
     1157    {
     1158        sprintf(tmp, "%s failed; unable to unmount ISO image\n", command);
     1159        log_to_screen(tmp);
    11181160        retval++;
    11191161    } else {
    11201162        log_msg(2, "OK, I've unmounted the ISO file\n");
    11211163    }
    1122     mr_free(mountpoint);
    1123     mr_free(command);
    1124 
    11251164    if (!does_file_exist(fname)) {
    1126         mr_asprintf(command, "umount -d %s", bkpinfo->media_device);
     1165        sprintf(command, "umount -d %s", bkpinfo->media_device);
    11271166        run_program_and_log_output(command, 2);
    1128         mr_free(command);
    1129 
    1130         if (!bkpinfo->please_dont_eject && eject_device(bkpinfo->media_device)) {
     1167        if (!bkpinfo->please_dont_eject
     1168            && eject_device(bkpinfo->media_device)) {
    11311169            log_msg(2, "Failed to eject CD-ROM drive");
    11321170        }
    11331171    }
    1134     mr_free(fname);
     1172    paranoid_free(command);
     1173    paranoid_free(mountpoint);
     1174    paranoid_free(tmp);
     1175    paranoid_free(fname);
    11351176    return (retval);
    11361177}
     
    11501191
    11511192    /*@ buffers ******************************************************** */
    1152     char *tmp = NULL;
    1153     char *changed_files_fname = NULL;
     1193    char tmp[MAX_STR_LEN];
     1194    char changed_files_fname[MAX_STR_LEN];
    11541195
    11551196    /*@ long *********************************************************** */
     
    11651206    retval += verify_biggiefiles_from_stream();
    11661207/* find the final blocks */
    1167     sync();
     1208    paranoid_system("sync");
    11681209    sleep(2);
    11691210    closein_tape();
    11701211/* close tape; exit */
    11711212//  fclose(g_tape_stream); <-- not needed; is handled by closein_tape()
    1172     mr_asprintf(tmp, "rm -f %s/biggies.changed %s/changed.files 2> /dev/null", bkpinfo->tmpdir, bkpinfo->tmpdir);
     1213    sprintf(tmp, "rm -f %s/biggies.changed %s/changed.files 2> /dev/null", bkpinfo->tmpdir, bkpinfo->tmpdir);
    11731214    paranoid_system(tmp);
    1174     mr_free(tmp);
    1175 
    1176     mr_asprintf(changed_files_fname, "%s/changed.files", bkpinfo->tmpdir);
    1177     mr_asprintf(tmp, "grep -E '^%s:.*$' %s | cut -d'\"' -f2 | sort -u | awk '{print \"/\"$0;};' | tr -s '/' '/' | grep -v \"(total of\" | grep -v \"incheckentry.*xwait\" | grep -vE '^/afio:.*$' | grep -vE '^dev/.*$'  > %s", (bkpinfo->use_star) ? "star" : "afio", MONDO_LOGFILE, changed_files_fname);
     1215    sprintf(changed_files_fname, "%s/changed.files", bkpinfo->tmpdir);
     1216    sprintf(tmp,
     1217            "grep -E '^%s:.*$' %s | cut -d'\"' -f2 | sort -u | awk '{print \"/\"$0;};' | tr -s '/' '/' | grep -v \"(total of\" | grep -v \"incheckentry.*xwait\" | grep -vE '^/afio:.*$' | grep -vE '^dev/.*$'  > %s",
     1218            (bkpinfo->use_star) ? "star" : "afio", MONDO_LOGFILE,
     1219            changed_files_fname);
    11781220    log_msg(2, "Running command to derive list of changed files");
    11791221    log_msg(2, tmp);
    11801222    if (system(tmp)) {
    1181         if (does_file_exist(changed_files_fname) && length_of_file(changed_files_fname) > 2) {
    1182             log_to_screen("Warning - unable to check logfile to derive list of changed files");
     1223        if (does_file_exist(changed_files_fname)
     1224            && length_of_file(changed_files_fname) > 2) {
     1225            log_to_screen
     1226                ("Warning - unable to check logfile to derive list of changed files");
    11831227        } else {
    1184             log_to_screen("No differences found. Therefore, no 'changed.files' text file.");
    1185         }
    1186     }
    1187     mr_free(tmp);
    1188 
    1189     mr_asprintf(tmp, "cat %s/biggies.changed >> %s", bkpinfo->tmpdir, changed_files_fname);
     1228            log_to_screen
     1229                ("No differences found. Therefore, no 'changed.files' text file.");
     1230        }
     1231    }
     1232    sprintf(tmp, "cat %s/biggies.changed >> %s", bkpinfo->tmpdir, changed_files_fname);
    11901233    paranoid_system(tmp);
    1191     mr_free(tmp);
    11921234
    11931235    diffs = count_lines_in_file(changed_files_fname);
    11941236    if (diffs > 0) {
    1195         mr_asprintf(tmp, "cp -f %s %s/changed.files", changed_files_fname, MONDO_CACHE);
     1237        sprintf(tmp, "cp -f %s %s/changed.files", changed_files_fname,
     1238                MONDO_CACHE);
    11961239        run_program_and_log_output(tmp, FALSE);
    1197         mr_free(tmp);
    1198 
    1199         log_msg(0, "%ld files differed from live filesystem; type less %s or less %s/changed.files to see", diffs, changed_files_fname, MONDO_CACHE);
     1240        sprintf(tmp,
     1241                "%ld files differed from live filesystem; type less %s or less %s/changed.files to see",
     1242                diffs, changed_files_fname, MONDO_CACHE);
     1243        log_msg(0, tmp);
    12001244        log_to_screen("See "MONDO_CACHE"/changed.files for a list of nonmatching files.");
    12011245        log_to_screen("The files probably changed on filesystem, not on backup media.");
    1202     }
    1203     mr_free(changed_files_fname);
     1246        //      retval++;
     1247    }
    12041248    return (retval);
    12051249}
  • branches/3.0/mondo/src/common/mondostructures.h

    r3188 r3192  
    412412    bool use_gzip;
    413413
    414 /**
    415    * If TRUE, then use @c lzma to compress data.
    416    * This is used mainly in estimates. The backup/restore may or may
    417    * not work if you do not set this. You should also set @p zip_exe
    418    * and @p zip_suffix.
    419    */
    420     bool use_lzma;
     414  /**
     415   * A filename containing a list of extensions, one per line, to not
     416   * compress. If this is set to "", afio will still exclude a set of well-known
     417   * compressed files from compression, but biggiefiles that are compressed
     418   * will be recompressed again.
     419   */
     420    char do_not_compress_these[MAX_STR_LEN / 2];
    421421
    422422  /**
     
    492492   */
    493493    t_bkptype backup_media_type;
     494//  bool blank_dvd_first;
    494495
    495496  /**
     
    505506   * If you do nothing, "/" will be used.
    506507   */
    507     char *include_paths;
     508    char include_paths[MAX_STR_LEN*4];
    508509
    509510  /**
     
    559560   * address form. (Domain names will be resolved in post_param_configuration().)
    560561   */
    561     char *netfs_mount;
     562    char netfs_mount[MAX_STR_LEN];
    562563
    563564  /**
     
    565566   * the backups in.
    566567   */
    567     char *netfs_remote_dir;
     568    char netfs_remote_dir[MAX_STR_LEN];
    568569
    569570  /**
     
    673674   */
    674675    bool expanded;
     676};
     677
     678
     679
     680/**
     681 * A structure to wrap a FIFO device for writing to a tape/CD stream.
     682 * @bug Is this structure used (w/the move to a standalone @c buffer and all)?
     683 */
     684struct s_wrapfifo {
     685        /**
     686     * The device we write to or read from (a FIFO).
     687     */
     688    char public_device[MAX_STR_LEN / 4];
     689
     690        /**
     691     * The actual device that data from the FIFO should be buffered and written to.
     692     */
     693    char private_device[MAX_STR_LEN / 4];
     694
     695        /**
     696     * A buffer for holding data read from the FIFO.
     697     */
     698    char internal_buffer_IN_fifo[MAX_STR_LEN / 4];
     699
     700        /**
     701     * A buffer for holding data to be written to the FIFO.
     702     */
     703    char internal_buffer_OUT_fifo[MAX_STR_LEN / 4];
     704
     705        /**
     706     * If TRUE, then we're writing directly to the tape streamer; if FALSE, we're writing to the FIFO.
     707     */
     708    bool writing_to_private_device;
    675709};
    676710
  • branches/3.0/mondo/src/common/newt-specific.c

    r3188 r3192  
    9797    extern int g_current_media_number;
    9898    pid_t g_main_pid = 0;       ///< The PID of the main Mondo process.
    99     long g_maximum_progress = 999L; ///< The maximum amount of progress (100%) for the currently opened progress form.
     99    long g_maximum_progress = 999;  ///< The maximum amount of progress (100%) for the currently opened progress form.
    100100    long g_current_progress = -999; ///< The current amount of progress (filelist #, etc.) for the currently opened progress form.
    101     long g_start_time = 0L;     ///< The time (in seconds since the epoch) that the progress form was opened.
     101    long g_start_time = 0;      ///< The time (in seconds since the epoch) that the progress form was opened.
    102102    bool g_text_mode = TRUE;    ///< If FALSE, use a newt interface; if TRUE, use an ugly (but more compatible) dumb terminal interface.
     103    char g_xmondo_stdin[MAX_NEWT_COMMENT_LEN],  ///< ... @bug Unneeded w/current XMondo.
     104     g_xmondo_stdout[MAX_NEWT_COMMENT_LEN]; ///< .... @bug Unneeded w/current XMondo.
     105    bool g_called_by_xmondo = FALSE;    ///< @bug Unneeded w/current XMondo.
    103106    char *g_selfmounted_isodir; ///< Holds the NETFS mountpoint if mounted via mondoarchive.
    104107
    105108/* @} - end of globalGroup */
     109
     110//int g_fd_in=-1, g_fd_out=-1;
    106111
    107112    void popup_and_OK(char *);
     
    120125
    121126        /*@ buffers ********************************************************** */
    122         int i = 0;
    123         char *tmp = NULL;
     127        int i;
     128        char *p;
    124129
    125130        assert_string_is_neither_NULL_nor_zerolength(prompt);
     
    131136        }
    132137        if (g_text_mode) {
     138
     139            char *tmp;
     140            tmp = malloc(MAX_NEWT_COMMENT_LEN);
     141
    133142            while (1) {
    134                 sync();
    135                 printf("---promptdialogYN---1--- %s\n---promptdialogYN---Q--- [yes] [no] ---\n--> ", prompt);
    136                 mr_getline(tmp, stdin);
     143                paranoid_system("sync");
     144                printf
     145                    ("---promptdialogYN---1--- %s\n---promptdialogYN---Q--- [yes] [no] ---\n--> ",
     146                     prompt);
     147                p= fgets(tmp, MAX_NEWT_COMMENT_LEN, stdin);
     148                if (!p) {
     149                    //FIXME
     150                }
    137151                if (tmp[strlen(tmp) - 1] == '\n')
    138152                    tmp[strlen(tmp) - 1] = '\0';
     
    143157                }
    144158                if (strstr("yesYES", tmp)) {
    145                     mr_free(tmp);
     159                    paranoid_free(tmp);
    146160                    return (TRUE);
    147161                } else if (strstr("NOno", tmp)) {
    148                     mr_free(tmp);
     162                    paranoid_free(tmp);
    149163                    return (FALSE);
    150164                } else {
    151                     sync();
    152                     printf("Please enter either YES or NO (or yes or no, or y or n, or...)\n");
     165                    paranoid_system("sync");
     166                    printf
     167                        ("Please enter either YES or NO (or yes or no, or y or n, or...)\n");
    153168                }
    154169            }
     
    168183
    169184        /*@ buffer *********************************************************** */
    170         char *tmp = NULL;
     185        char *tmp;
     186        char *p;
    171187        int i;
    172188
     
    177193            finish(1);
    178194        }
    179 
     195        tmp = malloc(MAX_NEWT_COMMENT_LEN);
    180196        if (g_text_mode) {
    181             sync();
    182             printf("---promptdialogOKC---1--- %s\n---promptdialogOKC---Q--- [OK] [Cancel] ---\n--> ", prompt);
    183             mr_getline(tmp, stdin);
     197            paranoid_system("sync");
     198            printf
     199                ("---promptdialogOKC---1--- %s\n---promptdialogOKC---Q--- [OK] [Cancel] ---\n--> ",
     200                 prompt);
     201            p = fgets(tmp, MAX_NEWT_COMMENT_LEN, stdin);
     202            if (!p) {
     203                // FIXME
     204            }
    184205            if (tmp[strlen(tmp) - 1] == '\n')
    185206                tmp[strlen(tmp) - 1] = '\0';
     
    190211            }
    191212            if (strstr("okOKOkYESyes", tmp)) {
    192                 mr_free(tmp);
     213                paranoid_free(tmp);
    193214                return (TRUE);
    194215            } else {
    195                 mr_free(tmp);
     216                paranoid_free(tmp);
    196217                return (FALSE);
    197218            }
    198219        } else {
     220            paranoid_free(tmp);
    199221            return (popup_with_buttons(prompt, " Okay ", "Cancel"));
    200222        }
     
    242264        }
    243265        if (g_current_progress == -999) {
    244             log_msg(2, "Trying to close the progress form when it ain't open!");
     266            log_msg(2,
     267                    "Trying to close the progress form when it ain't open!");
    245268            return;
    246269        }
     
    278301        mr_asprintf(tmp1,"kill `%s`", tmp);
    279302        run_program_and_log_output(tmp1, TRUE);
    280         mr_free(tmp1);
    281     }
    282     mr_free(tmp);
     303        paranoid_free(tmp1);
     304    }
     305    paranoid_free(tmp);
    283306}
    284307
     
    289312 * @note This function never returns.
    290313 */
    291 void fatal_error(char *error_string) {
    292 
     314    void
     315     fatal_error(char *error_string) {
    293316        /*@ buffers ***************************************************** */
    294         char *command = NULL;
     317        char fatalstr[MAX_NEWT_COMMENT_LEN] =
     318            "-------FATAL ERROR---------";
     319        char *tmp;
     320        char *command;
    295321        static bool already_exiting = FALSE;
    296322
    297323        /*@ end vars **************************************************** */
    298324
     325        malloc_string(command);
     326        tmp = malloc(MAX_NEWT_COMMENT_LEN);
    299327        set_signals(FALSE);     // link to external func
    300328        g_exiting = TRUE;
     
    304332            log_msg(2, "mastermind %d is exiting", (int) getpid());
    305333            kill(g_main_pid, SIGTERM);
     334            paranoid_free(tmp);
    306335            finish(1);
    307336        }
     
    311340                log_msg(2, "non-m/m %d is exiting", (int) getpid());
    312341                kill(g_main_pid, SIGTERM);
     342                paranoid_free(tmp);
    313343                finish(1);
    314344            }
     
    318348        if (already_exiting) {
    319349            log_msg(3, "...I'm already exiting. Give me time, Julian!");
     350            paranoid_free(tmp);
    320351            finish(1);
    321352        }
     
    328359        kill_anything_like_this("ntfsclone");
    329360        sync();
     361        /*
     362        sprintf(tmp, "umount %s", g_tmpfs_mountpt);
     363        for (i = 0; i < 10 && run_program_and_log_output(tmp, 5); i++) {
     364            log_msg(2, "Waiting for child processes to terminate");
     365            sleep(1);
     366            run_program_and_log_output(tmp, 5);
     367        }
     368        */
    330369
    331370        if (chdir("/")) {
     
    333372        }
    334373        if (g_selfmounted_isodir) {
    335             mr_asprintf(command, "umount -d %s", g_selfmounted_isodir);
     374            sprintf(command, "umount -d %s", g_selfmounted_isodir);
    336375            run_program_and_log_output(command, 5);
    337             mr_free(command);
    338             mr_asprintf(command, "rmdir %s", g_selfmounted_isodir);
     376            sprintf(command, "rmdir %s", g_selfmounted_isodir);
    339377            run_program_and_log_output(command, 5);
    340             mr_free(command);
    341378        }
    342379
    343380        if (!g_text_mode) {
    344             log_msg(0, "-------FATAL ERROR---------");
     381            log_msg(0, fatalstr);
    345382            log_msg(0, error_string);
     383            //      popup_and_OK (error_string);
     384            newtFinished();
    346385        }
    347386
    348387        printf("---FATALERROR--- %s\n", error_string);
    349         printf("If you require technical support, please contact the mailing list.\n");
     388        printf
     389                ("If you require technical support, please contact the mailing list.\n");
    350390        printf("See http://www.mondorescue.org for details.\n");
    351         printf("The list's members can help you, if you attach that file to your e-mail.\n");
     391        printf
     392                ("The list's members can help you, if you attach that file to your e-mail.\n");
    352393        printf("Log file: %s\n", MONDO_LOGFILE);
    353394        printf("Mondo has aborted.\n");
     
    355396            log_msg(3, "FYI - g_main_pid is blank");
    356397        }
     398        paranoid_free(tmp);
     399        paranoid_free(command);
    357400        finish(254);
    358401    }
     
    377420 * @note This function never returns.
    378421 */
    379 void finish(int signal) {
    380 
     422    void
     423     finish(int signal) {
    381424        char *command = NULL;
     425
     426        /*  if (signal==0) { popup_and_OK("Please press <enter> to quit."); } */
     427
     428        /* newtPopHelpLine(); */
    382429
    383430        /*  Before removing dir, make sure we're out of them */
     
    389436            mr_asprintf(command, "umount -d %s", g_selfmounted_isodir);
    390437            run_program_and_log_output(command, 1);
    391             mr_free(command);
    392 
     438            paranoid_free(command);
    393439            mr_asprintf(command, "rmdir %s", g_selfmounted_isodir);
    394440            run_program_and_log_output(command, 1);
    395             mr_free(command);
    396         }
     441            paranoid_free(command);
     442        }
     443        if (!g_text_mode) {
     444            if (does_file_exist("/THIS-IS-A-RAMDISK")) {
     445                log_msg(1, "Calling newtFinished()");
     446                newtFinished();
     447            } else {
     448                log_msg(1, "Calling newtSuspend()");
     449                newtSuspend();
     450            }
     451        }
     452        printf("Execution run ended; result=%d\n", signal);
     453        printf("Type 'less %s' to see the output log\n", MONDO_LOGFILE);
    397454        if (bkpinfo->tmpdir) {
    398455            log_msg(8,"tempdir is %s",bkpinfo->tmpdir);
     
    419476        mr_free(bkpinfo->exclude_paths);
    420477        mr_free(bkpinfo->subdir);
     478
    421479        /* Then free the structure */
    422480        paranoid_free(bkpinfo);
    423 
    424481        free_libmondo_global_strings();
    425482        free_newt_stuff();
    426         if (!g_text_mode) {
    427             if (does_file_exist("/THIS-IS-A-RAMDISK")) {
    428                 log_msg(1, "Calling newtFinished()");
    429                 newtFinished();
    430             } else {
    431                 log_msg(1, "Calling newtSuspend()");
    432                 newtSuspend();
    433             }
    434         }
    435         printf("Execution run ended; result=%d\n", signal);
    436         printf("Type 'less %s' to see the output log\n", MONDO_LOGFILE);
    437483        exit(signal);
    438484    }
     485
     486
     487
    439488
    440489
     
    445494 * @param grep_for_me If not "", then only give lines in @p filename that match this regular expression.
    446495 */
    447 void log_file_end_to_screen(char *filename, char *grep_for_me) {
     496    void
     497     log_file_end_to_screen(char *filename, char *grep_for_me) {
    448498
    449499        /*@ buffers ********************************************************** */
     
    465515        }
    466516        if (grep_for_me[0] != '\0') {
    467             mr_asprintf(command, "grep '%s' %s | tail -n%d", grep_for_me, filename, g_noof_log_lines);
    468         } else {
    469             mr_asprintf(command, "tail -n%d %s", g_noof_log_lines, filename);
     517            mr_asprintf(command, "grep '%s' %s | tail -n%d",
     518                    grep_for_me, filename, g_noof_log_lines);
     519        } else {
     520            mr_asprintf(command, "tail -n%d %s", g_noof_log_lines,
     521                    filename);
    470522        }
    471523        fin = popen(command, "r");
     
    505557 * @note The message is also written to the logfile.
    506558 */
    507 void log_to_screen(const char *fmt, ...) {
     559    void
     560     log_to_screen(const char *fmt, ...) {
    508561
    509562        /*@ int ************************************************************** */
     
    561614 * @param output The string to write.
    562615 */
    563 void mvaddstr_and_log_it(int y, int x, char *output) {
    564 
     616    void
     617     mvaddstr_and_log_it(int y, int x, char *output) {
    565618        assert_string_is_neither_NULL_nor_zerolength(output);
    566619        log_msg(0, output);
     
    580633 * @param ttl The title to use for the evalcall form.
    581634 */
    582 void open_evalcall_form(char *ttl) {
     635    void
     636     open_evalcall_form(char *ttl) {
    583637
    584638        /*@ buffers ********************************************************* */
    585         char *tmp = NULL;
     639        char *title;
     640        char *tmp;
    586641
    587642        /*@ initialize ****************************************************** */
    588643        g_isoform_old_progress = -1;
    589644        g_mysterious_dot_counter = 0;
     645        malloc_string(title);
     646        malloc_string(tmp);
    590647
    591648        assert(ttl != NULL);
    592         malloc_string(tmp);
    593         strcpy(g_isoform_header_str, ttl);
     649        strcpy(title, ttl);
     650        strcpy(g_isoform_header_str, title);
     651//  center_string (title, 80);
    594652        if (g_text_mode) {
    595             log_msg(0, ttl);
    596         } else {
    597             strcpy(tmp, ttl);
     653            log_msg(0, title);
     654        } else {
     655            strcpy(tmp, title);
    598656            center_string(tmp, 80);
    599657            newtPushHelpLine(tmp);
     
    606664            g_isoform_header = newtLabel(1, 1, g_isoform_header_str);
    607665            g_isoform_scale = newtScale(3, 3, 34, 100);
    608             newtCenteredWindow(40, 7, ttl);
     666            //      newtOpenWindow (20, 6, 40, 7, title);      // "Please Wait");
     667            newtCenteredWindow(40, 7, title);
    609668            g_isoform_main = newtForm(NULL, NULL, 0);
    610669            g_isoform_timeline = newtLabel(1, 5, "                    ");
     
    618677        update_evalcall_form(0);
    619678        paranoid_free(tmp);
     679        paranoid_free(title);
    620680    }
    621681
     
    631691 * @param max_val The maximum amount of progress (number of filesets, etc.)
    632692 */
    633 void open_progress_form(char *title, char *b1, char *b2, char *b3, long max_val) {
     693    void
     694     open_progress_form(char *title, char *b1, char *b2, char *b3,
     695                        long max_val) {
    634696
    635697        /*@ buffers ********************************************************* */
    636698        char *b1c;
    637         char *blurb1 = NULL;
    638         char *blurb2 = NULL;
    639         char *blurb3 = NULL;
     699        char *blurb1;
     700        char *blurb2;
     701        char *blurb3;
    640702
    641703        /*@ initialize ****************************************************** */
     
    643705
    644706        malloc_string(b1c);
     707        malloc_string(blurb1);
     708        malloc_string(blurb2);
     709        malloc_string(blurb3);
    645710
    646711        assert(title != NULL);
     
    649714        assert(b3 != NULL);
    650715
    651         mr_asprintf(blurb1,  "%s", b1);
    652         mr_asprintf(blurb2,  "%s", b2);
    653         mr_asprintf(blurb3,  "%s", b3);
    654 
     716        strcpy(blurb1, b1);
     717        strcpy(blurb2, b2);
     718        strcpy(blurb3, b3);
    655719        strcpy(b1c, b1);
    656720        center_string(b1c, 80);
     
    673737            g_blurb2 = newtLabel(2, 2, blurb3);
    674738            g_blurb3 = newtLabel(2, 4, blurb2);
     739            //      newtOpenWindow (10, 4, 60, 11, title);
    675740            newtCenteredWindow(60, 11, title);
    676             g_scale = newtScale(3, 6, 54, (long long)g_maximum_progress);
     741            g_scale = newtScale(3, 6, 54, g_maximum_progress);
    677742            g_progressForm = newtForm(NULL, NULL, 0);
    678743            g_percentline = newtLabel(10, 9, "                       ");
    679744            g_timeline = newtLabel(10, 8, "                    ");
    680             newtFormAddComponents(g_progressForm, g_percentline, g_timeline, g_scale, g_blurb1, g_blurb3, g_blurb2, NULL);
     745            newtFormAddComponents(g_progressForm, g_percentline,
     746                                  g_timeline, g_scale, g_blurb1, g_blurb3,
     747                                  g_blurb2, NULL);
    681748            newtPushHelpLine(b1c);
    682749            newtDrawForm(g_progressForm);
     
    685752        update_progress_form_full(blurb1, blurb2, blurb3);
    686753        paranoid_free(b1c);
    687         mr_free(blurb1);
    688         mr_free(blurb2);
    689         mr_free(blurb3);
     754        paranoid_free(blurb1);
     755        paranoid_free(blurb2);
     756        paranoid_free(blurb3);
    690757    }
    691758
     
    694761 * @param prompt The message.
    695762 */
    696 void popup_and_OK(char *prompt) {
    697 
     763    void
     764     popup_and_OK(char *prompt) {
    698765        char ch;
    699766
     
    702769        log_msg(0, prompt);
    703770        if (g_text_mode) {
    704             printf("---promptpopup---1--- %s\n---promptpopup---Q--- [OK] ---\n--> ", prompt);
     771            printf
     772                ("---promptpopup---1--- %s\n---promptpopup---Q--- [OK] ---\n--> ",
     773                 prompt);
    705774            while (((ch = getchar()) != '\n') && (ch != EOF));
    706775        } else {
     
    717786 * @return TRUE if the user pressed OK, FALSE if they pressed Cancel.
    718787 */
    719     bool popup_and_get_string(char *title, char *b, char *output, int maxsize) {
     788    bool popup_and_get_string(char *title, char *b, char *output,
     789                              int maxsize) {
    720790
    721791        /*@ newt ************************************************************ */
     
    731801
    732802        /*@ buffers ********************************************************** */
    733         char *blurb = NULL;
     803        char *blurb;
    734804        char *p;
    735         char *original_contents = NULL;
    736 
     805        char *original_contents;
     806
     807        blurb = malloc(MAX_NEWT_COMMENT_LEN);
     808        original_contents = malloc(MAX_NEWT_COMMENT_LEN);
    737809        assert_string_is_neither_NULL_nor_zerolength(title);
    738810        assert(b != NULL);
     
    740812
    741813        if (g_text_mode) {
    742             printf("---promptstring---1--- %s\n---promptstring---2--- %s\n---promptstring---Q---\n-->  ", title, b);
     814            printf
     815                ("---promptstring---1--- %s\n---promptstring---2--- %s\n---promptstring---Q---\n-->  ",
     816                 title, b);
    743817            p = fgets(output, maxsize, stdin);
    744818            if (!p) {
     
    747821            if (output[strlen(output) - 1] == '\n')
    748822                output[strlen(output) - 1] = '\0';
     823            paranoid_free(blurb);
     824            paranoid_free(original_contents);
    749825            return (TRUE);
    750826        }
    751        
    752         blurb = malloc(MAX_NEWT_COMMENT_LEN);
    753827        strcpy(blurb, b);
    754828        text = newtTextboxReflowed(2, 1, blurb, 48, 5, 5, 0);
    755         mr_asprintf(original_contents, "%s", output);
     829        strcpy(original_contents, output);
    756830        output[0] = '\0';
    757         type_here = newtEntry(2, newtTextboxGetNumLines(text) + 2, original_contents, 50,
     831        type_here =
     832            newtEntry(2, newtTextboxGetNumLines(text) + 2,
     833                      original_contents, 50,
    758834#ifdef __cplusplus
    759835                      0, NEWT_FLAG_RETURNEXIT
     
    764840        b_1 = newtButton(6, newtTextboxGetNumLines(text) + 4, "  OK  ");
    765841        b_2 = newtButton(18, newtTextboxGetNumLines(text) + 4, "Cancel");
     842        //  newtOpenWindow (8, 5, 54, newtTextboxGetNumLines (text) + 9, title);
    766843        newtCenteredWindow(54, newtTextboxGetNumLines(text) + 9, title);
    767844        myForm = newtForm(NULL, NULL, 0);
     
    774851        newtFormDestroy(myForm);
    775852        newtPopWindow();
    776         paranoid_free(blurb);
    777 
    778853        if (b_res == b_2) {
    779854            strcpy(output, original_contents);
    780             mr_free(original_contents);
     855            paranoid_free(blurb);
     856            paranoid_free(original_contents);
    781857            return (FALSE);
    782858        } else {
    783             mr_free(original_contents);
     859            paranoid_free(blurb);
     860            paranoid_free(original_contents);
    784861            return (TRUE);
    785862        }
     
    794871 * @return TRUE if @p button1 was pushed, FALSE otherwise.
    795872 */
    796 bool popup_with_buttons(char *p, char *button1, char *button2) {
     873    bool popup_with_buttons(char *p, char *button1, char *button2) {
    797874
    798875        /*@ buffers *********************************************************** */
    799         char *prompt = NULL;
     876        char *prompt;
     877        char *q;
    800878
    801879        /*@ newt ************************************************************** */
     
    809887        assert(button1 != NULL);
    810888        assert(button2 != NULL);
     889        prompt = malloc(MAX_NEWT_COMMENT_LEN);
    811890        if (g_text_mode) {
    812891            if (strlen(button2) == 0) {
     
    815894                printf("%s (%s or %s) --> ", p, button1, button2);
    816895            }
    817             mr_getline(prompt, stdin);
    818             while (strcmp(prompt, button1) && (strlen(button2) == 0 || strcmp(prompt, button2))) {
     896            for (prompt[0] = '\0';
     897                 strcmp(prompt, button1) && (strlen(button2) == 0
     898                                          || strcmp(prompt, button2));) {
    819899                printf("--> ");
    820                 mr_free(prompt);
    821                 mr_getline(prompt, stdin);
     900                q = fgets(prompt, MAX_NEWT_COMMENT_LEN, stdin);
     901                if (!q) {
     902                    // FIXME
     903                }
    822904            }
    823905            if (!strcmp(prompt, button1)) {
    824                 mr_free(prompt);
     906                paranoid_free(prompt);
    825907                return (TRUE);
    826908            } else {
    827                 mr_free(prompt);
     909                paranoid_free(prompt);
    828910                return (FALSE);
    829911            }
    830912        }
    831913
    832         prompt = malloc(MAX_NEWT_COMMENT_LEN);
    833914        strncpy(prompt, p, MAX_NEWT_COMMENT_LEN - 1);
    834915        prompt[MAX_NEWT_COMMENT_LEN - 1] = '\0';
    835916        text = newtTextboxReflowed(1, 1, prompt, 40, 5, 5, 0);
    836         b_1 = newtButton(20 - ((button2[0] != '\0') ? strlen(button1) + 2 : strlen(button1) / 2), newtTextboxGetNumLines(text) + 3, button1);
     917        b_1 =
     918            newtButton(20 -
     919                       ((button2[0] !=
     920                         '\0') ? strlen(button1) +
     921                        2 : strlen(button1) / 2),
     922                       newtTextboxGetNumLines(text) + 3, button1);
    837923        if (button2[0] != '\0') {
    838             b_2 = newtButton(24, newtTextboxGetNumLines(text) + 3, button2);
     924            b_2 =
     925                newtButton(24, newtTextboxGetNumLines(text) + 3, button2);
    839926        } else {
    840927            b_2 = NULL;
    841928        }
     929        //  newtOpenWindow (25, 5, 46, newtTextboxGetNumLines (text) + 7, "Alert");
    842930        newtCenteredWindow(46, newtTextboxGetNumLines(text) + 7, "Alert");
    843931        myForm = newtForm(NULL, NULL, 0);
     
    865953 * on the screen.
    866954 */
    867 void refresh_log_screen() {
     955    void
     956     refresh_log_screen() {
    868957
    869958        /*@ int *********************************************************** */
     
    892981 * only allocate some memory.
    893982 */
    894 void setup_newt_stuff() {
     983    void
     984     setup_newt_stuff() {
    895985
    896986        /*@ int *********************************************************** */
     
    901991            newtInit();
    902992            newtCls();
    903             newtPushHelpLine("Welcome to Mondo Rescue, by Dev Team and the Internet. All rights reversed.");
     993            newtPushHelpLine
     994                ("Welcome to Mondo Rescue, by Dev Team and the Internet. All rights reversed.");
     995            /*  newtDrawRootText(28,0,"Welcome to Mondo Rescue"); */
    904996            newtDrawRootText(18, 0, WELCOME_STRING);
    905997            newtRefresh();
     
    9081000        }
    9091001
    910         err_log_lines = (char **) mr_malloc(sizeof(char *) * g_noof_log_lines);
     1002        err_log_lines =
     1003            (char **) malloc(sizeof(char *) * g_noof_log_lines);
     1004        if (!err_log_lines) {
     1005            fatal_error("Out of memory");
     1006        }
    9111007
    9121008        for (i = 0; i < g_noof_log_lines; i++) {
    913             err_log_lines[i] = (char *) mr_malloc(MAX_NEWT_COMMENT_LEN);
     1009            err_log_lines[i] = (char *) malloc(MAX_NEWT_COMMENT_LEN);
     1010            if (!err_log_lines[i]) {
     1011                fatal_error("Out of memory");
     1012            }
    9141013        }
    9151014
     
    9251024 * @param denom The denomenator of the ratio.
    9261025 */
    927 void update_evalcall_form_ratio(int num, int denom) {
     1026    void
     1027     update_evalcall_form_ratio(int num, int denom) {
    9281028
    9291029        /*@ long ************************************************************ */
    930         long current_time = 0L;
    931         long time_taken = 0L;
    932         long time_total_est = 0L;
    933         long time_remaining = 0L;
     1030        long current_time = 0;
     1031        long time_taken = 0;
     1032        long time_total_est = 0;
     1033        long time_remaining = 0;
    9341034
    9351035        /*@ buffers ********************************************************** */
    936         char *timeline_str = NULL;
     1036        char *timeline_str;
    9371037        char *pcline_str = NULL;
    9381038        char *taskprogress = NULL;
     
    9431043        int j = 0;
    9441044
     1045        malloc_string(timeline_str);
     1046        timeline_str[0] = '\0';
     1047//  log_it("update_eval_call_form called");
    9451048        if (num * 100 < denom) {
    9461049            percentage = 1;
     
    9551058            time_remaining = time_total_est - time_taken;
    9561059        } else {
    957             time_remaining = 0L;
     1060            time_remaining = 0;
    9581061        }
    9591062        if (!g_text_mode) {
     
    9661069            || percentage > g_isoform_old_progress) {
    9671070            g_isoform_old_progress = percentage;
    968             mr_asprintf(timeline_str, "%2ld:%02ld taken            %2ld:%02ld remaining", (long) time_taken / 60, (long) time_taken % 60, (long) time_remaining / 60, (long) time_remaining % 60);
     1071            sprintf(timeline_str,
     1072                    "%2ld:%02ld taken            %2ld:%02ld remaining",
     1073                    (long) time_taken / 60, (long) time_taken % 60, (long) time_remaining / 60,
     1074                    (long) time_remaining % 60);
    9691075            if (percentage < 3) {
    9701076                mr_asprintf(pcline_str, " Working");
     
    9771083                mr_strcat(pcline_str, " %c", special_dot_char(g_mysterious_dot_counter));
    9781084            } else {
    979                 mr_asprintf(pcline_str, " %3d%% done              %3d%% to go", percentage, 100 - percentage);
     1085                mr_asprintf(pcline_str, " %3d%% done              %3d%% to go",
     1086                        percentage, 100 - percentage);
    9801087            }
    9811088            if (g_text_mode) {
     
    9881095                }
    9891096                if (percentage >= 3) {
    990                     mr_strcat(taskprogress, "] %3d%% done; %2ld:%02ld to go", percentage, (long) time_remaining / 60, (long) time_remaining % 60);
    991                     printf("---evalcall---1--- %s\n", g_isoform_header_str);
     1097                    mr_strcat(taskprogress, "] %3d%% done; %2ld:%02ld to go", percentage,
     1098                            (long) time_remaining / 60, (long) time_remaining % 60);
     1099                    printf("---evalcall---1--- %s\n",
     1100                           g_isoform_header_str);
    9921101                    printf("---evalcall---2--- %s\n", taskprogress);
    9931102                    printf("---evalcall---E---\n");
    9941103                }
    995                 mr_free(taskprogress);
     1104                paranoid_free(taskprogress);
    9961105            } else {
    997                 newtScaleSet(g_isoform_scale, (unsigned long long) percentage);
     1106                newtScaleSet(g_isoform_scale,
     1107                             (unsigned long long) percentage);
    9981108                if (g_isoform_pcline) {
    9991109                    newtLabelSetText(g_isoform_pcline, pcline_str);
     
    10031113                }
    10041114            }
    1005             mr_free(pcline_str);
    1006             mr_free(timeline_str);
     1115            paranoid_free(pcline_str);
    10071116        }
    10081117        if (!g_text_mode) {
     1118//      log_it("refreshing");
    10091119            newtDrawForm(g_isoform_main);
    10101120            newtRefresh();
    10111121        }
     1122        paranoid_free(timeline_str);
    10121123    }
    10131124
     
    10181129 * @param curr The current amount of progress (percentage) in the evalcall form.
    10191130 */
    1020 void update_evalcall_form(int curr) {
    1021 
     1131    void
     1132     update_evalcall_form(int curr) {
    10221133        update_evalcall_form_ratio(curr, 100);
    1023 }
     1134    }
    10241135
    10251136
     
    10301141 * @param blurb3 The new third line of the blurb; use @p g_blurb_str_2 (no, that's not a typo) to keep it the same.
    10311142 */
    1032 void update_progress_form(char *blurb3) {
    1033 
     1143    void
     1144     update_progress_form(char *blurb3) {
     1145        /*  log_it("update_progress_form --- called"); */
    10341146        if (g_current_progress == -999) {
     1147            /* log_it("You're trying to update progress form when it ain't open. Aww, that's OK. I'll let it go. It's a bit naughty but it's a nonfatal error. No prob, Bob."); */
    10351148            return;
    10361149        }
    10371150        strcpy(g_blurb_str_2, blurb3);
    1038         update_progress_form_full(g_blurb_str_1, g_blurb_str_2, g_blurb_str_3);
    1039 }
     1151        update_progress_form_full(g_blurb_str_1, g_blurb_str_2,
     1152                                  g_blurb_str_3);
     1153    }
    10401154
    10411155
     
    10461160 * @param blurb3 The third line of the blurb. Use @p g_blurb_str_2 (no, that's not a typo either) to keep it the same.
    10471161 */
    1048 void update_progress_form_full(char *blurb1, char *blurb2, char *blurb3) {
    1049 
     1162    void
     1163     update_progress_form_full(char *blurb1, char *blurb2, char *blurb3) {
    10501164        /*@ long ***************************************************** */
    10511165        long current_time = 0L;
     
    10591173
    10601174        /*@ buffers *************************************************** */
    1061         char *percentline_str = NULL;
    1062         char *timeline_str = NULL;
     1175        char *percentline_str;
     1176        char *timeline_str;
    10631177        char *taskprogress = NULL;
    1064 
     1178        char *tmp;
     1179
     1180//  log_msg(1, "'%s' '%s' '%s'", blurb1, blurb2, blurb3);
     1181        percentline_str = malloc(MAX_NEWT_COMMENT_LEN);
     1182        timeline_str = malloc(MAX_NEWT_COMMENT_LEN);
     1183        malloc_string(tmp);
    10651184        if (!g_text_mode) {
    10661185            assert(blurb1 != NULL);
     
    10701189        }
    10711190
     1191        percentline_str[0] = '\0';
     1192
    10721193        current_time = get_time();
    10731194        time_taken = current_time - g_start_time;
     
    10761197        } else {
    10771198            if (g_current_progress > g_maximum_progress) {
    1078                 log_msg(0, "update_progress_form_full(%s,%s,%s) --- g_current_progress=%ld; g_maximum_progress=%ld", blurb1, blurb2, blurb3, g_current_progress, g_maximum_progress);
     1199                sprintf(tmp,
     1200                        "update_progress_form_full(%s,%s,%s) --- g_current_progress=%ld; g_maximum_progress=%ld",
     1201                        blurb1, blurb2, blurb3, g_current_progress,
     1202                        g_maximum_progress);
     1203                log_msg(0, tmp);
    10791204                g_current_progress = g_maximum_progress;
    10801205            }
    1081             percentage = (int) ((g_current_progress * 100L) / g_maximum_progress);
     1206            percentage =
     1207                (int) ((g_current_progress * 100L) / g_maximum_progress);
    10821208        }
    10831209        if (percentage < 1) {
     
    10881214        }
    10891215        if (g_current_progress) {
    1090             time_total_est = time_taken * (long) g_maximum_progress / (long) g_current_progress;
     1216            time_total_est =
     1217                time_taken * (long) g_maximum_progress /
     1218                (long) (g_current_progress);
    10911219            time_remaining = time_total_est - time_taken;
    10921220        } else {
     
    10941222        }
    10951223        g_mysterious_dot_counter = (g_mysterious_dot_counter + 1) % 27;
     1224        sprintf(timeline_str,
     1225                "%2ld:%02ld taken               %2ld:%02ld remaining  ",
     1226                (long) time_taken / 60, time_taken % 60, time_remaining / 60,
     1227                time_remaining % 60);
     1228        sprintf(percentline_str, " %3d%% done                 %3d%% to go",
     1229                percentage, 100 - percentage);
     1230
    10961231        if (g_text_mode) {
    10971232            printf("---progress-form---1--- %s\n", blurb1);
     
    11091244                log_msg(2, "percentage = %d", percentage);
    11101245            }
    1111             mr_strcat(taskprogress, "] %3d%% done; %2ld:%02ld to go", percentage, (long) time_remaining / 60, (long) time_remaining % 60);
     1246            mr_strcat(taskprogress, "] %3d%% done; %2ld:%02ld to go", percentage,
     1247                            (long) time_remaining / 60, (long) time_remaining % 60);
    11121248            printf("---progress-form---4--- %s\n", taskprogress);
    11131249            paranoid_free(taskprogress);
    11141250        } else {
    1115             mr_asprintf(timeline_str, "%2ld:%02ld taken               %2ld:%02ld remaining  ", (long) time_taken / 60, (long) time_taken % 60, (long) time_remaining / 60, (long) time_remaining % 60);
    1116             mr_asprintf(percentline_str, " %3d%% done                 %3d%% to go", percentage, 100 - percentage);
    1117 
    11181251            center_string(blurb1, 54);
    11191252            center_string(blurb2, 54);
     
    11321265                newtLabelSetText(g_timeline, timeline_str);
    11331266            }
    1134             mr_free(timeline_str);
    1135 
    11361267            if (g_percentline) {
    11371268                newtLabelSetText(g_percentline, percentline_str);
    11381269            }
    1139             mr_free(percentline_str);
    1140 
    11411270            newtDrawForm(g_progressForm);
    11421271            newtRefresh();
    11431272        }
    1144     }
     1273        paranoid_free(percentline_str);
     1274        paranoid_free(timeline_str);
     1275        paranoid_free(tmp);
     1276    }
     1277
     1278
     1279
     1280
     1281
     1282
     1283
     1284
     1285
     1286
     1287
     1288
    11451289
    11461290
     
    11531297 * @return The backup type chosen, or @c none if the user chose "Exit to shell".
    11541298 */
    1155 t_bkptype which_backup_media_type(bool restoring) {
     1299    t_bkptype which_backup_media_type(bool restoring) {
    11561300
    11571301        /*@ char ************************************************************ */
     
    11601304
    11611305        /*@ newt ************************************************************ */
    1162         char *title_sz = NULL;
    1163         char *minimsg_sz = NULL;
    1164         static t_bkptype possible_bkptypes[] = { none, cdr, cdrw, dvd, tape, cdstream, udev, netfs, iso };
    1165         static char *possible_responses[] = { "none", "cdr", "cdrw", "dvd", "tape", "cdstream", "udev", "netfs", "iso", NULL };
    1166         char *outstr = NULL;
     1306        char *title_sz;
     1307        char *minimsg_sz;
     1308        static t_bkptype possible_bkptypes[] =
     1309            { none, cdr, cdrw, dvd, tape, cdstream, udev, netfs, iso };
     1310        static char *possible_responses[] =
     1311            { "none", "cdr", "cdrw", "dvd", "tape", "cdstream", "udev",
     1312"netfs", "iso", NULL };
     1313        char *outstr;
     1314        char *p;
    11671315        t_bkptype backup_type;
    11681316        int i;
     
    11791327        newtComponent myForm;
    11801328
     1329        title_sz = malloc(MAX_NEWT_COMMENT_LEN);
     1330        minimsg_sz = malloc(MAX_NEWT_COMMENT_LEN);
     1331        outstr = malloc(MAX_NEWT_COMMENT_LEN);
    11811332        if (g_text_mode) {
    11821333            for (backup_type = none; backup_type == none;) {
     
    11871338                }
    11881339                printf(")\n--> ");
    1189                 mr_getline(outstr, stdin);
    1190                 mr_strip_spaces(outstr);
     1340                p = fgets(outstr, MAX_NEWT_COMMENT_LEN, stdin);
     1341                if (!p) {
     1342                    // FIXME
     1343                }
     1344                strip_spaces(outstr);
    11911345                for (i = 0; possible_responses[i]; i++) {
    11921346                    if (!strcmp(possible_responses[i], outstr)) {
     
    11941348                    }
    11951349                }
    1196                 mr_free(outstr);
    1197             }
     1350            }
     1351            paranoid_free(title_sz);
     1352            paranoid_free(minimsg_sz);
     1353            paranoid_free(outstr);
    11981354            return (backup_type);
    11991355        }
    12001356        newtDrawRootText(18, 0, WELCOME_STRING);
    12011357        if (restoring) {
    1202             mr_asprintf(title_sz, "Please choose the backup media from which you want to read data.");
    1203             mr_asprintf(minimsg_sz, "Read from:");
    1204         } else {
    1205             mr_asprintf(title_sz, "Please choose the backup media to which you want to archive data.");
    1206             mr_asprintf(minimsg_sz, "Backup to:");
     1358            strcpy(title_sz,
     1359                   "Please choose the backup media from which you want to read data.");
     1360            strcpy(minimsg_sz, "Read from:");
     1361        } else {
     1362            strcpy(title_sz,
     1363                   "Please choose the backup media to which you want to archive data.");
     1364            strcpy(minimsg_sz, "Backup to:");
    12071365        }
    12081366        newtPushHelpLine(title_sz);
     1367        //  newtOpenWindow (23, 3, 34, 17, minimsg_sz);
    12091368        newtCenteredWindow(34, 17, minimsg_sz);
    12101369        b1 = newtButton(1, 1, "CD-R disks ");
     
    12401399        }
    12411400        newtPopHelpLine();
    1242         mr_free(title_sz);
    1243         mr_free(minimsg_sz);
     1401        paranoid_free(title_sz);
     1402        paranoid_free(minimsg_sz);
     1403        paranoid_free(outstr);
    12441404        return (output);
    12451405    }
     
    12631423        newtComponent b2;
    12641424        newtComponent b3;
    1265         newtComponent b4;
     1425        //newtComponent b4;
    12661426        newtComponent b5;
    12671427        newtComponent b_res;
     
    12751435        b2 = newtButton(18, 1, "gzip");
    12761436        b3 = newtButton(4, 5, "lzo");
    1277         b4 = newtButton(18, 5, "lzma");
     1437        //b4 = newtButton(18, 5, "lzma");
    12781438        b5 = newtButton(4, 9, "         Exit        ");
    12791439        myForm = newtForm(NULL, NULL, 0);
     
    12881448        } else if (b_res == b3) {
    12891449            mr_asprintf(output, "%s", "lzo");
    1290         } else if (b_res == b4) {
    1291             mr_asprintf(output, "%s", "lzma");
     1450        //} else if (b_res == b4) {
     1451            //mr_asprintf(output, "%s", "lzma");
    12921452        }
    12931453        newtPopHelpLine();
     
    13011461 * @return The compression level (0-9) chosen, or -1 for "Exit".
    13021462 */
    1303 int which_compression_level() {
     1463    int
     1464     which_compression_level() {
    13041465
    13051466        /*@ char ************************************************************ */
     
    13181479
    13191480        newtDrawRootText(18, 0, WELCOME_STRING);
    1320         newtPushHelpLine("   Please specify the level of compression that you want.");
     1481        newtPushHelpLine
     1482            ("   Please specify the level of compression that you want.");
     1483        //  newtOpenWindow (23, 3, 34, 13, "How much compression?");
    13211484        newtCenteredWindow(34, 13, "How much compression?");
    13221485        b1 = newtButton(4, 1, "Maximum (9)");
     
    13551518 * @param source_file The file containing a list of filenames to load into @p filelist.
    13561519 */
    1357 int load_filelist_into_array(struct s_filelist *filelist, char *source_file) {
    1358 
     1520    int load_filelist_into_array(struct s_filelist *filelist,
     1521                                 char *source_file) {
    13591522        int i;
    13601523        int j = 0;
    13611524        bool done;
    1362         char *tmp = NULL;
     1525        char *tmp;
     1526        char *p;
    13631527        char *tmp1 = NULL;
    13641528        FILE *fin, *fout;
     
    13791543        if (!(fout = fopen(tmp1, "a"))) {
    13801544            log_msg(2, "Can't write to %s", tmp1);
    1381             mr_free(tmp1);
    13821545            return(1);
    13831546            }
    13841547
     1548        malloc_string(tmp);
    13851549        log_msg(2, "Loading %s", source_file);
    1386         for (filelist->entries = 0; filelist->entries <= ARBITRARY_MAXIMUM; ) {
    1387             mr_free(tmp);
     1550        for (filelist->entries = 0; filelist->entries <= ARBITRARY_MAXIMUM;
     1551             filelist->entries++) {
     1552          god_i_hate_gotos:
    13881553            if (feof(fin)) {
    13891554                break;
    13901555            }
    1391             mr_getline(tmp, fin);
     1556            p = fgets(tmp, MAX_NEWT_COMMENT_LEN, fin);
     1557            if (!p) {
     1558                // FIXME
     1559            }
    13921560            i = (int) strlen(tmp);
    13931561            if (i < 2) {
    1394                 continue;
     1562                goto god_i_hate_gotos;
    13951563            }
    13961564            if (tmp[i - 1] < 32) {
     
    13981566            }
    13991567            if (i < 2) {
    1400                 continue;
     1568                goto god_i_hate_gotos;
    14011569            }
    14021570            if (!does_file_exist(tmp) && !feof(fin)) {
    14031571                j++;
    14041572                fprintf(fout, "%s\n", tmp);
    1405                 continue;
    1406             }
    1407             filelist->el[filelist->entries].severity = severity_of_difference(tmp, NULL);
     1573
     1574                goto god_i_hate_gotos;
     1575            }
     1576            filelist->el[filelist->entries].severity =
     1577                severity_of_difference(tmp, NULL);
    14081578            strcpy(filelist->el[filelist->entries].filename, tmp);
    14091579            if (feof(fin)) {
    14101580                break;
    14111581            }
    1412             filelist->entries++;
    1413         }
    1414         mr_free(tmp);
     1582        }
    14151583        paranoid_fclose(fin);
    14161584        paranoid_fclose(fout);
     
    14181586            log_to_screen("%d files listed in %s/changed.files have been deleted since backup was made\nand are referenced in %s", j, bkpinfo->tmpdir,tmp1);
    14191587        }
    1420         mr_free(tmp1);
     1588        paranoid_free(tmp1);
    14211589        if (filelist->entries >= ARBITRARY_MAXIMUM) {
    14221590            log_to_screen("Arbitrary limits suck, man!");
     1591            paranoid_free(tmp);
    14231592            return (1);
    14241593        }
     
    14481617            }
    14491618        }
     1619        paranoid_free(tmp);
    14501620        log_it("leaving");
    14511621        return (0);
    14521622    }
     1623
    14531624
    14541625
     
    14591630 * @note The returned value points to static storage that will be overwritten with each call.
    14601631 */
    1461 char *filelist_entry_to_string(struct s_filelist_entry *flentry) {
     1632    char *filelist_entry_to_string(struct s_filelist_entry *flentry) {
    14621633        static char comment[100];
    14631634        char *tmp = NULL;
    14641635
    1465         log_msg(8, "entering");
     1636        log_it("entering");
    14661637        assert(flentry != NULL);
    14671638        if (flentry->severity == 0) {
     
    14771648        mr_strcat(tmp, flentry->filename);
    14781649        strncpy(comment, tmp, 99);
    1479         mr_free(tmp);
     1650        paranoid_free(tmp);
    14801651
    14811652        log_it("leaving");
    14821653        return (comment);
    14831654    }
     1655
     1656
     1657
    14841658
    14851659
     
    14891663 * @param source_file The file containing a list of changed files.
    14901664 */
    1491 void popup_changelist_from_file(char *source_file) {
    1492 
    1493         char *reason = NULL;
     1665    void popup_changelist_from_file(char *source_file) {
     1666        char *reason;
    14941667        newtComponent myForm;
    14951668        newtComponent bClose;
     
    15121685
    15131686        /*@ buffers ********************************************************* */
    1514         char *tmp = NULL;
    1515         char *differ_sz = NULL;
     1687        char *tmp;
     1688        char *differ_sz;
    15161689
    15171690        struct s_filelist *filelist;
     1691        malloc_string(reason);
     1692        tmp = malloc(5000);
     1693        malloc_string(differ_sz);
    15181694        assert_string_is_neither_NULL_nor_zerolength(source_file);
    15191695        if (g_text_mode) {
    15201696            log_msg(2, "Text mode. Therefore, no popup list.");
    1521             return;
     1697            goto free_to_go;
    15221698        }
    15231699        log_msg(2, "Examining file %s", source_file);
     
    15261702        if (lng < 1) {
    15271703            log_msg(2, "No lines in file. Therefore, no popup list.");
    1528             return;
     1704            paranoid_free(reason);
     1705            goto free_to_go;
    15291706        } else if (lng >= ARBITRARY_MAXIMUM) {
    15301707            log_msg(2, "Too many files differ for me to list.");
    1531             return;
     1708            goto free_to_go;
    15321709        }
    15331710
     
    15381715
    15391716        if (load_filelist_into_array(filelist, source_file)) {
    1540             log_msg(2, "Can't open %s; therefore, cannot popup list", source_file);
     1717            log_msg(2, "Can't open %s; therefore, cannot popup list",
     1718                    source_file);
     1719            paranoid_free(reason);
    15411720            return;
    15421721        }
    1543         log_msg(2, "%d files loaded into filelist array", filelist->entries);
     1722        log_msg(2, "%d files loaded into filelist array",
     1723                filelist->entries);
    15441724        for (i = 0; i < filelist->entries; i++) {
    15451725            keylist[i] = (void *) i;
     
    15501730                                   keylist[i]);
    15511731        }
    1552         mr_asprintf(differ_sz, "  %ld files differ. Hit 'Select' to pick a file. Hit 'Close' to quit the list.", i);
     1732        sprintf(differ_sz,
     1733                "  %ld files differ. Hit 'Select' to pick a file. Hit 'Close' to quit the list.",
     1734                i);
    15531735        newtPushHelpLine(differ_sz);
    1554         mr_free(differ_sz);
    1555 
    15561736        bClose = newtCompactButton(10, 15, " Close  ");
    15571737        bSelect = newtCompactButton(30, 15, " Select ");
    1558         mr_asprintf(tmp, "%-10s               %-20s", "Priority", "Filename");
     1738        sprintf(tmp, "%-10s               %-20s", "Priority", "Filename");
    15591739        headerMsg = newtLabel(2, 1, tmp);
    1560         mr_free(tmp);
    1561 
    15621740        newtOpenWindow(5, 4, 70, 16, "Non-matching files");
    15631741        myForm = newtForm(NULL, NULL, 0);
    1564         newtFormAddComponents(myForm, headerMsg, fileListbox, bClose, bSelect, NULL);
    1565 
     1742        newtFormAddComponents(myForm, headerMsg, fileListbox, bClose,
     1743                              bSelect, NULL);
    15661744        while (!finished) {
    15671745            b_res = newtRunForm(myForm);
     
    15781756                    currline = i;
    15791757                    if (filelist->entries > 0) {
    1580                         malloc_string(reason);
    1581                         severity_of_difference(filelist->el[currline].  filename, &reason);
    1582                         mr_asprintf(tmp, "%s --- %s", filelist->el[currline].filename, reason);
    1583 
     1758                        severity_of_difference(filelist->el[currline].
     1759                                               filename, reason);
     1760                        sprintf(tmp, "%s --- %s",
     1761                                filelist->el[currline].filename, reason);
    15841762                        popup_and_OK(tmp);
    1585                         mr_free(tmp);
    1586                         paranoid_free(reason);
    15871763                    }
    15881764                }
     
    15921768        newtPopWindow();
    15931769        newtPopHelpLine();
     1770      free_to_go:
     1771        paranoid_free(reason);
     1772        paranoid_free(tmp);
     1773        paranoid_free(differ_sz);
    15941774        return;
    15951775    }
  • branches/3.0/mondo/src/include/my-stuff.h

    r3189 r3192  
    7777 * The location where mindi media images are stored.
    7878 */
    79 #define MINDI_CACHE_REL "var/cache/mindi"   /* Should be coherent with mindi */
    80 #define MINDI_CACHE "/"MINDI_CACHE_REL
     79#define MINDI_CACHE "/var/cache/mindi"
    8180
    8281/**
     
    8988 */
    9089#define MDSTAT_FILE "/proc/mdstat"
    91 
    92 #ifdef __FreeBSD__
    93 #define CMDLINE "/tmp/cmdline"
    94 #else
    95 // Default Linux
    96 #define CMDLINE "/proc/cmdline"
    97 #endif
    9890
    9991#undef assert
  • branches/3.0/mondo/src/lib/mr_err.c

    r3189 r3192  
    1616#include <stdio.h>
    1717#include <stdlib.h>
    18 #include "mr_msg.h"
    1918
    2019/* Pointer to the right cleanup function provided by each main */
    21 extern void (*mr_cleanup)(int);
     20extern void (*mr_cleanup)(void);
    2221
    2322/*
     
    2726
    2827    if (mr_cleanup != NULL) {
    29         mr_cleanup(errorcode);
     28        mr_cleanup();
    3029    }
    3130    if (message != NULL) {
    3231        fprintf(stderr,"%s\n",message);
    3332    }
    34     mr_msg_close();
    3533    exit(errorcode);
    3634}
Note: See TracChangeset for help on using the changeset viewer.