Ignore:
Timestamp:
Mar 6, 2024, 5:30:47 PM (4 months ago)
Author:
Bruno Cornec
Message:

find_tape_device_and_size => find_tape_device as size unused

File:
1 edited

Legend:

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

    r3646 r3857  
    251251 * Determine the name and size of the tape device. Tries the SCSI tape for
    252252 * this platform, then the IDE tape, then "/dev/st0", then "/dev/osst0".
    253  * @param dev Where to put the found tape device.
     253 * @param dev Where to put the found tape device. Allocated dynamically by caller or reallocated here
    254254 * @param siz Where to put the tape size (a string like "4GB")
    255255 * @return 0 if success, nonzero if failure (in which @p dev and @p siz are undefined).
    256256 */
    257 int find_tape_device_and_size(char *dev, char *siz)
    258 {
     257int find_tape_device(char *dev) {
    259258    char *tmp = NULL;
    260259    char *command = NULL;
     
    263262
    264263    log_to_screen("I am looking for your tape streamer. Please wait.");
    265     dev[0] = siz[0] = '\0';
     264    mr_free(dev);
    266265    if (find_home_of_exe("cdrecord")) {
    267266        mr_asprintf(cdr_exe, "cdrecord");
     
    275274    if (atoi(tmp) != 1) {
    276275        log_it("Either too few or too many tape streamers for me to detect...");
    277         strcpy(dev, VANILLA_SCSI_TAPE);
     276        mr_asprintf(dev, "%s", VANILLA_SCSI_TAPE);
    278277        mr_free(tmp);
    279278        mr_free(cdr_exe);
     
    298297    mr_free(command);
    299298
    300     strcpy(dev, VANILLA_SCSI_TAPE);
     299    mr_asprintf(dev, "%s", VANILLA_SCSI_TAPE);
    301300    dev[strlen(dev) - 1] = '\0';
    302     strcat(dev, tmp);           // e.g. '/dev/st0' becomes '/dev/stN'
     301    mr_strcat(dev, tmp);            // e.g. '/dev/st0' becomes '/dev/stN'
    303302    mr_free(tmp);
    304303
    305304    res = 0;
    306305    if (!mt_says_tape_exists(dev)) {
    307         strcpy(dev, ALT_TAPE);
     306        mr_asprintf(dev, "%s", ALT_TAPE);
    308307        if (!mt_says_tape_exists(dev)) {
    309308            log_it("Cannot openin %s", dev);
    310             strcpy(dev, "/dev/st0");
     309            mr_asprintf(dev, "%s", "/dev/st0");
    311310            if (!mt_says_tape_exists(dev)) {
    312311                log_it("Cannot openin %s", dev);
    313                 strcpy(dev, "/dev/osst0");
     312                mr_asprintf(dev, "%s", "/dev/osst0");
    314313                if (!mt_says_tape_exists(dev)) {
    315314                    res++;
     
    324323        log_it("At this point, dev = %s and res = %d", dev, res);
    325324    } else {
    326         log_it("At this point, dev is NULL and res = %d", dev, res);
    327     }
    328 
    329     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;};};};'");
     325        log_it("At this point, dev is NULL and res = %d", res);
     326    }
    330327
    331328    if (mt_says_tape_exists(dev)) {
     
    335332        mr_free(tmp);
    336333        mr_asprintf(tmp, "%s", (strrchr(dev, '/') != NULL) ? strrchr(dev, '/') : dev);
    337         sprintf(dev, "/dev/os%s", tmp);
     334        mr_asprintf(dev, "/dev/os%s", tmp);
    338335        log_it("...into %s", dev);
    339336        if (mt_says_tape_exists(dev)) {
     
    343340        }
    344341    }
    345 
    346     siz[0] = '\0';
    347342    log_it("res=%d; dev=%s", res, dev);
    348 
    349     if (res) {
    350         return (res);
    351     }
    352 
    353     if (strlen(tmp) < 2) {
    354         siz[0] = '\0';
    355         log_it("Warning - size of tape unknown");
    356     } else {
    357         strcpy(siz, tmp);
    358     }
    359     mr_free(tmp);
    360     return (0);
     343    return (res);
    361344}
    362345
Note: See TracChangeset for help on using the changeset viewer.