From: Oliver Kurth Date: Tue, 5 Dec 2017 00:27:20 +0000 (-0800) Subject: GuestInfo: skip check for shrinkable disk when gathering disk info X-Git-Tag: stable-10.3.0~202 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=1667bc143164a6709debca423e4be0241e3275db;p=thirdparty%2Fopen-vm-tools.git GuestInfo: skip check for shrinkable disk when gathering disk info Some Linux OSes may have a non-existing device mounted to a filesystem, for example Photon OS has the root file system mounted from /dev/root, which does not exist. The wiper library does a check for a shrinkable disk, and this fails. This change skips the check when gathering data for diskinfo, but leaves it intact for other disk wiper purposes. Information from read-only flesystems will also be reported. --- diff --git a/open-vm-tools/lib/include/wiper.h b/open-vm-tools/lib/include/wiper.h index d16972d6d..49892313c 100644 --- a/open-vm-tools/lib/include/wiper.h +++ b/open-vm-tools/lib/include/wiper.h @@ -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 a0458329e..fd98f06d1 100644 --- a/open-vm-tools/services/plugins/guestInfo/diskInfo.c +++ b/open-vm-tools/services/plugins/guestInfo/diskInfo.c @@ -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..db714f33e 100644 --- a/open-vm-tools/toolbox/toolboxcmd-shrink.c +++ b/open-vm-tools/toolbox/toolboxcmd-shrink.c @@ -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; }