Ignore:
Timestamp:
May 26, 2008, 5:35:44 PM (11 years ago)
Author:
bruno
Message:
  • Adds OBDR support (use_obdr field in bkpinfo added, -o option changed to mean OBDR - LILO not usable anyway as a bootloader for ISO images)
File:
1 edited

Legend:

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

    r1943 r1948  
    44...tools for talking to tapes, Monitas streams, etc.
    55
    6 
    7 07/10
    8 - added ACL and XATTR support
    9 
    10 04/17
    11 - added bkpinfo->internal_tape_block_size
    12 - fixed bug in set_tape_block_size_with_mt()
    13 
    14 03/25
    15 - call 'mt' when opening tape in/out, to set block size to 32K
    16 
    17 02/06/2004
    18 - only eject_device() at end of closein_tape() --- not closeout_tape()
    19 
    20 10/26/2003
    21 - call eject_device() at end of closein_tape() and closeout_tape()
    22  
    23 09/25
    24 - added docu-header to each subroutine
    25 
    26 09/20
    27 - working on multi-tape code
    28 - friendlier message in insist_on_this_tape_number()
    29 - delay is now 5s
    30 
    31 09/10
    32 - adding multi-tape support
    33 - adding 'back catalog' of previous archives, so that we may resume
    34   from point of end-of-tape (approx.)
    35 
    36 09/08
    37 - cleaned up insist_on_this_tape_number() --- 10s delay for same tape now
    38 
    39 08/27
    40 - improved find_tape_device_and_size() --- tries /dev/osst*
    41 
    42 05/05
    43 - added Joshua Oreman's FreeBSD patches
    44 
    45 04/24
    46 - added lots of assert()'s and log_OS_error()'s
    47 
    48 04/06/2003
    49 - use find_home_of_exe() instead of which
    50 
    51 12/13/2002
    52 - cdrecord -scanbus call was missing 2> /dev/null
    53 
    54 11/24
    55 - disabled fatal_error("Bad marker")
    56 
    57 10/29
    58 - replaced convoluted grep wih wc (KP)
    59 
    60 09/07
    61 - removed g_end_of_tape_reached
    62 - lots of multitape-related fixes
    63 
    64 08/01 - 08/31
    65 - write 16MB of zeroes to end of tape when closing(out)
    66 - compensate for 'buffer' and its distortion of speed of writing/reading
    67   when writing/reading data disks at start of tape
    68 - rewrote lots of multitape stuff
    69 - wrote workaround to allow >2GB of archives w/buffering
    70 - do not close/reopen tape when starting to read/write from
    71   new tape: no need! 'buffer' handles all that; we're writing
    72   to/reading from a FIFO, so no need to close/reopen when new tape
    73 - write 8MB of zeroes at end of tape, just in case
    74 - re-enable various calls to *_evalcall_form
    75 - added g_end_of_tape_reached
    76 - fixed bugs in start_to_[read|write]_[to|from]_next_tape
    77 - added internal buffering, replacing the external 'buffer' exe
    78 - wait 10 seconds (after user inserts new tape), to
    79   let tape stabilize in drive
    80 - added insist_on_this_tape_number()
    81 - worked on find_tape_device_and_size()
    82 - cleaned up some log_it() calls
    83 - added find_tape_device_and_size()
    84 - replaced using_cdstream with backup_media_type
    85 - replace *_from_tape with *_from_stream
    86 - replace *_to_stream with *_to_stream
    87 
    88 07/01 - 07/31
    89 - leave 32MB at end of tape, to avoid overrunning
    90 - started [07/24/2002]
    916*/
    927
     
    753668        return (0);
    754669    }
     670    if (bkpinfo->use_obdr) {
     671        skip_obdr(tapedev);
     672    }
     673
    755674    insist_on_this_tape_number(1);
    756675    sprintf(outfname, "%s/tmp/all.tar.gz", bkpinfo->tmpdir);
     
    864783
    865784/**
    866  * Start writing to a tape device for the backup.
     785 * Return the non-rewinding device when passed the normal one
     786 * @param tapedev The tape device to open for writing.
     787 * @note the caller needs to free the string returned
     788 */
     789char *get_non_rewind_dev(char *tapedev)
     790{
     791
     792    char *ntapedev = NULL;
     793    char *p = NULL;
     794    char *q = NULL;
     795
     796    ntapedev = (char *)malloc(strlen(tapedev)+sizeof(char));
     797    p = strrchr(tapedev,'/');
     798    if (p == NULL) {
     799        return(NULL);
     800    }
     801
     802    /* Copy tapedev content up to the last / */
     803    q = tapedev;
     804    while (q != p) {
     805        *ntapedev = *q;
     806        ntapedev++;
     807        q++;
     808    }
     809    /* Copy the '/' */
     810    *ntapedev = *q;
     811    ntapedev++;
     812    q++;
     813    /* Adds a 'n' - non-rewinding */
     814    *ntapedev = 'n';
     815    ntapedev++;
     816    /* Copy the rest of tapedev */
     817    while (*q != '\0') {
     818        *ntapedev = *q;
     819        ntapedev++;
     820        q++;
     821    }
     822    *ntapedev = '\0';
     823    if (mt_says_tape_exists(ntapedev)) {
     824        log_it("Non-rewinding tape device is %s",ntapedev);
     825    } else {
     826        log_it("Unable to find non-rewinding tape device.");
     827        ntapedev = NULL;
     828    }
     829    return(ntapedev);
     830}
     831
     832
     833/**
     834 * Handle OBDR if we were asked to do so
    867835 * @param tapedev The tape device to open for writing.
    868836 * @return 0 for success, nonzero for failure.
     
    870838 * EXISTING DATA on the tape!
    871839 */
     840void skip_obdr(char *tapedev)
     841{
     842    char *command = NULL;
     843
     844    ntapedev = get_non_rewind_dev(tapedev);
     845    if (ntapedev == NULL) {
     846        log_it("Not skipping OBDR");
     847    }
     848
     849    asprintf(&command, "mt -f %s fsf 2", ntapedev);
     850    run_program_and_log_output(command, 1);
     851    paranoid_free(command);
     852}
     853
     854int create_obdr(char *tapedev)
     855{
     856
     857    char *ntapedev = NULL;
     858    char *command = NULL;
     859    int res = 0;
     860
     861    ntapedev = get_non_rewind_dev(tapedev);
     862    if (ntapedev == NULL) {
     863        log_it("Skipping OBDR");
     864        return(1);
     865    }
     866
     867    /* OBDR: First block 10 kB of zero bs = 512 */
     868    asprintf(&command, "mt -f %s compression off", tapedev);
     869    res = run_program_and_log_output(command, 1);
     870    paranoid_free(command);
     871
     872    asprintf(&command, "mt -f %s rewind", tapedev);
     873    res = run_program_and_log_output(command, 1);
     874    paranoid_free(command);
     875
     876    asprintf(&command, "mt -f %s setblk 512", ntapedev);
     877    res = run_program_and_log_output(command, 1);
     878    paranoid_free(command);
     879
     880    asprintf(&command, "dd if=/dev/zero of=%s bs=512 count=20", ntapedev);
     881    res = run_program_and_log_output(command, 1);
     882    paranoid_free(command);
     883
     884    /* OBDR: then ISO boot image bs = 2048 */
     885    asprintf(&command, "mt -f %s setblk 2048", ntapedev);
     886    res = run_program_and_log_output(command, 1);
     887    paranoid_free(command);
     888
     889    asprintf(&command, "dd if=%s of=%s bs=2048", ntapedev);
     890    res = run_program_and_log_output(command, 1);
     891    paranoid_free(command);
     892
     893}
     894
     895/**
     896 * Start writing to a tape device for the backup.
     897 * Handle OBDR if we were asked to do so
     898 * @param tapedev The tape device to open for writing.
     899 * @return 0 for success, nonzero for failure.
     900 * @note This should be called ONLY from backup processes. It will OVERWRITE ANY
     901 * EXISTING DATA on the tape!
     902 */
    872903int openout_tape(char *tapedev, long internal_tape_block_size)
    873904{
    874 //  char sz_call_to_buffer[MAX_STR_LEN];
    875905
    876906    g_current_media_number = 1;
     
    884914    g_tapecatalog->entries = 0;
    885915    g_tape_posK = 0;
     916
     917    if (bkpindo->use_obdr) {
     918        create_obdr(tapedev);
     919    }
    886920
    887921    set_tape_block_size_with_mt(tapedev, internal_tape_block_size);
Note: See TracChangeset for help on using the changeset viewer.