summaryrefslogtreecommitdiffstats
path: root/perl-install/fsedit.pm
blob: 19c0d9888701d0a125f8a5862926491368c8be50 (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
106
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
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
package fsedit; # $Id$

use diagnostics;
use strict;
use vars qw(%suggestions);

#-######################################################################################
#- misc imports
#-######################################################################################
use common qw(:common :constant :functional :file);
use partition_table qw(:types);
use partition_table_raw;
use detect_devices;
use fsedit;
use devices;
use loopback;
use log;
use fs;

%suggestions = (
  __("simple") => [
    { mntpoint => "/",     size => 300 << 11, type => 0x83, ratio => 5, maxsize =>3500 << 11 },
    { mntpoint => "swap",  size =>  64 << 11, type => 0x82, ratio => 1, maxsize => 250 << 11 },
    { mntpoint => "/home", size => 300 << 11, type => 0x83, ratio => 3 },
  ], 'with usr' => [
    { mntpoint => "/",     size => 150 << 11, type => 0x83, ratio => 1, maxsize => 500 << 11 },
    { mntpoint => "swap",  size =>  64 << 11, type => 0x82, ratio => 1, maxsize => 250 << 11 },
    { mntpoint => "/usr",  size => 300 << 11, type => 0x83, ratio => 4, maxsize =>3000 << 11 },
    { mntpoint => "/home", size => 100 << 11, type => 0x83, ratio => 5 },
  ], __("server") => [
    { mntpoint => "/",     size => 150 << 11, type => 0x83, ratio => 1, maxsize => 250 << 11 },
    { mntpoint => "swap",  size =>  64 << 11, type => 0x82, ratio => 2, maxsize => 400 << 11 },
    { mntpoint => "/usr",  size => 300 << 11, type => 0x83, ratio => 3, maxsize =>3000 << 11 },
    { mntpoint => "/var",  size => 100 << 11, type => 0x83, ratio => 4 },
    { mntpoint => "/home", size => 100 << 11, type => 0x83, ratio => 5 },
  ],
);
my @suggestions_mntpoints = (
    "/root", "/var/ftp", "/var/www", "/boot",
    arch() =~ /sparc/ ? "/mnt/sunos" : arch() =~ /ppc/ ? "/mnt/macos" : "/mnt/windows",
);

my @partitions_signatures = (
    [ 0x83, 0x438, "\x53\xEF" ],
    [ 0x183, 0x10034, "ReIsErFs" ],
    [ 0x183, 0x10034, "ReIsEr2Fs" ],
    [ 0x283, 0, 'XFSB', 0x200, 'XAGF', 0x400, 'XAGI' ],
    [ 0x82, 4086, "SWAP-SPACE" ],
    [ 0x7,  0x1FE, "\x55\xAA", 0x3, "NTFS" ],
    [ 0xc,  0x1FE, "\x55\xAA", 0x52, "FAT32" ],
arch() !~ /^sparc/ ? (
    [ 0x6,  0x1FE, "\x55\xAA", 0x36, "FAT" ],
) : (),
);

sub typeOfPart { typeFromMagic(devices::make($_[0]), @partitions_signatures) }

#-######################################################################################
#- Functions
#-######################################################################################
sub hds {
    my ($drives, $flags) = @_;
    my (@hds, @lvms, @raid);
    my $rc;

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

	my $hd = partition_table_raw::get_geometry($file) or log::l("An error occurred while getting the geometry of block device $file: $!"), next;
	add2hash_($hd, $_);
	$hd->{file} = $file;
	$hd->{prefix} = $hd->{device};
	# for RAID arrays of format c0d0p1
	$hd->{prefix} .= "p" if $hd->{prefix} =~ m,(rd|ida|cciss)/,;

	eval { partition_table::read($hd, $flags->{clearall} || member($_->{device}, @{$flags->{clear} || []})) };
	if ($@) {
	    partition_table_raw::zero_MBR($hd);
	}
	member($_->{device}, @{$flags->{clear} || []}) and partition_table::remove($hd, $_)
	  foreach partition_table::get_normal_parts($hd);

	#- special case for type overloading (eg: reiserfs is 0x183)
	foreach (grep { isExt2($_) } partition_table::get_normal_parts($hd)) {
	    my $type = typeOfPart($_->{device});
	    $_->{type} = $type if $type > 0x100;
	}
	push @hds, $hd;
    }
    if (my @pvs = grep { isLVM($_) } map { partition_table::get_normal_parts($_) } @hds) {
	#- otherwise vgscan won't find them
	devices::make($_->{device}) foreach @pvs; 
	require lvm;
	foreach (@pvs) {
	    my $name = lvm::get_vg($_) or next;
	    my ($lvm) = grep { $_->{LVMname} eq $name } (@hds, @lvms);
	    if (!$lvm) {
		$lvm = bless { disks => [], LVMname => $name, level => 'linear' }, 'lvm';
		lvm::update_size($lvm);
		lvm::get_lvs($lvm);
		push @lvms, $lvm;
	    }
	    $_->{lvm} = $name;
	    push @{$lvm->{disks}}, $_;
	}
    }
    if ((my @parts = grep { isRAID($_) } map { partition_table::get_normal_parts($_) } @hds) && detect_devices::raidAutoStart()) {
	my @mdstat = cat_("/proc/mdstat");
	for (my $i=0 ; $i<@mdstat ; $i++) {
	    next if $mdstat[$i] !~ /^md(.).* ([^ \[\]]+) ([^ ]+\[[^ \]]+\])(.*)$/;
	    my ($nb, $level, $partcar, $partcdr) = ($1, $2, $3, $4);
	    $level =~ /raid(.)/ and $level = $1;
	    $partcar =~ /([^\[]+)/ or next;
	    my @thisparts = ( $1 );
	    while ($partcdr =~ /\s*([^\[]+)[^\]]+\](.*)/) {
		push @thisparts, $1;
		$partcdr = $2;
	    }
	    my $chunks = $mdstat[$i+1] =~ /([^ ]+) chunks/ ? $1 : "64k";
	    my @disks;
	    foreach my $part (@parts) {
		if (grep /$part->{device}/, @thisparts) {
		    $part->{raid} = $nb;
		    delete $part->{mntpoint};
		    push @disks, $part;
		}
	    }
	    my $type = typeOfPart("md$nb");
	    my $notformat = 0;
	    log::l("RAID: found md$nb (raid $level) chunks $chunks ", $type ? "type $type " : "", "with parts ", join(", ", @thisparts));
	    if (!$type) {
		$type = 0x83;
		$notformat = 1;
	    }
	    $raid[$nb] = { 'chunk-size' => $chunks, type => $type, disks => \@disks,
			   device => "md$nb", notFormatted => $notformat, level => $level };
	}
	require raid;
	raid::update(@raid);
    }

    \@hds, \@lvms, \@raid;
}

