]> git.ipfire.org Git - thirdparty/open-vm-tools.git/commitdiff
GuestInfo: skip check for shrinkable disk when gathering disk info
authorOliver Kurth <okurth@vmware.com>
Tue, 5 Dec 2017 00:27:20 +0000 (16:27 -0800)
committerOliver Kurth <okurth@vmware.com>
Tue, 5 Dec 2017 00:27:20 +0000 (16:27 -0800)
Some Linux OSes may have a non-existing device mounted to a filesystem,
for example Photon OS has the root file system mounted from
/dev/root, which does not exist. The wiper library does a check
for a shrinkable disk, and this fails. This change skips the check
when gathering data for diskinfo, but leaves it intact for
other disk wiper purposes. Information from read-only flesystems
will also be reported.

open-vm-tools/lib/include/wiper.h
open-vm-tools/lib/wiper/wiperPosix.c
open-vm-tools/services/plugins/guestInfo/diskInfo.c
open-vm-tools/toolbox/toolboxcmd-shrink.c

index d16972d6d4539dc3b5840d9a5da60609a5673faa..49892313c3bca5ea85a30f698b5c15d7a81c882d 100644 (file)
@@ -96,11 +96,11 @@ typedef struct WiperInitData {
 } WiperInitData;
 
 Bool Wiper_Init(WiperInitData *clientData);
-Bool WiperPartition_Open(WiperPartition_List *pl);
+Bool WiperPartition_Open(WiperPartition_List *pl, Bool shrinkableOnly);
 void WiperPartition_Close(WiperPartition_List *pl);
 
 WiperPartition *WiperSinglePartition_Allocate(void);
-WiperPartition *WiperSinglePartition_Open(const char *mntpt);
+WiperPartition *WiperSinglePartition_Open(const char *mntpt, Bool shrinkableOnly);
 void WiperSinglePartition_Close(WiperPartition *);
 Bool Wiper_IsWipeSupported(const WiperPartition *);
 
index 9dcc38733b837913ce9a62a14e95df5bcc99490c..7feaab24c0267ffb16c79e7c0388fba121ac0d86 100644 (file)
@@ -154,7 +154,7 @@ static Bool initDone = FALSE;
 
 /* Local functions */
 static Bool WiperIsDiskDevice(MNTINFO *mnt, struct stat *s);
-static void WiperPartitionFilter(WiperPartition *item, MNTINFO *mnt);
+static void WiperPartitionFilter(WiperPartition *item, MNTINFO *mnt, Bool shrinkableOnly);
 static unsigned char *WiperGetSpace(WiperState *state, uint64 *free, uint64 *total);
 static void WiperClean(WiperState *state);
 
@@ -409,6 +409,10 @@ WiperIsDiskDevice(MNTINFO *mnt,     // IN
  *
  *      Determine whether or not we know how to wipe a partition.
  *
+ *      When the parameter 'shrinkableOnly' is TRUE, disk will be checked
+ *      if it is really shrinkable. Otherwise only the filesystem
+ *      will be checked for support.
+ *
  * Results:
  *      None
  *
@@ -420,7 +424,8 @@ WiperIsDiskDevice(MNTINFO *mnt,     // IN
 
 static void
 WiperPartitionFilter(WiperPartition *item,         // IN/OUT
-                     MNTINFO *mnt)                 // IN
+                     MNTINFO *mnt,                 // IN
+                     Bool shrinkableOnly)          // IN
 {
    struct stat s;
    const char *comment = NULL;
@@ -441,7 +446,8 @@ WiperPartitionFilter(WiperPartition *item,         // IN/OUT
 
    if (i == ARRAYSIZE(gKnownPartitions)) {
       comment = "Unknown filesystem. Contact VMware.";
-   } else if (item->type != PARTITION_UNSUPPORTED) {
+   } else if (item->type != PARTITION_UNSUPPORTED &&
+              shrinkableOnly) {
       /*
        * If the partition is supported by the wiper library, do some other
        * checks before declaring it shrinkable.
@@ -493,7 +499,8 @@ WiperPartitionFilter(WiperPartition *item,         // IN/OUT
  */
 
 WiperPartition *
-WiperSinglePartition_Open(const char *mountPoint)      // IN
+WiperSinglePartition_Open(const char *mountPoint,      // IN
+                          Bool shrinkableOnly)         // IN
 {
    char *mntpt = NULL;
    MNTHANDLE fp;
@@ -535,7 +542,7 @@ WiperSinglePartition_Open(const char *mountPoint)      // IN
             p = NULL;
          } else {
             WiperCollectDiskMajors();
-            WiperPartitionFilter(p, mnt);
+            WiperPartitionFilter(p, mnt, shrinkableOnly);
          }
 
          goto out;
@@ -645,7 +652,8 @@ WiperSinglePartition_GetSpace(const WiperPartition *p, // IN
  */
 
 Bool
-WiperPartition_Open(WiperPartition_List *pl)
+WiperPartition_Open(WiperPartition_List *pl,
+                    Bool shrinkableOnly)
 {
    MNTHANDLE fp;
    DECLARE_MNTINFO(mnt);
@@ -681,7 +689,7 @@ WiperPartition_Open(WiperPartition_List *pl)
          break;
       }
 
-      WiperPartitionFilter(part, mnt);
+      WiperPartitionFilter(part, mnt, shrinkableOnly);
       DblLnkLst_LinkLast(&pl->link, &part->link);
    }
 
index a0458329e59c2fa0611d8d2b7a21bd52696a4696..fd98f06d11d018f79957bc5b3388924454b0fc51 100644 (file)
@@ -90,7 +90,7 @@ GuestInfoGetDiskInfoWiper(Bool includeReserved)  // IN
    GuestDiskInfo *di;
 
    /* Get partition list. */
-   if (!WiperPartition_Open(&pl)) {
+   if (!WiperPartition_Open(&pl, FALSE)) {
       g_warning("GetDiskInfo: ERROR: could not get partition list\n");
       return FALSE;
    }
index ef192ba0344bb96090839a15eb413b96e0570730..db714f33e295cf99c604c84448c4a670a820302f 100644 (file)
@@ -143,7 +143,7 @@ ShrinkGetMountPoints(WiperPartition_List *pl) // OUT: Known mount points
       break;
 
    case WIPER_ENABLED:
-      if (WiperPartition_Open(pl)) {
+      if (WiperPartition_Open(pl, TRUE)) {
          return TRUE;
       }