From: Oliver Kurth Date: Wed, 8 May 2019 22:27:19 +0000 (-0700) Subject: Plumb through filesystemType X-Git-Tag: stable-11.0.0~82 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9876844113a4f6b538f131d61b61c994264f7caf;p=thirdparty%2Fopen-vm-tools.git Plumb through filesystemType Implement the filesystemType property in the vim.vm.guestInfo.DiskInfo. --- diff --git a/open-vm-tools/lib/include/guestInfo.h b/open-vm-tools/lib/include/guestInfo.h index 07ca5fbca..613acb195 100644 --- a/open-vm-tools/lib/include/guestInfo.h +++ b/open-vm-tools/lib/include/guestInfo.h @@ -1,5 +1,5 @@ /********************************************************* - * 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 @@ -56,6 +56,7 @@ #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" @@ -109,6 +110,15 @@ typedef struct _DiskInfo { #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" + /** * @} */ diff --git a/open-vm-tools/services/plugins/guestInfo/guestInfoInt.h b/open-vm-tools/services/plugins/guestInfo/guestInfoInt.h index 068e48244..56b82f954 100644 --- a/open-vm-tools/services/plugins/guestInfo/guestInfoInt.h +++ b/open-vm-tools/services/plugins/guestInfo/guestInfoInt.h @@ -49,6 +49,8 @@ typedef struct _PartitionEntryInt { #ifdef _WIN32 /* UUID of the disk, if known. Currently only Windows */ char uuid[PARTITION_NAME_SIZE]; + /* filesystem type. Currently only Windows */ + char fsType[FSTYPE_SIZE]; #endif } PartitionEntryInt; diff --git a/open-vm-tools/services/plugins/guestInfo/guestInfoServer.c b/open-vm-tools/services/plugins/guestInfo/guestInfoServer.c index 92320b1d7..27c68b3cb 100644 --- a/open-vm-tools/services/plugins/guestInfo/guestInfoServer.c +++ b/open-vm-tools/services/plugins/guestInfo/guestInfoServer.c @@ -1231,14 +1231,15 @@ GuestInfoSendDiskInfoV1(ToolsAppCtx *ctx, // IN * 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[] = "]}"; @@ -1277,6 +1278,12 @@ GuestInfoSendDiskInfoV1(ToolsAppCtx *ctx, // IN 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);