sub readProcPartitions {
    my ($hds) = @_;
    my @parts;
    foreach (cat_("/proc/partitions")) {
	my (undef, undef, $size, $device) = split;
	next if $size eq "1"; #- extended partitions
	foreach (@$hds) {
	    push @parts, { start => 0, size => $size * 2, device => $device, 
			   type => typeOfPart($device), rootDevice => $_->{device} 
			 } if $device =~ /^$_->{device}./;
	}
    }
    @parts;
}

#- get all normal partition including special ones as found on sparc.
sub get_fstab {
    loopback::loopbacks(@_), map { partition_table::get_normal_parts($_) } @_
}

#- get normal partition that should be visible for working on.
sub get_visible_fstab {
    grep { $_ && !partition_table::isWholedisk($_) && !partition_table::isHiddenMacPart($_) } map { partition_table::get_normal_parts($_) } @_;
}

sub free_space {
    sum map { $_->{size} } map { partition_table::get_holes($_) } @_;
}

sub is_one_big_fat {
    my ($hds) = @_;
    @$hds == 1 or return;

    my @l = get_fstab(@$hds);
    @l == 1 && isFat($l[0]) && free_space(@$hds) < 10 << 11;
}


sub computeSize {
    my ($part, $best, $hds, $suggestions) = @_;
    my $max = $part->{maxsize} || $part->{size};
    return min($max, $best->{size}) unless $best->{ratio};

    my $free_space = free_space(@$hds);
    my @l = my @L = grep { 
	if (!has_mntpoint($_->{mntpoint}, $hds) && $free_space >= $_->{size}) {
	    $free_space -= $_->{size};
	    1;
	} else { 0 } } @$suggestions;

    my $tot_ratios = 0;
    while (1) {
	my $old_free_space = $free_space;
	my $old_tot_ratios = $tot_ratios;

	$tot_ratios = sum(map { $_->{ratio} } @l);
	last if $tot_ratios == $old_tot_ratios;

	@l = grep { 
	    if ($_->{ratio} && $_->{maxsize} && $tot_ratios &&
		$_->{size} + $_->{ratio} / $tot_ratios * $old_free_space >= $_->{maxsize}) {
		return min($max, $best->{maxsize}) if $best->{mntpoint} eq $_->{mntpoint};
		$free_space -= $_->{maxsize} - $_->{size};
		0;
	    } else {
		$_->{ratio};
	    } 
	} @l;
    }
    my $size = int min($max, $best->{size} + $free_space * ($tot_ratios && $best->{ratio} / $tot_ratios));
    #- verify other entry can fill the hole
    if (grep { $_->{size} < $max - $size } @L) { $size } else { $max }
}

