/*********************************************************
- * Copyright (C) 2014-2018 VMware, Inc. All rights reserved.
+ * Copyright (C) 2014-2019 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
*/
void
-GuestInfo_FreeDiskInfo(GuestDiskInfo *di)
+GuestInfo_FreeDiskInfo(GuestDiskInfoInt *di)
{
if (di) {
free(di->partitionList);
*
* Uses wiper library to enumerate fixed volumes and lookup utilization data.
*
- * @return Pointer to a GuestDiskInfo structure on success or NULL on failure.
- * Caller should free returned pointer with GuestInfoFreeDiskInfo.
+ * @return Pointer to a GuestDiskInfoInt structure on success or NULL on failure.
+ * Caller should free returned pointer with GuestInfo_FreeDiskInfo.
*
******************************************************************************
*/
-GuestDiskInfo *
+GuestDiskInfoInt *
GuestInfoGetDiskInfoWiper(Bool includeReserved) // IN
{
WiperPartition_List pl;
uint64 totalBytes = 0;
unsigned int partNameSize = 0;
Bool success = FALSE;
- GuestDiskInfo *di;
+ GuestDiskInfoInt *di;
/* Get partition list. */
if (!WiperPartition_Open(&pl, FALSE)) {
WiperPartition *part = DblLnkLst_Container(curr, WiperPartition, link);
if (part->type != PARTITION_UNSUPPORTED) {
- PPartitionEntry newPartitionList;
- PPartitionEntry partEntry;
+ PartitionEntryInt *newPartitionList;
+ PartitionEntryInt *partEntry;
unsigned char *error;
if (includeReserved) {
error = WiperSinglePartition_GetSpace(part, NULL,
/*********************************************************
- * Copyright (C) 2014-2017 VMware, Inc. All rights reserved.
+ * Copyright (C) 2014-2019 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
*
* Uses wiper library to enumerate fixed volumes and lookup utilization data.
*
- * @return Pointer to a GuestDiskInfo structure on success or NULL on failure.
- * Caller should free returned pointer with GuestInfoFreeDiskInfo.
+ * @return Pointer to a GuestDiskInfoInt structure on success or NULL on failure.
+ * Caller should free returned pointer with GuestInfo_FreeDiskInfo.
*
******************************************************************************
*/
-GuestDiskInfo *
+GuestDiskInfoInt *
GuestInfo_GetDiskInfo(const ToolsAppCtx *ctx)
{
gboolean includeReserved;
/*********************************************************
- * Copyright (C) 2008-2018 VMware, Inc. All rights reserved.
+ * Copyright (C) 2008-2019 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
/**
* @file guestInfoInt.h
*
- * Declares internal functions of the guestInfo plugin.
+ * Declares internal functions and data structures of the guestInfo plugin.
*/
#define G_LOG_DOMAIN "guestinfo"
#include "nicInfo.h"
#include "dynbuf.h"
+/*
+ * Plugin-specific data structures for the DiskGuestInfo.
+ *
+ * These expand upon the GuestDiskInfo in bora/public/guestInfo.h,
+ * but are not shared and need not maintain any version compatibility.
+ */
+
+typedef struct _PartitionEntryInt {
+ uint64 freeBytes;
+ uint64 totalBytes;
+ char name[PARTITION_NAME_SIZE];
+#ifdef _WIN32
+ /* UUID of the disk, if known. Currently only Windows */
+ char uuid[PARTITION_NAME_SIZE];
+#endif
+} PartitionEntryInt;
+
+typedef struct _GuestDiskInfoInt {
+ unsigned int numEntries;
+ PartitionEntryInt *partitionList;
+} GuestDiskInfoInt;
+
extern int guestInfoPollInterval;
Bool
gboolean
GuestInfo_StatProviderPoll(gpointer data);
-GuestDiskInfo *
+GuestDiskInfoInt *
GuestInfoGetDiskInfoWiper(Bool includeReserved);
-GuestDiskInfo *
+GuestDiskInfoInt *
GuestInfo_GetDiskInfo(const ToolsAppCtx *ctx);
void
-GuestInfo_FreeDiskInfo(GuestDiskInfo *di);
+GuestInfo_FreeDiskInfo(GuestDiskInfoInt *di);
void
GuestInfo_StatProviderShutdown(void);
HostinfoDetailedDataHeader *detailedData;
NicInfoV3 *nicInfo;
NicInfoMethod method;
- GuestDiskInfo *diskInfo;
+ GuestDiskInfoInt *diskInfo;
Bool diskInfoUseJson;
} GuestInfoCache;
GuestInfoType key,
const char *value);
static void SendUptime(ToolsAppCtx *ctx);
-static Bool DiskInfoChanged(const GuestDiskInfo *diskInfo);
+static Bool DiskInfoChanged(const GuestDiskInfoInt *diskInfo);
static void GuestInfoClearCache(void);
static GuestNicList *NicInfoV3ToV2(const NicInfoV3 *infoV3);
static void TweakGatherLoops(ToolsAppCtx *ctx,
// "Host names are limited to 255 bytes"
#if !defined(USERWORLD)
gboolean disableQueryDiskInfo;
- GuestDiskInfo *diskInfo = NULL;
+ GuestDiskInfoInt *diskInfo = NULL;
#endif
NicInfoV3 *nicInfo = NULL;
ToolsAppCtx *ctx = data;
* RPC
*
* @param[in] ctx Application context.
- * @param[in] pdi GuestDiskInfo *
+ * @param[in] pdi GuestDiskInfoInt *
* @param[in] infoSize Size of disk info.
*
* @retval TRUE Update sent successfully.
static Bool
GuestInfoSendDiskInfoV1(ToolsAppCtx *ctx, // IN
- GuestDiskInfo *pdi, // IN
+ GuestDiskInfoInt *pdi, // IN
size_t infoSize) // IN
{
DynBuf dynBuffer;
static char jsonSuffix[] = "]}";
int i;
- // 20 bytes per numbr for ascii representation
+ // 20 bytes per number for ascii representation
ASSERT_ON_COMPILE(sizeof tmpBuf > sizeof jsonPerDiskFmt +
PARTITION_NAME_SIZE + 20 + 20);
* format.
*
* @param[in] ctx Application context.
- * @param[in] pdi GuestDiskInfo *
+ * @param[in] pdiInt GuestDiskInfoInt *
* @param[in] infoSize Size of disk info.
*
* @retval TRUE Update sent successfully.
static Bool
GuestInfoSendDiskInfoV0(ToolsAppCtx *ctx, // IN
- GuestDiskInfo *pdi, // IN
+ GuestDiskInfoInt *pdiInt, // IN
size_t infoSize) // IN
{
/*
char *reply;
size_t replyLen;
Bool status;
+ GuestDiskInfo *pdi;
+ int i;
- ASSERT((pdi->numEntries && pdi->partitionList) ||
- (!pdi->numEntries && !pdi->partitionList));
+ ASSERT((pdiInt->numEntries && pdiInt->partitionList) ||
+ (!pdiInt->numEntries && !pdiInt->partitionList));
+
+ /*
+ * Build a GuestDiskInfo structure to provide the expected binary
+ * format for the binary RPC, copying out the V0 elements.
+ */
+ pdi = Util_SafeCalloc(1, sizeof *pdi);
+ pdi->numEntries = pdiInt->numEntries;
+ pdi->partitionList = Util_SafeCalloc(pdi->numEntries,
+ sizeof *pdi->partitionList);
+ for (i = 0; i < pdi->numEntries; i++) {
+ pdi->partitionList[i].freeBytes = pdiInt->partitionList[i].freeBytes;
+ pdi->partitionList[i].totalBytes = pdiInt->partitionList[i].totalBytes;
+ Str_Strcpy(pdi->partitionList[i].name,
+ pdiInt->partitionList[i].name,
+ PARTITION_NAME_SIZE);
+ }
/* partitionCount is a uint8 and cannot be larger than UCHAR_MAX. */
if (pdi->numEntries > UCHAR_MAX) {
vm_free(request);
vm_free(reply);
+ vm_free(pdi->partitionList);
+ vm_free(pdi);
+
return status;
}
* Push updated Disk info to the VMX.
*
* @param[in] ctx Application context.
- * @param[in] info GuestDiskInfo *
+ * @param[in] info GuestDiskInfoInt *
* @param[in] infoSize Size of disk info.
*
* @retval TRUE Update sent successfully.
static Bool
GuestInfoSendDiskInfo(ToolsAppCtx *ctx, // IN
- GuestDiskInfo *info, // IN
+ GuestDiskInfoInt *info, // IN
size_t infoSize) // IN
{
if (gInfoCache.diskInfoUseJson &&
*/
static Bool
-DiskInfoChanged(const GuestDiskInfo *diskInfo)
+DiskInfoChanged(const GuestDiskInfoInt *diskInfo)
{
int index;
char *name;
int i;
int matchedPartition;
- PGuestDiskInfo cachedDiskInfo;
+ GuestDiskInfoInt *cachedDiskInfo;
cachedDiskInfo = gInfoCache.diskInfo;