Ignore:
Timestamp:
Aug 18, 2009, 3:05:43 PM (11 years ago)
Author:
Bruno Cornec
Message:

r3334@localhost: bruno | 2009-08-08 12:17:37 +0200

  • Change mr_asprintf interface to pass only the char * (makes bkpinfo usage more easy)
File:
1 edited

Legend:

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

    r2321 r2323  
    9393    assert_string_is_neither_NULL_nor_zerolength(stderr_fname);
    9494
    95     mr_asprintf(&afio_found_changes, "%s.afio", ignorefiles_fname);
     95    mr_asprintf(afio_found_changes, "%s.afio", ignorefiles_fname);
    9696    paranoid_system("sync");
    9797
    9898    log_msg(1, "Now scanning log file for 'afio: ' stuff");
    99     mr_asprintf(&command, "grep \"afio: \" %s | sed 's/afio: //' | grep -vE '^/dev/.*$' >> %s", stderr_fname, afio_found_changes);
     99    mr_asprintf(command, "grep \"afio: \" %s | sed 's/afio: //' | grep -vE '^/dev/.*$' >> %s", stderr_fname, afio_found_changes);
    100100    log_msg(2, command);
    101101    res = system(command);
     
    107107
    108108    log_msg(1, "Now scanning log file for 'star: ' stuff");
    109     mr_asprintf(&command, "grep \"star: \" %s | sed 's/star: //' | grep -vE '^/dev/.*$' >> %s", stderr_fname, afio_found_changes);
     109    mr_asprintf(command, "grep \"star: \" %s | sed 's/star: //' | grep -vE '^/dev/.*$' >> %s", stderr_fname, afio_found_changes);
    110110    log_msg(2, command);
    111111    res = system(command);
     
    116116    }
    117117    afio_diffs = count_lines_in_file(afio_found_changes);
    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);
     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);
    119119    mr_free(afio_found_changes);
    120120    log_msg(2, command);
     
    167167        } else {
    168168            retval++;
    169             mr_asprintf(&tmp, "Warning - missing set(s) between %d and %d\n", 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);
    170170            log_to_screen(tmp);
    171171            mr_free(tmp);
     
    173173    }
    174174    mds = media_descriptor_string(bkpinfo->backup_media_type);
    175     mr_asprintf(&tmp, "Verifying %s #%d's tarballs", mds, g_current_media_number);
     175    mr_asprintf(tmp, "Verifying %s #%d's tarballs", mds, g_current_media_number);
    176176    mr_free(mds);
    177177
     
    269269    log_it("before vsbf");
    270270    mds = media_descriptor_string(bkpinfo->backup_media_type);
    271     mr_asprintf(&tmp, "Verifying %s#%d's big files", mds, g_current_media_number);
     271    mr_asprintf(tmp, "Verifying %s#%d's big files", mds, g_current_media_number);
    272272    mr_free(mds);
    273273
     
    276276
    277277    log_it("after vsbf");
    278     mr_asprintf(&mountpoint, "%s/archives", mtpt);
     278    mr_asprintf(mountpoint, "%s/archives", mtpt);
    279279    if (last_bigfile_num == -1) {
    280280        bigfile_num = 0;
     
    302302                paranoid_fclose(fin);
    303303            }
    304             mr_asprintf(&tmp, "%s/%s", bkpinfo->restore_path, biggiestruct.filename);
     304            mr_asprintf(tmp, "%s/%s", bkpinfo->restore_path, biggiestruct.filename);
    305305            log_msg(2, "Opening biggiefile #%ld - '%s'", bigfile_num, tmp);
    306306            forig = fopen(tmp, "r");
     
    312312                            bkpinfo->restore_path,
    313313                            biggiestruct.filename);
    314                 mr_asprintf(&tmp, "echo \"%s/%s not found\" >> %s/biggies.changed", bkpinfo->restore_path, biggiestruct.filename, bkpinfo->tmpdir);
     314                mr_asprintf(tmp, "echo \"%s/%s not found\" >> %s/biggies.changed", bkpinfo->restore_path, biggiestruct.filename, bkpinfo->tmpdir);
    315315                system(tmp);
    316316                mr_free(tmp);
     
    333333                    g_current_media_number, bigfile_num, slice_num);
    334334            if (!does_file_exist(slice_fname(bigfile_num, slice_num, mountpoint, ""))) {
    335                 mr_asprintf(&command, "%s -dc %s 2>> %s", sz_exe, slice_fname(bigfile_num, slice_num, mountpoint, bkpinfo->zip_suffix), MONDO_LOGFILE);
     335                mr_asprintf(command, "%s -dc %s 2>> %s", sz_exe, slice_fname(bigfile_num, slice_num, mountpoint, bkpinfo->zip_suffix), MONDO_LOGFILE);
    336336            } else {
    337                 mr_asprintf(&command, "cat %s 2>> %s", slice_fname(bigfile_num, slice_num, mountpoint, ""), MONDO_LOGFILE);
     337                mr_asprintf(command, "cat %s 2>> %s", slice_fname(bigfile_num, slice_num, mountpoint, ""), MONDO_LOGFILE);
    338338            }
    339339            pin = popen(command, "r");
     
    432432
    433433    log_it("Verifying fileset '%s'", tarball_fname);
    434     mr_asprintf(&outlog, "%s/afio.log", bkpinfo->tmpdir);
     434    mr_asprintf(outlog, "%s/afio.log", bkpinfo->tmpdir);
    435435    /* if programmer forgot to say which compression thingy to use then find out */
    436436    if (strstr(tarball_fname, ".lzo")
     
    462462        bkpinfo->use_star = TRUE;
    463463        if (strstr(tarball_fname, ".bz2"))
    464             mr_asprintf(&command, "star -diff diffopts=mode,size,data file=%s -bz >> %s 2>> %s", tarball_fname, outlog, outlog);
     464            mr_asprintf(command, "star -diff diffopts=mode,size,data file=%s %s >> %s 2>> %s", tarball_fname, (strstr(tarball_fname, ".bz2")) ? "-bz" : " ", outlog, outlog);
    465465    } else {
    466466        bkpinfo->use_star = FALSE;
    467         mr_asprintf(&command, "afio -r -P %s -Z %s >> %s 2>> %s", bkpinfo->zip_exe, tarball_fname, outlog, outlog);
     467        mr_asprintf(command, "afio -r -P %s -Z %s >> %s 2>> %s", bkpinfo->zip_exe, tarball_fname, outlog, outlog);
    468468    }
    469469    log_msg(6, "command=%s", command);
     
    472472
    473473    if (length_of_file(outlog) < 10) {
    474         mr_asprintf(&command, "cat %s >> %s", outlog, MONDO_LOGFILE);
     474        mr_asprintf(command, "cat %s >> %s", outlog, MONDO_LOGFILE);
    475475    } else {
    476         mr_asprintf(&command, "cut -d: -f%d %s | sort -u", (bkpinfo->use_star) ? 1 : 2, outlog);
     476        mr_asprintf(command, "cut -d: -f%d %s | sort -u", (bkpinfo->use_star) ? 1 : 2, outlog);
    477477        pin = popen(command, "r");
    478478        if (pin) {
     
    580580        p++;
    581581    }
    582     mr_asprintf(&tmp, "mkdir -p %s/tmpfs", bkpinfo->tmpdir);
     582    mr_asprintf(tmp, "mkdir -p %s/tmpfs", bkpinfo->tmpdir);
    583583    paranoid_system(tmp);
    584584    mr_free(tmp);
    585585
    586     mr_asprintf(&tarball_fname, "%s/tmpfs/temporary-%s", bkpinfo->tmpdir, p);
     586    mr_asprintf(tarball_fname, "%s/tmpfs/temporary-%s", bkpinfo->tmpdir, p);
    587587    read_file_from_stream_to_file(tarball_fname, size);
    588588    res = verify_a_tarball(tarball_fname);
     
    639639        p++;
    640640    }
    641     mr_asprintf(&test_file, "%s/temporary-%s", bkpinfo->tmpdir, p);
     641    mr_asprintf(test_file, "%s/temporary-%s", bkpinfo->tmpdir, p);
    642642    for (res =
    643643         read_header_block_from_stream(&slice_siz, slice_fnam, &ctrl_chr);
     
    666666        if (strcmp(biggie_cksum, orig_cksum)) {
    667667            log_msg(2, "orig cksum=%s; curr cksum=%s", biggie_cksum, orig_cksum);
    668             mr_asprintf(&tmp, "%s has changed on live filesystem", biggie_fname);
     668            mr_asprintf(tmp, "%s has changed on live filesystem", biggie_fname);
    669669            log_to_screen(tmp);
    670670            mr_free(tmp);
    671671
    672             mr_asprintf(&tmp, "echo \"%s\" >> %s/biggies.changed", biggie_fname, bkpinfo->tmpdir);
     672            mr_asprintf(tmp, "echo \"%s\" >> %s/biggies.changed", biggie_fname, bkpinfo->tmpdir);
    673673            system(tmp);
    674674            mr_free(tmp);
     
    713713
    714714    if (g_getfattr) {
    715         mr_asprintf(&curr_xattr_list_fname, XATTR_BIGGLST_FNAME_RAW_SZ, bkpinfo->tmpdir);
     715        mr_asprintf(curr_xattr_list_fname, XATTR_BIGGLST_FNAME_RAW_SZ, bkpinfo->tmpdir);
    716716    }
    717717    if (g_getfacl) {
    718         mr_asprintf(&curr_acl_list_fname, ACL_BIGGLST_FNAME_RAW_SZ, bkpinfo->tmpdir);
     718        mr_asprintf(curr_acl_list_fname, ACL_BIGGLST_FNAME_RAW_SZ, bkpinfo->tmpdir);
    719719    }
    720720    log_to_screen("Verifying regular archives on tape");
     
    749749         res = read_header_block_from_stream(&size, fname, &ctrl_chr)) {
    750750        if (g_getfattr) {
    751             mr_asprintf(&curr_xattr_list_fname, XATTR_LIST_FNAME_RAW_SZ, bkpinfo->tmpdir, current_afioball_number);
     751            mr_asprintf(curr_xattr_list_fname, XATTR_LIST_FNAME_RAW_SZ, bkpinfo->tmpdir, current_afioball_number);
    752752        }
    753753        if (g_getfacl) {
    754             mr_asprintf(&curr_acl_list_fname, ACL_LIST_FNAME_RAW_SZ, bkpinfo->tmpdir, current_afioball_number);
     754            mr_asprintf(curr_acl_list_fname, ACL_LIST_FNAME_RAW_SZ, bkpinfo->tmpdir, current_afioball_number);
    755755        }
    756756        if (ctrl_chr == BLK_START_EXTENDED_ATTRIBUTES) {
     
    770770            wrong_marker(BLK_START_AN_AFIO_OR_SLICE, ctrl_chr);
    771771        }
    772         mr_asprintf(&tmp, "Verifying fileset #%ld", current_afioball_number);
     772        mr_asprintf(tmp, "Verifying fileset #%ld", current_afioball_number);
    773773        update_progress_form(tmp);
    774774        mr_free(tmp);
     
    776776        res = verify_an_afioball_from_stream(fname, size);
    777777        if (res) {
    778             mr_asprintf(&tmp, "Afioball %ld differs from live filesystem", current_afioball_number);
     778            mr_asprintf(tmp, "Afioball %ld differs from live filesystem", current_afioball_number);
    779779            log_to_screen(tmp);
    780780            mr_free(tmp);
     
    830830
    831831    if (g_getfattr) {
    832         mr_asprintf(&curr_xattr_list_fname, XATTR_BIGGLST_FNAME_RAW_SZ, bkpinfo->tmpdir);
     832        mr_asprintf(curr_xattr_list_fname, XATTR_BIGGLST_FNAME_RAW_SZ, bkpinfo->tmpdir);
    833833    }
    834834    if (g_getfacl) {
    835         mr_asprintf(&curr_acl_list_fname, ACL_BIGGLST_FNAME_RAW_SZ, bkpinfo->tmpdir);
    836     }
    837     mr_asprintf(&comment, "Verifying all bigfiles.");
     835        mr_asprintf(curr_acl_list_fname, ACL_BIGGLST_FNAME_RAW_SZ, bkpinfo->tmpdir);
     836    }
     837    mr_asprintf(comment, "Verifying all bigfiles.");
    838838    log_to_screen(comment);
    839839    res = read_header_block_from_stream(&size, orig_fname, &ctrl_chr);
     
    878878            p++;
    879879        }
    880         mr_asprintf(&comment, "Verifying bigfile #%ld (%ld K)", current_biggiefile_number, (long) size >> 10);
     880        mr_asprintf(comment, "Verifying bigfile #%ld (%ld K)", current_biggiefile_number, (long) size >> 10);
    881881        update_progress_form(comment);
    882882        mr_free(comment);
    883883
    884         mr_asprintf(&logical_fname, "%s/%s", bkpinfo->restore_path, orig_fname);
     884        mr_asprintf(logical_fname, "%s/%s", bkpinfo->restore_path, orig_fname);
    885885        res = verify_a_biggiefile_from_stream(logical_fname, size);
    886886        mr_free(logical_fname);
     
    901901 * Verify the USB device
    902902 * @param bkpinfo The backup information structure. Fields used:
    903  * - @c bkpinfo->isodir
    904903 * - @c bkpinfo->media_device
    905904 * - @c bkpinfo->tmpdir
     
    931930    assert(bkpinfo != NULL);
    932931
    933     mr_asprintf(&fname, "%s1", bkpinfo->media_device);
     932    mr_asprintf(fname, "%s1", bkpinfo->media_device);
    934933    if (is_this_device_mounted(fname)) {
    935934        log_msg(1, "USB device mounted. Remounting it at the right place");
    936         mr_asprintf(&tmp, "umount %s", fname);
     935        mr_asprintf(tmp, "umount %s", fname);
    937936        run_program_and_log_output(tmp, FALSE);
    938937        paranoid_free(tmp);
     
    941940
    942941    log_msg(1, "Mounting USB device.");
    943     mr_asprintf(&mountpoint, "%s/usb", bkpinfo->tmpdir);
    944     mr_asprintf(&tmp, "mkdir -p %s", mountpoint);
     942    mr_asprintf(mountpoint, "%s/usb", bkpinfo->tmpdir);
     943    mr_asprintf(tmp, "mkdir -p %s", mountpoint);
    945944    run_program_and_log_output(tmp, FALSE);
    946945    paranoid_free(tmp);
    947946    /* Mindi always create one single parition on the USB dev */
    948     mr_asprintf(&tmp, "mount %s1 %s", bkpinfo->media_device, mountpoint);
     947    mr_asprintf(tmp, "mount %s1 %s", bkpinfo->media_device, mountpoint);
    949948    ret = run_program_and_log_output(tmp, FALSE);
    950949    paranoid_free(tmp);
     
    956955    sync();
    957956    log_msg(2, "OK, I've mounted the USB Disk/Key\n");
    958     mr_asprintf(&tmp, "%s/archives/NOT-THE-LAST", mountpoint);
     957    mr_asprintf(tmp, "%s/archives/NOT-THE-LAST", mountpoint);
    959958    if (!does_file_exist(tmp)) {
    960959        log_msg
     
    973972    verify_all_slices_on_CD(mountpoint);
    974973
    975     mr_asprintf(&tmp1, "umount %s", mountpoint);
     974    mr_asprintf(tmp1, "umount %s", mountpoint);
    976975#ifdef __FreeBSD__
    977976    ret += system(tmp1);
     
    982981#endif
    983982    {
    984         mr_asprintf(&tmp, "%s failed; unable to unmount USB device\n", tmp1);
     983        mr_asprintf(tmp, "%s failed; unable to unmount USB device\n", tmp1);
    985984        log_to_screen(tmp);
    986985        paranoid_free(tmp);
     
    10311030    assert(bkpinfo != NULL);
    10321031
    1033     mr_asprintf(&mountpoint, "%s/cdrom", bkpinfo->tmpdir);
    1034     mr_asprintf(&fname, "%s/%s/%s-%d.iso", bkpinfo->isodir, bkpinfo->nfs_remote_dir, bkpinfo->prefix, g_current_media_number);
     1032    mr_asprintf(mountpoint, "%s/cdrom", bkpinfo->tmpdir);
     1033    mr_asprintf(fname, "%s/%s/%s-%d.iso", bkpinfo->isodir, bkpinfo->nfs_remote_dir, bkpinfo->prefix, g_current_media_number);
    10351034
    10361035    mkdir(mountpoint, 1777);
     
    10541053        mddevice = make_vn(fname);
    10551054        if (ret) {
    1056             mr_asprintf(&tmp, "make_vn of %s failed; unable to verify ISO\n", fname);
     1055            mr_asprintf(tmp, "make_vn of %s failed; unable to verify ISO\n", fname);
    10571056            log_to_screen(tmp);
    10581057            mr_free(tmp);
     
    10611060            return (1);
    10621061        }
    1063         mr_asprintf(&command, "mount_cd9660 %s %s", mddevice, mountpoint);
     1062        mr_asprintf(command, "mount_cd9660 %s %s", mddevice, mountpoint);
    10641063#else
    1065         mr_asprintf(&command, "mount -o loop,ro -t iso9660 %s %s", fname, mountpoint);
     1064        mr_asprintf(command, "mount -o loop,ro -t iso9660 %s %s", fname, mountpoint);
    10661065#endif
    10671066        if (run_program_and_log_output(command, FALSE)) {
    1068             mr_asprintf(&tmp, "%s failed; unable to mount ISO image\n", command);
     1067            mr_asprintf(tmp, "%s failed; unable to mount ISO image\n", command);
    10691068            log_to_screen(tmp);
    10701069            mr_free(tmp);
     
    10771076    }
    10781077    log_msg(2, "OK, I've mounted the ISO/CD\n");
    1079     mr_asprintf(&tmp, "%s/archives/NOT-THE-LAST", mountpoint);
     1078    mr_asprintf(tmp, "%s/archives/NOT-THE-LAST", mountpoint);
    10801079    if (!does_file_exist(tmp)) {
    10811080        log_msg
     
    10971096#ifdef __FreeBSD__
    10981097    ret = 0;
    1099     mr_asprintf(&command, "umount %s", mountpoint);
     1098    mr_asprintf(command, "umount %s", mountpoint);
    11001099    ret += system(command);
    11011100    ret += kick_vn(mddevice);
    11021101    if (ret)
    11031102#else
    1104     mr_asprintf(&command, "umount %s", mountpoint);
     1103    mr_asprintf(command, "umount %s", mountpoint);
    11051104    if (system(command))
    11061105#endif
    11071106    {
    1108         mr_asprintf(&tmp, "%s failed; unable to unmount ISO image\n", command);
     1107        mr_asprintf(tmp, "%s failed; unable to unmount ISO image\n", command);
    11091108        log_to_screen(tmp);
    11101109        mr_free(tmp);
     
    11181117
    11191118    if (!does_file_exist(fname)) {
    1120         mr_asprintf(&command, "umount %s", bkpinfo->media_device);
     1119        mr_asprintf(command, "umount %s", bkpinfo->media_device);
    11211120        run_program_and_log_output(command, 2);
    11221121        mr_free(command);
     
    11651164/* close tape; exit */
    11661165//  fclose(g_tape_stream); <-- not needed; is handled by closein_tape()
    1167     mr_asprintf(&tmp, "rm -f %s/biggies.changed %s/changed.files 2> /dev/null", bkpinfo->tmpdir, bkpinfo->tmpdir);
     1166    mr_asprintf(tmp, "rm -f %s/biggies.changed %s/changed.files 2> /dev/null", bkpinfo->tmpdir, bkpinfo->tmpdir);
    11681167    paranoid_system(tmp);
    11691168    mr_free(tmp);
    11701169
    1171     mr_asprintf(&changed_files_fname, "%s/changed.files", bkpinfo->tmpdir);
    1172     mr_asprintf(&tmp, "grep -E '^%s:.*$' %s | cut -d'\"' -f2 | sort -u | awk '{print \"/\"$0;};' | tr -s '/' '/' | grep -v \"(total of\" | grep -v \"incheckentry.*xwait\" | grep -vE '^/afio:.*$' | grep -vE '^dev/.*$'  > %s", (bkpinfo->use_star) ? "star" : "afio", MONDO_LOGFILE, changed_files_fname);
     1170    mr_asprintf(changed_files_fname, "%s/changed.files", bkpinfo->tmpdir);
     1171    mr_asprintf(tmp, "grep -E '^%s:.*$' %s | cut -d'\"' -f2 | sort -u | awk '{print \"/\"$0;};' | tr -s '/' '/' | grep -v \"(total of\" | grep -v \"incheckentry.*xwait\" | grep -vE '^/afio:.*$' | grep -vE '^dev/.*$'  > %s", (bkpinfo->use_star) ? "star" : "afio", MONDO_LOGFILE, changed_files_fname);
    11731172    log_msg(2, "Running command to derive list of changed files");
    11741173    log_msg(2, tmp);
     
    11821181    mr_free(tmp);
    11831182
    1184     mr_asprintf(&tmp, "cat %s/biggies.changed >> %s", bkpinfo->tmpdir, changed_files_fname);
     1183    mr_asprintf(tmp, "cat %s/biggies.changed >> %s", bkpinfo->tmpdir, changed_files_fname);
    11851184    paranoid_system(tmp);
    11861185    mr_free(tmp);
     
    11881187    diffs = count_lines_in_file(changed_files_fname);
    11891188    if (diffs > 0) {
    1190         mr_asprintf(&tmp, "cp -f %s %s/changed.files", changed_files_fname, MONDO_CACHE);
     1189        mr_asprintf(tmp, "cp -f %s %s/changed.files", changed_files_fname, MONDO_CACHE);
    11911190        run_program_and_log_output(tmp, FALSE);
    11921191        mr_free(tmp);
Note: See TracChangeset for help on using the changeset viewer.