+examine_devices (guestfs_h *g)
+{
+ CLEANUP_FREE_STRING_LIST char **devices = NULL;
+ size_t i;
+
+ /* Get list of devices. */
+ devices = guestfs_list_devices (g);
+ if (devices == NULL)
+ return -1;
+
+ for (i = 0; devices[i] != NULL; ++i) {
+ CLEANUP_FREE char *object = NULL;
+ int64_t size;
+
+ printf ("virt-bmap: examining %s ...\n", devices[i]);
+
+ if (asprintf (&object, "v %s", devices[i]) == -1)
+ return -1;
+
+ /* We don't actually bother to examine the device, which would be
+ * slow and pointless. We just mark it in the map.
+ */
+ size = guestfs_blockdev_getsize64 (g, devices[i]);
+ if (size == -1)
+ return -1;
+
+ pthread_mutex_lock (¤t_object_mutex);
+ insert_range (ranges, 0, size, object);
+ pthread_mutex_unlock (¤t_object_mutex);
+ }
+
+ return 0;
+}
+
+static int