sub suggest_part {
    my ($part, $hds, $suggestions) = @_;
    $suggestions ||= $suggestions{server};

    my $has_swap = grep { isSwap($_) } get_fstab(@$hds);

    my ($best, $second) =
      grep { !$_->{maxsize} || $part->{size} <= $_->{maxsize} }
      grep { $_->{size} <= ($part->{maxsize} || $part->{size}) }
      grep { !has_mntpoint($_->{mntpoint}, $hds) || isSwap($_) && !$has_swap }
      grep { !$_->{hd} || $_->{hd} eq $part->{rootDevice} }
      grep { !$part->{type} || $part->{type} == $_->{type} || isTrueFS($part) && isTrueFS($_) }
	@$suggestions or return;

#-    if (arch() =~ /i.86/) {
#-	  $best = $second if
#-	    $best->{mntpoint} eq '/boot' &&
#-	    $part->{start} + $best->{size} > 1024 * $hd->cylinder_size(); #- if the empty slot is beyond the 1024th cylinder, no use having /boot
#-    }

    defined $best or return; #- sorry no suggestion :(

    $part->{mntpoint} = $best->{mntpoint};
    $part->{type} = $best->{type};
    $part->{size} = computeSize($part, $best, $hds, $suggestions);
    1;
}

sub suggestions_mntpoint {
    my ($hds) = @_;
    sort grep { !/swap/ && !has_mntpoint($_, $hds) }
      (@suggestions_mntpoints, map { $_->{mntpoint} } @{$suggestions{server}});
}

#-sub partitionDrives {
#-
#-    my $cmd = "/sbin/fdisk";
#-    -x $cmd or $cmd = "/usr/bin/fdisk";
#-
#-    my $drives = findDrivesPresent() or die "You don't have any hard drives available! You probably forgot to configure a SCSI controller.";
#-
#-    foreach (@$drives) {
#-	 my $text = "/dev/" . $_->{device};
#-	 $text .= " - SCSI ID " . $_->{id} if $_->{device} =~ /^sd/;
#-	 $text .= " - Model " . $_->{info};
#-	 $text .= " array" if $_->{device} =~ /^c.d/;
#-
#-	 #- truncate at 50 columns for now
#-	 $text = substr $text, 0, 50;
#-    }
#-    #-TODO TODO
#-}


sub mntpoint2part {
    my ($mntpoint, $fstab) = @_;
    first(grep { $mntpoint eq $_->{mntpoint} } @$fstab);
}
sub has_mntpoint {
    my ($mntpoint, $hds) = @_;
    mntpoint2part($mntpoint, [ get_fstab(@$hds) ]);
}
sub get_root_ {
    my ($fstab, $boot) = @_;
    $boot && mntpoint2part("/boot", $fstab) || mntpoint2part("/", $fstab);
}
sub get_root { &get_root_ || {} }

#- do this before modifying $part->{mntpoint}
#- $part->{mntpoint} should not be used here, use $mntpoint instead
sub check_mntpoint {
    my ($mntpoint, $hd, $part, $hds, $loopbackDevice) = @_;

    ref $loopbackDevice or undef $loopbackDevice;

    $mntpoint eq '' || isSwap($part) || isNonMountable($part) and return;

    local $_ = $mntpoint;
    m|^/| or die _("Mount points must begin with a leading /");
#-    m|(.)/$| and die "The mount point $_ is illegal.\nMount points may not end with a /";

    has_mntpoint($mntpoint, $hds) and die _("There is already a partition with mount point %s\n", $mntpoint);

    my $fake_part = { mntpoint => $mntpoint, device => $loopbackDevice };
    $fake_part->{loopback_file} = 1 if $loopbackDevice;
    my $fstab = [ get_fstab(@$hds), $fake_part ];
    my $check; $check = sub {
	my ($p, @seen) = @_;
	push @seen, $p->{mntpoint} || return;
	@seen > 1 && $p->{mntpoint} eq $mntpoint and die _("Circular mounts %s\n", join(", ", @seen));
	if (my $part = fs::up_mount_point($p->{mntpoint}, $fstab)) {
	    #- '/' carrier is a special case, it will be mounted first
	    $check->($part, @seen) unless loopback::carryRootLoopback($p);
	}
	if (isLoopback($p)) {
	    $check->($p->{device}, @seen);
	}
    };
    $check->($fake_part) unless $mntpoint eq '/' && $loopbackDevice; #- '/' is a special case, no loop check

    die "raid / with no /boot" if $mntpoint eq "/" && isMDRAID($part) && !has_mntpoint("/boot", $hds);
    die _("You can't use a LVM Logical Volume for mount point %s", $mntpoint) if ($mntpoint eq '/' || $mntpoint eq '/boot') && isLVMBased($hd);
    die _("This directory should remain within the root filesystem") if member($mntpoint, qw(/bin /dev /etc /lib /sbin));
    die _("You need a true filesystem (ext2, reiserfs) for this mount point\n") if !isTrueFS($part) && member($mntpoint, qw(/ /home /tmp /usr /var));
#-    if ($part->{start} + $part->{size} > 1024 * $hd->cylinder_size() && arch() =~ /i.86/) {
#-	  die "/boot ending on cylinder > 1024" if $mntpoint eq "/boot";
#-	  die     "/ ending on cylinder > 1024" if $mntpoint eq "/" && !has_mntpoint("/boot", $hds);
#-    }
}

