]> git.ipfire.org Git - thirdparty/open-vm-tools.git/commitdiff
Plumb through filesystemType
authorOliver Kurth <okurth@vmware.com>
Wed, 8 May 2019 22:27:19 +0000 (15:27 -0700)
committerOliver Kurth <okurth@vmware.com>
Wed, 8 May 2019 22:27:19 +0000 (15:27 -0700)
Implement the filesystemType property in the vim.vm.guestInfo.DiskInfo.

open-vm-tools/lib/include/guestInfo.h
open-vm-tools/services/plugins/guestInfo/guestInfoInt.h
open-vm-tools/services/plugins/guestInfo/guestInfoServer.c

index 07ca5fbcaff415afbe3de9faf7aee7a8a835ba05..613acb195a8ae904d63ebb82af9af1fd67ae1aaf 100644 (file)
@@ -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"
+
 /**
  * @}
  */
index 068e48244f99b6976528bbbf2c447d4c11a03a26..56b82f95416f9be17d27566b70c98f8eb3c5a062 100644 (file)
@@ -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;
 
index 92320b1d788ee458e1abbe228d2a207ec2b66362..27c68b3cb5aa573a3419e3e753449950fb895042 100644 (file)
@@ -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);