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

commit b0458778972ae2e048e87edcadfa38c63dcdb065
Author: James Buren <[email protected]>
Date:   Sat Sep 21 21:06:10 2013 -0500

format: drop special sorting case for root path.
it is replaced by generic qsort sorting logic, which handles the
original case as well as allowing the possibility of having non-root
directories being setup at install time.

diff --git a/src/format.c b/src/format.c
index b10216d..dff06ab 100644
--- a/src/format.c
+++ b/src/format.c
@@ -47,6 +47,16 @@ static inline void add_target(struct format *p,int *n,int 
*size)
*n += 1;
}

+static int compare_target(const void *A,const void *B)
+{
+  struct format *a = * (struct format **) A;
+  struct format *b = * (struct format **) B;
+  size_t c = dirs_count(a->mountpath);
+  size_t d = dirs_count(b->mountpath);
+
+  return (c < d) ? -1 : (c > d) ? 1 : 0;
+}
+
static inline void probe_filesystem(struct format *target)
{
blkid_probe probe = 0;
@@ -195,35 +205,6 @@ static void format_filter_devices(void)
targets = redim(targets,struct format *,j);
}

-static bool format_sort_devices(void)
-{
-  struct format **p = targets;
-  struct format *t = 0;
-
-  for( ; *p != 0 ; ++p )
-  {
-    struct format *target = *p;
-
-    if(strcmp(target->newfilesystem,"swap") != 0 && 
strcmp(target->mountpath,g->hostroot) == 0)
-      break;
-  }
-
-  if(*p == 0)
-  {
-    errno = EINVAL;
-    error(strerror(errno));
-    return false;
-  }
-
-  t = targets[0];
-
-  targets[0] = *p;
-
-  *p = t;
-
-  return true;
-}
-
static bool format_process_devices(void)
{
int i = 0;
@@ -239,6 +220,8 @@ static bool format_process_devices(void)

padding = get_number_padding(j);

+  qsort(targets,j,sizeof(struct format *),compare_target);
+
for( ; i < j ; ++i )
{
struct format *target = targets[i];
@@ -346,9 +329,6 @@ static bool format_run(void)

format_filter_devices();

-  if(!format_sort_devices())
-    return false;
-
if(!format_process_devices())
return false;
_______________________________________________
Frugalware-git mailing list
[email protected]
http://frugalware.org/mailman/listinfo/frugalware-git

Reply via email to