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

commit 9d6e9b6126f5875120a9cfb523f3ef3ec6d5b8c1
Author: James Buren <[email protected]>
Date:   Sat Sep 21 22:04:28 2013 -0500

preconfig: integrate the 2 path preparation functions
they now function off one loop. the directories are
created and mounted within the same loop now. also,
the list of directories has been manually sorted to
follow the new sorting logic.

diff --git a/src/preconfig.c b/src/preconfig.c
index 39a3898..2319e52 100644
--- a/src/preconfig.c
+++ b/src/preconfig.c
@@ -17,6 +17,12 @@

#include "local.h"

+struct preconfig
+{
+  const char *path;
+  const char *filesystem;
+};
+
static inline bool preconfig_copy_fdb(const char *fdb)
{
char old[PATH_MAX] = {0};
@@ -29,83 +35,45 @@ static inline bool preconfig_copy_fdb(const char *fdb)
return copy(old,new);
}

-static bool preconfig_create_paths(void)
+static bool preconfig_prepare_paths(void)
{
size_t i = 0;
-  static const char *paths[] =
+  static const struct preconfig paths[] =
{
-    "/sys",
-    "/proc",
-    "/dev",
-    "/tmp",
-    "/var/tmp",
-    "/var/lib/pacman-g2",
-    "/var/cache/pacman-g2/pkg",
-    "/var/log",
-    "/etc/X11/xorg.conf.d",
-    0
-  };
+    {                     "/sys",    "sysfs" },
+    {                    "/proc",     "proc" },
+    {                     "/dev", "devtmpfs" },
+    {                     "/tmp",    "tmpfs" },
+    {                 "/var/tmp",    "tmpfs" },
+    {                 "/var/log",         "" },
+    {       "/var/lib/pacman-g2",         "" },
+    {     "/etc/X11/xorg.conf.d",         "" },
+    { "/var/cache/pacman-g2/pkg",         "" },
+    {                          0,          0 }
+  };
char path[PATH_MAX] = {0};
+  const struct preconfig *p = 0;

-  for( ; paths[i] != 0 ; ++i )
+  for( p = &paths[i] ; p->path != 0 && p->filesystem != 0 ; p = &paths[++i] )
{
-    strfcpy(path,sizeof(path),"%s%s",g->guestroot,paths[i]);
+    strfcpy(path,sizeof(path),"%s%s",g->guestroot,p->path);

if(!mkdir_recurse(path))
return false;
-  }
-
-  return true;
-}
-
-extern bool preconfig_mount_extra(void)
-{
-  char path[PATH_MAX] = {0};
-
-  strfcpy(path,sizeof(path),"%s/dev",g->guestroot);
-
-  if(mount("none",path,"devtmpfs",0,0) == -1)
-  {
-    error(strerror(errno));
-    return false;
-  }
-
-  strfcpy(path,sizeof(path),"%s/proc",g->guestroot);
-
-  if(mount("none",path,"proc",0,0) == -1)
-  {
-    error(strerror(errno));
-    return false;
-  }

-  strfcpy(path,sizeof(path),"%s/sys",g->guestroot);
+    if(strlen(p->filesystem) == 0)
+      continue;

-  if(mount("none",path,"sysfs",0,0) == -1)
-  {
-    error(strerror(errno));
-    return false;
-  }
-
-  strfcpy(path,sizeof(path),"%s/tmp",g->guestroot);
-
-  if(mount("none",path,"tmpfs",0,0) == -1)
-  {
-    error(strerror(errno));
-    return false;
-  }
-
-  strfcpy(path,sizeof(path),"%s/var/tmp",g->guestroot);
-
-  if(mount("none",path,"tmpfs",0,0) == -1)
-  {
-    error(strerror(errno));
-    return false;
+    if(mount("none",path,p->filesystem,0,0) == -1)
+    {
+      error(strerror(errno));
+      return false;
+    }
}

return true;
}

-
static bool preconfig_prepare_source(void)
{
char path[PATH_MAX] = {0};
@@ -156,10 +124,7 @@ static bool preconfig_prepare_source(void)

static bool preconfig_run(void)
{
-  if(!preconfig_create_paths())
-    return false;
-
-  if(!preconfig_mount_extra())
+  if(!preconfig_prepare_paths())
return false;

if(!preconfig_prepare_source())
_______________________________________________
Frugalware-git mailing list
[email protected]
http://frugalware.org/mailman/listinfo/frugalware-git

Reply via email to