aboutsummaryrefslogtreecommitdiffstats
path: root/sysconfig/init
diff options
context:
space:
mode:
authorBill Nottingham <notting@redhat.com>1999-02-22 23:43:52 +0000
committerBill Nottingham <notting@redhat.com>1999-02-22 23:43:52 +0000
commit83aa1f9a5ab54c1578b1e6c1c15f05ef784259df (patch)
tree5ea38a91b655c3c934fc971d4cded7cc73e14bd7 /sysconfig/init
parent8a287013f87a889ad57acf9dc32cf487b297c5e8 (diff)
downloadinitscripts-83aa1f9a5ab54c1578b1e6c1c15f05ef784259df.tar
initscripts-83aa1f9a5ab54c1578b1e6c1c15f05ef784259df.tar.gz
initscripts-83aa1f9a5ab54c1578b1e6c1c15f05ef784259df.tar.bz2
initscripts-83aa1f9a5ab54c1578b1e6c1c15f05ef784259df.tar.xz
initscripts-83aa1f9a5ab54c1578b1e6c1c15f05ef784259df.zip
add default /etc/sysconfig/init
change raw ansi to echo -e add a 'serial' mode that has no ansi escapes
Diffstat (limited to 'sysconfig/init')
-rw-r--r--sysconfig/init12
1 files changed, 12 insertions, 0 deletions
diff --git a/sysconfig/init b/sysconfig/init
new file mode 100644
index 00000000..3b49ec82
--- /dev/null
+++ b/sysconfig/init
@@ -0,0 +1,12 @@
+# color => new RH6.0 bootup
+# verbose => old-style bootup
+# anything else => new style bootup without ANSI colors or positioning
+BOOTUP=color
+# color for 'OK' label ; 2=green
+COLOR_SUCCESS=2
+# color for 'FAILED' label ; 1=red
+COLOR_FAILURE=1
+# column to start "[ OK ]" label in
+RES_COL=60
+# default kernel loglevel on boot (syslog will reset this)
+LOGLEVEL=1
='#n107'>107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275
package partition_table::dos; # $Id: dos.pm 263707 2009-11-26 13:26:41Z pterjan $

use diagnostics;
use strict;
use vars qw(@ISA);

@ISA = qw(partition_table::raw);

use common;
use partition_table::raw;
use partition_table;
use fs::type;
use c;

my @fields = qw(active start_head start_sec start_cyl pt_type end_head end_sec end_cyl start size);
my $format = "C8 V2";
my $magic = "\x55\xAA";
my $nb_primary = 4;

my $offset = $common::SECTORSIZE - length($magic) - $nb_primary * common::psizeof($format);

sub use_pt_type { 1 }
sub hasExtended { 1 }

sub geometry_to_string {
    my ($geom) = @_;
    "$geom->{cylinders}/$geom->{heads}/$geom->{sectors}";
}

sub last_usable_sector { 
    my ($hd) = @_;
    #- do not use totalsectors, see gi/docs/Partition-ends-after-end-of-disk.txt for more
    $hd->{geom}{sectors} * $hd->{geom}{heads} * $hd->{geom}{cylinders};
}

my $two_TB = 2 * 1024 * 1024 * 2048;
sub max_partition_start { $two_TB - 1 }
sub max_partition_size { $two_TB - 1 }

sub get_rawCHS {
    my ($part) = @_;

    exists $part->{start_cyl} or internal_error("get_rawCHS $part->{device}");

    [ $part->{start_cyl}, $part->{start_head}, $part->{start_sec} ],
      [ $part->{end_cyl}, $part->{end_head}, $part->{end_sec} ];
}
sub set_rawCHS {
    my ($part, $raw_chs_start, $raw_chs_end) = @_;   
    ($part->{start_cyl}, $part->{start_head}, $part->{start_sec}) = @$raw_chs_start;
    ($part->{end_cyl}, $part->{end_head}, $part->{end_sec}) = @$raw_chs_end;
}

sub compute_CHS {
    my ($hd, $part) = @_;
    my ($chs_start, $chs_end) = CHS_from_part_linear($hd->{geom}, $part);
    set_rawCHS($part, $chs_start ? CHS2rawCHS($hd->{geom}, $chs_start) : [0,0,0], 
	              $chs_end ? CHS2rawCHS($hd->{geom}, $chs_end) : [0,0,0]);
}

sub CHS_from_part_rawCHS {
    my ($part) = @_;

    $part->{start} || $part->{pt_type} or return;

    my ($raw_chs_start, $raw_chs_end) = get_rawCHS($part);
    rawCHS2CHS($raw_chs_start), rawCHS2CHS($raw_chs_end);
}

sub CHS_from_part_linear {
    my ($geom, $part) = @_;

    $part->{start} || $part->{pt_type} or return;

    sector2CHS($geom, $part->{start}), sector2CHS($geom, $part->{start} + $part->{size} - 1);
}

