From: VMware, Inc <> Date: Tue, 13 Mar 2012 20:05:29 +0000 (-0700) Subject: toolbox-cmd: fix checking if wiper is enabled before shrinking X-Git-Tag: 2012.03.13-651368~53 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=3343d305ea5f0a93113a9e1f4e6a018f4fc0a573;p=thirdparty%2Fopen-vm-tools.git toolbox-cmd: fix checking if wiper is enabled before shrinking 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 --- diff --git a/open-vm-tools/toolbox/toolboxcmd-shrink.c b/open-vm-tools/toolbox/toolboxcmd-shrink.c index c2967636f..acb74647f 100644 --- a/open-vm-tools/toolbox/toolboxcmd-shrink.c +++ b/open-vm-tools/toolbox/toolboxcmd-shrink.c @@ -30,6 +30,7 @@ # include #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; }