sub add($$$;$) {
    my ($hd, $part, $hds, $options) = @_;

    isSwap($part) ?
      ($part->{mntpoint} = 'swap') :
      $options->{force} || check_mntpoint($part->{mntpoint}, $hd, $part, $hds);

    delete $part->{maxsize};

    if (isLVMBased($hd)) {
	lvm::lv_create($hd, $part);
    } else {
	partition_table::add($hd, $part, $options->{primaryOrExtended});
    }
}

sub allocatePartitions($$) {
    my ($hds, $to_add) = @_;

    foreach my $hd (@$hds) {
	foreach (partition_table::get_holes($hd)) {
	    my ($start, $size) = @$_{"start", "size"};
	    my $part;
	    while (suggest_part($part = { start => $start, size => 0, maxsize => $size, rootDevice => $hd->{device} }, 
				$hds, $to_add)) {
		add($hd, $part, $hds);
		$size -= $part->{size} + $part->{start} - $start;
		$start = $part->{start} + $part->{size};
	    }
	}
    }
}

sub auto_allocate {
    my ($hds, $suggestions) = @_;    
    allocatePartitions($hds, $suggestions || $suggestions{simple});
    map { partition_table::assign_device_numbers($_) } @$hds;
}

sub undo_prepare($) {
    my ($hds) = @_;
    require Data::Dumper;
    $Data::Dumper::Purity = 1;
    foreach (@$hds) {
	my @h = @{$_}{@partition_table::fields2save};
	push @{$_->{undo}}, Data::Dumper->Dump([\@h], ['$h']);
    }
}
sub undo($) {
    my ($hds) = @_;
    foreach (@$hds) {
	my $h; eval pop @{$_->{undo}} || next;
	@{$_}{@partition_table::fields2save} = @$h;

	$_->{isDirty} = $_->{needKernelReread} = 1 if $_->{hasBeenDirty};
    }
}

sub move {
    my ($hd, $part, $hd2, $sector2) = @_;

    my $part1 = { %$part };
    my $part2 = { %$part };
    $part2->{start} = $sector2;
    $part2->{size} += $hd2->cylinder_size() - 1;
    partition_table::remove($hd, $part);
    {
	local ($part2->{notFormatted}, $part2->{isFormatted}); #- do not allow partition::add to change this
	partition_table::add($hd2, $part2);
    }

    return if $part2->{notFormatted} && !$part2->{isFormatted} || $::testing;

    local (*F, *G);
    sysopen F, $hd->{file}, 0 or die '';
    sysopen G, $hd2->{file}, 2 or die _("Error opening %s for writing: %s", $hd2->{file}, "$!");

    my $base = $part1->{start};
    my $base2 = $part2->{start};
    my $step = 10;
    if ($hd eq $hd2) {
	$base == $base2 and return;
	$step = min($step, abs($base2 - $base));

	if ($base < $base2) {
	    $base  += $part1->{size} - $step;
	    $base2 += $part1->{size} - $step;
	    $step = -$step;
	}
    }

    my $f = sub {
	$base  < 0 and $base2 += -$base,  $base  = 0;
	$base2 < 0 and $base  += -$base2, $base2 = 0;
	c::lseek_sector(fileno(F), $base,  0) or die "seeking to sector $base failed on drive $hd->{device}";
	c::lseek_sector(fileno(G), $base2, 0) or die "seeking to sector $base2 failed on drive $hd2->{device}";

	my $buf;
	sysread F, $buf, $SECTORSIZE * abs($_[0]) or die '';
	syswrite G, $buf;
    };

    for (my $i = 0; $i < $part1->{size} / abs($step); $i++, $base += $step, $base2 += $step) {
	print "$base $base2\n";
	&$f($step);
    }
    if (my $v = ($part1->{size} % abs($step)) * sign($step)) {
	$base += $v;
	$base2 += $v;
	&$f($v);
    }
}

sub change_type($$$) {
    my ($hd, $part, $type) = @_;
    $type != $part->{type} or return;
    $hd->{isDirty} = 1;
    $part->{mntpoint} = '' if isSwap($part) && $part->{mntpoint} eq "swap";
    $part->{mntpoint} = '' if isLVM({ type => $type }) || isRAID({ type => $type });
    $part->{type} = $type;
    $part->{notFormatted} = 1;
    $part->{isFormatted} = 0;    
}