sub rawCHS2CHS {
    my ($chs) = @_;
    my ($c, $h, $s) = @$chs;
    [ $c | (($s & 0xc0) << 2), $h, ($s & 0x3f) - 1 ];
}

sub CHS2rawCHS {
    my ($geom, $chs) = @_;
    my ($c, $h, $s) = @$chs;
    if ($c > 1023) {
	#- no way to have a #cylinder >= 1024
	$c = 1023;
	$h = $geom->{heads} - 1;
	$s = $geom->{sectors} - 1;
    }
    [ $c & 0xff, $h, ($s + 1) | (($c >> 2) & 0xc0) ];
}

# returns (cylinder, head, sector)
sub sector2CHS {
    my ($geom, $start) = @_;
    my ($s, $h);
    ($start, $s) = divide($start, $geom->{sectors});
    ($start, $h) = divide($start, $geom->{heads});
    [ $start, $h, $s ];
}

sub is_geometry_valid_for_the_partition_table {
    my ($hd, $geom, $no_log) = @_;

    every {
	my ($chs_start_v1, $chs_end_v1) = map { join(',', @$_) } CHS_from_part_rawCHS($_) or next;
	my ($chs_start_v2, $chs_end_v2) = map { join(',', @$_) } map { [ min($_->[0], 1023), $_->[1], $_->[2] ] } CHS_from_part_linear($geom, $_);
	if (!$no_log) {
	    $chs_start_v1 eq $chs_start_v2 or log::l("is_geometry_valid_for_the_partition_table failed for ($_->{device}, $_->{start}): $chs_start_v1 vs $chs_start_v2 with geometry " . geometry_to_string($geom));
	    $chs_end_v1 eq $chs_end_v2 or log::l("is_geometry_valid_for_the_partition_table failed for ($_->{device}, " . ($_->{start} + $_->{size} - 1) . "): $chs_end_v1 vs $chs_end_v2 with geometry " . geometry_to_string($geom));
	}
	$chs_start_v1 eq $chs_start_v2 && $chs_end_v1 eq $chs_end_v2;
    } @{$hd->{primary}{normal} || []};
}

#- from parted, thanks!
my @valid_nb_sectors = (63, 61, 48, 32, 16);
my @valid_nb_heads = (255, 240, 192, 128, 96, 64, 61, 32, 17, 16);

sub guess_geometry_from_partition_table {
    my ($hd) = @_;

    my @chss = map { CHS_from_part_rawCHS($_) } @{$hd->{primary}{normal} || []} or return { empty => 1 };
    my ($nb_heads, $nb_sectors) = (max(map { $_->[1] } @chss) + 1, max(map { $_->[2] } @chss) + 1);    
    my $geom = { sectors => $nb_sectors, heads => $nb_heads };
    partition_table::raw::compute_nb_cylinders($geom, $hd->{totalsectors});
    log::l("guess_geometry_from_partition_table $hd->{device}: " . geometry_to_string($geom));

    member($geom->{sectors}, @valid_nb_sectors) or return { invalid => 1 };
    $geom;
}

sub geometry_from_edd {
    my ($hd, $edd_dir) = @_;

    my $sectors = cat_("$edd_dir/legacy_sectors_per_track") or return;
    my $heads = cat_("$edd_dir/legacy_max_head") or return;

    my $geom = { sectors => 0 + $sectors, heads => 1 + $heads, from_edd => 1 };
    is_geometry_valid_for_the_partition_table($hd, $geom, 0) or return;
    partition_table::raw::compute_nb_cylinders($geom, $hd->{totalsectors});

    log::l("geometry_from_edd $hd->{device} $hd->{volume_id}: " . geometry_to_string($geom));
    
    $geom;
}


sub try_every_geometry {
    my ($hd) = @_;

    my $geom = {};
    foreach (@valid_nb_sectors) {
	$geom->{sectors} = $_;
	foreach (@valid_nb_heads) {
	    $geom->{heads} = $_;
	    if (is_geometry_valid_for_the_partition_table($hd, $geom, 1)) {
		partition_table::raw::compute_nb_cylinders($geom, $hd->{totalsectors});
		log::l("try_every_geometry $hd->{device}: found " . geometry_to_string($geom));
		return $geom;
	    }
	}
    }
    log::l("$hd->{device}: argh! no geometry exists for this partition table");
    undef;
}

sub set_best_geometry_for_the_partition_table {
    my ($hd) = @_;

    my $guessed_geom = guess_geometry_from_partition_table($hd);
    if ($guessed_geom->{empty}) {
	log::l("$hd->{device}: would need looking at BIOS info to find out geometry") if !$hd->{geom}{from_edd};
	return;
    } 
    my $default_ok = is_geometry_valid_for_the_partition_table($hd, $hd->{geom}, 0);
    if ($guessed_geom->{invalid}) {
	log::l("$hd->{device}: no valid geometry guessed from partition table");
	$default_ok and return;
	$guessed_geom = try_every_geometry($hd) or return;