| 36 | | use vars qw(@pci_adapters @chip_ids @undetectable_adapters); |
| 37 | | |
| 38 | | @undetectable_adapters = ( "i2c-elektor","i2c-elv", "i2c-philips-par", |
| 39 | | "i2c-velleman" ); |
| | 36 | use vars qw(@pci_adapters @chip_ids @undetectable_adapters @dmidecode); |
| | 37 | |
| | 38 | @dmidecode = ( '/usr/local/sbin/dmidecode', '/usr/sbin/dmidecode' ); |
| | 39 | |
| | 40 | @undetectable_adapters = ( 'i2c-elektor', 'i2c-elv', 'i2c-philips-par', |
| | 41 | 'i2c-velleman' ); |
| | 2772 | sub safe_system_vendor |
| | 2773 | { |
| | 2774 | if ($> != 0) |
| | 2775 | { |
| | 2776 | print " As you are not root, we can't run dmidecode to determine your system vendor.\n"; |
| | 2777 | return 0; |
| | 2778 | } |
| | 2779 | |
| | 2780 | my $opened = 0; |
| | 2781 | foreach my $dmidecode (@dmidecode) |
| | 2782 | { |
| | 2783 | last if (-r $dmidecode && ($opened = open (DMI, "$dmidecode |"))); |
| | 2784 | } |
| | 2785 | |
| | 2786 | unless ($opened) |
| | 2787 | { |
| | 2788 | print " Could not find dmidecode, which should have been installed with lm_sensors.\n", |
| | 2789 | " Runing dmidecode would help us determining your system vendor, which allows\n", |
| | 2790 | " safer operations. Please provide one of the following:\n "; |
| | 2791 | print join ("\n ", @dmidecode); |
| | 2792 | print "\nYou can still go on, but you are encouraged to fix the problem first.\n"; |
| | 2793 | return 0; |
| | 2794 | } |
| | 2795 | |
| | 2796 | my $line; |
| | 2797 | while (<DMI>) |
| | 2798 | { |
| | 2799 | next unless m/System Information Block/; |
| | 2800 | $line = <DMI>; |
| | 2801 | last; |
| | 2802 | } |
| | 2803 | close (DMI); |
| | 2804 | |
| | 2805 | if ((defined $line) && ($line =~ m/^\s*Vendor: (.*)$/) && ($1 !~ /^\s*$/)) |
| | 2806 | { |
| | 2807 | my $vendor = $1; |
| | 2808 | $vendor =~ s/\s*$//; |
| | 2809 | print " System vendor: $vendor\n"; |
| | 2810 | if ($vendor =~ /\bIBM\b/) |
| | 2811 | { |
| | 2812 | print " Sorry, we won't let you go on. IBM systems are known to have serious\n", |
| | 2813 | " problems with lm_sensors, resulting in hardware failures.\n"; |
| | 2814 | exit; |
| | 2815 | } |
| | 2816 | return 1; |
| | 2817 | } |
| | 2818 | |
| | 2819 | print " Could not determine system vendor, due to some problem with dmidecode. Please\n", |
| | 2820 | " have it fixed, we use it for safer operations.\n". |
| | 2821 | return 0; |
| | 2822 | } |
| | 2823 | |
| 2798 | | print " IF THIS IS AN IBM THINKPAD, PRESS CTRL-C NOW!\n"; |
| 2799 | | print " IBM Thinkpads have a severely broken i2c/SMBus implementation, "; |
| 2800 | | print " just scanning\n"; |
| 2801 | | print " the bus will break your thinkpad forever!\n\n"; |
| | 2852 | unless (safe_system_vendor ()) |
| | 2853 | { |
| | 2854 | print " IF THIS IS AN IBM THINKPAD, PRESS CTRL-C NOW!\n"; |
| | 2855 | print " IBM Thinkpads have a severely broken i2c/SMBus implementation, "; |
| | 2856 | print "just scanning\n"; |
| | 2857 | print " the bus will break your Thinkpad forever!\n"; |
| | 2858 | print " If this is a non-Thinkpad IBM, we still suggest you press CTRL+C. We have\n"; |
| | 2859 | print " had users reporting system breakage on other IBM systems as well.\n\n"; |
| | 2860 | } |