Changeset 1086 in MondoRescue for trunk/mondo/src/common/libmondo-devices.c
- Timestamp:
- Feb 2, 2007, 11:21:27 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/mondo/src/common/libmondo-devices.c
r1079 r1086 133 133 } 134 134 135 log_msg(4, "(mount_CDROM_here --- device=%s, mountpoint=%s", device,135 mr_msg(4, "(mount_CDROM_here --- device=%s, mountpoint=%s", device, 136 136 mountpoint); 137 137 /*@ end vars *************************************************** */ … … 145 145 #endif 146 146 147 log_msg(4, command);147 mr_msg(4, command); 148 148 if (strncmp(device, "/dev/", 5) == 0) { 149 149 retract_CD_tray_and_defeat_autorun(); 150 150 } 151 151 retval = system(command); 152 log_msg(1, "system(%s) returned %d", command, retval);152 mr_msg(1, "system(%s) returned %d", command, retval); 153 153 mr_free(command); 154 154 … … 174 174 mr_asprintf(&tmp, where_is_root_mounted()); 175 175 mr_asprintf(&comment, "root is mounted at %s\n", tmp); 176 log_msg(0, comment);176 mr_msg(0, comment); 177 177 mr_free(comment); 178 178 179 log_msg(0,179 mr_msg(0, 180 180 "No, Schlomo, that doesn't mean %s is the root partition. It's just a debugging message. Relax. It's part of am_I_in_disaster_recovery_mode().", 181 181 tmp); … … 208 208 is_this_a_ramdisk = TRUE; 209 209 } 210 log_msg(1, "Is this a ramdisk? result = %d", is_this_a_ramdisk);210 mr_msg(1, "Is this a ramdisk? result = %d", is_this_a_ramdisk); 211 211 return (is_this_a_ramdisk); 212 212 } … … 291 291 #endif 292 292 293 log_msg(3, "Ejecting %s", dev);293 mr_msg(3, "Ejecting %s", dev); 294 294 res2 = run_program_and_log_output(command, 1); 295 295 mr_free(command); … … 543 543 } 544 544 if (res) { 545 log_msg(1, _("mount failed"));546 } else { 547 log_msg(1, _("mount succeeded with %s"), dev);545 mr_msg(1, _("mount failed")); 546 } else { 547 mr_msg(1, _("mount succeeded with %s"), dev); 548 548 } 549 549 mr_free(dev); … … 568 568 if (g_cdrw_drive_is_here != NULL) { 569 569 mr_asprintf(&cdrw_device, g_cdrw_drive_is_here); 570 log_msg(3, "Been there, done that. Returning %s", cdrw_device);570 mr_msg(3, "Been there, done that. Returning %s", cdrw_device); 571 571 return(cdrw_device); 572 572 } 573 573 if (g_backup_media_type == dvd) { 574 log_msg(1,574 mr_msg(1, 575 575 "This is dumb. You're calling find_cdrw_device() but you're backing up to DVD. WTF?"); 576 576 return(NULL); … … 652 652 if ((g_cdrom_drive_is_here != NULL) && !isdigit(g_cdrom_drive_is_here[0])) { 653 653 mr_asprintf(&output, g_cdrom_drive_is_here); 654 log_msg(3, "Been there, done that. Returning %s", output);654 mr_msg(3, "Been there, done that. Returning %s", output); 655 655 return(output); 656 656 } 657 657 if ((the_last_place_i_found_it != NULL) && !try_to_mount) { 658 658 mr_asprintf(&output, the_last_place_i_found_it); 659 log_msg(3,659 mr_msg(3, 660 660 "find_cdrom_device() --- returning last found location - '%s'", 661 661 output); … … 674 674 if (!tmp) { 675 675 mr_asprintf(&output, "/dev/cdrom"); 676 log_msg(4, "Can't find cdrecord; assuming %s", output);676 mr_msg(4, "Can't find cdrecord; assuming %s", output); 677 677 if (!does_device_exist(output)) { 678 log_msg(4, "That didn't work. Sorry.");678 mr_msg(4, "That didn't work. Sorry."); 679 679 mr_free(cdr_exe); 680 680 mr_free(output); … … 690 690 fin = popen(command, "r"); 691 691 if (!fin) { 692 log_msg(4, "command=%s", command);692 mr_msg(4, "command=%s", command); 693 693 log_OS_error("Cannot popen command"); 694 694 mr_free(cdr_exe); … … 730 730 #ifndef __FreeBSD__ 731 731 if (strlen(phrase_two) == 0) { 732 log_msg(4, "Not running phase two. String is empty.");732 mr_msg(4, "Not running phase two. String is empty."); 733 733 } else { 734 734 mr_asprintf(&command, "dmesg | grep \"%s\" 2> /dev/null", phrase_two); 735 735 fin = popen(command, "r"); 736 736 if (!fin) { 737 log_msg(4, "Cannot run 2nd command - non-fatal, fortunately");737 mr_msg(4, "Cannot run 2nd command - non-fatal, fortunately"); 738 738 } else { 739 739 for (mr_getline(&tmp, &n, fin); !feof(fin); 740 740 mr_getline(&tmp, &n, fin)) { 741 log_msg(5, "--> '%s'", tmp);741 mr_msg(5, "--> '%s'", tmp); 742 742 if (tmp[0] != ' ' && tmp[1] != ' ') { 743 743 p = strchr(tmp, ':'); … … 747 747 mr_free(dvd_last_resort); 748 748 mr_asprintf(&dvd_last_resort, "/dev/%s", tmp); 749 log_msg(4,749 mr_msg(4, 750 750 "Ignoring '%s' because it's a DVD drive", 751 751 tmp); … … 767 767 #ifdef __FreeBSD__ 768 768 if (!found_it) { 769 log_msg(4, "OK, approach 2");769 mr_msg(4, "OK, approach 2"); 770 770 if (!(found_it = set_dev_to_this_if_rx_OK(output, "/dev/cdrom"))) { 771 771 if (! … … 804 804 if (dvd_last_resort != NULL) { 805 805 if (!found_it && strlen(dvd_last_resort) > 0) { 806 log_msg(4, "Well, I'll use the DVD - %s - as a last resort",806 mr_msg(4, "Well, I'll use the DVD - %s - as a last resort", 807 807 dvd_last_resort); 808 808 mr_free(output); … … 817 817 strrchr(output, '/') + 1); 818 818 if (system(tmp) == 0) { 819 log_msg(4,819 mr_msg(4, 820 820 "%s is not right. It's being SCSI-emulated. Continuing.", 821 821 output); … … 827 827 828 828 if (found_it) { 829 log_msg(4, "(find_cdrom_device) --> '%s'", output);829 mr_msg(4, "(find_cdrom_device) --> '%s'", output); 830 830 if (!does_device_exist(output)) { 831 log_msg(4, "OK, I was wrong, I haven't found it... yet.");831 mr_msg(4, "OK, I was wrong, I haven't found it... yet."); 832 832 found_it = FALSE; 833 833 mr_free(output); … … 836 836 837 837 if (!found_it) { 838 log_msg(4, "OK, approach 2");838 mr_msg(4, "OK, approach 2"); 839 839 if (!(found_it = set_dev_to_this_if_rx_OK(output, "/dev/scd0"))) { 840 840 if (!(found_it = set_dev_to_this_if_rx_OK(output, "/dev/sr0"))) { … … 882 882 if (found_it && try_to_mount) { 883 883 if (! mount_CDROM_here(output, mountpoint)) { 884 log_msg(4, "[Cardigans] I've changed my mind");884 mr_msg(4, "[Cardigans] I've changed my mind"); 885 885 found_it = FALSE; 886 886 mr_free(output); … … 888 888 mr_asprintf(&tmp, "%s/archives", mountpoint); 889 889 if (!does_file_exist(tmp)) { 890 log_msg(4, "[Cardigans] I'll take it back");890 mr_msg(4, "[Cardigans] I'll take it back"); 891 891 found_it = FALSE; 892 892 mr_free(output); … … 895 895 paranoid_system(command); 896 896 mr_free(command); 897 log_msg(4, "I'm confident the Mondo CD is in %s", output);897 mr_msg(4, "I'm confident the Mondo CD is in %s", output); 898 898 } 899 899 mr_free(tmp); … … 905 905 if (found_it) { 906 906 if (!does_file_exist(output)) { 907 log_msg(3, "I still haven't found it.");907 mr_msg(3, "I still haven't found it."); 908 908 mr_free(output); 909 909 return(NULL); 910 910 } 911 log_msg(3, "(find_cdrom_device) --> '%s'", output);911 mr_msg(3, "(find_cdrom_device) --> '%s'", output); 912 912 mr_asprintf(&the_last_place_i_found_it, output); 913 913 mr_free(g_cdrom_drive_is_here); … … 921 921 mr_free(cdr_exe); 922 922 923 log_msg(1, "command=%s", command);923 mr_msg(1, "command=%s", command); 924 924 mr_asprintf(&tmp, call_program_and_get_last_line_of_output(command)); 925 925 mr_free(command); … … 927 927 if (tmp[0]) { 928 928 output = tmp; 929 log_msg(4, "Finally found it at %s", output);929 mr_msg(4, "Finally found it at %s", output); 930 930 } else { 931 931 mr_free(tmp); 932 932 mr_free(output); 933 log_msg(4, "Still couldn't find it.");933 mr_msg(4, "Still couldn't find it."); 934 934 } 935 935 return(output); … … 945 945 if (g_dvd_drive_is_here != NULL) { 946 946 mr_asprintf(&output, g_dvd_drive_is_here); 947 log_msg(3, "Been there, done that. Returning %s", output);947 mr_msg(3, "Been there, done that. Returning %s", output); 948 948 return (output); 949 949 } … … 952 952 ("dvdrecord -scanbus 2> /dev/null | grep \") '\" | grep -n \"\" | grep DVD | cut -d':' -f1") 953 953 ); 954 log_msg(5, "tmp = '%s'", tmp);954 mr_msg(5, "tmp = '%s'", tmp); 955 955 if (!tmp[0]) { 956 956 mr_free(tmp); … … 969 969 mr_free(g_dvd_drive_is_here); 970 970 mr_asprintf(&g_dvd_drive_is_here, output); 971 log_msg(2, "I think DVD is at %s", output);972 } else { 973 log_msg(2, "I cannot find DVD");971 mr_msg(2, "I think DVD is at %s", output); 972 } else { 973 mr_msg(2, "I cannot find DVD"); 974 974 } 975 975 … … 1032 1032 1033 1033 if (outvalB <= 0) { 1034 log_msg(1, "Error getting size of %s: %s", drive, strerror(errno));1034 mr_msg(1, "Error getting size of %s: %s", drive, strerror(errno)); 1035 1035 #if linux 1036 1036 fileid = open(drive, O_RDONLY); … … 1041 1041 cylindersize = hdgeo.heads * hdgeo.sectors / 2; 1042 1042 outvalA = cylindersize * cylinders / 1024; 1043 log_msg(2, "Got Harddisk geometry, C:%d, H:%d, S:%d",1043 mr_msg(2, "Got Harddisk geometry, C:%d, H:%d, S:%d", 1044 1044 hdgeo.cylinders, hdgeo.heads, hdgeo.sectors); 1045 1045 gotgeo = 1; 1046 1046 } else { 1047 log_msg(1, "Harddisk geometry wrong");1047 mr_msg(1, "Harddisk geometry wrong"); 1048 1048 } 1049 1049 } else { 1050 log_msg(1,1050 mr_msg(1, 1051 1051 "Error in ioctl() getting new hard disk geometry (%s), resizing in unsafe mode", 1052 1052 strerror(errno)); … … 1054 1054 close(fileid); 1055 1055 } else { 1056 log_msg(1, "Failed to open %s for reading: %s", drive,1056 mr_msg(1, "Failed to open %s for reading: %s", drive, 1057 1057 strerror(errno)); 1058 1058 } 1059 1059 if (!gotgeo) { 1060 log_msg(1, "Failed to get harddisk geometry, using old mode");1060 mr_msg(1, "Failed to get harddisk geometry, using old mode"); 1061 1061 } 1062 1062 #endif … … 1067 1067 outvalC = (outvalA > outvalB) ? outvalA : outvalB; 1068 1068 1069 // log_msg (5, "drive = %s, error = %s", drive, strerror (errno));1069 // mr_msg (5, "drive = %s, error = %s", drive, strerror (errno)); 1070 1070 // fatal_error ("GPSOD: Unable to get size of drive"); 1071 log_msg(1, "%s --> %ld or %ld --> %ld", drive, outvalA, outvalB,1071 mr_msg(1, "%s --> %ld or %ld --> %ld", drive, outvalA, outvalB, 1072 1072 outvalC); 1073 1073 … … 1164 1164 // assert_string_is_neither_NULL_nor_zerolength(device_raw); 1165 1165 if (device_raw[0] != '/' && !strstr(device_raw, ":/")) { 1166 log_msg(1, "%s needs to have a '/' prefixed - I'll do it",1166 mr_msg(1, "%s needs to have a '/' prefixed - I'll do it", 1167 1167 device_raw); 1168 1168 mr_asprintf(&tmp, "/%s", device_raw); … … 1170 1170 mr_asprintf(&tmp, device_raw); 1171 1171 } 1172 log_msg(1, "Is %s mounted?", tmp);1172 mr_msg(1, "Is %s mounted?", tmp); 1173 1173 if (!strcmp(tmp, "/proc") || !strcmp(tmp, "proc")) { 1174 log_msg(1,1174 mr_msg(1, 1175 1175 "I don't know how the heck /proc made it into the mountlist. I'll ignore it."); 1176 1176 return (FALSE); … … 1201 1201 mr_free(device_with_space); 1202 1202 1203 log_msg(4, "tmp (command) = '%s'", tmp);1203 mr_msg(4, "tmp (command) = '%s'", tmp); 1204 1204 if (!system(tmp)) { 1205 1205 mr_free(tmp); … … 1321 1321 assert(cd_number_i_want > 0); 1322 1322 1323 // log_msg(3, "Insisting on CD number %d", cd_number_i_want);1323 // mr_msg(3, "Insisting on CD number %d", cd_number_i_want); 1324 1324 1325 1325 if (IS_THIS_A_STREAMING_BACKUP(bkpinfo->backup_media_type)) { 1326 log_msg(3,1326 mr_msg(3, 1327 1327 "No need to insist_on_this_cd_number when the backup type isn't CD-R(W) or NFS or ISO"); 1328 1328 return; … … 1335 1335 if (g_ISO_restore_mode || bkpinfo->backup_media_type == iso 1336 1336 || bkpinfo->backup_media_type == nfs) { 1337 log_msg(3, "Remounting CD");1337 mr_msg(3, "Remounting CD"); 1338 1338 g_ISO_restore_mode = TRUE; 1339 1339 // FIXME --- I'm tempted to do something about this... … … 1352 1352 cd_number_i_want); 1353 1353 if (does_file_exist(tmp)) { 1354 log_msg(1,1354 mr_msg(1, 1355 1355 "FIXME - hacking bkpinfo->isodir from '%s' to /tmp/isodir", 1356 1356 bkpinfo->isodir); … … 1358 1358 } 1359 1359 } 1360 log_msg(3, "Mounting %s at %s", tmp, MNT_CDROM);1360 mr_msg(3, "Mounting %s at %s", tmp, MNT_CDROM); 1361 1361 if (! mount_CDROM_here(tmp, MNT_CDROM)) { 1362 1362 fatal_error("Mommy!"); … … 1365 1365 } 1366 1366 if ((res = what_number_cd_is_this(bkpinfo)) != cd_number_i_want) { 1367 log_msg(3, "Currently, we hold %d but we want %d", res,1367 mr_msg(3, "Currently, we hold %d but we want %d", res, 1368 1368 cd_number_i_want); 1369 1369 mr_asprintf(&tmp, "Insisting on %s #%d", … … 1373 1373 bkpinfo->backup_media_string, 1374 1374 cd_number_i_want); 1375 log_msg(3, tmp);1375 mr_msg(3, tmp); 1376 1376 mr_free(tmp); 1377 1377 … … 1403 1403 mr_free(request); 1404 1404 1405 log_msg(1, "Thankyou. Proceeding...");1405 mr_msg(1, "Thankyou. Proceeding..."); 1406 1406 g_current_media_number = cd_number_i_want; 1407 1407 } … … 1452 1452 } 1453 1453 bkpinfo->backup_media_string = bkptype_to_string(bkpinfo->backup_media_type); 1454 log_msg(3, "media type = %s",bkpinfo->backup_media_string);1454 mr_msg(3, "media type = %s",bkpinfo->backup_media_string); 1455 1455 1456 1456 if (archiving_to_media) { … … 1490 1490 mr_asprintf(&tmp, "1"); 1491 1491 mr_asprintf(&sz_size, "%d", DEFAULT_DVD_DISK_SIZE); // 4.7 salesman's GB = 4.482 real GB = 4582 MB 1492 log_msg(1, "Setting to DVD defaults");1492 mr_msg(1, "Setting to DVD defaults"); 1493 1493 } else if (bkpinfo->backup_media_type == usb) { 1494 1494 strcpy(bkpinfo->media_device, VANILLA_USB_DEVICE); … … 1498 1498 mr_asprintf(&tmp, "4"); 1499 1499 mr_asprintf(&sz_size, "650"); 1500 log_msg(1, "Setting to CD defaults");1500 mr_msg(1, "Setting to CD defaults"); 1501 1501 } 1502 1502 if ((bkpinfo->backup_media_type != dvd) && (bkpinfo->backup_media_type != usb)) { … … 1534 1534 if (bkpinfo->disaster_recovery) { 1535 1535 mr_allocstr(bkpinfo->media_device, "/dev/cdrom"); 1536 log_msg(2, "CD-ROM device assumed to be at %s",1536 mr_msg(2, "CD-ROM device assumed to be at %s", 1537 1537 bkpinfo->media_device); 1538 1538 } else if (bkpinfo->restore_data … … 1541 1541 mr_asprintf(&bkpinfo->media_device, "/dev/cdrom"); 1542 1542 } // just for the heck of it :) 1543 log_msg(1, "bkpinfo->media_device = %s",1543 mr_msg(1, "bkpinfo->media_device = %s", 1544 1544 bkpinfo->media_device); 1545 1545 tmp = find_cdrom_device(FALSE); … … 1547 1547 || (tmp != NULL)) { 1548 1548 mr_allocstr(bkpinfo->media_device, tmp); 1549 log_msg(1, "bkpinfo->media_device = %s",1549 mr_msg(1, "bkpinfo->media_device = %s", 1550 1550 bkpinfo->media_device); 1551 1551 mr_asprintf(&comment, … … 1561 1561 mr_free(tmp); 1562 1562 1563 log_msg(2, "%s device found at %s",1563 mr_msg(2, "%s device found at %s", 1564 1564 bkpinfo->backup_media_string, 1565 1565 bkpinfo->media_device); … … 1607 1607 mr_free(bkpinfo->media_device); 1608 1608 if (find_tape_device_and_size(bkpinfo->media_device, sz_size)) { 1609 log_msg(3, _("Ok, using vanilla scsi tape."));1609 mr_msg(3, _("Ok, using vanilla scsi tape.")); 1610 1610 mr_allocstr(bkpinfo->media_device,VANILLA_SCSI_TAPE"0" ); 1611 1611 if ((fin = fopen(bkpinfo->media_device, "r"))) { … … 1647 1647 } 1648 1648 mr_free(tmp); 1649 log_msg(4, "sz_size = %s", sz_size);1649 mr_msg(4, "sz_size = %s", sz_size); 1650 1650 mr_free(sz_size); 1651 1651 bkpinfo->media_size[0] = 0; 1652 log_msg(4, "media_size[0] = %ld", bkpinfo->media_size[0]);1652 mr_msg(4, "media_size[0] = %ld", bkpinfo->media_size[0]); 1653 1653 if (bkpinfo->media_size[0] <= 0) { 1654 1654 bkpinfo->media_size[0] = 0; … … 1781 1781 finish(1); 1782 1782 } 1783 log_msg(3, "prefix set to %s", bkpinfo->prefix);1783 mr_msg(3, "prefix set to %s", bkpinfo->prefix); 1784 1784 1785 1785 for (i = 0; i <= MAX_NOOF_MEDIA; i++) { 1786 1786 bkpinfo->media_size[i] = 650; 1787 1787 } 1788 log_msg(3, "Just set nfs_remote_dir to %s",1788 mr_msg(3, "Just set nfs_remote_dir to %s", 1789 1789 bkpinfo->nfs_remote_dir); 1790 log_msg(3, "isodir is still %s", bkpinfo->isodir);1790 mr_msg(3, "isodir is still %s", bkpinfo->isodir); 1791 1791 break; 1792 1792 … … 1828 1828 finish(1); 1829 1829 } 1830 log_msg(3, "prefix set to %s", bkpinfo->prefix);1830 mr_msg(3, "prefix set to %s", bkpinfo->prefix); 1831 1831 break; 1832 1832 default: … … 1974 1974 #else 1975 1975 if (bkpinfo->backup_media_type == nfs) { 1976 log_msg(3, "I think the NFS mount is mounted at %s",1976 mr_msg(3, "I think the NFS mount is mounted at %s", 1977 1977 bkpinfo->isodir); 1978 1978 } … … 1997 1997 fatal_error("Media size is less than zero."); 1998 1998 } else { 1999 log_msg(2, "Warning - media size is less than zero.");1999 mr_msg(2, "Warning - media size is less than zero."); 2000 2000 bkpinfo->media_size[0] = 0; 2001 2001 } … … 2092 2092 return (FALSE); 2093 2093 } 2094 log_msg(10, "Injecting %s", dev);2094 mr_msg(10, "Injecting %s", dev); 2095 2095 inject_device(dev); 2096 2096 if (!does_file_exist(dev)) { 2097 log_msg(10, "%s doesn't exist. Returning FALSE.", dev);2097 mr_msg(10, "%s doesn't exist. Returning FALSE.", dev); 2098 2098 return (FALSE); 2099 2099 } … … 2103 2103 && !run_program_and_log_output(command, FALSE)) { 2104 2104 mr_asprintf(&output, dev); 2105 log_msg(4, "Found it - %s", dev);2105 mr_msg(4, "Found it - %s", dev); 2106 2106 mr_free(command); 2107 2107 return (TRUE); 2108 2108 } else { 2109 log_msg(4, "It's not %s", dev);2109 mr_msg(4, "It's not %s", dev); 2110 2110 mr_free(command); 2111 2111 return (FALSE); … … 2365 2365 lstat(curr_fname, &statbuf); 2366 2366 while (S_ISLNK(statbuf.st_mode)) { 2367 log_msg(1, "curr_fname = %s", curr_fname);2367 mr_msg(1, "curr_fname = %s", curr_fname); 2368 2368 mr_asprintf(&command, "file %s", curr_fname); 2369 2369 tmp = call_program_and_get_last_line_of_output(command); … … 2376 2376 for (p = scratch; *p != '\0' && *p != '\''; p++); 2377 2377 *p = '\0'; 2378 log_msg(0, "curr_fname %s --> '%s' --> %s", curr_fname, tmp, scratch);2378 mr_msg(0, "curr_fname %s --> '%s' --> %s", curr_fname, tmp, scratch); 2379 2379 mr_free(tmp); 2380 2380 … … 2419 2419 char *fdisk = NULL; 2420 2420 2421 log_msg(0, "Looking for partition table format type");2421 mr_msg(0, "Looking for partition table format type"); 2422 2422 mr_asprintf(&fdisk, "/sbin/parted2fdisk"); 2423 log_msg(1, "Using %s", fdisk);2423 mr_msg(1, "Using %s", fdisk); 2424 2424 mr_asprintf(&command, "%s -l %s | grep 'EFI GPT'", fdisk, drive); 2425 2425 mr_free(fdisk); … … 2434 2434 } 2435 2435 mr_free(tmp); 2436 log_msg(0, "Found %s partition table format type", output);2436 mr_msg(0, "Found %s partition table format type", output); 2437 2437 return (output); 2438 2438 }
Note:
See TracChangeset
for help on using the changeset viewer.