sub rescuept($) {
    my ($hd) = @_;
    my ($ext, @hd);

    my $dev = devices::make($hd->{device});
    local *F; open F, "rescuept $dev|";
    local $_;
    while (<F>) {
	my ($st, $si, $id) = /start=\s*(\d+),\s*size=\s*(\d+),\s*Id=\s*(\d+)/ or next;
	my $part = { start => $st, size => $si, type => hex($id) };
	if (isExtended($part)) {
	    $ext = $part;
	} else {
	    push @hd, $part;
	}
    }
    close F or die "rescuept failed";

    partition_table_raw::zero_MBR($hd);
    foreach (@hd) {
	my $b = partition_table::verifyInside($_, $ext);
	if ($b) {
	    $_->{start}--;
	    $_->{size}++;
	}
	local $_->{notFormatted};

	partition_table::add($hd, $_, ($b ? 'Extended' : 'Primary'), 1);
    }
}

sub verifyHds {
    my ($hds, $readonly, $ok) = @_;

    if (is_empty_array_ref($hds)) { #- no way
	die _("An error has occurred - no valid devices were found on which to create new filesystems. Please check your hardware for the cause of this problem");
    }

    my @parts = readProcPartitions($hds);
    $ok &&= @parts == listlength(get_fstab(@$hds)) unless arch() eq "ppc";

    if ($readonly && !$ok) {
	log::l("using /proc/partitions as diskdrake failed :(");
	foreach my $hd (@$hds) {
	    partition_table_raw::zero_MBR($hd);
	    $hd->{primary} = { normal => [ grep { $hd->{device} eq $_->{rootDevice} } @parts ] };
	}
	$ok = 1;
    }
    $readonly && get_fstab(@$hds) == 0 and die _("You don't have any partitions!");
    $ok;
}

