]> 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, 30 Jan 2018 00:52:18 +0000 (16:52 -0800)
committerOliver Kurth <okurth@vmware.com>
Tue, 30 Jan 2018 00:52:18 +0000 (16:52 -0800)
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..ad71f1749487791c9f33af8fe84c292fbf87d012 100644 (file)
@@ -1,5 +1,5 @@
 /*********************************************************
- * Copyright (C) 2004-2017 VMware, Inc. All rights reserved.
+ * Copyright (C) 2004-2018 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
@@ -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 7b236881e6be40758e2324556841df8e336bea47..d1789443b5812220a60f06b1d0c1924c5c9f5b5e 100644 (file)
@@ -1,5 +1,5 @@
 /*********************************************************
- * Copyright (C) 2014-2017 VMware, Inc. All rights reserved.
+ * Copyright (C) 2014-2018 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
@@ -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..8774fa43793a62709f4e05d6aa26abb708f867ee 100644 (file)
@@ -1,5 +1,5 @@
 /*********************************************************
- * Copyright (C) 2008-2017 VMware, Inc. All rights reserved.
+ * Copyright (C) 2008-2018 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
@@ -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;
       }