]> git.ipfire.org Git - thirdparty/open-vm-tools.git/commitdiff
toolbox-cmd: fix checking if wiper is enabled before shrinking
authorVMware, Inc <>
Tue, 13 Mar 2012 20:05:29 +0000 (13:05 -0700)
committerDmitry Torokhov <dtor@vmware.com>
Wed, 14 Mar 2012 16:04:58 +0000 (09:04 -0700)
We may not be allowed to shrink volume(s) even if wiper
functionality is available (because of presence of snapshots,
linked clones and other factors). Unfortunately CS 1409972
broke this and resulted in toolbox-cmd proceeding to wipe disk
only to be informed later that shrink could not be completed.

Signed-off-by: Dmitry Torokhov <dtor@vmware.com>
open-vm-tools/toolbox/toolboxcmd-shrink.c

index c2967636fb746ef8b5c141e483372b2a3222cf94..acb74647f2910ced29222e0d593637b47c7f5cb6 100644 (file)
@@ -30,6 +30,7 @@
 #   include <signal.h>
 #endif
 
+#include "vm_assert.h"
 #include "toolboxCmdInt.h"
 #include "guestApp.h"
 #include "wiper.h"
@@ -128,16 +129,33 @@ ShrinkGetWiperState(void)
 static Bool
 ShrinkGetMountPoints(WiperPartition_List *pl) // OUT: Known mount points
 {
-   if (ShrinkGetWiperState() == WIPER_UNAVAILABLE) {
+   WiperState state = ShrinkGetWiperState();
+
+   switch (state) {
+   case WIPER_UNAVAILABLE:
       ToolsCmd_PrintErr("%s",
                         SU_(disk.shrink.unavailable, SHRINK_FEATURE_ERR));
-   } else if (!WiperPartition_Open(pl)) {
+      break;
+
+   case WIPER_DISABLED:
+      ToolsCmd_PrintErr("%s",
+                        SU_(disk.shrink.disabled, SHRINK_DISABLED_ERR));
+      break;
+
+   case WIPER_ENABLED:
+      if (WiperPartition_Open(pl)) {
+         return TRUE;
+      }
+
       ToolsCmd_PrintErr("%s",
                         SU_(disk.shrink.partition.error,
                            "Unable to collect partition data.\n"));
-   } else {
-      return TRUE;
+      break;
+
+   default:
+      NOT_REACHED();
    }
+
    return FALSE;
 }