fish: -i option should fail if / is not mountable, but warn about others.
authorRichard W.M. Jones <rjones@redhat.com>
Fri, 9 Dec 2011 09:49:37 +0000 (09:49 +0000)
committerRichard W.M. Jones <rjones@redhat.com>
Fri, 9 Dec 2011 15:35:46 +0000 (15:35 +0000)
In particular this stops a problem with guestmount where if the -i
option half-recognizes the guest OS, it would mount the disk (and
fail, giving only warnings), leaving the mountpoint unusable.

(Thanks Pádraig Brady)
(cherry picked from commit 54e91da925323642e67b8ce4b95899fe4b7a51c4)

fish/inspect.c

index 7d4401e..f93367b 100644 (file)
@@ -154,8 +154,14 @@ inspect_mount_root (const char *root)
       r = guestfs_mount_options (g, "", mountpoints[i+1], mountpoints[i]);
     else
       r = guestfs_mount_ro (g, mountpoints[i+1], mountpoints[i]);
-    if (r == -1)
+    if (r == -1) {
+      /* If the "/" filesystem could not be mounted, give up, else
+       * just count the errors and print a warning.
+       */
+      if (STREQ (mountpoints[i], "/"))
+        exit (EXIT_FAILURE);
       mount_errors++;
+    }
   }
 
   free_strings (mountpoints);