Index: /trunk/include/VBox/VBoxGuestLib.h
===================================================================
--- /trunk/include/VBox/VBoxGuestLib.h	(revision 35015)
+++ /trunk/include/VBox/VBoxGuestLib.h	(revision 35016)
@@ -538,4 +538,5 @@
 VBGLR3DECL(int)     VbglR3SharedFolderGetName(uint32_t  u32ClientId,uint32_t u32Root, char **ppszName);
 VBGLR3DECL(int)     VbglR3SharedFolderGetMountPrefix(char **ppszPrefix);
+VBGLR3DECL(int)     VbglR3SharedFolderGetMountDir(char **ppszDir);
 /** @}  */
 # endif /* VBOX_WITH_SHARED_FOLDERS defined */
Index: /trunk/src/VBox/Additions/common/VBoxGuestLib/VBoxGuestR3LibSharedFolders.cpp
===================================================================
--- /trunk/src/VBox/Additions/common/VBoxGuestLib/VBoxGuestR3LibSharedFolders.cpp	(revision 35015)
+++ /trunk/src/VBox/Additions/common/VBoxGuestLib/VBoxGuestR3LibSharedFolders.cpp	(revision 35016)
@@ -288,2 +288,29 @@
     return rc;
 }
+
+/**
+ * Retrieves the mount root directory for auto-mounted shared 
+ * folders. mount point. If no string is set (VERR_NOT_FOUND) 
+ * it's up on the caller (guest) to decide where to mount. 
+ *
+ * @returns VBox status code.
+ * @param   ppszDir         Where to return the directory 
+ *                          string. This shall be freed by
+ *                          calling RTStrFree.
+ */
+VBGLR3DECL(int) VbglR3SharedFolderGetMountDir(char **ppszDir)
+{
+    AssertPtrReturn(ppszDir, VERR_INVALID_POINTER);
+    int rc;
+#ifdef VBOX_WITH_GUEST_PROPS
+    uint32_t u32ClientIdGuestProp;
+    rc = VbglR3GuestPropConnect(&u32ClientIdGuestProp);
+    if (RT_SUCCESS(rc))
+    {
+        rc = VbglR3GuestPropReadValueAlloc(u32ClientIdGuestProp, "/VirtualBox/GuestAdd/SharedFolders/MountDir", ppszDir);
+        VbglR3GuestPropDisconnect(u32ClientIdGuestProp);
+    }
+#endif
+    return rc;
+}
+
Index: /trunk/src/VBox/Additions/common/VBoxService/VBoxServiceAutoMount.cpp
===================================================================
--- /trunk/src/VBox/Additions/common/VBoxService/VBoxServiceAutoMount.cpp	(revision 35015)
+++ /trunk/src/VBox/Additions/common/VBoxService/VBoxServiceAutoMount.cpp	(revision 35016)
@@ -48,14 +48,14 @@
 
 #ifdef RT_OS_SOLARIS
-# define AUTO_MOUNT_POINT       "/mnt/%s%s"
+# define VBOXSERVICE_AUTOMOUNT_DEFAULT_DIR       "/mnt"
 #else
-# define AUTO_MOUNT_POINT       "/media/%s%s"
+# define VBOXSERVICE_AUTOMOUNT_DEFAULT_DIR       "/media"
 #endif
 
 #ifndef _PATH_MOUNTED
  #ifdef RT_OS_SOLARIS
-  #define _PATH_MOUNTED         "/etc/mnttab"
+  #define _PATH_MOUNTED                          "/etc/mnttab"
  #else
-  #define _PATH_MOUNTED         "/etc/mtab"
+  #define _PATH_MOUNTED                          "/etc/mtab"
  #endif
 #endif
@@ -190,5 +190,5 @@
             rc = RTPathSetMode(pszMountPoint, fMode);
             if (RT_FAILURE(rc))
-                VBoxServiceError(": Could not set mode %RTfmode for mount directory \"%s\", rc = %Rrc\n",
+                VBoxServiceError("VBoxServiceAutoMountPrepareMountPoint: Could not set mode %RTfmode for mount directory \"%s\", rc = %Rrc\n",
                                  fMode, pszMountPoint, rc);
         }
@@ -368,4 +368,77 @@
 }
 