#-######################################################################################
#- Wonderful perl :(
#-######################################################################################
1; #
an> # Refer to the XF86Config(4/5) man page for details about the format of # this file. # ********************************************************************** Section "Files" RgbPath "/usr/X11R6/lib/X11/rgb" # Multiple FontPath entries are allowed (they are concatenated together) # By default, Mandrake 6.0 and later now use a font server independent of # the X server to render fonts. FontPath "unix/:-1" EndSection # ********************************************************************** # Server flags section. # ********************************************************************** Section "ServerFlags" # Uncomment this to cause a core dump at the spot where a signal is # received. This may leave the console in an unusable state, but may # provide a better stack trace in the core dump to aid in debugging #NoTrapSignals # Uncomment this to disable the <Crtl><Alt><BS> server abort sequence # This allows clients to receive this key event. #DontZap # Uncomment this to disable the <Crtl><Alt><KP_+>/<KP_-> mode switching # sequences. This allows clients to receive these key events. #DontZoom # This allows the server to start up even if the # mouse device can't be opened/initialised. AllowMouseOpenFail EndSection # ********************************************************************** # Input devices # ********************************************************************** ); $keyboardsection_start = ' # ********************************************************************** # Keyboard section # ********************************************************************** Section "Keyboard" Protocol "Standard" # when using XQUEUE, comment out the above line, and uncomment the # following line #Protocol "Xqueue" AutoRepeat 250 30 # Let the server do the NumLock processing. This should only be # required when using pre-R6 clients #ServerNumLock # Specify which keyboard LEDs can be user-controlled (eg, with xset(1)) #Xleds "1 2 3" #To set the LeftAlt to Meta, RightAlt key to ModeShift, #RightCtl key to Compose, and ScrollLock key to ModeLock: LeftAlt Meta RightAlt Meta ScrollLock Compose RightCtl Control # To disable the XKEYBOARD extension, uncomment XkbDisable. # XkbDisable '; $keyboardsection_start_v4 = ' # ********************************************************************** # Keyboard section # ********************************************************************** Section "InputDevice" Identifier "Keyboard1" Driver "Keyboard" Option "AutoRepeat" "250 30" '; if (arch() =~ /^sparc/) { $keyboardsection_part3 = ' # To customise the XKB settings to suit your keyboard, modify the # lines below (which are the defaults). For example: # XkbModel "type6" # If you have a SUN keyboard, you may use: # XkbModel "sun" # # Then to change the language, change the Layout setting. # For example, a german layout can be obtained with: # XkbLayout "de" # or: # XkbLayout "de" # XkbVariant "nodeadkeys" # # If you\'d like to switch the positions of your capslock and # control keys, use: # XkbOptions "ctrl:swapcaps" # These are the default XKB settings for XFree86 on SUN: # XkbRules "sun" # XkbModel "type5_unix" # XkbLayout "us" # XkbCompat "compat/complete" # XkbTypes "types/complete" # XkbKeycodes "sun(type5)" # XkbGeometry "sun(type5)" # XkbSymbols "sun/us(sun5)" XkbRules "sun" XkbLayout "us" XkbCompat "compat/complete" XkbTypes "types/complete" XkbKeycodes "sun(type5)" XkbGeometry "sun(type5)" XkbSymbols "sun/us(sun5)" '; $keyboardsection_part3_v4 = ' Option "XkbRules" "sun" Option "XkbLayout" "us" Option "XkbCompat" "compat/complete" Option "XkbTypes" "types/complete" Option "XkbKeycodes" "sun(type5)" Option "XkbGeometry" "sun(type5)" Option "XkbSymbols" "sun/us(sun5)" '; } elsif (arch() =~ /ppc/) { $keyboardsection_part3 = ' # To customise the XKB settings to suit your keyboard, modify the # lines below (which are the defaults). For example, for a non-U.S. # keyboard, you will probably want to use: # XkbModel "pc102" # If you have a US Microsoft Natural keyboard, you can use: # XkbModel "microsoft" # # Then to change the language, change the Layout setting. # For example, a german layout can be obtained with: # XkbLayout "de" # or: # XkbLayout "de" # XkbVariant "nodeadkeys" # # If you\'d like to switch the positions of your capslock and # control keys, use: # XkbOptions "ctrl:swapcaps" # These are the default XKB settings for XFree86 # XkbRules "xfree86" # XkbModel "pc101" # XkbLayout "us" # XkbVariant "" # XkbOptions "" XkbKeycodes "xfree86" XkbTypes "default" XkbCompat "default" XkbSymbols "macintosh/us" XkbGeometry "macintosh" XkbRules "xfree86" '; $keyboardsection_part3_v4 = ' Option "XkbRules" "xfree86" '; } else { $keyboardsection_part3 = ' # To customise the XKB settings to suit your keyboard, modify the # lines below (which are the defaults). For example, for a non-U.S. # keyboard, you will probably want to use: # XkbModel "pc102" # If you have a US Microsoft Natural keyboard, you can use: # XkbModel "microsoft" # # Then to change the language, change the Layout setting. # For example, a german layout can be obtained with: # XkbLayout "de" # or: # XkbLayout "de" # XkbVariant "nodeadkeys" # # If you\'d like to switch the positions of your capslock and # control keys, use: # XkbOptions "ctrl:swapcaps" # These are the default XKB settings for XFree86 # XkbRules "xfree86" # XkbModel "pc101" # XkbLayout "us" # XkbVariant "" # XkbOptions "" XkbKeycodes "xfree86" XkbTypes "default" XkbCompat "default" XkbSymbols "us(pc105)" XkbGeometry "pc" XkbRules "xfree86" '; $keyboardsection_part3_v4 = ' Option "XkbRules" "xfree86" '; } $keyboardsection_end = ' EndSection '; $pointersection_text = ' # ********************************************************************** # Pointer section # ********************************************************************** '; $monitorsection_text1 = ' # ********************************************************************** # Monitor section # ********************************************************************** # Any number of monitor sections may be present Section "Monitor" '; $monitorsection_text2 = ' # HorizSync is in kHz unless units are specified. # HorizSync may be a comma separated list of discrete values, or a # comma separated list of ranges of values. # NOTE: THE VALUES HERE ARE EXAMPLES ONLY. REFER TO YOUR MONITOR\'S # USER MANUAL FOR THE CORRECT NUMBERS. '; $monitorsection_text3 = ' # VertRefresh is in Hz unless units are specified. # VertRefresh may be a comma separated list of discrete values, or a # comma separated list of ranges of values. # NOTE: THE VALUES HERE ARE EXAMPLES ONLY. REFER TO YOUR MONITOR\'S # USER MANUAL FOR THE CORRECT NUMBERS. '; $monitorsection_text4 = ' # Modes can be specified in two formats. A compact one-line format, or # a multi-line format. # These two are equivalent # ModeLine "1024x768i" 45 1024 1048 1208 1264 768 776 784 817 Interlace # Mode "1024x768i" # DotClock 45 # HTimings 1024 1048 1208 1264 # VTimings 768 776 784 817 # Flags "Interlace" # EndMode '; $modelines_text_Trident_TG_96xx = ' # This is a set of standard mode timings. Modes that are out of monitor spec # are automatically deleted by the server (provided the HorizSync and # VertRefresh lines are correct), so there\'s no immediate need to # delete mode timings (unless particular mode timings don\'t work on your # monitor). With these modes, the best standard mode that your monitor # and video card can support for a given resolution is automatically # used. # These are special modelines for Trident Providia 9685. It is for VA Linux # systems only. # 640x480 @ 72 Hz, 36.5 kHz hsync Modeline "640x480" 31.5 640 680 720 864 480 488 491 521 # 800x600 @ 72 Hz, 48.0 kHz hsync Modeline "800x600" 50 800 856 976 1040 600 637 643 666 +hsync +vsync # 1024x768 @ 60 Hz, 48.4 kHz hsync #Modeline "1024x768" 65 1024 1032 1176 1344 768 771 777 806 -hsync -vsync # 1024x768 @ 70 Hz, 56.5 kHz hsync Modeline "1024x768" 75 1024 1048 1184 1328 768 771 777 806 -hsync -vsync '; $modelines_text = ' # This is a set of standard mode timings. Modes that are out of monitor spec # are automatically deleted by the server (provided the HorizSync and # VertRefresh lines are correct), so there\'s no immediate need to # delete mode timings (unless particular mode timings don\'t work on your # monitor). With these modes, the best standard mode that your monitor # and video card can support for a given resolution is automatically # used. # 640x400 @ 70 Hz, 31.5 kHz hsync Modeline "640x400" 25.175 640 664 760 800 400 409 411 450 # 640x480 @ 60 Hz, 31.5 kHz hsync Modeline "640x480" 25.175 640 664 760 800 480 491 493 525 # 800x600 @ 56 Hz, 35.15 kHz hsync ModeLine "800x600" 36 800 824 896 1024 600 601 603 625 # 1024x768 @ 87 Hz interlaced, 35.5 kHz hsync Modeline "1024x768" 44.9 1024 1048 1208 1264 768 776 784 817 Interlace # 640x400 @ 85 Hz, 37.86 kHz hsync Modeline "640x400" 31.5 640 672 736 832 400 401 404 445 -HSync +VSync # 640x480 @ 72 Hz, 36.5 kHz hsync Modeline "640x480" 31.5 640 680 720 864 480 488 491 521 # 640x480 @ 75 Hz, 37.50 kHz hsync ModeLine "640x480" 31.5 640 656 720 840 480 481 484 500 -HSync -VSync # 800x600 @ 60 Hz, 37.8 kHz hsync Modeline "800x600" 40 800 840 968 1056 600 601 605 628 +hsync +vsync # 640x480 @ 85 Hz, 43.27 kHz hsync Modeline "640x480" 36 640 696 752 832 480 481 484 509 -HSync -VSync # 1152x864 @ 89 Hz interlaced, 44 kHz hsync ModeLine "1152x864" 65 1152 1168 1384 1480 864 865 875 985 Interlace # 800x600 @ 72 Hz, 48.0 kHz hsync Modeline "800x600" 50 800 856 976 1040 600 637 643 666 +hsync +vsync # 1024x768 @ 60 Hz, 48.4 kHz hsync Modeline "1024x768" 65 1024 1032 1176 1344 768 771 777 806 -hsync -vsync # 640x480 @ 100 Hz, 53.01 kHz hsync Modeline "640x480" 45.8 640 672 768 864 480 488 494 530 -HSync -VSync # 1152x864 @ 60 Hz, 53.5 kHz hsync Modeline "1152x864" 89.9 1152 1216 1472 1680 864 868 876 892 -HSync -VSync # 800x600 @ 85 Hz, 55.84 kHz hsync Modeline "800x600" 60.75 800 864 928 1088 600 616 621 657 -HSync -VSync # 1024x768 @ 70 Hz, 56.5 kHz hsync Modeline "1024x768" 75 1024 1048 1184 1328 768 771 777 806 -hsync -vsync # 1280x1024 @ 87 Hz interlaced, 51 kHz hsync Modeline "1280x1024" 80 1280 1296 1512 1568 1024 1025 1037 1165 Interlace # 800x600 @ 100 Hz, 64.02 kHz hsync Modeline "800x600" 69.65 800 864 928 1088 600 604 610 640 -HSync -VSync # 1024x768 @ 76 Hz, 62.5 kHz hsync Modeline "1024x768" 85 1024 1032 1152 1360 768 784 787 823 # 1152x864 @ 70 Hz, 62.4 kHz hsync Modeline "1152x864" 92 1152 1208 1368 1474 864 865 875 895 # 1280x1024 @ 61 Hz, 64.2 kHz hsync Modeline "1280x1024" 110 1280 1328 1512 1712 1024 1025 1028 1054 # 1024x768 @ 85 Hz, 70.24 kHz hsync Modeline "1024x768" 98.9 1024 1056 1216 1408 768 782 788 822 -HSync -VSync # 1152x864 @ 78 Hz, 70.8 kHz hsync Modeline "1152x864" 110 1152 1240 1324 1552 864 864 876 908 # 1280x1024 @ 70 Hz, 74.59 kHz hsync Modeline "1280x1024" 126.5 1280 1312 1472 1696 1024 1032 1040 1068 -HSync -VSync # 1600x1200 @ 60Hz, 75.00 kHz hsync Modeline "1600x1200" 162 1600 1664 1856 2160 1200 1201 1204 1250 +HSync +VSync # 1152x864 @ 84 Hz, 76.0 kHz hsync Modeline "1152x864" 135 1152 1464 1592 1776 864 864 876 908 # 1280x1024 @ 74 Hz, 78.85 kHz hsync Modeline "1280x1024" 135 1280 1312 1456 1712 1024 1027 1030 1064 # 1024x768 @ 100Hz, 80.21 kHz hsync Modeline "1024x768" 115.5 1024 1056 1248 1440 768 771 781 802 -HSync -VSync # 1280x1024 @ 76 Hz, 81.13 kHz hsync Modeline "1280x1024" 135 1280 1312 1416 1664 1024 1027 1030 1064 # 1600x1200 @ 70 Hz, 87.50 kHz hsync Modeline "1600x1200" 189 1600 1664 1856 2160 1200 1201 1204 1250 -HSync -VSync # 1152x864 @ 100 Hz, 89.62 kHz hsync Modeline "1152x864" 137.65 1152 1184 1312 1536 864 866 885 902 -HSync -VSync # 1280x1024 @ 85 Hz, 91.15 kHz hsync Modeline "1280x1024" 157.5 1280 1344 1504 1728 1024 1025 1028 1072 +HSync +VSync # 1600x1200 @ 75 Hz, 93.75 kHz hsync Modeline "1600x1200" 202.5 1600 1664 1856 2160 1200 1201 1204 1250 +HSync +VSync # 1600x1200 @ 85 Hz, 105.77 kHz hsync Modeline "1600x1200" 220 1600 1616 1808 2080 1200 1204 1207 1244 +HSync +VSync # 1280x1024 @ 100 Hz, 107.16 kHz hsync Modeline "1280x1024" 181.75 1280 1312 1440 1696 1024 1031 1046 1072 -HSync -VSync # 1800x1440 @ 64Hz, 96.15 kHz hsync ModeLine "1800X1440" 230 1800 1896 2088 2392 1440 1441 1444 1490 +HSync +VSync # 1800x1440 @ 70Hz, 104.52 kHz hsync ModeLine "1800X1440" 250 1800 1896 2088 2392 1440 1441 1444 1490 +HSync +VSync # 512x384 @ 78 Hz, 31.50 kHz hsync Modeline "512x384" 20.160 512 528 592 640 384 385 388 404 -HSync -VSync # 512x384 @ 85 Hz, 34.38 kHz hsync Modeline "512x384" 22 512 528 592 640 384 385 388 404 -HSync -VSync # Low-res Doublescan modes # If your chipset does not support doublescan, you get a \'squashed\' # resolution like 320x400. # 320x200 @ 70 Hz, 31.5 kHz hsync, 8:5 aspect ratio Modeline "320x200" 12.588 320 336 384 400 200 204 205 225 Doublescan # 320x240 @ 60 Hz, 31.5 kHz hsync, 4:3 aspect ratio Modeline "320x240" 12.588 320 336 384 400 240 245 246 262 Doublescan # 320x240 @ 72 Hz, 36.5 kHz hsync Modeline "320x240" 15.750 320 336 384 400 240 244 246 262 Doublescan # 400x300 @ 56 Hz, 35.2 kHz hsync, 4:3 aspect ratio ModeLine "400x300" 18 400 416 448 512 300 301 302 312 Doublescan # 400x300 @ 60 Hz, 37.8 kHz hsync Modeline "400x300" 20 400 416 480 528 300 301 303 314 Doublescan # 400x300 @ 72 Hz, 48.0 kHz hsync Modeline "400x300" 25 400 424 488 520 300 319 322 333 Doublescan # 480x300 @ 56 Hz, 35.2 kHz hsync, 8:5 aspect ratio ModeLine "480x300" 21.656 480 496 536 616 300 301 302 312 Doublescan # 480x300 @ 60 Hz, 37.8 kHz hsync Modeline "480x300" 23.890 480 496 576 632 300 301 303 314 Doublescan # 480x300 @ 63 Hz, 39.6 kHz hsync Modeline "480x300" 25 480 496 576 632 300 301 303 314 Doublescan # 480x300 @ 72 Hz, 48.0 kHz hsync Modeline "480x300" 29.952 480 504 584 624 300 319 322 333 Doublescan '; $devicesection_text = ' # ********************************************************************** # Graphics device section # ********************************************************************** Section "Device" Identifier "Generic VGA" Chipset "generic" EndSection '; $devicesection_text_v4 = ' # ********************************************************************** # Graphics device section # ********************************************************************** Section "Device" Identifier "Generic VGA" Driver "vga" EndSection '; $screensection_text1 = ' # ********************************************************************** # Screen sections # ********************************************************************** ';