/*********************************************************
- * Copyright (C) 2003-2018 VMware, Inc. All rights reserved.
+ * Copyright (C) 2003-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
#define MAC_ADDR_SIZE 19
#define IP_ADDR_SIZE 16
#define PARTITION_NAME_SIZE MAX_VALUE_LEN
+#define FSTYPE_SIZE 260 // Windows fs types can be up to MAX_PATH chars
/* Value to be used when "primary" IP address is indeterminable. */
#define GUESTINFO_IP_UNKNOWN "unknown"
#define DISK_INFO_VERSION_1 1
+/* Disk info json keys */
+#define DISK_INFO_KEY_VERSION "version"
+#define DISK_INFO_KEY_DISKS "disks"
+#define DISK_INFO_KEY_DISK_NAME "name"
+#define DISK_INFO_KEY_DISK_FREE "free"
+#define DISK_INFO_KEY_DISK_SIZE "size"
+#define DISK_INFO_KEY_DISK_UUID "uuid"
+#define DISK_INFO_KEY_DISK_FSTYPE "fstype"
+
/**
* @}
*/
* with older VMXs.
*/
static char headerFmt[] = "%s {\n"
- "\"version\":\"%d\",\n"
- "\"disks\":[\n";
+ "\"" DISK_INFO_KEY_VERSION "\":\"%d\",\n"
+ "\"" DISK_INFO_KEY_DISKS "\":[\n";
static char jsonPerDiskFmt[] = "{"
- "\"name\":\"%s\","
- "\"free\":\"%"FMT64"u\","
- "\"size\":\"%"FMT64"u\"";
+ "\"" DISK_INFO_KEY_DISK_NAME "\":\"%s\","
+ "\"" DISK_INFO_KEY_DISK_FREE "\":\"%"FMT64"u\","
+ "\"" DISK_INFO_KEY_DISK_SIZE "\":\"%"FMT64"u\"";
#ifdef _WIN32
- static char jsonPerDiskUUIDFmt[] = ",\"uuid\":\"%s\"";
+ static char jsonPerDiskUUIDFmt[] = ",\"" DISK_INFO_KEY_DISK_UUID "\":\"%s\"";
+ static char jsonPerDiskFsTypeFmt[] = ",\"" DISK_INFO_KEY_DISK_FSTYPE "\":\"%s\"";
#endif
static char jsonPerDiskFmtFooter[] = "},\n";
static char jsonSuffix[] = "]}";
DynBuf_Append(&dynBuffer, tmpBuf, len);
}
}
+
+ if (pdi->partitionList[i].fsType[0] != '\0') {
+ len = Str_Snprintf(tmpBuf, sizeof tmpBuf, jsonPerDiskFsTypeFmt,
+ pdi->partitionList[i].fsType);
+ DynBuf_Append(&dynBuffer, tmpBuf, len);
+ }
#endif
DynBuf_Append(&dynBuffer, jsonPerDiskFmtFooter,
sizeof jsonPerDiskFmtFooter - 1);