summaryrefslogtreecommitdiffstats
path: root/perl-install/modules.pm
diff options
context:
space:
mode:
authorPascal Rigaux <pixel@mandriva.com>2000-09-11 10:56:54 +0000
committerPascal Rigaux <pixel@mandriva.com>2000-09-11 10:56:54 +0000
commit66acc9ca3c2c03404de8a2cb635d67f474e91e0a (patch)
tree031a2d66652d5f9c2d674cf96d5896ccd3a7a5bd /perl-install/modules.pm
parentf5d31de24627657212675867a36831d208148043 (diff)
downloaddrakx-backup-do-not-use-66acc9ca3c2c03404de8a2cb635d67f474e91e0a.tar
drakx-backup-do-not-use-66acc9ca3c2c03404de8a2cb635d67f474e91e0a.tar.gz
drakx-backup-do-not-use-66acc9ca3c2c03404de8a2cb635d67f474e91e0a.tar.bz2
drakx-backup-do-not-use-66acc9ca3c2c03404de8a2cb635d67f474e91e0a.tar.xz
drakx-backup-do-not-use-66acc9ca3c2c03404de8a2cb635d67f474e91e0a.zip
no_comment
Diffstat (limited to 'perl-install/modules.pm')
-rw-r--r--perl-install/modules.pm28
1 files changed, 14 insertions, 14 deletions
diff --git a/perl-install/modules.pm b/perl-install/modules.pm
index c7bd31622..3ed7e24fc 100644
--- a/perl-install/modules.pm
+++ b/perl-install/modules.pm
@@ -30,7 +30,7 @@ arch() =~ /^sparc/ ? (
"3c90x" => "3Com 3c90x (Cyclone/Hurricane/Tornado)",
"at1700" => "Allied Telesis AT1700",
"ac3200" => "Ansel Communication AC3200",
- "acenic" => "AceNIC Gigabit Ethernet",
+#BIG "acenic" => "AceNIC Gigabit Ethernet",
"pcnet32" => "AMD PC/Net 32",
"82596" => "Apricot 82596",
# "atp" => "ATP", # builtin the kernel
@@ -82,10 +82,10 @@ arch() =~ /^sparc/ ? (
"sb1000" => "sb1000",
"sbni" => "sbni",
"sis900" => "sis900",
- "sk98lin" => "Syskonnect (Schneider & Koch)|Gigabit Ethernet",
+#BIG "sk98lin" => "Syskonnect (Schneider & Koch)|Gigabit Ethernet",
),
"3c59x" => "3com 3c59x (Vortex)",
- "de4x5" => "Digital 425,434,435,450,500",
+#BIG "de4x5" => "Digital 425,434,435,450,500",
"rtl8139" => "RealTek RTL8129/8139",
}],
[ 'network', {
@@ -111,12 +111,12 @@ arch() =~ /^sparc/ ? (
"advansys" => "AdvanSys Adapters",
"in2000" => "Always IN2000",
"AM53C974" => "AMD SCSI",
- "BusLogic" => "BusLogic Adapters",
+#unsused "BusLogic" => "BusLogic Adapters",
"dtc" => "DTC 3180/3280",
- "seagate" => "Future Domain TMC-885, TMC-950",
- "fdomain" => "Future Domain TMC-16x0",
+#unsused "seagate" => "Future Domain TMC-885, TMC-950",
+#unsused "fdomain" => "Future Domain TMC-16x0",
"initio" => "Initio",
- "g_NCR5380" => "NCR 5380",
+#unsused "g_NCR5380" => "NCR 5380",
"NCR53c406a" => "NCR 53c406a",
"53c7,8xx" => "NCR 53c7xx",
"qlogicfas" => "Qlogic FAS",
@@ -128,12 +128,12 @@ arch() =~ /^sparc/ ? (
"a100u2w" => "a100u2w",
"atp870u" => "atp870u (Acard/Artop)",
- "dc395x_trm" => "dc395x_trm",
+#unsused "dc395x_trm" => "dc395x_trm",
"psi240i" => "psi240i",
"qlogicfc" => "qlogicfc",
"sim710" => "sim710",
"sym53c416" => "sym53c416",
- "tmscsim" => "tmscsim",
+#unsused "tmscsim" => "tmscsim",
),
"aic7xxx" => "Adaptec 2740, 2840, 2940",
"ncr53c8xx" => "NCR 53C8xx PCI",
@@ -153,15 +153,15 @@ arch() =~ /^sparc/ ? (
"pluto" => "Sun SparcSTORAGE Array SCSI", #- name it "fc4:soc:pluto" ?
) : arch() =~ /alpha/ ? () : (
"DAC960" => "Mylex DAC960",
-# "dpt" => "Distributed Tech SmartCache/Raid I-IV Controller", # not there anymore?
+#unused "dpt_i2o" => "Distributed Tech SmartCache/Raid I-IV Controller", # not there anymore?
"megaraid" => "AMI MegaRAID",
"aacraid" => "AACxxx Raid Controller",
"cpqarray" => "Compaq Smart-2/P RAID Controller",
"gdth" => "ICP Disk Array Controller",
"ips" => "IBM ServeRAID controller",
- "eata" => "EATA SCSI PM2x24/PM3224",
- "eata_pio" => "EATA PIO Adapters",
- "eata_dma" => "EATA DMA Adapters",
+#unused "eata" => "EATA SCSI PM2x24/PM3224",
+#unused "eata_pio" => "EATA PIO Adapters",
+#unused "eata_dma" => "EATA DMA Adapters",
"ppa" => "Iomega PPA3 (parallel port Zip)",
"imm" => "Iomega Zip (new driver)",
),
@@ -237,7 +237,7 @@ arch() !~ /^sparc/ ? (
"3c589_cs" => "3c589_cs",
"parport_cs" => "parport_cs",
"3c575_cb" => "3c575_cb",
- "apa1480_cb" => "apa1480_cb",
+#unused "apa1480_cb" => "apa1480_cb",
"cb_enabler" => "cb_enabler",
"epic_cb" => "epic_cb",
"iflash2+_mtd" => "iflash2+_mtd",
304
package raid; # $Id: raid.pm 269279 2010-05-24 14:12:09Z pterjan $

use diagnostics;
use strict;

#-######################################################################################
#- misc imports
#-######################################################################################
use common;
use fs::type;
use fs::get;
use run_program;
use devices;
use modules;

sub max_nb() { 31 }

sub check_prog {
    # perl_checker: require interactive
    my ($in) = @_; # perl_checker: $in = interactive->new
    $::prefix ? whereis_binary('mdadm') : $in->do_pkgs->ensure_binary_is_installed('mdadm', 'mdadm');
}

sub new {
    my ($raids, %opts) = @_;
    my $md_part = { %opts };
    add2hash_($md_part, { 'chunk-size' => '64', disks => [], 
			  fs_type => defaultFS(),
			  device => first(free_mds($raids)), 
			  notFormatted => 1, level => 1 });
    push @$raids, $md_part;
    foreach (@{$md_part->{disks}}) {
	$_->{raid} = $md_part->{device};
	fs::type::set_pt_type($_, 0xfd);
	delete $_->{mntpoint};
    }
    update($md_part);
    $md_part;
}

sub add {
    my ($md_part, $part) = @_;
    $md_part->{isMounted} and die N("Cannot add a partition to _formatted_ RAID %s", $md_part->{device});
    inactivate_and_dirty($md_part);
    set_isFormatted($part, 0);
    $part->{raid} = $md_part->{device};
    delete $part->{mntpoint};
    push @{$md_part->{disks}}, $part;
    update($md_part);
}

sub delete {
    my ($raids, $md_part) = @_;
    inactivate_and_dirty($md_part);
    delete $_->{raid} foreach @{$md_part->{disks}};
    @$raids = grep { $_ != $md_part } @$raids;
    write_conf($raids) if $::isStandalone;
}

sub change_device {
    my ($md_part, $new_device) = @_;
    if ($new_device ne $md_part->{device}) {
	inactivate_and_dirty($md_part);
	$md_part->{device} = $new_device;
	$_->{raid} = $new_device foreach @{$md_part->{disks}};
    }
}

sub removeDisk {
    my ($raids, $part) = @_;
    my $md_part = fs::get::device2part($part->{raid}, $raids);
    inactivate_and_dirty($md_part);
    fs::type::set_isFormatted($part, 0);
    delete $part->{raid};
    my $disks = $md_part->{disks};
    @$disks = grep { $_ != $part } @$disks;
    if (@$disks) {
	update($md_part);
    } else {
	@$raids = grep { $_ != $md_part } @$raids;
    }
    write_conf($raids) if $::isStandalone;
}

sub updateSize {
    my ($part) = @_;
    local $_ = $part->{level};
    my @l = map { $_->{size} } @{$part->{disks}};

    $part->{size} = do {
	if (/0|linear/) { sum @l }
	elsif (/1/)     { min @l }
	elsif (/4|5/)   { min(@l) * (@l - 1) }
	elsif (/6/)     { min(@l) * (@l - 2) }
	elsif (/10/)	{ min(@l) * (@l / 2) }
    };
}

sub allmodules {
    ('raid0', 'raid1', 'raid10', 'raid456');
}

sub module {
    my ($part) = @_;
    my $level = $part->{level};
    log::l("level $level");

    if (member($level, 4, 5, 6)) {
	'raid456';
    } elsif (member($level, 10)) {
	'raid10';
    } elsif ($level =~ /^\d+$/) {
	"raid$level";
    } else {
	$level;
    }
}


sub update {
    updateSize($_) foreach @_;
}

sub make {
    my ($raids, $part) = @_;    

    return if is_active($part->{device});

    inactivate_and_dirty($part);

    isRAID($_) and make($raids, $_) foreach @{$part->{disks}};
    eval { modules::load(module($part)) };

    whereis_binary('mdadm') or die 'mdadm not installed';

    my $dev = devices::make($part->{device});
    my $nb = @{$part->{disks}};

    run_program::run_or_die('mdadm', '--create', '--run', $dev, 
			    if_($nb == 1, '--force'),
			    '--chunk=' . $part->{'chunk-size'}, 
			    "--level=$part->{level}", 
			    "--raid-devices=$nb",
			    if_($part->{metadata}, "--metadata=$part->{metadata}"),
			    map { devices::make($_->{device}) } @{$part->{disks}});

    if (my $raw_part = get_md_info($dev)) {
	$part->{UUID} = $raw_part->{UUID};
    }
    write_conf($raids) if $::isStandalone;
}

sub format_part {
    my ($raids, $part) = @_;
    $part->{isFormatted} and return;

    make($raids, $part);
    fs::format::part_raw($part, undef);
    set_isFormatted($_, 1) foreach @{$part->{disks}};
}

sub verify {
    my ($raids) = @_;
    foreach (@$raids) {
	my $nb = $_->{level} =~ /6|10/ ? 4 : $_->{level} =~ /4|5/ ? 3 : 2;
	@{$_->{disks}} >= $nb or die N("Not enough partitions for RAID level %d\n", $_->{level});
    }
}

sub inactivate_and_dirty {
    my ($part) = @_;
    run_program::run('mdadm', '--stop', devices::make($part->{device}));
    set_isFormatted($part, 0);
}

sub active_mds() {
    map { if_(/^(md\S+)\s*:\s*active/, $1) } cat_("/proc/mdstat");
}
sub inactive_mds() {
    map { if_(/^(md\S+)\s*:\s*inactive/, $1) } cat_("/proc/mdstat");
}

sub free_mds {
    my ($raids) = @_;