inspect: win64 regexp was dead code.
[libguestfs.git] / src / inspect.c
index e7b1e41..531e3f7 100644 (file)
@@ -29,7 +29,6 @@
 #include <pcre.h>
 #include <magic.h>
 #include <hivex.h>
-#include <augeas.h>
 
 #include "c-ctype.h"
 #include "ignore-value.h"
@@ -46,7 +45,6 @@
  * simultaneously.
  */
 static pcre *re_file_elf;
-static pcre *re_file_win64;
 static pcre *re_elf_ppc64;
 static pcre *re_fedora;
 static pcre *re_rhel_old;
@@ -95,7 +93,6 @@ static void
 free_regexps (void)
 {
   pcre_free (re_file_elf);
-  pcre_free (re_file_win64);
   pcre_free (re_elf_ppc64);
   pcre_free (re_fedora);
   pcre_free (re_rhel_old);
@@ -423,28 +420,11 @@ guestfs__inspect_os (guestfs_h *g)
   /* At this point we have, in the handle, a list of all filesystems
    * found and data about each one.  Now we assemble the list of
    * filesystems which are root devices and return that to the user.
+   * Fall through to guestfs__inspect_get_roots to do that.
    */
-  size_t count = 0;
-  for (i = 0; i < g->nr_fses; ++i)
-    if (g->fses[i].is_root)
-      count++;
-
-  char **ret = calloc (count+1, sizeof (char *));
-  if (ret == NULL) {
-    perrorf (g, "calloc");
+  char **ret = guestfs__inspect_get_roots (g);
+  if (ret == NULL)
     guestfs___free_inspect_info (g);
-    return NULL;
-  }
-
-  count = 0;
-  for (i = 0; i < g->nr_fses; ++i) {
-    if (g->fses[i].is_root) {
-      ret[count] = safe_strdup (g, g->fses[i].device);
-      count++;
-    }
-  }
-  ret[count] = NULL;
-
   return ret;
 }
 
@@ -858,7 +838,7 @@ check_linux_root (guestfs_h *g, struct inspect_fs *fs)
    * are mounted.
    * XXX What if !feature_available (g, "augeas")?
    */
-  if (guestfs_aug_init (g, "/", AUG_NO_LOAD|AUG_SAVE_NOOP) == -1)
+  if (guestfs_aug_init (g, "/", 16|32) == -1)
     return -1;
 
   /* Tell Augeas to only load /etc/fstab (thanks RaphaĆ«l Pinson). */
@@ -1307,6 +1287,37 @@ search_for_root (guestfs_h *g, const char *root)
   return NULL;
 }
 
+char **
+guestfs__inspect_get_roots (guestfs_h *g)
+{
+  /* NB. Doesn't matter if g->nr_fses == 0.  We just return an empty
+   * list in this case.
+   */
+
+  size_t i;
+  size_t count = 0;
+  for (i = 0; i < g->nr_fses; ++i)
+    if (g->fses[i].is_root)
+      count++;
+
+  char **ret = calloc (count+1, sizeof (char *));
+  if (ret == NULL) {
+    perrorf (g, "calloc");
+    return NULL;
+  }
+
+  count = 0;
+  for (i = 0; i < g->nr_fses; ++i) {
+    if (g->fses[i].is_root) {
+      ret[count] = safe_strdup (g, g->fses[i].device);
+      count++;
+    }
+  }
+  ret[count] = NULL;
+
+  return ret;
+}
+
 char *
 guestfs__inspect_get_type (guestfs_h *g, const char *root)
 {