patches/system-tools-backends-03-disks.diff
changeset 6955 fef846f62545
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/patches/system-tools-backends-03-disks.diff	Thu Mar 16 09:25:39 2006 +0000
@@ -0,0 +1,220 @@
+diff -ru /var/tmp/clean/system-tools-backends-1.4.2/disks-conf.in system-tools-backends-1.4.2/disks-conf.in
+--- /var/tmp/clean/system-tools-backends-1.4.2/disks-conf.in	2005-11-21 01:14:51.000000000 +0000
++++ system-tools-backends-1.4.2/disks-conf.in	2006-03-13 10:14:56.140947000 +0000
+@@ -66,7 +66,7 @@
+ @platforms = ("redhat-5.2", "redhat-6.0", "redhat-6.1", "redhat-6.2", "redhat-7.0",
+               "redhat-7.1", "mandrake-7.2", "debian-2.2", "debian-woody", "debian-sarge",
+ 	      "debian-3.1", "suse-7.0", "suse-9.1", "suse-1.0", "unitedlinux-1.0", 
+-	      "turbolinux-7.0", "rpath");
++	      "turbolinux-7.0", "nexenta-1.0", "solaris-2.11");
+ 
+ $description =<<"end_of_description;";
+        Configures locally mounted partitioned media.
+@@ -83,7 +83,11 @@
+ # Right now there's only one entry per array, as I couldn't find any
+ # typical deviations.
+ 
+-@fstab_names = ( "/etc/fstab" );
++if ($$tool{"system"} eq "SunOS") {
++  @fstab_names = ( "/etc/vfstab" );
++} else {
++  @fstab_names = ( "/etc/fstab" );
++}
+ 
+ 
+ # --- Internal configuration variables --- #
+@@ -698,7 +702,7 @@
+    }
+ }
+ 
+-sub scan_ide_bus
++sub scan_ide_bus_linux
+ {
+    my $device = shift;
+ 
+@@ -733,7 +737,145 @@
+    closedir (DIR);
+ }
+ 
+-sub scan_scsi_bus
++# wait_for(handle, regexp, regexp, ...)
++# Read from the input stream until one of the regexps matches..
++sub wait_for
++{
++	local ($c, $i, $sw, $rv, $ha); undef($wait_for_input);
++	$ha = $_[0];
++	$codes =
++		"local \$hit;\n".
++		"while(1) {\n".
++		" if ((\$c = getc(\$ha)) eq \"\") { return -1; }\n".
++		" \$wait_for_input .= \$c;\n";
++	for($i=1; $i<@_; $i++) {
++		$sw = $i>1 ? "elsif" : "if";
++		$codes .= " $sw (\$wait_for_input =~ /$_[$i]/i) { \$hit = $i-1; }\n";
++	}
++	$codes .=
++		" if (defined(\$hit)) {\n".
++		"  \@matches = (-1, \$1, \$2, \$3, \$4, \$5, \$6, \$7, \$8, \$9);\n".
++		"  return \$hit;\n".
++		"  }\n".
++		" }\n";
++	$rv = eval $codes;
++	if ($@) {
++		print STDERR $codes,"\n";
++		&error("wait_for error : $@\n");
++	}
++	return $rv;
++}
++
++# text(message, [substitute]+)
++sub text
++{
++   local $rv = $text{$_[0]};
++   local $i;
++   for($i=1; $i<@_; $i++) {
++	$rv =~ s/\$$i/$_[$i]/g;
++   }
++   return $rv;
++}
++
++# list_disks()
++# Returns a list of structures, one per disk
++sub list_disks_sunos
++{
++   local(@rv);
++   local $temp = "/tmp/stb-format.tmp";
++   open(TEMP, ">$temp");
++   print TEMP "disk\n";
++   close(TEMP);
++   open(FORMAT, "format -f $temp |");
++   while(1) {
++	   local $rv = &wait_for(FORMAT, 'Specify', '\s+\d+\. (\S+) <(.*) cyl (\d+) alt (\d+) hd (\d+) sec (\d+)>\s*(\S*)', '\s+\d+\. (\S+) <drive type unknown>', 'space for more');
++	   if ($rv == 0) { last; }
++	   elsif ($rv == 1) {
++		   local $disk = { 'device' => "/dev/dsk/$matches[1]",
++			   'type' => $matches[2] eq 'DEFAULT' ?
++				   undef : $matches[2],
++			   'cyl' => $matches[3],
++			   'alt' => $matches[4],
++			   'hd' => $matches[5],
++			   'sec' => $matches[6],
++			   'volume' => $matches[7] };
++		   if ($matches[1] =~ /c(\d+)t(\d+)d(\d+)$/) {
++			   $disk->{'desc'} = &text('select_device',
++					   "$1", "$2", "$3");
++		   }
++		   elsif ($matches[1] =~ /c(\d+)d(\d+)$/) {
++			   $disk->{'desc'} = &text('select_idedevice',
++					   chr($1*2 + $2 + 65));
++		   }
++		   push(@rv, $disk);
++	   }
++   }
++   close(FORMAT);
++   unlink($temp);
++   return @rv;
++}
++
++# list_partitions(device)
++# Returns a list of structures, one per partition
++sub list_partitions_sunos
++{
++   local(@rv, $secs, $i);
++   local @tag = ("unassigned", "boot", "root", "swap", "usr", "backup", "stand", "var", "home", "alternates", "cache");
++   open(VTOC, "prtvtoc $_[0]s0 |");
++   while(<VTOC>) {
++	if (/(\d+)\s+sectors\/cylinder/) {
++		$secs = $1;
++		}
++	if (/^\s+(\d+)\s+(\S+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)/) {
++		local $n = $1;
++		local $part = { 'tag' => $tag[$2],
++				'flag' => $3 eq "00" ? "wm" :
++					  $3 eq "01" ? "wu" :
++					  $3 eq "10" ? "rm" : "ru",
++				'start' => int($4 / $secs),
++				'end' => int($6 / $secs),
++				'device' => $_[0]."s$n" };
++		$rv[$n] = $part;
++		}
++	}
++   close(VTOC);
++   for($i=0; $i<8 || $i<@rv; $i++) {
++	$rv[$i] = { 'tag' => 'unassigned',
++		    'flag' => 'wm',
++		    'device' => $_[0]."s$i" } if (!$rv[$i]);
++	if ($_[0] =~ /c(\d+)t(\d+)d(\d+)$/) {
++		$rv[$i]->{'desc'} = &text('select_part',
++					  "$1", "$2", "$3", $i);
++		}
++	elsif ($_[0] =~ /c(\d+)d(\d+)$/) {
++		$rv[$i]->{'desc'} = &text('select_idepart',
++				    	  chr($1*2 + $2 + 65), $i);
++		}
++	}
++   return @rv;
++}
++
++sub scan_any_bus_sunos
++{
++   my $device = shift;
++#   foreach $disk (&list_disks_sunos()) {
++#	&update_disk_data ($part->{'device'}, "media", $part->{'desc'});
++#	foreach $part (&list_partitions_sunos($disk->{'device'})) {
++#		&update_disk_data ($part->{'device'}, "media", 'disk');
++#	 if ($scsi[$i]->{'device'}) { &update_disk_data ($scsi[$i]->{'device'}, "model", "$vendor $model");}
++#	}
++#   }
++}
++
++sub scan_ide_bus
++{
++   my $device = shift;
++
++   &scan_ide_bus_linux($device) if ($$tool{"system"} eq "Linux");
++   &scan_ide_bus_sunos($device) if ($$tool{"system"} eq "SunOS");
++}
++
++sub scan_scsi_bus_linux
+ {
+    my $device = shift;
+ 
+@@ -833,7 +975,20 @@
+    close (PROC_SCSI_FILE);
+ }
+ 
+-sub scan_floppy
++sub scan_scsi_bus_sunos
++{
++   my $device = shift;
++}
++
++sub scan_scsi_bus
++{
++   my $device = shift;
++
++   &scan_scsi_bus_linux($device) if ($$tool{"system"} eq "Linux");
++   &scan_scsi_bus_sunos($device) if ($$tool{"system"} eq "SunOS");
++}
++
++sub scan_floppy_linux
+ {
+    #FIXME: I don't like it
+    $floppy = `grep fd /proc/devices | wc -l`;
+@@ -849,6 +1004,16 @@
+    }
+ }
+ 
++sub scan_floppy_sunos
++{
++}
++
++sub scan_floppy
++{
++   &scan_floppy_linux($device) if ($$tool{"system"} eq "Linux");
++   &scan_floppy_sunos($device) if ($$tool{"system"} eq "SunOS");
++}
++
+ sub get_fs_type
+ {
+    my ($device) = @_;