Changeset 900 in MondoRescue for trunk/mondo/src/common/libmondo-archive.c


Ignore:
Timestamp:
Oct 24, 2006, 8:49:18 AM (18 years ago)
Author:
Bruno Cornec
Message:

Huge patch to introduce low level functions that will bw used everywhere (mr_free, mr_asprintf, ...)
Nearly linking now due to that.

File:
1 edited

Legend:

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

    r815 r900  
    99 * This is the main file (at least the longest one) in libmondo.
    1010 */
     11#include <sys/sem.h>
     12#include <sys/types.h>
     13#include <sys/ipc.h>
     14#include <stdarg.h>
     15#include <unistd.h>
    1116
    1217#include "my-stuff.h"
    1318#include "../common/mondostructures.h"
    1419#include "mr_conf.h"
     20#include "mr_mem.h"
     21#include "mr_err.h"
     22
    1523#include "libmondo-string-EXT.h"
    1624#include "libmondo-stream-EXT.h"
     
    2432#include "libmondo-verify-EXT.h"
    2533#include "libmondo-archive.h"
    26 #include <sys/sem.h>
    27 #include <sys/types.h>
    28 #include <sys/ipc.h>
    29 #include <stdarg.h>
    30 #include <unistd.h>
    3134#define DVDRWFORMAT 1
    3235
     
    201204
    202205    if (!does_file_exist(filelist)) {
    203         asprintf(&tmp,
     206        mr_asprintf(&tmp,
    204207                 "(archive_this_fileset) - filelist %s does not exist",
    205208                 filelist);
    206209        log_to_screen(tmp);
    207         paranoid_free(tmp);
     210        mr_free(tmp);
    208211        return (1);
    209212    }
    210213
    211     asprintf(&tmp, "echo hi > %s 2> /dev/null", fname);
     214    mr_asprintf(&tmp, "echo hi > %s 2> /dev/null", fname);
    212215    if (system(tmp)) {
    213216        fatal_error("Unable to write tarball to scratchdir");
    214217    }
    215     paranoid_free(tmp);
    216 
    217     asprintf(&command, "star H=star list=%s -c " STAR_ACL_SZ " file=%s",
     218    mr_free(tmp);
     219
     220    mr_asprintf(&command, "star H=star list=%s -c " STAR_ACL_SZ " file=%s",
    218221             filelist, fname);
    219222    if (bkpinfo->use_lzo) {
     
    221224    }
    222225    if (bkpinfo->compression_level > 0) {
    223         asprintf(&tmp, "%s -bz", command);
    224         paranoid_free(command);
     226        mr_asprintf(&tmp, "%s -bz", command);
     227        mr_free(command);
    225228        command = tmp;
    226229    }
    227     asprintf(&tmp, "%s 2>> %s", command, MONDO_LOGFILE);
    228     paranoid_free(command);
     230    mr_asprintf(&tmp, "%s 2>> %s", command, MONDO_LOGFILE);
     231    mr_free(command);
    229232    command = tmp;
    230233    log_msg(4, "command = '%s'", command);
     
    241244            res = 0;
    242245        }
    243         paranoid_free(tmp);
     246        mr_free(tmp);
    244247        if (res) {
    245248            log_OS_error(command);
     
    256259        }
    257260    }
    258     paranoid_free(command);
     261    mr_free(command);
    259262
    260263    retval += res;
     
    314317
    315318    if (!does_file_exist(filelist)) {
    316         asprintf(&tmp,
     319        mr_asprintf(&tmp,
    317320                 "(archive_this_fileset) - filelist %s does not exist",
    318321                 filelist);
    319322        log_to_screen(tmp);
    320         paranoid_free(tmp)
     323        mr_free(tmp);
    321324            return (1);
    322325    }
    323     asprintf(&tmp, "echo hi > %s 2> /dev/null", fname);
     326    mr_asprintf(&tmp, "echo hi > %s 2> /dev/null", fname);
    324327    if (system(tmp)) {
    325328        fatal_error("Unable to write tarball to scratchdir");
    326329    }
    327     paranoid_free(tmp)
     330    mr_free(tmp);
    328331
    329332
    330333    if (bkpinfo->compression_level > 0) {
    331         asprintf(&tmp, "%s/do-not-compress-these", g_mondo_home);
     334        mr_asprintf(&tmp, "%s/do-not-compress-these", g_mondo_home);
    332335        //       -b %ld, TAPE_BLOCK_SIZE
    333         asprintf(&zipparams, "-Z -P %s -G %d -T 3k", bkpinfo->zip_exe,
     336        mr_asprintf(&zipparams, "-Z -P %s -G %d -T 3k", bkpinfo->zip_exe,
    334337                 bkpinfo->compression_level);
    335338        if (does_file_exist(tmp)) {
    336             asprintf(&tmp1, "%s -E %s", zipparams, tmp);
    337             paranoid_free(zipparams)
     339            mr_asprintf(&tmp1, "%s -E %s", zipparams, tmp);
     340            mr_free(zipparams);
    338341            zipparams = tmp1;
    339342        } else {
    340             asprintf(&zipparams, " ");
     343            mr_asprintf(&zipparams, " ");
    341344            log_msg(3, "%s not found. Cannot exclude zipfiles, etc.", tmp);
    342345        }
    343         paranoid_free(tmp)
     346        mr_free(tmp);
    344347    } else {
    345         asprintf(&zipparams, " ");
     348        mr_asprintf(&zipparams, " ");
    346349    }
    347350
     
    356359        fatal_error("scratchdir not found");
    357360    }
    358     asprintf(&command, "rm -f %s %s. %s.gz %s.%s", fname, fname, fname,
     361    mr_asprintf(&command, "rm -f %s %s. %s.gz %s.%s", fname, fname, fname,
    359362             fname, bkpinfo->zip_suffix);
    360363    paranoid_system(command);
    361     paranoid_free(command);
    362 
    363     asprintf(&command, "afio -o -b %ld -M 16m %s %s < %s 2>> %s",
     364    mr_free(command);
     365
     366    mr_asprintf(&command, "afio -o -b %ld -M 16m %s %s < %s 2>> %s",
    364367             TAPE_BLOCK_SIZE, zipparams, fname, filelist, MONDO_LOGFILE);
    365     paranoid_free(zipparams);
    366 
    367     asprintf(&tmp, "echo hi > %s 2> /dev/null", fname);
     368    mr_free(zipparams);
     369
     370    mr_asprintf(&tmp, "echo hi > %s 2> /dev/null", fname);
    368371    if (system(tmp)) {
    369372        fatal_error("Unable to write tarball to scratchdir");
    370373    }
    371     paranoid_free(tmp);
     374    mr_free(tmp);
    372375
    373376    for (res = 99, tries = 0; tries < 3 && res != 0; tries++) {
     
    382385        }
    383386    }
    384     paranoid_free(command);
     387    mr_free(command);
    385388
    386389    retval += res;
     
    396399                 ("df -m -P | grep dev/shm | grep -v none | tr -s ' ' '\t' | cut -f4");
    397400        i = atoi(tmp);
    398         paranoid_free(tmp);
     401        mr_free(tmp);
    399402
    400403        if (i > 0) {
     
    440443                ("Cannot find dvd+rw-format. Please install it or fix your PATH.");
    441444        }
    442         paranoid_free(tmp);
     445        mr_free(tmp);
    443446#endif
    444447        tmp = find_home_of_exe("growisofs");
     
    447450                ("Cannot find growisofs. Please install it or fix your PATH.");
    448451        }
    449         paranoid_free(tmp);
     452        mr_free(tmp);
    450453    }
    451454
     
    458461
    459462/*
    460       asprintf(&tmp, "wc -l %s/archives/filelist.full > %s/archives/filelist.count",bkpinfo->scratchdir, bkpinfo->scratchdir);
     463      mr_asprintf(&tmp, "wc -l %s/archives/filelist.full > %s/archives/filelist.count",bkpinfo->scratchdir, bkpinfo->scratchdir);
    461464      if (run_program_and_log_output(tmp, 2))
    462465        { fatal_error("Failed to count filelist.full"); }
    463466*/
    464     asprintf(&tmp, "gzip -9 %s/archives/filelist.full",
     467    mr_asprintf(&tmp, "gzip -9 %s/archives/filelist.full",
    465468             bkpinfo->scratchdir);
    466469    if (run_program_and_log_output(tmp, 2)) {
    467470        fatal_error("Failed to gzip filelist.full");
    468471    }
    469     paranoid_free(tmp);
    470     asprintf(&tmp, "cp -f %s/archives/*list*.gz %s", bkpinfo->scratchdir,
     472    mr_free(tmp);
     473    mr_asprintf(&tmp, "cp -f %s/archives/*list*.gz %s", bkpinfo->scratchdir,
    471474             bkpinfo->tmpdir);
    472475    if (run_program_and_log_output(tmp, 2)) {
    473476        fatal_error("Failed to copy to tmpdir");
    474477    }
    475     paranoid_free(tmp);
     478    mr_free(tmp);
    476479
    477480    copy_mondo_and_mindi_stuff_to_scratchdir(bkpinfo);  // payload, too, if it exists
    478481#if __FreeBSD__ == 5
    479     paranoid_alloc(bkpinfo->kernel_path, "/boot/kernel/kernel");
     482    mr_allocstr(bkpinfo->kernel_path, "/boot/kernel/kernel");
    480483#elif __FreeBSD__ == 4
    481     paranoid_alloc(bkpinfo->kernel_path, "/kernel");
     484    mr_allocstr(bkpinfo->kernel_path, "/kernel");
    482485#elif linux
    483486    if (figure_out_kernel_path_interactively_if_necessary
     
    493496    }
    494497    retval += do_that_initial_phase(bkpinfo);   // prepare
    495     asprintf(&tmp, "rm -f %s/images/*.iso", bkpinfo->scratchdir);
     498    mr_asprintf(&tmp, "rm -f %s/images/*.iso", bkpinfo->scratchdir);
    496499    run_program_and_log_output(tmp, 1);
    497     paranoid_free(tmp);
     500    mr_free(tmp);
    498501    retval += make_those_slices_phase(bkpinfo); // backup BIG files
    499502    retval += do_that_final_phase(bkpinfo); // clean up
     
    564567    assert(bkpinfo != NULL);
    565568
    566     asprintf(&tmp,
     569    mr_asprintf(&tmp,
    567570             "echo '%s' | tr -s ' ' '\n' | grep -x '/dev/.*' | tr -s '\n' ' ' | awk '{print $0\"\\n\";}'",
    568571             bkpinfo->exclude_paths);
    569572    devs_to_exclude = call_program_and_get_last_line_of_output(tmp);
    570     paranoid_free(tmp);
    571     asprintf(&tmp, "devs_to_exclude = '%s'", devs_to_exclude);
     573    mr_free(tmp);
     574    mr_asprintf(&tmp, "devs_to_exclude = '%s'", devs_to_exclude);
    572575    log_msg(2, tmp);
    573     paranoid_free(tmp);
     576    mr_free(tmp);
    574577    mvaddstr_and_log_it(g_currentY, 0,
    575578                        "Calling MINDI to create boot+data disks");
    576     asprintf(&tmp, "%s/filelist.full", bkpinfo->tmpdir);
     579    mr_asprintf(&tmp, "%s/filelist.full", bkpinfo->tmpdir);
    577580    if (!does_file_exist(tmp)) {
    578         paranoid_free(tmp);
    579         asprintf(&tmp, "%s/tmpfs/filelist.full", bkpinfo->tmpdir);
     581        mr_free(tmp);
     582        mr_asprintf(&tmp, "%s/tmpfs/filelist.full", bkpinfo->tmpdir);
    580583        if (!does_file_exist(tmp)) {
    581584            fatal_error
     
    584587    }
    585588    lines_in_filelist = count_lines_in_file(tmp);
    586     paranoid_free(tmp);
    587     asprintf(&tmp, "%s/LAST-FILELIST-NUMBER", bkpinfo->tmpdir);
     589    mr_free(tmp);
     590    mr_asprintf(&tmp, "%s/LAST-FILELIST-NUMBER", bkpinfo->tmpdir);
    588591    last_filelist_number = last_line_of_file(tmp);
    589     paranoid_free(tmp);
     592    mr_free(tmp);
    590593    if (IS_THIS_A_STREAMING_BACKUP(bkpinfo->backup_media_type)) {
    591         asprintf(&tape_size_sz, "%ld", bkpinfo->media_size[1]);
    592         asprintf(&tape_device, bkpinfo->media_device);
     594        mr_asprintf(&tape_size_sz, "%ld", bkpinfo->media_size[1]);
     595        mr_asprintf(&tape_device, bkpinfo->media_device);
    593596    } else {
    594         asprintf(&tape_size_sz, " ");
    595         asprintf(&tape_device, " ");
     597        mr_asprintf(&tape_size_sz, " ");
     598        mr_asprintf(&tape_device, " ");
    596599    }
    597600    if (bkpinfo->use_lzo) {
    598         asprintf(&use_lzo_sz, "yes");
     601        mr_asprintf(&use_lzo_sz, "yes");
    599602    } else {
    600         asprintf(&use_lzo_sz, "no");
     603        mr_asprintf(&use_lzo_sz, "no");
    601604    }
    602605    if (bkpinfo->use_star) {
    603         asprintf(&use_star_sz, "yes");
     606        mr_asprintf(&use_star_sz, "yes");
    604607    } else {
    605         asprintf(&use_star_sz, "no");
     608        mr_asprintf(&use_star_sz, "no");
    606609    }
    607610
    608611    if (bkpinfo->compression_level > 0) {
    609         asprintf(&use_comp_sz, "yes");
     612        mr_asprintf(&use_comp_sz, "yes");
    610613    } else {
    611         asprintf(&use_comp_sz, "no");
    612     }
    613 
    614     asprintf(&broken_bios_sz, "yes");   /* assume so */
     614        mr_asprintf(&use_comp_sz, "no");
     615    }
     616
     617    mr_asprintf(&broken_bios_sz, "yes");    /* assume so */
    615618    if (g_cd_recovery) {
    616         asprintf(&cd_recovery_sz, "yes");
     619        mr_asprintf(&cd_recovery_sz, "yes");
    617620    } else {
    618         asprintf(&cd_recovery_sz, "no");
     621        mr_asprintf(&cd_recovery_sz, "no");
    619622    }
    620623    /* Field shared between LILO/ELILO */
    621624    if (bkpinfo->make_cd_use_lilo) {
    622         asprintf(&use_lilo_sz, "yes");
     625        mr_asprintf(&use_lilo_sz, "yes");
    623626    } else {
    624         asprintf(&use_lilo_sz, "no");
     627        mr_asprintf(&use_lilo_sz, "no");
    625628    }
    626629
     
    644647        }
    645648        if ((bootdev) && (strstr(bootdev, "/dev/cciss/"))) {
    646             paranoid_free(bootdev);
     649            mr_free(bootdev);
    647650            bootdev = call_program_and_get_last_line_of_output
    648651                     ("mount | grep ' /boot ' | head -1 | cut -d' ' -f1 | cut -dp -f1");
     
    655658
    656659        if (bkpinfo->boot_loader != '\0') {
    657             asprintf(&tmp, "User specified boot loader. It is '%c'.",
     660            mr_asprintf(&tmp, "User specified boot loader. It is '%c'.",
    658661                     bkpinfo->boot_loader);
    659662            log_msg(2, tmp);
    660             paranoid_free(tmp);
     663            mr_free(tmp);
    661664        } else {
    662665            bkpinfo->boot_loader = ch;
    663666        }
    664667        if (bkpinfo->boot_device != NULL) {
    665             asprintf(&tmp, "User specified boot device. It is '%s'.",
     668            mr_asprintf(&tmp, "User specified boot device. It is '%s'.",
    666669                     bkpinfo->boot_device);
    667670            log_msg(2, tmp);
    668             paranoid_free(tmp);
    669             paranoid_free(bootdev);
     671            mr_free(tmp);
     672            mr_free(bootdev);
    670673        } else {
    671674            bkpinfo->boot_device = bootdev;
     
    687690    }
    688691    if (bkpinfo->boot_loader == 'L') {
    689         asprintf(&bootldr_str, "LILO");
     692        mr_asprintf(&bootldr_str, "LILO");
    690693        if (!does_file_exist("/etc/lilo.conf")) {
    691694            fatal_error
     
    693696        }
    694697    } else if (bkpinfo->boot_loader == 'G') {
    695         asprintf(&bootldr_str, "GRUB");
     698        mr_asprintf(&bootldr_str, "GRUB");
    696699        if (!does_file_exist("/etc/grub.conf")
    697700            && does_file_exist("/boot/grub/grub.conf")) {
     
    710713        }
    711714    } else if (bkpinfo->boot_loader == 'E') {
    712         asprintf(&bootldr_str, "ELILO");
     715        mr_asprintf(&bootldr_str, "ELILO");
    713716        /* BERLIOS: fix it for SuSE, Debian, Mandrake, ... */
    714717        if (!does_file_exist("/etc/elilo.conf")
     
    723726        }
    724727    } else if (bkpinfo->boot_loader == 'R') {
    725         asprintf(&bootldr_str, "RAW");
     728        mr_asprintf(&bootldr_str, "RAW");
    726729    }
    727730#ifdef __FreeBSD__
    728731    else if (bkpinfo->boot_loader == 'D') {
    729         asprintf(&bootldr_str, "DD");
     732        mr_asprintf(&bootldr_str, "DD");
    730733    }
    731734
    732735    else if (bkpinfo->boot_loader == 'B') {
    733         asprintf(&bootldr_str, "BOOT0");
     736        mr_asprintf(&bootldr_str, "BOOT0");
    734737    }
    735738#endif
    736739    else {
    737         asprintf(&bootldr_str, "unknown");
    738     }
    739     asprintf(&tmp, "Your boot loader is %s and it boots from %s",
     740        mr_asprintf(&bootldr_str, "unknown");
     741    }
     742    mr_asprintf(&tmp, "Your boot loader is %s and it boots from %s",
    740743             bootldr_str, bkpinfo->boot_device);
    741744    log_to_screen(tmp);
    742     paranoid_free(tmp);
    743     asprintf(&tmp, "%s/BOOTLOADER.DEVICE", bkpinfo->tmpdir);
     745    mr_free(tmp);
     746    mr_asprintf(&tmp, "%s/BOOTLOADER.DEVICE", bkpinfo->tmpdir);
    744747    if (write_one_liner_data_file(tmp, bkpinfo->boot_device)) {
    745748        log_msg(1, "%ld: Unable to write one-liner boot device", __LINE__);
    746749    }
    747     paranoid_free(tmp);
     750    mr_free(tmp);
    748751    /* BERLIOS: Use bkptype_to_string without LANG */
    749752    switch (bkpinfo->backup_media_type) {
    750753    case cdr:
    751         asprintf(&value, "cdr");
     754        mr_asprintf(&value, "cdr");
    752755        break;
    753756    case cdrw:
    754         asprintf(&value, "cdrw");
     757        mr_asprintf(&value, "cdrw");
    755758        break;
    756759    case cdstream:
    757         asprintf(&value, "cdstream");
     760        mr_asprintf(&value, "cdstream");
    758761        break;
    759762    case tape:
    760         asprintf(&value, "tape");
     763        mr_asprintf(&value, "tape");
    761764        break;
    762765    case udev:
    763         asprintf(&value, "udev");
     766        mr_asprintf(&value, "udev");
    764767        break;
    765768    case iso:
    766         asprintf(&value, "iso");
     769        mr_asprintf(&value, "iso");
    767770        break;
    768771    case nfs:
    769         asprintf(&value, "nfs");
     772        mr_asprintf(&value, "nfs");
    770773        break;
    771774    case dvd:
    772         asprintf(&value, "dvd");
     775        mr_asprintf(&value, "dvd");
    773776        break;
    774777    default:
    775778        fatal_error("Unknown backup_media_type");
    776779    }
    777     asprintf(&tmp, "%s/BACKUP-MEDIA-TYPE", bkpinfo->tmpdir);
     780    mr_asprintf(&tmp, "%s/BACKUP-MEDIA-TYPE", bkpinfo->tmpdir);
    778781    if (write_one_liner_data_file(tmp, value)) {
    779782        res++;
     
    781784                __LINE__);
    782785    }
    783     paranoid_free(value);
    784     paranoid_free(tmp);
     786    mr_free(value);
     787    mr_free(tmp);
    785788    log_to_screen(bkpinfo->tmpdir);
    786     asprintf(&tmp, "%s/BOOTLOADER.NAME", bkpinfo->tmpdir);
     789    mr_asprintf(&tmp, "%s/BOOTLOADER.NAME", bkpinfo->tmpdir);
    787790    if (write_one_liner_data_file(tmp, bootldr_str)) {
    788791        res++;
     
    790793                __LINE__);
    791794    }
    792     paranoid_free(bootldr_str);
    793     paranoid_free(tmp);
    794     asprintf(&tmp, "%s/DIFFERENTIAL", bkpinfo->tmpdir);
     795    mr_free(bootldr_str);
     796    mr_free(tmp);
     797    mr_asprintf(&tmp, "%s/DIFFERENTIAL", bkpinfo->tmpdir);
    795798    if (bkpinfo->differential) {
    796799        res += write_one_liner_data_file(tmp, "1");
     
    798801        res += write_one_liner_data_file(tmp, "0");
    799802    }
    800     paranoid_free(tmp);
     803    mr_free(tmp);
    801804
    802805    estimated_total_noof_slices =
    803806        size_of_all_biggiefiles_K(bkpinfo) / bkpinfo->optimal_set_size + 1;
    804     asprintf(&command, "mkdir -p %s/images", bkpinfo->scratchdir);
     807    mr_asprintf(&command, "mkdir -p %s/images", bkpinfo->scratchdir);
    805808    if (system(command)) {
    806809        res++;
    807810        log_OS_error("Unable to make images directory");
    808811    }
    809     paranoid_free(command);
    810 
    811     asprintf(&command, "mkdir -p %s%s", bkpinfo->scratchdir, MNT_FLOPPY);
     812    mr_free(command);
     813
     814    mr_asprintf(&command, "mkdir -p %s%s", bkpinfo->scratchdir, MNT_FLOPPY);
    812815    if (system(command)) {
    813816        res++;
    814817        log_OS_error("Unable to make mnt floppy directory");
    815818    }
    816     paranoid_free(command);
    817 
    818     asprintf(&tmp, "BTW, I'm telling Mindi your kernel is '%s'",
     819    mr_free(command);
     820
     821    mr_asprintf(&tmp, "BTW, I'm telling Mindi your kernel is '%s'",
    819822             bkpinfo->kernel_path);
    820823    log_to_screen(tmp);
    821     paranoid_free(tmp);
     824    mr_free(tmp);
    822825
    823826    log_msg(1, "lines_in_filelist = %ld", lines_in_filelist);
     
    825828    // Watch it! This next line adds a parameter...
    826829    if (bkpinfo->nonbootable_backup) {
    827         asprintf(&tmp, " NONBOOTABLE");
     830        mr_asprintf(&tmp, " NONBOOTABLE");
    828831    } else {
    829         asprintf(&tmp, " ");
    830     }
    831 
    832     asprintf(&command,
     832        mr_asprintf(&tmp, " ");
     833    }
     834
     835    mr_asprintf(&command,
    833836/*     "mindi --custom 2=%s 3=%s/images 4=\"%s\" 5=\"%s\" \
    8348376=\"%s\" 7=%ld 8=\"%s\" 9=\"%s\" 10=\"%s\" \
     
    855858             bkpinfo->differential, // parameter #19 (INT)
    856859             tmp);
    857     paranoid_free(tmp);
    858     paranoid_free(tape_size_sz);
    859     paranoid_free(use_lzo_sz);
    860     paranoid_free(tape_device);
    861     paranoid_free(use_star_sz);
    862     paranoid_free(use_comp_sz);
    863     paranoid_free(broken_bios_sz);
    864     paranoid_free(cd_recovery_sz);
    865     paranoid_free(last_filelist_number);
    866     paranoid_free(devs_to_exclude);
    867     paranoid_free(use_lilo_sz);
     860    mr_free(tmp);
     861    mr_free(tape_size_sz);
     862    mr_free(use_lzo_sz);
     863    mr_free(tape_device);
     864    mr_free(use_star_sz);
     865    mr_free(use_comp_sz);
     866    mr_free(broken_bios_sz);
     867    mr_free(cd_recovery_sz);
     868    mr_free(last_filelist_number);
     869    mr_free(devs_to_exclude);
     870    mr_free(use_lilo_sz);
    868871
    869872    log_msg(2, command);
     
    872875    res = run_program_and_log_to_screen(command,
    873876                                        "Generating boot+data disks");
    874     paranoid_free(command);
     877    mr_free(command);
    875878
    876879    if (bkpinfo->nonbootable_backup) {
     
    879882    if (!res) {
    880883        log_to_screen("Boot+data disks were created OK");
    881         asprintf(&command, "mkdir -p /var/cache/mindi/");
     884        mr_asprintf(&command, "mkdir -p /var/cache/mindi/");
    882885        log_msg(2, command);
    883886        run_program_and_log_output(command, FALSE);
    884         paranoid_free(command);
    885 
    886         asprintf(&command,
     887        mr_free(command);
     888
     889        mr_asprintf(&command,
    887890                 "cp -f %s/images/mindi.iso /var/cache/mindi/mondorescue.iso",
    888891                 bkpinfo->scratchdir);
    889892        log_msg(2, command);
    890893        run_program_and_log_output(command, FALSE);
    891         paranoid_free(command);
     894        mr_free(command);
    892895
    893896        if (bkpinfo->nonbootable_backup) {
    894             asprintf(&command, "cp -f %s/all.tar.gz %s/images",
     897            mr_asprintf(&command, "cp -f %s/all.tar.gz %s/images",
    895898                     bkpinfo->tmpdir, bkpinfo->scratchdir);
    896899            if (system(command)) {
    897900                fatal_error("Unable to create temporary duff tarball");
    898                 paranoid_free(command);
    899             }
    900         }
    901         asprintf(&command, "cp -f %s/mindi-*oot*.img %s/images",
     901                mr_free(command);
     902            }
     903        }
     904        mr_asprintf(&command, "cp -f %s/mindi-*oot*.img %s/images",
    902905                 bkpinfo->tmpdir, bkpinfo->scratchdir);
    903906        log_msg(2, command);
    904907        run_program_and_log_output(command, FALSE);
    905         paranoid_free(command);
    906 
    907         asprintf(&tmp, "cp -f %s/images/all.tar.gz %s",
     908        mr_free(command);
     909
     910        mr_asprintf(&tmp, "cp -f %s/images/all.tar.gz %s",
    908911                 bkpinfo->scratchdir, bkpinfo->tmpdir);
    909912        if (system(tmp)) {
    910913            fatal_error("Cannot find all.tar.gz in tmpdir");
    911914        }
    912         paranoid_free(tmp);
     915        mr_free(tmp);
    913916
    914917        if (res) {
     
    919922    } else {
    920923        log_to_screen("Mindi failed to create your boot+data disks.");
    921         asprintf(&command, "grep 'Fatal error' /var/log/mindi.log");
     924        mr_asprintf(&command, "grep 'Fatal error' /var/log/mindi.log");
    922925        tmp = call_program_and_get_last_line_of_output(command);
    923         paranoid_free(command);
     926        mr_free(command);
    924927        if (strlen(tmp) > 1) {
    925928            popup_and_OK(tmp);
    926929        }
    927         paranoid_free(tmp);
     930        mr_free(tmp);
    928931    }
    929932    return (res);
     
    990993    bkpinfo = (struct s_bkpinfo *) (inbuf + BKPINFO_LOC_OFFSET);
    991994
    992     asprintf(&archiving_filelist_fname, FILELIST_FNAME_RAW_SZ,
     995    mr_asprintf(&archiving_filelist_fname, FILELIST_FNAME_RAW_SZ,
    993996             bkpinfo->tmpdir, 0L);
    994997    archiving_set_no = 0;
    995998    while (does_file_exist(archiving_filelist_fname)) {
    996         paranoid_free(archiving_filelist_fname);
     999        mr_free(archiving_filelist_fname);
    9971000        if (g_exiting) {
    9981001            fatal_error("Execution run aborted (pthread)");
     
    10151018
    10161019        /* backup this set of files */
    1017         asprintf(&archiving_afioball_fname, AFIOBALL_FNAME_RAW_SZ,
     1020        mr_asprintf(&archiving_afioball_fname, AFIOBALL_FNAME_RAW_SZ,
    10181021                 bkpinfo->tmpdir, archiving_set_no, bkpinfo->zip_suffix);
    1019         asprintf(&archiving_filelist_fname, FILELIST_FNAME_RAW_SZ,
     1022        mr_asprintf(&archiving_filelist_fname, FILELIST_FNAME_RAW_SZ,
    10201023                 bkpinfo->tmpdir, archiving_set_no);
    10211024        if (!does_file_exist(archiving_filelist_fname)) {
     
    10241027                    FORTY_SPACES, getpid(), this_thread_no,
    10251028                    archiving_set_no);
    1026             paranoid_free(archiving_filelist_fname);
    1027             paranoid_free(archiving_afioball_fname);
     1029            mr_free(archiving_filelist_fname);
     1030            mr_free(archiving_afioball_fname);
    10281031            break;
    10291032        }
    10301033
    1031         asprintf(&tmp, AFIOBALL_FNAME_RAW_SZ, bkpinfo->tmpdir,
     1034        mr_asprintf(&tmp, AFIOBALL_FNAME_RAW_SZ, bkpinfo->tmpdir,
    10321035                 archiving_set_no - ARCH_BUFFER_NUM, bkpinfo->zip_suffix);
    10331036        if (does_file_exist(tmp)) {
     
    10391042            log_msg(4, "[%d] - continuing", getpid());
    10401043        }
    1041         paranoid_free(tmp);
     1044        mr_free(tmp);
    10421045
    10431046        log_msg(4, "%s[%d:%d] - EXATing %d...", FORTY_SPACES, getpid(),
    10441047                this_thread_no, archiving_set_no);
    1045         asprintf(&curr_xattr_list_fname, XATTR_LIST_FNAME_RAW_SZ,
     1048        mr_asprintf(&curr_xattr_list_fname, XATTR_LIST_FNAME_RAW_SZ,
    10461049                 bkpinfo->tmpdir, archiving_set_no);
    1047         asprintf(&curr_acl_list_fname, ACL_LIST_FNAME_RAW_SZ,
     1050        mr_asprintf(&curr_acl_list_fname, ACL_LIST_FNAME_RAW_SZ,
    10481051                 bkpinfo->tmpdir, archiving_set_no);
    10491052        get_fattr_list(archiving_filelist_fname, curr_xattr_list_fname);
    1050         paranoid_free(curr_xattr_list_fname);
     1053        mr_free(curr_xattr_list_fname);
    10511054        get_acl_list(archiving_filelist_fname, curr_acl_list_fname);
    1052         paranoid_free(curr_acl_list_fname);
     1055        mr_free(curr_acl_list_fname);
    10531056
    10541057        log_msg(4, "%s[%d:%d] - archiving %d...", FORTY_SPACES, getpid(),
     
    10571060                                   archiving_afioball_fname,
    10581061                                   archiving_set_no);
    1059         paranoid_free(archiving_afioball_fname);
    1060         paranoid_free(archiving_filelist_fname);
     1062        mr_free(archiving_afioball_fname);
     1063        mr_free(archiving_filelist_fname);
    10611064        retval += res;
    10621065
    10631066        if (res) {
    1064             asprintf(&tmp,
     1067            mr_asprintf(&tmp,
    10651068                     "Errors occurred while archiving set %ld. Please review logs.",
    10661069                     archiving_set_no);
    10671070            log_to_screen(tmp);
    1068             paranoid_free(tmp);
     1071            mr_free(tmp);
    10691072        }
    10701073        if (!semaphore_p()) {
     
    10841087                this_thread_no, archiving_set_no);
    10851088        archiving_set_no++;
    1086         asprintf(&archiving_filelist_fname, FILELIST_FNAME_RAW_SZ,
     1089        mr_asprintf(&archiving_filelist_fname, FILELIST_FNAME_RAW_SZ,
    10871090                 bkpinfo->tmpdir, archiving_set_no);
    10881091    }
     
    10961099    log_msg(3, "%s[%d:%d] - exiting", FORTY_SPACES, getpid(),
    10971100            this_thread_no);
    1098     paranoid_free(archiving_filelist_fname);
     1101    mr_free(archiving_filelist_fname);
    10991102    pthread_exit(NULL);
    11001103}
     
    11781181
    11791182    assert(bkpinfo != NULL);
    1180     asprintf(&data_disks_file, "%s/all.tar.gz", bkpinfo->tmpdir);
     1183    mr_asprintf(&data_disks_file, "%s/all.tar.gz", bkpinfo->tmpdir);
    11811184
    11821185    g_serial_string = call_program_and_get_last_line_of_output("dd \
    11831186if=/dev/urandom bs=16 count=1 2> /dev/null | \
    11841187hexdump | tr -s ' ' '0' | head -n1");
    1185     asprintf(&tmp, "%s...word.", g_serial_string);
    1186     paranoid_free(g_serial_string);
     1188    mr_asprintf(&tmp, "%s...word.", g_serial_string);
     1189    mr_free(g_serial_string);
    11871190    g_serial_string = tmp;
    11881191    log_msg(2, "g_serial_string = '%s'", g_serial_string);
    11891192
    1190     asprintf(&tmpfile, "%s/archives/SERIAL-STRING", bkpinfo->scratchdir);
     1193    mr_asprintf(&tmpfile, "%s/archives/SERIAL-STRING", bkpinfo->scratchdir);
    11911194    if (write_one_liner_data_file(tmpfile, g_serial_string)) {
    11921195        log_msg(1, "%ld: Failed to write serial string", __LINE__);
    11931196    }
    1194     paranoid_free(g_serial_string);
    1195     paranoid_free(tmpfile);
     1197    mr_free(g_serial_string);
     1198    mr_free(tmpfile);
    11961199
    11971200    mvaddstr_and_log_it(g_currentY, 0, "Preparing to archive your data");
     
    12101213        log_msg(1, "Backing up to CD's");
    12111214    }
    1212     paranoid_free(data_disks_file);
    1213 
    1214     asprintf(&command, "rm -f %s/%s/%s-[1-9]*.iso", bkpinfo->isodir,
     1215    mr_free(data_disks_file);
     1216
     1217    mr_asprintf(&command, "rm -f %s/%s/%s-[1-9]*.iso", bkpinfo->isodir,
    12151218             bkpinfo->nfs_remote_dir, bkpinfo->prefix);
    12161219    paranoid_system(command);
    1217     paranoid_free(command);
     1220    mr_free(command);
    12181221    wipe_archives(bkpinfo->scratchdir);
    12191222    mvaddstr_and_log_it(g_currentY++, 74, "Done.");
     
    12741277/* if not Debian then go ahead & use fdformat */
    12751278    tempfile = call_program_and_get_last_line_of_output("mktemp -q /tmp/mondo.XXXXXXXX");
    1276     asprintf(&command, "%s >> %s 2>> %s; rm -f %s", cmd, tempfile,
     1279    mr_asprintf(&command, "%s >> %s 2>> %s; rm -f %s", cmd, tempfile,
    12771280             tempfile, tempfile);
    12781281    log_msg(3, command);
     
    12871290        maxtracks = 80;
    12881291    }
    1289     paranoid_free(command);
     1292    mr_free(command);
    12901293
    12911294    for (sleep(1); does_file_exist(tempfile); sleep(1)) {
     
    13091312    }
    13101313    unlink(tempfile);
    1311     paranoid_free(tempfile);
     1314    mr_free(tempfile);
    13121315    return (res);
    13131316}
     
    13381341    assert_string_is_neither_NULL_nor_zerolength(device);
    13391342    if (!system("which superformat > /dev/null 2> /dev/null")) {
    1340         asprintf(&command, "superformat %s", device);
     1343        mr_asprintf(&command, "superformat %s", device);
    13411344    } else {
    13421345#ifdef __FreeBSD__
    1343         asprintf(&command, "fdformat -y %s", device);
     1346        mr_asprintf(&command, "fdformat -y %s", device);
    13441347#else
    1345         asprintf(&command, "fdformat %s", device);
     1348        mr_asprintf(&command, "fdformat %s", device);
    13461349#endif
    13471350    }
    1348     asprintf(&title, "Formatting disk %s", device);
     1351    mr_asprintf(&title, "Formatting disk %s", device);
    13491352    while ((res = format_disk_SUB(command, title))) {
    13501353        if (!ask_me_yes_or_no("Failed to format disk. Retry?")) {
     
    13521355        }
    13531356    }
    1354     paranoid_free(title);
    1355     paranoid_free(command);
     1357    mr_free(title);
     1358    mr_free(command);
    13561359    return (res);
    13571360}
     
    15021505            /* maybe  */
    15031506            tmp = percent_media_full_comment(bkpinfo);
    1504             asprintf(&media_usage_comment, "%s", tmp);
    1505             paranoid_free(tmp);
     1507            mr_asprintf(&media_usage_comment, "%s", tmp);
     1508            mr_free(tmp);
    15061509            if (!misc_counter_that_is_not_important) {
    15071510                update_progress_form(media_usage_comment);
    15081511            }
    1509             paranoid_free(media_usage_comment);
     1512            mr_free(media_usage_comment);
    15101513            sleep(1);
    15111514        } else {
    15121515            // store set N
    1513             asprintf(&storing_filelist_fname, FILELIST_FNAME_RAW_SZ,
     1516            mr_asprintf(&storing_filelist_fname, FILELIST_FNAME_RAW_SZ,
    15141517                     bkpinfo->tmpdir, storing_set_no);
    1515             asprintf(&storing_afioball_fname, AFIOBALL_FNAME_RAW_SZ,
     1518            mr_asprintf(&storing_afioball_fname, AFIOBALL_FNAME_RAW_SZ,
    15161519                     bkpinfo->tmpdir, storing_set_no, bkpinfo->zip_suffix);
    1517             asprintf(&curr_xattr_list_fname, XATTR_LIST_FNAME_RAW_SZ,
     1520            mr_asprintf(&curr_xattr_list_fname, XATTR_LIST_FNAME_RAW_SZ,
    15181521                     bkpinfo->tmpdir, storing_set_no);
    1519             asprintf(&curr_acl_list_fname, ACL_LIST_FNAME_RAW_SZ,
     1522            mr_asprintf(&curr_acl_list_fname, ACL_LIST_FNAME_RAW_SZ,
    15201523                     bkpinfo->tmpdir, storing_set_no);
    15211524
     
    15291532            }
    15301533            tmp = percent_media_full_comment(bkpinfo);
    1531             asprintf(&media_usage_comment, "%s", tmp);
    1532             paranoid_free(tmp);
     1534            mr_asprintf(&media_usage_comment, "%s", tmp);
     1535            mr_free(tmp);
    15331536            /* copy to CD (scratchdir) ... and an actual CD-R if necessary */
    15341537            if (IS_THIS_A_STREAMING_BACKUP(bkpinfo->backup_media_type)) {
     
    15521555                                     storing_afioball_fname, NULL);
    15531556            }
    1554             paranoid_free(storing_filelist_fname);
    1555             paranoid_free(storing_afioball_fname);
    1556             paranoid_free(curr_xattr_list_fname);
    1557             paranoid_free(curr_acl_list_fname);
     1557            mr_free(storing_filelist_fname);
     1558            mr_free(storing_afioball_fname);
     1559            mr_free(curr_xattr_list_fname);
     1560            mr_free(curr_acl_list_fname);
    15581561            retval += res;
    15591562            g_current_progress++;
    15601563            update_progress_form(media_usage_comment);
    1561             paranoid_free(media_usage_comment);
     1564            mr_free(media_usage_comment);
    15621565
    15631566            if (res) {
    1564                 asprintf(&tmp,
     1567                mr_asprintf(&tmp,
    15651568                         "Failed to add archive %ld's files to CD dir\n",
    15661569                         storing_set_no);
    15671570                log_to_screen(tmp);
    1568                 paranoid_free(tmp);
     1571                mr_free(tmp);
    15691572                fatal_error
    15701573                    ("Is your hard disk full? If not, please send the author the logfile.");
     
    15841587    log_msg(2, "Done.");
    15851588    if (retval) {
    1586         asprintf(&tmp,
     1589        mr_asprintf(&tmp,
    15871590                 "Your regular files have been archived (with errors).");
    15881591    } else {
    1589         asprintf(&tmp,
     1592        mr_asprintf(&tmp,
    15901593                 "Your regular files have been archived successfully");
    15911594    }
    15921595    log_to_screen(tmp);
    1593     paranoid_free(tmp);
    1594     paranoid_free(transfer_block);
    1595     paranoid_free(result_str);
     1596    mr_free(tmp);
     1597    mr_free(transfer_block);
     1598    mr_free(result_str);
    15961599    return (retval);
    15971600}
     
    16471650    assert_string_is_neither_NULL_nor_zerolength(destfile);
    16481651
    1649     asprintf(&tmp, "%s/isolinux.bin", bkpinfo->scratchdir);
    1650     asprintf(&tmp2, "%s/isolinux.bin", bkpinfo->tmpdir);
     1652    mr_asprintf(&tmp, "%s/isolinux.bin", bkpinfo->scratchdir);
     1653    mr_asprintf(&tmp2, "%s/isolinux.bin", bkpinfo->tmpdir);
    16511654    if (does_file_exist(tmp)) {
    1652         asprintf(&tmp3, "cp -f %s %s", tmp, tmp2);
     1655        mr_asprintf(&tmp3, "cp -f %s %s", tmp, tmp2);
    16531656        paranoid_system(tmp3);
    1654         paranoid_free(tmp3);
     1657        mr_free(tmp3);
    16551658    }
    16561659    if (!does_file_exist(tmp) && does_file_exist(tmp2)) {
    1657         asprintf(&tmp3, "cp -f %s %s", tmp2, tmp);
     1660        mr_asprintf(&tmp3, "cp -f %s %s", tmp2, tmp);
    16581661        paranoid_system(tmp3);
    1659         paranoid_free(tmp3);
    1660     }
    1661     paranoid_free(tmp2);
    1662     paranoid_free(tmp);
     1662        mr_free(tmp3);
     1663    }
     1664    mr_free(tmp2);
     1665    mr_free(tmp);
    16631666
    16641667    if (bkpinfo->backup_media_type == iso && bkpinfo->manual_cd_tray) {
     
    16701673    /* BERLIOS: Do not ignore getcwd result */
    16711674    (void) getcwd(old_pwd, MAX_STR_LEN - 1);
    1672     asprintf(&tmp, "chmod 755 %s", bkpinfo->scratchdir);
     1675    mr_asprintf(&tmp, "chmod 755 %s", bkpinfo->scratchdir);
    16731676    run_program_and_log_output(tmp, FALSE);
    1674     paranoid_free(tmp);
     1677    mr_free(tmp);
    16751678    chdir(bkpinfo->scratchdir);
    16761679
    16771680    if (bkpinfo->call_before_iso != NULL) {
    1678         asprintf(&message_to_screen, "Running pre-ISO call for CD#%d",
     1681        mr_asprintf(&message_to_screen, "Running pre-ISO call for CD#%d",
    16791682                 g_current_media_number);
    16801683        res = eval_call_to_make_ISO(bkpinfo, bkpinfo->call_before_iso,
     
    16861689            log_to_screen("%s...OK", message_to_screen);
    16871690        }
    1688         paranoid_free(message_to_screen);
     1691        mr_free(message_to_screen);
    16891692        retval += res;
    16901693    }
     
    16921695    if (bkpinfo->call_make_iso != NULL) {
    16931696        log_msg(2, "bkpinfo->call_make_iso = %s", bkpinfo->call_make_iso);
    1694         asprintf(&tmp, "%s/archives/NOT-THE-LAST", bkpinfo->scratchdir);
    1695         asprintf(&message_to_screen, "Making an ISO (%s #%d)",
     1697        mr_asprintf(&tmp, "%s/archives/NOT-THE-LAST", bkpinfo->scratchdir);
     1698        mr_asprintf(&message_to_screen, "Making an ISO (%s #%d)",
    16961699                 bkpinfo->backup_media_string,
    16971700                 g_current_media_number);
     
    17201723            retval += res;
    17211724#ifdef DVDRWFORMAT
    1722             asprintf(&tmp,
     1725            mr_asprintf(&tmp,
    17231726                     "tail -n8 %s | grep 'blank=full.*dvd-compat.*DAO'",
    17241727                     MONDO_LOGFILE);
     
    17381741                }
    17391742                pause_for_N_seconds(5, "Letting DVD drive settle");
    1740                 asprintf(&sz_blank_disk, "dvd+rw-format %s",
     1743                mr_asprintf(&sz_blank_disk, "dvd+rw-format %s",
    17411744                         bkpinfo->media_device);
    17421745                log_msg(3, "sz_blank_disk = '%s'", sz_blank_disk);
     
    17571760                        ("Format succeeded. Sleeping for 5 seconds to take a breath...");
    17581761                }
    1759                 paranoid_free(sz_blank_disk);
     1762                mr_free(sz_blank_disk);
    17601763                pause_for_N_seconds(5, "Letting DVD drive settle");
    17611764                if (!bkpinfo->please_dont_eject) {
     
    17831786                }
    17841787            }
    1785             paranoid_free(tmp);
     1788            mr_free(tmp);
    17861789#endif
    17871790            if (g_backup_media_type == dvd && !bkpinfo->please_dont_eject) {
     
    17891792            }
    17901793        }
    1791         paranoid_free(message_to_screen);
     1794        mr_free(message_to_screen);
    17921795    } else {
    1793         asprintf(&message_to_screen, "Running mkisofs to make %s #%d",
     1796        mr_asprintf(&message_to_screen, "Running mkisofs to make %s #%d",
    17941797                 bkpinfo->backup_media_string,
    17951798                 g_current_media_number);
    17961799        log_msg(1, message_to_screen);
    1797         asprintf(&result_sz, "Call to mkisofs to make ISO (%s #%d) ",
     1800        mr_asprintf(&result_sz, "Call to mkisofs to make ISO (%s #%d) ",
    17981801                 bkpinfo->backup_media_string,
    17991802                 g_current_media_number);
     
    18211824#ifdef __IA64__
    18221825                log_msg(1, "IA64 --> elilo");
    1823                 asprintf(&tmp2,"mkisofs -no-emul-boot -b images/mindi-bootroot.%s.img -c boot.cat -o _ISO_ -J -r -p MondoRescue -publisher www.mondorescue.org -A Mondo_Rescue_GPL -V _CD#_ .", bkpinfo->mrconf->mindi_ia64_boot_size);
     1826                mr_asprintf(&tmp2,"mkisofs -no-emul-boot -b images/mindi-bootroot.%s.img -c boot.cat -o _ISO_ -J -r -p MondoRescue -publisher www.mondorescue.org -A Mondo_Rescue_GPL -V _CD#_ .", bkpinfo->mrconf->mindi_ia64_boot_size);
    18241827                res = eval_call_to_make_ISO(bkpinfo,
    18251828                                            tmp2,
     
    18311834// FIXME --- change mkisofs string to MONDO_MKISOFS_REGULAR_SYSLINUX/LILO depending on bkpinfo->make_cd_usE_lilo
    18321835// and add ' .' at end
    1833                 paranoid_free(tmp2);
     1836                mr_free(tmp2);
    18341837                log_msg(1, "Non-ia64 --> lilo");
    18351838                res = eval_call_to_make_ISO(bkpinfo,
     
    18571860        }
    18581861        retval += res;
    1859         paranoid_free(message_to_screen);
    1860         paranoid_free(result_sz);
     1862        mr_free(message_to_screen);
     1863        mr_free(result_sz);
    18611864    }
    18621865
     
    18671870                    "Warning - %s mounted. I'm unmounting it before I burn to it.",
    18681871                    bkpinfo->media_device);
    1869             asprintf(&tmp, "umount %s", bkpinfo->media_device);
     1872            mr_asprintf(&tmp, "umount %s", bkpinfo->media_device);
    18701873            run_program_and_log_output(tmp, FALSE);
    1871             paranoid_free(tmp);
     1874            mr_free(tmp);
    18721875        }
    18731876    }
     
    18751878    if (bkpinfo->call_burn_iso != NULL) {
    18761879        log_msg(2, "bkpinfo->call_burn_iso = %s", bkpinfo->call_burn_iso);
    1877         asprintf(&message_to_screen, "Burning %s #%d",
     1880        mr_asprintf(&message_to_screen, "Burning %s #%d",
    18781881                 bkpinfo->backup_media_string,
    18791882                 g_current_media_number);
     
    18871890            log_to_screen("%s...OK", message_to_screen);
    18881891        }
    1889         paranoid_free(message_to_screen);
     1892        mr_free(message_to_screen);
    18901893        retval += res;
    18911894    }
    18921895
    18931896    if (bkpinfo->call_after_iso != NULL) {
    1894         asprintf(&message_to_screen, "Running post-ISO call (%s #%d)",
     1897        mr_asprintf(&message_to_screen, "Running post-ISO call (%s #%d)",
    18951898                 bkpinfo->backup_media_string,
    18961899                 g_current_media_number);
     
    19031906            log_to_screen("%s...OK", message_to_screen);
    19041907        }
    1905         paranoid_free(message_to_screen);
     1908        mr_free(message_to_screen);
    19061909        retval += res;
    19071910    }
     
    19111914        log_msg(1, "WARNING - make_iso_fs returned an error");
    19121915    }
    1913     paranoid_free(old_pwd);
     1916    mr_free(old_pwd);
    19141917    return (retval);
    19151918}
     
    19211924    char *command;
    19221925    bool ret = TRUE;
    1923     asprintf(&command,
     1926    mr_asprintf(&command,
    19241927             "dd if=%s bs=512 count=1 2> /dev/null | strings | head -n1",
    19251928             bigfile_fname);
     
    19271930    tmp = call_program_and_get_last_line_of_output(command);
    19281931    log_msg(1, "--> tmp = '%s'", tmp);
    1929     paranoid_free(command);
     1932    mr_free(command);
    19301933    if (strstr(tmp, "NTFS")) {
    19311934        iamhere("TRUE");
     
    19341937        ret = FALSE;
    19351938    }
    1936     paranoid_free(tmp);
     1939    mr_free(tmp);
    19371940    return(ret);
    19381941}
     
    19972000        return (0);
    19982001    }
    1999     asprintf(&tmp, "I am now backing up all large files.");
     2002    mr_asprintf(&tmp, "I am now backing up all large files.");
    20002003    log_to_screen(tmp);
    20012004    noof_biggie_files = count_lines_in_file(biggielist_fname);
     
    20032006                       "Please wait. This may take some time.", "",
    20042007                       estimated_total_noof_slices);
    2005     paranoid_free(tmp);
     2008    mr_free(tmp);
    20062009
    20072010    if (!(fin = fopen(biggielist_fname, "r"))) {
     
    20092012        return (1);
    20102013    }
    2011     for (getline(&bigfile_fname, &n, fin); !feof(fin);
    2012          getline(&bigfile_fname, &n, fin), biggie_file_number++) {
     2014    for (mr_getline(&bigfile_fname, &n, fin); !feof(fin);
     2015         mr_getline(&bigfile_fname, &n, fin), biggie_file_number++) {
    20132016        use_ntfsprog = FALSE;
    20142017        if (bigfile_fname[strlen(bigfile_fname) - 1] < 32) {
     
    20212024            ftmp = fopen(bigfile_fname, "w");
    20222025            paranoid_fclose(ftmp);
    2023             asprintf(&tmp, "bigfile %s was deleted - creating a dummy",
     2026            mr_asprintf(&tmp, "bigfile %s was deleted - creating a dummy",
    20242027                     bigfile_fname);
    20252028            delete_when_done = TRUE;
     
    20352038                        "Calling ntfsclone in background because %s is an NTFS partition",
    20362039                        bigfile_fname);
    2037                 asprintf(&sz_devfile, "%s/%d.%d.000",
     2040                mr_asprintf(&sz_devfile, "%s/%d.%d.000",
    20382041                        bkpinfo->tmpdir,
    20392042                         (int) (random() % 32768),
     
    20562059                            (long int) (pid));
    20572060
    2058                     paranoid_free(sz_devfile);
     2061                    mr_free(sz_devfile);
    20592062                }
    20602063            }
     
    20812084                tmp = calc_checksum_of_file(bigfile_fname);
    20822085                write_header_block_to_stream((off_t)0, tmp, BLK_STOP_A_BIGGIE);
    2083                 paranoid_free(tmp);
     2086                mr_free(tmp);
    20842087            }
    20852088            retval += res;
     
    20912094            }
    20922095            if (res) {
    2093                 asprintf(&tmp, "Archiving %s ... Failed!", bigfile_fname);
     2096                mr_asprintf(&tmp, "Archiving %s ... Failed!", bigfile_fname);
    20942097            } else {
    2095                 asprintf(&tmp, "Archiving %s ... OK!", bigfile_fname);
     2098                mr_asprintf(&tmp, "Archiving %s ... OK!", bigfile_fname);
    20962099            }
    20972100
     
    21082111#endif
    21092112    }
    2110     paranoid_free(tmp);
    2111     paranoid_free(bigfile_fname);
     2113    mr_free(tmp);
     2114    mr_free(bigfile_fname);
    21122115    paranoid_fclose(fin);
    21132116
     
    21412144
    21422145    /* BERLIOS: Useless ?
    2143        asprintf(&tmp, "%s/archives/filelist.full", bkpinfo->scratchdir);
     2146       mr_asprintf(&tmp, "%s/archives/filelist.full", bkpinfo->scratchdir);
    21442147     */
    21452148
     
    21522155                       get_last_filelist_number(bkpinfo) + 1);
    21532156
    2154     asprintf(&curr_filelist_fname, FILELIST_FNAME_RAW_SZ, bkpinfo->tmpdir,
     2157    mr_asprintf(&curr_filelist_fname, FILELIST_FNAME_RAW_SZ, bkpinfo->tmpdir,
    21552158             0L);
    21562159
     
    21582161    while (does_file_exist(curr_filelist_fname)) {
    21592162        /* backup this set of files */
    2160         asprintf(&curr_afioball_fname, AFIOBALL_FNAME_RAW_SZ,
     2163        mr_asprintf(&curr_afioball_fname, AFIOBALL_FNAME_RAW_SZ,
    21612164                 bkpinfo->tmpdir, curr_set_no, bkpinfo->zip_suffix);
    21622165
    21632166        log_msg(1, "EXAT'g set %ld", curr_set_no);
    2164         asprintf(&curr_xattr_list_fname, XATTR_LIST_FNAME_RAW_SZ,
     2167        mr_asprintf(&curr_xattr_list_fname, XATTR_LIST_FNAME_RAW_SZ,
    21652168                 bkpinfo->tmpdir, curr_set_no);
    2166         asprintf(&curr_acl_list_fname, ACL_LIST_FNAME_RAW_SZ,
     2169        mr_asprintf(&curr_acl_list_fname, ACL_LIST_FNAME_RAW_SZ,
    21672170                 bkpinfo->tmpdir, curr_set_no);
    21682171        get_fattr_list(curr_filelist_fname, curr_xattr_list_fname);
     
    21742177        retval += res;
    21752178        if (res) {
    2176             asprintf(&tmp,
     2179            mr_asprintf(&tmp,
    21772180                     "Errors occurred while archiving set %ld. Perhaps your live filesystem changed?",
    21782181                     curr_set_no);
    21792182            log_to_screen(tmp);
    2180             paranoid_free(tmp);
     2183            mr_free(tmp);
    21812184        }
    21822185
    21832186        tmp = percent_media_full_comment(bkpinfo);
    2184         asprintf(&media_usage_comment, "%s", tmp);
    2185         paranoid_free(tmp);
     2187        mr_asprintf(&media_usage_comment, "%s", tmp);
     2188        mr_free(tmp);
    21862189
    21872190        /* copy to CD (scratchdir) ... and an actual CD-R if necessary */
     
    22062209        g_current_progress++;
    22072210        update_progress_form(media_usage_comment);
    2208         paranoid_free(media_usage_comment);
     2211        mr_free(media_usage_comment);
    22092212
    22102213        if (res) {
    2211             asprintf(&tmp, "Failed to add archive %ld's files to CD dir\n",
     2214            mr_asprintf(&tmp, "Failed to add archive %ld's files to CD dir\n",
    22122215                     curr_set_no);
    22132216            log_to_screen(tmp);
    2214             paranoid_free(tmp);
     2217            mr_free(tmp);
    22152218            fatal_error
    22162219                ("Is your hard disk is full? If not, please send the author the logfile.");
    22172220        }
    2218         paranoid_free(curr_filelist_fname);
    2219         paranoid_free(curr_afioball_fname);
    2220         paranoid_free(curr_xattr_list_fname);
    2221         paranoid_free(curr_acl_list_fname);
    2222         asprintf(&curr_filelist_fname, FILELIST_FNAME_RAW_SZ,
     2221        mr_free(curr_filelist_fname);
     2222        mr_free(curr_afioball_fname);
     2223        mr_free(curr_xattr_list_fname);
     2224        mr_free(curr_acl_list_fname);
     2225        mr_asprintf(&curr_filelist_fname, FILELIST_FNAME_RAW_SZ,
    22232226                 bkpinfo->tmpdir, ++curr_set_no);
    22242227    }
    2225     paranoid_free(curr_filelist_fname);
     2228    mr_free(curr_filelist_fname);
    22262229    close_progress_form();
    22272230    if (retval) {
     
    23102313    mvaddstr_and_log_it(g_currentY, 0,
    23112314                        "Archiving large files to media           ");
    2312     asprintf(&biggielist, "%s/archives/biggielist.txt",
     2315    mr_asprintf(&biggielist, "%s/archives/biggielist.txt",
    23132316             bkpinfo->scratchdir);
    2314     asprintf(&xattr_fname, XATTR_BIGGLST_FNAME_RAW_SZ, bkpinfo->tmpdir);
    2315     asprintf(&acl_fname, ACL_BIGGLST_FNAME_RAW_SZ, bkpinfo->tmpdir);
    2316 
    2317     asprintf(&command, "cp %s/biggielist.txt %s", bkpinfo->tmpdir,
     2317    mr_asprintf(&xattr_fname, XATTR_BIGGLST_FNAME_RAW_SZ, bkpinfo->tmpdir);
     2318    mr_asprintf(&acl_fname, ACL_BIGGLST_FNAME_RAW_SZ, bkpinfo->tmpdir);
     2319
     2320    mr_asprintf(&command, "cp %s/biggielist.txt %s", bkpinfo->tmpdir,
    23182321             biggielist);
    23192322    paranoid_system(command);
    2320     paranoid_free(command);
    2321 
    2322     asprintf(&blah, "biggielist = %s", biggielist);
     2323    mr_free(command);
     2324
     2325    mr_asprintf(&blah, "biggielist = %s", biggielist);
    23232326    log_msg(2, blah);
    2324     paranoid_free(blah);
     2327    mr_free(blah);
    23252328
    23262329    if (!does_file_exist(biggielist)) {
     
    23302333    get_fattr_list(biggielist, xattr_fname);
    23312334    get_acl_list(biggielist, acl_fname);
    2332     asprintf(&command, "cp %s %s/archives/", xattr_fname,
     2335    mr_asprintf(&command, "cp %s %s/archives/", xattr_fname,
    23332336             bkpinfo->scratchdir);
    23342337    paranoid_system(command);
    2335     paranoid_free(command);
    2336 
    2337     asprintf(&command, "cp %s %s/archives/", acl_fname,
     2338    mr_free(command);
     2339
     2340    mr_asprintf(&command, "cp %s %s/archives/", acl_fname,
    23382341             bkpinfo->scratchdir);
    23392342    paranoid_system(command);
    2340     paranoid_free(command);
     2343    mr_free(command);
    23412344
    23422345    if (IS_THIS_A_STREAMING_BACKUP(bkpinfo->backup_media_type)) {
    23432346        res += write_EXAT_files_to_tape(bkpinfo, xattr_fname, acl_fname);
    2344         asprintf(&blah, "%ld", count_lines_in_file(biggielist));
     2347        mr_asprintf(&blah, "%ld", count_lines_in_file(biggielist));
    23452348        write_header_block_to_stream((off_t)0, blah, BLK_START_BIGGIEFILES);
    2346         paranoid_free(blah);
    2347     }
    2348     paranoid_free(xattr_fname);
    2349     paranoid_free(acl_fname);
     2349        mr_free(blah);
     2350    }
     2351    mr_free(xattr_fname);
     2352    mr_free(acl_fname);
    23502353
    23512354    res = make_slices_and_images(bkpinfo, biggielist);
    2352     paranoid_free(biggielist);
     2355    mr_free(biggielist);
    23532356
    23542357    if (IS_THIS_A_STREAMING_BACKUP(bkpinfo->backup_media_type)) {
     
    24182421            continue;
    24192422        }
    2420         asprintf(&curr_file, "%s", cf);
     2423        mr_asprintf(&curr_file, "%s", cf);
    24212424        if (!does_file_exist(curr_file)) {
    24222425            log_msg(1,
     
    24272430            would_occupy += length_of_file(curr_file) / 1024;
    24282431        }
    2429         paranoid_free(curr_file);
     2432        mr_free(curr_file);
    24302433    }
    24312434    va_end(ap);
     
    24482451            continue;
    24492452        }
    2450         asprintf(&curr_file, "%s", cf);
    2451 
    2452         asprintf(&tmp, "mv -f %s %s/archives/", curr_file,
     2453        mr_asprintf(&curr_file, "%s", cf);
     2454
     2455        mr_asprintf(&tmp, "mv -f %s %s/archives/", curr_file,
    24532456                 bkpinfo->scratchdir);
    24542457        res = run_program_and_log_output(tmp, 5);
     
    24592462            log_msg(8, "Moved %s to CD OK", tmp);
    24602463        }
    2461         paranoid_free(tmp);
    2462         paranoid_free(curr_file);
     2464        mr_free(tmp);
     2465        mr_free(curr_file);
    24632466        //      unlink (curr_file);
    24642467    }
     
    25182521        system("/usr/sbin/fdcontrol -F 1722 /dev/fd0.1722");
    25192522#endif
    2520         asprintf(&bootdisk_dev, "%s", DEFAULT_1722MB_DISK);
     2523        mr_asprintf(&bootdisk_dev, "%s", DEFAULT_1722MB_DISK);
    25212524    } else if (does_device_exist(BACKUP_1722MB_DISK)) {
    2522         asprintf(&bootdisk_dev, "/dev/fd0H1722");
     2525        mr_asprintf(&bootdisk_dev, "/dev/fd0H1722");
    25232526    } else {
    25242527        log_msg(1, "Warning - can't find a 1.72MB floppy device *sigh*");
    2525         asprintf(&bootdisk_dev, DEFAULT_1722MB_DISK);
    2526     }
    2527     asprintf(&datadisk_dev, "%s", "/dev/fd0");
     2528        mr_asprintf(&bootdisk_dev, DEFAULT_1722MB_DISK);
     2529    }
     2530    mr_asprintf(&datadisk_dev, "%s", "/dev/fd0");
    25282531    if (!does_device_exist(datadisk_dev)) {
    25292532        log_msg(1, "Warning - can't find a 1.44MB floppy device *sigh*");
    2530         paranoid_free(datadisk_dev);
    2531         asprintf(&datadisk_dev, "%s", "/dev/fd0");
     2533        mr_free(datadisk_dev);
     2534        mr_asprintf(&datadisk_dev, "%s", "/dev/fd0");
    25322535    }
    25332536    format_first = ask_me_yes_or_no
     
    25382541        log_to_screen("Writing boot floppy");
    25392542#ifdef __FreeBSD__
    2540         asprintf(&tmp, "%s/mindi-kern.1722.img", imagesdir);
     2543        mr_asprintf(&tmp, "%s/mindi-kern.1722.img", imagesdir);
    25412544        if (format_first) {
    25422545            format_disk(bootdisk_dev);
    25432546        }
    25442547        res += write_image_to_floppy(bootdisk_dev, tmp);
    2545         paranoid_free(tmp);
     2548        mr_free(tmp);
    25462549
    25472550        if (ask_me_OK_or_cancel("About to write 1.44MB mfsroot disk")) {
     
    25502553                format_disk(datadisk_dev);
    25512554            }
    2552             asprintf(&tmp, "%s/mindi-mfsroot.1440.img", imagesdir);
     2555            mr_asprintf(&tmp, "%s/mindi-mfsroot.1440.img", imagesdir);
    25532556            write_image_to_floppy(datadisk_dev, tmp);
    2554             paranoid_free(tmp);
     2557            mr_free(tmp);
    25552558        }
    25562559#else
    2557         asprintf(&bootdisk_file, "%s/mindi-bootroot.1722.img", imagesdir);
     2560        mr_asprintf(&bootdisk_file, "%s/mindi-bootroot.1722.img", imagesdir);
    25582561        if (does_file_exist(bootdisk_file)) {
    25592562            if (format_first) {
     
    25622565            res += write_image_to_floppy(bootdisk_dev, bootdisk_file);
    25632566        } else {
    2564             paranoid_free(bootdisk_file);
    2565             asprintf(&bootdisk_file, "%s/mindi-boot.1440.img", imagesdir);
    2566             asprintf(&rootdisk_file, "%s/mindi-root.1440.img", imagesdir);
     2567            mr_free(bootdisk_file);
     2568            mr_asprintf(&bootdisk_file, "%s/mindi-boot.1440.img", imagesdir);
     2569            mr_asprintf(&rootdisk_file, "%s/mindi-root.1440.img", imagesdir);
    25672570            root_disk_exists = TRUE;
    25682571            if (!does_file_exist(rootdisk_file)
     
    25722575                log_to_screen
    25732576                    ("Failed to find boot/root floppy images. Oh dear.");
    2574                 paranoid_free(bootdisk_file);
    2575                 paranoid_free(rootdisk_file);
    2576                 paranoid_free(bootdisk_dev);
     2577                mr_free(bootdisk_file);
     2578                mr_free(rootdisk_file);
     2579                mr_free(bootdisk_dev);
    25772580                return (1);
    25782581            }
     
    25862589                    format_disk(datadisk_dev);
    25872590                }
    2588                 asprintf(&tmp, "cat %s > %s", rootdisk_file, datadisk_dev);
     2591                mr_asprintf(&tmp, "cat %s > %s", rootdisk_file, datadisk_dev);
    25892592                log_msg(1, "tmp = '%s'", tmp);
    25902593                res +=
     
    25922595                    ("Writing root floppy", tmp);
    25932596//              res += write_image_to_floppy (datadisk_dev, rootdisk_file);
    2594                 paranoid_free(tmp);
    2595             }
    2596             paranoid_free(rootdisk_file);
    2597             paranoid_free(bootdisk_file);
     2597                mr_free(tmp);
     2598            }
     2599            mr_free(rootdisk_file);
     2600            mr_free(bootdisk_file);
    25982601        }
    25992602#endif
    26002603    }
    2601     paranoid_free(bootdisk_dev);
     2604    mr_free(bootdisk_dev);
    26022605
    26032606    if (IS_THIS_A_STREAMING_BACKUP(bkpinfo->backup_media_type)) {
     
    26072610    }
    26082611    for (i = 1; i < 99; i++) {
    2609         asprintf(&tmp, "%s/mindi-data-%d.img", imagesdir, i);
     2612        mr_asprintf(&tmp, "%s/mindi-data-%d.img", imagesdir, i);
    26102613        log_msg(3, tmp);
    26112614        if (!does_file_exist(tmp)) {
     
    26132616            break;
    26142617        }
    2615         asprintf(&comment, "About to write data disk #%d", i);
     2618        mr_asprintf(&comment, "About to write data disk #%d", i);
    26162619        if (ask_me_OK_or_cancel(comment)) {
    2617             paranoid_free(comment);
    2618             asprintf(&comment, "Writing data disk #%3d", i);
     2620            mr_free(comment);
     2621            mr_asprintf(&comment, "Writing data disk #%3d", i);
    26192622            log_to_screen(comment);
    2620             paranoid_free(comment);
     2623            mr_free(comment);
    26212624            if (format_first) {
    26222625                res += format_disk(datadisk_dev);
     
    26252628        }
    26262629    }
    2627     paranoid_free(tmp);
    2628     paranoid_free(datadisk_dev);
     2630    mr_free(tmp);
     2631    mr_free(datadisk_dev);
    26292632    return (res);
    26302633}
     
    27292732            continue;
    27302733        }
    2731         asprintf(&curr_file, "%s", cf);
     2734        mr_asprintf(&curr_file, "%s", cf);
    27322735        if (!does_file_exist(curr_file)) {
    27332736            log_msg(1,
     
    27522755        retval += res;
    27532756        unlink(curr_file);
    2754         paranoid_free(curr_file);
     2757        mr_free(curr_file);
    27552758        /* write closing header */
    27562759        write_header_block_to_stream((off_t)0, "finished-writing-file", stop_chr);
     
    27862789    if ((cdrw_device = find_cdrw_device()) != NULL) {
    27872790        if (!system("which cdrecord > /dev/null 2> /dev/null")) {
    2788             asprintf(&cdrecord, "cdrecord dev=%s -atip", cdrw_device);
     2791            mr_asprintf(&cdrecord, "cdrecord dev=%s -atip", cdrw_device);
    27892792        } else if (!system("which dvdrecord > /dev/null 2> /dev/null")) {
    2790             asprintf(&cdrecord, "cdrecord dev=%s -atip", cdrw_device);
     2793            mr_asprintf(&cdrecord, "cdrecord dev=%s -atip", cdrw_device);
    27912794        } else {
    2792             asprintf(&cdrecord, " ");
     2795            mr_asprintf(&cdrecord, " ");
    27932796            log_msg(2, "Found no cdrecord nor dvdrecord in path.");
    27942797        }
     
    27972800                run_program_and_log_output(cdrecord, 5);
    27982801        }
    2799         paranoid_free(cdrecord);
     2802        mr_free(cdrecord);
    28002803    }
    28012804    return(cdrw_device);
     
    28272830    char *szunmount;
    28282831
    2829     asprintf(&szmsg, "I am about to burn %s #%d",
     2832    mr_asprintf(&szmsg, "I am about to burn %s #%d",
    28302833             g_backup_media_string,
    28312834             g_current_media_number);
    28322835    log_to_screen(szmsg);
    2833     paranoid_free(szmsg);
     2836    mr_free(szmsg);
    28342837    if (g_current_media_number < ask_for_one_if_more_than_this) {
    28352838        return;
    28362839    }
    28372840    log_to_screen("Scanning CD-ROM drive...");
    2838     asprintf(&mtpt, "/tmp/cd.mtpt.%ld.%ld", (long int) random(),
     2841    mr_asprintf(&mtpt, "/tmp/cd.mtpt.%ld.%ld", (long int) random(),
    28392842             (long int) random());
    28402843    make_hole_for_dir(mtpt);
     
    28482851      retract_CD_tray_and_defeat_autorun();
    28492852*/
    2850         asprintf(&tmp, "umount %s", cdrom_dev);
     2853        mr_asprintf(&tmp, "umount %s", cdrom_dev);
    28512854        run_program_and_log_output(tmp, 1);
    2852         paranoid_free(tmp);
    2853         asprintf(&szcdno, "%s/archives/THIS-CD-NUMBER", mtpt);
    2854         asprintf(&szserfname, "%s/archives/SERIAL-STRING", mtpt);
    2855         asprintf(&szunmount, "umount %s", mtpt);
     2855        mr_free(tmp);
     2856        mr_asprintf(&szcdno, "%s/archives/THIS-CD-NUMBER", mtpt);
     2857        mr_asprintf(&szserfname, "%s/archives/SERIAL-STRING", mtpt);
     2858        mr_asprintf(&szunmount, "umount %s", mtpt);
    28562859        cd_number = -1;
    2857         asprintf(&tmp, "mount %s %s", cdrom_dev, mtpt);
     2860        mr_asprintf(&tmp, "mount %s %s", cdrom_dev, mtpt);
    28582861        if ((attempt_to_mount_returned_this =
    28592862             run_program_and_log_output(tmp, 1))) {
    28602863            log_msg(4, "Failed to mount %s at %s", cdrom_dev, mtpt);
    28612864            log_to_screen("If there's a CD/DVD in the drive, it's blank.");
    2862             asprintf(&our_serial_str, "%s", "");
     2865            mr_asprintf(&our_serial_str, "%s", "");
    28632866        } else if (!does_file_exist(szcdno)
    28642867                   || !does_file_exist(szserfname)) {
     
    28662869                ("%s has data on it but it's probably not a Mondo CD.",
    28672870                 g_backup_media_string);
    2868             asprintf(&our_serial_str, "%s", "");
     2871            mr_asprintf(&our_serial_str, "%s", "");
    28692872        } else {
    28702873            log_to_screen("%s found in drive. It's a Mondo disk.",
     
    28722875            tmp1 = last_line_of_file(szcdno);
    28732876            cd_number = atoi(tmp1);
    2874             paranoid_free(tmp1);
    2875             asprintf(&tmp1, "cat %s 2> /dev/null", szserfname);
     2877            mr_free(tmp1);
     2878            mr_asprintf(&tmp1, "cat %s 2> /dev/null", szserfname);
    28762879            our_serial_str = call_program_and_get_last_line_of_output(tmp1);
    2877             paranoid_free(tmp1);
     2880            mr_free(tmp1);
    28782881            // FIXME - should be able to use last_line_of_file(), surely?
    28792882        }
    2880         paranoid_free(szcdno);
    2881         paranoid_free(szserfname);
    2882         paranoid_free(tmp);
     2883        mr_free(szcdno);
     2884        mr_free(szserfname);
     2885        mr_free(tmp);
    28832886
    28842887        run_program_and_log_output(szunmount, 1);
    2885         paranoid_free(szunmount);
     2888        mr_free(szunmount);
    28862889
    28872890        log_msg(2, "paafcd: cd_number = %d", cd_number);
     
    29042907            log_to_screen("...but not part of _our_ backup set.");
    29052908        }
    2906         paranoid_free(our_serial_str);
     2909        mr_free(our_serial_str);
    29072910    } else {
    29082911        log_msg(2,
     
    29142917                          g_backup_media_string);
    29152918        }
    2916         paranoid_free(cdrw_device);
    2917     }
    2918     paranoid_free(mtpt);
     2919        mr_free(cdrw_device);
     2920    }
     2921    mr_free(mtpt);
    29192922
    29202923    if (!ok_go_ahead_burn_it) {
    29212924        eject_device(cdrom_dev);
    2922         asprintf(&tmp,
     2925        mr_asprintf(&tmp,
    29232926                 "I am about to burn %s #%d of the backup set. Please insert %s and press Enter.",
    29242927                 g_backup_media_string,
     
    29262929                 g_backup_media_string);
    29272930        popup_and_OK(tmp);
    2928         paranoid_free(tmp);
     2931        mr_free(tmp);
    29292932        goto gotos_make_me_puke;
    29302933    } else {
    29312934        log_msg(2, "paafcd: OK, going ahead and burning it.");
    29322935    }
    2933     paranoid_free(cdrom_dev);
     2936    mr_free(cdrom_dev);
    29342937
    29352938    log_msg(2,
     
    30483051    if (is_this_file_compressed(biggie_filename)
    30493052        || bkpinfo->compression_level == 0) {
    3050         asprintf(&suffix, "%s", "");
     3053        mr_asprintf(&suffix, "%s", "");
    30513054        //      log_it("%s is indeed compressed :-)", filename);
    30523055        should_I_compress_slices = FALSE;
    30533056    } else {
    3054         asprintf(&suffix, "%s", bkpinfo->zip_suffix);
     3057        mr_asprintf(&suffix, "%s", bkpinfo->zip_suffix);
    30553058        should_I_compress_slices = TRUE;
    30563059    }
     
    30613064    if (ntfsprog_fifo) {
    30623065        file_to_openin = ntfsprog_fifo;
    3063         asprintf(&checksum_line, "IGNORE");
     3066        mr_asprintf(&checksum_line, "IGNORE");
    30643067        log_msg(2,
    30653068                "Not calculating checksum for %s: it would take too long",
     
    30693072            fatal_error("ntfsresize not found");
    30703073        }
    3071         paranoid_free(tmp);
    3072 
    3073         asprintf(&command, "ntfsresize --force --info %s|grep '^You might resize at '|cut -d' ' -f5", biggie_filename);
     3074        mr_free(tmp);
     3075
     3076        mr_asprintf(&command, "ntfsresize --force --info %s|grep '^You might resize at '|cut -d' ' -f5", biggie_filename);
    30743077        log_it("command = %s", command);
    30753078        tmp = call_program_and_get_last_line_of_output(command);
    3076         paranoid_free(command);
     3079        mr_free(command);
    30773080
    30783081        log_it("res of it = %s", tmp);
    30793082        totallength = (off_t)atoll(tmp);
    3080         paranoid_free(tmp);
     3083        mr_free(tmp);
    30813084    } else {
    30823085        file_to_openin = biggie_filename;
    30833086        if (strchr(biggie_filename,'\'') != NULL) {
    3084             asprintf(&command, "md5sum \"%s\"", biggie_filename);
     3087            mr_asprintf(&command, "md5sum \"%s\"", biggie_filename);
    30853088        } else {
    3086             asprintf(&command, "md5sum '%s'", biggie_filename);
     3089            mr_asprintf(&command, "md5sum '%s'", biggie_filename);
    30873090        }
    30883091        if (!(fin = popen(command, "r"))) {
    30893092            log_OS_error("Unable to popen-in command");
    3090             paranoid_free(command);
     3093            mr_free(command);
    30913094            return (1);
    30923095        }
    3093         paranoid_free(command);
    3094         (void) getline(&checksum_line, &n, fin);
     3096        mr_free(command);
     3097        mr_getline(&checksum_line, &n, fin);
    30953098        pclose(fin);
    30963099        totallength = length_of_file (biggie_filename);
     
    31143117        fatal_error("checksum_line too big");
    31153118    }
    3116     paranoid_free(checksum_line);
     3119    mr_free(checksum_line);
    31173120
    31183121    tmp = slice_fname(biggie_file_number, 0, bkpinfo->tmpdir, "");
    31193122    fout = fopen(tmp, "w");
    3120     paranoid_free(tmp);
     3123    mr_free(tmp);
    31213124    (void) fwrite((void *) &biggiestruct, 1, sizeof(biggiestruct), fout);
    31223125    paranoid_fclose(fout);
     
    31263129    if (!(fin = fopen(file_to_openin, "r"))) {
    31273130        log_OS_error("Unable to openin biggie_filename");
    3128         asprintf(&tmp, "Cannot archive bigfile '%s': not found",
     3131        mr_asprintf(&tmp, "Cannot archive bigfile '%s': not found",
    31293132                 biggie_filename);
    31303133        log_to_screen(tmp);
    3131         paranoid_free(tmp);
    3132 
    3133         paranoid_free(suffix);
     3134        mr_free(tmp);
     3135
     3136        mr_free(suffix);
    31343137        return (1);
    31353138    }
     
    31403143        res = move_files_to_cd(bkpinfo, tmp, NULL);
    31413144    }
    3142     paranoid_free(tmp);
     3145    mr_free(tmp);
    31433146    i = bkpinfo->optimal_set_size / 256;
    31443147    for (slice_num = 1; !finished; slice_num++) {
     
    31483151        tmp = percent_media_full_comment(bkpinfo);
    31493152        update_progress_form(tmp);
    3150         paranoid_free(tmp);
     3153        mr_free(tmp);
    31513154
    31523155        if (!(fout = fopen(curr_slice_fname_uncompressed, "w"))) {
    31533156            log_OS_error(curr_slice_fname_uncompressed);
    31543157
    3155             paranoid_free(curr_slice_fname_uncompressed);
    3156             paranoid_free(curr_slice_fname_compressed);
    3157             paranoid_free(suffix);
     3158            mr_free(curr_slice_fname_uncompressed);
     3159            mr_free(curr_slice_fname_compressed);
     3160            mr_free(suffix);
    31583161            return (1);
    31593162        }
     
    31753178            i = 0;
    31763179        }
    3177         paranoid_free(tempblock);
     3180        mr_free(tempblock);
    31783181        paranoid_fclose(fout);
    31793182        if (i > 0)              // length_of_file (curr_slice_fname_uncompressed)
     
    31853188            }
    31863189            if (should_I_compress_slices && bkpinfo->compression_level > 0) {
    3187                 asprintf(&command, "%s -%d %s", bkpinfo->zip_exe,
     3190                mr_asprintf(&command, "%s -%d %s", bkpinfo->zip_exe,
    31883191                         bkpinfo->compression_level,
    31893192                         curr_slice_fname_uncompressed);
     
    31953198            } else {
    31963199                /* BERLIOS: Useless
    3197                    asprintf(&command, "mv %s %s 2>> %s",
     3200                   mr_asprintf(&command, "mv %s %s 2>> %s",
    31983201                   curr_slice_fname_uncompressed,
    31993202                   curr_slice_fname_compressed, MONDO_LOGFILE);
     
    32123215            }
    32133216            if (res) {
    3214                 asprintf(&tmp, "Problem with slice # %ld", slice_num);
     3217                mr_asprintf(&tmp, "Problem with slice # %ld", slice_num);
    32153218            } else {
    3216                 asprintf(&tmp,
     3219                mr_asprintf(&tmp,
    32173220                         "%s - Bigfile #%ld, slice #%ld compressed OK          ",
    32183221                         biggie_filename, biggie_file_number + 1,
     
    32293232            log_msg(2, tmp);
    32303233#endif
    3231             paranoid_free(tmp);
    3232             asprintf(&file_to_archive, "%s", curr_slice_fname_compressed);
     3234            mr_free(tmp);
     3235            mr_asprintf(&file_to_archive, "%s", curr_slice_fname_compressed);
    32333236            g_current_progress++;
    32343237        } else {                /* if i==0 then ... */
    32353238
    32363239            finished = TRUE;
    3237             asprintf(&file_to_archive, "%s",
     3240            mr_asprintf(&file_to_archive, "%s",
    32383241                     curr_slice_fname_uncompressed);
    32393242            if (IS_THIS_A_STREAMING_BACKUP(bkpinfo->backup_media_type)) {
     
    32513254            res = move_files_to_cd(bkpinfo, file_to_archive, NULL);
    32523255        }
    3253         paranoid_free(file_to_archive);
     3256        mr_free(file_to_archive);
    32543257        retval += res;
    32553258        if (res) {
    3256             asprintf(&tmp,
     3259            mr_asprintf(&tmp,
    32573260                     "Failed to add slice %ld of bigfile %ld to scratchdir",
    32583261                     slice_num, biggie_file_number + 1);
    32593262            log_to_screen(tmp);
    3260             paranoid_free(tmp);
     3263            mr_free(tmp);
    32613264            fatal_error
    32623265                ("Hard disk full. You should have bought a bigger one.");
    32633266        }
    3264         paranoid_free(curr_slice_fname_uncompressed);
    3265         paranoid_free(curr_slice_fname_compressed);
    3266     }
    3267     paranoid_free(suffix);
     3267        mr_free(curr_slice_fname_uncompressed);
     3268        mr_free(curr_slice_fname_compressed);
     3269    }
     3270    mr_free(suffix);
    32683271    paranoid_fclose(fin);
    32693272    if (retval) {
    3270         asprintf(&tmp, "Sliced bigfile #%ld...FAILED",
     3273        mr_asprintf(&tmp, "Sliced bigfile #%ld...FAILED",
    32713274                 biggie_file_number + 1);
    32723275    } else {
    3273         asprintf(&tmp, "Sliced bigfile #%ld...OK!",
     3276        mr_asprintf(&tmp, "Sliced bigfile #%ld...OK!",
    32743277                 biggie_file_number + 1);
    32753278    }
    32763279    log_msg(1, tmp);
    3277     paranoid_free(tmp);
     3280    mr_free(tmp);
    32783281    return (retval);
    32793282}
     
    33003303    assert_string_is_neither_NULL_nor_zerolength(d);
    33013304
    3302     asprintf(&dir, "%s/archives", d);
    3303     asprintf(&tmp, "find %s -name '*.afio*' -exec rm -f '{}' \\;", dir);
     3305    mr_asprintf(&dir, "%s/archives", d);
     3306    mr_asprintf(&tmp, "find %s -name '*.afio*' -exec rm -f '{}' \\;", dir);
    33043307    run_program_and_log_output(tmp, FALSE);
    3305     paranoid_free(tmp);
    3306 
    3307     asprintf(&tmp, "find %s -name '*list.[0-9]*' -exec rm -f '{}' \\;",
     3308    mr_free(tmp);
     3309
     3310    mr_asprintf(&tmp, "find %s -name '*list.[0-9]*' -exec rm -f '{}' \\;",
    33083311             dir);
    33093312    run_program_and_log_output(tmp, FALSE);
    3310     paranoid_free(tmp);
    3311 
    3312     asprintf(&tmp, "find %s -name 'slice*' -exec rm -f '{}' \\;", dir);
     3313    mr_free(tmp);
     3314
     3315    mr_asprintf(&tmp, "find %s -name 'slice*' -exec rm -f '{}' \\;", dir);
    33133316    run_program_and_log_output(tmp, FALSE);
    3314     paranoid_free(tmp);
    3315 
    3316     asprintf(&tmp, "rm -f %s/cklist*", dir);
     3317    mr_free(tmp);
     3318
     3319    mr_asprintf(&tmp, "rm -f %s/cklist*", dir);
    33173320    run_program_and_log_output(tmp, FALSE);
    3318     paranoid_free(tmp);
    3319 
    3320     asprintf(&tmp, "rm -f %s/zero", dir);
     3321    mr_free(tmp);
     3322
     3323    mr_asprintf(&tmp, "rm -f %s/zero", dir);
    33213324    run_program_and_log_output(tmp, FALSE);
    3322     paranoid_free(tmp);
     3325    mr_free(tmp);
    33233326
    33243327    log_msg(1, "Wiped %s's archives", dir);
    3325     asprintf(&tmp, "ls -l %s", dir);
     3328    mr_asprintf(&tmp, "ls -l %s", dir);
    33263329    run_program_and_log_output(tmp, FALSE);
    3327     paranoid_free(tmp);
    3328 
    3329     paranoid_free(dir);
     3330    mr_free(tmp);
     3331
     3332    mr_free(dir);
    33303333}
    33313334
     
    33573360// I should really check if there are any slices or tarballs to be copied to CD-R(W)'s; the odds are approx. 1 in a million that there are no files here, so I'll just go ahead & make one more CD anyway
    33583361
    3359     asprintf(&tmp, "Writing the final ISO");
     3362    mr_asprintf(&tmp, "Writing the final ISO");
    33603363    log_msg(2, tmp);
    33613364    /* BERLIOS: center_string is now broken
     
    33673370    }
    33683371#endif
    3369     paranoid_free(tmp);
     3372    mr_free(tmp);
    33703373    res = write_iso_and_go_on(bkpinfo, TRUE);
    33713374#ifndef _XWIN
     
    34323435    /* label the ISO with its number */
    34333436
    3434     asprintf(&cdno_fname, "%s/archives/THIS-CD-NUMBER",
     3437    mr_asprintf(&cdno_fname, "%s/archives/THIS-CD-NUMBER",
    34353438             bkpinfo->scratchdir);
    34363439    fout = fopen(cdno_fname, "w");
    34373440    fprintf(fout, "%d", g_current_media_number);
    34383441    paranoid_fclose(fout);
    3439     paranoid_free(cdno_fname);
    3440 
    3441     asprintf(&tmp, "cp -f %s/autorun %s/", g_mondo_home,
     3442    mr_free(cdno_fname);
     3443
     3444    mr_asprintf(&tmp, "cp -f %s/autorun %s/", g_mondo_home,
    34423445             bkpinfo->scratchdir);
    34433446    if (run_program_and_log_output(tmp, FALSE)) {
    34443447        log_msg(2, "Warning - unable to copy autorun to scratchdir");
    34453448    }
    3446     paranoid_free(tmp);
     3449    mr_free(tmp);
    34473450
    34483451    /* last CD or not? Label accordingly */
    3449     asprintf(&lastcd_fname, "%s/archives/NOT-THE-LAST",
     3452    mr_asprintf(&lastcd_fname, "%s/archives/NOT-THE-LAST",
    34503453             bkpinfo->scratchdir);
    34513454    if (last_cd) {
     
    34593462        paranoid_fclose(fout);
    34603463    }
    3461     paranoid_free(lastcd_fname);
     3464    mr_free(lastcd_fname);
    34623465
    34633466    if (space_occupied_by_cd(bkpinfo->scratchdir) / 1024 >
    34643467        bkpinfo->media_size[g_current_media_number]) {
    3465         asprintf(&tmp,
     3468        mr_asprintf(&tmp,
    34663469                 "Warning! CD is too big. It occupies %ld KB, which is more than the %ld KB allowed.",
    34673470                 (long) space_occupied_by_cd(bkpinfo->scratchdir),
    34683471                 (long) bkpinfo->media_size[g_current_media_number]);
    34693472        log_to_screen(tmp);
    3470         paranoid_free(tmp);
    3471     }
    3472     asprintf(&isofile, "%s/%s/%s-%d.iso", bkpinfo->isodir,
     3473        mr_free(tmp);
     3474    }
     3475    mr_asprintf(&isofile, "%s/%s/%s-%d.iso", bkpinfo->isodir,
    34733476             bkpinfo->nfs_remote_dir, bkpinfo->prefix,
    34743477             g_current_media_number);
     
    34853488            else {
    34863489                log_msg(3, "Great. Found Mike's CD-ROM drive.");
    3487                 paranoid_free(tmp);
     3490                mr_free(tmp);
    34883491            }
    34893492        }
     
    35003503            that_one_was_ok = TRUE;
    35013504        } else {
    3502             asprintf(&tmp, "Failed to burn %s #%d. Retry?",
     3505            mr_asprintf(&tmp, "Failed to burn %s #%d. Retry?",
    35033506                     bkpinfo->backup_media_string,
    35043507                     g_current_media_number);
    35053508            res = ask_me_yes_or_no(tmp);
    3506             paranoid_free(tmp);
     3509            mr_free(tmp);
    35073510            if (!res) {
    35083511                if (ask_me_yes_or_no("Abort the backup?")) {
     
    35203523  if (using_nfs)
    35213524    {
    3522       asprintf(&tmp,"mv -f %s %s/%s/", isofile, bkpinfo->isodir, bkpinfo->nfs_remote_dir);
     3525      mr_asprintf(&tmp,"mv -f %s %s/%s/", isofile, bkpinfo->isodir, bkpinfo->nfs_remote_dir);
    35233526      if (run_program_and_log_output(tmp, FALSE))
    35243527        { log_to_screen("Unable to move ISO to NFS dir"); }
    35253528    }
    35263529*/
    3527     paranoid_free(isofile);
     3530    mr_free(isofile);
    35283531
    35293532    g_current_media_number++;
     
    35323535    }
    35333536    wipe_archives(bkpinfo->scratchdir);
    3534     asprintf(&tmp, "rm -Rf %s/images/*gz %s/images/*data*img",
     3537    mr_asprintf(&tmp, "rm -Rf %s/images/*gz %s/images/*data*img",
    35353538             bkpinfo->scratchdir, bkpinfo->scratchdir);
    35363539    if (system(tmp)) {
     
    35383541                "Error occurred when I tried to delete the redundant IMGs and GZs");
    35393542    }
    3540     paranoid_free(tmp);
     3543    mr_free(tmp);
    35413544
    35423545    if (last_cd) {
     
    35763579                            "Verifying archives against live filesystem");
    35773580        if (bkpinfo->backup_media_type == cdstream) {
    3578             paranoid_alloc(bkpinfo->media_device,"/dev/cdrom");
     3581            mr_allocstr(bkpinfo->media_device,"/dev/cdrom");
    35793582        }
    35803583        verify_tape_backups(bkpinfo);
     
    36063609            retval += res;
    36073610            if (res) {
    3608                 asprintf(&tmp,
     3611                mr_asprintf(&tmp,
    36093612                         "Warnings/errors were reported while checking %s #%d",
    36103613                         bkpinfo->backup_media_string,
    36113614                         g_current_media_number);
    36123615                log_to_screen(tmp);
    3613                 paranoid_free(tmp);
    3614 
    3615             }
    3616         }
    3617         asprintf(&tmp,
     3616                mr_free(tmp);
     3617
     3618            }
     3619        }
     3620        mr_asprintf(&tmp,
    36183621                 "grep 'afio: ' %s | sed 's/afio: //' | grep -vx '/dev/.*' >> /tmp/changed.files",
    36193622                 MONDO_LOGFILE);
    36203623        system(tmp);
    3621         paranoid_free(tmp);
    3622 
    3623         asprintf(&tmp,
     3624        mr_free(tmp);
     3625
     3626        mr_asprintf(&tmp,
    36243627                 "grep 'star: ' %s | sed 's/star: //' | grep -vx '/dev/.*' >> /tmp/changed.files",
    36253628                 MONDO_LOGFILE);
    36263629        system(tmp);
    3627         paranoid_free(tmp);
     3630        mr_free(tmp);
    36283631
    36293632        run_program_and_log_output("umount " MNT_CDROM, FALSE);
     
    36763679        p++;
    36773680    }
    3678     asprintf(&title, "Writing %s to floppy", p);
     3681    mr_asprintf(&title, "Writing %s to floppy", p);
    36793682    open_evalcall_form(title);
    3680     paranoid_free(title);
     3683    mr_free(title);
    36813684
    36823685    /* functional stuff */
     
    36873690        maxblocks = 1440;
    36883691    }
    3689     asprintf(&tmp, "maxblocks = %d; p=%s", maxblocks, p);
     3692    mr_asprintf(&tmp, "maxblocks = %d; p=%s", maxblocks, p);
    36903693    log_msg(2, tmp);
    3691     paranoid_free(tmp);
     3694    mr_free(tmp);
    36923695
    36933696    /* copy data from image to floppy */
     
    37633766    char *param = NULL;
    37643767
    3765     mr_conf = (struct s_mr_conf *)malloc(sizeof(struct s_mr_conf));
    3766     if (mr_conf == NULL) {
    3767             fatal_error("Unable to malloc mr_conf");
    3768     }
    3769     /* Default for everything int : 0 char * : NULL */
     3768    mr_conf = (struct s_mr_conf *)mr_malloc(sizeof(struct s_mr_conf));
    37703769
    37713770    /* mindi conf parameters also needed in mondo */
    3772     mr_conf->mindi_ia64_boot_size = 0;
    3773 
    3774     asprintf(&command, "mindi -printvar IA64_BOOT_SIZE");
     3771    mr_asprintf(&command, "mindi -printvar IA64_BOOT_SIZE");
    37753772    fin = popen(command, "r");
    3776     getline(&param, &n, fin);
     3773    mr_getline(&param, &n, fin);
    37773774    pclose(fin);
    3778     paranoid_free(command);
     3775    mr_free(command);
     3776
    37793777    mr_conf->mindi_ia64_boot_size = atoi(param);
    3780     paranoid_free(param);
    3781 
    3782     mr_conf->mondo_iso_creation_cmd = NULL;
     3778    mr_free(param);
    37833779
    37843780    /* Finds mondo conf file */
     
    37863782
    37873783    /* mondo conf parameters needed */
    3788     mr_conf->mondo_iso_creation_cmd = mr_conf_sread("mondo_iso_creation_cmd");
     3784    if ((mr_conf->mondo_iso_creation_cmd = mr_conf_sread("mondo_iso_creation_cmd")) == NULL) {;
     3785        mr_log_exit(-1,"Unable to get mondo_iso_creation_cmd parameter from conf file\nAborting...\n");
     3786    }
     3787
     3788    if ((mr_conf->mondo_logfile = mr_conf_sread("mondo_logfile")) == NULL) {
     3789        mr_log_exit(-1,"Unable to get mondo_logfile parameter from conf file\nAborting...\n");
     3790    }
    37893791
    37903792    mr_conf_close();
Note: See TracChangeset for help on using the changeset viewer.