Git-Url: 
http://git.frugalware.org/gitweb/gitweb.cgi?p=fwlive.git;a=commitdiff;h=fcead276a95abf917d71fe1917c46a7d984f99d1

commit fcead276a95abf917d71fe1917c46a7d984f99d1
Author: James Buren <[email protected]>
Date:   Thu Nov 8 02:41:55 2012 -0600

add initial setup code which probes devices and opens disk structs

diff --git a/src/partition.c b/src/partition.c
index 503969b..aa71596 100644
--- a/src/partition.c
+++ b/src/partition.c
@@ -1,12 +1,61 @@
#include "local.h"

+static struct device **devices = 0;
+static struct disk **disks = 0;
+
+static bool partition_setup(void)
+{
+  int i = 0;
+
+  if((devices = device_probe_all(true)) == 0)
+    return false;
+
+  for( ; devices[i] != 0 ; ++i )
+    ;
+
+  disks = malloc0(sizeof(struct disk *) * (i + 1));
+
+  for( i = 0 ; devices[i] != 0 ; ++i )
+    disks[i] = disk_open(devices[i]);
+
+  return true;
+}
+
static bool partition_run(void)
{
+  if(!partition_setup())
+    return false;
+
return true;
}

static void partition_reset(void)
{
+  int i = 0;
+
+  if(devices != 0)
+  {
+    if(disks != 0)
+    {
+      for( i = 0 ; disks[i] != 0 ; ++i )
+      {
+        disk_close(disks[i]);
+      }
+
+      free(disks);
+
+      disks = 0;
+    }
+
+    for( i = 0 ; devices[i] != 0 ; ++i )
+    {
+      device_close(devices[i]);
+    }
+
+    free(devices);
+
+    devices = 0;
+  }
}

struct module partition_module =
_______________________________________________
Frugalware-git mailing list
[email protected]
http://frugalware.org/mailman/listinfo/frugalware-git

Reply via email to