Changeset 3870 in MondoRescue
- Timestamp:
- Mar 7, 2024, 6:05:50 PM (14 months ago)
- Location:
- branches/3.3/mondo/src/common
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/3.3/mondo/src/common/libmondo-archive.c
r3868 r3870 27 27 #include "libmondo-tools-EXT.h" 28 28 #include "libmondo-verify-EXT.h" 29 #include "lib-common-externs.h" 29 30 30 #include <sys/sem.h> 31 31 #include <sys/types.h> … … 2527 2527 char *mds = NULL; 2528 2528 2529 malloc_string(cdrom_dev);2530 2529 malloc_string(cdrw_dev); 2531 2530 … … 2542 2541 gotos_make_me_puke: 2543 2542 ok_go_ahead_burn_it = TRUE; 2544 if (!find_cdrom_device(cdrom_dev, FALSE)) { 2543 mr_free(cdrom_dev); 2544 if ((cdrom_dev = find_cdrom_device()) != NULL) { 2545 2545 /* When enabled, it made CD eject-and-retract when wrong CD inserted.. Weird 2546 2546 log_msg(2, "paafcd: Retracting CD-ROM drive if possible" ); … … 2632 2632 mr_free(mds); 2633 2633 2634 paranoid_free(cdrom_dev);2634 mr_free(cdrom_dev); 2635 2635 paranoid_free(cdrw_dev); 2636 2636 mr_free(mtpt); … … 3044 3044 int res = 0; 3045 3045 3046 malloc_string(tmp);3047 3048 3046 assert(bkpinfo != NULL); 3049 3047 orig_vfy_flag_val = bkpinfo->verify_data; … … 3105 3103 && (bkpinfo->backup_media_type == cdr 3106 3104 || bkpinfo->backup_media_type == cdrw)) { 3107 if (find_cdrom_device(tmp, FALSE)) // make sure find_cdrom_device() finds, records CD-R's loc 3108 { 3105 if ((tmp = find_cdrom_device()) == NULL) { // make sure find_cdrom_device() finds, records CD-R's loc 3109 3106 log_msg(3, "*Sigh* Mike, I hate your computer."); 3110 3107 // if it can't be found then force pausing … … 3113 3110 log_msg(3, "Great. Found Mike's CD-ROM drive."); 3114 3111 } 3112 mr_free(tmp); 3115 3113 } 3116 3114 if (bkpinfo->verify_data && !res) { … … 3167 3165 3168 3166 bkpinfo->verify_data = orig_vfy_flag_val; 3169 paranoid_free(tmp);3170 3167 return (0); 3171 3168 } … … 3217 3214 g_current_media_number = cdno; 3218 3215 if (bkpinfo->backup_media_type != iso) { 3219 find_cdrom_device(bkpinfo->media_device, FALSE); // replace 0,0,0 with /dev/cdrom 3216 mr_free(bkpinfo->media_device); 3217 bkpinfo->media_device = find_cdrom_device(); // replace 0,0,0 with /dev/cdrom 3220 3218 } 3221 3219 if (chdir("/")) { -
branches/3.3/mondo/src/common/libmondo-cli.c
r3866 r3870 16 16 #include "mondostructures.h" 17 17 #include "libmondo-cli-EXT.h" 18 #include "libmondo-newt-specific-EXT.h" 18 19 #include "libmondo.h" 19 20 … … 45 46 extern pid_t g_main_pid; 46 47 extern char *resolve_softlinks_to_get_to_actual_device_file(char *); 47 extern char *mr_popup_and_get_string(const char *, const char *, const char *);48 48 extern char *call_program_and_get_last_line_of_output(const char *); 49 49 … … 294 294 295 295 if ((flag_set['c'] || flag_set['w'] || flag_set['C'] || flag_set['r']) && (! bkpinfo->restore_data)) { 296 if (!flag_set['r'] && g_kernel_version <= 2.5 && strstr(flag_val['d'], "/dev/")) {297 fatal_error("Please don't give a /dev entry. Give a SCSI node for the parameter of the -d flag.");298 }299 if (flag_set['r'] && g_kernel_version <= 2.5 && !strstr(flag_val['d'], "/dev/")) {300 fatal_error("Please give a /dev entry, not a SCSI node, as the parameter of the -d flag.");301 }302 if (g_kernel_version >= 2.6 && !strstr(flag_val['d'], "/dev/")) {303 log_to_screen("Linus says 2.6 has a broken ide-scsi module. Proceed at your own risk...");304 }305 306 296 if (system("which cdrecord > /dev/null 2> /dev/null") && system("which dvdrecord > /dev/null 2> /dev/null")) { 307 297 fatal_error("Please install dvdrecord/cdrecord and try again."); … … 336 326 if ((flag_set['t'] && !flag_set['d']) && (! bkpinfo->restore_data)) { 337 327 log_it("Hmm! No tape drive specified. Let's see what we can do."); 338 if ( find_tape_device(flag_val['d'])) {339 fatal_error("Tape device not specified . I couldn't find it either.");328 if ((bkpinfo->media_device = find_tape_device()) == NULL) { 329 fatal_error("Tape device not specified and I couldn't find it either. Please use option -d"); 340 330 } 341 331 flag_set['d'] = TRUE; 342 log_to_screen("You didn't specify a tape streamer device. I'm assuming %s", flag_val['d']);332 log_to_screen("You didn't specify a tape streamer device. I'm assuming %s", bkpinfo->media_device); 343 333 } 344 334 … … 359 349 } 360 350 if (!flag_set['d']) { 361 if ( !find_dvd_device(flag_val['d'])) {351 if ((bkpinfo->media_device = find_dvd_device()) != NULL) { 362 352 flag_set['d'] = TRUE; 363 log_to_screen("I guess DVD drive is at %s", flag_val['d']);364 } 365 } 366 if (strchr( flag_val['d'], ',')) {353 log_to_screen("I guess DVD drive is at %s", bkpinfo->media_device); 354 } 355 } 356 if (strchr(bkpinfo->media_device, ',')) { 367 357 fatal_error("Please don't give a SCSI node. Give a _device_, preferably a /dev entry, for the parameter of the -d flag."); 368 358 } … … 686 676 if (flag_set['d']) { /* backup directory (if ISO/NETFS) */ 687 677 if (flag_set['i']) { 678 // what is flag_val['d'] is NULL/undefined 688 679 mr_asprintf(bkpinfo->isodir, "%s", flag_val['d']); 689 680 mr_asprintf(tmp1, "ls -l %s", bkpinfo->isodir); … … 695 686 } else if (flag_set['n']) { 696 687 mr_free(bkpinfo->netfs_remote_dir); 688 // what is flag_val['d'] is NULL/undefined 697 689 mr_asprintf(bkpinfo->netfs_remote_dir, "%s", flag_val['d']); 698 690 } else { /* backup device (if tape/CD-R/CD-RW) */ 699 mr_asprintf(bkpinfo->media_device, "%s", flag_val['d']);691 /* bkpinfo-> media_device already setup upper */ 700 692 } 701 693 } … … 720 712 721 713 if (!flag_set['d'] && (flag_set['c'] || flag_set['w'] || flag_set['C'])) { 722 if (g_kernel_version >= 2.6) {723 714 tmp1 = mr_popup_and_get_string("Device", "Please specify the device", bkpinfo->media_device); 724 715 if (tmp1 == NULL) { … … 729 720 bkpinfo->media_device = tmp1; 730 721 } 731 } else if (find_cdrw_device(bkpinfo->media_device)) {732 retval++;733 log_to_screen("Tried and failed to find CD-R[W] drive automatically.\n");734 722 } else { 735 flag_set['d'] = TRUE;736 strncpy(flag_val['d'], bkpinfo->media_device, MAX_STR_LEN / 4);737 }738 723 } 739 724 -
branches/3.3/mondo/src/common/libmondo-devices.c
r3867 r3870 15 15 #include "mr_str.h" 16 16 #include "mondostructures.h" 17 #include "lib-common-externs.h" 17 18 18 #include "libmondo-files-EXT.h" 19 19 #include "libmondo-string-EXT.h" … … 22 22 #include "libmondo-fork-EXT.h" 23 23 #include "libmondo-stream-EXT.h" 24 #include "libmondo-newt-specific-EXT.h" 24 25 25 26 #ifdef __FreeBSD__ … … 52 53 extern void setup_tmpdir(char *path); 53 54 extern void setup_scratchdir(char *path); 54 extern char *mr_popup_and_get_string(const char *title, const char *b, const char *input);55 55 extern char *call_program_and_get_last_line_of_output(const char *); 56 56 … … 467 467 /*@ int's ****************************************************** */ 468 468 int res; 469 char *dev = NULL;470 469 471 470 /*@ end vars **************************************************** */ 472 471 473 malloc_string(dev);474 472 assert(bkpinfo != NULL); 475 473 assert_string_is_neither_NULL_nor_zerolength(mountpoint); 476 474 477 475 if (g_backup_media_type == dvd) { 478 strcpy(dev, g_dvd_drive_is_here); 479 if (!dev[0]) { 480 find_dvd_device(dev); 476 if (bkpinfo->media_device == NULL) { 477 bkpinfo->media_device = find_dvd_device(); 481 478 } 482 479 } else { 483 strcpy(dev, g_cdrom_drive_is_here); 484 if (!dev[0]) { 485 find_cdrom_device(dev, FALSE); 480 if (bkpinfo->media_device == NULL) { 481 bkpinfo->media_device = find_cdrom_device(); 486 482 } 487 483 } … … 491 487 } 492 488 493 if (!dev[0] || (res = mount_CDROM_here(dev, mountpoint))) { 494 if (!popup_and_get_string("CD-ROM device", "Please enter your CD-ROM's /dev device", dev,(MAX_STR_LEN / 4)-1)) { 489 if ((bkpinfo->media_device == NULL) || (res = mount_CDROM_here(bkpinfo->media_device, mountpoint))) { 490 mr_free(bkpinfo->media_device); 491 if ((bkpinfo->media_device = mr_popup_and_get_string("CD-ROM device", "Please enter your CD-ROM's /dev device", "/dev/cdrom")) == NULL) { 495 492 res = 1; 496 493 } else { 497 res = mount_CDROM_here( dev, mountpoint);494 res = mount_CDROM_here(bkpinfo->media_device, mountpoint); 498 495 } 499 496 } … … 501 498 log_msg(1, "mount failed"); 502 499 } else { 503 log_msg(1, "mount succeeded with %s", dev); 504 } 505 paranoid_free(dev); 500 log_msg(1, "mount succeeded with %s", bkpinfo->media_device); 501 } 506 502 return (res); 507 503 } … … 867 863 } 868 864 869 870 int find_dvd_device(char *output) 865 /* 866 * This function tries to find an optical media device 867 * and return it's device file to the caller that needs to free it 868 */ 869 char *find_dvd_device() 871 870 { 872 871 char *tmp = NULL; … … 874 873 int retval = 0, devno = -1; 875 874 876 if (g_dvd_drive_is_here[0]) { 877 strcpy(output, g_dvd_drive_is_here); 878 log_msg(3, "Been there, done that. Returning %s", output); 879 return (0); 880 } 881 882 mr_asprintf(tmp1, "cdrecord -inq dev=%s 2> /dev/null | grep -E 'Device seems to be' | cut -d':' -f2", output); 875 if (bkpinfo->media_device != NULL) { 876 log_msg(3, "Been there, done that. Returning %s", bkpinfo->media_device); 877 return (bkpinfo->media_device); 878 } 879 880 mr_asprintf(tmp1, "cdrecord -inq 2> /dev/null | grep -E '^Detected ' | cut -d':' -f2"); 883 881 tmp = call_program_and_get_last_line_of_output(tmp1); 884 882 mr_free(tmp1); 885 log_msg(5, "cdrecord tmp = '%s'", tmp); 886 mr_free(tmp); 883 log_msg(5, "find_dvd_device found device '%s'", tmp); 887 884 888 885 if (tmp != NULL) { 889 strcpy(g_dvd_drive_is_here, output); 890 log_msg(2, "I think DVD is at %s", output); 886 log_msg(2, "I think DVD is at %s", bkpinfo->media_device); 891 887 } else { 892 888 log_msg(2, "I cannot find DVD"); 893 retval = 1;894 }895 return( retval);889 } 890 bkpinfo->media_device = tmp; 891 return(bkpinfo->media_device); 896 892 } 897 893 … … 2358 2354 case tape: 2359 2355 2360 if ((!bkpinfo->restore_mode) && (find_tape_device(bkpinfo->media_device))) { 2361 log_msg(3, "Ok, using vanilla scsi tape."); 2362 mr_asprintf(bkpinfo->media_device, "%s", VANILLA_SCSI_TAPE); 2363 if ((fin = fopen(bkpinfo->media_device, "r"))) { 2364 paranoid_fclose(fin); 2365 } else { 2366 mr_asprintf(bkpinfo->media_device, "%s", "/dev/osst0"); 2367 } 2368 } 2356 bkpinfo->media_device = find_tape_device(); 2369 2357 if (bkpinfo->media_device != NULL) { 2370 2358 if ((fin = fopen(bkpinfo->media_device, "r"))) { … … 2384 2372 } 2385 2373 if (bkpinfo->media_device == NULL) { 2386 tmp2 = mr_popup_and_get_string("Device name?", "What is the /dev entry of your tape streamer?", bkpinfo->media_device);2374 tmp2 = mr_popup_and_get_string("Device name?", "What is the /dev entry of your tape streamer?", ""); 2387 2375 if (tmp2 == NULL) { 2388 2376 log_to_screen("User has chosen not to backup the machine"); 2389 2377 finish(1); 2390 2378 } else { 2391 mr_free(bkpinfo->media_device);2392 2379 bkpinfo->media_device = tmp2; 2393 2380 } … … 2421 2408 log_msg(4, "media_size = %ld", bkpinfo->media_size); 2422 2409 2423 bkpinfo->use_obdr = ask_me_yes_or_no 2424 ("Do you want to activate OBDR support for your tapes ?"); 2410 bkpinfo->use_obdr = ask_me_yes_or_no("Do you want to activate OBDR support for your tapes ?"); 2425 2411 if (bkpinfo->use_obdr) { 2426 2412 log_msg(4, "obdr mode = TRUE"); -
branches/3.3/mondo/src/common/libmondo-stream-EXT.h
r3860 r3870 5 5 extern int closein_tape(); 6 6 extern int closeout_tape(); 7 extern int find_tape_device(char *dev);7 extern char *find_tape_device(void); 8 8 extern void insist_on_this_tape_number(int tapeno); 9 9 extern void log_tape_pos(void); -
branches/3.3/mondo/src/common/libmondo-stream.c
r3868 r3870 16 16 #include "mr_file.h" 17 17 #include "mondostructures.h" 18 #include "lib-common-externs.h" 18 19 19 #include "libmondo-string-EXT.h" 20 20 #include "libmondo-files-EXT.h" … … 299 299 300 300 /** 301 * Determine the name and size of the tape device. Tries the SCSI tape for 302 * this platform, then the IDE tape, then "/dev/st0", then "/dev/osst0". 303 * @param dev Where to put the found tape device. Allocated dynamically by caller or reallocated here 304 * @param siz Where to put the tape size (a string like "4GB") 305 * @return 0 if success, nonzero if failure (in which @p dev and @p siz are undefined). 306 */ 307 int find_tape_device(char *dev) { 301 * Determine the name of the tape device. Tries the SCSI tape for 302 * this platform, then "/dev/st0", then "/dev/ht0" and "/dev/osst0". 303 * @return the value of the tape device or NULL if not found. Allocated dynamically must be freed by caller. 304 */ 305 char *find_tape_device(void) { 308 306 char *tmp = NULL; 307 char *dev = NULL; 309 308 char *command = NULL; 310 char *cdr_exe = NULL;311 int res;312 309 313 310 log_to_screen("I am looking for your tape streamer. Please wait."); 314 mr_free(dev); 315 if ((cdr_exe = find_home_of_exe("cdrecord")) != NULL) { 316 if ((cdr_exe = find_home_of_exe("wodim")) != NULL) { 317 cdr_exe = find_home_of_exe("dvdrecord"); 318 } 319 } 320 mr_asprintf(command, "%s -scanbus 2> /dev/null | grep -i tape | wc -l", cdr_exe); 321 tmp = call_program_and_get_last_line_of_output(command); 322 mr_free(command); 323 324 if (atoi(tmp) != 1) { 325 log_it("Either too few or too many tape streamers for me to detect..."); 311 312 tmp = find_home_of_exe("lsscsi"); 313 if (tmp != NULL) { 314 mr_asprintf(command, "%s | grep ' tape' | awk '{print $NF}' | head -1", tmp); 315 dev = call_program_and_get_last_line_of_output(command); 316 mr_free(command); 317 } 318 mr_free(tmp); 319 320 if (dev != NULL) && does_file_exist(dev) { 321 if (mt_says_tape_exists(dev)) { 322 log_it("find_tape_device found %s automatically", dev); 323 } 324 } else { 325 /* trying something else then */ 326 326 mr_asprintf(dev, "%s", VANILLA_SCSI_TAPE); 327 mr_free(tmp);328 mr_free(cdr_exe);329 return 1;330 }331 mr_free(tmp);332 333 mr_asprintf(command, "%s -scanbus 2> /dev/null | tr -s '\t' ' ' | grep \"[0-9]*,[0-9]*,[0-9]*\" | grep -v \"[0-9]*) \\*\" | grep -i TAPE | cut -d' ' -f2 | head -n1", cdr_exe);334 tmp = call_program_and_get_last_line_of_output(command);335 mr_free(command);336 337 if (strlen(tmp) < 2) {338 log_it("Could not find tape device");339 mr_free(cdr_exe);340 mr_free(tmp);341 return 1;342 }343 mr_asprintf(command, "%s -scanbus 2> /dev/null | tr -s '\t' ' ' | grep \"[0-9]*,[0-9]*,[0-9]*\" | grep -v \"[0-9]*) \\*\" | grep -i TAPE | cut -d' ' -f3 | cut -d')' -f1 | head -n1", cdr_exe);344 mr_free(cdr_exe);345 346 tmp = call_program_and_get_last_line_of_output(command);347 mr_free(command);348 349 mr_asprintf(dev, "%s", VANILLA_SCSI_TAPE);350 dev[strlen(dev) - 1] = '\0';351 mr_strcat(dev, tmp); // e.g. '/dev/st0' becomes '/dev/stN'352 mr_free(tmp);353 354 res = 0;355 if (!mt_says_tape_exists(dev)) {356 mr_asprintf(dev, "%s", ALT_TAPE);357 327 if (!mt_says_tape_exists(dev)) { 358 log_it("Cannot openin %s", dev); 359 mr_asprintf(dev, "%s", "/dev/st0"); 328 mr_asprintf(dev, "%s", ALT_TAPE); 360 329 if (!mt_says_tape_exists(dev)) { 361 log_it("Cannot openin %s", dev);362 330 mr_asprintf(dev, "%s", "/dev/osst0"); 363 331 if (!mt_says_tape_exists(dev)) { 364 res++; 365 } else { 366 res = 0; 332 log_it("Unable to find a tape device on this system"); 367 333 } 368 334 } 369 335 } 370 } 371 372 if (dev) { 373 log_it("At this point, dev = %s and res = %d", dev, res); 374 } else { 375 log_it("At this point, dev is NULL and res = %d", res); 376 } 377 378 if (mt_says_tape_exists(dev)) { 379 res = 0; 380 } else { 381 log_it("Turning %s", dev); 382 mr_free(tmp); 383 mr_asprintf(tmp, "%s", (strrchr(dev, '/') != NULL) ? strrchr(dev, '/') : dev); 384 mr_asprintf(dev, "/dev/os%s", tmp); 385 log_it("...into %s", dev); 386 if (mt_says_tape_exists(dev)) { 387 res = 0; 388 } else { 389 res++; 390 } 391 } 392 log_it("res=%d; dev=%s", res, dev); 393 return (res); 336 log_it("find_tape_device found %s manually", dev); 337 } 338 339 if (dev != NULL) { 340 log_it("find_tape_device returns %s", dev); 341 } else { 342 log_it("find_tape_device found no tape on your system returning NULL"); 343 } 344 return (dev); 394 345 } 395 346
Note:
See TracChangeset
for help on using the changeset viewer.