summaryrefslogtreecommitdiffstats
path: root/src/inspect.c
diff options
context:
space:
mode:
authorRichard W.M. Jones <rjones@redhat.com>2010-11-05 13:43:08 +0000
committerRichard W.M. Jones <rjones@redhat.com>2010-11-05 13:43:08 +0000
commit7d8807ec3bc0b772d65e2ca1196f0980a037504e (patch)
tree8d126df63e1f6206f0b6177785d134384deaa1cb /src/inspect.c
parent9f7926e7274aea9be43cf4bc1a9d1cf42ac6bec0 (diff)
downloadlibguestfs-7d8807ec3bc0b772d65e2ca1196f0980a037504e.tar.gz
libguestfs-7d8807ec3bc0b772d65e2ca1196f0980a037504e.tar.xz
libguestfs-7d8807ec3bc0b772d65e2ca1196f0980a037504e.zip
New API: inspect-get-roots to return roots from last inspection.
Return the roots found by the last call to inspect-os, but without redoing the whole inspection.
Diffstat (limited to 'src/inspect.c')
-rw-r--r--src/inspect.c54
1 files changed, 34 insertions, 20 deletions
diff --git a/src/inspect.c b/src/inspect.c
index e7b1e413..b06c8f68 100644
--- a/src/inspect.c
+++ b/src/inspect.c
@@ -423,28 +423,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;
}
@@ -1307,6 +1290,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)
{