Ignore:
Timestamp:
Feb 9, 2007, 2:07:01 AM (17 years ago)
Author:
Bruno Cornec
Message:

Memory management improvements for libmondo-archive.c (trunk merge again) TBC

File:
1 edited

Legend:

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

    r1116 r1118  
    2828#include "libmondo-devices-EXT.h"
    2929#include "libmondo-tools-EXT.h"
    30 #include "libmondo-gui-EXT.h"
     30#include "newt-specific-EXT.h"
    3131#include "libmondo-fork-EXT.h"
    3232#include "libmondo-files-EXT.h"
     
    208208    unsigned int res = 0;
    209209    int tries = 0;
    210     char *command;
    211     char *zipparams;
    212     char *tmp;
    213     char *p;
    214 
    215     malloc_string(command);
    216     malloc_string(zipparams);
    217     malloc_string(tmp);
     210    char *command = NULL;
     211    char *tmp = NULL;
     212    char *p =NULL;
     213    char *tmp1 = NULL;
     214
     215    malloc_string(tmp1);
    218216
    219217    if (!does_file_exist(filelist)) {
    220         sprintf(tmp, "(archive_this_fileset) - filelist %s does not exist",
    221                 filelist);
     218        mr_asprintf(&tmp,
     219                 "(archive_this_fileset) - filelist %s does not exist",
     220                 filelist);
    222221        log_to_screen(tmp);
     222        mr_free(tmp);
    223223        return (1);
    224224    }
    225225
    226     sprintf(tmp, "echo hi > %s 2> /dev/null", fname);
     226    mr_asprintf(&tmp, "echo hi > %s 2> /dev/null", fname);
    227227    if (system(tmp)) {
    228228        fatal_error("Unable to write tarball to scratchdir");
    229229    }
    230 
    231     sprintf(command, "star H=star list=%s -c " STAR_ACL_SZ " file=%s",
    232             filelist, fname);
     230    mr_free(tmp);
     231
     232    mr_asprintf(&command, "star H=star list=%s -c " STAR_ACL_SZ " file=%s",
     233             filelist, fname);
    233234    if (bkpinfo->use_lzo) {
    234235        fatal_error("Can't use lzop");
    235236    }
    236237    if (bkpinfo->compression_level > 0) {
    237         strcat(command, " -bz");
    238     }
    239     sprintf(command + strlen(command), " 2>> %s", MONDO_LOGFILE);
     238        mr_asprintf(&tmp, "%s -bz", command);
     239        mr_free(command);
     240        command = tmp;
     241    }
     242    mr_asprintf(&tmp, "%s 2>> %s", command, MONDO_LOGFILE);
     243    mr_free(command);
     244    command = tmp;
    240245    mr_msg(4, "command = '%s'", command);
    241246
     
    243248        mr_msg(5, "command='%s'", command);
    244249        res = system(command);
    245         strcpy(tmp, last_line_of_file(MONDO_LOGFILE));
     250        strcpy(tmp1, last_line_of_file(MONDO_LOGFILE));
    246251        mr_msg(1, "res=%d; tmp='%s'", res, tmp);
    247252        if (bkpinfo->use_star && (res == 254 || res == 65024)
     
    265270        }
    266271    }
     272    mr_free(command);
     273
    267274    retval += res;
    268275    if (retval) {
     
    273280    }
    274281
    275     mr_free(command);
    276     mr_free(zipparams);
    277     mr_free(tmp);
    278282    return (retval);
    279283}
     
    301305{
    302306
    303     /*@ int *************************************************************** */
     307    /*@ int ************************************************************ */
    304308    int retval = 0;
    305309    int res = 0;
     
    308312    static int free_ramdisk_space = 9999;
    309313
    310     /*@ buffers ************************************************************ */
    311     char *command;
    312     char *zipparams;
    313     char *tmp;
     314    /*@ buffers ******************************************************** */
     315    char *command = NULL;
     316    char *zipparams = NULL;
     317    char *tmp = NULL;
     318    char *tmp1 = NULL;
    314319
    315320    assert(bkpinfo != NULL);
     
    322327    }
    323328
    324     malloc_string(command);
    325     malloc_string(zipparams);
    326     malloc_string(tmp);
    327 
    328329    if (!does_file_exist(filelist)) {
    329         sprintf(tmp, "(archive_this_fileset) - filelist %s does not exist",
    330                 filelist);
     330        mr_asprintf(&tmp,
     331                 "(archive_this_fileset) - filelist %s does not exist",
     332                 filelist);
    331333        log_to_screen(tmp);
     334        mr_free(tmp);
    332335        return (1);
    333336    }
    334     sprintf(tmp, "echo hi > %s 2> /dev/null", fname);
     337    mr_asprintf(&tmp, "echo hi > %s 2> /dev/null", fname);
    335338    if (system(tmp)) {
    336339        fatal_error("Unable to write tarball to scratchdir");
    337340    }
     341    mr_free(tmp);
    338342
    339343
    340344    if (bkpinfo->compression_level > 0) {
    341         sprintf(tmp, "%s/do-not-compress-these", g_mondo_home);
     345        mr_asprintf(&tmp, "%s/do-not-compress-these", g_mondo_home);
    342346        //       -b %ld, TAPE_BLOCK_SIZE
    343         sprintf(zipparams, "-Z -P %s -G %d -T 3k", bkpinfo->zip_exe,
    344                 bkpinfo->compression_level);
     347        mr_asprintf(&zipparams, "-Z -P %s -G %d -T 3k", bkpinfo->zip_exe,
     348                 bkpinfo->compression_level);
    345349        if (does_file_exist(tmp)) {
    346             strcat(zipparams, " -E ");
    347             strcat(zipparams, tmp);
     350            mr_asprintf(&tmp1, "%s -E %s", zipparams, tmp);
     351            mr_free(zipparams);
     352            zipparams = tmp1;
    348353        } else {
    349354            mr_msg(3, "%s not found. Cannot exclude zipfiles, etc.", tmp);
    350355        }
    351     } else {
    352         zipparams[0] = '\0';
     356        mr_free(tmp);
     357    } else {
     358        mr_asprintf(&zipparams, " ");
    353359    }
    354360
     
    363369        fatal_error("scratchdir not found");
    364370    }
    365     sprintf(command, "rm -f %s %s. %s.gz %s.%s", fname, fname, fname,
    366             fname, bkpinfo->zip_suffix);
     371    mr_asprintf(&command, "rm -f %s %s. %s.gz %s.%s", fname, fname, fname,
     372             fname, bkpinfo->zip_suffix);
    367373    paranoid_system(command);
    368 
    369     sprintf(command, "afio -o -b %ld -M 16m %s %s < %s 2>> %s",
    370             TAPE_BLOCK_SIZE, zipparams, fname, filelist, MONDO_LOGFILE);
    371 
    372     sprintf(tmp, "echo hi > %s 2> /dev/null", fname);
     374    mr_free(command);
     375
     376    mr_asprintf(&command, "afio -o -b %ld -M 16m %s %s < %s 2>> %s",
     377             TAPE_BLOCK_SIZE, zipparams, fname, filelist, MONDO_LOGFILE);
     378    mr_free(zipparams);
     379
     380    mr_asprintf(&tmp, "echo hi > %s 2> /dev/null", fname);
    373381    if (system(tmp)) {
    374382        fatal_error("Unable to write tarball to scratchdir");
    375383    }
     384    mr_free(tmp);
    376385
    377386    for (res = 99, tries = 0; tries < 3 && res != 0; tries++) {
     
    386395        }
    387396    }
     397    mr_free(command);
     398
    388399    retval += res;
    389400    if (retval) {
     
    409420        }
    410421    }
    411     mr_free(command);
    412     mr_free(zipparams);
    413     mr_free(tmp);
    414422    return (retval);
    415423}
    416 
    417 
    418 
    419 
    420424
    421425
     
    435439{
    436440    int retval = 0, res = 0;
    437     char *tmp;
     441    char *tmp = NULL;
    438442
    439443    assert(bkpinfo != NULL);
    440444    set_g_cdrom_and_g_dvd_to_bkpinfo_value(bkpinfo);
    441     malloc_string(tmp);
     445
    442446    if (bkpinfo->backup_media_type == dvd) {
    443447#ifdef DVDRWFORMAT
     
    460464    }
    461465
    462 /*
    463       sprintf(tmp, "wc -l %s/archives/filelist.full > %s/archives/filelist.count",bkpinfo->scratchdir, bkpinfo->scratchdir);
    464       if (run_program_and_log_output(tmp, 2))
    465         { fatal_error("Failed to count filelist.full"); }
    466 */
    467     sprintf(tmp, "gzip -9 %s/archives/filelist.full", bkpinfo->scratchdir);
     466    mr_asprintf(&tmp, "gzip -9 %s/archives/filelist.full",
     467             bkpinfo->scratchdir);
    468468    if (run_program_and_log_output(tmp, 2)) {
    469469        fatal_error("Failed to gzip filelist.full");
    470470    }
    471     sprintf(tmp, "cp -f %s/archives/*list*.gz %s", bkpinfo->scratchdir,
    472             bkpinfo->tmpdir);
     471    mr_free(tmp);
     472    mr_asprintf(&tmp, "cp -f %s/archives/*list*.gz %s", bkpinfo->scratchdir,
     473             bkpinfo->tmpdir);
    473474    if (run_program_and_log_output(tmp, 2)) {
    474475        fatal_error("Failed to copy to tmpdir");
    475476    }
     477    mr_free(tmp);
    476478
    477479    copy_mondo_and_mindi_stuff_to_scratchdir(bkpinfo);  // payload, too, if it exists
     
    493495    }
    494496    retval += do_that_initial_phase(bkpinfo);   // prepare
    495     sprintf(tmp, "rm -f %s/images/*.iso", bkpinfo->scratchdir);
     497    mr_asprintf(&tmp, "rm -f %s/images/*.iso", bkpinfo->scratchdir);
    496498    run_program_and_log_output(tmp, 1);
     499    mr_free(tmp);
    497500    retval += make_those_afios_phase(bkpinfo);  // backup regular files
    498501    retval += make_those_slices_phase(bkpinfo); // backup BIG files
     
    502505        sleep(2);
    503506    }
    504     mr_free(tmp);
    505507    return (retval);
    506508}
    507 
    508 
    509509
    510510
     
    525525 * - @c media_size
    526526 * - @c nonbootable_backup
    527  * - @c scratchdir
    528527 * - @c tmpdir
    529528 * - @c use_lzo
     
    538537{
    539538    /*@ buffer ************************************************************ */
    540     char *tmp;
    541     char *scratchdir;
    542     char *command;
    543     char *bootldr_str;
    544     char *last_filelist_number;
    545     char *tape_size_sz;
    546     char *devs_to_exclude;
    547     char *value;
    548     char *bootdev;
     539    char *tmp = NULL;
     540    char *command = NULL;
     541    char *use_lzo_sz = NULL;
     542    char *use_gzip_sz = NULL;
     543    char *use_comp_sz = NULL;
     544    char *use_star_sz = NULL;
     545    char *bootldr_str = NULL;
     546    char *tape_device = NULL;
     547    char *last_filelist_number = NULL;
     548    char *broken_bios_sz = NULL;
     549    char *cd_recovery_sz = NULL;
     550    char *tape_size_sz = NULL;
     551    char *devs_to_exclude = NULL;
     552    char *use_lilo_sz = NULL;
     553    char *bootdev = NULL;
    549554
    550555    /*@ char ************************************************************** */
     
    554559    long lines_in_filelist = 0;
    555560
    556     /*@ int     ************************************************************* */
     561    /*@ int         ************************************************************* */
    557562    int res = 0;
    558563    long estimated_total_noof_slices = 0;
     
    562567
    563568    assert(bkpinfo != NULL);
    564     command = mr_malloc(1200);
    565     malloc_string(tmp);
    566     malloc_string(scratchdir);
    567569    malloc_string(bootldr_str);
    568570    malloc_string(last_filelist_number);
    569     malloc_string(tape_size_sz);
    570571    malloc_string(devs_to_exclude);
    571     malloc_string(value);
    572572    malloc_string(bootdev);
    573573
    574     strcpy(scratchdir, bkpinfo->scratchdir);
    575     sprintf(tmp,
     574    mr_asprintf(&tmp,
    576575            "echo '%s' | tr -s ' ' '\n' | grep -E '^/dev/.*$' | tr -s '\n' ' ' | awk '{print $0\"\\n\";}'",
    577576            bkpinfo->exclude_paths);
     577
    578578    strcpy(devs_to_exclude, call_program_and_get_last_line_of_output(tmp));
     579    mr_free(tmp);
     580
     581    mr_asprintf(&tmp, "devs_to_exclude = '%s'", devs_to_exclude);
    579582    mr_msg(2, tmp);
     583    mr_free(tmp);
    580584    mvaddstr_and_log_it(g_currentY, 0,
    581585                        "Calling MINDI to create boot+data disks");
    582     sprintf(tmp, "%s/filelist.full", bkpinfo->tmpdir);
     586    mr_asprintf(&tmp, "%s/filelist.full", bkpinfo->tmpdir);
    583587    if (!does_file_exist(tmp)) {
    584         sprintf(tmp, "%s/tmpfs/filelist.full", bkpinfo->tmpdir);
     588        mr_free(tmp);
     589        mr_asprintf(&tmp, "%s/tmpfs/filelist.full", bkpinfo->tmpdir);
    585590        if (!does_file_exist(tmp)) {
    586591            fatal_error
     
    590595    lines_in_filelist = count_lines_in_file(tmp);
    591596    strcpy(last_filelist_number, last_line_of_file(tmp));
     597    mr_free(tmp);
     598
     599    if (IS_THIS_A_STREAMING_BACKUP(bkpinfo->backup_media_type)) {
     600        mr_asprintf(&tape_size_sz, "%ld", bkpinfo->media_size[1]);
     601        mr_asprintf(&tape_device, bkpinfo->media_device);
     602    } else {
     603        mr_asprintf(&tape_size_sz, " ");
     604        mr_asprintf(&tape_device, " ");
     605    }
     606    /* BERLIOS: This parameter is not used after? */
     607    mr_free(tape_size_sz);
     608    if (bkpinfo->use_lzo) {
     609        mr_asprintf(&use_lzo_sz, "yes");
     610    } else {
     611        mr_asprintf(&use_lzo_sz, "no");
     612    }
     613    if (bkpinfo->use_gzip) {
     614        mr_asprintf(&use_gzip_sz, "yes");
     615    } else {
     616        mr_asprintf(&use_gzip_sz, "no");
     617    }
     618    if (bkpinfo->use_star) {
     619        mr_asprintf(&use_star_sz, "yes");
     620    } else {
     621        mr_asprintf(&use_star_sz, "no");
     622    }
     623
     624    if (bkpinfo->compression_level > 0) {
     625        mr_asprintf(&use_comp_sz, "yes");
     626    } else {
     627        mr_asprintf(&use_comp_sz, "no");
     628    }
     629
     630    mr_asprintf(&broken_bios_sz, "yes");    /* assume so */
     631    if (g_cd_recovery) {
     632        mr_asprintf(&cd_recovery_sz, "yes");
     633    } else {
     634        mr_asprintf(&cd_recovery_sz, "no");
     635    }
     636    /* Field shared between LILO/ELILO */
     637    if (bkpinfo->make_cd_use_lilo) {
     638        mr_asprintf(&use_lilo_sz, "yes");
     639    } else {
     640        mr_asprintf(&use_lilo_sz, "no");
     641    }
    592642
    593643    if (!bkpinfo->nonbootable_backup
     
    622672        else
    623673            ch = 'U';
     674
    624675        if (bkpinfo->boot_loader != '\0') {
    625             sprintf(tmp, "User specified boot loader. It is '%c'.",
     676            mr_asprintf(&tmp, "User specified boot loader. It is '%c'.",
    626677                    bkpinfo->boot_loader);
    627678            mr_msg(2, tmp);
     679            mr_free(tmp);
    628680        } else {
    629681            bkpinfo->boot_loader = ch;
    630682        }
    631683        if (bkpinfo->boot_device[0] != '\0') {
    632             sprintf(tmp, "User specified boot device. It is '%s'.",
     684            mr_asprintf(&tmp, "User specified boot device. It is '%s'.",
    633685                    bkpinfo->boot_device);
    634686            mr_msg(2, tmp);
     687            mr_free(tmp);
    635688        } else {
    636689            strcpy(bkpinfo->boot_device, bootdev);
     
    646699#endif
    647700           bkpinfo->boot_loader != 'L' && bkpinfo->boot_loader != 'G'
    648            && bkpinfo->boot_loader != 'R'
    649            && !bkpinfo->nonbootable_backup) {
     701           && bkpinfo->boot_loader != 'R' && !bkpinfo->nonbootable_backup)
     702    {
    650703        fatal_error
    651             ("Please specify your boot loader and device, e.g. -l GRUB -f /dev/hda. Type 'man mondoarchive' to read the manual.");
     704            ("Please specify your boot loader and device, e.g. -l GRUB -f /dev/hda.\nType 'man mondoarchive' to read the manual.");
    652705    }
    653706    if (bkpinfo->boot_loader == 'L') {
     
    655708        if (!does_file_exist("/etc/lilo.conf")) {
    656709            fatal_error
    657                 ("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?");
     710                ("The de facto standard location for your boot loader's config file is /etc/lilo.conf.\nBut I cannot find it there. What is wrong with your Linux distribution?");
    658711        }
    659712    } else if (bkpinfo->boot_loader == 'G') {
     
    672725        if (!does_file_exist("/etc/grub.conf")) {
    673726            fatal_error
    674                 ("The de facto standard location for your boot loader's config file is /etc/grub.conf but I cannot find it there. What is wrong with your Linux distribution? Try 'ln -s /boot/grub/menu.lst /etc/grub.conf'...");
     727                ("The de facto standard location for your boot loader's config file is /etc/grub.conf.\nBut I cannot find it there. What is wrong with your Linux distribution?\nTry 'ln -s /boot/grub/menu.lst /etc/grub.conf'...");
    675728        }
    676729    } else if (bkpinfo->boot_loader == 'E') {
    677730        strcpy(bootldr_str, "ELILO");
    678         /* BCO: fix it for SuSE, Debian, Mandrake, ... */
     731        /* BERLIOS: fix it for SuSE, Debian, Mandrake, ... */
    679732        if (!does_file_exist("/etc/elilo.conf")
    680733            && does_file_exist("/boot/efi/efi/redhat/elilo.conf")) {
     
    685738        if (!does_file_exist("/etc/elilo.conf")) {
    686739            fatal_error
    687                 ("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'");
     740                ("The de facto mondo standard location for your boot loader's config file is /etc/elilo.conf\nBut I cannot find it there. What is wrong with your Linux distribution?\nTry finding it under /boot/efi and do 'ln -s /boot/efi/..../elilo.conf /etc/elilo.conf'");
    688741        }
    689742    } else if (bkpinfo->boot_loader == 'R') {
     
    702755        strcpy(bootldr_str, "unknown");
    703756    }
    704     sprintf(tmp, "Your boot loader is %s and it boots from %s",
     757    mr_asprintf(&tmp, "Your boot loader is %s and it boots from %s",
    705758            bootldr_str, bkpinfo->boot_device);
    706759    log_to_screen(tmp);
     760    mr_free(tmp);
     761    mr_asprintf(&tmp, "%s/BOOTLOADER.DEVICE", bkpinfo->tmpdir);
     762    if (write_one_liner_data_file(tmp, bkpinfo->boot_device)) {
     763        mr_msg(1, "Unable to write one-liner boot device");
     764
     765    }
    707766
    708767    estimated_total_noof_slices =
    709768        size_of_all_biggiefiles_K(bkpinfo) / bkpinfo->optimal_set_size + 1;
    710 /* add nfs stuff here? */
    711     sprintf(command, "mkdir -p %s/images", bkpinfo->scratchdir);
     769    mr_asprintf(&command, "mkdir -p %s/images", bkpinfo->scratchdir);
    712770    if (system(command)) {
    713771        res++;
    714772        log_OS_error("Unable to make images directory");
    715773    }
    716     sprintf(command, "mkdir -p %s%s", bkpinfo->scratchdir, MNT_FLOPPY);
     774    mr_free(command);
     775
     776    mr_asprintf(&command, "mkdir -p %s%s", bkpinfo->scratchdir, MNT_FLOPPY);
    717777    if (system(command)) {
    718778        res++;
    719779        log_OS_error("Unable to make mnt floppy directory");
    720780    }
     781    mr_free(command);
    721782
    722783    /* Prepare interface with mindi through a configuration file
     
    818879        mr_fprintf(fd1, "use-cdrecovery no\n");
    819880    }
     881
    820882    if (bkpinfo->make_cd_use_lilo) {
    821883        mr_fprintf(fd1, "use-lilo yes\n");
     
    838900    mr_fclose(fd1);
    839901
    840     sprintf(command, "mindi --custom '%s' '%s/images'",
     902    mr_asprintf(&command, "mindi --custom '%s' '%s/images'",
    841903                bkpinfo->tmpdir, bkpinfo->scratchdir);
    842904            //bkpinfo->tmpdir,      // parameter #2
     
    863925
    864926    res = run_program_and_log_to_screen(command, "Generating boot+data disks");
     927    mr_free(command);
    865928    if (bkpinfo->nonbootable_backup) {
    866929        res = 0;
     
    868931    if (!res) {
    869932        log_to_screen("Boot+data disks were created OK");
    870         sprintf(command, "mkdir -p /var/cache/mindi/");
     933        mr_asprintf(&command, "mkdir -p /var/cache/mindi/");
    871934        mr_msg(2, command);
    872935        run_program_and_log_output(command, FALSE);
    873         sprintf(command,
     936        mr_free(command);
     937
     938        mr_asprintf(&command,
    874939                "cp -f %s/images/mindi.iso /var/cache/mindi/mondorescue.iso",
    875940                bkpinfo->scratchdir);
    876941        mr_msg(2, command);
    877942        run_program_and_log_output(command, FALSE);
     943        mr_free(command);
     944
    878945        if (bkpinfo->nonbootable_backup) {
    879             sprintf(command, "cp -f %s/all.tar.gz %s/images",
     946            mr_asprintf(&command, "cp -f %s/all.tar.gz %s/images",
    880947                    bkpinfo->tmpdir, bkpinfo->scratchdir);
    881948            if (system(command)) {
    882949                fatal_error("Unable to create temporary duff tarball");
    883950            }
    884         }
     951            mr_free(command);
     952           
     953        }
     954/* BERLIOS: Not executed ?
    885955        sprintf(command, "cp -f %s/mindi-*oot*.img %s/images",
    886956                bkpinfo->tmpdir, bkpinfo->scratchdir);
    887         sprintf(tmp, "cp -f %s/images/all.tar.gz %s", bkpinfo->scratchdir,
    888                 bkpinfo->tmpdir);
     957*/
     958        mr_asprintf(&tmp, "cp -f %s/images/all.tar.gz %s",
     959                 bkpinfo->scratchdir, bkpinfo->tmpdir);
    889960        if (system(tmp)) {
    890961            fatal_error("Cannot find all.tar.gz in tmpdir");
    891962        }
     963        mr_free(tmp);
     964
    892965        if (res) {
    893966            mvaddstr_and_log_it(g_currentY++, 74, "Errors.");
     
    897970    } else {
    898971        log_to_screen("Mindi failed to create your boot+data disks.");
    899         strcpy(command, "grep 'Fatal error' /var/log/mindi.log");
    900         strcpy(tmp, call_program_and_get_last_line_of_output(command));
     972        mr_asprintf(&command, "grep 'Fatal error' /var/log/mindi.log");
     973        malloc_string(tmp);
     974        strcpy(tmp,call_program_and_get_last_line_of_output(command));
     975        mr_free(command);
    901976        if (strlen(tmp) > 1) {
    902977            popup_and_OK(tmp);
    903978        }
    904     }
    905     mr_free(tmp);
    906     mr_free(scratchdir);
     979        mr_free(tmp);
     980    }
    907981    mr_free(bootldr_str);
    908982    mr_free(last_filelist_number);
    909     mr_free(tape_size_sz);
    910983    mr_free(devs_to_exclude);
    911     mr_free(value);
    912984    mr_free(bootdev);
    913     mr_free(command);
    914985    return (res);
    915986}
    916 
    917987
    918988
     
    9621032
    9631033    struct s_bkpinfo *bkpinfo;
    964     char *tmp;
     1034    char *tmp = NULL;
    9651035    int res = 0, retval = 0;
    9661036    int *p_archival_threads_running;
     
    9701040    int this_thread_no = g_current_thread_no++;
    9711041
    972     malloc_string(curr_xattr_list_fname);
    973     malloc_string(curr_acl_list_fname);
    9741042    malloc_string(archiving_filelist_fname);
    9751043    malloc_string(archiving_afioball_fname);
    976     malloc_string(tmp);
    9771044    p_last_set_archived = (int *) inbuf;
    9781045    p_archival_threads_running = (int *) (inbuf + 4);
     
    10181085        }
    10191086
    1020         sprintf(tmp, AFIOBALL_FNAME_RAW_SZ, bkpinfo->tmpdir,
    1021                 archiving_set_no - ARCH_BUFFER_NUM, bkpinfo->zip_suffix);
     1087        mr_asprintf(&tmp, AFIOBALL_FNAME_RAW_SZ, bkpinfo->tmpdir,
     1088                 archiving_set_no - ARCH_BUFFER_NUM, bkpinfo->zip_suffix);
    10221089        if (does_file_exist(tmp)) {
    1023             mr_msg(4, "%s[%d:%d] - waiting for storer", FORTY_SPACES,
    1024                     getpid(), this_thread_no);
     1090            mr_msg(4, "%s[%d:%d] - waiting for storer",
     1091                    FORTY_SPACES, getpid(), this_thread_no);
    10251092            while (does_file_exist(tmp)) {
    10261093                sleep(1);
     
    10281095            mr_msg(4, "[%d] - continuing", getpid());
    10291096        }
     1097        mr_free(tmp);
    10301098
    10311099        mr_msg(4, "%s[%d:%d] - EXATing %d...", FORTY_SPACES, getpid(),
    10321100                this_thread_no, archiving_set_no);
    10331101        if (g_getfattr) {
    1034             sprintf(curr_xattr_list_fname, XATTR_LIST_FNAME_RAW_SZ,
     1102            mr_asprintf(&curr_xattr_list_fname, XATTR_LIST_FNAME_RAW_SZ,
    10351103                bkpinfo->tmpdir, archiving_set_no);
    10361104            get_fattr_list(archiving_filelist_fname, curr_xattr_list_fname);
     1105            mr_free(curr_xattr_list_fname);
    10371106        }
    10381107        if (g_getfacl) {
    1039             sprintf(curr_acl_list_fname, ACL_LIST_FNAME_RAW_SZ,
     1108            mr_asprintf(&curr_acl_list_fname, ACL_LIST_FNAME_RAW_SZ,
    10401109                bkpinfo->tmpdir, archiving_set_no);
    10411110            get_acl_list(archiving_filelist_fname, curr_acl_list_fname);
     1111            mr_free(curr_acl_list_fname);
    10421112        }
    10431113
     
    10511121
    10521122        if (res) {
    1053             sprintf(tmp,
    1054                     "Errors occurred while archiving set %ld. Please review logs.",
    1055                     archiving_set_no);
     1123            mr_asprintf(&tmp,
     1124                     "Errors occurred while archiving set %ld. Please review logs.",
     1125                     archiving_set_no);
    10561126            log_to_screen(tmp);
     1127            mr_free(tmp);
    10571128        }
    10581129        if (!semaphore_p()) {
     
    10841155    mr_free(archiving_filelist_fname);
    10851156    mr_free(archiving_afioball_fname);
    1086     mr_free(curr_xattr_list_fname);
    1087     mr_free(curr_acl_list_fname);
    1088     mr_free(tmp);
    10891157    pthread_exit(NULL);
    10901158}
    1091 
    1092 
    1093 
    10941159
    10951160
     
    11171182
    11181183    mr_msg(1, "Closing tape/CD ... ");
    1119     if (IS_THIS_A_STREAMING_BACKUP(bkpinfo->backup_media_type))
     1184    if (IS_THIS_A_STREAMING_BACKUP(bkpinfo->backup_media_type)) {
    11201185        /* write tape/cdstream */
    1121     {
    11221186        closeout_tape(bkpinfo);
    1123     } else
     1187    } else {
    11241188        /* write final ISO/USB */
    1125     {
    11261189        res = write_final_iso_if_necessary(bkpinfo);
    11271190        retval += res;
     
    11741237    assert(bkpinfo != NULL);
    11751238    malloc_string(command);
    1176     malloc_string(tmpfile);
    1177     malloc_string(data_disks_file);
    1178     sprintf(data_disks_file, "%s/all.tar.gz", bkpinfo->tmpdir);
     1239
     1240    mr_asprintf(&data_disks_file, "%s/all.tar.gz", bkpinfo->tmpdir);
    11791241
    11801242    snprintf(g_serial_string, MAX_STR_LEN - 1,
     
    11871249    assert(strlen(g_serial_string) < MAX_STR_LEN);
    11881250
    1189     sprintf(tmpfile, "%s/archives/SERIAL-STRING", bkpinfo->scratchdir);
     1251    mr_asprintf(&tmpfile, "%s/archives/SERIAL-STRING", bkpinfo->scratchdir);
    11901252    if (write_one_liner_data_file(tmpfile, g_serial_string)) {
    11911253        mr_msg(1, "%ld: Failed to write serial string", __LINE__);
    11921254    }
     1255    mr_free(tmpfile);
    11931256
    11941257    mvaddstr_and_log_it(g_currentY, 0, "Preparing to archive your data");
     
    12071270        mr_msg(1, "Backing up to CD's");
    12081271    }
    1209 
    1210     sprintf(command, "rm -f %s/%s/%s-[1-9]*.iso", bkpinfo->isodir,
    1211             bkpinfo->nfs_remote_dir, bkpinfo->prefix);
     1272    mr_free(data_disks_file);
     1273
     1274    mr_asprintf(&command, "rm -f %s/%s/%s-[1-9]*.iso", bkpinfo->isodir,
     1275             bkpinfo->nfs_remote_dir, bkpinfo->prefix);
    12121276    paranoid_system(command);
     1277    mr_free(command);
     1278
    12131279    wipe_archives(bkpinfo->scratchdir);
    12141280    mvaddstr_and_log_it(g_currentY++, 74, "Done.");
     
    12191285                                     BLK_START_OF_BACKUP);
    12201286    }
    1221     mr_free(command);
    1222     mr_free(tmpfile);
    1223     mr_free(data_disks_file);
    12241287    return (retval);
    12251288}
     
    12471310
    12481311    /*@ buffers *********************************************************** */
    1249     char *command;
     1312    char *command = NULL;
    12501313    char *tempfile;
    12511314
     
    12561319    assert_string_is_neither_NULL_nor_zerolength(title);
    12571320
    1258     malloc_string(command);
    12591321    malloc_string(tempfile);
    12601322#ifdef __FreeBSD__
     
    12761338           call_program_and_get_last_line_of_output
    12771339           ("mktemp -q /tmp/mondo.XXXXXXXX"));
    1278     sprintf(command, "%s >> %s 2>> %s; rm -f %s", cmd, tempfile, tempfile,
    1279             tempfile);
     1340    mr_asprintf(&command, "%s >> %s 2>> %s; rm -f %s", cmd, tempfile, tempfile, tempfile);
    12801341    mr_msg(3, command);
    12811342    open_evalcall_form(title);
     
    12891350        maxtracks = 80;
    12901351    }
     1352    mr_free(command);
     1353
    12911354    for (sleep(1); does_file_exist(tempfile); sleep(1)) {
    12921355        trackno = get_trackno_from_logfile(tempfile);
     
    13101373    }
    13111374    unlink(tempfile);
    1312     mr_free(command);
    13131375    mr_free(tempfile);
    13141376    return (res);
    13151377}
     1378
    13161379
    13171380/**
     
    13361399    char *title;
    13371400
    1338 
    13391401    assert_string_is_neither_NULL_nor_zerolength(device);
    1340     malloc_string(title);
    1341     command = mr_malloc(1000);
     1402
    13421403    if (!system("which superformat > /dev/null 2> /dev/null")) {
    1343         sprintf(command, "superformat %s", device);
     1404        mr_asprintf(&command, "superformat %s", device);
    13441405    } else {
    13451406#ifdef __FreeBSD__
    1346         sprintf(command, "fdformat -y %s", device);
     1407        mr_asprintf(&command, "fdformat -y %s", device);
    13471408#else
    1348         sprintf(command, "fdformat %s", device);
     1409        mr_asprintf(&command, "fdformat %s", device);
    13491410#endif
    13501411    }
    1351     sprintf(title, "Formatting disk %s", device);
     1412    mr_asprintf(&title, "Formatting disk %s", device);
    13521413    while ((res = format_disk_SUB(command, title))) {
    13531414        if (!ask_me_yes_or_no("Failed to format disk. Retry?")) {
     
    13591420    return (res);
    13601421}
     1422
    13611423
    13621424/**
     
    13831445    }
    13841446}
    1385 
    1386 
    1387 
    1388 
    1389 
    1390 
    1391 
    13921447
    13931448
     
    14701525    log_to_screen("Archiving regular files");
    14711526    mr_msg(5, "Go, Shorty. It's your birthday.");
    1472     open_progress_form("Backing up filesystem",
    1473                        "I am backing up your live filesystem now.",
    1474                        "Please wait. This may take a couple of hours.",
    1475                        "Working...",
     1527    open_progress_form(_("Backing up filesystem"),
     1528                       _("I am backing up your live filesystem now."),
     1529                       _("Please wait. This may take a couple of hours."),
     1530                       _("Working..."),
    14761531                       get_last_filelist_number(bkpinfo) + 1);
    14771532
     
    15191574            }
    15201575            sleep(1);
    1521         } else
     1576        } else {
    15221577            // store set N
    1523         {
    15241578            sprintf(storing_filelist_fname, FILELIST_FNAME_RAW_SZ,
    15251579                    bkpinfo->tmpdir, storing_set_no);
     
    15521606                                                       storing_afioball_fname);
    15531607                iamhere("Writing EXAT files");
    1554                 res +=
    1555                     write_EXAT_files_to_tape(bkpinfo,
    1556                                              curr_xattr_list_fname,
    1557                                              curr_acl_list_fname);
    1558 // archives themselves
     1608                res += write_EXAT_files_to_tape(bkpinfo,
     1609                                                curr_xattr_list_fname,
     1610                                                curr_acl_list_fname);
     1611                // archives themselves
    15591612                res +=
    15601613                    move_files_to_stream(bkpinfo, storing_afioball_fname,
Note: See TracChangeset for help on using the changeset viewer.