Changeset 2296 in MondoRescue for branches/2.2.10/mondo/src/mondorestore


Ignore:
Timestamp:
Jul 23, 2009, 2:53:30 PM (16 years ago)
Author:
Bruno Cornec
Message:
  • Replace sprintf by mr_asprintf in mondo-rstr-compare.c
  • All mr_asprintf call should be on one line (for quality script) and use a string as second param
  • Improve quality script
Location:
branches/2.2.10/mondo/src/mondorestore
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • branches/2.2.10/mondo/src/mondorestore/mondo-prep.c

    r2291 r2296  
    7979        make_list_of_drives_in_mountlist(mountlist, drivelist);
    8080        for (lino = 0; lino < drivelist->entries; lino++) {
    81             mr_asprintf(&command,
    82                     "dd if=%s bs=512 count=1 2> /dev/null | grep \"%s\"",
    83                     drivelist->el[lino].device, MONDO_WAS_HERE);
     81            mr_asprintf(&command, "dd if=%s bs=512 count=1 2> /dev/null | grep \"%s\"", drivelist->el[lino].device, MONDO_WAS_HERE);
    8482            res = run_program_and_log_output(command, 1);
    8583            mr_free(command);
     
    260258        strcpy(vgremove_sz, "vgremove");
    261259    }
    262     mr_asprintf(&tmp1,
    263             "for i in `%s | cut -d\"'\" -f2 | sort -r` ; do echo \"Shutting down lv $i\" >> %s ; %s -f $i; done", lvscan_sz, MONDO_LOGFILE, lvremove_sz);
     260    mr_asprintf(&tmp1, "for i in `%s | cut -d\"'\" -f2 | sort -r` ; do echo \"Shutting down lv $i\" >> %s ; %s -f $i; done", lvscan_sz, MONDO_LOGFILE, lvremove_sz);
    264261    run_program_and_log_output(tmp1, 5);
    265262    mr_free(tmp1);
     
    521518                            new_mountlist->entries++;
    522519                        } else {
    523                             mr_asprintf(&tmp,
    524                                     "Not adding %s to mountlist: it's already there",
    525                                     p);
     520                            mr_asprintf(&tmp, "Not adding %s to mountlist: it's already there", p);
    526521                            log_it(tmp);
    527522                            mr_free(tmp);
     
    647642    mr_asprintf(&strtmp, "%s", program);
    648643    paranoid_free(program);
    649     mr_asprintf(&program, "%s --spare-devices=%d", strtmp,
    650          raidlist->el[i].spare_disks.entries);
     644    mr_asprintf(&program, "%s --spare-devices=%d", strtmp, raidlist->el[i].spare_disks.entries);
    651645    paranoid_free(strtmp);
    652646  }
     
    747741
    748742            /* format raid partition */
    749             mr_asprintf(&program,
    750                     "for plex in `vinum lv -r %s | grep '^P' | tr '\t' ' ' | tr -s ' ' | cut -d' ' -f2`; do echo $plex; done > /tmp/plexes", basename(device));
     743            mr_asprintf(&program, "for plex in `vinum lv -r %s | grep '^P' | tr '\t' ' ' | tr -s ' ' | cut -d' ' -f2`; do echo $plex; done > /tmp/plexes", basename(device));
    751744            system(program);
    752745            if (g_fprep) {
     
    914907
    915908    assert(mountlist != NULL);
    916     mr_asprintf(&tmp, "format_everything (mountlist, interactively = %s",
    917             (interactively) ? "true" : "false");
     909    mr_asprintf(&tmp, "format_everything (mountlist, interactively = %s", (interactively) ? "true" : "false");
    918910    log_it(tmp);
    919911    mr_free(tmp);
     
    943935            if (interactively) {
    944936                // ask user if we should format the current device
    945                 mr_asprintf(&tmp, "Shall I format %s (%s) ?", me->device,
    946                         me->mountpoint);
     937                mr_asprintf(&tmp, "Shall I format %s (%s) ?", me->device, me->mountpoint);
    947938                do_it = ask_me_yes_or_no(tmp);
    948939                mr_free(tmp);
     
    14251416    mr_free(command);
    14261417
    1427     mr_asprintf(&command, "disklabel -R %s /tmp/disklabel",
    1428             canonical_name(drivename));
     1418    mr_asprintf(&command, "disklabel -R %s /tmp/disklabel", canonical_name(drivename));
    14291419    retval += run_program_and_log_output(command, TRUE);
    14301420    mr_free(command);
     
    15711561            file = open(drivename, O_WRONLY);
    15721562            if (file != -1) {
    1573                 mr_asprintf(&tmp,
    1574                         "Warning - unable to open %s for wiping it's partition table",
    1575                         drivename);
     1563                mr_asprintf(&tmp, "Warning - unable to open %s for wiping it's partition table", drivename);
    15761564                log_to_screen(tmp);
    15771565                mr_free(tmp);
     
    15801568            for (i = 0; i < 512; i++) {
    15811569                if (!write(file, "\0", 1)) {
    1582                     mr_asprintf(&tmp, "Warning - unable to write to %s",
    1583                             drivename);
     1570                    mr_asprintf(&tmp, "Warning - unable to write to %s", drivename);
    15841571                    log_to_screen(tmp);
    15851572                    mr_free(tmp);
     
    16421629    if (pout_to_fdisk) {
    16431630// mark relevant partition as bootable
    1644         mr_asprintf(&tmp, "a\n%s\n",
    1645                 call_program_and_get_last_line_of_output
    1646                 ("make-me-bootable /tmp/mountlist.txt dummy"));
     1631        mr_asprintf(&tmp, "a\n%s\n", call_program_and_get_last_line_of_output("make-me-bootable /tmp/mountlist.txt dummy"));
    16471632        fput_string_one_char_at_a_time(pout_to_fdisk, tmp);
    16481633        mr_free(tmp);
     
    17391724
    17401725    if (is_this_device_mounted(partition_name)) {
    1741         mr_asprintf(&tmp, "%s is mounted, and should not be partitioned",
    1742                 partition_name);
     1726        mr_asprintf(&tmp, "%s is mounted, and should not be partitioned", partition_name);
    17431727        log_to_screen(tmp);
    17441728        mr_free(tmp);
     
    20502034    } else {
    20512035        /* probably an image */
    2052         mr_asprintf(&tmp,
    2053                 "Unknown format ('%s') - using supplied string anyway",
    2054                 format);
     2036        mr_asprintf(&tmp, "Unknown format ('%s') - using supplied string anyway", format);
    20552037        mvaddstr_and_log_it(g_currentY++, 0, tmp);
    20562038        mr_free(tmp);
  • branches/2.2.10/mondo/src/mondorestore/mondo-rstr-compare.c

    r2291 r2296  
    4747    char *bigfile_fname_ptr;
    4848    char *tmp_ptr = NULL;
    49     char *command_ptr;
     49    char *command_ptr = NULL;
    5050
    5151    char *checksum, *original_cksum, *bigfile_fname, *tmp, *command;
     
    6565    malloc_string(original_cksum_ptr);
    6666    malloc_string(bigfile_fname_ptr);
    67     malloc_string(command_ptr);
    6867
    6968  /*********************************************************************
     
    7473    memset(original_cksum_ptr, '\0', sizeof(original_cksum));
    7574    memset(bigfile_fname_ptr, '\0', sizeof(bigfile_fname));
    76     memset(command_ptr, '\0', sizeof(command));
    7775  /** end **/
    7876
     
    113111    if (!strncmp(bigfile_fname_ptr, "/dev/", 5)) {
    114112        strcpy(original_cksum_ptr, "IGNORE");
    115     } else {
    116         sprintf(command_ptr,
    117                 "md5sum \"%s%s\" > /tmp/md5sum.txt 2> /tmp/errors",
    118                 MNT_RESTORING, bigfile_fname_ptr);
    119     }
     113        log_msg(2, "IGNORING %s as begining with /dev", bigfile_fname_ptr);
     114        return (1);
     115    }
     116
     117    mr_asprintf(&command_ptr, "md5sum \"%s%s\" > /tmp/md5sum.txt 2> /tmp/errors", MNT_RESTORING, bigfile_fname_ptr);
    120118    log_msg(2, command_ptr);
     119    i =  system(command_ptr);
     120    mr_free(command_ptr);
     121
    121122    mr_asprintf(&tmp_ptr, "cat /tmp/errors >> %s 2> /dev/null", MONDO_LOGFILE);
    122123    paranoid_system(tmp_ptr);
    123124    paranoid_free(tmp_ptr);
    124125
    125     if (system(command_ptr)) {
     126    if (i) {
    126127        log_OS_error("Warning - command failed");
    127128        original_cksum[0] = '\0';
     
    169170    paranoid_free(checksum_ptr);
    170171    paranoid_free(checksum);
    171     paranoid_free(command_ptr);
    172172    paranoid_free(command);
    173173    paranoid_free(tmp);
     
    190190    int res;
    191191    long noof_biggiefiles, bigfileno = 0;
    192     char tmp[MAX_STR_LEN];
     192    char *tmp = NULL;
    193193
    194194    log_msg(1, "Comparing biggiefiles");
     
    211211                       noof_biggiefiles);
    212212    for (bigfileno = 0; bigfileno < noof_biggiefiles; bigfileno++) {
    213         sprintf(tmp, "Comparing big file #%ld", bigfileno + 1);
     213        mr_asprintf(&tmp, "Comparing big file #%ld", bigfileno + 1);
    214214        log_msg(1, tmp);
    215215        update_progress_form(tmp);
     216        mr_free(tmp);
     217
    216218        res = compare_a_biggiefile(bigfileno);
    217219        retval += res;
     
    250252
    251253  /***  needs malloc *********/
    252     char *command, *tmp, *filelist_name, *logfile,
    253         *compressor_exe;
     254    char *command = NULL;
     255    char *tmp = NULL;
    254256    char *archiver_exe = NULL;
    255 
    256     malloc_string(command);
    257     malloc_string(tmp);
    258     malloc_string(filelist_name);
    259     malloc_string(logfile);
    260     malloc_string(compressor_exe);
     257    char *filelist_name = NULL;
     258    char *logfile = NULL;
     259    char *compressor_exe = NULL;
    261260
    262261    use_star = (strstr(tarball_fname, ".star")) ? TRUE : FALSE;
    263262    assert_string_is_neither_NULL_nor_zerolength(tarball_fname);
    264     sprintf(logfile, "/tmp/afio.log.%d", current_tarball_number);
    265     sprintf(filelist_name, MNT_CDROM "/archives/filelist.%d",
    266             current_tarball_number);
    267 
     263    mr_asprintf(&filelist_name, MNT_CDROM "/archives/filelist.%d", current_tarball_number);
    268264    noof_lines = count_lines_in_file(filelist_name);
     265    mr_free(filelist_name);
    269266
    270267    if (strstr(tarball_fname, ".bz2")) {
    271         strcpy(compressor_exe, "bzip2");
     268        mr_asprintf(&compressor_exe, "bzip2");
    272269    } else if (strstr(tarball_fname, ".gz")) {
    273         strcpy(compressor_exe, "gzip");
     270        mr_asprintf(&compressor_exe, "gzip");
    274271    } else if (strstr(tarball_fname, ".lzo")) {
    275         strcpy(compressor_exe, "lzop");
    276     } else {
    277         compressor_exe[0] = '\0';
     272        mr_asprintf(&compressor_exe, "lzop");
    278273    }
    279274
     
    284279    }
    285280
    286     if (compressor_exe[0]) {
    287         strcpy(tmp, compressor_exe);
    288         if (!find_home_of_exe(tmp)) {
     281    if (compressor_exe) {
     282        if (!find_home_of_exe(compressor_exe)) {
     283            mr_free(compressor_exe);
     284            mr_free(archiver_exe);
    289285            fatal_error("(compare_a_tarball) Compression program missing");
    290286        }
    291         if (use_star)           // star
    292         {
     287        if (use_star) {
    293288            if (!strcmp(compressor_exe, "bzip2")) {
    294289                mr_strcat(archiver_exe, " -bz");
    295290            } else {
    296                 fatal_error
    297                     ("(compare_a_tarball) Please use only bzip2 with star");
     291                mr_free(compressor_exe);
     292                mr_free(archiver_exe);
     293                fatal_error("(compare_a_tarball) Please use only bzip2 with star");
    298294            }
    299         } else                  // afio
    300         {
    301             sprintf(compressor_exe, "-P %s -Z", tmp);
    302         }
    303     }
    304 // star -diff H=star -bz file=....
     295        } else {
     296            // afio
     297            mr_free(compressor_exe);
     298            mr_asprintf(&tmp, "%s", compressor_exe);
     299            mr_asprintf(&compressor_exe, "-P %s -Z", tmp);
     300            mr_free(tmp);
     301        }
     302    }
    305303
    306304#ifdef __FreeBSD__
     
    309307#define BUFSIZE (1024L*1024L)/TAPE_BLOCK_SIZE
    310308#endif
    311     if (use_star)               // doesn't use compressor_exe
    312     {
    313         sprintf(command,
    314                 "%s -diff H=star file=%s >> %s 2>> %s",
    315                 archiver_exe, tarball_fname, logfile, logfile);
    316     } else {
    317         sprintf(command,
    318                 "%s -r -b %ld -M 16m -c %ld %s %s >> %s 2>> %s",
    319                 archiver_exe,
    320                 TAPE_BLOCK_SIZE,
    321                 BUFSIZE, compressor_exe, tarball_fname, logfile, logfile);
    322     }
     309    mr_asprintf(&logfile, "/tmp/afio.log.%d", current_tarball_number);
     310
     311    if (use_star) {
     312        // doesn't use compressor_exe
     313        mr_asprintf(&command, "%s -diff H=star file=%s >> %s 2>> %s", archiver_exe, tarball_fname, logfile, logfile);
     314    } else {
     315        mr_asprintf(&command, "%s -r -b %ld -M 16m -c %ld %s %s >> %s 2>> %s", archiver_exe, TAPE_BLOCK_SIZE, BUFSIZE, compressor_exe, tarball_fname, logfile, logfile);
     316    }
     317    mr_free(compressor_exe);
    323318    paranoid_free(archiver_exe);
    324319
     
    329324    if (res) {
    330325        log_OS_error(command);
    331         sprintf(tmp, "Warning - afio returned error = %d", res);
    332         log_msg(2, tmp);
    333     }
     326        log_msg(2, "Warning - afio returned error = %d", res);
     327    }
     328    mr_free(command);
     329
    334330    if (length_of_file(logfile) > 5) {
    335         sprintf(command,
    336                 "sed s/': \\\"'/\\|/ %s | sed s/'\\\": '/\\|/ | cut -d'|' -f2 | sort -u | grep -vE \"^dev/.*\" >> "MONDO_CACHE"/changed.txt",
    337                 logfile);
     331        mr_asprintf(&command, "sed s/': \\\"'/\\|/ %s | sed s/'\\\": '/\\|/ | cut -d'|' -f2 | sort -u | grep -vE \"^dev/.*\" >> "MONDO_CACHE"/changed.txt", logfile);
    338332        system(command);
     333        mr_free(command);
     334
    339335        archiver_errors = count_lines_in_file(logfile);
    340336    } else {
    341337        archiver_errors = 0;
    342338    }
    343     sprintf(tmp, "%ld difference%c in fileset #%d          ",
    344             archiver_errors, (archiver_errors != 1) ? 's' : ' ',
    345             current_tarball_number);
    346339    if (archiver_errors) {
    347         sprintf(tmp,
    348                 "Differences found while processing fileset #%d       ",
    349                 current_tarball_number);
    350         log_msg(1, tmp);
     340        log_msg(1, "%ld difference%c in fileset #%d          ", archiver_errors, (archiver_errors != 1) ? 's' : ' ', current_tarball_number);
    351341    }
    352342    unlink(logfile);
    353     paranoid_free(command);
    354     paranoid_free(tmp);
    355     paranoid_free(filelist_name);
    356     paranoid_free(logfile);
    357     paranoid_free(compressor_exe);
     343    mr_free(logfile);
     344
    358345    return (retval);
    359346}
     
    377364  /**  needs malloc **********/
    378365
    379     char *tarball_fname, *progress_str, *tmp;
     366    char *tarball_fname = NULL;
     367    char *progress_str = NULL;
     368    char *tmp = NULL;
    380369    char *mds = NULL;
    381370    long max_val;
    382371
    383     malloc_string(tarball_fname);
    384     malloc_string(progress_str);
    385     malloc_string(tmp);
    386372
    387373    assert(bkpinfo != NULL);
    388374    mvaddstr_and_log_it(g_currentY, 0, "Comparing archives");
     375
     376    malloc_string(tmp);
    389377    read_cfg_var(g_mondo_cfg_file, "last-filelist-number", tmp);
    390 
    391378    max_val = atol(tmp);
     379    paranoid_free(tmp);
     380
    392381    mds = media_descriptor_string(bkpinfo->backup_media_type);
    393     sprintf(progress_str, "Comparing with %s #%d ", mds, g_current_media_number);
     382    mr_asprintf(&progress_str, "Comparing with %s #%d ", mds, g_current_media_number);
    394383
    395384    open_progress_form("Comparing files",
     
    403392        insist_on_this_cd_number(g_current_media_number);
    404393        update_progress_form(progress_str);
    405         sprintf(tarball_fname,
    406                 MNT_CDROM "/archives/%d.afio.bz2", current_tarball_number);
     394        mr_asprintf(&tarball_fname, MNT_CDROM "/archives/%d.afio.bz2", current_tarball_number);
    407395
    408396        if (!does_file_exist(tarball_fname)) {
    409             sprintf(tarball_fname, MNT_CDROM "/archives/%d.afio.lzo",
    410                     current_tarball_number);
     397            mr_free(tarball_fname);
     398            mr_asprintf(&tarball_fname, MNT_CDROM "/archives/%d.afio.lzo", current_tarball_number);
    411399        }
    412400        if (!does_file_exist(tarball_fname)) {
    413             sprintf(tarball_fname, MNT_CDROM "/archives/%d.afio.gz",
    414                     current_tarball_number);
     401            mr_free(tarball_fname);
     402            mr_asprintf(&tarball_fname, MNT_CDROM "/archives/%d.afio.gz", current_tarball_number);
    415403        }
    416404        if (!does_file_exist(tarball_fname)) {
    417             sprintf(tarball_fname, MNT_CDROM "/archives/%d.afio.",
    418                     current_tarball_number);
     405            mr_free(tarball_fname);
     406            mr_asprintf(&tarball_fname, MNT_CDROM "/archives/%d.afio.", current_tarball_number);
    419407        }
    420408        if (!does_file_exist(tarball_fname)) {
    421             sprintf(tarball_fname, MNT_CDROM "/archives/%d.star.bz2",
    422                     current_tarball_number);
     409            mr_free(tarball_fname);
     410            mr_asprintf(&tarball_fname, MNT_CDROM "/archives/%d.star.bz2", current_tarball_number);
    423411        }
    424412        if (!does_file_exist(tarball_fname)) {
    425             sprintf(tarball_fname, MNT_CDROM "/archives/%d.star.",
    426                     current_tarball_number);
     413            mr_free(tarball_fname);
     414            mr_asprintf(&tarball_fname, MNT_CDROM "/archives/%d.star.", current_tarball_number);
    427415        }
    428416        if (!does_file_exist(tarball_fname)) {
     
    432420                == 0) {
    433421                log_msg(2, "OK, I think I'm done with tarballs...");
     422                mr_free(tarball_fname);
    434423                break;
    435424            }
    436425            log_msg(2, "OK, I think it's time for another CD...");
    437426            g_current_media_number++;
    438             sprintf(progress_str, "Comparing with %s #%d ", mds, g_current_media_number);
     427
     428            mr_free(progress_str);
     429            mr_asprintf(&progress_str, "Comparing with %s #%d ", mds, g_current_media_number);
    439430            log_to_screen(progress_str);
    440431        } else {
     
    444435            current_tarball_number++;
    445436        }
    446     }
     437        mr_free(tarball_fname);
     438    }
     439    mr_free(progress_str);
    447440    mr_free(mds);
    448441
     
    453446        mvaddstr_and_log_it(g_currentY++, 74, "Done.");
    454447    }
    455     paranoid_free(tarball_fname);
    456     paranoid_free(progress_str);
    457     paranoid_free(tmp);
    458448    return (retval);
    459449}
     
    478468{
    479469  /** needs malloc *********/
    480     char *tmp, *cwd, *new, *command;
     470    char *tmp = NULL;
     471    char *cwd, *new;
     472    char *command = NULL;
    481473    int resA = 0;
    482474    int resB = 0;
    483475    long noof_changed_files;
    484476
    485     malloc_string(tmp);
    486477    malloc_string(cwd);
    487478    malloc_string(new);
    488     malloc_string(command);
    489479
    490480    assert(bkpinfo != NULL);
     
    501491    noof_changed_files = count_lines_in_file(MONDO_CACHE"/changed.txt");
    502492    if (noof_changed_files) {
    503         sprintf(tmp, "%ld files do not match the backup            ",
    504                 noof_changed_files);
    505         //      mvaddstr_and_log_it( g_currentY++, 0, tmp );
     493        mr_asprintf(&tmp, "%ld files do not match the backup            ", noof_changed_files);
    506494        log_to_screen(tmp);
    507         sprintf(command, "cat "MONDO_CACHE"/changed.txt >> %s", MONDO_LOGFILE);
     495        mr_free(tmp);
     496
     497        mr_asprintf(&command, "cat "MONDO_CACHE"/changed.txt >> %s", MONDO_LOGFILE);
    508498        paranoid_system(command);
    509     } else {
    510         sprintf(tmp, "All files match the backup                     ");
     499        mr_free(command);
     500    } else {
     501        mr_asprintf(&tmp, "All files match the backup                     ");
    511502        mvaddstr_and_log_it(g_currentY++, 0, tmp);
    512503        log_to_screen(tmp);
    513     }
    514 
    515     paranoid_free(tmp);
     504        mr_free(tmp);
     505    }
     506
    516507    paranoid_free(cwd);
    517508    paranoid_free(new);
    518     paranoid_free(command);
    519509
    520510    return (resA + resB);
     
    544534    int res = 0;
    545535    long q;
    546     char *tmp;
     536    char *tmp = NULL;
    547537    char *new;
    548538    char *cwd;
    549539
    550     malloc_string(tmp);
    551540    malloc_string(new);
    552541    malloc_string(cwd);
     
    575564    if (g_text_mode) {
    576565        save_mountlist_to_disk(mountlist, g_mountlist_fname);
    577         sprintf(tmp, "%s %s", find_my_editor(), g_mountlist_fname);
     566        mr_asprintf(&tmp, "%s %s", find_my_editor(), g_mountlist_fname);
    578567        res = system(tmp);
     568        mr_free(tmp);
     569
    579570        load_mountlist(mountlist, g_mountlist_fname);
    580571    } else {
     
    622613        } else {
    623614            q = count_lines_in_file(MONDO_CACHE"/changed.files");
    624             sprintf(tmp, "%ld significant difference%s found.", q,
    625                     (q != 1) ? "s" : "");
     615            mr_asprintf(&tmp, "%ld significant difference%s found.", q, (q != 1) ? "s" : "");
    626616            mvaddstr_and_log_it(g_currentY++, 0, tmp);
    627617            log_to_screen(tmp);
    628 
    629             strcpy(tmp,
    630                   "Type 'less /tmp/changed.files' for a list of non-matching files");
     618            mr_free(tmp);
     619
     620            mr_asprintf(&tmp, "Type 'less /tmp/changed.files' for a list of non-matching files");
    631621            mvaddstr_and_log_it(g_currentY++, 0, tmp);
    632622            log_to_screen(tmp);
     623            mr_free(tmp);
    633624
    634625            log_msg(2, "calling popup_changelist_from_file()");
     
    647638
    648639    kill_petris();
    649     paranoid_free(tmp);
    650640    paranoid_free(new);
    651641    paranoid_free(cwd);
     
    670660
    671661  /** needs malloc **/
    672     char *dir, *command;
     662    char *dir;
     663    char *command = NULL;
    673664
    674665    assert(bkpinfo != NULL);
    675666    malloc_string(dir);
    676     malloc_string(command);
    677667    getcwd(dir, MAX_STR_LEN);
    678668    chdir(bkpinfo->restore_path);
    679669
    680     sprintf(command, "cp -f /tmp/LAST-FILELIST-NUMBER %s/tmp",
    681             bkpinfo->restore_path);
     670    mr_asprintf(&command, "cp -f /tmp/LAST-FILELIST-NUMBER %s/tmp", bkpinfo->restore_path);
    682671    run_program_and_log_output(command, FALSE);
     672    mr_free(command);
     673
    683674    mvaddstr_and_log_it(g_currentY,
    684675                        0, "Verifying archives against filesystem");
     
    704695    mvaddstr_and_log_it(g_currentY++, 74, "Done.");
    705696    paranoid_free(dir);
    706     paranoid_free(command);
    707697    return (res);
    708698}
     
    727717{
    728718    int res;
    729     char *dir, *command;
     719    char *dir;
     720    char *command = NULL;
    730721
    731722    assert(bkpinfo != NULL);
    732723    malloc_string(dir);
    733     malloc_string(command);
    734724
    735725    getcwd(dir, MAX_STR_LEN);
    736726    chdir(bkpinfo->restore_path);
    737     sprintf(command, "cp -f /tmp/LAST-FILELIST-NUMBER %s/tmp",
    738             bkpinfo->restore_path);
     727    mr_asprintf(&command, "cp -f /tmp/LAST-FILELIST-NUMBER %s/tmp", bkpinfo->restore_path);
    739728    run_program_and_log_output(command, FALSE);
     729    mr_free(command);
     730
    740731    mvaddstr_and_log_it(g_currentY,
    741732                        0, "Verifying archives against filesystem");
     
    748739    }
    749740    paranoid_free(dir);
    750     paranoid_free(command);
    751741    return (res);
    752742}
  • branches/2.2.10/mondo/src/mondorestore/mondo-rstr-tools.c

    r2287 r2296  
    368368        log_msg(3, "Mommm! SME is being a dildo!");
    369369    } else {
    370         mr_asprintf(&mountpoint, mpt);
     370        mr_asprintf(&mountpoint, "%s", mpt);
    371371    }
    372372
     
    408408        mr_free(command);
    409409
    410         mr_asprintf(&command, "mount -t %s %s %s %s 2>> %s", format, device,
    411                 additional_parameters, mountdir, MONDO_LOGFILE);
     410        mr_asprintf(&command, "mount -t %s %s %s %s 2>> %s", format, device, additional_parameters, mountdir, MONDO_LOGFILE);
    412411        log_msg(2, "command='%s'", command);
    413412    }
     
    418417        log_msg(1, "Re-trying without the fancy extra parameters");
    419418        mr_free(command);
    420         mr_asprintf(&command, "mount -t %s %s %s 2>> %s", format, device,
    421             mountdir, MONDO_LOGFILE);
     419        mr_asprintf(&command, "mount -t %s %s %s 2>> %s", format, device, mountdir, MONDO_LOGFILE);
    422420        res = run_program_and_log_output(command, TRUE);
    423421    }
     
    497495                "Again with the /proc - why is this in your mountlist?");
    498496        } else if (is_this_device_mounted(mountlist->el[lino].device)) {
    499             mr_asprintf(&tmp, "%s is already mounted",
    500                 mountlist->el[lino].device);
     497            mr_asprintf(&tmp, "%s is already mounted", mountlist->el[lino].device);
    501498            log_to_screen(tmp);
    502499            mr_free(tmp);
     
    607604        mr_asprintf(&mount_cmd, "mount_cd9660 -r %s " MNT_CDROM, mddev);
    608605#else
    609         mr_asprintf(&mount_cmd, "mount %s/%s/%s-%d.iso -t iso9660 -o loop,ro %s", bkpinfo->isodir, bkpinfo->nfs_remote_dir,
    610             bkpinfo->prefix, g_current_media_number, MNT_CDROM);
     606        mr_asprintf(&mount_cmd, "mount %s/%s/%s-%d.iso -t iso9660 -o loop,ro %s", bkpinfo->isodir, bkpinfo->nfs_remote_dir, bkpinfo->prefix, g_current_media_number, MNT_CDROM);
    611607#endif
    612608
     
    619615        mr_asprintf(&mount_cmd, "mount_cd9660 -r %s %s", mddev, MNT_CDROM);
    620616#else
    621         mr_asprintf(&mount_cmd, "mount %s/%s-%d.iso -t iso9660 -o loop,ro %s",
    622             bkpinfo->isodir, bkpinfo->prefix, g_current_media_number, MNT_CDROM);
     617        mr_asprintf(&mount_cmd, "mount %s/%s-%d.iso -t iso9660 -o loop,ro %s", bkpinfo->isodir, bkpinfo->prefix, g_current_media_number, MNT_CDROM);
    623618#endif
    624619    } else if (bkpinfo->backup_media_type == usb) {
     
    11011096    unlink(FILELIST_FULL_STUB);
    11021097    if (IS_THIS_A_STREAMING_BACKUP(bkpinfo->backup_media_type)) {
    1103         mr_asprintf(&command, "tar -b %ld -zxf %s ./%s ./%s ./%s ./%s ./%s",
    1104             bkpinfo->internal_tape_block_size,
    1105             bkpinfo->media_device,
    1106             MOUNTLIST_FNAME_STUB,
    1107             BIGGIELIST_TXT_STUB,
    1108             FILELIST_FULL_STUB,
    1109             IWANTMYLVM_STUB,
    1110             MONDO_CFG_FILE_STUB);
     1098        mr_asprintf(&command, "tar -b %ld -zxf %s ./%s ./%s ./%s ./%s ./%s", bkpinfo->internal_tape_block_size, bkpinfo->media_device, MOUNTLIST_FNAME_STUB, BIGGIELIST_TXT_STUB, FILELIST_FULL_STUB, IWANTMYLVM_STUB, MONDO_CFG_FILE_STUB);
    11111099        log_msg(1, "tarcommand = %s", command);
    11121100        run_program_and_log_output(command, 1);
     
    11161104            /* Doing that allow us to remain compatible with pre-2.2.5 versions */
    11171105            log_msg(2, "pre-2.2.4 compatible mode on");
    1118             mr_asprintf(&command,
    1119                 "tar -b %ld -zxf %s %s %s %s %s %s",
    1120                 bkpinfo->internal_tape_block_size,
    1121                 bkpinfo->media_device,
    1122                 MOUNTLIST_FNAME_STUB,
    1123                 BIGGIELIST_TXT_STUB,
    1124                 FILELIST_FULL_STUB,
    1125                 IWANTMYLVM_STUB,
    1126                 MONDO_CFG_FILE_STUB);
     1106            mr_asprintf(&command, "tar -b %ld -zxf %s %s %s %s %s %s", bkpinfo->internal_tape_block_size, bkpinfo->media_device, MOUNTLIST_FNAME_STUB, BIGGIELIST_TXT_STUB, FILELIST_FULL_STUB, IWANTMYLVM_STUB, MONDO_CFG_FILE_STUB);
    11271107            log_msg(1, "tarcommand = %s", command);
    11281108            run_program_and_log_output(command, 1);
     
    11361116        log_msg(2, "Back from iotcn");
    11371117        run_program_and_log_output("mount", 1);
    1138         mr_asprintf(&command,
    1139             "tar -zxf %s/images/all.tar.gz ./%s ./%s ./%s ./%s ./%s",
    1140             MNT_CDROM,
    1141             MOUNTLIST_FNAME_STUB,
    1142             BIGGIELIST_TXT_STUB,
    1143             FILELIST_FULL_STUB,
    1144             IWANTMYLVM_STUB,
    1145             MONDO_CFG_FILE_STUB);
     1118        mr_asprintf(&command, "tar -zxf %s/images/all.tar.gz ./%s ./%s ./%s ./%s ./%s", MNT_CDROM, MOUNTLIST_FNAME_STUB, BIGGIELIST_TXT_STUB, FILELIST_FULL_STUB, IWANTMYLVM_STUB, MONDO_CFG_FILE_STUB);
    11461119
    11471120        log_msg(1, "tarcommand = %s", command);
     
    11521125            /* Doing that allow us to remain compatible with pre-2.2.5 versions */
    11531126            log_msg(2, "pre-2.2.4 compatible mode on");
    1154             mr_asprintf(&command,
    1155                 "tar -zxf %s/images/all.tar.gz %s %s %s %s %s",
    1156                 MNT_CDROM,
    1157                 MOUNTLIST_FNAME_STUB,
    1158                 BIGGIELIST_TXT_STUB,
    1159                 FILELIST_FULL_STUB,
    1160                 IWANTMYLVM_STUB,
    1161                 MONDO_CFG_FILE_STUB);
     1127            mr_asprintf(&command, "tar -zxf %s/images/all.tar.gz %s %s %s %s %s", MNT_CDROM, MOUNTLIST_FNAME_STUB, BIGGIELIST_TXT_STUB, FILELIST_FULL_STUB, IWANTMYLVM_STUB, MONDO_CFG_FILE_STUB);
    11621128
    11631129            log_msg(1, "tarcommand = %s", command);
     
    11951161    &&
    11961162    ask_me_yes_or_no("Do you want to retrieve the mountlist as well?")) {
    1197         mr_asprintf(&command, "ln -sf %s/%s /tmp", MOUNTLIST_FNAME_STUB,
    1198             bkpinfo->tmpdir);
     1163        mr_asprintf(&command, "ln -sf %s/%s /tmp", MOUNTLIST_FNAME_STUB, bkpinfo->tmpdir);
    11991164        paranoid_system(command);
    12001165        mr_free(command);
     
    12251190            mr_free(command);
    12261191        }
    1227         mr_asprintf(&command, "grep -E '^/dev/.*' %s > %s",
    1228                 g_biggielist_txt, g_filelist_imagedevs);
     1192        mr_asprintf(&command, "grep -E '^/dev/.*' %s > %s", g_biggielist_txt, g_filelist_imagedevs);
    12291193        paranoid_system(command);
    12301194        mr_free(command);
     
    20442008                            "Well, I know a certain kitty-kitty who'll be sleeping with Mommy tonight...");
    20452009                } else {
    2046                     mr_asprintf(&command, "umount " MNT_RESTORING "%s",
    2047                             mountlist->el[lino].mountpoint);
     2010                    mr_asprintf(&command, "umount " MNT_RESTORING "%s", mountlist->el[lino].mountpoint);
    20482011
    20492012                    /* To support latest Ubuntu where /var is a separate FS
     
    21122075    }
    21132076
    2114     mr_asprintf(&command,
    2115             "dd if=%s bs=%ld count=%ld 2> /dev/null | tar -zx ./%s ./%s ./%s ./%s ./%s",
    2116             dev,
    2117             bkpinfo->internal_tape_block_size,
    2118             1024L * 1024 * 32 / bkpinfo->internal_tape_block_size,
    2119             MOUNTLIST_FNAME_STUB, MONDO_CFG_FILE_STUB,
    2120             BIGGIELIST_TXT_STUB, FILELIST_FULL_STUB, IWANTMYLVM_STUB);
     2077    mr_asprintf(&command, "dd if=%s bs=%ld count=%ld 2> /dev/null | tar -zx ./%s ./%s ./%s ./%s ./%s", dev, bkpinfo->internal_tape_block_size, 1024L * 1024 * 32 / bkpinfo->internal_tape_block_size, MOUNTLIST_FNAME_STUB, MONDO_CFG_FILE_STUB, BIGGIELIST_TXT_STUB, FILELIST_FULL_STUB, IWANTMYLVM_STUB);
    21212078    log_msg(2, "command = '%s'", command);
    21222079    res = run_program_and_log_output(command, -1);
     
    21292086            /* Doing that allow us to remain compatible with pre-2.2.5 versions */
    21302087            log_msg(2, "pre-2.2.4 compatible mode on");
    2131             mr_asprintf(&command,
    2132                     "dd if=%s bs=%ld count=%ld 2> /dev/null | tar -zx %s %s %s %s %s",
    2133                     dev,
    2134                     bkpinfo->internal_tape_block_size,
    2135                     1024L * 1024 * 32 / bkpinfo->internal_tape_block_size,
    2136                     MOUNTLIST_FNAME_STUB, MONDO_CFG_FILE_STUB,
    2137                     BIGGIELIST_TXT_STUB, FILELIST_FULL_STUB, IWANTMYLVM_STUB);
     2088            mr_asprintf(&command, "dd if=%s bs=%ld count=%ld 2> /dev/null | tar -zx %s %s %s %s %s", dev, bkpinfo->internal_tape_block_size, 1024L * 1024 * 32 / bkpinfo->internal_tape_block_size, MOUNTLIST_FNAME_STUB, MONDO_CFG_FILE_STUB, BIGGIELIST_TXT_STUB, FILELIST_FULL_STUB, IWANTMYLVM_STUB);
    21382089            log_msg(2, "command = '%s'", command);
    21392090            res = run_program_and_log_output(command, -1);
     
    22262177                log_msg(2, "media_device is blank; assuming %s");
    22272178            }
    2228             mr_asprintf(&tmp, bkpinfo->media_device);
     2179            mr_asprintf(&tmp, "%s", bkpinfo->media_device);
    22292180            if (extract_cfg_file_and_mountlist_from_tape_dev
    22302181                (bkpinfo->media_device)) {
     
    23352286            /* Is this code really useful ??? */
    23362287        if (extract_mountlist_stub) {
    2337             mr_asprintf(&command, "cp -f %s %s/%s", MOUNTLIST_FNAME_STUB,
    2338                     bkpinfo->tmpdir, MOUNTLIST_FNAME_STUB);
     2288            mr_asprintf(&command, "cp -f %s %s/%s", MOUNTLIST_FNAME_STUB, bkpinfo->tmpdir, MOUNTLIST_FNAME_STUB);
    23392289            run_program_and_log_output(command, FALSE);
    23402290            mr_free(command);
  • branches/2.2.10/mondo/src/mondorestore/mondorestore.c

    r2291 r2296  
    668668            strcpy(fstab_fname, "/tmp/fstab");
    669669        }
    670         mr_asprintf(&tmp1,
    671                 "label-partitions-as-necessary %s < %s >> %s 2>> %s",
    672                 g_mountlist_fname, fstab_fname, MONDO_LOGFILE,
    673                 MONDO_LOGFILE);
     670        mr_asprintf(&tmp1, "label-partitions-as-necessary %s < %s >> %s 2>> %s", g_mountlist_fname, fstab_fname, MONDO_LOGFILE, MONDO_LOGFILE);
    674671        res = system(tmp1);
    675672        mr_free(tmp1);
     
    811808    }
    812809    if (!evaluate_mountlist(mountlist, tmpA, tmpB, tmpC)) {
    813         mr_asprintf(&tmp,
    814                 "Mountlist analyzed. Result: \"%s %s %s\" Switch to Interactive Mode?",
    815                 tmpA, tmpB, tmpC);
     810        mr_asprintf(&tmp, "Mountlist analyzed. Result: \"%s %s %s\" Switch to Interactive Mode?", tmpA, tmpB, tmpC);
    816811        res = ask_me_yes_or_no(tmp);
    817812        mr_free(tmp);
     
    12931288            }
    12941289            mds = media_descriptor_string(bkpinfo->backup_media_type);
    1295             mr_asprintf(&tmp, "Working on %s #%d, file #%ld, slice #%ld    ", mds,
    1296                     g_current_media_number, bigfileno + 1, sliceno);
     1290            mr_asprintf(&tmp, "Working on %s #%d, file #%ld, slice #%ld    ", mds, g_current_media_number, bigfileno + 1, sliceno);
    12971291            mr_free(mds);
    12981292            log_msg(2, tmp);
     
    13291323    if (use_ntfsprog_hack) {
    13301324        log_msg(3, "Waiting for ntfsclone to finish");
    1331         mr_asprintf(&tmp,
    1332                 " ps | grep \" ntfsclone \" | grep -v grep > /dev/null 2> /dev/null");
     1325        mr_asprintf(&tmp, " ps | grep \" ntfsclone \" | grep -v grep > /dev/null 2> /dev/null");
    13331326        while (system(tmp) == 0) {
    13341327            sleep(1);
     
    14641457        use_ntfsprog_hack = TRUE;
    14651458        log_msg(2, "Calling ntfsclone in background because %s is a /dev entry", outfile_fname);
    1466         mr_asprintf(&sz_devfile, "%s/%d.%d.000",
    1467                 bkpinfo->tmpdir,
    1468                 (int) (random() % 32768),
    1469                 (int) (random() % 32768));
     1459        mr_asprintf(&sz_devfile, "%s/%d.%d.000", bkpinfo->tmpdir, (int) (random() % 32768), (int) (random() % 32768));
    14701460        mkfifo(sz_devfile, 0x770);
    14711461        strcpy(ntfsprog_fifo, sz_devfile);
     
    16841674            log_msg(3, "Saved fileset %ld's subset to %s", current_tarball_number, filelist_subset_fname);
    16851675        }
    1686         mr_asprintf(&screen_message, "Tarball #%ld --- %ld matches",
    1687                 current_tarball_number, matches);
     1676        mr_asprintf(&screen_message, "Tarball #%ld --- %ld matches", current_tarball_number, matches);
    16881677        log_to_screen(screen_message);
    16891678        mr_free(screen_message);
     
    22372226            }
    22382227            g_current_media_number++;
    2239             mr_asprintf(&progress_str, "Restoring from %s #%d",
    2240                     media_descriptor_string(bkpinfo->backup_media_type),
    2241                     g_current_media_number);
     2228            mr_asprintf(&progress_str, "Restoring from %s #%d", media_descriptor_string(bkpinfo->backup_media_type), g_current_media_number);
    22422229            log_to_screen(progress_str);
    22432230        } else {
    2244             mr_asprintf(&progress_str, "Restoring from fileset #%ld on %s #%d",
    2245                     current_tarball_number, mds, g_current_media_number);
     2231            mr_asprintf(&progress_str, "Restoring from fileset #%ld on %s #%d", current_tarball_number, mds, g_current_media_number);
    22462232            for (res = 999, attempts = 0; attempts < 3 && res != 0;
    22472233                 attempts++) {
     
    22512237                                              filelist);
    22522238            }
    2253             mr_asprintf(&tmp1, "%s #%d, fileset #%ld - restore ",
    2254                     mds, g_current_media_number, current_tarball_number);
     2239            mr_asprintf(&tmp1, "%s #%d, fileset #%ld - restore ", mds, g_current_media_number, current_tarball_number);
    22552240            if (res) {
    22562241                mr_strcat(tmp1, "reported errors");
     
    23812366            p++;
    23822367        }
    2383         mr_asprintf(&tmp1, "Restoring big file %ld (%lld K)",
    2384                 current_bigfile_number + 1, biggie_size / 1024);
     2368        mr_asprintf(&tmp1, "Restoring big file %ld (%lld K)", current_bigfile_number + 1, biggie_size / 1024);
    23852369        update_progress_form(tmp1);
    23862370        mr_free(tmp1);
     
    25192503        update_progress_form(progress_str);
    25202504        if (g_getfattr) {
    2521             mr_asprintf(&xattr_fname, "%s/xattr-subset-%ld.tmp", bkpinfo->tmpdir,
    2522                 current_afioball_number);
     2505            mr_asprintf(&xattr_fname, "%s/xattr-subset-%ld.tmp", bkpinfo->tmpdir, current_afioball_number);
    25232506            unlink(xattr_fname);
    25242507        }
Note: See TracChangeset for help on using the changeset viewer.