Changeset 3857 in MondoRescue


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

find_tape_device_and_size => find_tape_device as size unused

Location:
branches/3.3/mondo/src/common
Files:
5 edited

Legend:

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

    r3853 r3857  
    331331    if ((flag_set['t'] && !flag_set['d']) && (! bkpinfo->restore_data)) {
    332332        log_it("Hmm! No tape drive specified. Let's see what we can do.");
    333         if (find_tape_device_and_size(flag_val['d'], tmp)) {
     333        if (find_tape_device(flag_val['d'])) {
    334334            fatal_error("Tape device not specified. I couldn't find it either.");
    335335        }
     
    686686        if (flag_set['i']) {
    687687            mr_asprintf(bkpinfo->isodir, "%s", flag_val['d']);
    688             sprintf(tmp, "ls -l %s", bkpinfo->isodir);
    689             if (run_program_and_log_output(tmp, 2)) {
     688            mr_asprintf(tmp1, "ls -l %s", bkpinfo->isodir);
     689            if (run_program_and_log_output(tmp1, 2)) {
     690                mr_free(tmp1);
    690691                fatal_error("output folder does not exist - please create it");
    691692            }
     693            mr_free(tmp1);
    692694        } else if (flag_set['n']) {
    693695            mr_free(bkpinfo->netfs_remote_dir);
  • branches/3.3/mondo/src/common/libmondo-devices.c

    r3853 r3857  
    23602360    case tape:
    23612361
    2362         if ((!bkpinfo->restore_mode) && (find_tape_device_and_size(bkpinfo->media_device, sz_size))) {
     2362        if ((!bkpinfo->restore_mode) && (find_tape_device(bkpinfo->media_device))) {
    23632363            log_msg(3, "Ok, using vanilla scsi tape.");
    23642364            mr_asprintf(bkpinfo->media_device, "%s", VANILLA_SCSI_TAPE);
  • branches/3.3/mondo/src/common/libmondo-stream-EXT.h

    r1954 r3857  
    55extern int closein_tape();
    66extern int closeout_tape();
    7 extern int find_tape_device_and_size(char *dev, char *siz);
     7extern int find_tape_device(char *dev);
    88extern void insist_on_this_tape_number(int tapeno);
    99extern void log_tape_pos(void);
  • 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
  • branches/3.3/mondo/src/common/libmondo-stream.h

    r1954 r3857  
    77int closein_tape();
    88int closeout_tape();
    9 int find_tape_device_and_size(char *dev, char *siz);
     9int find_tape_device(char *dev);
    1010void insist_on_this_tape_number(int tapeno);
    1111void log_tape_pos(void);
Note: See TracChangeset for help on using the changeset viewer.