summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard W.M. Jones <rjones@redhat.com>2012-11-29 17:24:30 +0000
committerRichard W.M. Jones <rjones@redhat.com>2012-11-29 18:27:26 +0000
commit6ee80b8dac508927ff56ba6093bc47755f4880ae (patch)
tree31f51ab1c364c4ef54e6bf5173d964a470134826
parent90e7981082a2685b235724a6dd9b737cb90fe553 (diff)
downloadlibguestfs-6ee80b8dac508927ff56ba6093bc47755f4880ae.tar.gz
libguestfs-6ee80b8dac508927ff56ba6093bc47755f4880ae.tar.xz
libguestfs-6ee80b8dac508927ff56ba6093bc47755f4880ae.zip
inspection: Don't probe partitions when we've probed the whole device (RHBZ#798979).
So we don't get multiple <operatingsystem> entries, particularly for install ISOs.
-rw-r--r--src/inspect.c31
1 files changed, 31 insertions, 0 deletions
diff --git a/src/inspect.c b/src/inspect.c
index 725a71b4..30e9762e 100644
--- a/src/inspect.c
+++ b/src/inspect.c
@@ -41,6 +41,8 @@
#include "guestfs-internal-actions.h"
#include "guestfs_protocol.h"
+static int parent_device_already_probed (guestfs_h *g, const char *partition);
+
/* The main inspection code. */
char **
guestfs__inspect_os (guestfs_h *g)
@@ -78,6 +80,9 @@ guestfs__inspect_os (guestfs_h *g)
}
for (i = 0; partitions[i] != NULL; ++i) {
+ if (parent_device_already_probed (g, partitions[i]))
+ continue;
+
if (guestfs___check_for_filesystem_on (g, partitions[i], 0, i+1) == -1) {
guestfs___free_string_list (partitions);
guestfs___free_inspect_info (g);
@@ -132,6 +137,32 @@ guestfs__inspect_os (guestfs_h *g)
return ret;
}
+/* If we found a filesystem on the parent device then ignore the
+ * partitions within.
+ */
+static int
+parent_device_already_probed (guestfs_h *g, const char *partition)
+{
+ char *device;
+ size_t i;
+
+ guestfs_push_error_handler (g, NULL, NULL);
+ device = guestfs_part_to_dev (g, partition);
+ guestfs_pop_error_handler (g);
+ if (!device)
+ return 0;
+
+ for (i = 0; i < g->nr_fses; ++i) {
+ if (STREQ (device, g->fses[i].device)) {
+ free (device);
+ return 1;
+ }
+ }
+
+ free (device);
+ return 0;
+}
+
static int
compare_strings (const void *vp1, const void *vp2)
{