Changeset 3872 in MondoRescue


Ignore:
Timestamp:
Mar 7, 2024, 7:00:38 PM (4 months ago)
Author:
Bruno Cornec
Message:

Rewrite find_dvd_device

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

Legend:

Unmodified
Added
Removed
  • branches/3.3/mondo/src/common/libmondo-devices-EXT.h

    r3853 r3872  
    1010                                    char *mountpoint);
    1111extern int find_cdrom_device(char *output, bool try_to_mount);
    12 extern int find_dvd_device(char *output);
     12extern char *find_dvd_device(void);
    1313extern long get_phys_size_of_drive(char *drive);
    1414extern bool is_this_a_valid_disk_format(char *format);
  • branches/3.3/mondo/src/common/libmondo-devices.c

    r3870 r3872  
    2222#include "libmondo-fork-EXT.h"
    2323#include "libmondo-stream-EXT.h"
    24 #include "libmondo-newt-specific-EXT.h"
     24#include "newt-specific-EXT.h"
    2525
    2626#ifdef __FreeBSD__
     
    867867 * and return it's device file to the caller that needs to free it
    868868 */
    869 char *find_dvd_device()
    870 {
    871     char *tmp = NULL;
     869char *find_dvd_device(void)
     870{
     871    char *dev = NULL;
    872872    char *tmp1 = NULL;
    873     int retval = 0, devno = -1;
     873    char *command = NULL;
     874
     875    log_to_screen("I am looking for your optical burner. Please wait.");
    874876
    875877    if (bkpinfo->media_device != NULL) {
     
    879881
    880882    mr_asprintf(tmp1, "cdrecord -inq 2> /dev/null | grep -E '^Detected '  | cut -d':' -f2");
    881     tmp = call_program_and_get_last_line_of_output(tmp1);
     883    dev = call_program_and_get_last_line_of_output(tmp1);
    882884    mr_free(tmp1);
    883     log_msg(5, "find_dvd_device found device '%s'", tmp);
    884 
    885     if (tmp != NULL) {
    886         log_msg(2, "I think DVD is at %s", bkpinfo->media_device);
     885
     886    if ((dev != NULL) && does_file_exist(dev)) {
     887        log_msg(2, "find_dvd_device found %s automatically", dev);
    887888    } else {
    888         log_msg(2, "I cannot find DVD");
    889     }
    890     bkpinfo->media_device = tmp;
    891     return(bkpinfo->media_device);
     889        mr_free(dev);
     890        tmp1 = find_home_of_exe("lsscsi");
     891        if (tmp1 != NULL) {
     892            mr_asprintf(command, "%s | grep ' cd' | awk '{print $NF}' | head -1", tmp1);
     893            dev = call_program_and_get_last_line_of_output(command);
     894            mr_free(command);
     895        }
     896        mr_free(tmp1);
     897
     898        if ((dev == NULL) || !does_file_exist(dev)) {
     899            /* trying something else then */
     900            mr_asprintf(dev, "%s", VANILLA_SCSI_CDROM);
     901            if (!does_file_exist(dev)) {
     902                mr_asprintf(dev, "%s", ALT_CDROM);
     903                if (!does_file_exist(dev)) {
     904                    log_it("Unable to find a tape device on this system");
     905                }
     906            }
     907        }
     908        if (dev != NULL) {
     909            log_it("find_dvd_device found %s manually", dev);
     910        }
     911    }
     912
     913    if ((dev != NULL) && does_file_exist(dev)) {
     914        log_it("find_dvd_device returns %s", dev);
     915    } else {
     916        mr_free(dev);
     917        log_it("find_dvd_device found no optical burner on your system returning NULL");
     918    }
     919    return(dev);
    892920}
    893921
     
    22462274            mr_asprintf(comment, "What speed is your %s (re)writer?", mds);
    22472275            if (bkpinfo->backup_media_type == dvd) {
    2248                 find_dvd_device(bkpinfo->media_device);
     2276                bkpinfo->media_device = find_dvd_device();
     2277                if (bkpinfo->media_device == NULL) {
     2278                    log_msg(1, "No backup device found for your DVD");
     2279                }
    22492280                strcpy(tmp1, "1");
    22502281                mr_asprintf(sz_size, "%d", DEFAULT_DVD_DISK_SIZE);  // 4.7 salesman's GB = 4.482 real GB = 4482 MB
  • branches/3.3/mondo/src/common/libmondo-stream.c

    r3870 r3872  
    310310    log_to_screen("I am looking for your tape streamer. Please wait.");
    311311
     312    if (bkpinfo->media_device != NULL) {
     313        log_msg(3, "Been there, done that. Returning %s", bkpinfo->media_device);
     314        return (bkpinfo->media_device);
     315    }
     316
    312317    tmp = find_home_of_exe("lsscsi");
    313318    if (tmp != NULL) {
     
    318323    mr_free(tmp);
    319324
    320     if (dev != NULL) && does_file_exist(dev) {
     325    if ((dev != NULL) && does_file_exist(dev)) {
    321326        if (mt_says_tape_exists(dev)) {
    322327            log_it("find_tape_device found %s automatically", dev);
     
    334339            }
    335340        }
    336         log_it("find_tape_device found %s manually", dev);
    337     }
    338 
    339     if (dev != NULL) {
     341        if (dev != NULL) {
     342            log_it("find_tape_device found %s manually", dev);
     343        }
     344    }
     345
     346    if ((dev != NULL) && does_file_exist(dev)) {
    340347        log_it("find_tape_device returns %s", dev);
    341348    } else {
     349        mr_free(dev);
    342350        log_it("find_tape_device found no tape on your system returning NULL");
    343351    }
  • branches/3.3/mondo/src/include/my-stuff.h

    r3866 r3872  
    315315#define CP_BIN      "gcp"
    316316#else
    317 #define VANILLA_SCSI_CDROM  "/dev/scd0"
     317#define VANILLA_SCSI_CDROM  "/dev/sr0"
     318#define ALT_CDROM   "/dev/scd0"
    318319#define VANILLA_SCSI_TAPE   "/dev/st0"
    319320#define VANILLA_USB_DEVICE  "/dev/hda"
  • branches/3.3/mondo/src/mondoarchive/mondoarchive.c

    r3853 r3872  
    300300        g_loglevel = 10;
    301301        setup_newt_stuff();
    302         malloc_string(tmp);
    303         if (find_dvd_device(tmp)) {
     302        if (tmp = find_dvd_device()) {
    304303            printf("Failed to find DVD drive\n");
    305304        } else {
Note: See TracChangeset for help on using the changeset viewer.