+static int VBoxServiceAutoMountProcessMappings(PVBGLR3SHAREDFOLDERMAPPING paMappings, uint32_t cMappings, 
+                                               const char *pszMountDir, const char *pszSharePrefix, uint32_t uClientID)
+{
+    if (cMappings == 0)
+        return VINF_SUCCESS;
+    AssertPtrReturn(paMappings, VERR_INVALID_PARAMETER);
+    AssertPtrReturn(pszMountDir, VERR_INVALID_PARAMETER);
+    AssertPtrReturn(pszSharePrefix, VERR_INVALID_PARAMETER);
+    AssertPtrReturn(*pszSharePrefix, VERR_INVALID_PARAMETER);
+    AssertReturn(uClientID > 0, VERR_INVALID_PARAMETER);
+
+    int rc = VINF_SUCCESS;
+    for (uint32_t i = 0; i < cMappings && RT_SUCCESS(rc); i++)
+    {
+        char *pszShareName = NULL;
+        rc = VbglR3SharedFolderGetName(uClientID, paMappings[i].u32Root, &pszShareName);
+        if (   RT_SUCCESS(rc)
+            && *pszShareName)
+        {
+            VBoxServiceVerbose(3, "VBoxServiceAutoMountWorker: Connecting share %u (%s) ...\n", i+1, pszShareName);
+
+            char *pszShareNameFull = NULL;
+            if (RTStrAPrintf(&pszShareNameFull, "%s%s", pszSharePrefix, pszShareName) > 0)
+            {                
+                char szMountPoint[RTPATH_MAX];
+                rc = RTPathJoin(szMountPoint, sizeof(szMountPoint), pszMountDir, pszShareNameFull);
+                if (RT_SUCCESS(rc))
+                {
+                    VBoxServiceVerbose(4, "VBoxServiceAutoMountWorker: Processing mount point \"%s\"\n", szMountPoint);
+    
+                    struct group *grp_vboxsf = getgrnam("vboxsf");
+                    if (grp_vboxsf)
+                    {
+                        struct vbsf_mount_opts mount_opts =
+                        {
+                            0,                     /* uid */
+                            grp_vboxsf->gr_gid,    /* gid */
+                            0,                     /* ttl */
+                            0770,                  /* dmode, owner and group "vboxsf" have full access */
+                            0770,                  /* fmode, owner and group "vboxsf" have full access */
+                            0,                     /* dmask */
+                            0,                     /* fmask */
+                            0,                     /* ronly */
+                            0,                     /* noexec */
+                            0,                     /* nodev */
+                            0,                     /* nosuid */
+                            0,                     /* remount */
+                            "\0",                  /* nls_name */
+                            NULL,                  /* convertcp */
+                        };
+    
+                        /* We always use "/media" as our root mounting directory. */
+                        /** @todo Detect the correct "media/mnt" directory, based on the current guest (?). */
+                        rc = VBoxServiceAutoMountSharedFolder(pszShareName, szMountPoint, &mount_opts);
+                    }
+                    else
+                        VBoxServiceError("VBoxServiceAutoMountWorker: Group \"vboxsf\" does not exist\n");
+                }
+                else
+                    VBoxServiceError("VBoxServiceAutoMountWorker: Unable to join mount point/prefix/shrae, rc = %Rrc\n", rc);
+                RTStrFree(pszShareNameFull);
+            }
+            else
+                VBoxServiceError("VBoxServiceAutoMountWorker: Unable to allocate full share name\n");
+            RTStrFree(pszShareName);
+        }
+        else
+            VBoxServiceError("VBoxServiceAutoMountWorker: Error while getting the shared folder name for root node = %u, rc = %Rrc\n",
+                             paMappings[i].u32Root, rc);
+    } /* for cMappings. */
+    return rc;
+}
+
 
 /** @copydoc VBOXSERVICE::pfnWorker */
