]> git.ipfire.org Git - thirdparty/open-vm-tools.git/commitdiff
DnD: fix vmblock-fuse detection on newer Linuxes
authorVMware, Inc <>
Mon, 21 Nov 2011 23:26:59 +0000 (15:26 -0800)
committerMarcelo Vanzin <mvanzin@vmware.com>
Mon, 21 Nov 2011 23:26:59 +0000 (15:26 -0800)
Newer Linuxes, such as Fedora 15 and Ubuntu 11.10, have
/var/run symlinked to /run so when we read existing mount
points in search of fuse.vmware-vmblock our matching on
/var/run/vmblock-fuse does not work anymore.

Try to resolve supplied mount point before comparing with
mount data.

Signed-off-by: Marcelo Vanzin <mvanzin@vmware.com>
open-vm-tools/services/plugins/dndcp/dnd/dndLinux.c

index 8d456d0c4b8718701ae3f8aab31ba455118931a3..31a8a80a90a924fe505bb71b86dda6f4228569b3 100644 (file)
@@ -548,15 +548,29 @@ DnD_TryInitVmblock(const char *vmbFsName,          // IN
 {
    Bool found = FALSE;
    int blockFd = -1;
+   char *realMntPoint;
    MNTHANDLE fp;
    DECLARE_MNTINFO(mnt);
 
+   ASSERT(vmbFsName);
+   ASSERT(vmbMntPoint);
+   ASSERT(vmbDevice);
+
+   /* Resolve desired mount point in case it is symlinked somewhere */
+   realMntPoint = Posix_RealPath(vmbMntPoint);
+   if (!realMntPoint) {
+      /*
+       * If resolve failed for some reason try to fall back to
+       * original mount point specification.
+       */
+      realMntPoint = Util_SafeStrdup(vmbMntPoint);
+   }
+
    /* Make sure the vmblock file system is mounted. */
    fp = OPEN_MNTFILE("r");
    if (fp == NULL) {
       LOG(1, ("%s: could not open mount file\n", __func__));
-
-      return -1;
+      goto out;
    }
 
    while (GETNEXT_MNTINFO(fp, mnt)) {
@@ -566,7 +580,7 @@ DnD_TryInitVmblock(const char *vmbFsName,          // IN
        */
 
       if (strcmp(MNTINFO_FSTYPE(mnt), vmbFsName) == 0 &&
-          strcmp(MNTINFO_MNTPT(mnt), vmbMntPoint) == 0) {
+          strcmp(MNTINFO_MNTPT(mnt), realMntPoint) == 0) {
          found = TRUE;
          break;
       }
@@ -592,6 +606,8 @@ DnD_TryInitVmblock(const char *vmbFsName,          // IN
       }
    }
 
+out:
+   free(realMntPoint);
    return blockFd;
 }