From: Oliver Kurth Date: Tue, 30 Jan 2018 00:52:18 +0000 (-0800) Subject: GuestInfo: skip check for shrinkable disk when gathering disk info X-Git-Tag: 10.2.5~19 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=97e001504a19fd51aac49acd87be837194ce2cd2;p=thirdparty%2Fopen-vm-tools.git GuestInfo: skip check for shrinkable disk when gathering disk info --- diff --git a/open-vm-tools/lib/include/wiper.h b/open-vm-tools/lib/include/wiper.h index d16972d6d..ad71f1749 100644 --- a/open-vm-tools/lib/include/wiper.h +++ b/open-vm-tools/lib/include/wiper.h @@ -1,5 +1,5 @@ /********************************************************* - * Copyright (C) 2004-2017 VMware, Inc. All rights reserved. + * Copyright (C) 2004-2018 VMware, Inc. All rights reserved. * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published @@ -96,11 +96,11 @@ typedef struct WiperInitData { } WiperInitData; Bool Wiper_Init(WiperInitData *clientData); -Bool WiperPartition_Open(WiperPartition_List *pl); +Bool WiperPartition_Open(WiperPartition_List *pl, Bool shrinkableOnly); void WiperPartition_Close(WiperPartition_List *pl); WiperPartition *WiperSinglePartition_Allocate(void); -WiperPartition *WiperSinglePartition_Open(const char *mntpt); +WiperPartition *WiperSinglePartition_Open(const char *mntpt, Bool shrinkableOnly); void WiperSinglePartition_Close(WiperPartition *); Bool Wiper_IsWipeSupported(const WiperPartition *); diff --git a/open-vm-tools/lib/wiper/wiperPosix.c b/open-vm-tools/lib/wiper/wiperPosix.c index 9dcc38733..7feaab24c 100644 --- a/open-vm-tools/lib/wiper/wiperPosix.c +++ b/open-vm-tools/lib/wiper/wiperPosix.c @@ -154,7 +154,7 @@ static Bool initDone = FALSE; /* Local functions */ static Bool WiperIsDiskDevice(MNTINFO *mnt, struct stat *s); -static void WiperPartitionFilter(WiperPartition *item, MNTINFO *mnt); +static void WiperPartitionFilter(WiperPartition *item, MNTINFO *mnt, Bool shrinkableOnly); static unsigned char *WiperGetSpace(WiperState *state, uint64 *free, uint64 *total); static void WiperClean(WiperState *state); @@ -409,6 +409,10 @@ WiperIsDiskDevice(MNTINFO *mnt, // IN * * Determine whether or not we know how to wipe a partition. * + * When the parameter 'shrinkableOnly' is TRUE, disk will be checked + * if it is really shrinkable. Otherwise only the filesystem + * will be checked for support. + * * Results: * None * @@ -420,7 +424,8 @@ WiperIsDiskDevice(MNTINFO *mnt, // IN static void WiperPartitionFilter(WiperPartition *item, // IN/OUT - MNTINFO *mnt) // IN + MNTINFO *mnt, // IN + Bool shrinkableOnly) // IN { struct stat s; const char *comment = NULL; @@ -441,7 +446,8 @@ WiperPartitionFilter(WiperPartition *item, // IN/OUT if (i == ARRAYSIZE(gKnownPartitions)) { comment = "Unknown filesystem. Contact VMware."; - } else if (item->type != PARTITION_UNSUPPORTED) { + } else if (item->type != PARTITION_UNSUPPORTED && + shrinkableOnly) { /* * If the partition is supported by the wiper library, do some other * checks before declaring it shrinkable. @@ -493,7 +499,8 @@ WiperPartitionFilter(WiperPartition *item, // IN/OUT */ WiperPartition * -WiperSinglePartition_Open(const char *mountPoint) // IN +WiperSinglePartition_Open(const char *mountPoint, // IN + Bool shrinkableOnly) // IN { char *mntpt = NULL; MNTHANDLE fp; @@ -535,7 +542,7 @@ WiperSinglePartition_Open(const char *mountPoint) // IN p = NULL; } else { WiperCollectDiskMajors(); - WiperPartitionFilter(p, mnt); + WiperPartitionFilter(p, mnt, shrinkableOnly); } goto out; @@ -645,7 +652,8 @@ WiperSinglePartition_GetSpace(const WiperPartition *p, // IN */ Bool -WiperPartition_Open(WiperPartition_List *pl) +WiperPartition_Open(WiperPartition_List *pl, + Bool shrinkableOnly) { MNTHANDLE fp; DECLARE_MNTINFO(mnt); @@ -681,7 +689,7 @@ WiperPartition_Open(WiperPartition_List *pl) break; } - WiperPartitionFilter(part, mnt); + WiperPartitionFilter(part, mnt, shrinkableOnly); DblLnkLst_LinkLast(&pl->link, &part->link); } diff --git a/open-vm-tools/services/plugins/guestInfo/diskInfo.c b/open-vm-tools/services/plugins/guestInfo/diskInfo.c index 7b236881e..d1789443b 100644 --- a/open-vm-tools/services/plugins/guestInfo/diskInfo.c +++ b/open-vm-tools/services/plugins/guestInfo/diskInfo.c @@ -1,5 +1,5 @@ /********************************************************* - * Copyright (C) 2014-2017 VMware, Inc. All rights reserved. + * Copyright (C) 2014-2018 VMware, Inc. All rights reserved. * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published @@ -90,7 +90,7 @@ GuestInfoGetDiskInfoWiper(Bool includeReserved) // IN GuestDiskInfo *di; /* Get partition list. */ - if (!WiperPartition_Open(&pl)) { + if (!WiperPartition_Open(&pl, FALSE)) { g_warning("GetDiskInfo: ERROR: could not get partition list\n"); return FALSE; } diff --git a/open-vm-tools/toolbox/toolboxcmd-shrink.c b/open-vm-tools/toolbox/toolboxcmd-shrink.c index ef192ba03..8774fa437 100644 --- a/open-vm-tools/toolbox/toolboxcmd-shrink.c +++ b/open-vm-tools/toolbox/toolboxcmd-shrink.c @@ -1,5 +1,5 @@ /********************************************************* - * Copyright (C) 2008-2017 VMware, Inc. All rights reserved. + * Copyright (C) 2008-2018 VMware, Inc. All rights reserved. * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published @@ -143,7 +143,7 @@ ShrinkGetMountPoints(WiperPartition_List *pl) // OUT: Known mount points break; case WIPER_ENABLED: - if (WiperPartition_Open(pl)) { + if (WiperPartition_Open(pl, TRUE)) { return TRUE; }