@@ -385,5 +458,5 @@
     {
         uint32_t cMappings;
-        VBGLR3SHAREDFOLDERMAPPING *paMappings;
+        PVBGLR3SHAREDFOLDERMAPPING paMappings;
 
         rc = VbglR3SharedFolderGetMappings(u32ClientId, true /* Only process auto-mounted folders */,
@@ -391,76 +464,42 @@
         if (RT_SUCCESS(rc))
         {
-            char *pszSharePrefix;
-            rc = VbglR3SharedFolderGetMountPrefix(&pszSharePrefix);
+            char *pszMountDir;
+            rc = VbglR3SharedFolderGetMountDir(&pszMountDir);
+            if (rc == VERR_NOT_FOUND)
+                rc = RTStrDupEx(&pszMountDir, VBOXSERVICE_AUTOMOUNT_DEFAULT_DIR);
             if (RT_SUCCESS(rc))
             {
-                VBoxServiceVerbose(3, "VBoxServiceAutoMountWorker: Shared folder mount prefix set to \"%s\"\n", pszSharePrefix);
-#if 0
-                /* Check for a fixed/virtual auto-mount share. */
-                if (VbglR3SharedFolderExists(u32ClientId, "vbsfAutoMount"))
+                VBoxServiceVerbose(3, "VBoxServiceAutoMountWorker: Shared folder mount dir set to \"%s\"\n", pszMountDir);
+
+                char *pszSharePrefix;
+                rc = VbglR3SharedFolderGetMountPrefix(&pszSharePrefix);
+
                 {
-                    VBoxServiceVerbose(3, "VBoxServiceAutoMountWorker: Host supports auto-mount root\n");
                 }
+                if (RT_SUCCESS(rc))
+                {
+                    VBoxServiceVerbose(3, "VBoxServiceAutoMountWorker: Shared folder mount prefix set to \"%s\"\n", pszSharePrefix);
+    #if 0
+                    /* Check for a fixed/virtual auto-mount share. */
+                    if (VbglR3SharedFolderExists(u32ClientId, "vbsfAutoMount"))
+                    {
+                        VBoxServiceVerbose(3, "VBoxServiceAutoMountWorker: Host supports auto-mount root\n");
+                    }
+                    else
+                    {
+    #endif
+                        VBoxServiceVerbose(3, "VBoxServiceAutoMountWorker: Got %u shared folder mappings\n", cMappings);
+                        rc = VBoxServiceAutoMountProcessMappings(paMappings, cMappings, pszMountDir, pszSharePrefix, u32ClientId);
+    #if 0
+                    }
+    #endif
+                    RTStrFree(pszSharePrefix);
+                } /* Mount share prefix. */
                 else
-                {
-#endif
-                    VBoxServiceVerbose(3, "VBoxServiceAutoMountWorker: Got %u shared folder mappings\n", cMappings);
-                    for (uint32_t i = 0; i < cMappings && RT_SUCCESS(rc); i++)
-                    {
-                        char *pszShareName = NULL;
-                        rc = VbglR3SharedFolderGetName(u32ClientId, paMappings[i].u32Root, &pszShareName);
-                        if (   RT_SUCCESS(rc)
-                            && *pszShareName)
-                        {
-                            VBoxServiceVerbose(3, "VBoxServiceAutoMountWorker: Connecting share %u (%s) ...\n", i+1, pszShareName);
-
-                            char *pszMountPoint = NULL;
-                            if (   RTStrAPrintf(&pszMountPoint, AUTO_MOUNT_POINT, pszSharePrefix, pszShareName) > 0
-                                && pszMountPoint)
-                            {
-                                struct group *grp_vboxsf = getgrnam("vboxsf");
-                                if (grp_vboxsf)
-                                {
-                                    struct vbsf_mount_opts mount_opts =
-                                    {
-                                        0,                     /* uid */
-                                        grp_vboxsf->gr_gid,    /* gid */
-                                        0,                     /* ttl */
-                                        0770,                  /* dmode, owner and group "vboxsf" have full access */
-                                        0770,                  /* fmode, owner and group "vboxsf" have full access */
-                                        0,                     /* dmask */
-                                        0,                     /* fmask */
-                                        0,                     /* ronly */
-                                        0,                     /* noexec */
-                                        0,                     /* nodev */
-                                        0,                     /* nosuid */
-                                        0,                     /* remount */
-                                        "\0",                  /* nls_name */
-                                        NULL,                  /* convertcp */
-                                    };
-
-                                    /* We always use "/media" as our root mounting directory. */
-                                    /** @todo Detect the correct "media/mnt" directory, based on the current guest (?). */
-                                    rc = VBoxServiceAutoMountSharedFolder(pszShareName, pszMountPoint, &mount_opts);
-                                }
-                                else
-                                    VBoxServiceError("VBoxServiceAutoMountWorker: Group \"vboxsf\" does not exist\n");
-                                RTStrFree(pszMountPoint);
-                            }
-                            else
-                                rc = VERR_NO_MEMORY;
-                            RTStrFree(pszShareName);
-                        }
-                        else
-                            VBoxServiceError("VBoxServiceAutoMountWorker: Error while getting the shared folder name for root node = %u, rc = %Rrc\n",
-                                             paMappings[i].u32Root, rc);
-                    } /* for cMappings. */
-#if 0
-                }
-#endif
-                RTStrFree(pszSharePrefix);
-            } /* Mount prefix. */
+                    VBoxServiceError("VBoxServiceAutoMountWorker: Error while getting the shared folder mount prefix, rc = %Rrc\n", rc);
+                RTStrFree(pszMountDir);
+            }
             else
-                VBoxServiceError("VBoxServiceAutoMountWorker: Error while getting the shared folder mount prefix, rc = %Rrc\n", rc);
+                VBoxServiceError("VBoxServiceAutoMountWorker: Error while getting the shared folder directory, rc = %Rrc\n", rc);                       
             RTMemFree(paMappings);
         }
