]> git.ipfire.org Git - thirdparty/open-vm-tools.git/commitdiff
Pick up filesystem (fsType) name for Linux disks.
authorOliver Kurth <okurth@vmware.com>
Wed, 22 May 2019 20:09:36 +0000 (13:09 -0700)
committerOliver Kurth <okurth@vmware.com>
Wed, 22 May 2019 20:09:36 +0000 (13:09 -0700)
Building upon the OS Volume Disk Mapping changes added for Windows
guests, pick up and propogate the filesystem type for Linux disks.
Move fsType related code and declaration out of the _WIN32 specific
source code.

Diskwiper code (for Linux) modified to pass along filesystem type
obtained from the MNTINFO structure from the non-Windows guest.
Also passing along the mount point for device-based mapping to be done
in the guestInfo plugin.

open-vm-tools/lib/include/wiper.h
open-vm-tools/lib/wiper/wiperCommon.c
open-vm-tools/lib/wiper/wiperPosix.c
open-vm-tools/services/plugins/guestInfo/diskInfo.c
open-vm-tools/services/plugins/guestInfo/guestInfoInt.h
open-vm-tools/services/plugins/guestInfo/guestInfoServer.c

index ad71f1749487791c9f33af8fe84c292fbf87d012..f2b44ecf705547d6088b6fb2d3a0847936cdbbf7 100644 (file)
@@ -1,5 +1,5 @@
 /*********************************************************
- * Copyright (C) 2004-2018 VMware, Inc. All rights reserved.
+ * Copyright (C) 2004-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
@@ -64,8 +64,14 @@ typedef struct WiperPartition {
 
    /* Type of the partition */
    WiperPartition_Type type;
-   
-   /* 
+
+   /* Filesystem name - testing */
+   const char *fsName;
+
+   /* Filesystem type (name) */
+   const char *fsType;
+
+   /*
     * Clients should specifically set this flag to TRUE to enable free space
     * reclamation using unmaps.
     */
index 8f111ea4447aec999b288bb4e791d4a7a1a4ed70..c3d695a27eb7e6958fb944ea3f6713ea6f496850 100644 (file)
@@ -1,5 +1,5 @@
 /*********************************************************
- * Copyright (C) 2009-2016 VMware, Inc. All rights reserved.
+ * Copyright (C) 2009-2016, 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
@@ -54,6 +54,8 @@ WiperSinglePartition_Allocate(void)
    if (p != NULL) {
       memset(p->mountPoint, 0, sizeof p->mountPoint);
       p->type = PARTITION_UNSUPPORTED;
+      p->fsType = NULL;
+      p->fsName = NULL;
       p->comment = NULL;
       p->attemptUnmaps = TRUE;
       DblLnkLst_Init(&p->link);
@@ -86,6 +88,8 @@ WiperSinglePartition_Close(WiperPartition *p)      // IN
 {
    if (p) {
       free((char *)p->comment); /* Casting away constness */
+      free((char *)p->fsType);  /* Casting away constness */
+      free((char *)p->fsName);  /* Casting away constness */
       free(p);
    }
 }
index bd5424107a97ff47a91902f95e26ccd5a06a9230..68e75cf72708881cae31c007d97d8cf6c318363c 100644 (file)
@@ -1,5 +1,5 @@
 /*********************************************************
- * Copyright (C) 2004-2018 VMware, Inc. All rights reserved.
+ * Copyright (C) 2004-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
@@ -435,6 +435,8 @@ WiperPartitionFilter(WiperPartition *item,         // IN/OUT
    size_t i;
 
    item->type = PARTITION_UNSUPPORTED;
+   item->fsType = Util_SafeStrdup(MNTINFO_FSTYPE(mnt));
+   item->fsName = Util_SafeStrdup(MNTINFO_NAME(mnt));
 
    for (i = 0; i < ARRAYSIZE(gKnownPartitions); i++) {
       info = &gKnownPartitions[i];
index 33515f0bbff2bc6fb7382a1c75e1bc903796207a..5b12c686c36d6fc5bb898d3e648905c4f73d5406 100644 (file)
@@ -131,10 +131,14 @@ GuestInfoGetDiskInfoWiper(Bool includeReserved)  // IN
          Str_Strcpy(partEntry->name, part->mountPoint, partNameSize);
          partEntry->freeBytes = freeBytes;
          partEntry->totalBytes = totalBytes;
+         Str_Strncpy(partEntry->fsType, sizeof (di->partitionList)[0].fsType,
+                     part->fsType, strlen(part->fsType));
 
          di->partitionList = newPartitionList;
-         g_debug("%s added partition #%d %s type %d free %"FMT64"u total %"FMT64"u\n",
+         g_debug("%s added partition #%d %s type %d fstype %s (mount point %s) "
+                 "free %"FMT64"u total %"FMT64"u\n",
                  __FUNCTION__, partCount, partEntry->name, part->type,
+                 partEntry->fsType, part->fsName,
                  partEntry->freeBytes, partEntry->totalBytes);
       } else {
          g_debug("%s ignoring unsupported partition %s %s\n",
index 56b82f95416f9be17d27566b70c98f8eb3c5a062..5e0fc8fc3290a428c8afd07c1a1eda911b8548dc 100644 (file)
@@ -46,11 +46,10 @@ typedef struct _PartitionEntryInt {
    uint64 freeBytes;
    uint64 totalBytes;
    char name[PARTITION_NAME_SIZE];
+   char fsType[FSTYPE_SIZE];
 #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 27c68b3cb5aa573a3419e3e753449950fb895042..3517f17a57f5cad4e50df3502cbf15d3facbeea9 100644 (file)
@@ -1237,9 +1237,9 @@ GuestInfoSendDiskInfoV1(ToolsAppCtx *ctx,             // IN
                                   "\"" DISK_INFO_KEY_DISK_NAME "\":\"%s\","
                                   "\"" DISK_INFO_KEY_DISK_FREE "\":\"%"FMT64"u\","
                                   "\"" DISK_INFO_KEY_DISK_SIZE "\":\"%"FMT64"u\"";
+   static char jsonPerDiskFsTypeFmt[] = ",\"" DISK_INFO_KEY_DISK_FSTYPE "\":\"%s\"";
 #ifdef _WIN32
    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[] = "]}";
@@ -1270,6 +1270,12 @@ GuestInfoSendDiskInfoV1(ToolsAppCtx *ctx,             // IN
                          pdi->partitionList[i].totalBytes);
       DynBuf_Append(&dynBuffer, tmpBuf, len);
       g_free(b64name);
+
+      if (pdi->partitionList[i].fsType[0] != '\0') {
+         len = Str_Snprintf(tmpBuf, sizeof tmpBuf, jsonPerDiskFsTypeFmt,
+                            pdi->partitionList[i].fsType);
+         DynBuf_Append(&dynBuffer, tmpBuf, len);
+      }
 #ifdef _WIN32
       if (reportUUID) {
          if (pdi->partitionList[i].uuid[0] != '\0') {
@@ -1278,12 +1284,6 @@ 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);