[Setup-tool-hackers] First crack at porting g-s-t to FreeBSD



Here is a diff to the partition.pl.in in g-s-t 0.26.0.  It adds the
equivalent FreeBSD support.  Note, this new function is not called
anywhere yet.  What I'm trying to gage is the coding style and flow.  Is
this consistent with what you expect from a backend module?  Please Cc
me since I'm not [yet] subscribed to the list.  Thanks.

Joe 
-- 
Joe Marcus Clarke
FreeBSD GNOME Team	::	marcus@FreeBSD.org
http://www.FreeBSD.org/gnome


--- partition.pl.in.orig	Thu May 29 12:50:11 2003
+++ partition.pl.in	Thu May 29 15:16:18 2003
@@ -21,6 +21,8 @@
 # along with this program; if not, write to the Free Software
 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
 
+use Errno;
+
 $SCRIPTSDIR = "___scriptsdir___";
 if ($SCRIPTSDIR =~ /^___scriptsdir__[_]/)
 {
@@ -31,6 +33,114 @@
 require "$SCRIPTSDIR/general.pl$DOTIN";
 require "$SCRIPTSDIR/report.pl$DOTIN";
 
+@DEVICE_NAMES = (
+    {
+      "name" => "da",
+      "max"  => 16,
+    },
+    {
+      "name" => "ad",
+      "max"  => 16,
+    },
+    {
+      "name" => "ar",
+      "max"  => 16,
+    },
+    {
+      "name" => "fla",
+      "max"  => 16,
+    },
+    {
+      "name" => "afd",
+      "max"  => 4,
+    },
+    {
+      "name" => "mlx",
+      "max"  => 4,
+    },
+    {
+      "name" => "amrd",
+      "max"  => 4,
+    },
+    {
+      "name" => "idad",
+      "max"  => 4,
+    },
+    {
+      "name" => "twed",
+      "max"  => 4,
+    },
+    {
+      "name" => "aacd",
+      "max"  => 4,
+    },
+    {
+      "name" => "ipsd",
+      "max"  => 4,
+    },
+    {
+      "name" => "wd",
+      "max"  => 16,
+    },
+);
+
+sub gst_partition_scan_info_freebsd
+{
+  my ($fd, $line);
+  my (%hash);
+  my (@table);
+  local (*DEV);
+
+  # Some of this code has been adapted from the way
+  # sysinstall learns about devices.
+  foreach my $device (@DEVICE_NAMES)
+  {
+    for (my $i = 0; $i < $device->{"max"}; $i++)
+    {
+      my $dev = "/dev/" . $device->{"name"} . $i;
+      if (open (DEV, $dev) || $! == EBUSY)
+      {
+	if ($! == 0)
+	{
+	  close (DEV);
+	}
+	$fd = &gst_file_run_pipe ("fdisk -s " . $dev);
+	if ($fd eq undef)
+	{
+	  &gst_report ("fdisk_failed");
+	  return undef;
+	}
+
+	while ($line = <$fd>)
+	{
+	  # Example output from fdisk -s:
+	  # /dev/ad0: 26310 cyl 16 hd 63 sec
+	  # Part        Start        Size Type Flags
+	  #    1:          63    26520417 0xa5 0x80
+	  #
+	  if ($line =~ /^[ \t]+(\d+):[ \t]+(\d+)[ \t]+(\d+)[ \t]+0x([a-f0-9A-F][a-f0-9A-F])[ \t]+0x([a-f0-9A-F][a-f0-9A-F])$/)
+	  {
+	    $bootable = ($5 eq 80)? 0: 1;
+
+	    push @table, {"dev" => $dev,
+#                         "id"     => $1,
+#                         "start"  => $2,
+#                         "size"   => $3,
+#                         "boot"   => $bootable,
+                          "type" => $GST_FILESYS_TYPES{$4}
+			};
+          }
+	}
+
+	close $fd;
+      }
+    }
+  }
+
+  $hash{"partition"} = \@table;
+
+  return \%hash;
+}
 
 sub gst_partition_scan_info
 {

This is a digitally signed message part



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]