VMware Fusion 3.0.1, Ubuntu 9.10 and shared folders

In VMware Fusion I share a folder with many of my VMs. In a new Ubuntu 9.10 VM, that shared folder is always mounted with the wrong owner and group IDs. Here's a fix.

After booting the Ubuntu VM for the first time, I downloaded and installed the latest vmware-tools distribution, using the VMware "Virtual Machine -> Install VMware Tools" menu item. Then I added an entry to /etc/fstab, specifying the correct owner and group ID for the /mnt/hgfs mount point.

Unfortunately, the owner and group ID specifications were ignored. As it turns out, /etc/init.d/vmware-tools does not examine /etc/fstab when deciding whether or how to mount the shared filesystem.

Here's how I changed /etc/init.d/vmware-tools to address this problem.

Old

# Mount all hgfs filesystems
vmware_mount_vmhgfs() {
  if [ "`is_vmhgfs_mounted`" = "no" ]; then
    vmware_exec_selinux "mount -t vmhgfs .host:/ $vmhgfs_mnt"
  fi
}

New

is_vmhgfs_in_fstab() {
    if grep -q " $vmhgfs_mnt " /etc/fstab; then
        echo "yes"
    else
        echo "no"
    fi
}
# Mount all hgfs filesystems
vmware_mount_vmhgfs() {
  if [ "`is_vmhgfs_mounted`" = "no" ]; then
    if [ "`is_vmhgfs_in_fstab`" = "yes" ]; then
        vmware_exec_selinux "mount $vmhgfs_mnt"
    else
        vmware_exec_selinux "mount -t vmhgfs .host:/ $vmhgfs_mnt"
    fi
  fi
}