Index: /trunk/src/VBox/Additions/common/VBoxService/VBoxServiceAutoMount.cpp
===================================================================
--- /trunk/src/VBox/Additions/common/VBoxService/VBoxServiceAutoMount.cpp	(revision 75432)
+++ /trunk/src/VBox/Additions/common/VBoxService/VBoxServiceAutoMount.cpp	(revision 75433)
@@ -169,4 +169,7 @@
 /** The attachment tag we use to identify attchments that belongs to us. */
 static char const       g_szTag[] = "VBoxAutomounter";
+#elif defined(RT_OS_LINUX)
+/** Tag option value that lets us identify mounts that belongs to us. */
+static char const       g_szTag[] = "VBoxAutomounter";
 #elif defined(RT_OS_SOLARIS)
 /** Dummy mount option that lets us identify mounts that belongs to us. */
@@ -433,4 +436,5 @@
         mntinf.dmask = Opts.dmask;
         mntinf.fmask = Opts.fmask;
+        mntinf.tag[0] = '\0';
 
         strcpy(mntinf.name, pszShareName);
@@ -958,10 +962,7 @@
      * but later we may use the same approach as on solaris.
      */
-    char szMountPrefix[RTPATH_MAX];
-    rc = vbsvcAutomounterQueryMountDirAndPrefix(szMountPrefix, sizeof(szMountPrefix));
-    AssertRCReturn(rc, rc);
-    size_t const cchMountPrefix = strlen(szMountPrefix);
-
-    FILE *pFile = setmntent(_PATH_MOUNTED, "r");
+    FILE *pFile = setmntent("/proc/mounts", "r");
+    if (!pFile)
+        pFile = setmntent("/etc/mtab", "r");
     if (pFile)
     {
@@ -970,8 +971,5 @@
         while ((pEntry = getmntent(pFile)) != NULL)
             if (strcmp(pEntry->mnt_type, "vboxsf") == 0)
-            {
-                /** @todo add mount option for tagging a mount, make kernel show it by
-                 *        implementing super_operations::show_options. */
-                if (strncmp(pEntry->mnt_dir, szMountPrefix, cchMountPrefix) == 0)
+                if (strstr(pEntry->mnt_opts, g_szTag) != NULL)
                 {
                     rc = vbsvcAutomounterAddEntry(pMountTable, pEntry->mnt_fsname, pEntry->mnt_dir);
@@ -982,5 +980,4 @@
                     }
                 }
-            }
         endmntent(pFile);
     }
@@ -988,5 +985,4 @@
         VGSvcError("vbsvcAutomounterQueryMountPoint: Could not open mount tab '%s' (errno=%d) or '/proc/mounts' (errno=%d)\n",
                    _PATH_MOUNTED, errno);
-    return rc;
 
 #elif defined(RT_OS_SOLARIS)
