Changeset 2296


Ignore:
Timestamp:
Jul 23, 2009, 2:53:30 PM (10 years ago)
Author:
bruno
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
Files:
16 edited

Legend:

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

    r2291 r2296  
    350350    paranoid_free(command);
    351351
    352     mr_asprintf(&command, "afio -o -b %ld -M 16m %s %s < %s 2>> %s",
    353             TAPE_BLOCK_SIZE, zipparams, fname, filelist, MONDO_LOGFILE);
     352    mr_asprintf(&command, "afio -o -b %ld -M 16m %s %s < %s 2>> %s", TAPE_BLOCK_SIZE, zipparams, fname, filelist, MONDO_LOGFILE);
    354353    paranoid_free(zipparams);
    355354
     
    867866    log_msg(1, "lines_in_filelist = %ld", lines_in_filelist);
    868867
    869     mr_asprintf(&command,
    870 /*     "mindi --custom 2=%s 3=%s/images 4=\"%s\" 5=\"%s\" \
     868/*     "mindi 1=%s --custom 2=%s 3=%s/images 4=\"%s\" 5=\"%s\" \
    8718696=\"%s\" 7=%ld 8=\"%s\" 9=\"%s\" 10=\"%s\" \
    87287011=\"%s\" 12=%s 13=%ld 14=\"%s\" 15=\"%s\" 16=\"%s\" 17=\"%s\" 18=%ld 19=%d",*/
    873             "mindi %s --custom %s %s/images '%s' '%s' \
     871    mr_asprintf(&command, "mindi %s --custom %s %s/images '%s' '%s' \
    874872'%s' %ld '%s' '%s' '%s' \
    875873'%s' %s %ld '%s' '%s' '%s' '%s' %ld %d '%s'", tmp2, bkpinfo->tmpdir,    // parameter #2
     
    10761074                this_thread_no, archiving_set_no);
    10771075        if (g_getfattr) {
    1078             mr_asprintf(&curr_xattr_list_fname, XATTR_LIST_FNAME_RAW_SZ,
    1079                 bkpinfo->tmpdir, archiving_set_no);
     1076            mr_asprintf(&curr_xattr_list_fname, XATTR_LIST_FNAME_RAW_SZ, bkpinfo->tmpdir, archiving_set_no);
    10801077            get_fattr_list(archiving_filelist_fname, curr_xattr_list_fname);
    10811078            mr_free(curr_xattr_list_fname);
    10821079        }
    10831080        if (g_getfacl) {
    1084             mr_asprintf(&curr_acl_list_fname, ACL_LIST_FNAME_RAW_SZ,
    1085                 bkpinfo->tmpdir, archiving_set_no);
     1081            mr_asprintf(&curr_acl_list_fname, ACL_LIST_FNAME_RAW_SZ, bkpinfo->tmpdir, archiving_set_no);
    10861082            get_acl_list(archiving_filelist_fname, curr_acl_list_fname);
    10871083            mr_free(curr_acl_list_fname);
     
    10971093
    10981094        if (res) {
    1099             mr_asprintf(&tmp,
    1100                     "Errors occurred while archiving set %ld. Please review logs.",
    1101                     archiving_set_no);
     1095            mr_asprintf(&tmp, "Errors occurred while archiving set %ld. Please review logs.", archiving_set_no);
    11021096            log_to_screen(tmp);
    11031097            mr_free(tmp);
     
    14271421            } else {
    14281422                // store set N
    1429                 mr_asprintf(&storing_filelist_fname, FILELIST_FNAME_RAW_SZ,
    1430                         bkpinfo->tmpdir, storing_set_no);
    1431                 mr_asprintf(&storing_afioball_fname, AFIOBALL_FNAME_RAW_SZ,
    1432                         bkpinfo->tmpdir, storing_set_no, bkpinfo->zip_suffix);
     1423                mr_asprintf(&storing_filelist_fname, FILELIST_FNAME_RAW_SZ, bkpinfo->tmpdir, storing_set_no);
     1424                mr_asprintf(&storing_afioball_fname, AFIOBALL_FNAME_RAW_SZ, bkpinfo->tmpdir, storing_set_no, bkpinfo->zip_suffix);
    14331425                if (g_getfattr) {
    1434                     mr_asprintf(&curr_xattr_list_fname, XATTR_LIST_FNAME_RAW_SZ,
    1435                         bkpinfo->tmpdir, storing_set_no);
     1426                    mr_asprintf(&curr_xattr_list_fname, XATTR_LIST_FNAME_RAW_SZ, bkpinfo->tmpdir, storing_set_no);
    14361427                }
    14371428                if (g_getfacl) {
    1438                     mr_asprintf(&curr_acl_list_fname, ACL_LIST_FNAME_RAW_SZ,
    1439                         bkpinfo->tmpdir, storing_set_no);
     1429                    mr_asprintf(&curr_acl_list_fname, ACL_LIST_FNAME_RAW_SZ, bkpinfo->tmpdir, storing_set_no);
    14401430                }
    14411431
     
    14911481                mr_free(media_usage_comment);
    14921482                if (res) {
    1493                     mr_asprintf(&tmp, "Failed to add archive %ld's files to CD dir\n",
    1494                         storing_set_no);
     1483                    mr_asprintf(&tmp, "Failed to add archive %ld's files to CD dir\n", storing_set_no);
    14951484                    log_to_screen(tmp);
    14961485                    paranoid_free(tmp);
     
    17171706
    17181707    if (bkpinfo->call_before_iso[0] != '\0') {
    1719         mr_asprintf(&message_to_screen, "Running pre-ISO call for CD#%d",
    1720                 g_current_media_number);
     1708        mr_asprintf(&message_to_screen, "Running pre-ISO call for CD#%d", g_current_media_number);
    17211709        res =
    17221710            eval_call_to_make_ISO(bkpinfo->call_before_iso,
     
    17631751            retval += res;
    17641752#ifdef DVDRWFORMAT
    1765             mr_asprintf(&tmp,
    1766                     "tail -n8 %s | grep 'blank=full.*dvd-compat.*DAO'",
    1767                     MONDO_LOGFILE);
     1753            mr_asprintf(&tmp, "tail -n8 %s | grep 'blank=full.*dvd-compat.*DAO'", MONDO_LOGFILE);
    17681754            if (g_backup_media_type == dvd
    17691755                && (res || !run_program_and_log_output(tmp, 1))) {
     
    20892075                        "Calling ntfsclone in background because %s is an NTFS partition",
    20902076                        bigfile_fname);
    2091                 mr_asprintf(&sz_devfile, "%s/%d.%d.000", bkpinfo->tmpdir,
    2092                         (int) (random() % 32768),
    2093                         (int) (random() % 32768));
     2077                mr_asprintf(&sz_devfile, "%s/%d.%d.000", bkpinfo->tmpdir, (int) (random() % 32768), (int) (random() % 32768));
    20942078                mkfifo(sz_devfile, 0x770);
    20952079                ntfsprog_fifo = sz_devfile;
     
    27742758            mr_asprintf(&tmp, "cat %s 2> /dev/null", szserfname);
    27752759            mr_free(our_serial_str);
    2776             mr_asprintf(&our_serial_str, "%s",
    2777                    call_program_and_get_last_line_of_output(tmp));
     2760            mr_asprintf(&our_serial_str, "%s", call_program_and_get_last_line_of_output(tmp));
    27782761            mr_free(tmp);
    27792762            // FIXME - should be able to use last_line_of_file(), surely?
     
    28122795        eject_device(cdrom_dev);
    28132796        mds = media_descriptor_string(g_backup_media_type);
    2814         mr_asprintf(&tmp, "I am about to burn %s #%d of the backup set. Please insert %s and press Enter.",
    2815                 mds, g_current_media_number, mds);
     2797        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);
    28162798        mr_free(mds);
    28172799
     
    31143096                mr_asprintf(&tmp, "Problem with slice # %ld", slice_num);
    31153097            } else {
    3116                 mr_asprintf(&tmp, "%s - Bigfile #%ld, slice #%ld compressed OK          ", biggie_filename, biggie_file_number + 1,
    3117                         slice_num);
     3098                mr_asprintf(&tmp, "%s - Bigfile #%ld, slice #%ld compressed OK          ", biggie_filename, biggie_file_number + 1, slice_num);
    31183099            }
    31193100#ifndef _XWIN
     
    33513332    if (space_occupied_by_cd(bkpinfo->scratchdir) / 1024 >
    33523333        bkpinfo->media_size[g_current_media_number]) {
    3353         mr_asprintf(&tmp1,
    3354                 "Warning! CD is too big. It occupies %ld KB, which is more than the %ld KB allowed.",
    3355                 (long) space_occupied_by_cd(bkpinfo->scratchdir),
     3334        mr_asprintf(&tmp1, "Warning! CD is too big. It occupies %ld KB, which is more than the %ld KB allowed.", (long) space_occupied_by_cd(bkpinfo->scratchdir),
    33563335                (long) bkpinfo->media_size[g_current_media_number]);
    33573336        log_to_screen(tmp1);
    33583337        mr_free(tmp1);
    33593338    }
    3360     mr_asprintf(&isofile, "%s/%s/%s-%d.iso", bkpinfo->isodir,
    3361             bkpinfo->nfs_remote_dir, bkpinfo->prefix,
    3362             g_current_media_number);
     3339    mr_asprintf(&isofile, "%s/%s/%s-%d.iso", bkpinfo->isodir, bkpinfo->nfs_remote_dir, bkpinfo->prefix, g_current_media_number);
    33633340    for (that_one_was_ok = FALSE; !that_one_was_ok;) {
    33643341        if (bkpinfo->backup_media_type != usb) {
     
    34213398    }
    34223399    wipe_archives(bkpinfo->scratchdir);
    3423     mr_asprintf(&tmp1, "rm -Rf %s/images/*gz %s/images/*data*img",
    3424             bkpinfo->scratchdir, bkpinfo->scratchdir);
     3400    mr_asprintf(&tmp1, "rm -Rf %s/images/*gz %s/images/*data*img", bkpinfo->scratchdir, bkpinfo->scratchdir);
    34253401    if (system(tmp1)) {
    34263402        log_msg
  • branches/2.2.10/mondo/src/common/libmondo-cli.c

    r2291 r2296  
    901901        }
    902902        flag_set['d'] = TRUE;
    903         mr_asprintf(&tmp1,
    904                 "You didn't specify a tape streamer device. I'm assuming %s",
    905                 flag_val['d']);
     903        mr_asprintf(&tmp1, "You didn't specify a tape streamer device. I'm assuming %s", flag_val['d']);
    906904        log_to_screen(tmp1);
    907905        mr_free(tmp1);
     
    11841182
    11851183    if (flag_set['b']) {
    1186         mr_asprintf(&psz, flag_val['b']);
     1184        mr_asprintf(&psz, "%s", flag_val['b']);
    11871185        log_msg(1, "psz = '%s'", psz);
    11881186        if (psz[strlen(psz) - 1] == 'k') {
     
    12301228            && !does_file_exist(bkpinfo->kernel_path)) {
    12311229            retval++;
    1232             mr_asprintf(&tmp1,
    1233                     "You specified kernel '%s', which does not exist\n",
    1234                     bkpinfo->kernel_path);
     1230            mr_asprintf(&tmp1, "You specified kernel '%s', which does not exist\n", bkpinfo->kernel_path);
    12351231            log_to_screen(tmp1);
    12361232            mr_free(tmp1);
     
    12721268        if (i) {
    12731269            retval++;
    1274             mr_asprintf(&tmp2,
    1275                     "Are you sure directory '%s' exists in remote dir '%s'?\nIf so, do you have rights to write to it?\n",
    1276                     bkpinfo->nfs_remote_dir, bkpinfo->nfs_mount);
     1270            mr_asprintf(&tmp2, "Are you sure directory '%s' exists in remote dir '%s'?\nIf so, do you have rights to write to it?\n", bkpinfo->nfs_remote_dir, bkpinfo->nfs_mount);
    12771271            log_to_screen(tmp2);
    12781272            mr_free(tmp2);
     
    15931587    case SIGKILL:
    15941588        mr_asprintf(&tmp, "SIGKILL");
    1595         mr_asprintf(&tmp2,
    1596                "I seriously have no clue how this signal even got to me. Something's wrong with your system.");
     1589        mr_asprintf(&tmp2, "I seriously have no clue how this signal even got to me. Something's wrong with your system.");
    15971590        break;
    15981591    case SIGTERM:
     
    16061599    case SIGSEGV:
    16071600        mr_asprintf(&tmp, "SIGSEGV");
    1608         mr_asprintf(&tmp2,
    1609                "Internal programming error. Please send a backtrace as well as your log.");
     1601        mr_asprintf(&tmp2, "Internal programming error. Please send a backtrace as well as your log.");
    16101602        break;
    16111603    case SIGPIPE:
  • branches/2.2.10/mondo/src/common/libmondo-devices.c

    r2291 r2296  
    257257        mr_asprintf(&command, "cdcontrol -f %s close", dev);
    258258    } else {
    259         mr_asprintf(&command, "camcontrol load `echo %s | sed 's|/dev/||'`",
    260                 dev);
     259        mr_asprintf(&command, "camcontrol load `echo %s | sed 's|/dev/||'`", dev);
    261260    }
    262261#else
     
    343342#ifdef __FreeBSD__
    344343    // We assume here that this is running from mondorestore. (It is.)
    345     mr_asprintf(&program, "ls %s %s >/dev/null 2>&1", drive,
    346             build_partition_name(tmp, drive, partno));
     344    mr_asprintf(&program, "ls %s %s >/dev/null 2>&1", drive, build_partition_name(tmp, drive, partno));
    347345    res = system(program);
    348346    mr_free(program);
     
    399397    assert_string_is_neither_NULL_nor_zerolength(str);
    400398
    401     mr_asprintf(&command,
    402             "dd if=%s bs=446 count=1 2> /dev/null | strings | grep \"%s\" > /dev/null 2> /dev/null",
    403             dev, str);
     399    mr_asprintf(&command, "dd if=%s bs=446 count=1 2> /dev/null | strings | grep \"%s\" > /dev/null 2> /dev/null", dev, str);
    404400    i = system(command);
    405401    mr_free(command);
     
    425421    int i;
    426422
    427     mr_asprintf(&command,
    428             "dd if=%s bs=512 count=%i 2> /dev/null | strings | grep \"%s\" > /dev/null 2> /dev/null",
    429             dev, n, str);
     423    mr_asprintf(&command, "dd if=%s bs=512 count=%i 2> /dev/null | strings | grep \"%s\" > /dev/null 2> /dev/null", dev, n, str);
    430424    i = system(command);
    431425    mr_free(command);
     
    530524    }
    531525    if (find_home_of_exe(cdr_exe)) {
    532         mr_asprintf(&command,
    533                 "%s -scanbus 2> /dev/null | tr -s '\t' ' ' | grep \"[0-9]*,[0-9]*,[0-9]*\" | grep -v \"[0-9]*) \\*\" | grep CD | cut -d' ' -f2 | head -n1",
    534                 cdr_exe);
     526        mr_asprintf(&command, "%s -scanbus 2> /dev/null | tr -s '\t' ' ' | grep \"[0-9]*,[0-9]*,[0-9]*\" | grep -v \"[0-9]*) \\*\" | grep CD | cut -d' ' -f2 | head -n1", cdr_exe);
    535527        mr_asprintf(&tmp, "%s", call_program_and_get_last_line_of_output(command));
    536528        mr_free(command);
     
    848840    }
    849841
    850     mr_asprintf(&command,
    851             "%s -scanbus | grep \"[0-9],[0-9],[0-9]\" | grep \"[D|C][V|D]\" | grep -n \"\" | grep \"%s\" | cut -d':' -f2",
    852             cdr_exe, g_cdrw_drive_is_here);
     842    mr_asprintf(&command, "%s -scanbus | grep \"[0-9],[0-9],[0-9]\" | grep \"[D|C][V|D]\" | grep -n \"\" | grep \"%s\" | cut -d':' -f2", cdr_exe, g_cdrw_drive_is_here);
    853843    log_msg(1, "command=%s", command);
    854844    mr_asprintf(&tmp1, "%s", call_program_and_get_last_line_of_output(command));
     
    10421032
    10431033#ifdef __FreeBSD__
    1044     mr_asprintf(&command,
    1045             "lsvfs | tr -s '\t' ' ' | grep -v Filesys | grep -v -- -- | cut -d' ' -f1 | tr -s '\n' ' '");
     1034    mr_asprintf(&command, "lsvfs | tr -s '\t' ' ' | grep -v Filesys | grep -v -- -- | cut -d' ' -f1 | tr -s '\n' ' '");
    10461035#else
    1047     mr_asprintf(&command,
    1048             "grep -v nodev /proc/filesystems | tr -s '\t' ' ' | cut -d' ' -f2 | tr -s '\n' ' '");
     1036    mr_asprintf(&command, "grep -v nodev /proc/filesystems | tr -s '\t' ' ' | cut -d' ' -f2 | tr -s '\n' ' '");
    10491037#endif
    10501038
     
    12431231
    12441232#ifdef __FreeBSD__
    1245     mr_asprintf(&command, "mount_vfat %s %s 2>> %s",
    1246             device, mountpoint, MONDO_LOGFILE);
     1233    mr_asprintf(&command, "mount_vfat %s %s 2>> %s", device, mountpoint, MONDO_LOGFILE);
    12471234
    12481235#else
    1249     mr_asprintf(&command, "mount %s -t vfat %s 2>> %s",
    1250             device, mountpoint, MONDO_LOGFILE);
     1236    mr_asprintf(&command, "mount %s -t vfat %s 2>> %s", device, mountpoint, MONDO_LOGFILE);
    12511237#endif
    12521238
     
    13821368        mr_free(tmp);
    13831369
    1384         mr_asprintf(&tmp, "%s/%s/%s-%d.iso", bkpinfo->isodir,
    1385                 bkpinfo->nfs_remote_dir, bkpinfo->prefix,
    1386                 cd_number_i_want);
     1370        mr_asprintf(&tmp, "%s/%s/%s-%d.iso", bkpinfo->isodir, bkpinfo->nfs_remote_dir, bkpinfo->prefix, cd_number_i_want);
    13871371        if (!does_file_exist(tmp)) {
    13881372            mr_free(tmp);
    1389             mr_asprintf(&tmp, "%s/isodir/%s/%s-%d.iso", bkpinfo->tmpdir,
    1390                     bkpinfo->nfs_remote_dir, bkpinfo->prefix,
    1391                     cd_number_i_want);
     1373            mr_asprintf(&tmp, "%s/isodir/%s/%s-%d.iso", bkpinfo->tmpdir, bkpinfo->nfs_remote_dir, bkpinfo->prefix, cd_number_i_want);
    13921374            if (does_file_exist(tmp)) {
    13931375                log_msg(1,
     
    15501532            mr_free(tmp);
    15511533
    1552             mr_asprintf(&comment,
    1553                     "How much data (in Megabytes) will each %s store?", mds);
     1534            mr_asprintf(&comment, "How much data (in Megabytes) will each %s store?", mds);
    15541535            mr_free(mds);
    15551536            if (!popup_and_get_string("Size", comment, sz_size, 5)) {
     
    15881569                log_msg(1, "bkpinfo->media_device = %s",
    15891570                        bkpinfo->media_device);
    1590                 mr_asprintf(&comment,
    1591                         "Please specify your %s drive's /dev entry", mds);
     1571                mr_asprintf(&comment, "Please specify your %s drive's /dev entry", mds);
    15921572                if (!popup_and_get_string
    15931573                    ("Device?", comment, bkpinfo->media_device,
     
    17611741
    17621742            if (!bkpinfo->restore_data) {
    1763                 mr_asprintf(&comment,
    1764                     "How much data (in Megabytes) will each media store?");
     1743                mr_asprintf(&comment, "How much data (in Megabytes) will each media store?");
    17651744                if (!popup_and_get_string("Size", comment, sz_size, 5)) {
    17661745                    mr_free(comment);
  • branches/2.2.10/mondo/src/common/libmondo-fifo.c

    r2291 r2296  
    8888    for (bufsize = wise_upper_limit, res = -1;
    8989         res != 0 && bufsize >= wise_lower_limit; bufsize--) {
    90         mr_asprintf(&tmp,
    91                 "dd if=/dev/zero bs=1024 count=16k 2> /dev/null | buffer -o /dev/null -s %ld -m %d%c",
    92                 internal_tape_block_size, bufsize, 'm');
     90        mr_asprintf(&tmp, "dd if=/dev/zero bs=1024 count=16k 2> /dev/null | buffer -o /dev/null -s %ld -m %d%c", internal_tape_block_size, bufsize, 'm');
    9391        res = run_program_and_log_output(tmp, 2);
    9492        mr_free(tmp);
  • branches/2.2.10/mondo/src/common/libmondo-filelist.c

    r2291 r2296  
    500500        mr_free(command);
    501501
    502         mr_asprintf(&command,
    503                 "getfacl --all-effective -P %s 2>> %s | gzip -c1 > %s 2>> %s",
    504                 filelist, MONDO_LOGFILE, facl_fname, MONDO_LOGFILE);
     502        mr_asprintf(&command, "getfacl --all-effective -P %s 2>> %s | gzip -c1 > %s 2>> %s", filelist, MONDO_LOGFILE, facl_fname, MONDO_LOGFILE);
    505503        log_it("%s",command);
    506504        retval = system(command);
  • branches/2.2.10/mondo/src/common/libmondo-files.c

    r2289 r2296  
    7171        mr_free(command);
    7272    } else {
    73         mr_asprintf(&tmp, "File '%s' not found; cannot calc checksum",
    74                 filename);
     73        mr_asprintf(&tmp, "File '%s' not found; cannot calc checksum", filename);
    7574        log_it(tmp);
    7675        mr_free(tmp);
     
    143142    assert_string_is_neither_NULL_nor_zerolength(filename);
    144143    if (!does_file_exist(filename)) {
    145         mr_asprintf(&tmp,
    146                 "%s does not exist, so I cannot found the number of lines in it",
    147                 filename);
     144        mr_asprintf(&tmp, "%s does not exist, so I cannot found the number of lines in it", filename);
    148145        log_it(tmp);
    149146        mr_free(tmp);
     
    358355            return (NULL);      // forget it :)
    359356        }
    360         mr_asprintf(&command,
    361                 "file %s 2> /dev/null | cut -d':' -f1 2> /dev/null",
    362                 incoming);
     357        mr_asprintf(&command, "file %s 2> /dev/null | cut -d':' -f1 2> /dev/null", incoming);
    363358        strcpy(incoming,
    364359               call_program_and_get_last_line_of_output(command));
     
    459454         && !strstr(err_log_lines[i], "% done"); i--);
    460455    if (i < 0) {
    461         mr_asprintf(&command,
    462                 "tail -n3 %s | grep -Fi \"%c\" | tail -n1 | awk '{print $0;}'",
    463                 filename, '%');
     456        mr_asprintf(&command, "tail -n3 %s | grep -Fi \"%c\" | tail -n1 | awk '{print $0;}'", filename, '%');
    464457        strcpy(lastline,
    465458               call_program_and_get_last_line_of_output(command));
     
    512505
    513506    if (!does_file_exist(filename)) {
    514         mr_asprintf(&tmp, "Tring to get last line of nonexistent file (%s)",
    515                 filename);
     507        mr_asprintf(&tmp, "Tring to get last line of nonexistent file (%s)", filename);
    516508        log_it(tmp);
    517509        mr_free(tmp);
     
    630622                time_remaining =
    631623                    time_taken * 100 / (long) (percentage) - time_taken;
    632                 mr_asprintf(&tmp,
    633                         "%02d%% done   %02d:%02d taken   %02d:%02d remaining  %-37s\r",
    634                         percentage, (int) (time_taken / 60),
    635                         (int) (time_taken % 60),
    636                         (int) (time_remaining / 60),
    637                         (int) (time_remaining % 60), curr_fname);
     624                mr_asprintf(&tmp, "%02d%% done   %02d:%02d taken   %02d:%02d remaining  %-37s\r", percentage, (int) (time_taken / 60), (int) (time_taken % 60), (int) (time_remaining / 60), (int) (time_remaining % 60), curr_fname);
    638625                log_to_screen(tmp);
    639626                mr_free(tmp);
     
    758745
    759746    mr_asprintf(&mountlist, "%s/mountlist.txt", tmpdir);
    760     mr_asprintf(&command,
    761             "grep \"%s \" %s/mountlist.txt | head -n1 | awk '{print $4}'",
    762             dev, tmpdir);
     747    mr_asprintf(&command, "grep \"%s \" %s/mountlist.txt | head -n1 | awk '{print $4}'", dev, tmpdir);
    763748    mr_free(mountlist);
    764749
     
    837822                log_msg(4, "%s --> %ld K", fname, file_len_K);
    838823            }
    839             mr_asprintf(&comment,
    840                     "After adding %s, scratchL+%ld now equals %ld", fname,
    841                     file_len_K, scratchL);
     824            mr_asprintf(&comment, "After adding %s, scratchL+%ld now equals %ld", fname, file_len_K, scratchL);
    842825            log_msg(4, comment);
    843826            mr_free(comment);
     
    10601043        find_and_store_mondoarchives_home(g_mondo_home);
    10611044    }
    1062     mr_asprintf(&command, CP_BIN " --parents -pRdf %s %s", g_mondo_home,
    1063             bkpinfo->scratchdir);
     1045    mr_asprintf(&command, CP_BIN " --parents -pRdf %s %s", g_mondo_home, bkpinfo->scratchdir);
    10641046
    10651047    log_msg(4, "command = %s", command);
     
    10711053    }
    10721054
    1073     mr_asprintf(&command, "cp -f %s/LAST-FILELIST-NUMBER %s", bkpinfo->tmpdir,
    1074             bkpinfo->scratchdir);
     1055    mr_asprintf(&command, "cp -f %s/LAST-FILELIST-NUMBER %s", bkpinfo->tmpdir, bkpinfo->scratchdir);
    10751056    res = run_program_and_log_output(command, FALSE);
    10761057    mr_free(command);
     
    10991080
    11001081    if (bkpinfo->postnuke_tarball[0]) {
    1101         mr_asprintf(&command, "cp -f %s %s/post-nuke.tgz",
    1102                 bkpinfo->postnuke_tarball, bkpinfo->tmpdir);
     1082        mr_asprintf(&command, "cp -f %s %s/post-nuke.tgz", bkpinfo->postnuke_tarball, bkpinfo->tmpdir);
    11031083        res = run_program_and_log_output(command, FALSE);
    11041084        mr_free(command);
     
    11501130    }
    11511131    *(p++) = '\0';
    1152     mr_asprintf(&nfs_server_ipaddr, tmp);
    1153     mr_asprintf(&nfs_mount, p);
     1132    mr_asprintf(&nfs_server_ipaddr, "%s", tmp);
     1133    mr_asprintf(&nfs_mount, "%s", p);
    11541134    mr_free(tmp);
    11551135
    11561136    /* BERLIOS : there is a bug #67 here as it only considers the first NIC */
    1157     mr_asprintf(&command,
    1158             "ifconfig | tr '\n' '#' | sed s/##// | tr '#' ' ' | tr '' '\n' | head -n1 | cut -d' ' -f1");
     1137    mr_asprintf(&command, "ifconfig | tr '\n' '#' | sed s/##// | tr '#' ' ' | tr '' '\n' | head -n1 | cut -d' ' -f1");
    11591138    mr_asprintf(&nfs_dev, "%s", call_program_and_get_last_line_of_output(command));
    11601139    mr_free(command);
    11611140
    1162     mr_asprintf(&command,
    1163             "%s", "ifconfig | tr '\n' '#' | sed s/##// | tr '#' ' ' | tr '' '\\n' | head -n1 | tr -s '\t' ' ' | cut -d' ' -f7 | cut -d':' -f2");
     1141    mr_asprintf(&command, "%s", "ifconfig | tr '\n' '#' | sed s/##// | tr '#' ' ' | tr '' '\\n' | head -n1 | tr -s '\t' ' ' | cut -d' ' -f7 | cut -d':' -f2");
    11641142    mr_asprintf(&nfs_client_ipaddr, "%s", call_program_and_get_last_line_of_output(command));
    11651143    mr_free(command);
    11661144
    1167     mr_asprintf(&command,
    1168             "%s", "ifconfig | tr '\n' '#' | sed s/##// | tr '#' ' ' | tr '' '\\n' | head -n1 | tr -s '\t' ' ' | cut -d' ' -f9 | cut -d':' -f2");
     1145    mr_asprintf(&command, "%s", "ifconfig | tr '\n' '#' | sed s/##// | tr '#' ' ' | tr '' '\\n' | head -n1 | tr -s '\t' ' ' | cut -d' ' -f9 | cut -d':' -f2");
    11691146    mr_asprintf(&nfs_client_netmask, "%s", call_program_and_get_last_line_of_output(command));
    11701147    mr_free(command);
    11711148
    1172     mr_asprintf(&command,
    1173             "%s", "ifconfig | tr '\n' '#' | sed s/##// | tr '#' ' ' | tr '' '\\n' | head -n1 | tr -s '\t' ' ' | cut -d' ' -f8 | cut -d':' -f2");
     1149    mr_asprintf(&command, "%s", "ifconfig | tr '\n' '#' | sed s/##// | tr '#' ' ' | tr '' '\\n' | head -n1 | tr -s '\t' ' ' | cut -d' ' -f8 | cut -d':' -f2");
    11741150    mr_asprintf(&nfs_client_broadcast, "%s", call_program_and_get_last_line_of_output(command));
    11751151    mr_free(command);
    11761152
    1177     mr_asprintf(&command,
    1178             "%s", "route -n | grep '^0.0.0.0' | awk '{print $2}'");
     1153    mr_asprintf(&command, "%s", "route -n | grep '^0.0.0.0' | awk '{print $2}'");
    11791154    mr_asprintf(&nfs_client_defgw, "%s", call_program_and_get_last_line_of_output(command));
    11801155    mr_free(command);
     
    11951170    if (!strncmp(nfs_dev, "bond", 4) || !strncmp(nfs_dev, "alb", 3) || !strncmp(nfs_dev, "aft", 3)) {
    11961171        log_to_screen("Found bonding device %s; looking for corresponding ethN slave device\n", nfs_dev);
    1197         mr_asprintf(&command,
    1198                 "%s", "ifconfig %s | awk '{print $5}' | head -n1", nfs_dev);
     1172        mr_asprintf(&command, "%s", "ifconfig %s | awk '{print $5}' | head -n1", nfs_dev);
    11991173        mr_asprintf(&mac_addr, "%s", call_program_and_get_last_line_of_output(command));
    12001174        mr_free(command);
     
    12041178        mr_free(nfs_dev);
    12051179
    1206         mr_asprintf(&nfs_dev, call_program_and_get_last_line_of_output(command));
     1180        mr_asprintf(&nfs_dev, "%s", call_program_and_get_last_line_of_output(command));
    12071181        mr_free(command);
    12081182
     
    13131287        mr_free(mds);
    13141288    } else if (scratchLL > 4) {
    1315         mr_asprintf(&tmp,
    1316                 "Your backup will occupy one meeeeellion media! (maybe %s)",
    1317                 number_to_text((int) (scratchLL + 1)));
     1289        mr_asprintf(&tmp, "Your backup will occupy one meeeeellion media! (maybe %s)", number_to_text((int) (scratchLL + 1)));
    13181290    } else {
    1319         mr_asprintf(&tmp, "Your backup will occupy approximately %s media.",
    1320                 number_to_text((int) (scratchLL + 1)));
     1291        mr_asprintf(&tmp, "Your backup will occupy approximately %s media.", number_to_text((int) (scratchLL + 1)));
    13211292    }
    13221293    if (!bkpinfo->image_devs[0] && (scratchLL < 50)) {
  • branches/2.2.10/mondo/src/common/libmondo-fork.c

    r2275 r2296  
    283283        log_if_failure = TRUE;
    284284    }
    285     mr_asprintf(&callstr, "%s > %s/mondo-run-prog-thing.tmp 2> %s/mondo-run-prog-thing.err",
    286              program, bkpinfo->tmpdir, bkpinfo->tmpdir);
     285    mr_asprintf(&callstr, "%s > %s/mondo-run-prog-thing.tmp 2> %s/mondo-run-prog-thing.err", program, bkpinfo->tmpdir, bkpinfo->tmpdir);
    287286    while ((p = strchr(callstr, '\r'))) {
    288287        *p = ' ';
     
    390389    mr_asprintf(&lockfile, "%s/mojo-jojo.bla.bla", bkpinfo->tmpdir);
    391390
    392     mr_asprintf(&command,
    393             "echo hi > %s ; %s >> %s 2>> %s; res=$?; sleep 1; rm -f %s; exit $res",
    394             lockfile, basic_call, MONDO_LOGFILE, MONDO_LOGFILE, lockfile);
     391    mr_asprintf(&command, "echo hi > %s ; %s >> %s 2>> %s; res=$?; sleep 1; rm -f %s; exit $res", lockfile, basic_call, MONDO_LOGFILE, MONDO_LOGFILE, lockfile);
    395392    open_evalcall_form(what_i_am_doing);
    396393    mr_asprintf(&tmp, "Executing %s", basic_call);
  • branches/2.2.10/mondo/src/common/libmondo-stream.c

    r2266 r2296  
    273273        strcpy(cdr_exe, "dvdrecord");
    274274    }
    275     mr_asprintf(&command, "%s -scanbus 2> /dev/null | grep -i tape | wc -l",
    276             cdr_exe);
     275    mr_asprintf(&command, "%s -scanbus 2> /dev/null | grep -i tape | wc -l", cdr_exe);
    277276    strcpy(tmp, call_program_and_get_last_line_of_output(command));
    278277    mr_free(command);
     
    284283        return 1;
    285284    }
    286     mr_asprintf(&command,
    287             "%s -scanbus 2> /dev/null | tr -s '\t' ' ' | grep \"[0-9]*,[0-9]*,[0-9]*\" | grep -v \"[0-9]*) \\*\" | grep -i TAPE | cut -d' ' -f2 | head -n1",
    288             cdr_exe);
     285    mr_asprintf(&command, "%s -scanbus 2> /dev/null | tr -s '\t' ' ' | grep \"[0-9]*,[0-9]*,[0-9]*\" | grep -v \"[0-9]*) \\*\" | grep -i TAPE | cut -d' ' -f2 | head -n1", cdr_exe);
    289286    strcpy(tmp, call_program_and_get_last_line_of_output(command));
    290287    mr_free(command);
     
    294291        return 1;
    295292    }
    296     mr_asprintf(&command,
    297             "%s -scanbus 2> /dev/null | tr -s '\t' ' ' | grep \"[0-9]*,[0-9]*,[0-9]*\" | grep -v \"[0-9]*) \\*\" | grep -i TAPE | cut -d' ' -f3 | cut -d')' -f1 | head -n1",
    298             cdr_exe);
     293    mr_asprintf(&command, "%s -scanbus 2> /dev/null | tr -s '\t' ' ' | grep \"[0-9]*,[0-9]*,[0-9]*\" | grep -v \"[0-9]*) \\*\" | grep -i TAPE | cut -d' ' -f3 | cut -d')' -f1 | head -n1", cdr_exe);
    299294    strcpy(tmp, call_program_and_get_last_line_of_output(command));
    300295    mr_free(command);
     
    475470    log_it("Insisting on tape #%d", tapeno);
    476471    if (g_current_media_number != tapeno) {
    477         mr_asprintf(&tmp,
    478                 "When the tape drive goes quiet, please insert volume %d in this series.",
    479                 tapeno);
     472        mr_asprintf(&tmp, "When the tape drive goes quiet, please insert volume %d in this series.", tapeno);
    480473        popup_and_OK(tmp);
    481474        mr_free(tmp);
     
    869862    (void) getcwd(old_cwd, MAX_STR_LEN);
    870863    chdir(bkpinfo->tmpdir);
    871     mr_asprintf(&tmp, "tar -zxf %s ./tmp/mondo-restore.cfg 2> /dev/null",
    872             outfname);
     864    mr_asprintf(&tmp, "tar -zxf %s ./tmp/mondo-restore.cfg 2> /dev/null", outfname);
    873865    paranoid_system(tmp);
    874866    mr_free(tmp);
     
    11431135    }
    11441136    if (strcmp(temp_cksum, actual_cksum)) {
    1145         mr_asprintf(&tmp, "actual cksum=%s; recorded cksum=%s", actual_cksum,
    1146                 temp_cksum);
     1137        mr_asprintf(&tmp, "actual cksum=%s; recorded cksum=%s", actual_cksum, temp_cksum);
    11471138        log_to_screen(tmp);
    11481139        mr_free(tmp);
    11491140
    1150         mr_asprintf(&tmp, "%s (%ld K) is corrupt on tape", temp_fname,
    1151                 (long) orig_size >> 10);
     1141        mr_asprintf(&tmp, "%s (%ld K) is corrupt on tape", temp_fname, (long) orig_size >> 10);
    11521142        log_to_screen(tmp);
    11531143        mr_free(tmp);
     
    15001490    }
    15011491    if (bkpinfo->backup_media_type == cdstream) {
    1502         mr_asprintf(&command,
    1503                 "cdrecord -eject dev=%s speed=%d fs=24m -waiti - >> %s 2>> %s",
    1504                 bkpinfo->media_device, bkpinfo->cdrw_speed, MONDO_LOGFILE,
    1505                 MONDO_LOGFILE);
     1492        mr_asprintf(&command, "cdrecord -eject dev=%s speed=%d fs=24m -waiti - >> %s 2>> %s", bkpinfo->media_device, bkpinfo->cdrw_speed, MONDO_LOGFILE, MONDO_LOGFILE);
    15061493        log_it("Opening OUT to next CD with the command");
    15071494        log_it(command);
     
    17061693        p++;
    17071694    }
    1708     mr_asprintf(&tmp, "Writing file '%s' to tape (%ld KB)", p,
    1709             (long) filesize >> 10);
     1695    mr_asprintf(&tmp, "Writing file '%s' to tape (%ld KB)", p, (long) filesize >> 10);
    17101696    log_it(tmp);
    17111697    mr_free(tmp);
     
    18121798        fwrite(tempblock, 1, (size_t) TAPE_BLOCK_SIZE,
    18131799               g_tape_stream) / 1024;
    1814     mr_asprintf(&tmp, "%s (fname=%s, size=%ld K)",
    1815             marker_to_string(control_char), p,
    1816             (long) length_of_incoming_file >> 10);
     1800    mr_asprintf(&tmp, "%s (fname=%s, size=%ld K)", marker_to_string(control_char), p, (long) length_of_incoming_file >> 10);
    18171801    log_msg(6, tmp);
    18181802    mr_free(tmp);
  • branches/2.2.10/mondo/src/common/libmondo-tools.c

    r2291 r2296  
    610610
    611611        log_it("isodir = %s", bkpinfo->isodir);
    612         mr_asprintf(&command, "df -P %s | tail -n1 | cut -d' ' -f1",
    613                 bkpinfo->isodir);
     612        mr_asprintf(&command, "df -P %s | tail -n1 | cut -d' ' -f1", bkpinfo->isodir);
    614613        log_it("command = %s", command);
    615614        log_it("res of it = %s", call_program_and_get_last_line_of_output(command));
     
    911910            ("ln -sf `which mkfs.msdos` /sbin/mkfs.vfat", FALSE);
    912911    }
    913     mr_asprintf(&tmp, "%s",
    914            call_program_and_get_last_line_of_output
    915            ("free | grep Mem | head -n1 | tr -s ' ' '\t' | cut -f2"));
     912    mr_asprintf(&tmp, "%s", call_program_and_get_last_line_of_output("free | grep Mem | head -n1 | tr -s ' ' '\t' | cut -f2"));
    916913    if (atol(tmp) < 35000) {
    917914        retval++;
     
    984981    run_program_and_log_output
    985982        ("umount `mount | grep cdr | cut -d' ' -f3 | tr '\n' ' '`", 5);
    986     mr_asprintf(&tmp, "%s",
    987            call_program_and_get_last_line_of_output
    988            ("mount | grep -E \"cdr(om|w)\""));
     983    mr_asprintf(&tmp, "%s", call_program_and_get_last_line_of_output("mount | grep -E \"cdr(om|w)\""));
    989984    if (strcmp("", tmp)) {
    990985        if (strstr(tmp, "autofs")) {
     
    10671062    assert_string_is_neither_NULL_nor_zerolength(label);
    10681063    if (!does_file_exist(config_file)) {
    1069         mr_asprintf(&tmp, "(read_cfg_var) Cannot find %s config file",
    1070                 config_file);
     1064        mr_asprintf(&tmp, "(read_cfg_var) Cannot find %s config file", config_file);
    10711065        log_to_screen(tmp);
    10721066        mr_free(tmp);
     
    10781072        return (0);
    10791073    } else {
    1080         mr_asprintf(&command, "grep '%s .*' %s| cut -d' ' -f2,3,4,5",
    1081                 label, config_file);
     1074        mr_asprintf(&command, "grep '%s .*' %s| cut -d' ' -f2,3,4,5", label, config_file);
    10821075        strcpy(value, call_program_and_get_last_line_of_output(command));
    10831076        mr_free(command);
     
    12071200    g_boot_mountpt[0] = '\0';
    12081201    log_msg(4, "Done. Great. Seeting command to something");
    1209     mr_asprintf(&command, "%s",
    1210            "grep -v \":\" /etc/fstab | grep -vE '^#.*$' | grep -E \"[   ]/boot[     ]\" | tr -s ' ' '\t' | cut -f1 | head -n1");
     1202    mr_asprintf(&command, "grep -v \":\" /etc/fstab | grep -vE '^#.*$' | grep -E \"[    ]/boot[     ]\" | tr -s ' ' '\t' | cut -f1 | head -n1");
    12111203    log_msg(4, "Cool. Command = '%s'", command);
    12121204    mr_asprintf(&tmp, "%s", call_program_and_get_last_line_of_output(command));
     
    12181210        mr_asprintf(&command, "mount | grep -Ew '/boot'");
    12191211        mr_free(tmp);
    1220         mr_asprintf(&tmp, call_program_and_get_last_line_of_output(command));
     1212        mr_asprintf(&tmp, "%s", call_program_and_get_last_line_of_output(command));
    12211213        mr_free(command);
    12221214
     
    12351227                    strcpy(g_boot_mountpt, tmp);
    12361228                    mr_free(tmp);
    1237                     mr_asprintf(&tmp,
    1238                             "%s (your /boot partition) is not mounted. I'll mount it before backing up",
    1239                             g_boot_mountpt);
     1229                    mr_asprintf(&tmp, "%s (your /boot partition) is not mounted. I'll mount it before backing up", g_boot_mountpt);
    12401230                    log_it(tmp);
    12411231                    mr_free(tmp);
     
    13041294    assert(value != NULL);
    13051295    if (!does_file_exist(config_file)) {
    1306         mr_asprintf(&tmp, "(write_cfg_file) Cannot find %s config file",
    1307                 config_file);
     1296        mr_asprintf(&tmp, "(write_cfg_file) Cannot find %s config file", config_file);
    13081297        log_to_screen(tmp);
    13091298        mr_free(tmp);
     
    13121301    mr_asprintf(&tempfile, "%s/mojo-jojo.blah", bkpinfo->tmpdir);
    13131302    if (does_file_exist(config_file)) {
    1314         mr_asprintf(&command, "grep -vE '^%s .*$' %s > %s",
    1315                 label, config_file, tempfile);
     1303        mr_asprintf(&command, "grep -vE '^%s .*$' %s > %s", label, config_file, tempfile);
    13161304        paranoid_system(command);
    13171305        mr_free(command);
  • branches/2.2.10/mondo/src/common/libmondo-verify.c

    r2276 r2296  
    107107
    108108    log_msg(1, "Now scanning log file for 'star: ' stuff");
    109     mr_asprintf(&command,
    110             "grep \"star: \" %s | sed 's/star: //' | grep -vE '^/dev/.*$' >> %s",
    111             stderr_fname, afio_found_changes);
     109    mr_asprintf(&command, "grep \"star: \" %s | sed 's/star: //' | grep -vE '^/dev/.*$' >> %s", stderr_fname, afio_found_changes);
    112110    log_msg(2, command);
    113111    res = system(command);
     
    118116    }
    119117    afio_diffs = count_lines_in_file(afio_found_changes);
    120     mr_asprintf(&command,
    121             "sort %s %s %s | uniq -c | awk '{ if ($1==\"2\") {print $2;};}' | grep -v \"incheckentry xwait()\" > %s",
    122             ignorefiles_fname, afio_found_changes, afio_found_changes,
    123             changedfiles_fname);
     118    mr_asprintf(&command, "sort %s %s %s | uniq -c | awk '{ if ($1==\"2\") {print $2;};}' | grep -v \"incheckentry xwait()\" > %s", ignorefiles_fname, afio_found_changes, afio_found_changes, changedfiles_fname);
    124119    mr_free(afio_found_changes);
    125120    log_msg(2, command);
     
    172167        } else {
    173168            retval++;
    174             mr_asprintf(&tmp, "Warning - missing set(s) between %d and %d\n",
    175                     g_last_afioball_number, set_number - 1);
     169            mr_asprintf(&tmp, "Warning - missing set(s) between %d and %d\n", g_last_afioball_number, set_number - 1);
    176170            log_to_screen(tmp);
    177171            mr_free(tmp);
     
    342336                    g_current_media_number, bigfile_num, slice_num);
    343337            if (!does_file_exist(slice_fname(bigfile_num, slice_num, mountpoint, ""))) {
    344                 mr_asprintf(&command, "%s -dc %s 2>> %s",
    345                         sz_exe,
    346                         slice_fname(bigfile_num, slice_num, mountpoint, bkpinfo->zip_suffix),
    347                         MONDO_LOGFILE);
     338                mr_asprintf(&command, "%s -dc %s 2>> %s", sz_exe, slice_fname(bigfile_num, slice_num, mountpoint, bkpinfo->zip_suffix), MONDO_LOGFILE);
    348339            } else {
    349340                mr_asprintf(&command, "cat %s 2>> %s", slice_fname(bigfile_num, slice_num, mountpoint, ""), MONDO_LOGFILE);
     
    474465        bkpinfo->use_star = TRUE;
    475466        if (strstr(tarball_fname, ".bz2"))
    476             mr_asprintf(&command,
    477                     "star -diff diffopts=mode,size,data file=%s %s >> %s 2>> %s",
    478                     tarball_fname,
    479                     (strstr(tarball_fname, ".bz2")) ? "-bz" : " ", outlog,
    480                     outlog);
     467            mr_asprintf(&command, "star -diff diffopts=mode,size,data file=%s -bz >> %s 2>> %s", tarball_fname, outlog, outlog);
    481468    } else {
    482469        bkpinfo->use_star = FALSE;
    483         mr_asprintf(&command, "afio -r -P %s -Z %s >> %s 2>> %s",
    484                 bkpinfo->zip_exe, tarball_fname, outlog, outlog);
     470        mr_asprintf(&command, "afio -r -P %s -Z %s >> %s 2>> %s", bkpinfo->zip_exe, tarball_fname, outlog, outlog);
    485471    }
    486472    log_msg(6, "command=%s", command);
     
    491477        mr_asprintf(&command, "cat %s >> %s", outlog, MONDO_LOGFILE);
    492478    } else {
    493         mr_asprintf(&command, "cut -d: -f%d %s | sort -u",
    494                 (bkpinfo->use_star) ? 1 : 2, outlog);
     479        mr_asprintf(&command, "cut -d: -f%d %s | sort -u", (bkpinfo->use_star) ? 1 : 2, outlog);
    495480        pin = popen(command, "r");
    496481        if (pin) {
     
    794779        res = verify_an_afioball_from_stream(fname, size);
    795780        if (res) {
    796             mr_asprintf(&tmp, "Afioball %ld differs from live filesystem",
    797                     current_afioball_number);
     781            mr_asprintf(&tmp, "Afioball %ld differs from live filesystem", current_afioball_number);
    798782            log_to_screen(tmp);
    799783            mr_free(tmp);
     
    897881            p++;
    898882        }
    899         mr_asprintf(&comment, "Verifying bigfile #%ld (%ld K)",
    900                 current_biggiefile_number, (long) size >> 10);
     883        mr_asprintf(&comment, "Verifying bigfile #%ld (%ld K)", current_biggiefile_number, (long) size >> 10);
    901884        update_progress_form(comment);
    902885        mr_free(comment);
     
    12081191    diffs = count_lines_in_file(changed_files_fname);
    12091192    if (diffs > 0) {
    1210         mr_asprintf(&tmp, "cp -f %s %s/changed.files", changed_files_fname,
    1211                 MONDO_CACHE);
     1193        mr_asprintf(&tmp, "cp -f %s %s/changed.files", changed_files_fname, MONDO_CACHE);
    12121194        run_program_and_log_output(tmp, FALSE);
    12131195        mr_free(tmp);
  • branches/2.2.10/mondo/src/common/newt-specific.c

    r2291 r2296  
    10261026            || percentage > g_isoform_old_progress) {
    10271027            g_isoform_old_progress = percentage;
    1028             mr_asprintf(&timeline_str, "%2ld:%02ld taken            %2ld:%02ld remaining", (long) time_taken / 60, (long) time_taken % 60,
    1029                             (long) time_remaining / 60, (long) time_remaining % 60);
     1028            mr_asprintf(&timeline_str, "%2ld:%02ld taken            %2ld:%02ld remaining", (long) time_taken / 60, (long) time_taken % 60, (long) time_remaining / 60, (long) time_remaining % 60);
    10301029            if (percentage < 3) {
    10311030                mr_asprintf(&pcline_str, " Working");
     
    10381037                mr_strcat(pcline_str, " %c", special_dot_char(g_mysterious_dot_counter));
    10391038            } else {
    1040                 mr_asprintf(&pcline_str, " %3d%% done              %3d%% to go",
    1041                         percentage, 100 - percentage);
     1039                mr_asprintf(&pcline_str, " %3d%% done              %3d%% to go", percentage, 100 - percentage);
    10421040            }
    10431041            if (g_text_mode) {
     
    11431141        } else {
    11441142            if (g_current_progress > g_maximum_progress) {
    1145                 mr_asprintf(&tmp,
    1146                         "update_progress_form_full(%s,%s,%s) --- g_current_progress=%ld; g_maximum_progress=%ld",
    1147                         blurb1, blurb2, blurb3, g_current_progress,
    1148                         g_maximum_progress);
    1149                 log_msg(0, tmp);
    1150                 mr_free(tmp);
     1143                log_msg(0, "update_progress_form_full(%s,%s,%s) --- g_current_progress=%ld; g_maximum_progress=%ld", blurb1, blurb2, blurb3, g_current_progress, g_maximum_progress);
    11511144                g_current_progress = g_maximum_progress;
    11521145            }
     
    11851178            paranoid_free(taskprogress);
    11861179        } else {
    1187             mr_asprintf(&timeline_str, "%2ld:%02ld taken               %2ld:%02ld remaining  ",
    1188                 (long) time_taken / 60, (long) time_taken % 60, (long) time_remaining / 60, (long) time_remaining % 60);
     1180            mr_asprintf(&timeline_str, "%2ld:%02ld taken               %2ld:%02ld remaining  ", (long) time_taken / 60, (long) time_taken % 60, (long) time_remaining / 60, (long) time_remaining % 60);
    11891181            mr_asprintf(percentline_str, " %3d%% done                 %3d%% to go", percentage, 100 - percentage);
    11901182
     
    16081600                                   keylist[i]);
    16091601        }
    1610         mr_asprintf(&differ_sz,
    1611                 "  %ld files differ. Hit 'Select' to pick a file. Hit 'Close' to quit the list.",
    1612                 i);
     1602        mr_asprintf(&differ_sz, "  %ld files differ. Hit 'Select' to pick a file. Hit 'Close' to quit the list.", i);
    16131603        newtPushHelpLine(differ_sz);
    16141604        mr_free(differ_sz);
  • 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        }
  • branches/2.2.10/tools/quality

    r2267 r2296  
    2828
    2929# How many sprintf/strcat/strcpy vs asprintf are they
    30 for s in asprintf mr_asprintf sprintf snprintf strcat strcpy strncpy fgets malloc mr_malloc malloc_string getline mr_getline MAX_STR_LEN getcwd goto free mr_free paranoid_free; do
     30for s in asprintf mr_asprintf sprintf snprintf strcat strcpy strncpy fgets malloc mr_malloc malloc_string getline mr_getline MAX_STR_LEN getcwd goto free mr_free paranoid_free paranoid_system; do
    3131    echo "monodrescue $s usage : "
    3232    tot=0
     
    4040echo " "
    4141echo "Qualimetry: "
    42 find . -name '*.c' -o -name '*.h' |  egrep -v '\.svn|/\*|monitas|/\*|mindi-busybox' | xargs grep -rw asprintf | egrep -v '/\*' | egrep -v 'asprintf\(&' > /tmp/mondo.quality
     42pbg -w asprintf | grep -vE 'monitas|mindi-busybox|quality|/\*|asprintf\(&' > /tmp/mondo.quality
    4343cat /tmp/mondo.quality
    4444echo "monodrescue uses : `cat /tmp/mondo.quality | wc -l` asprintf without &"
    45 find . -name '*.c' -o -name '*.h' |  egrep -v '\.svn|/\*|monitas|/\*|mindi-busybox' | xargs grep -rw getline | egrep -v '/\*' | egrep -v 'getline\(&' > /tmp/mondo.quality
     45pbg -w getline | grep -vE 'monitas|mindi-busybox|quality|/\*|getline\(&' > /tmp/mondo.quality
    4646cat /tmp/mondo.quality
    4747echo "monodrescue uses : `cat /tmp/mondo.quality | wc -l` getline without &"
    48 
     48pbg mr_asprintf | grep -vE '"|FNAME|ISOFS|syscall_sprintf|mr_mem|quality' > /tmp/mondo.quality
     49cat /tmp/mondo.quality
     50echo "monodrescue uses : `cat /tmp/mondo.quality | wc -l` mr_aspritnf without \""
    4951echo " "
    5052echo "Splint: "
Note: See TracChangeset for help on using the changeset viewer.