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-stream.c

    r2321 r2323  
    236236    int res;
    237237
    238     mr_asprintf(&command, "mt -f %s status", dev);
     238    mr_asprintf(command, "mt -f %s status", dev);
    239239    res = run_program_and_log_output(command, 1);
    240240    mr_free(command);
     
    268268        mr_asprintf(&cdr_exe, "dvdrecord");
    269269    }
    270     mr_asprintf(&command, "%s -scanbus 2> /dev/null | grep -i tape | wc -l", cdr_exe);
     270    mr_asprintf(command, "%s -scanbus 2> /dev/null | grep -i tape | wc -l", cdr_exe);
    271271    mr_asprintf(&tmp, "%s", call_program_and_get_last_line_of_output(command));
    272272    mr_free(command);
     
    280280    mr_free(tmp);
    281281
    282     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);
     282    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);
    283283    mr_asprintf(&tmp, "%s", call_program_and_get_last_line_of_output(command));
    284284    mr_free(command);
     
    290290    }
    291291    mr_free(tmp);
    292     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);
     292    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);
    293293    mr_free(cdr_exe);
    294294
     
    372372        }
    373373        if (strstr(fname, "xattr") == NULL) {
    374             mr_asprintf(&tmp,"Wrong order expected xattr, got %s, sunshine.", fname);
     374            mr_asprintf(tmp,"Wrong order expected xattr, got %s, sunshine.", fname);
    375375            fatal_error(tmp);
    376376        }
     
    402402        }
    403403        if (strstr(fname, "acl") == NULL) {
    404             mr_asprintf(&tmp,"Wrong order expected acl, got %s, sunshine.", fname);
     404            mr_asprintf(tmp,"Wrong order expected acl, got %s, sunshine.", fname);
    405405            fatal_error(tmp);
    406406        }
     
    468468    log_it("Insisting on tape #%d", tapeno);
    469469    if (g_current_media_number != tapeno) {
    470         mr_asprintf(&tmp, "When the tape drive goes quiet, please insert volume %d in this series.", tapeno);
     470        mr_asprintf(tmp, "When the tape drive goes quiet, please insert volume %d in this series.", tapeno);
    471471        popup_and_OK(tmp);
    472472        mr_free(tmp);
     
    544544        fatal_error("Unknown type. Internal error in maintain_collection_of_recent_archives()");
    545545    }
    546     mr_asprintf(&tmpdir, "%s/tmpfs/backcatalog", bkpinfo->tmpdir);
     546    mr_asprintf(tmpdir, "%s/tmpfs/backcatalog", bkpinfo->tmpdir);
    547547    mkdir(tmpdir, 0x700);
    548     mr_asprintf(&command, "cp -f %s %s", latest_fname, tmpdir);
     548    mr_asprintf(command, "cp -f %s %s", latest_fname, tmpdir);
    549549    if (run_program_and_log_output(command, 6)) {
    550550        log_it("Warning - failed to copy %s to backcatalog at %s",
     
    575575
    576576    for (i = curr - 1; i >= 0 && curr - i < 10; i--) {
    577         mr_asprintf(&old_fname, "%s/%s", tmpdir, g_tapecatalog->el[i].fname);
     577        mr_asprintf(old_fname, "%s/%s", tmpdir, g_tapecatalog->el[i].fname);
    578578        unlink(old_fname);
    579579        mr_free(old_fname);
     
    615615        return (0);
    616616    }
    617     mr_asprintf(&tmp, "mt -f %s setblk %ld", bkpinfo->media_device, internal_tape_block_size);
     617    mr_asprintf(tmp, "mt -f %s setblk %ld", bkpinfo->media_device, internal_tape_block_size);
    618618    res = run_program_and_log_output(tmp, 3);
    619619    mr_free(tmp);
     
    684684
    685685    log_it("Skipping OBDR headers");
    686     mr_asprintf(&command, "mt -f %s rewind",bkpinfo->media_device);
     686    mr_asprintf(command, "mt -f %s rewind",bkpinfo->media_device);
    687687    res = run_program_and_log_output(command, 1);
    688688    paranoid_free(command);
    689689
    690     mr_asprintf(&command, "mt -f %s fsf 2",bkpinfo->media_device);
     690    mr_asprintf(command, "mt -f %s fsf 2",bkpinfo->media_device);
    691691    res = run_program_and_log_output(command, 1);
    692692    paranoid_free(command);
     
    711711    log_it("Creating OBDR headers");
    712712    /* OBDR: First block 10 kB of zero bs = 512 */
    713     mr_asprintf(&command, "mt -f %s compression off",bkpinfo->media_device);
     713    mr_asprintf(command, "mt -f %s compression off",bkpinfo->media_device);
    714714    res = run_program_and_log_output(command, 1);
    715715    paranoid_free(command);
    716716
    717     mr_asprintf(&command, "mt -f %s rewind",bkpinfo->media_device);
     717    mr_asprintf(command, "mt -f %s rewind",bkpinfo->media_device);
    718718    res += run_program_and_log_output(command, 1);
    719719    paranoid_free(command);
     
    721721    set_tape_block_size_with_mt(512);
    722722
    723     mr_asprintf(&command, "dd if=/dev/zero of=%s bs=512 count=20",bkpinfo->media_device);
     723    mr_asprintf(command, "dd if=/dev/zero of=%s bs=512 count=20",bkpinfo->media_device);
    724724    res += run_program_and_log_output(command, 1);
    725725    paranoid_free(command);
     
    728728    set_tape_block_size_with_mt(2048);
    729729
    730     mr_asprintf(&command, "dd if=%s of=%s bs=2048",MINDI_CACHE"/mondorescue.iso",bkpinfo->media_device);
     730    mr_asprintf(command, "dd if=%s of=%s bs=2048",MINDI_CACHE"/mondorescue.iso",bkpinfo->media_device);
    731731    res += run_program_and_log_output(command, 1);
    732732    paranoid_free(command);
     
    795795
    796796    insist_on_this_tape_number(1);
    797     mr_asprintf(&outfname, "%s/tmp/all.tar.gz", bkpinfo->tmpdir);
     797    mr_asprintf(outfname, "%s/tmp/all.tar.gz", bkpinfo->tmpdir);
    798798    make_hole_for_file(outfname);
    799799
     
    858858    (void) getcwd(old_cwd, MAX_STR_LEN);
    859859    chdir(bkpinfo->tmpdir);
    860     mr_asprintf(&tmp, "tar -zxf %s ./tmp/mondo-restore.cfg 2> /dev/null", outfname);
     860    mr_asprintf(tmp, "tar -zxf %s ./tmp/mondo-restore.cfg 2> /dev/null", outfname);
    861861    paranoid_system(tmp);
    862862    mr_free(tmp);
     
    885885
    886886    /*  add 'dummy' if testing */
    887     mr_asprintf(&command, "cdrecord -eject dev=%s speed=%d fs=24m -waiti - >> %s 2>> %s", cddev, speed, MONDO_LOGFILE, MONDO_LOGFILE);
     887    mr_asprintf(command, "cdrecord -eject dev=%s speed=%d fs=24m -waiti - >> %s 2>> %s", cddev, speed, MONDO_LOGFILE, MONDO_LOGFILE);
    888888    /*  initialise the catalog */
    889889    g_current_media_number = 1;
     
    10581058    res = read_header_block_from_stream(&temp_size, temp_fname, &ctrl_chr);
    10591059    if (orig_size != temp_size && orig_size != -1) {
    1060         mr_asprintf(&tmp, "output file's size should be %ld K but is apparently %ld K", (long) size >> 10, (long) temp_size >> 10);
     1060        mr_asprintf(tmp, "output file's size should be %ld K but is apparently %ld K", (long) size >> 10, (long) temp_size >> 10);
    10611061        log_to_screen(tmp);
    10621062        mr_free(tmp);
     
    11211121    log_msg(6, ".......................... Should be %lld", orig_size);
    11221122    g_tape_posK += total_read_from_tape_for_this_file / 1024;
    1123     mr_asprintf(&actual_cksum, "%04x%04x", crc16, crctt);
     1123    mr_asprintf(actual_cksum, "%04x%04x", crc16, crctt);
    11241124    if (foutstream) {           /*log_it("Finished writing to foutstream"); */
    11251125    } else {
     
    11311131    }
    11321132    if (strcmp(temp_cksum, actual_cksum)) {
    1133         mr_asprintf(&tmp, "actual cksum=%s; recorded cksum=%s", actual_cksum, temp_cksum);
     1133        mr_asprintf(tmp, "actual cksum=%s; recorded cksum=%s", actual_cksum, temp_cksum);
    11341134        log_to_screen(tmp);
    11351135        mr_free(tmp);
    11361136
    1137         mr_asprintf(&tmp, "%s (%ld K) is corrupt on tape", temp_fname, (long) orig_size >> 10);
     1137        mr_asprintf(tmp, "%s (%ld K) is corrupt on tape", temp_fname, (long) orig_size >> 10);
    11381138        log_to_screen(tmp);
    11391139        mr_free(tmp);
     
    14861486    }
    14871487    if (bkpinfo->backup_media_type == cdstream) {
    1488         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);
     1488        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);
    14891489        log_it("Opening OUT to next CD with the command");
    14901490        log_it(command);
     
    15381538    last = g_tapecatalog->entries - 1;
    15391539    for (i = 0; i <= last; i++) {
    1540         mr_asprintf(&fname, "%s/tmpfs/backcatalog/%s", bkpinfo->tmpdir, g_tapecatalog->el[i].fname);
     1540        mr_asprintf(fname, "%s/tmpfs/backcatalog/%s", bkpinfo->tmpdir, g_tapecatalog->el[i].fname);
    15411541        if (!does_file_exist(fname)) {
    15421542            log_msg(6, "Can't write %s - it doesn't exist.", fname);
     
    15911591    log_it("Data disks = %s", fname);
    15921592    if (!does_file_exist(fname)) {
    1593         mr_asprintf(&tmp, "Cannot find %s", fname);
     1593        mr_asprintf(tmp, "Cannot find %s", fname);
    15941594        log_to_screen(tmp);
    15951595        mr_free(tmp);
     
    16891689        p++;
    16901690    }
    1691     mr_asprintf(&tmp, "Writing file '%s' to tape (%ld KB)", p, (long) filesize >> 10);
     1691    mr_asprintf(tmp, "Writing file '%s' to tape (%ld KB)", p, (long) filesize >> 10);
    16921692    log_it(tmp);
    16931693    mr_free(tmp);
     
    17311731    }
    17321732    paranoid_fclose(fin);
    1733     mr_asprintf(&checksum, "%04x%04x", crc16, crctt);
     1733    mr_asprintf(checksum, "%04x%04x", crc16, crctt);
    17341734    /* BERLIOS: what does it do ??? */
    17351735    write_header_block_to_stream((off_t)g_current_media_number, checksum, BLK_STOP_FILE);
     
    17941794        fwrite(tempblock, 1, (size_t) TAPE_BLOCK_SIZE,
    17951795               g_tape_stream) / 1024;
    1796     mr_asprintf(&tmp, "%s (fname=%s, size=%ld K)", marker_to_string(control_char), p, (long) length_of_incoming_file >> 10);
     1796    mr_asprintf(tmp, "%s (fname=%s, size=%ld K)", marker_to_string(control_char), p, (long) length_of_incoming_file >> 10);
    17971797    log_msg(6, tmp);
    17981798    mr_free(tmp);
     
    18211821
    18221822    /*@ end vars *************************************************** */
    1823     mr_asprintf(&tmp, "Wrong marker! (Should be %s, is actually %s)", marker_to_string(should_be), marker_to_string(it_is));
     1823    mr_asprintf(tmp, "Wrong marker! (Should be %s, is actually %s)", marker_to_string(should_be), marker_to_string(it_is));
    18241824    log_to_screen(tmp);
    18251825    mr_free(tmp);
Note: See TracChangeset for help on using the changeset viewer.