Ignore:
Timestamp:
Sep 25, 2013, 8:55:39 AM (11 years ago)
Author:
Bruno Cornec
Message:
  • Backport tons of dynamic memory management rewrite from 3.1 branch. Test is needed
File:
1 edited

Legend:

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

    r3185 r3188  
    6464extern bool g_cd_recovery;
    6565extern char *g_mondo_home;
    66 /*
    67 extern char *g_tmpfs_mountpt;
    68 */
    69 extern char *g_serial_string;
     66
     67/**
     68 * The serial string (used to differentiate between backups) of the current backup.
     69 */
     70char *g_serial_string = NULL;
     71
    7072extern char *g_getfacl;
    7173extern char *g_getfattr;
     
    200202
    201203    if (!does_file_exist(filelist)) {
    202         mr_asprintf(tmp, "(archive_this_fileset) - filelist %s does not exist", filelist);
    203         log_to_screen(tmp);
    204         paranoid_free(tmp);
     204        log_to_screen("(archive_this_fileset) - filelist %s does not exist", filelist);
    205205        return (1);
    206206    }
     
    208208    mr_asprintf(tmp, "echo hi > %s 2> /dev/null", fname);
    209209    if (system(tmp)) {
    210         paranoid_free(tmp);
     210        mr_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",
    216             filelist, fname);
     215    mr_asprintf(command, "star H=exustar list=%s -c -sparse " STAR_ACL_SZ " file=%s", filelist, fname);
    217216    if (bkpinfo->use_lzo) {
     217        mr_free(command);
    218218        fatal_error("Can't use lzop");
    219219    }
     
    235235            res = 0;
    236236        }
    237         paranoid_free(tmp);
     237        mr_free(tmp);
    238238
    239239        if (res) {
     
    251251        }
    252252    }
    253     paranoid_free(command);
     253    mr_free(command);
    254254
    255255    retval += res;
     
    307307
    308308    if (!does_file_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);
     309        log_to_screen("(archive_this_fileset) - filelist %s does not exist", filelist);
    313310        return (1);
    314311    }
    315312    mr_asprintf(tmp, "echo hi > %s 2> /dev/null", fname);
    316313    if (system(tmp)) {
    317         paranoid_free(tmp);
     314        mr_free(tmp);
    318315        fatal_error("Unable to write tarball to scratchdir");
    319316    }
    320     paranoid_free(tmp);
     317    mr_free(tmp);
    321318
    322319
     
    324321        mr_asprintf(tmp, "%s/do-not-compress-these", g_mondo_home);
    325322        //       -b %ld, TAPE_BLOCK_SIZE
    326         mr_asprintf(zipparams, "-Z -P %s -G %d -T 3k", bkpinfo->zip_exe,
    327                 bkpinfo->compression_level);
     323        mr_asprintf(zipparams, "-Z -P %s -G %d -T 3k", bkpinfo->zip_exe, bkpinfo->compression_level);
    328324        if (does_file_exist(tmp)) {
    329325            mr_strcat(zipparams, " -E %s",tmp);
     
    331327            log_msg(3, "%s not found. Cannot exclude zipfiles, etc.", tmp);
    332328        }
    333         paranoid_free(tmp);
     329        mr_free(tmp);
    334330    } else {
    335331        mr_asprintf(zipparams, "");
    336332    }
    337 
    338 //  make_hole_for_file(fname);
    339333
    340334    if (!does_file_exist(bkpinfo->tmpdir)) {
     
    346340        fatal_error("scratchdir not found");
    347341    }
    348     mr_asprintf(command, "rm -f %s %s. %s.gz %s.%s", fname, fname, fname,
    349             fname, bkpinfo->zip_suffix);
     342    mr_asprintf(command, "rm -f %s %s. %s.gz %s.%s", fname, fname, fname, fname, bkpinfo->zip_suffix);
    350343    paranoid_system(command);
    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);
     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);
    356348
    357349    mr_asprintf(tmp, "echo hi > %s 2> /dev/null", fname);
    358350    if (system(tmp)) {
    359         paranoid_free(tmp);
     351        mr_free(tmp);
    360352        fatal_error("Unable to write tarball to scratchdir");
    361353    }
    362     paranoid_free(tmp);
     354    mr_free(tmp);
    363355
    364356    for (res = 99, tries = 0; tries < 3 && res != 0; tries++) {
     
    406398{
    407399    int retval = 0, res = 0;
    408     char *tmp;
     400    char *tmp = NULL;
    409401
    410402    assert(bkpinfo != NULL);
    411403    set_g_cdrom_and_g_dvd_to_bkpinfo_value();
    412     malloc_string(tmp);
    413404    if (bkpinfo->backup_media_type == dvd) {
    414405#ifdef DVDRWFORMAT
     
    431422    }
    432423
    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);
     424    mr_asprintf(tmp, "gzip -9 %s/archives/filelist.full", bkpinfo->scratchdir);
    439425    if (run_program_and_log_output(tmp, 2)) {
     426        mr_free(tmp);
    440427        fatal_error("Failed to gzip filelist.full");
    441428    }
    442     sprintf(tmp, "cp -f %s/archives/*list*.gz %s", bkpinfo->scratchdir,
    443             bkpinfo->tmpdir);
     429    mr_free(tmp);
     430
     431    mr_asprintf(tmp, "cp -f %s/archives/*list*.gz %s", bkpinfo->scratchdir, bkpinfo->tmpdir);
    444432    if (run_program_and_log_output(tmp, 2)) {
     433        mr_free(tmp);
    445434        fatal_error("Failed to copy to tmpdir");
    446435    }
     436    mr_free(tmp);
    447437
    448438    copy_mondo_and_mindi_stuff_to_scratchdir(); // payload, too, if it exists
     
    464454    }
    465455    retval += do_that_initial_phase();  // prepare
    466     sprintf(tmp, "rm -f %s/images/*.iso", bkpinfo->scratchdir);
     456    mr_asprintf(tmp, "rm -f %s/images/*.iso", bkpinfo->scratchdir);
    467457    run_program_and_log_output(tmp, 1);
     458    mr_free(tmp);
     459
    468460    retval += make_those_afios_phase(); // backup regular files
    469461    retval += make_those_slices_phase();    // backup BIG files
     
    473465        sleep(2);
    474466    }
    475     paranoid_free(tmp);
    476467    return (retval);
    477468}
     
    514505    char *use_lzo_sz = NULL;
    515506    char *use_gzip_sz = NULL;
     507    char *use_lzma_sz = NULL;
    516508    char *use_comp_sz = NULL;
    517509    char *use_star_sz = NULL;
     
    542534    assert(bkpinfo != NULL);
    543535
    544     mvaddstr_and_log_it(g_currentY, 0,
    545                         "Calling MINDI to create boot+data disks");
     536    mvaddstr_and_log_it(g_currentY, 0, "Calling MINDI to create boot+data disks");
    546537    open_evalcall_form("Calling MINDI to create boot+data disks");
    547538    mr_asprintf(tmp, "%s/filelist.full", bkpinfo->tmpdir);
     
    550541        mr_asprintf(tmp, "%s/tmpfs/filelist.full", bkpinfo->tmpdir);
    551542        if (!does_file_exist(tmp)) {
    552             fatal_error
    553                 ("Cannot find filelist.full, so I cannot count its lines");
     543            mr_free(tmp);
     544            fatal_error ("Cannot find filelist.full, so I cannot count its lines");
    554545        }
    555546    }
     
    571562            }
    572563        }
    573         paranoid_free(ntapedev);
     564        mr_free(ntapedev);
    574565        mr_asprintf(tape_device, "%s", bkpinfo->media_device);
    575566    } else {
     
    586577    } else {
    587578        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");
    588584    }
    589585    if (bkpinfo->use_star) {
     
    660656            ch = 'U';
    661657        if (bkpinfo->boot_loader != '\0') {
    662             mr_asprintf(tmp, "User specified boot loader. It is '%c'.", bkpinfo->boot_loader);
    663             log_msg(2, tmp);
    664             mr_free(tmp);
     658            log_msg(2, "User specified boot loader. It is '%c'.", bkpinfo->boot_loader);
    665659        } else {
    666660            bkpinfo->boot_loader = ch;
    667661        }
    668662        if (bkpinfo->boot_device[0] != '\0') {
    669             mr_asprintf(tmp, "User specified boot device. It is '%s'.", bkpinfo->boot_device);
    670             log_msg(2, tmp);
    671             mr_free(tmp);
     663            log_msg(2, "User specified boot device. It is '%s'.", bkpinfo->boot_device);
    672664        } else {
    673665            strcpy(bkpinfo->boot_device, bootdev);
     
    692684        mr_asprintf(bootldr_str, "LILO");
    693685        if (!does_file_exist("/etc/lilo.conf")) {
    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?");
     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?");
    696687        }
    697688    } else if (bkpinfo->boot_loader == 'G') {
    698689        mr_asprintf(bootldr_str, "GRUB");
    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);
     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);
    703692        }
    704693        if ((!does_file_exist("/boot/grub/menu.lst")) && (!does_file_exist("/boot/grub/grub.cfg")) && (!does_file_exist("/boot/grub2/grub.cfg"))) {
    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?");
     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?");
    707695        }
    708696        mr_asprintf(bootldr_ver, "%s", call_program_and_get_last_line_of_output("grub --version"));
     
    710698        mr_asprintf(bootldr_str, "ELILO");
    711699        /* BCO: fix it for Debian, Mandrake, ... */
    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);
     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);
    735711        }
    736712        if (!does_file_exist("/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'");
     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'");
    739714        }
    740715    } else if (bkpinfo->boot_loader == 'R') {
     
    753728        mr_asprintf(bootldr_str, "unknown");
    754729    }
    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);
     730    log_to_screen("Your boot loader is %s and it boots from %s", bootldr_str, bkpinfo->boot_device);
     731
    758732    if (bootldr_ver != NULL) {
    759         mr_asprintf(tmp, "Boot loader version string: %s", bootldr_ver);
    760         log_to_screen(tmp);
    761         mr_free(tmp);
     733        log_to_screen("Boot loader version string: %s", bootldr_ver);
    762734    }
    763735
     
    799771        fatal_error("Unknown backup_media_type");
    800772    }
    801     if (bkpinfo->backup_media_type == usb) {
     773
     774    if ((bkpinfo->backup_media_type == usb) && (bkpinfo->media_device)) {
    802775        mr_asprintf(tmp2, "--usb %s", bkpinfo->media_device);
    803776    } else {
     
    808781    if (write_one_liner_data_file(tmp, value)) {
    809782        res++;
    810         log_msg(1, "%ld: Unable to write one-liner backup-media-type",
    811                 __LINE__);
     783        log_msg(1, "%ld: Unable to write one-liner backup-media-type", __LINE__);
    812784    }
    813785    mr_free(value);
     
    817789    if (write_one_liner_data_file(tmp, bootldr_str)) {
    818790        res++;
    819         log_msg(1, "%ld: Unable to write one-liner bootloader.name",
    820                 __LINE__);
     791        log_msg(1, "%ld: Unable to write one-liner bootloader.name", __LINE__);
    821792    }
    822793    mr_free(bootldr_str);
     
    865836    }
    866837
    867     estimated_total_noof_slices =
    868         size_of_all_biggiefiles_K(bkpinfo) / bkpinfo->optimal_set_size + 1;
    869     /* add netfs stuff here? */
     838    estimated_total_noof_slices = size_of_all_biggiefiles_K(bkpinfo) / bkpinfo->optimal_set_size + 1;
     839
     840    /* TODO: add netfs stuff here? */
    870841    mr_asprintf(command, "mkdir -p %s/images", bkpinfo->scratchdir);
    871842    if (system(command)) {
     
    873844        log_OS_error("Unable to make images directory");
    874845    }
    875     paranoid_free(command);
     846    mr_free(command);
    876847    log_msg(1, "lines_in_filelist = %ld", lines_in_filelist);
    877848    update_evalcall_form(3);
     
    890861            use_lzo_sz,         // parameter #8
    891862            cd_recovery_sz,     // parameter #9
    892             bkpinfo->image_devs,    // parameter #10
     863            (bkpinfo->image_devs == NULL) ? "\"\"" : bkpinfo->image_devs,   // parameter #10
    893864            broken_bios_sz,     // parameter #11
    894865            last_filelist_number,   // parameter #12 (STRING)
     
    900871            bkpinfo->internal_tape_block_size,  // parameter #18 (LONG)
    901872            bkpinfo->differential,  // parameter #19 (INT)
    902             use_gzip_sz);       // parameter #20 (STRING)
     873            use_gzip_sz,        // parameter #19 (STRING)
     874            use_lzma_sz,        // parameter #20 (STRING)
     875            value,              // parameter #21 (STRING)
     876            MONDO_LOGFILE);
    903877
    904878    mr_free(last_filelist_number);
     
    906880    mr_free(use_lzo_sz);
    907881    mr_free(use_gzip_sz);
     882    mr_free(use_lzma_sz);
    908883    mr_free(use_star_sz);
    909884    mr_free(use_comp_sz);
     
    913888    mr_free(tape_size_sz);
    914889
     890    /* This parameter is always the last one and optional */
    915891    if (bkpinfo->nonbootable_backup) {
    916892        mr_strcat(command, " NONBOOTABLE");
     
    929905    if (!res) {
    930906        log_to_screen("Boot+data disks were created OK");
    931         mr_asprintf(command, "cp -f %s/images/mindi.iso %s/mondorescue.iso",
    932                 bkpinfo->scratchdir, MINDI_CACHE);
     907        mr_asprintf(command, "cp -f %s/images/mindi.iso %s/mondorescue.iso", bkpinfo->scratchdir, MINDI_CACHE);
    933908        log_msg(2, command);
    934909        run_program_and_log_output(command, FALSE);
    935         paranoid_free(command);
     910        mr_free(command);
    936911
    937912        if (bkpinfo->nonbootable_backup) {
    938             mr_asprintf(command, "cp -f %s/all.tar.gz %s/images",
    939                     bkpinfo->tmpdir, bkpinfo->scratchdir);
     913            mr_asprintf(command, "cp -f %s/all.tar.gz %s/images", bkpinfo->tmpdir, bkpinfo->scratchdir);
    940914            if (system(command)) {
    941                 paranoid_free(command);
     915                mr_free(command);
    942916                fatal_error("Unable to create temporary all tarball");
    943917            }
    944             paranoid_free(command);
     918            mr_free(command);
    945919        }
    946920        /* For USB we already have everything on the key */
     
    948922            mr_asprintf(command, "rm -rf %s/images", bkpinfo->scratchdir);
    949923            run_program_and_log_output(command, FALSE);
    950             paranoid_free(command);
     924            mr_free(command);
    951925        } else {
    952             mr_asprintf(tmp, "cp -f %s/images/all.tar.gz %s", bkpinfo->scratchdir,
    953                 bkpinfo->tmpdir);
     926            mr_asprintf(tmp, "cp -f %s/images/all.tar.gz %s", bkpinfo->scratchdir, bkpinfo->tmpdir);
    954927            if (system(tmp)) {
    955928                fatal_error("Cannot find all.tar.gz in tmpdir");
     
    966939        mr_asprintf(command, "grep 'Fatal error' /var/log/mindi.log");
    967940        mr_asprintf(tmp, "%s", call_program_and_get_last_line_of_output(command));
    968         paranoid_free(command);
     941        mr_free(command);
    969942
    970943        if (strlen(tmp) > 1) {
     
    1017990void *create_afio_files_in_background(void *inbuf)
    1018991{
    1019     long int archiving_set_no;
    1020     char *archiving_filelist_fname;
    1021     char *archiving_afioball_fname;
     992    long int archiving_set_no = 0L;
     993    char *archiving_filelist_fname = NULL;
     994    char *archiving_afioball_fname = NULL;
    1022995    char *curr_xattr_list_fname = NULL;
    1023     char *curr_acl_list_fname;
    1024 
    1025     char *tmp;
     996    char *curr_acl_list_fname = NULL;
     997
     998    char *tmp = NULL;
    1026999    int res = 0, retval = 0;
    10271000    int *p_archival_threads_running;
     
    10311004    int this_thread_no = g_current_thread_no++;
    10321005
    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);
    10381006    p_last_set_archived = (int *) inbuf;
    10391007    p_archival_threads_running = (int *) (inbuf + 4);
     
    10411009    p_list_of_fileset_flags = (char *) (inbuf + 12);
    10421010
    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)) {
     1011    mr_asprintf(archiving_filelist_fname, FILELIST_FNAME_RAW_SZ, bkpinfo->tmpdir, 0L);
     1012
     1013    while (does_file_exist(archiving_filelist_fname)) {
    10481014        if (g_exiting) {
     1015            mr_free(archiving_filelist_fname);
    10491016            fatal_error("Execution run aborted (pthread)");
    10501017        }
    10511018        if (archiving_set_no >= MAX_NOOF_SETS_HERE) {
    1052             fatal_error
    1053                 ("Maximum number of filesets exceeded. Adjust MAX_NOOF_SETS_HERE, please.");
     1019            mr_free(archiving_filelist_fname);
     1020            fatal_error("Maximum number of filesets exceeded. Adjust MAX_NOOF_SETS_HERE, please.");
    10541021        }
    10551022        if (!semaphore_p()) {
    10561023            log_msg(3, "P sem failed (pid=%d)", (int) getpid());
     1024            mr_free(archiving_filelist_fname);
    10571025            fatal_error("Cannot get semaphore P");
    10581026        }
     
    10621030        *p_next_set_to_archive = *p_next_set_to_archive + 1;
    10631031        if (!semaphore_v()) {
     1032            mr_free(archiving_filelist_fname);
    10641033            fatal_error("Cannot get semaphore V");
    10651034        }
    10661035
    10671036        /* backup this set of files */
    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);
     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);
    10721040        if (!does_file_exist(archiving_filelist_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);
     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);
    10771043            break;
    10781044        }
    10791045
    1080         sprintf(tmp, AFIOBALL_FNAME_RAW_SZ, bkpinfo->tmpdir,
    1081                 archiving_set_no - ARCH_BUFFER_NUM, bkpinfo->zip_suffix);
     1046        mr_asprintf(tmp, AFIOBALL_FNAME_RAW_SZ, bkpinfo->tmpdir, archiving_set_no - ARCH_BUFFER_NUM, bkpinfo->zip_suffix);
    10821047        if (does_file_exist(tmp)) {
    1083             log_msg(4, "%s[%d:%d] - waiting for storer", FORTY_SPACES,
    1084                     getpid(), this_thread_no);
     1048            log_msg(4, "%s[%d:%d] - waiting for storer", FORTY_SPACES, getpid(), this_thread_no);
    10851049            while (does_file_exist(tmp)) {
    10861050                sleep(1);
     
    10881052            log_msg(4, "[%d] - continuing", getpid());
    10891053        }
    1090 
    1091         log_msg(4, "%s[%d:%d] - EXATing %d...", FORTY_SPACES, getpid(),
    1092                 this_thread_no, archiving_set_no);
     1054        mr_free(tmp);
     1055
     1056        log_msg(4, "%s[%d:%d] - EXATing %d...", FORTY_SPACES, getpid(), this_thread_no, archiving_set_no);
     1057
    10931058        if (g_getfattr) {
    1094             sprintf(curr_xattr_list_fname, XATTR_LIST_FNAME_RAW_SZ,
    1095                 bkpinfo->tmpdir, archiving_set_no);
     1059            mr_asprintf(curr_xattr_list_fname, XATTR_LIST_FNAME_RAW_SZ, bkpinfo->tmpdir, archiving_set_no);
    10961060            get_fattr_list(archiving_filelist_fname, curr_xattr_list_fname);
     1061            mr_free(curr_xattr_list_fname);
    10971062        }
    10981063        if (g_getfacl) {
    1099             sprintf(curr_acl_list_fname, ACL_LIST_FNAME_RAW_SZ,
    1100                 bkpinfo->tmpdir, archiving_set_no);
     1064            mr_asprintf(curr_acl_list_fname, ACL_LIST_FNAME_RAW_SZ, bkpinfo->tmpdir, archiving_set_no);
    11011065            get_acl_list(archiving_filelist_fname, curr_acl_list_fname);
    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);
     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
    11101073        retval += res;
    11111074
    11121075        if (res) {
    1113             sprintf(tmp,
    1114                     "Errors occurred while archiving set %ld. Please review logs.",
    1115                     archiving_set_no);
    1116             log_to_screen(tmp);
    1117         }
     1076            log_to_screen("Errors occurred while archiving set %ld. Please review logs.", archiving_set_no);
     1077        }
     1078
    11181079        if (!semaphore_p()) {
     1080            mr_free(archiving_filelist_fname);
    11191081            fatal_error("Cannot get semaphore P");
    11201082        }
     
    11271089
    11281090        if (!semaphore_v()) {
     1091            mr_free(archiving_filelist_fname);
    11291092            fatal_error("Cannot get semaphore V");
    11301093        }
    1131         log_msg(4, "%s[%d:%d] - archived %d OK", FORTY_SPACES, getpid(),
    1132                 this_thread_no, archiving_set_no);
     1094        log_msg(4, "%s[%d:%d] - archived %d OK", FORTY_SPACES, getpid(), this_thread_no, archiving_set_no);
    11331095        archiving_set_no++;
    1134     }
     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
    11351102    if (!semaphore_p()) {
    11361103        fatal_error("Cannot get semaphore P");
     
    11401107        fatal_error("Cannot get semaphore V");
    11411108    }
    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);
     1109    log_msg(3, "%s[%d:%d] - exiting", FORTY_SPACES, getpid(), this_thread_no);
    11491110    pthread_exit(NULL);
    11501111}
     
    12281189
    12291190    /*@ buffers *********************************** */
    1230     char *command, *tmpfile, *data_disks_file;
     1191    char *command = NULL;
     1192    char *tmpfile = NULL;
     1193    char *data_disks_file = NULL;
    12311194
    12321195    assert(bkpinfo != NULL);
    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 \
    1240 if=/dev/urandom bs=16 count=1 2> /dev/null | \
    1241 hexdump | tr -s ' ' '0' | head -n1"));
     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"));
    12421199    strip_spaces(g_serial_string);
    12431200    strcat(g_serial_string, "...word.");
     
    12451202    assert(strlen(g_serial_string) < MAX_STR_LEN);
    12461203
    1247     sprintf(tmpfile, "%s/archives/SERIAL-STRING", bkpinfo->scratchdir);
     1204    mr_asprintf(tmpfile, "%s/archives/SERIAL-STRING", bkpinfo->scratchdir);
    12481205    if (write_one_liner_data_file(tmpfile, g_serial_string)) {
    12491206        log_msg(1, "%ld: Failed to write serial string", __LINE__);
    12501207    }
     1208    mr_free(tmpfile);
    12511209
    12521210    mvaddstr_and_log_it(g_currentY, 0, "Preparing to archive your data");
     
    12691227        }
    12701228    }
    1271 
    1272     sprintf(command, "rm -f %s/%s/%s-[1-9]*.iso", bkpinfo->isodir,
    1273             bkpinfo->netfs_remote_dir, bkpinfo->prefix);
     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);
    12741232    paranoid_system(command);
     1233    mr_free(command);
     1234
    12751235    wipe_archives(bkpinfo->scratchdir);
    12761236    mvaddstr_and_log_it(g_currentY++, 74, "Done.");
     
    12811241                                     BLK_START_OF_BACKUP);
    12821242    }
    1283     paranoid_free(command);
    1284     paranoid_free(tmpfile);
    1285     paranoid_free(data_disks_file);
    12861243    return (retval);
    12871244}
     
    13561313
    13571314    /*@ buffers ********************************************** */
    1358     char *storing_filelist_fname;
    1359     char *storing_afioball_fname;
     1315    char *storing_filelist_fname = NULL;
     1316    char *storing_afioball_fname = NULL;
    13601317    char *tmp = NULL;
    13611318    char *media_usage_comment = NULL;
     
    13741331    assert(bkpinfo != NULL);
    13751332    malloc_string(result_str);
    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);
     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);
    13841335    p_last_set_archived = (int *) transfer_block;
    13851336    p_archival_threads_running = (int *) (transfer_block + 4);
    13861337    p_next_set_to_archive = (int *) (transfer_block + 8);
    13871338    p_list_of_fileset_flags = (char *) (transfer_block + 12);
    1388     memcpy((void *) (transfer_block + BKPINFO_LOC_OFFSET),
    1389            (void *) bkpinfo, sizeof(struct s_bkpinfo));
     1339    memcpy((void *) (transfer_block + BKPINFO_LOC_OFFSET), (void *) bkpinfo, sizeof(struct s_bkpinfo));
    13901340    pvp = &vp;
    13911341    vp = (void *) result_str;
     
    13991349                       "Please wait. This may take a couple of hours.",
    14001350                       "Working...",
    1401                        get_last_filelist_number() + 1);
     1351                       (long)get_last_filelist_number() + 1L);
    14021352
    14031353    log_msg(5, "We're gonna party like it's your birthday.");
     
    14381388            if (!get_bit_N_of_array
    14391389                (p_list_of_fileset_flags, storing_set_no)) {
    1440             misc_counter_that_is_not_important =
    1441                 (misc_counter_that_is_not_important + 1) % 5;
     1390            misc_counter_that_is_not_important = (misc_counter_that_is_not_important + 1) % 5;
    14421391            /* BCO the media_usage_comment is not really initialized there !
    14431392            if (!misc_counter_that_is_not_important) {
     
    14461395            */
    14471396            sleep(1);
    1448             } else
     1397            } else {
    14491398                // store set N
    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);
     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);
    14551401                if (g_getfattr) {
    1456                     sprintf(curr_xattr_list_fname, XATTR_LIST_FNAME_RAW_SZ,
    1457                         bkpinfo->tmpdir, storing_set_no);
     1402                    mr_asprintf(curr_xattr_list_fname, XATTR_LIST_FNAME_RAW_SZ, bkpinfo->tmpdir, storing_set_no);
    14581403                }
    14591404                if (g_getfacl) {
    1460                     sprintf(curr_acl_list_fname, ACL_LIST_FNAME_RAW_SZ,
    1461                         bkpinfo->tmpdir, storing_set_no);
     1405                    mr_asprintf(curr_acl_list_fname, ACL_LIST_FNAME_RAW_SZ, bkpinfo->tmpdir, storing_set_no);
    14621406                }
    14631407
     
    14701414                    sleep(5);
    14711415                }
    1472                 mr_asprintf(media_usage_comment, "%s", percent_media_full_comment());
    14731416                /* copy to CD (scratchdir) ... and an actual CD-R if necessary */
    14741417                if (IS_THIS_A_STREAMING_BACKUP(bkpinfo->backup_media_type)) {
    14751418                    register_in_tape_catalog(fileset, storing_set_no, -1,
    14761419                                         storing_afioball_fname);
    1477                     maintain_collection_of_recent_archives(bkpinfo->tmpdir,
    1478                                                        storing_afioball_fname);
     1420                    maintain_collection_of_recent_archives(bkpinfo->tmpdir, storing_afioball_fname);
    14791421                    log_it("Writing EXAT files");
    14801422                    res +=
     
    15101452                retval += res;
    15111453                g_current_progress++;
     1454                mr_asprintf(media_usage_comment, "%s", percent_media_full_comment());
    15121455                update_progress_form(media_usage_comment);
    15131456                mr_free(media_usage_comment);
    15141457                if (res) {
    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.");
     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.");
    15211460                }
    15221461                storing_set_no++;
    15231462                //      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);
    15241471        }
    15251472    }
     
    15401487    }
    15411488    log_to_screen(tmp);
    1542     paranoid_free(tmp);
     1489    mr_free(tmp);
    15431490
    15441491    paranoid_free(transfer_block);
    15451492    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);
    15501493    return (retval);
    15511494}
     
    15981541    mr_asprintf(tmp, "chmod 700 %s", bkpinfo->scratchdir);
    15991542    run_program_and_log_output(tmp, FALSE);
    1600     paranoid_free(tmp);
     1543    mr_free(tmp);
    16011544    if (chdir(bkpinfo->scratchdir)) {
    16021545        // FIXME
     
    16081551    log_msg(1, message_to_screen);
    16091552
    1610     mr_asprintf(tmp1, "%s1", bkpinfo->media_device);
     1553    if (bkpinfo->media_device) {
     1554        mr_asprintf(tmp1, "%s1", bkpinfo->media_device);
     1555    } else {
     1556        mr_asprintf(tmp1, "");
     1557    }
    16111558    if (is_this_device_mounted(tmp1)) {
    16121559        log_msg(1, "USB device mounted. Remounting it at the right place");
    16131560        mr_asprintf(tmp, "umount %s", tmp1);
    16141561        run_program_and_log_output(tmp, FALSE);
    1615         paranoid_free(tmp);
    1616     }
    1617     paranoid_free(tmp1);
     1562        mr_free(tmp);
     1563    }
     1564    mr_free(tmp1);
    16181565
    16191566    log_msg(1, "Mounting USB device.");
     
    16211568    mr_asprintf(tmp, "mkdir -p %s", tmp1);
    16221569    run_program_and_log_output(tmp, FALSE);
    1623     paranoid_free(tmp);
     1570    mr_free(tmp);
     1571
    16241572
    16251573    /* Mindi always create one single parition on the USB dev */
    16261574    mr_asprintf(tmp, "mount %s1 %s", bkpinfo->media_device, tmp1);
    16271575    run_program_and_log_output(tmp, FALSE);
    1628     paranoid_free(tmp);
     1576    mr_free(tmp);
    16291577
    16301578    if (bkpinfo->nonbootable_backup) {
     
    16421590        }
    16431591        log_to_screen(result_sz);
    1644         paranoid_free(result_sz);
    1645         paranoid_free(tmp);
     1592        mr_free(result_sz);
     1593        mr_free(tmp);
    16461594        retval += res;
    16471595
     
    16491597        mr_asprintf(tmp,"mkdir %s/archive", bkpinfo->scratchdir);
    16501598        run_program_and_log_output(tmp, FALSE);
    1651         paranoid_free(tmp);
     1599        mr_free(tmp);
    16521600    }
    16531601    paranoid_free(message_to_screen);
     
    16571605        mr_asprintf(tmp, "umount %s1", bkpinfo->media_device);
    16581606        run_program_and_log_output(tmp, FALSE);
    1659         paranoid_free(tmp);
     1607        mr_free(tmp);
    16601608    }
    16611609
     
    16951643
    16961644    /*@ buffers ****************************************** */
    1697     char *tmp;
     1645    char *tmp = NULL;
     1646    char *tmp2 = NULL;
    16981647    char *old_pwd;
    16991648    char *result_sz = NULL;
    17001649    char *message_to_screen = NULL;
    17011650    char *sz_blank_disk = NULL;
    1702     char *fnam;
    1703     char *tmp2;
    1704     char *tmp3;
     1651    char *fnam = NULL;
     1652    char *tmp3 = NULL;
    17051653    char *isofs_cmd = NULL;
    17061654    char *full_isofs_cmd = NULL;
     
    17101658    malloc_string(old_pwd);
    17111659    malloc_string(fnam);
    1712     tmp = malloc(1200);
    1713     tmp2 = malloc(1200);
    1714     tmp3 = malloc(1200);
    17151660    assert(bkpinfo != NULL);
    17161661    assert_string_is_neither_NULL_nor_zerolength(destfile);
    17171662
    1718     sprintf(tmp, "%s/isolinux.bin", bkpinfo->scratchdir);
    1719     sprintf(tmp2, "%s/isolinux.bin", bkpinfo->tmpdir);
     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);
    17201666    if (does_file_exist(tmp)) {
    1721         sprintf(tmp3, "cp -f %s %s", tmp, tmp2);
     1667        mr_asprintf(tmp3, "cp -f %s %s", tmp, tmp2);
    17221668        paranoid_system(tmp3);
     1669        mr_free(tmp3);
    17231670    }
    17241671    if (!does_file_exist(tmp) && does_file_exist(tmp2)) {
    1725         sprintf(tmp3, "cp -f %s %s", tmp2, tmp);
     1672        mr_asprintf(tmp3, "cp -f %s %s", tmp2, tmp);
    17261673        paranoid_system(tmp3);
    1727     }
    1728     free(tmp2);
    1729     free(tmp3);
    1730     tmp2 = NULL;
    1731     tmp3 = NULL;
     1674        mr_free(tmp3);
     1675    }
     1676    mr_free(tmp2);
     1677    mr_free(tmp3);
    17321678    if (bkpinfo->backup_media_type == iso && bkpinfo->manual_cd_tray) {
    17331679        popup_and_OK("Please insert new media and press Enter.");
    17341680    }
    17351681
    1736     log_msg(2, "make_iso_fs --- scratchdir=%s --- destfile=%s",
    1737             bkpinfo->scratchdir, destfile);
     1682    log_msg(2, "make_iso_fs --- scratchdir=%s --- destfile=%s", bkpinfo->scratchdir, destfile);
    17381683    tmp2 = getcwd(old_pwd, MAX_STR_LEN - 1);
    1739     sprintf(tmp, "chmod 700 %s", bkpinfo->scratchdir);
     1684    if (! tmp2) {
     1685        //FIXME
     1686    }
     1687    mr_asprintf(tmp, "chmod 700 %s", bkpinfo->scratchdir);
    17401688    run_program_and_log_output(tmp, FALSE);
     1689    mr_free(tmp);
     1690
    17411691    if (chdir(bkpinfo->scratchdir)) {
    17421692        // FIXME
     
    17441694
    17451695    if (bkpinfo->call_before_iso[0] != '\0') {
    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);
     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);
    17521698        if (res) {
    17531699            mr_strcat(message_to_screen, "...failed");
     
    17631709    if (bkpinfo->call_make_iso[0] != '\0') {
    17641710        log_msg(2, "bkpinfo->call_make_iso = %s", bkpinfo->call_make_iso);
    1765         sprintf(tmp, "%s/archives/NOT-THE-LAST", bkpinfo->scratchdir);
    17661711        mds = media_descriptor_string(bkpinfo->backup_media_type);
    17671712        mr_asprintf(message_to_screen, "Making an ISO (%s #%d)", mds, g_current_media_number);
     
    17741719        } else {
    17751720            res =
    1776                 eval_call_to_make_ISO(bkpinfo->call_make_iso,
    1777                                       bkpinfo->scratchdir,
    1778                                       g_current_media_number,
    1779                                       MONDO_LOGFILE, message_to_screen);
     1721                eval_call_to_make_ISO(bkpinfo->call_make_iso, bkpinfo->scratchdir, g_current_media_number, MONDO_LOGFILE, message_to_screen);
    17801722            if (res) {
    17811723                log_to_screen("%s...failed to write", message_to_screen);
    17821724            } else {
    17831725                log_to_screen("%s...OK", message_to_screen);
    1784                 sprintf(tmp, "tail -n10 %s | grep -F ':-('", MONDO_LOGFILE);
     1726                mr_asprintf(tmp, "tail -n10 %s | grep -F ':-('", MONDO_LOGFILE);
    17851727                if (!run_program_and_log_output(tmp, 1)) {
    17861728                    log_to_screen
    17871729                        ("Despite nonfatal errors, growisofs confirms the write was successful.");
    17881730                }
     1731                mr_free(tmp);
    17891732            }
    17901733            retval += res;
    17911734#ifdef DVDRWFORMAT
    1792             sprintf(tmp,
    1793                     "tail -n8 %s | grep 'blank=full.*dvd-compat.*DAO'",
    1794                     MONDO_LOGFILE);
     1735            mr_asprintf(tmp, "tail -n8 %s | grep 'blank=full.*dvd-compat.*DAO'", MONDO_LOGFILE);
    17951736            if (g_backup_media_type == dvd
    17961737                && (res || !run_program_and_log_output(tmp, 1))) {
     
    18001741                /* reset error counter before trying to blank DVD */
    18011742                retval -= res;
    1802                 paranoid_system("sync");
     1743                sync();
    18031744                pause_for_N_seconds(5, "Letting DVD drive settle");
    18041745
     
    18101751                }
    18111752                pause_for_N_seconds(5, "Letting DVD drive settle");
    1812                 mr_asprintf(sz_blank_disk, "dvd+rw-format -force %s", bkpinfo->media_device);
     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                }
    18131758                log_msg(3, "sz_blank_disk = '%s'", sz_blank_disk);
    1814                 res =
    1815                     run_external_binary_with_percentage_indicator_NEW
    1816                     ("Blanking DVD disk", sz_blank_disk);
     1759                res = run_external_binary_with_percentage_indicator_NEW("Blanking DVD disk", sz_blank_disk);
    18171760                if (res) {
    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);
     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);
    18251764                    if (res) {
    18261765                        log_to_screen("Format failed a second time.");
     
    18381777                }
    18391778                pause_for_N_seconds(5, "Letting DVD drive settle");
    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);
     1779                res = eval_call_to_make_ISO(bkpinfo->call_make_iso, bkpinfo->scratchdir, g_current_media_number, MONDO_LOGFILE, message_to_screen);
    18461780                retval += res;
    18471781                if (!bkpinfo->please_dont_eject) {
     
    18561790                }
    18571791            }
     1792            mr_free(tmp);
    18581793#endif
    18591794            if (g_backup_media_type == dvd && !bkpinfo->please_dont_eject) {
     
    18761811            log_msg(1, "Making nonbootable backup");
    18771812            mr_asprintf(full_isofs_cmd, "%s%s-o '_ISO_' -V _CD#_ .",isofs_cmd,MONDO_MKISOFS);
    1878             res = eval_call_to_make_ISO(full_isofs_cmd,
    1879                                       destfile, g_current_media_number,
    1880                                       MONDO_LOGFILE, message_to_screen);
     1813            res = eval_call_to_make_ISO(full_isofs_cmd, destfile, g_current_media_number, MONDO_LOGFILE, message_to_screen);
    18811814            mr_free(full_isofs_cmd);
    18821815        } else {
     
    18881821
    18891822
    1890             log_msg(1, "make_cd_use_lilo is actually %d",
    1891                     bkpinfo->make_cd_use_lilo);
     1823            log_msg(1, "make_cd_use_lilo is actually %d", bkpinfo->make_cd_use_lilo);
    18921824            if (bkpinfo->make_cd_use_lilo) {
    18931825                log_msg(1, "make_cd_use_lilo = TRUE");
     
    18951827                log_msg(1, "IA64 --> elilo");
    18961828                mr_asprintf(full_isofs_cmd, "%s%s-o '_ISO_' -V _CD#_ .",isofs_cmd,MONDO_MKISOFS_REGULAR_ELILO);
    1897                 res = eval_call_to_make_ISO(full_isofs_cmd,
    1898                                             destfile,
    1899                                             g_current_media_number,
    1900                                             MONDO_LOGFILE,
    1901                                             message_to_screen);
     1829                res = eval_call_to_make_ISO(full_isofs_cmd, destfile, g_current_media_number, MONDO_LOGFILE, message_to_screen);
    19021830                mr_free(full_isofs_cmd);
    19031831#else
    19041832                log_msg(1, "Non-ia64 --> lilo");
    19051833                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);
    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);
     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);
    19121836                mr_free(full_isofs_cmd);
    19131837#endif
     
    19161840                log_msg(1, "Isolinux");
    19171841                mr_asprintf(full_isofs_cmd, "%s%s-o '_ISO_' -V _CD#_ .",isofs_cmd,MONDO_MKISOFS_REGULAR_SYSLINUX);
    1918                 res =
    1919                     eval_call_to_make_ISO(full_isofs_cmd,
    1920                                           destfile, g_current_media_number,
    1921                                           MONDO_LOGFILE,
    1922                                           message_to_screen);
     1842                res = eval_call_to_make_ISO(full_isofs_cmd, destfile, g_current_media_number, MONDO_LOGFILE, message_to_screen);
    19231843                mr_free(full_isofs_cmd);
    19241844            }
     
    19401860        || bkpinfo->backup_media_type == cdrw) {
    19411861        if (is_this_device_mounted(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);
     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);
    19461864            run_program_and_log_output(tmp, FALSE);
     1865            mr_free(tmp);
    19471866        }
    19481867    }
     
    19541873        mr_free(mds);
    19551874        pause_and_ask_for_cdr(2, &cd_is_mountable);
    1956         res =
    1957             eval_call_to_make_ISO(bkpinfo->call_burn_iso,
    1958                                   destfile, g_current_media_number,
    1959                                   MONDO_LOGFILE, message_to_screen);
     1875        res = eval_call_to_make_ISO(bkpinfo->call_burn_iso, destfile, g_current_media_number, MONDO_LOGFILE, message_to_screen);
    19601876        if (res) {
    19611877            mr_strcat(message_to_screen, "...failed");
     
    19731889        mr_asprintf(message_to_screen, "Running post-ISO call (%s #%d)", mds, g_current_media_number);
    19741890        mr_free(mds);
    1975         res =
    1976             eval_call_to_make_ISO(bkpinfo->call_after_iso,
    1977                                   destfile, g_current_media_number,
    1978                                   MONDO_LOGFILE, message_to_screen);
     1891        res = eval_call_to_make_ISO(bkpinfo->call_after_iso, destfile, g_current_media_number, MONDO_LOGFILE, message_to_screen);
    19791892        if (res) {
    19801893            mr_strcat(message_to_screen, "...failed");
     
    20441957
    20451958    /*@ pointers ******************************************* */
    2046     FILE *fin;
     1959    FILE *fin = NULL;
    20471960    char *p;
    20481961    char *q;
     
    20501963    /*@ buffers ******************************************** */
    20511964    char *tmp = NULL;
    2052     char *bigfile_fname;
     1965    char *bigfile_fname = NULL;
    20531966    char *sz_devfile = NULL;
    20541967    char *ntfsprog_fifo = NULL;
     
    20861999    log_to_screen(tmp);
    20872000    noof_biggie_files = count_lines_in_file(biggielist_fname);
    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);
     2001    open_progress_form("Backing up big files", tmp, "Please wait. This may take some time.", "", estimated_total_noof_slices);
     2002    mr_free(tmp);
    20922003
    20932004    if (!(fin = fopen(biggielist_fname, "r"))) {
     
    21212032            log_msg(2, "bigfile_fname = %s", bigfile_fname);
    21222033            use_ntfsprog = FALSE;
    2123             if (!strncmp(bigfile_fname, "/dev/", 5)
    2124                 && is_dev_an_NTFS_dev(bigfile_fname)) {
     2034            if (!strncmp(bigfile_fname, "/dev/", 5) && is_dev_an_NTFS_dev(bigfile_fname)) {
    21252035                use_ntfsprog = TRUE;
    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));
     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));
    21322038                mkfifo(sz_devfile, 0x770);
    21332039                ntfsprog_fifo = sz_devfile;
     
    21372043                    fatal_error("Fork failure");
    21382044                case 0:
    2139                     log_msg(2,
    2140                             "CHILD - fip - calling feed_into_ntfsprog(%s, %s)",
    2141                             bigfile_fname, sz_devfile);
     2045                    log_msg(2, "CHILD - fip - calling feed_into_ntfsprog(%s, %s)", bigfile_fname, sz_devfile);
    21422046                    res = feed_into_ntfsprog(bigfile_fname, sz_devfile);
    21432047                    /* BCO/BERLIOS Does the child need to unalocate memory as well ?
    2144                     paranoid_free(bigfile_fname);
     2048                    mr_free(bigfile_fname);
    21452049                    mr_free(sz_devfile);
    21462050                    */
     
    21482052                    break;
    21492053                default:
    2150                     log_msg(2,
    2151                             "feed_into_ntfsprog() called in background --- pid=%ld",
    2152                             (long int) (pid));
     2054                    log_msg(2, "feed_into_ntfsprog() called in background --- pid=%ld", (long int) (pid));
    21532055                }
    21542056            }
     
    21602062            // Whether partition or biggiefile, just do your thang :-)
    21612063            if (IS_THIS_A_STREAMING_BACKUP(bkpinfo->backup_media_type)) {
    2162                 write_header_block_to_stream(biggie_fsize, bigfile_fname,
    2163                                              use_ntfsprog ?
    2164                                              BLK_START_A_PIHBIGGIE :
    2165                                              BLK_START_A_NORMBIGGIE);
    2166             }
    2167             res =
    2168                 slice_up_file_etc(bigfile_fname,
    2169                                   ntfsprog_fifo, biggie_file_number,
    2170                                   noof_biggie_files, use_ntfsprog);
     2064                write_header_block_to_stream(biggie_fsize, bigfile_fname, use_ntfsprog ?  BLK_START_A_PIHBIGGIE : BLK_START_A_NORMBIGGIE);
     2065            }
     2066            res = slice_up_file_etc(bigfile_fname, ntfsprog_fifo, biggie_file_number, noof_biggie_files, use_ntfsprog);
    21712067
    21722068            /* Free it here as ntfsprog_fifo is not used anymore */
     
    21972093            }
    21982094        }
    2199 #ifndef _XWIN
    22002095        if (!g_text_mode) {
    22012096            newtDrawRootText(0, g_noof_rows - 2, tmp);
    22022097            newtRefresh();
    22032098        }
    2204 #endif
    2205         paranoid_free(tmp);
    2206     }
     2099        mr_free(tmp);
     2100    }
     2101    mr_free(bigfile_fname);
     2102
    22072103    log_msg(1, "Finished backing up bigfiles");
    22082104    log_msg(1, "estimated slices = %ld; actual slices = %ld",
     
    22102106    close_progress_form();
    22112107    paranoid_fclose(fin);
    2212     paranoid_free(bigfile_fname);
    22132108    return (retval);
    22142109}
     
    22712166        retval += res;
    22722167        if (res) {
    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());
     2168            log_to_screen("Errors occurred while archiving set %ld. Perhaps your live filesystem changed?", curr_set_no);
     2169        }
    22792170
    22802171        /* copy to CD (scratchdir) ... and an actual CD-R if necessary */
     
    23192210        retval += res;
    23202211        g_current_progress++;
     2212
     2213        mr_asprintf(media_usage_comment, "%s", percent_media_full_comment());
    23212214        update_progress_form(media_usage_comment);
    23222215        mr_free(media_usage_comment);
    23232216
    23242217        if (res) {
    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.");
     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.");
    23302220        }
    23312221        mr_free(curr_filelist_fname);
     
    24282318    }
    24292319
    2430     mr_asprintf(command, "cp %s/biggielist.txt %s", bkpinfo->tmpdir,
    2431             biggielist);
     2320    mr_asprintf(command, "cp %s/biggielist.txt %s", bkpinfo->tmpdir, biggielist);
    24322321    paranoid_system(command);
    24332322    mr_free(command);
     
    24432332    if (g_getfattr) {
    24442333        get_fattr_list(biggielist, xattr_fname);
    2445         mr_asprintf(command, "cp %s %s/archives/", xattr_fname,
    2446             bkpinfo->scratchdir);
     2334        mr_asprintf(command, "cp %s %s/archives/", xattr_fname, bkpinfo->scratchdir);
    24472335        paranoid_system(command);
    24482336        mr_free(command);
     
    27332621    /*@ buffers ********************************************* */
    27342622    char *tmp = NULL;
    2735     char *cdrom_dev;
    2736     char *cdrw_dev;
     2623    char *cdrom_dev = NULL;
     2624    char *cdrw_dev = NULL;
    27372625    char *our_serial_str = NULL;
    27382626    bool ok_go_ahead_burn_it;
     
    27402628    int attempt_to_mount_returned_this = 999;
    27412629    char *mtpt = NULL;
    2742     char *szcdno;
    2743     char *szserfname;
    2744     char *szunmount;
     2630    char *szcdno = NULL;
     2631    char *szserfname = NULL;
     2632    char *szunmount = NULL;
    27452633    char *mds = NULL;
    27462634
    27472635    malloc_string(cdrom_dev);
    27482636    malloc_string(cdrw_dev);
    2749     malloc_string(szcdno);
    2750     malloc_string(szserfname);
    2751     malloc_string(szunmount);
    2752     malloc_string(mtpt);
    27532637
    27542638    mds = media_descriptor_string(g_backup_media_type);
    2755     mr_asprintf(tmp, "I am about to burn %s #%d", mds, g_current_media_number);
     2639    log_to_screen("I am about to burn %s #%d", mds, g_current_media_number);
    27562640    mr_free(mds);
    2757     log_to_screen(tmp);
    2758     mr_free(tmp);
    27592641    if (g_current_media_number < ask_for_one_if_more_than_this) {
    27602642        return;
    27612643    }
    27622644    log_to_screen("Scanning CD-ROM drive...");
    2763     sprintf(mtpt, "%s/cd.mtpt", bkpinfo->tmpdir);
     2645    mr_asprintf(mtpt, "%s/cd.mtpt", bkpinfo->tmpdir);
    27642646    make_hole_for_dir(mtpt);
    27652647
     
    27672649    ok_go_ahead_burn_it = TRUE;
    27682650    if (!find_cdrom_device(cdrom_dev, FALSE)) {
    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 */
     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        */
    27732655        mr_asprintf(tmp, "umount %s", cdrom_dev);
    27742656        run_program_and_log_output(tmp, 1);
    2775         sprintf(szcdno, "%s/archives/THIS-CD-NUMBER", mtpt);
    2776         sprintf(szserfname, "%s/archives/SERIAL-STRING", mtpt);
    2777         sprintf(szunmount, "umount %s", mtpt);
     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);
    27782660        cd_number = -1;
    27792661        mr_asprintf(tmp, "mount %s %s", cdrom_dev, mtpt);
     
    27812663        attempt_to_mount_returned_this = run_program_and_log_output(tmp, 1);
    27822664        mr_free(tmp);
     2665
    27832666        if (attempt_to_mount_returned_this) {
    27842667            log_msg(4, "Failed to mount %s at %s", cdrom_dev, mtpt);
    27852668            log_to_screen("If there's a CD/DVD in the drive, it's blank.");
    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)) {
     2669        } else if (!does_file_exist(szcdno) || !does_file_exist(szserfname)) {
    27992670            mds = media_descriptor_string(g_backup_media_type);
    2800             log_to_screen
    2801                 ("%s has data on it but it's probably not a Mondo CD.", mds);
     2671            log_to_screen("%s has data on it but it's probably not a Mondo CD.", mds);
    28022672            mr_free(mds);
    28032673        } else {
     
    28092679            mr_asprintf(tmp, "cat %s 2> /dev/null", szserfname);
    28102680            mr_free(our_serial_str);
    2811             mr_asprintf(our_serial_str, "%s",
    2812                    call_program_and_get_last_line_of_output(tmp));
     2681            mr_asprintf(our_serial_str, "%s", call_program_and_get_last_line_of_output(tmp));
    28132682            mr_free(tmp);
    28142683            // FIXME - should be able to use last_line_of_file(), surely?
    28152684        }
     2685        mr_free(szcdno);
     2686        mr_free(szserfname);
     2687
    28162688        run_program_and_log_output(szunmount, 1);
     2689        mr_free(szunmount);
     2690
    28172691        log_msg(2, "paafcd: cd_number = %d", cd_number);
    2818         log_msg(2, "our serial str = %s; g_serial_string = %s",
    2819                 our_serial_str, g_serial_string);
     2692        log_msg(2, "our serial str = %s; g_serial_string = %s", our_serial_str, g_serial_string);
    28202693        if (cd_number > 0 && !strcmp(our_serial_str, g_serial_string)) {
    28212694            mds = media_descriptor_string(g_backup_media_type);
     
    28492722        }
    28502723        mds = media_descriptor_string(g_backup_media_type);
    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);
     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);
    28532725        mr_free(mds);
    28542726
     
    28612733
    28622734    mds = media_descriptor_string(g_backup_media_type);
    2863     log_msg(2,
    2864             "paafcd: OK, I assume I have a blank/reusable %s in the drive...", mds);
     2735    log_msg(2, "paafcd: OK, I assume I have a blank/reusable %s in the drive...", mds);
    28652736
    28662737    log_to_screen("Proceeding w/ %s in drive.", mds);
     
    28692740    paranoid_free(cdrom_dev);
    28702741    paranoid_free(cdrw_dev);
    2871     paranoid_free(mtpt);
    2872     paranoid_free(szcdno);
    2873     paranoid_free(szserfname);
    2874     paranoid_free(szunmount);
     2742    mr_free(mtpt);
    28752743    if (pmountable) {
    28762744        if (attempt_to_mount_returned_this) {
     
    28822750
    28832751}
    2884 
    2885 
    2886 
    2887 
    2888 
    2889 
    28902752
    28912753
     
    29172779
    29182780/* @} - end of utilityGroup */
    2919 
    2920 
    2921 
    2922 
    2923 
    2924 
    29252781
    29262782
     
    29452801 */
    29462802int
    2947 slice_up_file_etc(char *biggie_filename,
    2948                   char *ntfsprog_fifo, long biggie_file_number,
    2949                   long noof_biggie_files, bool use_ntfsprog)
    2950 {
     2803slice_up_file_etc(char *biggie_filename, char *ntfsprog_fifo, long biggie_file_number, long noof_biggie_files, bool use_ntfsprog) {
    29512804
    29522805    /*@ buffers ************************************************** */
    29532806    char *tmp = NULL;
    2954     char *checksum_line, *command;
    2955     char *tempblock;
     2807    char *checksum_line = NULL;
     2808    char *command = NULL;
     2809    char *tempblock = NULL;
    29562810    char *curr_slice_fname_uncompressed = NULL;
    29572811    char *curr_slice_fname_compressed = NULL;
    29582812    char *file_to_archive = NULL;
    2959     char *file_to_openin;
     2813    char *file_to_openin = NULL;
    29602814    /*@ pointers ************************************************** */
    2961     char *pB;
    2962     FILE *fin = NULL, *fout = NULL;
     2815    char *pB = NULL;
     2816    FILE *fin = NULL;
     2817    FILE *fout = NULL;
    29632818
    29642819    /*@ bool ****************************************************** */
     
    29662821
    29672822    /*@ long ****************************************************** */
    2968     size_t blksize = 0;
    2969     long slice_num = 0;
    2970     long i;
    2971     long optimal_set_size;
    2972     bool should_I_compress_slices;
     2823    size_t blksize = (size_t)0;
     2824    long slice_num = 0L;
     2825    long i = 0L;
     2826    bool should_I_compress_slices = TRUE;
    29732827    char *suffix = NULL;                // for compressed slices
    29742828
     
    29832837    /*@ structures ************************************************** */
    29842838    struct s_filename_and_lstat_info biggiestruct;
    2985 //  struct stat statbuf;
    29862839
    29872840    assert(bkpinfo != NULL);
    29882841    assert_string_is_neither_NULL_nor_zerolength(biggie_filename);
    2989     malloc_string(checksum_line);
    29902842
    29912843    biggiestruct.for_backward_compatibility = '\n';
    29922844    biggiestruct.use_ntfsprog = use_ntfsprog;
    2993     optimal_set_size = bkpinfo->optimal_set_size;
    2994     if (is_this_file_compressed(biggie_filename)
    2995         || bkpinfo->compression_level == 0) {
     2845    if (is_this_file_compressed(biggie_filename) || bkpinfo->compression_level == 0) {
    29962846        mr_asprintf(suffix, "%s", "");
    2997         //      log_it("%s is indeed compressed :-)", filename);
    29982847        should_I_compress_slices = FALSE;
    29992848    } else {
     
    30022851    }
    30032852
    3004     if (optimal_set_size < 999) {
     2853    if (bkpinfo->optimal_set_size < 999L) {
    30052854        fatal_error("bkpinfo->optimal_set_size is insanely small");
    30062855    }
     2856
    30072857    if (ntfsprog_fifo) {
    30082858        file_to_openin = ntfsprog_fifo;
    3009         strcpy(checksum_line, "IGNORE");
    3010         log_msg(2,
    3011                 "Not calculating checksum for %s: it would take too long",
    3012                 biggie_filename);
     2859        mr_asprintf(checksum_line, "IGNORE");
     2860        log_msg(2, "Not calculating checksum for %s: it would take too long", biggie_filename);
    30132861        if ( !find_home_of_exe("ntfsresize")) {
    30142862            fatal_error("ntfsresize not found");
     
    30202868        log_it("res of it = %s", tmp);
    30212869        totallength = (off_t)atoll(tmp);
    3022         paranoid_free(tmp);
     2870        mr_free(tmp);
    30232871    } else {
    30242872        file_to_openin = biggie_filename;
     
    30342882        }
    30352883        mr_free(command);
    3036         tmp = fgets(checksum_line, MAX_STR_LEN, fin);
     2884        mr_getline(checksum_line, fin);
    30372885        pclose(fin);
    30382886        totallength = length_of_file (biggie_filename);
     
    30482896    }
    30492897    strcpy(biggiestruct.checksum, checksum_line);
     2898    mr_free(checksum_line);
    30502899
    30512900    mr_asprintf(tmp, "%s", slice_fname(biggie_file_number, 0, bkpinfo->tmpdir, ""));
     
    30532902    if (fout == NULL) {
    30542903        log_msg(1, "Unable to open and write to %s\n", tmp);
    3055         paranoid_free(tmp);
     2904        mr_free(tmp);
    30562905        mr_free(suffix);
    30572906        return (1);
    30582907    }
    3059     paranoid_free(tmp);
     2908    mr_free(tmp);
    30602909
    30612910    res = fwrite((void *) &biggiestruct, 1, sizeof(biggiestruct), fout);
     
    30632912        paranoid_fclose(fout);
    30642913    }
    3065     log_msg(1, "Opening in %s; slicing it and writing to CD/tape",
    3066             file_to_openin);
     2914    log_msg(1, "Opening in %s; slicing it and writing to CD/tape", file_to_openin);
    30672915    if (!(fin = fopen(file_to_openin, "r"))) {
    30682916        log_OS_error("Unable to openin biggie_filename");
    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);
     2917        log_to_screen("Cannot archive bigfile '%s': not found", biggie_filename);
     2918
    30742919        mr_free(suffix);
    30752920        return (1);
     
    30942939        mr_asprintf(tmp, "%s", percent_media_full_comment());
    30952940        update_progress_form(tmp);
    3096         paranoid_free(tmp);
     2941        mr_free(tmp);
    30972942
    30982943        if (!(fout = fopen(curr_slice_fname_uncompressed, "w"))) {
     
    31012946            return (1);
    31022947        }
    3103         if ((i == bkpinfo->optimal_set_size / 256)
    3104             && (totalread < 1.1 * totallength)) {
    3105             for (i = 0; i < bkpinfo->optimal_set_size / 256; i++) {
     2948        if ((i == bkpinfo->optimal_set_size / 256) && (totalread < 1.1 * totallength)) {
     2949            for (i = 0L; i < bkpinfo->optimal_set_size / 256; i++) {
    31062950                blksize = fread(tempblock, 1, 256 * 1024, fin);
    31072951                if (blksize > 0) {
     
    31122956                }
    31132957            }
     2958            mr_free(tempblock);
    31142959        } else {
    3115             i = 0;
     2960            i = 0L;
    31162961        }
    31172962        paranoid_fclose(fout);
    3118         if (i > 0)              // length_of_file (curr_slice_fname_uncompressed)
     2963        if (i > 0L)             // length_of_file (curr_slice_fname_uncompressed)
    31192964        {
    31202965            if (!does_file_exist(curr_slice_fname_uncompressed)) {
    3121                 log_msg(2,
    3122                         "Warning - '%s' doesn't exist. How can I compress slice?",
    3123                         curr_slice_fname_uncompressed);
     2966                log_msg(2, "Warning - '%s' doesn't exist. How can I compress slice?", curr_slice_fname_uncompressed);
    31242967            }
    31252968            if (should_I_compress_slices && bkpinfo->compression_level > 0) {
     
    31412984                log_msg(2, "Failed to compress the slice");
    31422985            }
    3143             if (bkpinfo->use_lzo
    3144                 && strcmp(curr_slice_fname_compressed,
    3145                           curr_slice_fname_uncompressed)) {
     2986            if (bkpinfo->use_lzo && strcmp(curr_slice_fname_compressed, curr_slice_fname_uncompressed)) {
    31462987                unlink(curr_slice_fname_uncompressed);
    31472988            }
     
    31492990                mr_asprintf(tmp, "Problem with slice # %ld", slice_num);
    31502991            } else {
    3151                 mr_asprintf(tmp, "%s - Bigfile #%ld, slice #%ld compressed OK          ", biggie_filename, biggie_file_number + 1,
    3152                         slice_num);
    3153             }
    3154 #ifndef _XWIN
     2992                mr_asprintf(tmp, "%s - Bigfile #%ld, slice #%ld compressed OK          ", biggie_filename, biggie_file_number + 1, slice_num);
     2993            }
    31552994            if (!g_text_mode) {
    31562995                newtDrawRootText(0, g_noof_rows - 2, tmp);
     
    31592998                log_msg(2, tmp);
    31602999            }
    3161 #else
    3162             log_msg(2, tmp);
    3163 #endif
    3164             paranoid_free(tmp);
     3000            mr_free(tmp);
    31653001
    31663002            mr_asprintf(file_to_archive, "%s", curr_slice_fname_compressed);
     
    31783014
    31793015        if (IS_THIS_A_STREAMING_BACKUP(bkpinfo->backup_media_type)) {
    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);
     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);
    31843018            res = move_files_to_stream(file_to_archive, NULL);
    31853019        } else {
     
    31903024        retval += res;
    31913025        if (res) {
    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);
     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    }
    32003030    mr_free(suffix);
    32013031    paranoid_fclose(fin);
     
    32073037    }
    32083038    log_msg(1, tmp);
    3209     paranoid_free(tmp);
    3210 
    3211     paranoid_free(checksum_line);
     3039    mr_free(tmp);
     3040
    32123041    return (retval);
    32133042}
     
    32883117    log_msg(2, tmp);
    32893118    center_string(tmp, 80);
    3290 #ifndef _XWIN
    32913119    if (!g_text_mode) {
    32923120        newtPushHelpLine(tmp);
    32933121    }
    3294 #endif
    32953122    res = write_iso_and_go_on(TRUE);
    3296 #ifndef _XWIN
    32973123    if (!g_text_mode) {
    32983124        newtPopHelpLine();
    32993125    }
    3300 #endif
    33013126    log_msg(2, "Returning from writing final ISO (res=%d)", res);
    33023127    paranoid_free(tmp);
     
    33273152
    33283153    /*@ buffers ***************************************************** */
    3329     char *tmp;
    3330     char *cdno_fname;
    3331     char *lastcd_fname;
    3332     char *isofile;
     3154    char *tmp = NULL;
     3155    char *tmp1 = NULL;
     3156    char *cdno_fname = NULL;
     3157    char *lastcd_fname = NULL;
     3158    char *isofile = NULL;
    33333159    char *mds = NULL;
    33343160
     
    33413167
    33423168    malloc_string(tmp);
    3343     malloc_string(cdno_fname);
    3344     malloc_string(lastcd_fname);
    3345     malloc_string(isofile);
    33463169
    33473170    assert(bkpinfo != NULL);
     
    33573180    /* label the ISO with its number */
    33583181
    3359     sprintf(cdno_fname, "%s/archives/THIS-CD-NUMBER", bkpinfo->scratchdir);
     3182    mr_asprintf(cdno_fname, "%s/archives/THIS-CD-NUMBER", bkpinfo->scratchdir);
    33603183    fout = fopen(cdno_fname, "w");
     3184    mr_free(cdno_fname);
     3185
    33613186    fprintf(fout, "%d", g_current_media_number);
    33623187    paranoid_fclose(fout);
    33633188
    3364     sprintf(tmp, "cp -f %s/autorun %s/", g_mondo_home,
    3365             bkpinfo->scratchdir);
    3366     if (run_program_and_log_output(tmp, FALSE)) {
     3189    mr_asprintf(tmp1, "cp -f %s/autorun %s/", g_mondo_home, bkpinfo->scratchdir);
     3190    if (run_program_and_log_output(tmp1, FALSE)) {
    33673191        log_msg(2, "Warning - unable to copy autorun to scratchdir");
    33683192    }
     3193    mr_free(tmp1);
    33693194
    33703195    /* last CD or not? Label accordingly */
    3371     sprintf(lastcd_fname, "%s/archives/NOT-THE-LAST", bkpinfo->scratchdir);
     3196    mr_asprintf(lastcd_fname, "%s/archives/NOT-THE-LAST", bkpinfo->scratchdir);
    33723197    if (last_cd) {
    33733198        unlink(lastcd_fname);
     
    33803205        paranoid_fclose(fout);
    33813206    }
     3207    mr_free(lastcd_fname);
     3208
    33823209    if (space_occupied_by_cd(bkpinfo->scratchdir) / 1024 > bkpinfo->media_size) {
    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,
     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,
    33903213            bkpinfo->netfs_remote_dir, bkpinfo->prefix,
    33913214            g_current_media_number);
     
    34023225            {
    34033226                log_msg(3, "*Sigh* Mike, I hate your computer.");
     3227                // if it can't be found then force pausing
    34043228                bkpinfo->manual_cd_tray = TRUE;
    3405             }                   // if it can't be found then force pausing
    3406             else {
     3229            } else {
    34073230                log_msg(3, "Great. Found Mike's CD-ROM drive.");
    34083231            }
     
    34103233        if (bkpinfo->verify_data && !res) {
    34113234            mds = media_descriptor_string(g_backup_media_type);
    3412             log_to_screen
    3413                 ("Please reboot from the 1st %s in Compare Mode, as a precaution.", mds);
     3235            log_to_screen("Please reboot from the 1st %s in Compare Mode, as a precaution.", mds);
    34143236            mr_free(mds);
    34153237            if (chdir("/")) {
     
    34283250        } else {
    34293251            mds = media_descriptor_string(bkpinfo->backup_media_type);
    3430             sprintf(tmp, "Failed to create %s #%d. Retry?", mds, g_current_media_number);
     3252            mr_asprintf(tmp1, "Failed to create %s #%d. Retry?", mds, g_current_media_number);
    34313253            mr_free(mds);
    3432             res = ask_me_yes_or_no(tmp);
     3254            res = ask_me_yes_or_no(tmp1);
     3255            mr_free(tmp1);
     3256
    34333257            if (!res) {
    34343258                if (ask_me_yes_or_no("Abort the backup?")) {
     
    34433267        }
    34443268    }
     3269    mr_free(isofile);
     3270
    34453271    g_current_media_number++;
    34463272    wipe_archives(bkpinfo->scratchdir);
    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     }
     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);
    34543278
    34553279    if (last_cd) {
     
    34613285    bkpinfo->verify_data = orig_vfy_flag_val;
    34623286    paranoid_free(tmp);
    3463     paranoid_free(cdno_fname);
    3464     paranoid_free(lastcd_fname);
    3465     paranoid_free(isofile);
    34663287    return (0);
    34673288}
     
    35323353            if (res) {
    35333354                mds = media_descriptor_string(bkpinfo->backup_media_type);
    3534                 mr_asprintf(tmp, "Warnings/errors were reported while checking %s #%d", mds, g_current_media_number);
     3355                log_to_screen("Warnings/errors were reported while checking %s #%d", mds, g_current_media_number);
    35353356                mr_free(mds);
    3536                 log_to_screen(tmp);
    3537                 mr_free(tmp);
    35383357
    35393358            }
Note: See TracChangeset for help on using the changeset viewer.