From: "Richard W.M. Jones" <rjones(a)redhat.com>
list-filesystems was returning NULL (but not setting an error) if no
filesystems were found. Instead return an empty list.
(cherry picked from commit f1d2934216d3fca0501946c8ae0e5c7cd370e6b6)
(cherry picked from commit 19309661008ef1d13c05fad5401d95f260fbdae2)
---
src/listfs.c | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/src/listfs.c b/src/listfs.c
index 4bcdf51..b87a021 100644
--- a/src/listfs.c
+++ b/src/listfs.c
@@ -46,7 +46,7 @@ char **
guestfs__list_filesystems (guestfs_h *g)
{
size_t i;
- char **ret = NULL;
+ char **ret;
size_t ret_size = 0;
CLEANUP_FREE_STRING_LIST char **devices = NULL;
@@ -56,6 +56,13 @@ guestfs__list_filesystems (guestfs_h *g)
CLEANUP_FREE_STRING_LIST char **ldmvols = NULL;
CLEANUP_FREE_STRING_LIST char **ldmparts = NULL;
+ /* We need to initialize this with an empty list so that if there
+ * are no filesystems at all, we return an empty list (not NULL).
+ * See also add_vfs function below.
+ */
+ ret = safe_malloc (g, sizeof (char *));
+ ret[0] = NULL;
+
/* Look to see if any devices directly contain filesystems
* (RHBZ#590167). However vfs-type will fail to tell us anything
* useful about devices which just contain partitions, so we also
--
1.8.3.1