summaryrefslogtreecommitdiffstats
path: root/rescue/guessmounts
blob: f8e4b02dac1f8131a40af1c5e187a29d6bd181a3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
#!/usr/bin/perl
#
# Guillaume Cottenceau
#
# Copyright 2001-2005 Mandriva
#
# This software may be freely redistributed under the terms of the GNU
# public license.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#

use lib qw(/usr/lib/libDrakX);
use common;
use fs;
use fs::proc_partitions;
use fs::type;
use lvm;
use run_program;

my @proc_mounts = fs::read_fstab('', '/proc/mounts');

my $target = '/mnt';

if (fs::get::mntpoint2part($target, \@proc_mounts)) {
    print STDERR "$target is already mounted (according to /proc/mounts)\n";
    exit 0;
}

system('drvinst', 'STORAGE');

print STDERR "\nPlease wait, trying to find your root device...\n";

mkdir_p($target);

lvm::detect_during_install();

my @parts = map {
    $_->{device} = delete $_->{dev};
    put_in_hash($_, fs::type::type_subpart_from_magic($_));   
} fs::proc_partitions::read_raw();
my ($raid_parts, $normal_parts) = partition { isRawRAID($_) } @parts;

if (@$raid_parts) {
    require raid;
    raid::detect_during_install_once(@$raid_parts);
    my $raids = raid::get_existing(@$raid_parts);
    push @$normal_parts, @$raids;
}

my @fstab;
my ($root, @roots);

foreach (@$normal_parts) {
    my $dev = devices::make($_->{device});

    my $fs = find {
	system("mount -t $_ $dev $target 2>/dev/null") == 0;
    } fs::type::true_local_fs_types() or next;

    if (my $release_file = common::release_file($target)) {
	my $release = chomp_(cat_("$target$release_file"));
	print STDERR "=> found a %s root partition on $dev\n=> type $fs, version `",
	  $release, "'\n";
	@fstab = fs::read_fstab($target, '/etc/fstab');
	push @roots, { dev => $dev, release => $release };
    }
    system('umount', $target) == 0 or die "error unmounting $target\n";
}

# Try Mageia first:
if (@roots) {
    @roots = map { @$_ } partition { $_->{release} =~ /Mageia/ } @roots;
    $root = first(@roots)->{dev};
}

if ($root) {
    print STDERR "\nMounting other partitions from fstab on $target...\n";
    foreach (@fstab) {
	my ($valued_options, $options) = fs::mount_options::unpack($_);

	next if 
	  !$_->{fs_type} || $_->{device} eq 'none'
	    || $valued_options->{noauto}
	    || $_->{mntpoint} eq '/'
	    || member($_->{fs_type}, 'swap', 'nfs', 'ntfs', 'ntfs-3g');

	delete $valued_options->{'iocharset='};
	delete $valued_options->{'codepage='};
	fs::mount_options::pack($_, $valued_options, $options); #- vfat opts, we don't have the modules in rescue

	my $where = "$target$_->{mntpoint}";
	my $dev = fs::wild_device::from_part('', $_);
	mkdir_p($where);
	print STDERR "\t$dev on $where type $_->{fs_type} options $_->{options}\n";
	system("mount -t $_->{fs_type} $dev $where -o $_->{options}");
	system("cp -f /etc/mtab $target/etc/mtab"); #- to allow a nice chrooted "mount" or "df"
    }
    print STDERR "\nYour system is ready on $target.\n\n";
} else {
    die "Could not find your root device :-(.\n";
}

"hl kwb">$cpu->{vendor_id}}; } sub has_flag { my ($cpu, $flag) = @_; $cpu->{flags} =~ /\b$flag\b/; } my @cpus; sub get_cpus() { @cpus ? @cpus : @cpus = detect_devices::getCPUs(); } my @pci; sub pci_probe() { @pci ? @pci : @pci = detect_devices::pci_probe(); } sub find_pci_device { my (@devices) = @_; any { my $dev = $_; any { $_->{vendor} == $dev->[0] && $_->{id} == $dev->[1] } pci_probe() } @devices; } sub probe_acpi_cpufreq() { any { get_vendor($_) eq "Intel" && $_->{'cpu family'} == 6 && ( has_flag($_, 'est') || $_->{model} == 11 ); } get_cpus(); } # see cpuid.c (from cpuid package) for a list of family/models sub probe_centrino() { any { get_vendor($_) eq "Intel" && has_flag($_, 'est') && ( ($_->{'cpu family'} == 6 && $_->{model} == 9 && $_->{stepping} == 5 && $_->{'model name'} =~ /^Intel\(R\) Pentium\(R\) M processor ( 900|1[0-7]00)MHz$/) || ($_->{'cpu family'} == 6 && $_->{model} == 13 && member($_->{stepping}, 1, 2, 6)) || ($_->{'cpu family'} == 15 && $_->{model} == 3 && $_->{stepping} == 4) || ($_->{'cpu family'} == 15 && $_->{model} == 4 && $_->{stepping} == 1) ); } get_cpus(); } sub probe_ich() { find_pci_device([ 0x8086, 0x244c ], [ 0x8086, 0x24cc ], [ 0x8086, 0x248c ]) } sub probe_smi() { find_pci_device([ 0x8086, 0x7190 ]) } sub probe_nforce2() { find_pci_device([ 0x10de, 0x01e0 ]) } sub probe_gsx() { (any { member(get_vendor($_), "Cyrix", "NSC") } get_cpus()) && find_pci_device([ 0x1078, 0x0100 ], [ 0x1078, 0x0002 ], [ 0x1078, 0x0000 ]); } sub probe_powerpc() { arch() =~ /ppc/ && any { member($_->{motherboard}, ('PowerBook3,4', 'PowerBook3,5', 'PowerBook4,1', 'PowerBook3,2', 'MacRISC3')) && # Kernel contains a special case for the supported 750FX, # not sure if the cpu name can be used, so use same test as kernel first($_->{revision} =~ /\bpvr\s+(\d+)\b/) == 7000; } get_cpus(); } sub probe_p4() { any { get_vendor($_) eq "Intel" && ( $_->{'cpu family'} == 15 || ($_->{'cpu family'} == 6 && !has_flag($_, 'est') && member($_->{model}, 9, 13, 14, 15)) ); } get_cpus(); } sub probe_powernow_k6() { any { get_vendor($_) eq "AMD" && $_->{'cpu family'} == 5 && member($_->{model}, 12, 13); } get_cpus(); } sub probe_powernow_k7() { any { get_vendor($_) eq "AMD" &&