From: Oliver Kurth Date: Wed, 22 May 2019 20:09:36 +0000 (-0700) Subject: Pick up filesystem (fsType) name for Linux disks. X-Git-Tag: stable-11.0.0~77 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8017efa7e941561274088d27e32883f6c1965abf;p=thirdparty%2Fopen-vm-tools.git Pick up filesystem (fsType) name for Linux disks. 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. --- diff --git a/open-vm-tools/lib/include/wiper.h b/open-vm-tools/lib/include/wiper.h index ad71f1749..f2b44ecf7 100644 --- a/open-vm-tools/lib/include/wiper.h +++ b/open-vm-tools/lib/include/wiper.h @@ -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. */ diff --git a/open-vm-tools/lib/wiper/wiperCommon.c b/open-vm-tools/lib/wiper/wiperCommon.c index 8f111ea44..c3d695a27 100644 --- a/open-vm-tools/lib/wiper/wiperCommon.c +++ b/open-vm-tools/lib/wiper/wiperCommon.c @@ -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); } } diff --git a/open-vm-tools/lib/wiper/wiperPosix.c b/open-vm-tools/lib/wiper/wiperPosix.c index bd5424107..68e75cf72 100644 --- a/open-vm-tools/lib/wiper/wiperPosix.c +++ b/open-vm-tools/lib/wiper/wiperPosix.c @@ -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]; diff --git a/open-vm-tools/services/plugins/guestInfo/diskInfo.c b/open-vm-tools/services/plugins/guestInfo/diskInfo.c index 33515f0bb..5b12c686c 100644 --- a/open-vm-tools/services/plugins/guestInfo/diskInfo.c +++ b/open-vm-tools/services/plugins/guestInfo/diskInfo.c @@ -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", diff --git a/open-vm-tools/services/plugins/guestInfo/guestInfoInt.h b/open-vm-tools/services/plugins/guestInfo/guestInfoInt.h index 56b82f954..5e0fc8fc3 100644 --- a/open-vm-tools/services/plugins/guestInfo/guestInfoInt.h +++ b/open-vm-tools/services/plugins/guestInfo/guestInfoInt.h @@ -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; diff --git a/open-vm-tools/services/plugins/guestInfo/guestInfoServer.c b/open-vm-tools/services/plugins/guestInfo/guestInfoServer.c index 27c68b3cb..3517f17a5 100644 --- a/open-vm-tools/services/plugins/guestInfo/guestInfoServer.c +++ b/open-vm-tools/services/plugins/guestInfo/guestInfoServer.c @@ -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);