Changeset 1951 in MondoRescue


Ignore:
Timestamp:
May 26, 2008, 6:40:27 PM (16 years ago)
Author:
Bruno Cornec
Message:
  • Correct function to hqndle non-rewinding dev
File:
1 edited

Legend:

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

    r1950 r1951  
    623623}
    624624
     625/**
     626 * Return the non-rewinding device when passed the normal one
     627 * @param tapedev The tape device to open for writing.
     628 * @note the caller needs to free the string returned
     629 */
     630char *get_non_rewind_dev(char *tapedev)
     631{
     632
     633    char *ntapedev = NULL;
     634    char *p = NULL;
     635    char *q = NULL;
     636    char *r = NULL;
     637
     638    ntapedev = (char *)malloc(strlen(tapedev)+sizeof(char));
     639    p = strrchr(tapedev,'/');
     640    if (p == NULL) {
     641        log_it("Didn't find a '/' in %s",tapedev);
     642        return(NULL);
     643    }
     644
     645    /* Copy tapedev content up to the last / */
     646    q = tapedev;
     647    r = ntapedev;
     648    while (q != p) {
     649        *r = *q;
     650        r++;
     651        q++;
     652    }
     653    /* Copy the '/' */
     654    *r = *q;
     655    r++;
     656    q++;
     657    /* Adds a 'n' - non-rewinding */
     658    *r = 'n';
     659    r++;
     660    /* Copy the rest of tapedev */
     661    while (*q != '\0') {
     662        *r = *q;
     663        r++;
     664        q++;
     665    }
     666    *r = '\0';
     667    if (mt_says_tape_exists(ntapedev)) {
     668        log_it("Non-rewinding tape device is %s",ntapedev);
     669    } else {
     670        log_it("Unable to find non-rewinding tape device.");
     671        ntapedev = NULL;
     672    }
     673    return(ntapedev);
     674}
     675
     676
    625677
    626678/**
     
    846898        return (1);
    847899    }
    848 }
    849 
    850 /**
    851  * Return the non-rewinding device when passed the normal one
    852  * @param tapedev The tape device to open for writing.
    853  * @note the caller needs to free the string returned
    854  */
    855 char *get_non_rewind_dev(char *tapedev)
    856 {
    857 
    858     char *ntapedev = NULL;
    859     char *p = NULL;
    860     char *q = NULL;
    861 
    862     ntapedev = (char *)malloc(strlen(tapedev)+sizeof(char));
    863     p = strrchr(tapedev,'/');
    864     if (p == NULL) {
    865         return(NULL);
    866     }
    867 
    868     /* Copy tapedev content up to the last / */
    869     q = tapedev;
    870     while (q != p) {
    871         *ntapedev = *q;
    872         ntapedev++;
    873         q++;
    874     }
    875     /* Copy the '/' */
    876     *ntapedev = *q;
    877     ntapedev++;
    878     q++;
    879     /* Adds a 'n' - non-rewinding */
    880     *ntapedev = 'n';
    881     ntapedev++;
    882     /* Copy the rest of tapedev */
    883     while (*q != '\0') {
    884         *ntapedev = *q;
    885         ntapedev++;
    886         q++;
    887     }
    888     *ntapedev = '\0';
    889     if (mt_says_tape_exists(ntapedev)) {
    890         log_it("Non-rewinding tape device is %s",ntapedev);
    891     } else {
    892         log_it("Unable to find non-rewinding tape device.");
    893         ntapedev = NULL;
    894     }
    895     return(ntapedev);
    896900}
    897901
Note: See TracChangeset for help on using the changeset viewer.