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

r3336@localhost: bruno | 2009-08-11 16:32:36 +0200

  • bkpinfo->media_device, bkpinfo->nfs_remote_dir, and bkpinfo->nfs_mount are now dynamically allocated
  • new interfaces for find_cdrom_device(), find_tape_device_and_size(), find_dvd_device(), find_cdrw_device(), set_dev_to_this_if_rx_OK() and read_cfg_var() which allocate the string now returned
  • Better differentiation between ISO and NFS iso file names construction
File:
1 edited

Legend:

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

    r2324 r2325  
    138138    paranoid_pclose(g_tape_stream);
    139139    log_it("closein_tape() -- leaving");
    140 /*
    141   for(i=0; i < g_tapecatalog->entries; i++)
    142     {
    143       log_it("i=%d type=%s num=%d aux=%ld", i, (g_tapecatalog->el[i].type==fileset)?"fileset":"bigslice", g_tapecatalog->el[i].number, g_tapecatalog->el[i].aux);
    144     }
    145 */
    146140    if (!bkpinfo->please_dont_eject) {
    147141        eject_device(bkpinfo->media_device);
     
    222216               g_tapecatalog->el[i].tape_posK);
    223217    }
    224     //  if (!bkpinfo->please_dont_eject)
    225     //    { eject_device(bkpinfo->media_device); }
    226218    paranoid_free(blk);
    227219    paranoid_free(g_tapecatalog);
     
    261253    char *dev = NULL;
    262254    int res;
     255    char *dev = NULL;
    263256
    264257    log_to_screen("I am looking for your tape streamer. Please wait.");
     
    296289    mr_free(command);
    297290
    298     mr_asprintf(&dev, "%s", VANILLA_SCSI_TAPE);
    299     dev[strlen(dev) - 1] = '\0';
     291
     292    mr_asprintf(dev, "%s", "/dev/st");
    300293    mr_strcat(dev, tmp);            // e.g. '/dev/st0' becomes '/dev/stN'
    301294    mr_free(tmp);
    302 
    303295    res = 0;
    304296    if (!mt_says_tape_exists(dev)) {
     
    314306                mr_asprintf(&dev, "/dev/osst0");
    315307                if (!mt_says_tape_exists(dev)) {
     308                    mr_free(dev);
    316309                    res++;
    317310                } else {
     
    322315    }
    323316
    324     log_it("At this point, dev = %s and res = %d", dev, res);
     317    if (dev) {
     318        log_it("At this point, dev = %s and res = %d", dev, res);
     319    } else {
     320        log_it("At this point, dev is NULL and res = %d", dev, res);
     321    }
    325322
    326323    mr_asprintf(&tmp, call_program_and_get_last_line_of_output("cdrecord -scanbus 2> /dev/null | tr -s '\t' ' ' | grep \"[0-9]*,[0-9]*,[0-9]*\" | grep -v \"[0-9]*) \\*\" | grep -i TAPE | awk '{for(i=1; i<NF; i++) { if (index($i, \"GB\")>0) { print $i;};};};'"));
     
    338335            res = 0;
    339336        } else {
     337            mr_free(dev);
    340338            res++;
    341339        }
     
    610608    int res;
    611609
     610    if (bkpinfo->media_device == NULL) {
     611        return(1);
     612    }
     613
    612614    if (strncmp(bkpinfo->media_device, "/dev/", 5)) {
    613         log_msg(1,
    614                 "Not using 'mt setblk'. This isn't an actual /dev entry.");
     615        log_msg(1, "Not using 'mt setblk'. This isn't an actual /dev entry.");
    615616        return (0);
    616617    }
     
    683684    int res = 0;
    684685
     686    if (bkpinfo->media_device == NULL) {
     687        return(1);
     688    }
     689
    685690    log_it("Skipping OBDR headers");
    686691    mr_asprintf(command, "mt -f %s rewind",bkpinfo->media_device);
     
    708713    char *command = NULL;
    709714    int res = 0;
     715
     716    if (bkpinfo->media_device == NULL) {
     717        return(1);
     718    }
    710719
    711720    log_it("Creating OBDR headers");
     
    770779    /*@ end vars *************************************************** */
    771780
    772     assert_string_is_neither_NULL_nor_zerolength(bkpinfo->media_device);
    773     if (!(g_tapecatalog = malloc(sizeof(struct s_tapecatalog)))) {
    774         fatal_error("Cannot alloc mem for tape catalog");
    775     }
     781    g_tapecatalog = mr_malloc(sizeof(struct s_tapecatalog));
    776782    g_tapecatalog->entries = 0;
    777783    g_tape_posK = 0;
     
    790796        if (bkpinfo->media_device == NULL) {
    791797            log_it("Not able to skip OBDR - Restore will have to be done manually");
     798            return (1);
    792799        }
    793800        set_tape_block_size_with_mt(bkpinfo->internal_tape_block_size);
     
    798805    make_hole_for_file(outfname);
    799806
    800 //  start_buffer_process( bkpinfo->media_device, g_tape_fifo, FALSE);
    801807    log_it("Opening IN tape");
    802     if (!
    803         (g_tape_stream =
    804          open_device_via_buffer(bkpinfo->media_device, 'r',
    805                                 bkpinfo->internal_tape_block_size))) {
     808    if (!(g_tape_stream = open_device_via_buffer(bkpinfo->media_device, 'r', bkpinfo->internal_tape_block_size))) {
    806809        log_OS_error(g_tape_fifo);
    807810        log_to_screen("Cannot openin stream device");
     
    884887    /*@ end vars *************************************************** */
    885888
     889    if (cddev == NULL) {
     890        log_to_screen("Failed to openout NULL cddev");
     891        return (1);
     892    }
    886893    /*  add 'dummy' if testing */
    887894    mr_asprintf(command, "cdrecord -eject dev=%s speed=%d fs=24m -waiti - >> %s 2>> %s", cddev, speed, MONDO_LOGFILE, MONDO_LOGFILE);
     
    923930    return (0);
    924931}
    925 if (!(g_tapecatalog = malloc(sizeof(struct s_tapecatalog)))) {
    926     fatal_error("Cannot alloc mem for tape catalog");
    927 }
     932if (bkpinfo->media_device == NULL) {
     933    log_it("Unable to openout NULL dvice");
     934    return(1);
     935}
     936g_tapecatalog = mr_malloc(sizeof(struct s_tapecatalog));
    928937g_tapecatalog->entries = 0;
    929938g_tape_posK = 0;
     
    935944}
    936945log_it("Opening OUT tape");
    937 if (!
    938     (g_tape_stream =
    939      open_device_via_buffer(bkpinfo->media_device, 'w', bkpinfo->internal_tape_block_size))) {
     946if (!(g_tape_stream = open_device_via_buffer(bkpinfo->media_device, 'w', bkpinfo->internal_tape_block_size))) {
    940947    log_OS_error(g_tape_fifo);
    941948    log_to_screen("Cannot openin stream device");
     
    950957/**
    951958 * Copy a file from the opened stream (CD or tape) to @p outfile.
    952  * @param bkpinfo The backup information structure. @c bkpinfo->media_device is the only field used.
    953959 * @param outfile The file to write to.
    954960 * @param size The size of the file in the input stream.
     
    14221428    /*@ end vars *************************************************** */
    14231429
     1430    if (bkpinfo->media_device == NULL) {
     1431        log_it("Unable to open in from NULL device");
     1432        return (1);
     1433    }
     1434
    14241435    paranoid_pclose(g_tape_stream);
    14251436    sync();
     
    14291440    insist_on_this_tape_number(g_current_media_number + 1); // will increment it, too
    14301441    log_it("Opening IN the next tape");
    1431     if (!
    1432         (g_tape_stream =
    1433          open_device_via_buffer(bkpinfo->media_device, 'r',
    1434                                 bkpinfo->internal_tape_block_size))) {
     1442    if (!(g_tape_stream = open_device_via_buffer(bkpinfo->media_device, 'r', bkpinfo->internal_tape_block_size))) {
    14351443        log_OS_error(g_tape_fifo);
    14361444        log_to_screen("Cannot openin stream device");
     
    14641472    int res = 0;
    14651473    char *command = NULL;
     1474
     1475    if (bkpinfo->media_device == NULL) {
     1476        log_it("Unable to open out from NULL device");
     1477        return (1);
     1478    }
    14661479
    14671480    paranoid_pclose(g_tape_stream);
     
    14891502    } else {
    14901503        log_it("Opening OUT to next tape");
    1491         if (!
    1492             (g_tape_stream =
    1493              open_device_via_buffer(bkpinfo->media_device, 'w',
    1494                                     bkpinfo->internal_tape_block_size))) {
     1504        if (!(g_tape_stream = open_device_via_buffer(bkpinfo->media_device, 'w', bkpinfo->internal_tape_block_size))) {
    14951505            log_OS_error(g_tape_fifo);
    14961506            log_to_screen("Cannot openin stream device");
Note: See TracChangeset for help on using the changeset viewer.