[Libguestfs] [PATCH 3/3] fish: fix btrfs subvolumes display in error case

Cédric Bosdonnat cbosdonnat at suse.com
Tue Mar 1 10:17:19 UTC 2016


The list of filesystems that is printed when there was an error prints
the internal mountable string even for the btrfs subvolumes. Let's
printing a valid -m option value instead.
---
 fish/options.c | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)

diff --git a/fish/options.c b/fish/options.c
index da5015d..5c09bfb 100644
--- a/fish/options.c
+++ b/fish/options.c
@@ -280,7 +280,20 @@ display_mountpoints_on_failure (const char *mp_device,
            guestfs_int_program_name);
 
   for (i = 0; fses[i] != NULL; i += 2) {
-    CLEANUP_FREE char *p = guestfs_canonical_device_name (g, fses[i]);
+    CLEANUP_FREE char *p = NULL;
+    CLEANUP_FREE char *device = guestfs_mountable_device(g, fses[i]);
+    CLEANUP_FREE char *volume = guestfs_mountable_subvolume(g, fses[i]);
+
+    /* Reformat the internal btrfsvol string into a valid mount option */
+    if (device && volume && guestfs_last_errno (g) != EINVAL) {
+      if (asprintf (&p, "%s:/:subvol=%s", device, volume) == -1) {
+          perror ("asprintf");
+          exit (EXIT_FAILURE);
+      }
+    } else {
+      p = guestfs_canonical_device_name (g, fses[i]);
+    }
+
     fprintf (stderr, "%s: \t%s (%s)\n", guestfs_int_program_name,
              p ? p : fses[i], fses[i+1]);
   }
-- 
2.6.2




More information about the Libguestfs mailing list