Git-Url: 
http://git.frugalware.org/gitweb/gitweb.cgi?p=fvbe.git;a=commitdiff;h=4e6006d4df63b2faf195428989b3060d4cd34579

commit 4e6006d4df63b2faf195428989b3060d4cd34579
Author: James Buren <[email protected]>
Date:   Wed Jul 17 14:35:40 2013 -0500

main: replace how isodevice is found.
read it from /proc/mounts instead of wasting time with blkid.

diff --git a/src/block.c b/src/block.c
index 269f054..10f1832 100644
--- a/src/block.c
+++ b/src/block.c
@@ -368,7 +368,7 @@ extern struct device **device_probe_all(bool disk,bool raid)
else
continue;

-    if(strncmp(path,g->isodevice,8) == 0 || (device = device_open(path)) == 0)
+    if(strncmp(path,strng(g->isodevice),8) == 0 || (device = 
device_open(path)) == 0)
continue;

devices[i++] = device;
diff --git a/src/local.h b/src/local.h
index 3fabaa5..1a90fd5 100644
--- a/src/local.h
+++ b/src/local.h
@@ -54,6 +54,7 @@
#define NEWT_HEIGHT 21
#endif

+#define ISO_ROOT "/run/initramfs/live"
#define SPACE_CHARS " \t\r\n\v\f"
#define LOWER_CHARS "abcdefghijklmnopqrstuvwxyz"
#define TEXT_MAX 8192
diff --git a/src/main.c b/src/main.c
index 19fbf4c..0f6fe6a 100644
--- a/src/main.c
+++ b/src/main.c
@@ -24,50 +24,35 @@ static inline bool infvbe(void)
return (env != 0 && strcmp(env,"fvbe") == 0);
}

-static void find_iso(void)
+static void find_iso_device(void)
{
-  blkid_cache cache = 0;
-  blkid_dev_iterate iter = 0;
-  blkid_dev dev = 0;
-  char path[PATH_MAX] = {0};
+  FILE *file = 0;
+  char line[LINE_MAX] = {0};
+  char *device = 0;
+  char *root = 0;

-  if(blkid_get_cache(&cache,"/dev/null") != 0)
-  {
-    error("failed to create blkid cache");
-    goto bail;
-  }
-
-  if(blkid_probe_all(cache) != 0)
+  if((file = fopen("/proc/mounts","rb")) == 0)
{
-    error("failed to probe blkid devices");
-    goto bail;
-  }
-
-  if(blkid_probe_all_removable(cache) != 0)
-  {
-    error("failed to probe removable blkid devices");
-    goto bail;
+    error(strerror(errno));
+    return;
}
-
-  if((iter = blkid_dev_iterate_begin(cache)) == 0)
+
+  while(fgets(line,sizeof(line),file) != 0)
{
-    error("failed to create blkid dev iter");
-    goto bail;
+    if((device = strtok(line,SPACE_CHARS)) == 0)
+      continue;
+
+    if((root = strtok(0,SPACE_CHARS)) == 0)
+      continue;
+
+    if(strcmp(root,ISO_ROOT) == 0)
+    {
+      g->isodevice = strdup(device);
+      break;
+    }
}
-
-  while(blkid_dev_next(iter,&dev) == 0)
-    if(blkid_dev_has_tag(dev,"TYPE","iso9660") && 
blkid_dev_has_tag(dev,"LABEL","FVBE"))
-      strfcpy(path,sizeof(path),"%s",blkid_dev_devname(dev));
-
-  blkid_dev_iterate_end(iter);
-
-  if(strlen(path) != 0)
-    g->isodevice = strdup(path);
-
-bail:

-  if(cache != 0)
-    blkid_put_cache(cache);
+  fclose(file);
}

static void global_cleanup(void)
@@ -145,7 +130,7 @@ extern int main(int argc,char **argv)

g->guestroot = "/mnt/install";

-    find_iso();
+    find_iso_device();
}
else
{
diff --git a/src/preconfig.c b/src/preconfig.c
index 3eff0eb..39a3898 100644
--- a/src/preconfig.c
+++ b/src/preconfig.c
@@ -17,8 +17,6 @@

#include "local.h"

-#define ISO_ROOT "/run/initramfs/live"
-
static inline bool preconfig_copy_fdb(const char *fdb)
{
char old[PATH_MAX] = {0};
_______________________________________________
Frugalware-git mailing list
[email protected]
http://frugalware.org/mailman/listinfo/frugalware-git

Reply via email to