From e1729dfdb9c341fe0b9fed7d7b0a80691a547d82 Mon Sep 17 00:00:00 2001 From: Chmouel Boudjnah Date: Thu, 1 Jul 1999 12:29:54 +0000 Subject: "See_The_Changelog" --- perl-install/unused/cdrom.pm | 41 +++++++++++++++ perl-install/unused/dns.pm | 64 +++++++++++++++++++++++ perl-install/unused/otherinsmod.pm | 26 ++++++++++ perl-install/unused/scsi.pm | 104 +++++++++++++++++++++++++++++++++++++ 4 files changed, 235 insertions(+) create mode 100644 perl-install/unused/cdrom.pm create mode 100644 perl-install/unused/dns.pm create mode 100644 perl-install/unused/otherinsmod.pm create mode 100644 perl-install/unused/scsi.pm (limited to 'perl-install/unused') diff --git a/perl-install/unused/cdrom.pm b/perl-install/unused/cdrom.pm new file mode 100644 index 000000000..46bb4fc3f --- /dev/null +++ b/perl-install/unused/cdrom.pm @@ -0,0 +1,41 @@ +package cdrom; + +use diagnostics; +use strict; + +use detect_devices; + + +my %transTable = ( cm206 => 'cm206cd', sonycd535 => 'cdu535'); + +1; + + +sub setupCDdevicePanel { + my ($type) = @_; +} + +sub findAtapi { + my $ide = ideGetDevices(); + foreach (@$ide) { $_->{type} eq 'cdrom' and return $_->{device} } + error(); +} + +sub findSCSIcdrom { + detect_devices::isSCSI() or return error(); + my $scsi = detect_devices::getSCSI(); + foreach (@$scsi) { $_->{type} eq 'cdrom' and return $_->{device} } + error(); +} + +sub setupCDdevice { + my ($cddev, $dl) = @_; + #TODO +} + +sub removeCDmodule { + # this wil fail silently if no CD module has been loaded + removeDeviceDriver('cdrom'); + 1; +} + diff --git a/perl-install/unused/dns.pm b/perl-install/unused/dns.pm new file mode 100644 index 000000000..baad57f9e --- /dev/null +++ b/perl-install/unused/dns.pm @@ -0,0 +1,64 @@ +use diagnostics; +use strict; + +# This is dumb, but glibc doesn't like to do hostname lookups w/o libc.so + + +#TODO TODO +sub doQuery { +# my ($query, $queryType, $domainName, $ipNum) = @_; +# +# _res.retry = 2; +# +# len = res_search(query, C_IN, queryType, (void *) &response, +# sizeof(response)); +# if (len <= 0) return -1; +# +# if (ntohs(response.hdr.rcode) != NOERROR) return -1; +# ancount = ntohs(response.hdr.ancount); +# if (ancount < 1) return -1; +# +# data = response.buf + sizeof(HEADER); +# end = response.buf + len; +# +# # skip the question +# data += dn_skipname(data, end) + QFIXEDSZ; +# +# # parse the answer(s) +# while (--ancount >= 0 && data < end) { +# +# # skip the domain name portion of the RR record +# data += dn_skipname(data, end); +# +# # get RR information +# GETSHORT(type, data); +# data += INT16SZ; # skipp class +# data += INT32SZ; # skipp TTL +# GETSHORT(len, data); +# +# if (type == T_PTR) { +# # we got a pointer +# len = dn_expand(response.buf, end, data, name, sizeof(name)); +# if (len <= 0) return -1; +# if (queryType == T_PTR && domainName) { +# # we wanted a pointer +# *domainName = malloc(strlen(name) + 1); +# strcpy(*domainName, name); +# return 0; +# } +# } else if (type == T_A) { +# # we got an address +# if (queryType == T_A && ipNum) { +# # we wanted an address +# memcpy(ipNum, data, sizeof(*ipNum)); +# return 0; +# } +# } +# +# # move ahead to next RR +# data += len; +# } +# +# return -1; +} + diff --git a/perl-install/unused/otherinsmod.pm b/perl-install/unused/otherinsmod.pm new file mode 100644 index 000000000..fb62ff945 --- /dev/null +++ b/perl-install/unused/otherinsmod.pm @@ -0,0 +1,26 @@ +use diagnostics; +use strict; + +sub insmod { + + @_ or die "usage: insmod .o [params]\n"; + + my $file = shift; + my $tmpname; + + unless (-r $file) { + local *F; + open F, "/modules/modules.cgz" or die "error opening /modules/modules.cgz"; + + $tmpname = "/tmp/" . basename($file); + + installCpioFile(\*F, $file, $tmpname, 0) or die "error extracting file"; + } + + my $rc = insmod_main($tmpname || $file, @_); + + unlink($tmpname); + + return $rc; +} +sub modprobe { &insmod } diff --git a/perl-install/unused/scsi.pm b/perl-install/unused/scsi.pm new file mode 100644 index 000000000..77fe8fe44 --- /dev/null +++ b/perl-install/unused/scsi.pm @@ -0,0 +1,104 @@ +use diagnostics; +use strict; + +my $scsiDeviceAvailable; +my $CSADeviceAvailable; + +1; + +sub scsiDeviceAvailable { + defined $scsiDeviceAvailable and return $scsiDeviceAvailable; + local *F; + open F, "/proc/scsi/scsi" or log::l("failed to open /proc/scsi/scsi: $!"), return 0; + foreach () { + /devices: none/ and log::l("no scsi devices are available"), return $scsiDeviceAvailable = 0; + } + log::l("scsi devices are available"); + $scsiDeviceAvailable = 1; +} + +sub CompaqSmartArrayDeviceAvailable { + defined $CSADeviceAvailable and return $CSADeviceAvailable; + -r "/proc/array/ida0" or log::l("failed to open /proc/array/ida0: $!"), return $CSADeviceAvailable = 0; + log::l("Compaq Smart Array controllers available"); + $CSADeviceAvailable = 1; +} + +sub scsiGetDevices { + my @drives; + my ($driveNum, $cdromNum, $tapeNum) = qw(0 0 0); + my $err = sub { chop; log::l("unexpected line in /proc/scsi/scsi: $_"); error() }; + local $_; + + local *F; + open F, "/proc/scsi/scsi" or return &$err(); + $_ = ; /^Attached devices:/ or return &$err(); + while ($_ = ) { + my ($id) = /^Host:.*?Id: (\d+)/ or return &$err(); + $_ = ; my ($vendor, $model) = /^\s*Vendor:\s*(.*?)\s+Model:\s*(.*?)\s+Rev:/ or return &$err(); + $_ = ; my ($type) = /^\s*Type:\s*(.*)/ or &$err(); + my $device; + if ($type =~ /Direct-Access/) { + $type = 'hd'; + $device = "sd" . chr($driveNum++ + ord('a')); + } elsif ($type =~ /Sequential-Access/) { + $type = 'tape'; + $device = "st" . $tapeNum++; + } elsif ($type =~ /CD-ROM/) { + $type = 'cdrom'; + $device = "scd" . $cdromNum++; + } + $device and push @drives, { device => $device, type => $type, info => "$vendor $model", id => $id, bus => 0 }; + } + [ @drives ]; +} + +sub ideGetDevices { + my @idi; + + -r "/proc/ide" or die "sorry, /proc/ide not available, seems like you have a pre-2.2 kernel\n => not handled yet :("; + + # Great. 2.2 kernel, things are much easier and less error prone. + foreach my $d (glob_('/proc/ide/hd*')) { + my ($t) = chop_(cat_("$d/media")); + my $type = $ {{disk => 'hd', cdrom => 'cdrom', tape => 'tape', floppy => 'fd'}}{$t} or next; + my ($info) = chop_(cat_("$d/model")); $info ||= "(none)"; + + my $num = ord (($d =~ /(.)$/)[0]) - ord 'a'; + push @idi, { type => $type, device => basename($d), info => $info, bus => $num/2, id => $num%2 }; + } + [ @idi ]; +} + + +sub CompaqSmartArrayGetDevices { + my @idi; + my $f; + + for (my $i = 0; -r ($f = "/proc/array/ida$i"); $i++) { + local *F; + open F, $f or die; + local $_ = ; + my ($name) = m|ida/(.*?):| or next; + push @idi, { device => $name, info => "Compaq RAID logical disk", type => 'hd' }; + } + [ @idi ]; +} + +sub dac960GetDevices { + my @idi; + my $file = "/var/log/dmesg"; + -r $file or $file = "/tmp/syslog"; + + local *F; + open F, $file or die "Failed to open $file: $!"; + + # We are looking for lines of this format:DAC960#0: + # /dev/rd/c0d0: RAID-7, Online, 17928192 blocks, Write Thru0123456790123456789012 + foreach () { + my ($devicename, $info) = m|/dev/rd/(.*?): (.*?),| or next; + push @idi, { info => $info, type => 'hd', devicename => $devicename }; + log::l("DAC960: $devicename: $info"); + } + [ @idi ]; +} -- cgit v1.2.1