package detect_devices; # $Id$
use diagnostics;
use strict;
use vars qw($pcitable_addons $usbtable_addons);
#-######################################################################################
#- misc imports
#-######################################################################################
use log;
use common;
use devices;
use run_program;
use modules;
use c;
#-#####################################################################################
#- Globals
#-#####################################################################################
my %serialprobe;
#-######################################################################################
#- Functions
#-######################################################################################
sub dev_is_devfs() { -e "/dev/.devfsd" } #- no $::prefix, returns false during install and that's nice :)
sub get() {
#- Detect the default BIOS boot harddrive is kind of tricky. We may have IDE,
#- SCSI and RAID devices on the same machine. From what I see so far, the default
#- BIOS boot harddrive will be
#- 1. The first IDE device if IDE exists. Or
#- 2. The first SCSI device if SCSI exists. Or
#- 3. The first RAID device if RAID exists.
getIDE(), getSCSI(), getDAC960(), getCompaqSmartArray(), getATARAID();
}
sub hds() { grep { may_be_a_hd($_) } get() }
sub tapes() { grep { $_->{media_type} eq 'tape' } get() }
sub cdroms() { grep { $_->{media_type} eq 'cdrom' } get() }
sub burners() { grep { isBurner($_) } cdroms() }
sub dvdroms() { grep { isDvdDrive($_) } cdroms() }
sub raw_zips() { grep { member($_->{media_type}, 'fd', 'hd') && isZipDrive($_) } get() }
#-sub jazzs { grep { member($_->{media_type}, 'fd', 'hd') && isJazzDrive($_) } get() }
sub ls120s() { grep { member($_->{media_type}, 'fd', 'hd') && isLS120Drive($_) } get() }
sub zips() {
map {
$_->{device} .= 4;
$_->{devfs_device} = $_->{devfs_prefix} . '/part4';
$_;
} raw_zips();
}
sub floppies() {
require modules;
my @fds;
eval { modules::load("floppy") if $::isInstall };
if (!is_xbox()) {
@fds = map {
my $info = (!dev_is_devfs() || -e "/dev/fd$_") && c::floppy_info(devices::make("fd$_"));
if_($info && $info ne '(null)', { device => "fd$_", devfs_device => "floppy/$_", media_type => 'fd', info => $info });
} qw(0 1);
}
my @ide = ls120s() and eval { modules::load("ide-floppy") };
eval { modules::load("usb-storage") } if usbStorage();
my @scsi = grep { $_->{media_type} eq 'fd' } getSCSI();
@ide, @scsi, @fds;
}
sub floppies_dev() { map { $_->{device} } floppies() }
sub floppy() { first(floppies_dev()) }
#- example ls120, model = "LS-120 SLIM 02 UHD Floppy"
sub removables() {
floppies(), cdroms(), zips();
}
sub get_sys_cdrom_info {
my (@drives) = @_;
my @drives_order;
foreach (cat_("/proc/sys/dev/cdrom/info")) {
my ($t, $l) = split ':';
my @l;
@l = split(' ', $l) if $l;
if ($t eq 'drive name') {
@drives_order = map {
my $dev = $_;
find { $_->{device} eq $dev } @drives;
} @l;
} else {
my $capacity;
if ($t eq 'Can write CD-R') {
$capacity = 'burner';
} elsif ($t eq 'Can read DVD') {
$capacity = 'DVD';
}
if ($capacity) {
each_index {
($drives_order[$::i] || {})->{capacity} .= "$capacity " if $_;
} @l;
}
}
}
}
sub get_usb_storage_info_24 {
my (@l) = @_;
my %usbs = map {
my $s = cat_(glob_("$_/*"));
my ($host) = $s =~ /^\s*Host scsi(\d+):/m; #-#
my ($vendor_name) = $s =~ /^\s*Vendor: (.*)/m;
my ($vendor, $id) = $s =~ /^\s*GUID: (....)(....)/m!sH% K݇Ϻ&Yn~2tOabaf/{
Nh2Xݩm%C[+\GYs|?L$z<r$mB%V?`O`/F\$)f-6`Zj][]*)mTfcNLP1_H\O0O@smME$rREY8V Pϲ6Qljxڂ!Nt;uXOa/i[+
͢>>,tax $\WzS4
S+9*bwEQ xSOD0u5wf|@d3.ο% UmΧGRII)e/@φ!sçD#o;\^YB˱5? tK?Q6&u~
Q"{;Ml7Daxܿ iQN[nK?ȼ/r0s9tv)ɩueJ`6'k#S*cl^S__r
)*NCNUؼ"]4`͕b1.2t>ĉIЯ!7Mk _[QI
buЦXqu$+~ӆyI#T8 z0<%VʜtX"lǓJπ1/ U.l}8m)R*22Ҷti_\Q# Bē.,OS;8KWnX߁%a4@.;%
j[验p/iU
v9TNnY8H*R-?j͛1[8q.U/'2Om¸gS *kij)Ԩf}ـIFY5}Bv6:S_G'yX`z{~βT!C&g6]1j;-\VභzG>}ڬ7fy>@u KIph1\a
R,pc{度!Rޗw )TacnI_-ȁ̛ҷq/aQ{iNG2[/B&
|