@@ -1159,5 +1155,5 @@
                     if (RTStrICmp(pszMountedName, pszName) == 0)
                     {
-                        VGSvcVerbose(3, "vbsvcAutomounterQueryMountPoint: Found shared folder '%s' at '%s' as expected.\n",
+                        VGSvcVerbose(3, "vbsvcAutomounterQueryMountPoint: Found shared folder '%s' at '%s'.\n",
                                      pszMountPoint, pszName);
                         rc = VINF_SUCCESS;
@@ -1223,5 +1219,5 @@
             if (RTStrICmp(pszMountedName, pszName) == 0)
             {
-                VGSvcVerbose(3, "vbsvcAutomounterQueryMountPoint: Found shared folder '%s' at '%s' as expected.\n",
+                VGSvcVerbose(3, "vbsvcAutomounterQueryMountPoint: Found shared folder '%s' at '%s'.\n",
                              pszMountPoint, pszName);
                 rc = VINF_SUCCESS;
@@ -1255,8 +1251,8 @@
      * match file system and device/share.
      */
-    FILE *pFile = setmntent(_PATH_MOUNTED, "r");
+    FILE *pFile = setmntent("/proc/mounts", "r");
     int rc = errno;
     if (!pFile)
-        pFile = setmntent("/proc/mounts", "r");
+        pFile = setmntent(_PATH_MOUNTED, "r");
     if (pFile)
     {
@@ -1270,5 +1266,5 @@
                     if (RTStrICmp(pEntry->mnt_fsname, pszName) == 0)
                     {
-                        VGSvcVerbose(3, "vbsvcAutomounterQueryMountPoint: Found shared folder '%s' at '%s' as expected.\n",
+                        VGSvcVerbose(3, "vbsvcAutomounterQueryMountPoint: Found shared folder '%s' at '%s'.\n",
                                      pszMountPoint, pszName);
                         rc = VINF_SUCCESS;
@@ -1293,6 +1289,6 @@
     else
     {
-        VGSvcError("vbsvcAutomounterQueryMountPoint: Could not open mount tab '%s' (errno=%d) or '/proc/mounts' (errno=%d)\n",
-                   _PATH_MOUNTED, rc, errno);
+        VGSvcError("vbsvcAutomounterQueryMountPoint: Could not open mount tab '/proc/mounts' (errno=%d) or '%s' (errno=%d)\n",
+                   rc, _PATH_MOUNTED, errno);
         rc = VERR_ACCESS_DENIED;
     }
@@ -1316,5 +1312,5 @@
                     if (RTStrICmp(Entry.mnt_special, pszName) == 0)
                     {
-                        VGSvcVerbose(3, "vbsvcAutomounterQueryMountPoint: Found shared folder '%s' at '%s' as expected.\n",
+                        VGSvcVerbose(3, "vbsvcAutomounterQueryMountPoint: Found shared folder '%s' at '%s'.\n",
                                      pszMountPoint, pszName);
                         rc = VINF_SUCCESS;
@@ -1478,4 +1474,5 @@
     MntInfo.dmask        = MntOpts.dmask = 0000;
     MntInfo.fmask        = MntOpts.fmask = 0000;
+    memcpy(MntInfo.tag, g_szTag, sizeof(g_szTag)); AssertCompile(sizeof(MntInfo.tag) >= sizeof(g_szTag));
     rc = RTStrCopy(MntInfo.name, sizeof(MntInfo.name), pEntry->pszName);
     if (RT_FAILURE(rc))
@@ -1495,9 +1492,8 @@
         errno = 0;
         rc = vbsfmount_complete(pEntry->pszName, pEntry->pszActualMountPoint, fFlags, &MntOpts);
-        if (rc == 0)
-            return VINF_SUCCESS;
-
-        VGSvcError("vbsvcAutomounterMountIt: vbsfmount_complete failed: %s (%d/%d)\n",
-                   rc == 1 ? "open_memstream" : rc == 2 ? "setmntent" : rc == 3 ? "addmntent" : "unknown", rc, errno);
+        if (rc != 0) /* Ignorable. /etc/mtab is probably a link to /proc/mounts. */
+            VGSvcVerbose(1, "vbsvcAutomounterMountIt: vbsfmount_complete failed: %s (%d/%d)\n",
+                         rc == 1 ? "open_memstream" : rc == 2 ? "setmntent" : rc == 3 ? "addmntent" : "unknown", rc, errno);
+        return VINF_SUCCESS;
     }
     else if (errno == EINVAL)
@@ -1630,37 +1626,8 @@
          * Path based #2: Mount dir + prefix + share.
          */
-        /* Mount base directory: */
-        szActualMountPoint[0] = '\0';
-        char *pszProp;
-        rc = VbglR3SharedFolderGetMountDir(&pszProp);
+        rc = vbsvcAutomounterQueryMountDirAndPrefix(szActualMountPoint, sizeof(szActualMountPoint));
         if (RT_SUCCESS(rc))
         {
-            if (*pszProp == '/')
-                rc = RTPathAbs(pszProp, szActualMountPoint, sizeof(szActualMountPoint));
-            else
-                VGSvcError("vbsvcAutomounterMountNewEntry: Invalid mount directory: '%s'\n", pszProp);
-            RTStrFree(pszProp);
-        }
-        if (RT_FAILURE(rc) || szActualMountPoint[0] != '/')
-            memcpy(szActualMountPoint, VBOXSERVICE_AUTOMOUNT_DEFAULT_DIR, sizeof(VBOXSERVICE_AUTOMOUNT_DEFAULT_DIR));
-
-        /* Add prefix: */
-        rc = VbglR3SharedFolderGetMountPrefix(&pszProp);
-        if (RT_SUCCESS(rc))
-        {
-            if (   strchr(pszProp, '/')  == NULL
-                && strchr(pszProp, '\\') == NULL
-                && strcmp(pszProp, "..") != 0)
-                rc = RTPathAppend(szActualMountPoint, sizeof(szActualMountPoint), pszProp);
-            else
-                VGSvcError("vbsvcAutomounterMountNewEntry: Invalid mount prefix: '%s'\n", pszProp);
-            RTStrFree(pszProp);
-        }
-        else
-            rc = RTPathEnsureTrailingSeparator(szActualMountPoint, sizeof(szActualMountPoint)) != 0
-               ? VINF_SUCCESS : VERR_BUFFER_OVERFLOW;
-        if (RT_SUCCESS(rc))
-        {
-            /* Add sanitized share name: */
+            /* Append a sanitized share name: */
             size_t const offShare = strlen(szActualMountPoint);
             size_t offDst = offShare;
@@ -1824,5 +1791,13 @@
         int rc2 = umount(pszMountPoint);
         if (rc2 == 0)
+        {
+            /* Remove the mount directory if not directly under the root dir. */
+            RTPATHPARSED Parsed = { 0 };
+            RTPathParse(pszMountPoint, &Parsed, sizeof(Parsed), RTPATH_STR_F_STYLE_HOST);
+            if (Parsed.cComps >= 3)
+                RTDirRemove(pszMountPoint);
+
             return VINF_SUCCESS;
+        }
         rc2 = errno;
         VGSvcVerbose(2, "vbsvcAutomounterUnmount: umount failed on '%s' ('%s'): %d\n", pszMountPoint, pszName, rc2);
@@ -1865,6 +1840,6 @@
     Assert(iTable < pTable->cEntries);
     PVBSVCAUTOMOUNTERENTRY pEntry = pTable->papEntries[iTable];
-    VGSvcVerbose(3, "vbsvcAutomounterUnmountEntry: #%u: '%s' at '%s' (reason: %s)\n",
-                 iTable, pEntry->pszName, pEntry->pszMountPoint, pszReason);
+    VGSvcVerbose(2, "vbsvcAutomounterUnmountEntry: #%u: '%s' at '%s' (reason: %s)\n",
+                 iTable, pEntry->pszName, pEntry->pszActualMountPoint, pszReason);
 
     /*
@@ -1876,5 +1851,5 @@
         if (rc == VERR_TRY_AGAIN)
         {
-            VGSvcVerbose(2, "vbsvcAutomounterUnmountEntry: Keeping '%s' -> '%s' (VERR_TRY_AGAIN)\n",
+            VGSvcVerbose(1, "vbsvcAutomounterUnmountEntry: Keeping '%s' -> '%s' (VERR_TRY_AGAIN)\n",
                          pEntry->pszActualMountPoint, pEntry->pszName);
             return iTable + 1;
Index: /trunk/src/VBox/Additions/linux/sharedfolders/mount.vboxsf.c
===================================================================
--- /trunk/src/VBox/Additions/linux/sharedfolders/mount.vboxsf.c	(revision 75432)
+++ /trunk/src/VBox/Additions/linux/sharedfolders/mount.vboxsf.c	(revision 75433)
@@ -402,4 +402,5 @@
     mntinf.signature[2] = VBSF_MOUNT_SIGNATURE_BYTE_2;
     mntinf.length       = sizeof(mntinf);
+    mntinf.tag[0] = '\0';
 
     if (getuid())
Index: /trunk/src/VBox/Additions/linux/sharedfolders/vbsfmount.h
===================================================================
--- /trunk/src/VBox/Additions/linux/sharedfolders/vbsfmount.h	(revision 75432)
+++ /trunk/src/VBox/Additions/linux/sharedfolders/vbsfmount.h	(revision 75433)
@@ -59,4 +59,5 @@
 	int dmask;		/* umask applied to directories */
 	int fmask;		/* umask applied to regular files */
+	char tag[32];		/**< Mount tag for VBoxService automounter.  @since 6.0 */
 };
 
Index: /trunk/src/VBox/Additions/linux/sharedfolders/vfsmod.c
===================================================================
--- /trunk/src/VBox/Additions/linux/sharedfolders/vfsmod.c	(revision 75432)
+++ /trunk/src/VBox/Additions/linux/sharedfolders/vfsmod.c	(revision 75433)
@@ -156,5 +156,5 @@
 	sf_g->gid = info->gid;
 
-	if ((unsigned)info->length >= sizeof(struct vbsf_mount_info_new)) {
+	if ((unsigned)info->length >= RT_UOFFSETOF(struct vbsf_mount_info_new, tag)) {
 		/* new fields */
 		sf_g->dmode = info->dmode;
@@ -165,4 +165,12 @@
 		sf_g->dmode = ~0;
 		sf_g->fmode = ~0;
+	}
+
+	if ((unsigned)info->length >= sizeof(struct vbsf_mount_info_new)) {
+		AssertCompile(sizeof(sf_g->tag) >= sizeof(info->tag));
+		memcpy(sf_g->tag, info->tag, sizeof(info->tag));
+		sf_g->tag[sizeof(sf_g->tag) - 1] = '\0';
+	} else {
+		sf_g->tag[0] = '\0';
 	}
 
@@ -457,8 +465,20 @@
 			sf_g->gid = info->gid;
 			sf_g->ttl = info->ttl;
-			sf_g->dmode = info->dmode;
-			sf_g->fmode = info->fmode;
-			sf_g->dmask = info->dmask;
-			sf_g->fmask = info->fmask;
+			if ((unsigned)info->length >= RT_UOFFSETOF(struct vbsf_mount_info_new, tag)) {
+				sf_g->dmode = info->dmode;
+				sf_g->fmode = info->fmode;
+				sf_g->dmask = info->dmask;
+				sf_g->fmask = info->fmask;
+			} else {
+				sf_g->dmode = ~0;
+				sf_g->fmode = ~0;
+			}
+			if ((unsigned)info->length >= sizeof(struct vbsf_mount_info_new)) {
+				AssertCompile(sizeof(sf_g->tag) >= sizeof(info->tag));
+				memcpy(sf_g->tag, info->tag, sizeof(info->tag));
+				sf_g->tag[sizeof(sf_g->tag) - 1] = '\0';
+			} else {
+				sf_g->tag[0] = '\0';
+			}
 		}
 	}
@@ -479,4 +499,29 @@
 }
 
+/** Show mount options. */
+#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 3, 0)
+static int sf_show_options(struct seq_file *m, struct vfsmount *mnt)
+#else
+static int sf_show_options(struct seq_file *m, struct dentry *root)
+#endif
+{
+#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 3, 0)
+	struct super_block *sb = mnt->mnt_sb;
+#else
+	struct super_block *sb = root->d_sb;
+#endif
+	struct sf_glob_info *sf_g = GET_GLOB_INFO(sb);
+	if (sf_g) {
+		seq_printf(m, ",uid=%u,gid=%u,ttl=%u,dmode=0%o,fmode=0%o,dmask=0%o,fmask=0%o",
+			sf_g->uid, sf_g->gid, sf_g->ttl, sf_g->dmode, sf_g->fmode, sf_g->dmask, sf_g->fmask);
+		if (sf_g->tag[0] != '\0') {
+			seq_puts(m, ",tag=");
+			seq_escape(m, sf_g->tag, " \t\n\\");
+		}
+	}
+
+    return 0;
+}
+
 /** @todo Implement show_options (forever) or maybe set s_options (2.6.25+).
  *        Necessary for the automounter tagging.  */
@@ -492,5 +537,6 @@
 	.put_super = sf_put_super,
 	.statfs = sf_statfs,
-	.remount_fs = sf_remount_fs
+	.remount_fs = sf_remount_fs,
+	.show_options = sf_show_options
 };
 
Index: /trunk/src/VBox/Additions/linux/sharedfolders/vfsmod.h
===================================================================
--- /trunk/src/VBox/Additions/linux/sharedfolders/vfsmod.h	(revision 75432)
+++ /trunk/src/VBox/Additions/linux/sharedfolders/vfsmod.h	(revision 75433)
@@ -58,4 +58,5 @@
 	struct backing_dev_info bdi;
 #endif
+	char tag[32];		/**< Mount tag for VBoxService automounter.  @since 6.0 */
 };
 
