Changeset 3874 in MondoRescue for branches/3.3/mondo/src/common/libmondo-devices.c
- Timestamp:
- Mar 7, 2024, 7:23:09 PM (4 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/3.3/mondo/src/common/libmondo-devices.c
r3872 r3874 55 55 extern char *call_program_and_get_last_line_of_output(const char *); 56 56 57 static char g_cd rw_drive_is_here[MAX_STR_LEN / 4] = "";57 static char g_cd_drive_is_here[MAX_STR_LEN / 4] = ""; 58 58 static char g_cdrom_drive_is_here[MAX_STR_LEN / 4] = ""; 59 59 static char g_dvd_drive_is_here[MAX_STR_LEN / 4] = ""; … … 105 105 if (strlen(g_dvd_drive_is_here) > 0) { 106 106 inject_device(g_dvd_drive_is_here); 107 }108 if (strlen(g_cdrw_drive_is_here) > 0) {109 inject_device(g_cdrw_drive_is_here);110 107 } 111 108 } … … 188 185 case cdr: 189 186 strcpy(output, "cdr"); 190 break;191 case cdrw:192 strcpy(output, "cdrw");193 187 break; 194 188 case cdstream: … … 501 495 } 502 496 return (res); 503 }504 505 506 507 508 509 510 /**511 * Locate a CD-R/W writer's SCSI node.512 * @param cdrw_device SCSI node will be placed here.513 * @return 0 for success, nonzero for failure.514 */515 int find_cdrw_device(char *cdrw_device)516 {517 /*@ buffers ************************ */518 char *tmp = NULL;519 char *cdr_exe = NULL;520 char *command = NULL;521 522 if (g_cdrw_drive_is_here[0]) {523 strcpy(cdrw_device, g_cdrw_drive_is_here);524 log_msg(3, "Been there, done that. Returning %s", cdrw_device);525 return (0);526 }527 if (g_backup_media_type == dvd) {528 log_msg(1, "This is dumb. You're calling find_cdrw_device() but you're backing up to DVD. WTF?");529 return (1);530 }531 run_program_and_log_output("insmod ide-scsi", -1);532 if ((cdr_exe = find_home_of_exe("cdrecord")) == NULL) {533 if ((cdr_exe = find_home_of_exe("wodim")) == NULL) {534 cdr_exe = find_home_of_exe("dvdrecord");535 }536 }537 if (cdr_exe != NULL) {538 mr_asprintf(command, "%s -scanbus 2> /dev/null | tr -s '\t' ' ' | grep \"[0-9]*,[0-9]*,[0-9]*\" | grep -v \"[0-9]*) \\*\" | grep -E '[D|C][V|D]' | cut -d' ' -f2 | head -n1", cdr_exe);539 tmp = call_program_and_get_last_line_of_output(command);540 mr_free(command);541 }542 if ((tmp == NULL) || (strlen(tmp) < 2)) {543 mr_free(tmp);544 mr_free(cdr_exe);545 return (1);546 } else {547 strcpy(cdrw_device, tmp);548 log_it("Found CDRW device - %s", cdrw_device);549 strcpy(g_cdrw_drive_is_here, cdrw_device);550 mr_free(tmp);551 mr_free(cdr_exe);552 return (0);553 }554 497 } 555 498 … … 786 729 (found_it = 787 730 set_dev_to_this_if_rx_OK(output, 788 g_cd rw_drive_is_here)))731 g_cd_drive_is_here))) 789 732 { 790 733 retval = 1; … … 837 780 } 838 781 839 mr_asprintf(command, "%s -scanbus | grep \"[0-9],[0-9],[0-9]\" | grep -E \"[D|C][V|D]\" | grep -n \"\" | grep \"%s\" | cut -d':' -f2", cdr_exe, g_cd rw_drive_is_here);782 mr_asprintf(command, "%s -scanbus | grep \"[0-9],[0-9],[0-9]\" | grep -E \"[D|C][V|D]\" | grep -n \"\" | grep \"%s\" | cut -d':' -f2", cdr_exe, g_cd_drive_is_here); 840 783 841 784 log_msg(1, "command=%s", command); … … 2249 2192 switch (bkpinfo->backup_media_type) { 2250 2193 case cdr: 2251 case cdrw:2252 2194 case dvd: 2253 2195 case usb: … … 2338 2280 log_msg(2, "%s device found at %s", mds, bkpinfo->media_device); 2339 2281 } else { 2340 if ((find_cdr w_device(bkpinfo->media_device)) && (bkpinfo->backup_media_type != usb)) {2282 if ((find_cdrom_device(bkpinfo->media_device)) && (bkpinfo->backup_media_type != usb)) { 2341 2283 mr_free(bkpinfo->media_device); 2342 2284 }
Note:
See TracChangeset
for help on using the changeset viewer.