Index: /trunk/include/VBox/VBoxGuestLib.h
===================================================================
--- /trunk/include/VBox/VBoxGuestLib.h	(revision 31001)
+++ /trunk/include/VBox/VBoxGuestLib.h	(revision 31002)
@@ -4,5 +4,5 @@
 
 /*
- * Copyright (C) 2006-2009 Oracle Corporation
+ * Copyright (C) 2006-2010 Oracle Corporation
  *
  * This file is part of VirtualBox Open Source Edition (OSE), as
@@ -507,4 +507,29 @@
 /** @}  */
 # endif /* VBOX_WITH_GUEST_PROPS defined */
+
+# ifdef VBOX_WITH_SHARED_FOLDERS
+/** @name Shared folders
+ * @{ */
+/**
+ * Structure containing mapping information for a shared folder.
+ */
+struct VBGLR3SHAREDFOLDERMAPPING
+{
+    /** Mapping status. */
+    uint32_t u32Status;
+    /** Root handle. */
+    uint32_t u32Root;
+};
+typedef VBGLR3SHAREDFOLDERMAPPING *PVBGLR3SHAREDFOLDERMAPPING;
+/** @todo Docs. */
+VBGLR3DECL(int)     VbglR3SharedFolderConnect(uint32_t *pu32ClientId);
+VBGLR3DECL(int)     VbglR3SharedFolderDisconnect(uint32_t u32ClientId);
+VBGLR3DECL(int)     VbglR3SharedFolderGetMappings(uint32_t                   u32ClientId,  bool      bAutoMountOnly,
+                                                  VBGLR3SHAREDFOLDERMAPPING  paMappings[], uint32_t  cbMappings,
+                                                  uint32_t                  *pcMapCount);
+VBGLR3DECL(int)     VbglR3SharedFolderGetName(uint32_t   u32ClientId,uint32_t  u32Root,
+                                              char     **ppszName,   uint32_t *pcbLen);
+/** @}  */
+# endif /* VBOX_WITH_SHARED_FOLDERS defined */
 
 # ifdef VBOX_WITH_GUEST_CONTROL
Index: /trunk/include/VBox/settings.h
===================================================================
--- /trunk/include/VBox/settings.h	(revision 31001)
+++ /trunk/include/VBox/settings.h	(revision 31002)
@@ -537,4 +537,5 @@
     SharedFolder()
         : fWritable(false)
+        , fAutoMount(false)
     {}
 
@@ -544,4 +545,5 @@
                     strHostPath;
     bool            fWritable;
+    bool            fAutoMount;
 };
 typedef std::list<SharedFolder> SharedFoldersList;
Index: /trunk/include/VBox/shflsvc.h
===================================================================
--- /trunk/include/VBox/shflsvc.h	(revision 31001)
+++ /trunk/include/VBox/shflsvc.h	(revision 31002)
@@ -1,8 +1,8 @@
 /** @file
- * Shared Folders: Common header for host service and guest clients. (ADD,HSvc)
+ * Shared Folders: Common header for host service and guest clients.
  */
 
 /*
- * Copyright (C) 2006-2007 Oracle Corporation
+ * Copyright (C) 2006-2010 Oracle Corporation
  *
  * This file is part of VirtualBox Open Source Edition (OSE), as
@@ -134,4 +134,6 @@
 #define SHFL_HANDLE_ROOT ((SHFLHANDLE)0LL)
 
+/** Hardcoded maximum length (in chars) of a shared folder name. */
+#define SHFL_MAX_LEN         (256)
 /** Hardcoded maximum number of shared folder mapping available to the guest. */
 #define SHFL_MAX_MAPPINGS    (64)
@@ -166,10 +168,10 @@
 
 /** Calculate size of the string. */
-DECLINLINE(uint32_t) ShflStringSizeOfBuffer (PCSHFLSTRING pString)
+DECLINLINE(uint32_t) ShflStringSizeOfBuffer(PCSHFLSTRING pString)
 {
     return pString? sizeof (SHFLSTRING) - sizeof (pString->String) + pString->u16Size: 0;
 }
 
-DECLINLINE(uint32_t) ShflStringLength (PCSHFLSTRING pString)
+DECLINLINE(uint32_t) ShflStringLength(PCSHFLSTRING pString)
 {
     return pString? pString->u16Length: 0;
@@ -420,8 +422,13 @@
  * SHFL_FN_QUERY_MAPPINGS
  */
-
-#define SHFL_MF_UCS2 (0x00000000)
+/** Validation mask.  Needs to be adjusted
+  * whenever a new SHFL_MF_ flag is added. */
+#define SHFL_MF_MASK       (0x00000011)
+/** UC2 enconded strings. */
+#define SHFL_MF_UCS2       (0x00000000)
 /** Guest uses UTF8 strings, if not set then the strings are unicode (UCS2). */
-#define SHFL_MF_UTF8 (0x00000001)
+#define SHFL_MF_UTF8       (0x00000001)
+/** Just handle the auto-mounted folders. */
+#define SHFL_MF_AUTOMOUNT  (0x00000010)
 
 /** Type of guest system. For future system dependent features. */
@@ -992,4 +999,11 @@
 
 /**
+ * SHFL_FN_ADD_MAPPING, with auto-mount flag.
+ * Host call, no guest structure is used.
+ */
+
+#define SHFL_CPARMS_ADD_MAPPING2 (4)
+
+/**
  * SHFL_FN_REMOVE_MAPPING
  * Host call, no guest structure is used.
Index: /trunk/src/VBox/Additions/WINNT/VBoxTray/Makefile.kmk
===================================================================
--- /trunk/src/VBox/Additions/WINNT/VBoxTray/Makefile.kmk	(revision 31001)
+++ /trunk/src/VBox/Additions/WINNT/VBoxTray/Makefile.kmk	(revision 31002)
@@ -5,5 +5,5 @@
 
 #
-# Copyright (C) 2006-2007 Oracle Corporation
+# Copyright (C) 2006-2010 Oracle Corporation
 #
 # This file is part of VirtualBox Open Source Edition (OSE), as
@@ -42,4 +42,11 @@
 	VBoxHostVersion.cpp
 endif
+ifdef VBOX_WITH_SHARED_FOLDERS
+ VBoxTray_DEFS     +=  VBOX_WITH_SHARED_FOLDERS
+ VBoxTray_SOURCES  += \
+	VBoxSharedFolders.cpp
+ VBoxTray_LIBS.win += \
+	mpr.lib
+endif
 
 VBoxTray_LIBS     = \
Index: /trunk/src/VBox/Additions/WINNT/VBoxTray/VBoxHostVersion.cpp
===================================================================
--- /trunk/src/VBox/Additions/WINNT/VBoxTray/VBoxHostVersion.cpp	(revision 31001)
+++ /trunk/src/VBox/Additions/WINNT/VBoxTray/VBoxHostVersion.cpp	(revision 31002)
@@ -6,5 +6,5 @@
 
 /*
- * Copyright (C) 2009 Oracle Corporation
+ * Copyright (C) 2010 Oracle Corporation
  *
  * This file is part of VirtualBox Open Source Edition (OSE), as
@@ -45,5 +45,5 @@
                 char szTitle[64];
 
-                /** @todo add some translation macros here */
+                /** @todo Add some translation macros here. */
                 _snprintf(szTitle, sizeof(szTitle), "VirtualBox Guest Additions update available!");
                 _snprintf(szMsg, sizeof(szMsg), "Your guest is currently running the Guest Additions version %s. "
@@ -56,5 +56,5 @@
             }
 
-            /* Store host version to not notify again */
+            /* Store host version to not notify again. */
             rc = VbglR3HostVersionLastCheckedStore(uGuestPropSvcClientID, pszHostVersion);
 
Index: /trunk/src/VBox/Additions/WINNT/VBoxTray/VBoxHostVersion.h
===================================================================
--- /trunk/src/VBox/Additions/WINNT/VBoxTray/VBoxHostVersion.h	(revision 31001)
+++ /trunk/src/VBox/Additions/WINNT/VBoxTray/VBoxHostVersion.h	(revision 31002)
@@ -1,8 +1,9 @@
 /** @file
- * VBoxRestore - Restore notification
+ * VBoxHostVersion - Checks the host's VirtualBox version and notifies
+ *                   the user in case of an update.
  */
 
 /*
- * Copyright (C) 2006-2007 Oracle Corporation
+ * Copyright (C) 2006-2010 Oracle Corporation
  *
  * This file is part of VirtualBox Open Source Edition (OSE), as
Index: /trunk/src/VBox/Additions/WINNT/VBoxTray/VBoxTray.cpp
===================================================================
--- /trunk/src/VBox/Additions/WINNT/VBoxTray/VBoxTray.cpp	(revision 31001)
+++ /trunk/src/VBox/Additions/WINNT/VBoxTray/VBoxTray.cpp	(revision 31002)
@@ -22,4 +22,5 @@
 #include "VBoxVRDP.h"
 #include "VBoxHostVersion.h"
+#include "VBoxSharedFolders.h"
 #include <VBoxHook.h>
 #include "resource.h"
@@ -454,4 +455,6 @@
                  NULL       /* No timerproc */);
     }
+
+    VBoxSharedFoldersAutoMount();
 
     /* Boost thread priority to make sure we wake up early for seamless window notifications (not sure if it actually makes any difference though) */
Index: /trunk/src/VBox/Additions/WINNT/VBoxTray/helpers.cpp
===================================================================
--- /trunk/src/VBox/Additions/WINNT/VBoxTray/helpers.cpp	(revision 31001)
+++ /trunk/src/VBox/Additions/WINNT/VBoxTray/helpers.cpp	(revision 31002)
@@ -254,2 +254,3 @@
     return 0;
 }
+
Index: /trunk/src/VBox/Additions/common/VBoxControl/Makefile.kmk
===================================================================
--- /trunk/src/VBox/Additions/common/VBoxControl/Makefile.kmk	(revision 31001)
+++ /trunk/src/VBox/Additions/common/VBoxControl/Makefile.kmk	(revision 31002)
@@ -5,5 +5,5 @@
 
 #
-# Copyright (C) 2008 Oracle Corporation
+# Copyright (C) 2010 Oracle Corporation
 #
 # This file is part of VirtualBox Open Source Edition (OSE), as
@@ -33,5 +33,7 @@
 endif
 VBoxControl_DEFS     += \
-	$(if $(VBOX_WITH_GUEST_PROPS),VBOX_WITH_GUEST_PROPS VBOX_WITH_HGCM,)
+	$(if $(VBOX_WITH_HGCM),VBOX_WITH_HGCM,) \
+	$(if $(VBOX_WITH_GUEST_PROPS),VBOX_WITH_GUEST_PROPS,) \
+	$(if $(VBOX_WITH_SHARED_FOLDERS),VBOX_WITH_SHARED_FOLDERS,)
 VBoxControl_SOURCES = \
 	VBoxControl.cpp
Index: /trunk/src/VBox/Additions/common/VBoxControl/VBoxControl.cpp
===================================================================
--- /trunk/src/VBox/Additions/common/VBoxControl/VBoxControl.cpp	(revision 31001)
+++ /trunk/src/VBox/Additions/common/VBoxControl/VBoxControl.cpp	(revision 31002)
@@ -78,4 +78,7 @@
     GUEST_PROP,
 #endif
+#ifdef VBOX_WITH_SHARED_FOLDERS
+    GUEST_SHAREDFOLDERS,
+#endif
     USAGE_ALL = UINT32_MAX
 };
@@ -113,4 +116,10 @@
         doUsage("[-timestamp <last timestamp>]");
         doUsage("[-timeout <timeout in ms>");
+    }
+#endif
+#ifdef VBOX_WITH_SHARED_FOLDERS
+    if ((GUEST_SHAREDFOLDERS == eWhich) || (USAGE_ALL == eWhich))
+    {
+        doUsage("list [-automount]", g_pszProgName, "sharedfolder");
     }
 #endif
@@ -1255,5 +1264,97 @@
     return 1;
 }
-
+#endif
+
+#ifdef VBOX_WITH_SHARED_FOLDERS
+/**
+ * Lists the Shared Folders provided by the host.
+ */
+int listSharedFolders(int argc, char **argv)
+{
+    bool usageOK = true;
+    bool fOnlyShowAutoMount = false;
+    if (   argc == 1
+        && (   RTStrICmp(argv[0], "-automount") == 0
+            || RTStrICmp(argv[0], "/automount") == 0)
+       )
+    {
+        fOnlyShowAutoMount = true;
+    }
+    else if (argc > 1)
+        usageOK = false;
+
+    if (!usageOK)
+    {
+        usage(GUEST_SHAREDFOLDERS);
+        return 1;
+    }
+
+    uint32_t u32ClientId;
+    int rc = VbglR3SharedFolderConnect(&u32ClientId);
+    if (!RT_SUCCESS(rc))
+        VBoxControlError("Failed to connect to the shared folder service, error %Rrc\n", rc);
+    else
+    {
+        uint32_t cMappings = 64; /* See shflsvc.h for define; should be used later. */
+        uint32_t cbMappings = cMappings * sizeof(VBGLR3SHAREDFOLDERMAPPING);
+        VBGLR3SHAREDFOLDERMAPPING *pMappings = (VBGLR3SHAREDFOLDERMAPPING*)RTMemAlloc(cbMappings);
+
+        if (pMappings)
+        {
+            rc = VbglR3SharedFolderGetMappings(u32ClientId, fOnlyShowAutoMount,
+                                               pMappings, cbMappings,
+                                               &cMappings);
+            if (RT_SUCCESS(rc))
+            {
+                RT_CLAMP(cMappings, 0, 64); /* Maximum mappings, see shflsvc.h */
+                RTPrintf("Shared Folder Mappings (%u):\n\n", cMappings);
+                for (uint32_t i = 0; i < cMappings; i++)
+                {
+                    char *ppszName = NULL;
+                    uint32_t pcbLen = 0;
+                    rc = VbglR3SharedFolderGetName(u32ClientId, pMappings[i].u32Root,
+                                                   &ppszName, &pcbLen);
+                    if (RT_SUCCESS(rc))
+                    {
+                        RTPrintf("%02u - %s\n", i + 1, ppszName);
+                        RTStrFree(ppszName);
+                    }
+                    else
+                        VBoxControlError("Error while getting the shared folder name for root node = %u, rc = %Rrc\n",
+                                         pMappings[i].u32Root, rc);
+                }
+                if (cMappings == 0)
+                    RTPrintf("No Shared Folders available.\n");
+            }
+            else
+                VBoxControlError("Error while getting the shared folder mappings, rc = %Rrc\n", rc);
+            RTMemFree(pMappings);
+        }
+        else
+            rc = VERR_NO_MEMORY;
+        VbglR3SharedFolderDisconnect(u32ClientId);
+    }
+    return RT_SUCCESS(rc) ? 0 : 1;
+}
+
+/**
+ * Handles Shared Folders control.
+ *
+ * @returns 0 on success, 1 on failure
+ * @note see the command line API description for parameters
+ */
+static int handleSharedFolder(int argc, char *argv[])
+{
+    if (0 == argc)
+    {
+        usage(GUEST_SHAREDFOLDERS);
+        return 1;
+    }
+    if (0 == strcmp(argv[0], "list"))
+        return listSharedFolders(argc - 1, argv + 1);
+    /* else */
+    usage(GUEST_SHAREDFOLDERS);
+    return 1;
+}
 #endif
 
@@ -1279,4 +1380,7 @@
 #ifdef VBOX_WITH_GUEST_PROPS
     { "guestproperty", handleGuestProperty },
+#endif
+#ifdef VBOX_WITH_SHARED_FOLDERS
+    { "sharedfolder", handleSharedFolder },
 #endif
     { NULL, NULL }  /* terminator */
Index: /trunk/src/VBox/Additions/common/VBoxGuestLib/Makefile.kmk
===================================================================
--- /trunk/src/VBox/Additions/common/VBoxGuestLib/Makefile.kmk	(revision 31001)
+++ /trunk/src/VBox/Additions/common/VBoxGuestLib/Makefile.kmk	(revision 31002)
@@ -61,5 +61,5 @@
 	VMMDev.cpp \
 	HGCM.cpp \
-	VBoxCalls.c \
+	VBoxGuestR0LibSharedFolders.c \
 	VbglR0CanUsePhysPageList.cpp
 
@@ -88,4 +88,5 @@
 	VBOX_WITH_HGCM \
 	$(if $(VBOX_WITH_GUEST_PROPS),VBOX_WITH_GUEST_PROPS,) \
+	$(if $(VBOX_WITH_SHARED_FOLDERS),VBOX_WITH_SHARED_FOLDERS,) \
 	$(if $(VBOX_WITH_GUEST_CONTROL),VBOX_WITH_GUEST_CONTROL,)
 VBoxGuestR3Lib_SOURCES     = \
@@ -114,4 +115,8 @@
  	VBoxGuestR3LibGuestProp.cpp \
  	VBoxGuestR3LibHostVersion.cpp
+endif
+ifdef VBOX_WITH_SHARED_FOLDERS
+ VBoxGuestR3Lib_SOURCES   += \
+ 	VBoxGuestR3LibSharedFolders.cpp
 endif
 ifdef VBOX_WITH_GUEST_CONTROL
Index: unk/src/VBox/Additions/common/VBoxGuestLib/VBoxCalls.c
===================================================================
--- /trunk/src/VBox/Additions/common/VBoxGuestLib/VBoxCalls.c	(revision 31001)
+++ 	(revision )
@@ -1,684 +1,0 @@
-/* $Revision$ */
-/** @file
- * VBoxGuestLibR0 - Central calls.
- */
-
-/*
- * Copyright (C) 2006-2007 Oracle Corporation
- *
- * This file is part of VirtualBox Open Source Edition (OSE), as
- * available from http://www.virtualbox.org. This file is free software;
- * you can redistribute it and/or modify it under the terms of the GNU
- * General Public License (GPL) as published by the Free Software
- * Foundation, in version 2 as it comes in the "COPYING" file of the
- * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
- * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
- *
- * The contents of this file may alternatively be used under the terms
- * of the Common Development and Distribution License Version 1.0
- * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
- * VirtualBox OSE distribution, in which case the provisions of the
- * CDDL are applicable instead of those of the GPL.
- *
- * You may elect to license modified versions of this file under the
- * terms and conditions of either the GPL or the CDDL or both.
- */
-
-/* Entire file is ifdef'ed with !VBGL_VBOXGUEST */
-#ifndef VBGL_VBOXGUEST
-
-#ifdef RT_OS_LINUX
-# include "VBoxCalls.h"
-# define DbgPrint RTAssertMsg2Weak
-#else
-# include "VBoxCalls.h"
-#endif
-#include <iprt/time.h>
-#include <iprt/mem.h>
-#include <iprt/path.h>
-#include <iprt/string.h>
-
-#define SHFL_CPARMS_SET_UTF8 0
-
-#define VBOX_INIT_CALL(a, b, c)          \
-    (a)->result      = VINF_SUCCESS;     \
-    (a)->u32ClientID = (c)->ulClientID;  \
-    (a)->u32Function = SHFL_FN_##b;      \
-    (a)->cParms      = SHFL_CPARMS_##b
-
-#ifndef RT_OS_WINDOWS
-# define RtlZeroMemory(a, b) memset (a, 0, b)
-#endif
-
-
-DECLVBGL(int) vboxInit (void)
-{
-    int rc = VINF_SUCCESS;
-
-    rc = VbglInit ();
-    return rc;
-}
-
-DECLVBGL(void) vboxUninit (void)
-{
-    VbglTerminate ();
-}
-
-DECLVBGL(int) vboxConnect (PVBSFCLIENT pClient)
-{
-    int rc = VINF_SUCCESS;
-
-    VBoxGuestHGCMConnectInfo data;
-
-    RtlZeroMemory (&data, sizeof (VBoxGuestHGCMConnectInfo));
-
-    pClient->handle = NULL;
-
-    data.result   = VINF_SUCCESS;
-    data.Loc.type = VMMDevHGCMLoc_LocalHost_Existing;
-    strcpy (data.Loc.u.host.achName, "VBoxSharedFolders");
-
-    rc = VbglHGCMConnect (&pClient->handle, &data);
-
-/*    Log(("VBOXSF: VBoxSF::vboxConnect: VbglHGCMConnect rc = %#x, result = %#x\n",
-         rc, data.result));
-*/
-    if (RT_SUCCESS (rc))
-    {
-        rc = data.result;
-    }
-
-    if (RT_SUCCESS (rc))
-    {
-        pClient->ulClientID = data.u32ClientID;
-    }
-    return rc;
-}
-
-DECLVBGL(void) vboxDisconnect (PVBSFCLIENT pClient)
-{
-    int rc;
-
-    VBoxGuestHGCMDisconnectInfo data;
-
-    if (pClient->handle == NULL)
-        return;                 /* not connected */
-
-    RtlZeroMemory (&data, sizeof (VBoxGuestHGCMDisconnectInfo));
-
-    data.result      = VINF_SUCCESS;
-    data.u32ClientID = pClient->ulClientID;
-
-    rc = VbglHGCMDisconnect (pClient->handle, &data);
-/*    Log(("VBOXSF: VBoxSF::vboxDisconnect: "
-         "VbglHGCMDisconnect rc = %#x, result = %#x\n", rc, data.result));
-*/
-    return;
-}
-
-DECLVBGL(int) vboxCallQueryMappings (PVBSFCLIENT pClient, SHFLMAPPING paMappings[],
-                           uint32_t *pcMappings)
-{
-    int rc = VINF_SUCCESS;
-
-    VBoxSFQueryMappings data;
-
-    VBOX_INIT_CALL(&data.callInfo, QUERY_MAPPINGS, pClient);
-
-    data.flags.type                      = VMMDevHGCMParmType_32bit;
-    data.flags.u.value32                 = SHFL_MF_UCS2;
-
-    data.numberOfMappings.type           = VMMDevHGCMParmType_32bit;
-    data.numberOfMappings.u.value32      = *pcMappings;
-
-    data.mappings.type                   = VMMDevHGCMParmType_LinAddr;
-    data.mappings.u.Pointer.size         = sizeof (SHFLMAPPING) * *pcMappings;
-    data.mappings.u.Pointer.u.linearAddr = (uintptr_t)&paMappings[0];
-
-/*    Log(("VBOXSF: in ifs difference %d\n",
-         (char *)&data.flags.type - (char *)&data.callInfo.cParms));
-*/
-    rc = VbglHGCMCall (pClient->handle, &data.callInfo, sizeof (data));
-
-/*
-    Log(("VBOXSF: VBoxSF::vboxCallQueryMappings: "
-         "VbglHGCMCall rc = %#x, result = %#x\n", rc, data.callInfo.result));
-*/
-    if (RT_SUCCESS (rc))
-    {
-        rc = data.callInfo.result;
-    }
-
-    if (RT_SUCCESS (rc))
-    {
-        *pcMappings = data.numberOfMappings.u.value32;
-    }
-
-    return rc;
-}
-
-DECLVBGL(int) vboxCallQueryMapName (PVBSFCLIENT pClient, SHFLROOT root, SHFLSTRING *pString, uint32_t size)
-{
-    int rc = VINF_SUCCESS;
-
-    VBoxSFQueryMapName data;
-
-    VBOX_INIT_CALL(&data.callInfo, QUERY_MAP_NAME, pClient);
-
-    data.root.type                   = VMMDevHGCMParmType_32bit;
-    data.root.u.value32              = root;
-
-    data.name.type                   = VMMDevHGCMParmType_LinAddr;
-    data.name.u.Pointer.size         = size;
-    data.name.u.Pointer.u.linearAddr = (uintptr_t)pString;
-
-    rc = VbglHGCMCall (pClient->handle, &data.callInfo, sizeof (data));
-
-/*    Log(("VBOXSF: VBoxSF::vboxCallQueryMapName: "
-         "VbglHGCMCall rc = %#x, result = %#x\n", rc, data.callInfo.result));
-*/
-    if (RT_SUCCESS (rc))
-    {
-        rc = data.callInfo.result;
-    }
-
-    return rc;
-}
-
-DECLVBGL(int) vboxCallMapFolder(PVBSFCLIENT pClient, PSHFLSTRING szFolderName,
-                                PVBSFMAP pMap)
-{
-    int rc = VINF_SUCCESS;
-
-    VBoxSFMapFolder data;
-
-    VBOX_INIT_CALL(&data.callInfo, MAP_FOLDER, pClient);
-
-    data.path.type                    = VMMDevHGCMParmType_LinAddr;
-    data.path.u.Pointer.size          = ShflStringSizeOfBuffer (szFolderName);
-    data.path.u.Pointer.u.linearAddr  = (uintptr_t)szFolderName;
-
-    data.root.type                    = VMMDevHGCMParmType_32bit;
-    data.root.u.value32               = 0;
-
-    data.delimiter.type               = VMMDevHGCMParmType_32bit;
-    data.delimiter.u.value32          = RTPATH_DELIMITER;
-
-    data.fCaseSensitive.type          = VMMDevHGCMParmType_32bit;
-#if defined(RT_OS_WINDOWS) || defined(RT_OS_OS2)
-    data.fCaseSensitive.u.value32     = 0;
-#else
-    data.fCaseSensitive.u.value32     = 1;
-#endif
-
-    rc = VbglHGCMCall (pClient->handle, &data.callInfo, sizeof (data));
-
-/*    Log(("VBOXSF: VBoxSF::vboxCallMapFolder: "
-         "VbglHGCMCall rc = %#x, result = %#x\n", rc, data.callInfo.result));
-*/
-    if (RT_SUCCESS (rc))
-    {
-        pMap->root = data.root.u.value32;
-        rc         = data.callInfo.result;
-    }
-    else
-    if (rc == VERR_NOT_IMPLEMENTED)
-    {
-        /* try the legacy interface too; temporary to assure backwards compatibility */
-        VBoxSFMapFolder_Old data;
-
-        VBOX_INIT_CALL(&data.callInfo, MAP_FOLDER_OLD, pClient);
-
-        data.path.type                    = VMMDevHGCMParmType_LinAddr;
-        data.path.u.Pointer.size          = ShflStringSizeOfBuffer (szFolderName);
-        data.path.u.Pointer.u.linearAddr  = (uintptr_t)szFolderName;
-
-        data.root.type                    = VMMDevHGCMParmType_32bit;
-        data.root.u.value32               = 0;
-
-        data.delimiter.type               = VMMDevHGCMParmType_32bit;
-        data.delimiter.u.value32          = RTPATH_DELIMITER;
-
-        rc = VbglHGCMCall (pClient->handle, &data.callInfo, sizeof (data));
-
-        if (RT_SUCCESS (rc))
-        {
-            pMap->root = data.root.u.value32;
-            rc         = data.callInfo.result;
-        }
-    }
-    return rc;
-}
-
-DECLVBGL(int) vboxCallUnmapFolder(PVBSFCLIENT pClient, PVBSFMAP pMap)
-{
-    int rc = VINF_SUCCESS;
-
-    VBoxSFUnmapFolder data;
-
-    VBOX_INIT_CALL(&data.callInfo, UNMAP_FOLDER, pClient);
-
-    data.root.type                      = VMMDevHGCMParmType_32bit;
-    data.root.u.value32                 = pMap->root;
-
-    rc = VbglHGCMCall (pClient->handle, &data.callInfo, sizeof (data));
-
-/*    Log(("VBOXSF: VBoxSF::vboxCallUnmapFolder: "
-         "VbglHGCMCall rc = %#x, result = %#x\n", rc, data.callInfo.result));
-*/
-    if (RT_SUCCESS (rc))
-    {
-        rc         = data.callInfo.result;
-    }
-    return rc;
-}
-
-DECLVBGL(int) vboxCallCreate (PVBSFCLIENT pClient, PVBSFMAP pMap,
-                              PSHFLSTRING pParsedPath, PSHFLCREATEPARMS pCreateParms)
-{
-    /** @todo copy buffers to physical or mapped memory. */
-    int rc = VINF_SUCCESS;
-
-    VBoxSFCreate data;
-
-    VBOX_INIT_CALL(&data.callInfo, CREATE, pClient);
-
-    data.root.type                    = VMMDevHGCMParmType_32bit;
-    data.root.u.value32               = pMap->root;
-
-    data.path.type                    = VMMDevHGCMParmType_LinAddr;
-    data.path.u.Pointer.size          = ShflStringSizeOfBuffer (pParsedPath);
-    data.path.u.Pointer.u.linearAddr  = (uintptr_t)pParsedPath;
-
-    data.parms.type                   = VMMDevHGCMParmType_LinAddr;
-    data.parms.u.Pointer.size         = sizeof (SHFLCREATEPARMS);
-    data.parms.u.Pointer.u.linearAddr = (uintptr_t)pCreateParms;
-
-    rc = VbglHGCMCall (pClient->handle, &data.callInfo, sizeof (data));
-
-/*    Log(("VBOXSF: VBoxSF::vboxCallCreate: "
-         "VbglHGCMCall rc = %#x, result = %#x\n", rc, data.callInfo.result));
-*/
-    if (RT_SUCCESS (rc))
-    {
-        rc = data.callInfo.result;
-    }
-    return rc;
-}
-
-DECLVBGL(int) vboxCallClose (PVBSFCLIENT pClient, PVBSFMAP pMap, SHFLHANDLE Handle)
-{
-    int rc = VINF_SUCCESS;
-
-    VBoxSFClose data;
-
-    VBOX_INIT_CALL(&data.callInfo, CLOSE, pClient);
-
-    data.root.type                      = VMMDevHGCMParmType_32bit;
-    data.root.u.value32                 = pMap->root;
-
-    data.handle.type                    = VMMDevHGCMParmType_64bit;
-    data.handle.u.value64               = Handle;
-
-    rc = VbglHGCMCall (pClient->handle, &data.callInfo, sizeof (data));
-
-/*    Log(("VBOXSF: VBoxSF::vboxCallClose: "
-         "VbglHGCMCall rc = %#x, result = %#x\n", rc, data.callInfo.result));
-*/
-    if (RT_SUCCESS (rc))
-    {
-        rc = data.callInfo.result;
-    }
-
-    return rc;
-}
-
-DECLVBGL(int) vboxCallRemove (PVBSFCLIENT pClient, PVBSFMAP pMap,
-                              PSHFLSTRING pParsedPath, uint32_t flags)
-{
-    int rc = VINF_SUCCESS;
-
-    VBoxSFRemove data;
-
-    VBOX_INIT_CALL(&data.callInfo, REMOVE, pClient);
-
-    data.root.type                      = VMMDevHGCMParmType_32bit;
-    data.root.u.value32                 = pMap->root;
-
-    data.path.type                      = VMMDevHGCMParmType_LinAddr_In;
-    data.path.u.Pointer.size            = ShflStringSizeOfBuffer (pParsedPath);
-    data.path.u.Pointer.u.linearAddr    = (uintptr_t)pParsedPath;
-
-    data.flags.type                     = VMMDevHGCMParmType_32bit;
-    data.flags.u.value32                = flags;
-
-    rc = VbglHGCMCall (pClient->handle, &data.callInfo, sizeof (data));
-
-/*    Log(("VBOXSF: VBoxSF::vboxCallRemove: "
-         "VbglHGCMCall rc = %#x, result = %#x\n", rc, data.callInfo.result));
-*/
-    if (RT_SUCCESS (rc))
-    {
-        rc = data.callInfo.result;
-    }
-
-    return rc;
-}
-
-DECLVBGL(int) vboxCallRename (PVBSFCLIENT pClient, PVBSFMAP pMap,
-                              PSHFLSTRING pSrcPath, PSHFLSTRING pDestPath, uint32_t flags)
-{
-    int rc = VINF_SUCCESS;
-
-    VBoxSFRename data;
-
-    VBOX_INIT_CALL(&data.callInfo, RENAME, pClient);
-
-    data.root.type                      = VMMDevHGCMParmType_32bit;
-    data.root.u.value32                 = pMap->root;
-
-    data.src.type                       = VMMDevHGCMParmType_LinAddr_In;
-    data.src.u.Pointer.size             = ShflStringSizeOfBuffer (pSrcPath);
-    data.src.u.Pointer.u.linearAddr     = (uintptr_t)pSrcPath;
-
-    data.dest.type                      = VMMDevHGCMParmType_LinAddr_In;
-    data.dest.u.Pointer.size            = ShflStringSizeOfBuffer (pDestPath);
-    data.dest.u.Pointer.u.linearAddr    = (uintptr_t)pDestPath;
-
-    data.flags.type                     = VMMDevHGCMParmType_32bit;
-    data.flags.u.value32                = flags;
-
-    rc = VbglHGCMCall (pClient->handle, &data.callInfo, sizeof (data));
-
-/*    Log(("VBOXSF: VBoxSF::vboxCallRename: "
-         "VbglHGCMCall rc = %#x, result = %#x\n", rc, data.callInfo.result));
-*/
-    if (RT_SUCCESS (rc))
-    {
-        rc = data.callInfo.result;
-    }
-    return rc;
-}
-
-DECLVBGL(int) vboxCallRead(PVBSFCLIENT pClient, PVBSFMAP pMap, SHFLHANDLE hFile,
-                           uint64_t offset, uint32_t *pcbBuffer, uint8_t *pBuffer, bool fLocked)
-{
-    int rc = VINF_SUCCESS;
-
-    VBoxSFRead data;
-
-    VBOX_INIT_CALL(&data.callInfo, READ, pClient);
-
-    data.root.type                      = VMMDevHGCMParmType_32bit;
-    data.root.u.value32                 = pMap->root;
-
-    data.handle.type                    = VMMDevHGCMParmType_64bit;
-    data.handle.u.value64               = hFile;
-    data.offset.type                    = VMMDevHGCMParmType_64bit;
-    data.offset.u.value64               = offset;
-    data.cb.type                        = VMMDevHGCMParmType_32bit;
-    data.cb.u.value32                   = *pcbBuffer;
-    data.buffer.type                    = (fLocked) ? VMMDevHGCMParmType_LinAddr_Locked_Out : VMMDevHGCMParmType_LinAddr_Out;
-    data.buffer.u.Pointer.size          = *pcbBuffer;
-    data.buffer.u.Pointer.u.linearAddr  = (uintptr_t)pBuffer;
-
-    rc = VbglHGCMCall (pClient->handle, &data.callInfo, sizeof (data));
-
-/*    Log(("VBOXSF: VBoxSF::vboxCallRead: "
-         "VbglHGCMCall rc = %#x, result = %#x\n", rc, data.callInfo.result));
-*/
-    if (RT_SUCCESS (rc))
-    {
-        rc = data.callInfo.result;
-        *pcbBuffer = data.cb.u.value32;
-    }
-    return rc;
-}
-
-DECLVBGL(int) vboxCallWrite(PVBSFCLIENT pClient, PVBSFMAP pMap, SHFLHANDLE hFile,
-                            uint64_t offset, uint32_t *pcbBuffer, uint8_t *pBuffer, bool fLocked)
-{
-    int rc = VINF_SUCCESS;
-
-    VBoxSFWrite data;
-
-    VBOX_INIT_CALL(&data.callInfo, WRITE, pClient);
-
-    data.root.type                      = VMMDevHGCMParmType_32bit;
-    data.root.u.value32                 = pMap->root;
-
-    data.handle.type                    = VMMDevHGCMParmType_64bit;
-    data.handle.u.value64               = hFile;
-    data.offset.type                    = VMMDevHGCMParmType_64bit;
-    data.offset.u.value64               = offset;
-    data.cb.type                        = VMMDevHGCMParmType_32bit;
-    data.cb.u.value32                   = *pcbBuffer;
-    data.buffer.type                    = (fLocked) ? VMMDevHGCMParmType_LinAddr_Locked_In : VMMDevHGCMParmType_LinAddr_In;
-    data.buffer.u.Pointer.size          = *pcbBuffer;
-    data.buffer.u.Pointer.u.linearAddr  = (uintptr_t)pBuffer;
-
-    rc = VbglHGCMCall (pClient->handle, &data.callInfo, sizeof (data));
-
-/*    Log(("VBOXSF: VBoxSF::vboxCallWrite: "
-         "VbglHGCMCall rc = %#x, result = %#x\n", rc, data.callInfo.result));
-*/
-    if (RT_SUCCESS (rc))
-    {
-        rc = data.callInfo.result;
-        *pcbBuffer = data.cb.u.value32;
-    }
-    return rc;
-}
-
-DECLVBGL(int) VbglR0SfWritePhysCont(PVBSFCLIENT pClient, PVBSFMAP pMap, SHFLHANDLE hFile, uint64_t offset, uint32_t *pcbBuffer, RTCCPHYS PhysBuffer)
-{
-    uint32_t            cbToWrite = *pcbBuffer;
-    uint32_t            cPages    = RT_ALIGN_32((PhysBuffer & PAGE_OFFSET_MASK) + cbToWrite, PAGE_SIZE) >> PAGE_SHIFT;
-    uint32_t            cbData    = sizeof(VBoxSFWrite) + RT_UOFFSETOF(HGCMPageListInfo, aPages[cPages]);
-    VBoxSFWrite        *pData     = (VBoxSFWrite *)RTMemTmpAlloc(cbData);
-    HGCMPageListInfo   *pPgLst    = (HGCMPageListInfo *)(pData + 1);
-    uint32_t            iPage;
-    int                 rc;
-
-    if (RT_UNLIKELY(!pData))
-        return VERR_NO_TMP_MEMORY;
-
-    VBOX_INIT_CALL(&pData->callInfo, WRITE, pClient);
-
-    pData->root.type                      = VMMDevHGCMParmType_32bit;
-    pData->root.u.value32                 = pMap->root;
-
-    pData->handle.type                    = VMMDevHGCMParmType_64bit;
-    pData->handle.u.value64               = hFile;
-    pData->offset.type                    = VMMDevHGCMParmType_64bit;
-    pData->offset.u.value64               = offset;
-    pData->cb.type                        = VMMDevHGCMParmType_32bit;
-    pData->cb.u.value32                   = cbToWrite;
-    pData->buffer.type                    = VMMDevHGCMParmType_PageList;
-    pData->buffer.u.PageList.size         = cbToWrite;
-    pData->buffer.u.PageList.offset       = sizeof(VBoxSFWrite);
-
-    pPgLst->flags = VBOX_HGCM_F_PARM_DIRECTION_TO_HOST;
-    pPgLst->offFirstPage = PhysBuffer & PAGE_OFFSET_MASK;
-    pPgLst->cPages = cPages;
-    PhysBuffer &= ~(RTCCPHYS)PAGE_OFFSET_MASK;
-    for (iPage = 0; iPage < cPages; iPage++, PhysBuffer += PAGE_SIZE)
-        pPgLst->aPages[iPage] = PhysBuffer;
-
-    rc = VbglHGCMCall (pClient->handle, &pData->callInfo, cbData);
-    if (RT_SUCCESS (rc))
-    {
-        rc = pData->callInfo.result;
-        *pcbBuffer = pData->cb.u.value32;
-    }
-
-    RTMemTmpFree(pData);
-    return rc;
-
-}
-
-DECLVBGL(int) vboxCallFlush(PVBSFCLIENT pClient, PVBSFMAP pMap, SHFLHANDLE hFile)
-{
-    int rc = VINF_SUCCESS;
-
-    VBoxSFFlush data;
-
-    VBOX_INIT_CALL(&data.callInfo, FLUSH, pClient);
-
-    data.root.type                      = VMMDevHGCMParmType_32bit;
-    data.root.u.value32                 = pMap->root;
-
-    data.handle.type                    = VMMDevHGCMParmType_64bit;
-    data.handle.u.value64               = hFile;
-
-    rc = VbglHGCMCall (pClient->handle, &data.callInfo, sizeof (data));
-
-/*    Log(("VBOXSF: VBoxSF::vboxCallFlush: "
-         "VbglHGCMCall rc = %#x, result = %#x\n", rc, data.callInfo.result));
-*/
-    if (RT_SUCCESS (rc))
-    {
-        rc = data.callInfo.result;
-    }
-    return rc;
-}
-
-DECLVBGL(int) vboxCallDirInfo (
-    PVBSFCLIENT pClient,
-    PVBSFMAP pMap,
-    SHFLHANDLE hFile,
-    PSHFLSTRING ParsedPath,
-    uint32_t flags,
-    uint32_t index,
-    uint32_t *pcbBuffer,
-    PSHFLDIRINFO pBuffer,
-    uint32_t *pcFiles)
-{
-    int rc = VINF_SUCCESS;
-
-    VBoxSFList data;
-
-    VBOX_INIT_CALL(&data.callInfo, LIST, pClient);
-
-    data.root.type                      = VMMDevHGCMParmType_32bit;
-    data.root.u.value32                 = pMap->root;
-
-    data.handle.type                    = VMMDevHGCMParmType_64bit;
-    data.handle.u.value64               = hFile;
-    data.flags.type                     = VMMDevHGCMParmType_32bit;
-    data.flags.u.value32                = flags;
-    data.cb.type                        = VMMDevHGCMParmType_32bit;
-    data.cb.u.value32                   = *pcbBuffer;
-    data.path.type                      = VMMDevHGCMParmType_LinAddr_In;
-    data.path.u.Pointer.size            =
-        (ParsedPath) ? ShflStringSizeOfBuffer(ParsedPath) : 0;
-    data.path.u.Pointer.u.linearAddr    = (uintptr_t) ParsedPath;
-
-    data.buffer.type                    = VMMDevHGCMParmType_LinAddr_Out;
-    data.buffer.u.Pointer.size          = *pcbBuffer;
-    data.buffer.u.Pointer.u.linearAddr  = (uintptr_t)pBuffer;
-
-    data.resumePoint.type               = VMMDevHGCMParmType_32bit;
-    data.resumePoint.u.value32          = index;
-    data.cFiles.type                    = VMMDevHGCMParmType_32bit;
-    data.cFiles.u.value32               = 0; /* out parameters only */
-
-    rc = VbglHGCMCall (pClient->handle, &data.callInfo, sizeof (data));
-
-/*    Log(("VBOXSF: VBoxSF::vboxCallDirInfo: "
-         "VbglHGCMCall rc = %#x, result = %#x\n", rc, data.callInfo.result));
-*/
-    if (RT_SUCCESS (rc))
-    {
-        rc = data.callInfo.result;
-    }
-    *pcbBuffer = data.cb.u.value32;
-    *pcFiles   = data.cFiles.u.value32;
-    return rc;
-}
-
-DECLVBGL(int) vboxCallFSInfo(PVBSFCLIENT pClient, PVBSFMAP pMap, SHFLHANDLE hFile,
-                             uint32_t flags, uint32_t *pcbBuffer, PSHFLDIRINFO pBuffer)
-{
-    int rc = VINF_SUCCESS;
-
-    VBoxSFInformation data;
-
-    VBOX_INIT_CALL(&data.callInfo, INFORMATION, pClient);
-
-    data.root.type                      = VMMDevHGCMParmType_32bit;
-    data.root.u.value32                 = pMap->root;
-
-    data.handle.type                    = VMMDevHGCMParmType_64bit;
-    data.handle.u.value64               = hFile;
-    data.flags.type                     = VMMDevHGCMParmType_32bit;
-    data.flags.u.value32                = flags;
-    data.cb.type                        = VMMDevHGCMParmType_32bit;
-    data.cb.u.value32                   = *pcbBuffer;
-    data.info.type                      = VMMDevHGCMParmType_LinAddr;
-    data.info.u.Pointer.size            = *pcbBuffer;
-    data.info.u.Pointer.u.linearAddr    = (uintptr_t)pBuffer;
-
-    rc = VbglHGCMCall (pClient->handle, &data.callInfo, sizeof (data));
-
-/*    Log(("VBOXSF: VBoxSF::vboxCallFileInfo: "
-         "VbglHGCMCall rc = %#x, result = %#x\n", rc, data.callInfo.result));
-*/
-    if (RT_SUCCESS (rc))
-    {
-        rc = data.callInfo.result;
-        *pcbBuffer = data.cb.u.value32;
-    }
-    return rc;
-}
-
-DECLVBGL(int) vboxCallLock(PVBSFCLIENT pClient, PVBSFMAP pMap, SHFLHANDLE hFile,
-                           uint64_t offset, uint64_t cbSize, uint32_t fLock)
-{
-    int rc = VINF_SUCCESS;
-
-    VBoxSFLock data;
-
-    VBOX_INIT_CALL(&data.callInfo, LOCK, pClient);
-
-    data.root.type                      = VMMDevHGCMParmType_32bit;
-    data.root.u.value32                 = pMap->root;
-
-    data.handle.type                    = VMMDevHGCMParmType_64bit;
-    data.handle.u.value64               = hFile;
-    data.offset.type                    = VMMDevHGCMParmType_64bit;
-    data.offset.u.value64               = offset;
-    data.length.type                    = VMMDevHGCMParmType_64bit;
-    data.length.u.value64               = cbSize;
-
-    data.flags.type                     = VMMDevHGCMParmType_32bit;
-    data.flags.u.value32                = fLock;
-
-    rc = VbglHGCMCall (pClient->handle, &data.callInfo, sizeof (data));
-
-/*    Log(("VBOXSF: VBoxSF::vboxCallLock: "
-         "VbglHGCMCall rc = %#x, result = %#x\n", rc, data.callInfo.result));
-*/
-    if (RT_SUCCESS (rc))
-    {
-        rc = data.callInfo.result;
-    }
-    return rc;
-}
-
-DECLVBGL(int) vboxCallSetUtf8 (PVBSFCLIENT pClient)
-{
-    int rc = VINF_SUCCESS;
-
-    VBoxGuestHGCMCallInfo callInfo;
-
-    VBOX_INIT_CALL (&callInfo, SET_UTF8, pClient);
-    rc = VbglHGCMCall (pClient->handle, &callInfo, sizeof (callInfo));
-    if (RT_SUCCESS (rc))
-    {
-        rc = callInfo.result;
-    }
-    return rc;
-}
-
-#endif /* !VBGL_VBOXGUEST */
Index: unk/src/VBox/Additions/common/VBoxGuestLib/VBoxCalls.h
===================================================================
--- /trunk/src/VBox/Additions/common/VBoxGuestLib/VBoxCalls.h	(revision 31001)
+++ 	(revision )
@@ -1,181 +1,0 @@
-/** @file
- * VBoxGuestLib - Central calls header.
- */
-
-/*
- * Copyright (C) 2006-2007 Oracle Corporation
- *
- * This file is part of VirtualBox Open Source Edition (OSE), as
- * available from http://www.virtualbox.org. This file is free software;
- * you can redistribute it and/or modify it under the terms of the GNU
- * General Public License (GPL) as published by the Free Software
- * Foundation, in version 2 as it comes in the "COPYING" file of the
- * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
- * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
- *
- * The contents of this file may alternatively be used under the terms
- * of the Common Development and Distribution License Version 1.0
- * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
- * VirtualBox OSE distribution, in which case the provisions of the
- * CDDL are applicable instead of those of the GPL.
- *
- * You may elect to license modified versions of this file under the
- * terms and conditions of either the GPL or the CDDL or both.
- */
-
-#ifndef __VBOXCALLS__H
-#define __VBOXCALLS__H
-
-#include <VBox/VBoxGuestLib.h>
-#ifndef _NTIFS_
-# ifdef RT_OS_WINDOWS
-#  if (_MSC_VER >= 1400) && !defined(VBOX_WITH_PATCHED_DDK)
-#   include <iprt/asm.h>
-#   define _InterlockedExchange           _InterlockedExchange_StupidDDKvsCompilerCrap
-#   define _InterlockedExchangeAdd        _InterlockedExchangeAdd_StupidDDKvsCompilerCrap
-#   define _InterlockedCompareExchange    _InterlockedCompareExchange_StupidDDKvsCompilerCrap
-#   define _InterlockedAddLargeStatistic  _InterlockedAddLargeStatistic_StupidDDKvsCompilerCrap
-#   pragma warning(disable : 4163)
-    RT_C_DECLS_BEGIN
-#   include <ntddk.h>
-    RT_C_DECLS_END
-#   pragma warning(default : 4163)
-#   undef  _InterlockedExchange
-#   undef  _InterlockedExchangeAdd
-#   undef  _InterlockedCompareExchange
-#   undef  _InterlockedAddLargeStatistic
-#  else
-    RT_C_DECLS_BEGIN
-#   include <ntddk.h>
-    RT_C_DECLS_END
-#  endif
-# endif
-#endif
-
-#if defined(RT_OS_LINUX) || defined(RT_OS_WINDOWS)
-/** @todo remove this legacy and use VBox/log.h and/or iprt/log.h. */
-# ifdef DEBUG
-#  define LOG_ENABLED
-# endif
-# include "VBoxGuestLog.h"
-#endif
-
-#include <iprt/assert.h>
-#define ASSERTVBSF AssertRelease
-
-#include <VBox/shflsvc.h>
-
-typedef struct _VBSFCLIENT
-{
-    uint32_t ulClientID;
-    VBGLHGCMHANDLE handle;
-} VBSFCLIENT;
-typedef VBSFCLIENT *PVBSFCLIENT;
-
-typedef struct _VBSFMAP
-{
-    SHFLROOT root;
-} VBSFMAP, *PVBSFMAP;
-
-
-#define VBSF_DRIVE_LETTER_FIRST   L'A'
-#define VBSF_DRIVE_LETTER_LAST    L'Z'
-
-#define VBSF_MAX_DRIVES           (VBSF_DRIVE_LETTER_LAST - VBSF_DRIVE_LETTER_FIRST)
-
-/* Poller thread flags. */
-#define VBSF_TF_NONE             (0x0000)
-#define VBSF_TF_STARTED          (0x0001)
-#define VBSF_TF_TERMINATE        (0x0002)
-#define VBSF_TF_START_PROCESSING (0x0004)
-
-#define DRIVE_FLAG_WORKING         (0x1)
-#define DRIVE_FLAG_LOCKED          (0x2)
-#define DRIVE_FLAG_WRITE_PROTECTED (0x4)
-
-#ifdef RT_OS_WINDOWS
-/** Device extension structure for each drive letter we created. */
-typedef struct _VBSFDRIVE
-{
-    /*  A pointer to the Driver object we created for the drive. */
-    PDEVICE_OBJECT pDeviceObject;
-
-    /** Root handle to access the drive. */
-    SHFLROOT root;
-
-    /** Informational string - the resource name on host. */
-    WCHAR awcNameHost[256];
-
-    /** Guest drive letter. */
-    WCHAR wcDriveLetter;
-
-    /** DRIVE_FLAG_* */
-    uint32_t u32DriveFlags;
-
-    /** Head of FCB list. */
-    LIST_ENTRY FCBHead;
-
-    /* Synchronise requests directed to the drive. */
-    ERESOURCE DriveResource;
-} VBSFDRIVE;
-typedef VBSFDRIVE *PVBSFDRIVE;
-#endif /* RT_OS_WINDOWS */
-
-/* forward decl */
-struct _MRX_VBOX_DEVICE_EXTENSION;
-typedef struct _MRX_VBOX_DEVICE_EXTENSION *PMRX_VBOX_DEVICE_EXTENSION;
-
-DECLVBGL(int)  vboxInit (void);
-DECLVBGL(void) vboxUninit (void);
-DECLVBGL(int)  vboxConnect (PVBSFCLIENT pClient);
-DECLVBGL(void) vboxDisconnect (PVBSFCLIENT pClient);
-
-DECLVBGL(int) vboxCallQueryMappings (PVBSFCLIENT pClient, SHFLMAPPING paMappings[], uint32_t *pcMappings);
-
-DECLVBGL(int) vboxCallQueryMapName (PVBSFCLIENT pClient, SHFLROOT root, SHFLSTRING *pString, uint32_t size);
-
-/**
- * Create a new file or folder or open an existing one in a shared folder.  Proxies
- * to vbsfCreate in the host shared folder service.
- *
- * @returns IPRT status code, but see note below
- * @param   pClient      Host-guest communication connection
- * @param   pMap         The mapping for the shared folder in which the file
- *                       or folder is to be created
- * @param   pParsedPath  The path of the file or folder relative to the shared
- *                       folder
- * @param   pCreateParms Parameters for file/folder creation.  See the
- *                       structure description in shflsvc.h
- * @retval  pCreateParms See the structure description in shflsvc.h
- *
- * @note This function reports errors as follows.  The return value is always
- *       VINF_SUCCESS unless an exceptional condition occurrs - out of
- *       memory, invalid arguments, etc.  If the file or folder could not be
- *       opened or created, pCreateParms->Handle will be set to
- *       SHFL_HANDLE_NIL on return.  In this case the value in
- *       pCreateParms->Result provides information as to why (e.g.
- *       SHFL_FILE_EXISTS).  pCreateParms->Result is also set on success
- *       as additional information.
- */
-DECLVBGL(int) vboxCallCreate (PVBSFCLIENT pClient, PVBSFMAP pMap, PSHFLSTRING pParsedPath, PSHFLCREATEPARMS pCreateParms);
-
-DECLVBGL(int) vboxCallClose (PVBSFCLIENT pClient, PVBSFMAP pMap, SHFLHANDLE Handle);
-DECLVBGL(int) vboxCallRemove (PVBSFCLIENT pClient, PVBSFMAP pMap, PSHFLSTRING pParsedPath, uint32_t flags);
-DECLVBGL(int) vboxCallRename (PVBSFCLIENT pClient, PVBSFMAP pMap, PSHFLSTRING pSrcPath, PSHFLSTRING pDestPath, uint32_t flags);
-DECLVBGL(int) vboxCallFlush (PVBSFCLIENT pClient, PVBSFMAP pMap, SHFLHANDLE hFile);
-
-DECLVBGL(int) vboxCallRead (PVBSFCLIENT pClient, PVBSFMAP pMap, SHFLHANDLE hFile, uint64_t offset, uint32_t *pcbBuffer, uint8_t *pBuffer, bool fLocked);
-DECLVBGL(int) vboxCallWrite (PVBSFCLIENT pClient, PVBSFMAP pMap, SHFLHANDLE hFile, uint64_t offset, uint32_t *pcbBuffer, uint8_t *pBuffer, bool fLocked);
-DECLVBGL(int) VbglR0SfWritePhysCont(PVBSFCLIENT pClient, PVBSFMAP pMap, SHFLHANDLE hFile, uint64_t offset, uint32_t *pcbBuffer, RTCCPHYS PhysBuffer);
-
-DECLVBGL(int) vboxCallLock (PVBSFCLIENT pClient, PVBSFMAP pMap, SHFLHANDLE hFile, uint64_t offset, uint64_t cbSize, uint32_t fLock);
-
-DECLVBGL(int) vboxCallDirInfo (PVBSFCLIENT pClient, PVBSFMAP pMap, SHFLHANDLE hFile,PSHFLSTRING ParsedPath, uint32_t flags,
-                               uint32_t index, uint32_t *pcbBuffer, PSHFLDIRINFO pBuffer, uint32_t *pcFiles);
-DECLVBGL(int) vboxCallFSInfo (PVBSFCLIENT pClient, PVBSFMAP pMap, SHFLHANDLE hFile, uint32_t flags, uint32_t *pcbBuffer, PSHFLDIRINFO pBuffer);
-
-DECLVBGL(int) vboxCallMapFolder (PVBSFCLIENT pClient, PSHFLSTRING szFolderName, PVBSFMAP pMap);
-DECLVBGL(int) vboxCallUnmapFolder (PVBSFCLIENT pClient, PVBSFMAP pMap);
-DECLVBGL(int) vboxCallSetUtf8 (PVBSFCLIENT pClient);
-
-#endif /* __VBOXCALLS__H */
Index: /trunk/src/VBox/Additions/common/VBoxGuestLib/VBoxGuestR0LibSharedFolders.c
===================================================================
--- /trunk/src/VBox/Additions/common/VBoxGuestLib/VBoxGuestR0LibSharedFolders.c	(revision 31002)
+++ /trunk/src/VBox/Additions/common/VBoxGuestLib/VBoxGuestR0LibSharedFolders.c	(revision 31002)
@@ -0,0 +1,684 @@
+/* $Revision$ */
+/** @file
+ * VBoxGuestR0LibSharedFolders - Ring 0 Shared Folders calls.
+ */
+
+/*
+ * Copyright (C) 2006-2010 Oracle Corporation
+ *
+ * This file is part of VirtualBox Open Source Edition (OSE), as
+ * available from http://www.virtualbox.org. This file is free software;
+ * you can redistribute it and/or modify it under the terms of the GNU
+ * General Public License (GPL) as published by the Free Software
+ * Foundation, in version 2 as it comes in the "COPYING" file of the
+ * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
+ * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
+ *
+ * The contents of this file may alternatively be used under the terms
+ * of the Common Development and Distribution License Version 1.0
+ * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
+ * VirtualBox OSE distribution, in which case the provisions of the
+ * CDDL are applicable instead of those of the GPL.
+ *
+ * You may elect to license modified versions of this file under the
+ * terms and conditions of either the GPL or the CDDL or both.
+ */
+
+/* Entire file is ifdef'ed with !VBGL_VBOXGUEST */
+#ifndef VBGL_VBOXGUEST
+
+#ifdef RT_OS_LINUX
+# include "VBoxGuestR0LibSharedFolders.h"
+# define DbgPrint RTAssertMsg2Weak
+#else
+# include "VBoxGuestR0LibSharedFolders.h"
+#endif
+#include <iprt/time.h>
+#include <iprt/mem.h>
+#include <iprt/path.h>
+#include <iprt/string.h>
+
+#define SHFL_CPARMS_SET_UTF8 0
+
+#define VBOX_INIT_CALL(a, b, c)          \
+    (a)->result      = VINF_SUCCESS;     \
+    (a)->u32ClientID = (c)->ulClientID;  \
+    (a)->u32Function = SHFL_FN_##b;      \
+    (a)->cParms      = SHFL_CPARMS_##b
+
+#ifndef RT_OS_WINDOWS
+# define RtlZeroMemory(a, b) memset (a, 0, b)
+#endif
+
+
+DECLVBGL(int) vboxInit (void)
+{
+    int rc = VINF_SUCCESS;
+
+    rc = VbglInit ();
+    return rc;
+}
+
+DECLVBGL(void) vboxUninit (void)
+{
+    VbglTerminate ();
+}
+
+DECLVBGL(int) vboxConnect (PVBSFCLIENT pClient)
+{
+    int rc = VINF_SUCCESS;
+
+    VBoxGuestHGCMConnectInfo data;
+
+    RtlZeroMemory (&data, sizeof (VBoxGuestHGCMConnectInfo));
+
+    pClient->handle = NULL;
+
+    data.result   = VINF_SUCCESS;
+    data.Loc.type = VMMDevHGCMLoc_LocalHost_Existing;
+    strcpy (data.Loc.u.host.achName, "VBoxSharedFolders");
+
+    rc = VbglHGCMConnect (&pClient->handle, &data);
+
+/*    Log(("VBOXSF: VBoxSF::vboxConnect: VbglHGCMConnect rc = %#x, result = %#x\n",
+         rc, data.result));
+*/
+    if (RT_SUCCESS (rc))
+    {
+        rc = data.result;
+    }
+
+    if (RT_SUCCESS (rc))
+    {
+        pClient->ulClientID = data.u32ClientID;
+    }
+    return rc;
+}
+
+DECLVBGL(void) vboxDisconnect (PVBSFCLIENT pClient)
+{
+    int rc;
+
+    VBoxGuestHGCMDisconnectInfo data;
+
+    if (pClient->handle == NULL)
+        return;                 /* not connected */
+
+    RtlZeroMemory (&data, sizeof (VBoxGuestHGCMDisconnectInfo));
+
+    data.result      = VINF_SUCCESS;
+    data.u32ClientID = pClient->ulClientID;
+
+    rc = VbglHGCMDisconnect (pClient->handle, &data);
+/*    Log(("VBOXSF: VBoxSF::vboxDisconnect: "
+         "VbglHGCMDisconnect rc = %#x, result = %#x\n", rc, data.result));
+*/
+    return;
+}
+
+DECLVBGL(int) vboxCallQueryMappings (PVBSFCLIENT pClient, SHFLMAPPING paMappings[],
+                           uint32_t *pcMappings)
+{
+    int rc = VINF_SUCCESS;
+
+    VBoxSFQueryMappings data;
+
+    VBOX_INIT_CALL(&data.callInfo, QUERY_MAPPINGS, pClient);
+
+    data.flags.type                      = VMMDevHGCMParmType_32bit;
+    data.flags.u.value32                 = SHFL_MF_UCS2;
+
+    data.numberOfMappings.type           = VMMDevHGCMParmType_32bit;
+    data.numberOfMappings.u.value32      = *pcMappings;
+
+    data.mappings.type                   = VMMDevHGCMParmType_LinAddr;
+    data.mappings.u.Pointer.size         = sizeof (SHFLMAPPING) * *pcMappings;
+    data.mappings.u.Pointer.u.linearAddr = (uintptr_t)&paMappings[0];
+
+/*    Log(("VBOXSF: in ifs difference %d\n",
+         (char *)&data.flags.type - (char *)&data.callInfo.cParms));
+*/
+    rc = VbglHGCMCall (pClient->handle, &data.callInfo, sizeof (data));
+
+/*
+    Log(("VBOXSF: VBoxSF::vboxCallQueryMappings: "
+         "VbglHGCMCall rc = %#x, result = %#x\n", rc, data.callInfo.result));
+*/
+    if (RT_SUCCESS (rc))
+    {
+        rc = data.callInfo.result;
+    }
+
+    if (RT_SUCCESS (rc))
+    {
+        *pcMappings = data.numberOfMappings.u.value32;
+    }
+
+    return rc;
+}
+
+DECLVBGL(int) vboxCallQueryMapName (PVBSFCLIENT pClient, SHFLROOT root, SHFLSTRING *pString, uint32_t size)
+{
+    int rc = VINF_SUCCESS;
+
+    VBoxSFQueryMapName data;
+
+    VBOX_INIT_CALL(&data.callInfo, QUERY_MAP_NAME, pClient);
+
+    data.root.type                   = VMMDevHGCMParmType_32bit;
+    data.root.u.value32              = root;
+
+    data.name.type                   = VMMDevHGCMParmType_LinAddr;
+    data.name.u.Pointer.size         = size;
+    data.name.u.Pointer.u.linearAddr = (uintptr_t)pString;
+
+    rc = VbglHGCMCall (pClient->handle, &data.callInfo, sizeof (data));
+
+/*    Log(("VBOXSF: VBoxSF::vboxCallQueryMapName: "
+         "VbglHGCMCall rc = %#x, result = %#x\n", rc, data.callInfo.result));
+*/
+    if (RT_SUCCESS (rc))
+    {
+        rc = data.callInfo.result;
+    }
+
+    return rc;
+}
+
+DECLVBGL(int) vboxCallMapFolder(PVBSFCLIENT pClient, PSHFLSTRING szFolderName,
+                                PVBSFMAP pMap)
+{
+    int rc = VINF_SUCCESS;
+
+    VBoxSFMapFolder data;
+
+    VBOX_INIT_CALL(&data.callInfo, MAP_FOLDER, pClient);
+
+    data.path.type                    = VMMDevHGCMParmType_LinAddr;
+    data.path.u.Pointer.size          = ShflStringSizeOfBuffer (szFolderName);
+    data.path.u.Pointer.u.linearAddr  = (uintptr_t)szFolderName;
+
+    data.root.type                    = VMMDevHGCMParmType_32bit;
+    data.root.u.value32               = 0;
+
+    data.delimiter.type               = VMMDevHGCMParmType_32bit;
+    data.delimiter.u.value32          = RTPATH_DELIMITER;
+
+    data.fCaseSensitive.type          = VMMDevHGCMParmType_32bit;
+#if defined(RT_OS_WINDOWS) || defined(RT_OS_OS2)
+    data.fCaseSensitive.u.value32     = 0;
+#else
+    data.fCaseSensitive.u.value32     = 1;
+#endif
+
+    rc = VbglHGCMCall (pClient->handle, &data.callInfo, sizeof (data));
+
+/*    Log(("VBOXSF: VBoxSF::vboxCallMapFolder: "
+         "VbglHGCMCall rc = %#x, result = %#x\n", rc, data.callInfo.result));
+*/
+    if (RT_SUCCESS (rc))
+    {
+        pMap->root = data.root.u.value32;
+        rc         = data.callInfo.result;
+    }
+    else
+    if (rc == VERR_NOT_IMPLEMENTED)
+    {
+        /* try the legacy interface too; temporary to assure backwards compatibility */
+        VBoxSFMapFolder_Old data;
+
+        VBOX_INIT_CALL(&data.callInfo, MAP_FOLDER_OLD, pClient);
+
+        data.path.type                    = VMMDevHGCMParmType_LinAddr;
+        data.path.u.Pointer.size          = ShflStringSizeOfBuffer (szFolderName);
+        data.path.u.Pointer.u.linearAddr  = (uintptr_t)szFolderName;
+
+        data.root.type                    = VMMDevHGCMParmType_32bit;
+        data.root.u.value32               = 0;
+
+        data.delimiter.type               = VMMDevHGCMParmType_32bit;
+        data.delimiter.u.value32          = RTPATH_DELIMITER;
+
+        rc = VbglHGCMCall (pClient->handle, &data.callInfo, sizeof (data));
+
+        if (RT_SUCCESS (rc))
+        {
+            pMap->root = data.root.u.value32;
+            rc         = data.callInfo.result;
+        }
+    }
+    return rc;
+}
+
+DECLVBGL(int) vboxCallUnmapFolder(PVBSFCLIENT pClient, PVBSFMAP pMap)
+{
+    int rc = VINF_SUCCESS;
+
+    VBoxSFUnmapFolder data;
+
+    VBOX_INIT_CALL(&data.callInfo, UNMAP_FOLDER, pClient);
+
+    data.root.type                      = VMMDevHGCMParmType_32bit;
+    data.root.u.value32                 = pMap->root;
+
+    rc = VbglHGCMCall (pClient->handle, &data.callInfo, sizeof (data));
+
+/*    Log(("VBOXSF: VBoxSF::vboxCallUnmapFolder: "
+         "VbglHGCMCall rc = %#x, result = %#x\n", rc, data.callInfo.result));
+*/
+    if (RT_SUCCESS (rc))
+    {
+        rc         = data.callInfo.result;
+    }
+    return rc;
+}
+
+DECLVBGL(int) vboxCallCreate (PVBSFCLIENT pClient, PVBSFMAP pMap,
+                              PSHFLSTRING pParsedPath, PSHFLCREATEPARMS pCreateParms)
+{
+    /** @todo copy buffers to physical or mapped memory. */
+    int rc = VINF_SUCCESS;
+
+    VBoxSFCreate data;
+
+    VBOX_INIT_CALL(&data.callInfo, CREATE, pClient);
+
+    data.root.type                    = VMMDevHGCMParmType_32bit;
+    data.root.u.value32               = pMap->root;
+
+    data.path.type                    = VMMDevHGCMParmType_LinAddr;
+    data.path.u.Pointer.size          = ShflStringSizeOfBuffer (pParsedPath);
+    data.path.u.Pointer.u.linearAddr  = (uintptr_t)pParsedPath;
+
+    data.parms.type                   = VMMDevHGCMParmType_LinAddr;
+    data.parms.u.Pointer.size         = sizeof (SHFLCREATEPARMS);
+    data.parms.u.Pointer.u.linearAddr = (uintptr_t)pCreateParms;
+
+    rc = VbglHGCMCall (pClient->handle, &data.callInfo, sizeof (data));
+
+/*    Log(("VBOXSF: VBoxSF::vboxCallCreate: "
+         "VbglHGCMCall rc = %#x, result = %#x\n", rc, data.callInfo.result));
+*/
+    if (RT_SUCCESS (rc))
+    {
+        rc = data.callInfo.result;
+    }
+    return rc;
+}
+
+DECLVBGL(int) vboxCallClose (PVBSFCLIENT pClient, PVBSFMAP pMap, SHFLHANDLE Handle)
+{
+    int rc = VINF_SUCCESS;
+
+    VBoxSFClose data;
+
+    VBOX_INIT_CALL(&data.callInfo, CLOSE, pClient);
+
+    data.root.type                      = VMMDevHGCMParmType_32bit;
+    data.root.u.value32                 = pMap->root;
+
+    data.handle.type                    = VMMDevHGCMParmType_64bit;
+    data.handle.u.value64               = Handle;
+
+    rc = VbglHGCMCall (pClient->handle, &data.callInfo, sizeof (data));
+
+/*    Log(("VBOXSF: VBoxSF::vboxCallClose: "
+         "VbglHGCMCall rc = %#x, result = %#x\n", rc, data.callInfo.result));
+*/
+    if (RT_SUCCESS (rc))
+    {
+        rc = data.callInfo.result;
+    }
+
+    return rc;
+}
+
+DECLVBGL(int) vboxCallRemove (PVBSFCLIENT pClient, PVBSFMAP pMap,
+                              PSHFLSTRING pParsedPath, uint32_t flags)
+{
+    int rc = VINF_SUCCESS;
+
+    VBoxSFRemove data;
+
+    VBOX_INIT_CALL(&data.callInfo, REMOVE, pClient);
+
+    data.root.type                      = VMMDevHGCMParmType_32bit;
+    data.root.u.value32                 = pMap->root;
+
+    data.path.type                      = VMMDevHGCMParmType_LinAddr_In;
+    data.path.u.Pointer.size            = ShflStringSizeOfBuffer (pParsedPath);
+    data.path.u.Pointer.u.linearAddr    = (uintptr_t)pParsedPath;
+
+    data.flags.type                     = VMMDevHGCMParmType_32bit;
+    data.flags.u.value32                = flags;
+
+    rc = VbglHGCMCall (pClient->handle, &data.callInfo, sizeof (data));
+
+/*    Log(("VBOXSF: VBoxSF::vboxCallRemove: "
+         "VbglHGCMCall rc = %#x, result = %#x\n", rc, data.callInfo.result));
+*/
+    if (RT_SUCCESS (rc))
+    {
+        rc = data.callInfo.result;
+    }
+
+    return rc;
+}
+
+DECLVBGL(int) vboxCallRename (PVBSFCLIENT pClient, PVBSFMAP pMap,
+                              PSHFLSTRING pSrcPath, PSHFLSTRING pDestPath, uint32_t flags)
+{
+    int rc = VINF_SUCCESS;
+
+    VBoxSFRename data;
+
+    VBOX_INIT_CALL(&data.callInfo, RENAME, pClient);
+
+    data.root.type                      = VMMDevHGCMParmType_32bit;
+    data.root.u.value32                 = pMap->root;
+
+    data.src.type                       = VMMDevHGCMParmType_LinAddr_In;
+    data.src.u.Pointer.size             = ShflStringSizeOfBuffer (pSrcPath);
+    data.src.u.Pointer.u.linearAddr     = (uintptr_t)pSrcPath;
+
+    data.dest.type                      = VMMDevHGCMParmType_LinAddr_In;
+    data.dest.u.Pointer.size            = ShflStringSizeOfBuffer (pDestPath);
+    data.dest.u.Pointer.u.linearAddr    = (uintptr_t)pDestPath;
+
+    data.flags.type                     = VMMDevHGCMParmType_32bit;
+    data.flags.u.value32                = flags;
+
+    rc = VbglHGCMCall (pClient->handle, &data.callInfo, sizeof (data));
+
+/*    Log(("VBOXSF: VBoxSF::vboxCallRename: "
+         "VbglHGCMCall rc = %#x, result = %#x\n", rc, data.callInfo.result));
+*/
+    if (RT_SUCCESS (rc))
+    {
+        rc = data.callInfo.result;
+    }
+    return rc;
+}
+
+DECLVBGL(int) vboxCallRead(PVBSFCLIENT pClient, PVBSFMAP pMap, SHFLHANDLE hFile,
+                           uint64_t offset, uint32_t *pcbBuffer, uint8_t *pBuffer, bool fLocked)
+{
+    int rc = VINF_SUCCESS;
+
+    VBoxSFRead data;
+
+    VBOX_INIT_CALL(&data.callInfo, READ, pClient);
+
+    data.root.type                      = VMMDevHGCMParmType_32bit;
+    data.root.u.value32                 = pMap->root;
+
+    data.handle.type                    = VMMDevHGCMParmType_64bit;
+    data.handle.u.value64               = hFile;
+    data.offset.type                    = VMMDevHGCMParmType_64bit;
+    data.offset.u.value64               = offset;
+    data.cb.type                        = VMMDevHGCMParmType_32bit;
+    data.cb.u.value32                   = *pcbBuffer;
+    data.buffer.type                    = (fLocked) ? VMMDevHGCMParmType_LinAddr_Locked_Out : VMMDevHGCMParmType_LinAddr_Out;
+    data.buffer.u.Pointer.size          = *pcbBuffer;
+    data.buffer.u.Pointer.u.linearAddr  = (uintptr_t)pBuffer;
+
+    rc = VbglHGCMCall (pClient->handle, &data.callInfo, sizeof (data));
+
+/*    Log(("VBOXSF: VBoxSF::vboxCallRead: "
+         "VbglHGCMCall rc = %#x, result = %#x\n", rc, data.callInfo.result));
+*/
+    if (RT_SUCCESS (rc))
+    {
+        rc = data.callInfo.result;
+        *pcbBuffer = data.cb.u.value32;
+    }
+    return rc;
+}
+
+DECLVBGL(int) vboxCallWrite(PVBSFCLIENT pClient, PVBSFMAP pMap, SHFLHANDLE hFile,
+                            uint64_t offset, uint32_t *pcbBuffer, uint8_t *pBuffer, bool fLocked)
+{
+    int rc = VINF_SUCCESS;
+
+    VBoxSFWrite data;
+
+    VBOX_INIT_CALL(&data.callInfo, WRITE, pClient);
+
+    data.root.type                      = VMMDevHGCMParmType_32bit;
+    data.root.u.value32                 = pMap->root;
+
+    data.handle.type                    = VMMDevHGCMParmType_64bit;
+    data.handle.u.value64               = hFile;
+    data.offset.type                    = VMMDevHGCMParmType_64bit;
+    data.offset.u.value64               = offset;
+    data.cb.type                        = VMMDevHGCMParmType_32bit;
+    data.cb.u.value32                   = *pcbBuffer;
+    data.buffer.type                    = (fLocked) ? VMMDevHGCMParmType_LinAddr_Locked_In : VMMDevHGCMParmType_LinAddr_In;
+    data.buffer.u.Pointer.size          = *pcbBuffer;
+    data.buffer.u.Pointer.u.linearAddr  = (uintptr_t)pBuffer;
+
+    rc = VbglHGCMCall (pClient->handle, &data.callInfo, sizeof (data));
+
+/*    Log(("VBOXSF: VBoxSF::vboxCallWrite: "
+         "VbglHGCMCall rc = %#x, result = %#x\n", rc, data.callInfo.result));
+*/
+    if (RT_SUCCESS (rc))
+    {
+        rc = data.callInfo.result;
+        *pcbBuffer = data.cb.u.value32;
+    }
+    return rc;
+}
+
+DECLVBGL(int) VbglR0SfWritePhysCont(PVBSFCLIENT pClient, PVBSFMAP pMap, SHFLHANDLE hFile, uint64_t offset, uint32_t *pcbBuffer, RTCCPHYS PhysBuffer)
+{
+    uint32_t            cbToWrite = *pcbBuffer;
+    uint32_t            cPages    = RT_ALIGN_32((PhysBuffer & PAGE_OFFSET_MASK) + cbToWrite, PAGE_SIZE) >> PAGE_SHIFT;
+    uint32_t            cbData    = sizeof(VBoxSFWrite) + RT_UOFFSETOF(HGCMPageListInfo, aPages[cPages]);
+    VBoxSFWrite        *pData     = (VBoxSFWrite *)RTMemTmpAlloc(cbData);
+    HGCMPageListInfo   *pPgLst    = (HGCMPageListInfo *)(pData + 1);
+    uint32_t            iPage;
+    int                 rc;
+
+    if (RT_UNLIKELY(!pData))
+        return VERR_NO_TMP_MEMORY;
+
+    VBOX_INIT_CALL(&pData->callInfo, WRITE, pClient);
+
+    pData->root.type                      = VMMDevHGCMParmType_32bit;
+    pData->root.u.value32                 = pMap->root;
+
+    pData->handle.type                    = VMMDevHGCMParmType_64bit;
+    pData->handle.u.value64               = hFile;
+    pData->offset.type                    = VMMDevHGCMParmType_64bit;
+    pData->offset.u.value64               = offset;
+    pData->cb.type                        = VMMDevHGCMParmType_32bit;
+    pData->cb.u.value32                   = cbToWrite;
+    pData->buffer.type                    = VMMDevHGCMParmType_PageList;
+    pData->buffer.u.PageList.size         = cbToWrite;
+    pData->buffer.u.PageList.offset       = sizeof(VBoxSFWrite);
+
+    pPgLst->flags = VBOX_HGCM_F_PARM_DIRECTION_TO_HOST;
+    pPgLst->offFirstPage = PhysBuffer & PAGE_OFFSET_MASK;
+    pPgLst->cPages = cPages;
+    PhysBuffer &= ~(RTCCPHYS)PAGE_OFFSET_MASK;
+    for (iPage = 0; iPage < cPages; iPage++, PhysBuffer += PAGE_SIZE)
+        pPgLst->aPages[iPage] = PhysBuffer;
+
+    rc = VbglHGCMCall (pClient->handle, &pData->callInfo, cbData);
+    if (RT_SUCCESS (rc))
+    {
+        rc = pData->callInfo.result;
+        *pcbBuffer = pData->cb.u.value32;
+    }
+
+    RTMemTmpFree(pData);
+    return rc;
+
+}
+
+DECLVBGL(int) vboxCallFlush(PVBSFCLIENT pClient, PVBSFMAP pMap, SHFLHANDLE hFile)
+{
+    int rc = VINF_SUCCESS;
+
+    VBoxSFFlush data;
+
+    VBOX_INIT_CALL(&data.callInfo, FLUSH, pClient);
+
+    data.root.type                      = VMMDevHGCMParmType_32bit;
+    data.root.u.value32                 = pMap->root;
+
+    data.handle.type                    = VMMDevHGCMParmType_64bit;
+    data.handle.u.value64               = hFile;
+
+    rc = VbglHGCMCall (pClient->handle, &data.callInfo, sizeof (data));
+
+/*    Log(("VBOXSF: VBoxSF::vboxCallFlush: "
+         "VbglHGCMCall rc = %#x, result = %#x\n", rc, data.callInfo.result));
+*/
+    if (RT_SUCCESS (rc))
+    {
+        rc = data.callInfo.result;
+    }
+    return rc;
+}
+
+DECLVBGL(int) vboxCallDirInfo (
+    PVBSFCLIENT pClient,
+    PVBSFMAP pMap,
+    SHFLHANDLE hFile,
+    PSHFLSTRING ParsedPath,
+    uint32_t flags,
+    uint32_t index,
+    uint32_t *pcbBuffer,
+    PSHFLDIRINFO pBuffer,
+    uint32_t *pcFiles)
+{
+    int rc = VINF_SUCCESS;
+
+    VBoxSFList data;
+
+    VBOX_INIT_CALL(&data.callInfo, LIST, pClient);
+
+    data.root.type                      = VMMDevHGCMParmType_32bit;
+    data.root.u.value32                 = pMap->root;
+
+    data.handle.type                    = VMMDevHGCMParmType_64bit;
+    data.handle.u.value64               = hFile;
+    data.flags.type                     = VMMDevHGCMParmType_32bit;
+    data.flags.u.value32                = flags;
+    data.cb.type                        = VMMDevHGCMParmType_32bit;
+    data.cb.u.value32                   = *pcbBuffer;
+    data.path.type                      = VMMDevHGCMParmType_LinAddr_In;
+    data.path.u.Pointer.size            =
+        (ParsedPath) ? ShflStringSizeOfBuffer(ParsedPath) : 0;
+    data.path.u.Pointer.u.linearAddr    = (uintptr_t) ParsedPath;
+
+    data.buffer.type                    = VMMDevHGCMParmType_LinAddr_Out;
+    data.buffer.u.Pointer.size          = *pcbBuffer;
+    data.buffer.u.Pointer.u.linearAddr  = (uintptr_t)pBuffer;
+
+    data.resumePoint.type               = VMMDevHGCMParmType_32bit;
+    data.resumePoint.u.value32          = index;
+    data.cFiles.type                    = VMMDevHGCMParmType_32bit;
+    data.cFiles.u.value32               = 0; /* out parameters only */
+
+    rc = VbglHGCMCall (pClient->handle, &data.callInfo, sizeof (data));
+
+/*    Log(("VBOXSF: VBoxSF::vboxCallDirInfo: "
+         "VbglHGCMCall rc = %#x, result = %#x\n", rc, data.callInfo.result));
+*/
+    if (RT_SUCCESS (rc))
+    {
+        rc = data.callInfo.result;
+    }
+    *pcbBuffer = data.cb.u.value32;
+    *pcFiles   = data.cFiles.u.value32;
+    return rc;
+}
+
+DECLVBGL(int) vboxCallFSInfo(PVBSFCLIENT pClient, PVBSFMAP pMap, SHFLHANDLE hFile,
+                             uint32_t flags, uint32_t *pcbBuffer, PSHFLDIRINFO pBuffer)
+{
+    int rc = VINF_SUCCESS;
+
+    VBoxSFInformation data;
+
+    VBOX_INIT_CALL(&data.callInfo, INFORMATION, pClient);
+
+    data.root.type                      = VMMDevHGCMParmType_32bit;
+    data.root.u.value32                 = pMap->root;
+
+    data.handle.type                    = VMMDevHGCMParmType_64bit;
+    data.handle.u.value64               = hFile;
+    data.flags.type                     = VMMDevHGCMParmType_32bit;
+    data.flags.u.value32                = flags;
+    data.cb.type                        = VMMDevHGCMParmType_32bit;
+    data.cb.u.value32                   = *pcbBuffer;
+    data.info.type                      = VMMDevHGCMParmType_LinAddr;
+    data.info.u.Pointer.size            = *pcbBuffer;
+    data.info.u.Pointer.u.linearAddr    = (uintptr_t)pBuffer;
+
+    rc = VbglHGCMCall (pClient->handle, &data.callInfo, sizeof (data));
+
+/*    Log(("VBOXSF: VBoxSF::vboxCallFileInfo: "
+         "VbglHGCMCall rc = %#x, result = %#x\n", rc, data.callInfo.result));
+*/
+    if (RT_SUCCESS (rc))
+    {
+        rc = data.callInfo.result;
+        *pcbBuffer = data.cb.u.value32;
+    }
+    return rc;
+}
+
+DECLVBGL(int) vboxCallLock(PVBSFCLIENT pClient, PVBSFMAP pMap, SHFLHANDLE hFile,
+                           uint64_t offset, uint64_t cbSize, uint32_t fLock)
+{
+    int rc = VINF_SUCCESS;
+
+    VBoxSFLock data;
+
+    VBOX_INIT_CALL(&data.callInfo, LOCK, pClient);
+
+    data.root.type                      = VMMDevHGCMParmType_32bit;
+    data.root.u.value32                 = pMap->root;
+
+    data.handle.type                    = VMMDevHGCMParmType_64bit;
+    data.handle.u.value64               = hFile;
+    data.offset.type                    = VMMDevHGCMParmType_64bit;
+    data.offset.u.value64               = offset;
+    data.length.type                    = VMMDevHGCMParmType_64bit;
+    data.length.u.value64               = cbSize;
+
+    data.flags.type                     = VMMDevHGCMParmType_32bit;
+    data.flags.u.value32                = fLock;
+
+    rc = VbglHGCMCall (pClient->handle, &data.callInfo, sizeof (data));
+
+/*    Log(("VBOXSF: VBoxSF::vboxCallLock: "
+         "VbglHGCMCall rc = %#x, result = %#x\n", rc, data.callInfo.result));
+*/
+    if (RT_SUCCESS (rc))
+    {
+        rc = data.callInfo.result;
+    }
+    return rc;
+}
+
+DECLVBGL(int) vboxCallSetUtf8 (PVBSFCLIENT pClient)
+{
+    int rc = VINF_SUCCESS;
+
+    VBoxGuestHGCMCallInfo callInfo;
+
+    VBOX_INIT_CALL (&callInfo, SET_UTF8, pClient);
+    rc = VbglHGCMCall (pClient->handle, &callInfo, sizeof (callInfo));
+    if (RT_SUCCESS (rc))
+    {
+        rc = callInfo.result;
+    }
+    return rc;
+}
+
+#endif /* !VBGL_VBOXGUEST */
Index: /trunk/src/VBox/Additions/common/VBoxGuestLib/VBoxGuestR0LibSharedFolders.h
===================================================================
--- /trunk/src/VBox/Additions/common/VBoxGuestLib/VBoxGuestR0LibSharedFolders.h	(revision 31002)
+++ /trunk/src/VBox/Additions/common/VBoxGuestLib/VBoxGuestR0LibSharedFolders.h	(revision 31002)
@@ -0,0 +1,181 @@
+/** @file
+ * VBoxGuestLib - Central calls header.
+ */
+
+/*
+ * Copyright (C) 2006-2007 Oracle Corporation
+ *
+ * This file is part of VirtualBox Open Source Edition (OSE), as
+ * available from http://www.virtualbox.org. This file is free software;
+ * you can redistribute it and/or modify it under the terms of the GNU
+ * General Public License (GPL) as published by the Free Software
+ * Foundation, in version 2 as it comes in the "COPYING" file of the
+ * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
+ * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
+ *
+ * The contents of this file may alternatively be used under the terms
+ * of the Common Development and Distribution License Version 1.0
+ * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
+ * VirtualBox OSE distribution, in which case the provisions of the
+ * CDDL are applicable instead of those of the GPL.
+ *
+ * You may elect to license modified versions of this file under the
+ * terms and conditions of either the GPL or the CDDL or both.
+ */
+
+#ifndef __VBOXCALLS__H
+#define __VBOXCALLS__H
+
+#include <VBox/VBoxGuestLib.h>
+#ifndef _NTIFS_
+# ifdef RT_OS_WINDOWS
+#  if (_MSC_VER >= 1400) && !defined(VBOX_WITH_PATCHED_DDK)
+#   include <iprt/asm.h>
+#   define _InterlockedExchange           _InterlockedExchange_StupidDDKvsCompilerCrap
+#   define _InterlockedExchangeAdd        _InterlockedExchangeAdd_StupidDDKvsCompilerCrap
+#   define _InterlockedCompareExchange    _InterlockedCompareExchange_StupidDDKvsCompilerCrap
+#   define _InterlockedAddLargeStatistic  _InterlockedAddLargeStatistic_StupidDDKvsCompilerCrap
+#   pragma warning(disable : 4163)
+    RT_C_DECLS_BEGIN
+#   include <ntddk.h>
+    RT_C_DECLS_END
+#   pragma warning(default : 4163)
+#   undef  _InterlockedExchange
+#   undef  _InterlockedExchangeAdd
+#   undef  _InterlockedCompareExchange
+#   undef  _InterlockedAddLargeStatistic
+#  else
+    RT_C_DECLS_BEGIN
+#   include <ntddk.h>
+    RT_C_DECLS_END
+#  endif
+# endif
+#endif
+
+#if defined(RT_OS_LINUX) || defined(RT_OS_WINDOWS)
+/** @todo remove this legacy and use VBox/log.h and/or iprt/log.h. */
+# ifdef DEBUG
+#  define LOG_ENABLED
+# endif
+# include "VBoxGuestLog.h"
+#endif
+
+#include <iprt/assert.h>
+#define ASSERTVBSF AssertRelease
+
+#include <VBox/shflsvc.h>
+
+typedef struct _VBSFCLIENT
+{
+    uint32_t ulClientID;
+    VBGLHGCMHANDLE handle;
+} VBSFCLIENT;
+typedef VBSFCLIENT *PVBSFCLIENT;
+
+typedef struct _VBSFMAP
+{
+    SHFLROOT root;
+} VBSFMAP, *PVBSFMAP;
+
+
+#define VBSF_DRIVE_LETTER_FIRST   L'A'
+#define VBSF_DRIVE_LETTER_LAST    L'Z'
+
+#define VBSF_MAX_DRIVES           (VBSF_DRIVE_LETTER_LAST - VBSF_DRIVE_LETTER_FIRST)
+
+/* Poller thread flags. */
+#define VBSF_TF_NONE             (0x0000)
+#define VBSF_TF_STARTED          (0x0001)
+#define VBSF_TF_TERMINATE        (0x0002)
+#define VBSF_TF_START_PROCESSING (0x0004)
+
+#define DRIVE_FLAG_WORKING         (0x1)
+#define DRIVE_FLAG_LOCKED          (0x2)
+#define DRIVE_FLAG_WRITE_PROTECTED (0x4)
+
+#ifdef RT_OS_WINDOWS
+/** Device extension structure for each drive letter we created. */
+typedef struct _VBSFDRIVE
+{
+    /*  A pointer to the Driver object we created for the drive. */
+    PDEVICE_OBJECT pDeviceObject;
+
+    /** Root handle to access the drive. */
+    SHFLROOT root;
+
+    /** Informational string - the resource name on host. */
+    WCHAR awcNameHost[256];
+
+    /** Guest drive letter. */
+    WCHAR wcDriveLetter;
+
+    /** DRIVE_FLAG_* */
+    uint32_t u32DriveFlags;
+
+    /** Head of FCB list. */
+    LIST_ENTRY FCBHead;
+
+    /* Synchronise requests directed to the drive. */
+    ERESOURCE DriveResource;
+} VBSFDRIVE;
+typedef VBSFDRIVE *PVBSFDRIVE;
+#endif /* RT_OS_WINDOWS */
+
+/* forward decl */
+struct _MRX_VBOX_DEVICE_EXTENSION;
+typedef struct _MRX_VBOX_DEVICE_EXTENSION *PMRX_VBOX_DEVICE_EXTENSION;
+
+DECLVBGL(int)  vboxInit (void);
+DECLVBGL(void) vboxUninit (void);
+DECLVBGL(int)  vboxConnect (PVBSFCLIENT pClient);
+DECLVBGL(void) vboxDisconnect (PVBSFCLIENT pClient);
+
+DECLVBGL(int) vboxCallQueryMappings (PVBSFCLIENT pClient, SHFLMAPPING paMappings[], uint32_t *pcMappings);
+
+DECLVBGL(int) vboxCallQueryMapName (PVBSFCLIENT pClient, SHFLROOT root, SHFLSTRING *pString, uint32_t size);
+
+/**
+ * Create a new file or folder or open an existing one in a shared folder.  Proxies
+ * to vbsfCreate in the host shared folder service.
+ *
+ * @returns IPRT status code, but see note below
+ * @param   pClient      Host-guest communication connection
+ * @param   pMap         The mapping for the shared folder in which the file
+ *                       or folder is to be created
+ * @param   pParsedPath  The path of the file or folder relative to the shared
+ *                       folder
+ * @param   pCreateParms Parameters for file/folder creation.  See the
+ *                       structure description in shflsvc.h
+ * @retval  pCreateParms See the structure description in shflsvc.h
+ *
+ * @note This function reports errors as follows.  The return value is always
+ *       VINF_SUCCESS unless an exceptional condition occurrs - out of
+ *       memory, invalid arguments, etc.  If the file or folder could not be
+ *       opened or created, pCreateParms->Handle will be set to
+ *       SHFL_HANDLE_NIL on return.  In this case the value in
+ *       pCreateParms->Result provides information as to why (e.g.
+ *       SHFL_FILE_EXISTS).  pCreateParms->Result is also set on success
+ *       as additional information.
+ */
+DECLVBGL(int) vboxCallCreate (PVBSFCLIENT pClient, PVBSFMAP pMap, PSHFLSTRING pParsedPath, PSHFLCREATEPARMS pCreateParms);
+
+DECLVBGL(int) vboxCallClose (PVBSFCLIENT pClient, PVBSFMAP pMap, SHFLHANDLE Handle);
+DECLVBGL(int) vboxCallRemove (PVBSFCLIENT pClient, PVBSFMAP pMap, PSHFLSTRING pParsedPath, uint32_t flags);
+DECLVBGL(int) vboxCallRename (PVBSFCLIENT pClient, PVBSFMAP pMap, PSHFLSTRING pSrcPath, PSHFLSTRING pDestPath, uint32_t flags);
+DECLVBGL(int) vboxCallFlush (PVBSFCLIENT pClient, PVBSFMAP pMap, SHFLHANDLE hFile);
+
+DECLVBGL(int) vboxCallRead (PVBSFCLIENT pClient, PVBSFMAP pMap, SHFLHANDLE hFile, uint64_t offset, uint32_t *pcbBuffer, uint8_t *pBuffer, bool fLocked);
+DECLVBGL(int) vboxCallWrite (PVBSFCLIENT pClient, PVBSFMAP pMap, SHFLHANDLE hFile, uint64_t offset, uint32_t *pcbBuffer, uint8_t *pBuffer, bool fLocked);
+DECLVBGL(int) VbglR0SfWritePhysCont(PVBSFCLIENT pClient, PVBSFMAP pMap, SHFLHANDLE hFile, uint64_t offset, uint32_t *pcbBuffer, RTCCPHYS PhysBuffer);
+
+DECLVBGL(int) vboxCallLock (PVBSFCLIENT pClient, PVBSFMAP pMap, SHFLHANDLE hFile, uint64_t offset, uint64_t cbSize, uint32_t fLock);
+
+DECLVBGL(int) vboxCallDirInfo (PVBSFCLIENT pClient, PVBSFMAP pMap, SHFLHANDLE hFile,PSHFLSTRING ParsedPath, uint32_t flags,
+                               uint32_t index, uint32_t *pcbBuffer, PSHFLDIRINFO pBuffer, uint32_t *pcFiles);
+DECLVBGL(int) vboxCallFSInfo (PVBSFCLIENT pClient, PVBSFMAP pMap, SHFLHANDLE hFile, uint32_t flags, uint32_t *pcbBuffer, PSHFLDIRINFO pBuffer);
+
+DECLVBGL(int) vboxCallMapFolder (PVBSFCLIENT pClient, PSHFLSTRING szFolderName, PVBSFMAP pMap);
+DECLVBGL(int) vboxCallUnmapFolder (PVBSFCLIENT pClient, PVBSFMAP pMap);
+DECLVBGL(int) vboxCallSetUtf8 (PVBSFCLIENT pClient);
+
+#endif /* __VBOXCALLS__H */
Index: /trunk/src/VBox/Frontends/VBoxManage/VBoxManageHelp.cpp
===================================================================
--- /trunk/src/VBox/Frontends/VBoxManage/VBoxManageHelp.cpp	(revision 31001)
+++ /trunk/src/VBox/Frontends/VBoxManage/VBoxManageHelp.cpp	(revision 31002)
@@ -602,5 +602,5 @@
         RTPrintf("VBoxManage sharedfolder     add <vmname>|<uuid>\n"
                  "                            --name <name> --hostpath <hostpath>\n"
-                 "                            [--transient] [--readonly]\n"
+                 "                            [--transient] [--readonly] [--automount]\n"
                  "\n");
     }
Index: /trunk/src/VBox/Frontends/VBoxManage/VBoxManageMisc.cpp
===================================================================
--- /trunk/src/VBox/Frontends/VBoxManage/VBoxManageMisc.cpp	(revision 31001)
+++ /trunk/src/VBox/Frontends/VBoxManage/VBoxManageMisc.cpp	(revision 31002)
@@ -684,4 +684,5 @@
         bool fTransient = false;
         bool fWritable = true;
+        bool fAutoMount = false;
 
         for (int i = 2; i < a->argc; i++)
@@ -712,4 +713,9 @@
             {
                 fTransient = true;
+            }
+            else if (   !strcmp(a->argv[i], "--automount")
+                     || !strcmp(a->argv[i], "-automount"))
+            {
+                fAutoMount = true;
             }
             else
@@ -737,6 +743,6 @@
             CHECK_ERROR_RET(a->session, COMGETTER(Console)(console.asOutParam()), 1);
 
-            CHECK_ERROR(console, CreateSharedFolder(Bstr(name), Bstr(hostpath), fWritable));
-
+            CHECK_ERROR(console, CreateSharedFolder(Bstr(name), Bstr(hostpath),
+                                                    fWritable, fAutoMount));
             if (console)
                 a->session->Close();
@@ -750,6 +756,6 @@
             a->session->COMGETTER(Machine)(machine.asOutParam());
 
-            CHECK_ERROR(machine, CreateSharedFolder(Bstr(name), Bstr(hostpath), fWritable));
-
+            CHECK_ERROR(machine, CreateSharedFolder(Bstr(name), Bstr(hostpath),
+                                                    fWritable, fAutoMount));
             if (SUCCEEDED(rc))
                 CHECK_ERROR(machine, SaveSettings());
Index: /trunk/src/VBox/Frontends/VirtualBox/src/settings/vm/VBoxVMSettingsSF.cpp
===================================================================
--- /trunk/src/VBox/Frontends/VirtualBox/src/settings/vm/VBoxVMSettingsSF.cpp	(revision 31001)
+++ /trunk/src/VBox/Frontends/VirtualBox/src/settings/vm/VBoxVMSettingsSF.cpp	(revision 31002)
@@ -7,5 +7,5 @@
 
 /*
- * Copyright (C) 2008-2009 Oracle Corporation
+ * Copyright (C) 2008-2010 Oracle Corporation
  *
  * This file is part of VirtualBox Open Source Edition (OSE), as
@@ -345,4 +345,5 @@
     mTrFull = tr ("Full");
     mTrReadOnly = tr ("Read-only");
+    mTrYes = tr ("Yes"); /** @todo Need to figure out if this string is necessary at all! */
 }
 
@@ -364,4 +365,5 @@
         QStringList fields;
         fields << name /* name */ << path /* path */
+               << (dlg.isAutoMounted() ? mTrYes : "" /* auto mount? */)
                << (dlg.isWriteable() ? mTrFull : mTrReadOnly /* writable? */)
                << "edited" /* mark item as edited */;
@@ -392,5 +394,6 @@
     dlg.setName (item->getText (0));
     dlg.setPermanent ((SFDialogType)item->parent()->text (1).toInt() != ConsoleType);
-    dlg.setWriteable (item->getText (2) == mTrFull);
+    dlg.setAutoMount (item->getText (2) == mTrYes);
+    dlg.setWriteable (item->getText (3) == mTrFull);
     if (dlg.exec() == QDialog::Accepted)
     {
@@ -406,4 +409,5 @@
         QStringList fields;
         fields << name /* name */ << path /* path */
+               << (dlg.isAutoMounted() ? mTrYes : "" /* auto mount? */)
                << (dlg.isWriteable() ? mTrFull : mTrReadOnly /* writable? */)
                << "edited" /* mark item as edited */;
@@ -516,5 +520,6 @@
 }
 
-void VBoxVMSettingsSF::createSharedFolder (const QString &aName, const QString &aPath, bool aWritable, SFDialogType aType)
+void VBoxVMSettingsSF::createSharedFolder (const QString &aName, const QString &aPath,
+                                           bool aWritable, bool aAutoMount, SFDialogType aType)
 {
     switch (aType)
@@ -529,5 +534,5 @@
         {
             Assert (!mMachine.isNull());
-            mMachine.CreateSharedFolder (aName, aPath, aWritable);
+            mMachine.CreateSharedFolder (aName, aPath, aWritable, aAutoMount);
             if (!mMachine.isOk())
                 vboxProblem().cannotCreateSharedFolder (this, mMachine, aName, aPath);
@@ -537,5 +542,5 @@
         {
             Assert (!mConsole.isNull());
-            mConsole.CreateSharedFolder (aName, aPath, aWritable);
+            mConsole.CreateSharedFolder (aName, aPath, aWritable, aAutoMount);
             if (!mConsole.isOk())
                 vboxProblem().cannotCreateSharedFolder (this, mConsole, aName, aPath);
@@ -589,5 +594,6 @@
         QStringList fields;
         fields << sf.GetName() /* name */ << sf.GetHostPath() /* path */
-               << (sf.GetWritable() ? mTrFull : mTrReadOnly /* writable? */)
+               << (sf.GetAutoMount() ? mTrYes : "") /* auto mount? */
+               << (sf.GetWritable() ? mTrFull : mTrReadOnly) /* writable? */
                << "not edited" /* initially not edited */;
         new SFTreeViewItem (aRoot, fields, SFTreeViewItem::EllipsisFile);
@@ -604,4 +610,6 @@
     SFDialogType type = (SFDialogType) aRoot->text (1).toInt();
 
+    /** @todo Use enums rather than numbers for the text fields (like  item->getText (4)). */
+
     /* Delete all changed folders from vm */
     for (int idx = 0; idx < aVec.size(); ++ idx)
@@ -614,5 +622,5 @@
         {
             SFTreeViewItem *item = aRoot->child (i);
-            if (item->getText (0) == sf.GetName() && item->getText (3) == "not edited")
+            if (item->getText (0) == sf.GetName() && item->getText (4) == "not edited")
                 break;
         }
@@ -627,6 +635,8 @@
         SFTreeViewItem *item = aRoot->child (i);
 
-        if (!item->getText (0).isNull() && !item->getText (1).isNull() && item->getText (3) == "edited")
-            createSharedFolder (item->getText (0), item->getText (1), item->getText (2) == mTrFull ? true : false, type);
+        if (!item->getText (0).isNull() && !item->getText (1).isNull() && item->getText (4) == "edited")
+            createSharedFolder (item->getText (0), item->getText (1),
+                                item->getText (3) == mTrFull ? true : false, item->getText (2) == mTrYes ? true : false,
+                                type);
     }
 }
Index: /trunk/src/VBox/Frontends/VirtualBox/src/settings/vm/VBoxVMSettingsSF.h
===================================================================
--- /trunk/src/VBox/Frontends/VirtualBox/src/settings/vm/VBoxVMSettingsSF.h	(revision 31001)
+++ /trunk/src/VBox/Frontends/VirtualBox/src/settings/vm/VBoxVMSettingsSF.h	(revision 31002)
@@ -81,5 +81,5 @@
     void showEvent (QShowEvent *aEvent);
 
-    void createSharedFolder (const QString &aName, const QString &aPath, bool aWritable, SFDialogType aType);
+    void createSharedFolder (const QString &aName, const QString &aPath, bool aWritable, bool aAutoMount, SFDialogType aType);
     void removeSharedFolder (const QString &aName, const QString &aPath, SFDialogType aType);
 
@@ -100,4 +100,5 @@
     QString   mTrFull;
     QString   mTrReadOnly;
+    QString   mTrYes;
 };
 
Index: /trunk/src/VBox/Frontends/VirtualBox/src/settings/vm/VBoxVMSettingsSF.ui
===================================================================
--- /trunk/src/VBox/Frontends/VirtualBox/src/settings/vm/VBoxVMSettingsSF.ui	(revision 31001)
+++ /trunk/src/VBox/Frontends/VirtualBox/src/settings/vm/VBoxVMSettingsSF.ui	(revision 31002)
@@ -77,4 +77,9 @@
        <column>
         <property name="text">
+         <string>Auto-Mount</string>
+        </property>
+       </column>
+       <column>
+        <property name="text">
          <string>Access</string>
         </property>
Index: /trunk/src/VBox/Frontends/VirtualBox/src/settings/vm/VBoxVMSettingsSFDetails.cpp
===================================================================
--- /trunk/src/VBox/Frontends/VirtualBox/src/settings/vm/VBoxVMSettingsSFDetails.cpp	(revision 31001)
+++ /trunk/src/VBox/Frontends/VirtualBox/src/settings/vm/VBoxVMSettingsSFDetails.cpp	(revision 31002)
@@ -7,5 +7,5 @@
 
 /*
- * Copyright (C) 2008 Oracle Corporation
+ * Copyright (C) 2010 Oracle Corporation
  *
  * This file is part of VirtualBox Open Source Edition (OSE), as
@@ -100,4 +100,14 @@
 }
 
+void VBoxVMSettingsSFDetails::setAutoMount (bool aAutoMount)
+{
+    mCbAutoMount->setChecked (aAutoMount);
+}
+
+bool VBoxVMSettingsSFDetails::isAutoMounted() const
+{
+    return mCbAutoMount->isChecked();
+}
+
 void VBoxVMSettingsSFDetails::setPermanent (bool aPermanent)
 {
Index: /trunk/src/VBox/Frontends/VirtualBox/src/settings/vm/VBoxVMSettingsSFDetails.h
===================================================================
--- /trunk/src/VBox/Frontends/VirtualBox/src/settings/vm/VBoxVMSettingsSFDetails.h	(revision 31001)
+++ /trunk/src/VBox/Frontends/VirtualBox/src/settings/vm/VBoxVMSettingsSFDetails.h	(revision 31002)
@@ -52,4 +52,7 @@
     bool isWriteable() const;
 
+    void setAutoMount (bool aAutoMount);
+    bool isAutoMounted() const;
+
     void setPermanent (bool aPermanent);
     bool isPermanent() const;
Index: /trunk/src/VBox/Frontends/VirtualBox/src/settings/vm/VBoxVMSettingsSFDetails.ui
===================================================================
--- /trunk/src/VBox/Frontends/VirtualBox/src/settings/vm/VBoxVMSettingsSFDetails.ui	(revision 31001)
+++ /trunk/src/VBox/Frontends/VirtualBox/src/settings/vm/VBoxVMSettingsSFDetails.ui	(revision 31002)
@@ -68,4 +68,14 @@
    </item>
    <item row="3" column="1" >
+    <widget class="QCheckBox" name="mCbAutoMount" >
+     <property name="toolTip" >
+      <string>When checked, the guest OS will try to automatically mount the shared folder on startup.</string>
+     </property>
+     <property name="text" >
+      <string>&amp;Auto-mount</string>
+     </property>
+    </widget>
+   </item>
+   <item row="4" column="1" >
     <widget class="QCheckBox" name="mCbPermanent" >
      <property name="text" >
Index: /trunk/src/VBox/HostServices/SharedFolders/mappings.cpp
===================================================================
--- /trunk/src/VBox/HostServices/SharedFolders/mappings.cpp	(revision 31001)
+++ /trunk/src/VBox/HostServices/SharedFolders/mappings.cpp	(revision 31002)
@@ -171,9 +171,8 @@
 
 /*
- *
  * We are always executed from one specific HGCM thread. So thread safe.
- *
  */
-int vbsfMappingsAdd (PSHFLSTRING pFolderName, PSHFLSTRING pMapName, uint32_t fWritable)
+int vbsfMappingsAdd (PSHFLSTRING pFolderName, PSHFLSTRING pMapName,
+                     uint32_t    fWritable,   uint32_t    fAutoMount)
 {
     unsigned i;
@@ -218,7 +217,8 @@
             memcpy(FolderMapping[i].pMapName->String.ucs2, pMapName->String.ucs2, pMapName->u16Size);
 
-            FolderMapping[i].fValid    = true;
-            FolderMapping[i].cMappings = 0;
-            FolderMapping[i].fWritable = !!fWritable;
+            FolderMapping[i].fValid     = true;
+            FolderMapping[i].cMappings  = 0;
+            FolderMapping[i].fWritable  = !!fWritable;
+            FolderMapping[i].fAutoMount = !!fAutoMount;
 
             /* Check if the host file system is case sensitive */
@@ -343,6 +343,13 @@
     {
         MAPPING *pFolderMapping = vbsfMappingGetByRoot(i);
-        if (pFolderMapping != NULL && pFolderMapping->fValid == true)
-        {
+        if (   pFolderMapping != NULL
+            && pFolderMapping->fValid == true)
+        {
+            /* Skip mappings which are not marked for auto-mounting if
+             * the SHFL_MF_AUTOMOUNT flag ist set. */
+            if (   (pClient->fu32Flags & SHFL_MF_AUTOMOUNT)
+                && !pFolderMapping->fAutoMount)
+                continue;
+
             pMappings[*pcMappings].u32Status = SHFL_MS_NEW;
             pMappings[*pcMappings].root = i;
@@ -350,7 +357,5 @@
         }
     }
-
     LogFlow(("vbsfMappingsQuery: return rc = %Rrc\n", rc));
-
     return rc;
 }
@@ -371,5 +376,5 @@
     if (BIT_FLAG(pClient->fu32Flags, SHFL_CF_UTF8))
     {
-        /* not implemented */
+        /* Not implemented. */
         AssertFailed();
         return VERR_INVALID_PARAMETER;
@@ -412,4 +417,27 @@
 }
 
+int vbsfMappingsQueryAutoMount (SHFLCLIENTDATA *pClient, SHFLROOT root, bool *fAutoMount)
+{
+    int rc = VINF_SUCCESS;
+
+    LogFlow(("vbsfMappingsQueryAutoMount: pClient = %p, root = %d\n",
+             pClient, root));
+
+    MAPPING *pFolderMapping = vbsfMappingGetByRoot(root);
+    if (pFolderMapping == NULL)
+    {
+        return VERR_INVALID_PARAMETER;
+    }
+
+    if (pFolderMapping->fValid == true)
+        *fAutoMount = pFolderMapping->fAutoMount;
+    else
+        rc = VERR_FILE_NOT_FOUND;
+
+    LogFlow(("vbsfMappingsQueryAutoMount:Writable return rc = %Rrc\n", rc));
+
+    return rc;
+}
+
 int vbsfMapFolder (SHFLCLIENTDATA *pClient, PSHFLSTRING pszMapName, RTUTF16 delimiter, bool fCaseSensitive, SHFLROOT *pRoot)
 {
Index: /trunk/src/VBox/HostServices/SharedFolders/mappings.h
===================================================================
--- /trunk/src/VBox/HostServices/SharedFolders/mappings.h	(revision 31001)
+++ /trunk/src/VBox/HostServices/SharedFolders/mappings.h	(revision 31002)
@@ -4,5 +4,5 @@
 
 /*
- * Copyright (C) 2006-2007 Oracle Corporation
+ * Copyright (C) 2006-2010 Oracle Corporation
  *
  * This file is part of VirtualBox Open Source Edition (OSE), as
@@ -30,4 +30,5 @@
     bool        fGuestCaseSensitive;
     bool        fWritable;
+    bool        fAutoMount;
 } MAPPING, *PMAPPING;
 
@@ -36,17 +37,17 @@
 bool vbsfMappingQuery(uint32_t iMapping, PMAPPING *pMapping);
 
-int vbsfMappingsAdd (PSHFLSTRING pFolderName, PSHFLSTRING pMapName, uint32_t fWritable);
-int vbsfMappingsRemove (PSHFLSTRING pMapName);
+int vbsfMappingsAdd(PSHFLSTRING pFolderName, PSHFLSTRING pMapName, uint32_t fWritable, uint32_t fAutoMount);
+int vbsfMappingsRemove(PSHFLSTRING pMapName);
 
-int vbsfMappingsQuery (SHFLCLIENTDATA *pClient, SHFLMAPPING *pMappings, uint32_t *pcMappings);
-int vbsfMappingsQueryName (SHFLCLIENTDATA *pClient, SHFLROOT root, SHFLSTRING *pString);
-int vbsfMappingsQueryWritable (SHFLCLIENTDATA *pClient, SHFLROOT root, bool *fWritable);
+int vbsfMappingsQuery(SHFLCLIENTDATA *pClient, SHFLMAPPING *pMappings, uint32_t *pcMappings);
+int vbsfMappingsQueryName(SHFLCLIENTDATA *pClient, SHFLROOT root, SHFLSTRING *pString);
+int vbsfMappingsQueryWritable(SHFLCLIENTDATA *pClient, SHFLROOT root, bool *fWritable);
 
-int vbsfMapFolder (SHFLCLIENTDATA *pClient, PSHFLSTRING pszMapName, RTUTF16 delimiter, bool fCaseSensitive, SHFLROOT *pRoot);
-int vbsfUnmapFolder (SHFLCLIENTDATA *pClient, SHFLROOT root);
+int vbsfMapFolder(SHFLCLIENTDATA *pClient, PSHFLSTRING pszMapName, RTUTF16 delimiter, bool fCaseSensitive, SHFLROOT *pRoot);
+int vbsfUnmapFolder(SHFLCLIENTDATA *pClient, SHFLROOT root);
 
-PCRTUTF16     vbsfMappingsQueryHostRoot (SHFLROOT root, uint32_t *pcbRoot);
-bool          vbsfIsGuestMappingCaseSensitive (SHFLROOT root);
-bool          vbsfIsHostMappingCaseSensitive (SHFLROOT root);
+PCRTUTF16 vbsfMappingsQueryHostRoot (SHFLROOT root, uint32_t *pcbRoot);
+bool vbsfIsGuestMappingCaseSensitive (SHFLROOT root);
+bool vbsfIsHostMappingCaseSensitive (SHFLROOT root);
 
 int vbsfMappingLoaded (const MAPPING *pLoadedMapping, SHFLROOT root);
Index: /trunk/src/VBox/HostServices/SharedFolders/service.cpp
===================================================================
--- /trunk/src/VBox/HostServices/SharedFolders/service.cpp	(revision 31001)
+++ /trunk/src/VBox/HostServices/SharedFolders/service.cpp	(revision 31002)
@@ -310,6 +310,6 @@
 
                 /* Verify parameters values. */
-                if (   (fu32Flags & ~SHFL_MF_UTF8) != 0
-                    || cbMappings / sizeof (SHFLMAPPING) < cMappings
+                if (   (fu32Flags & ~SHFL_MF_MASK) != 0
+                    || cbMappings / sizeof (SHFLMAPPING) != cMappings
                    )
                 {
@@ -320,13 +320,12 @@
                     /* Execute the function. */
                     if (fu32Flags & SHFL_MF_UTF8)
-                    {
                         pClient->fu32Flags |= SHFL_CF_UTF8;
-                    }
-
-                    rc = vbsfMappingsQuery (pClient, pMappings, &cMappings);
-
-                    if (RT_SUCCESS(rc))
-                    {
-                        /* Update parameters.*/
+                    if (fu32Flags & SHFL_MF_AUTOMOUNT)
+                        pClient->fu32Flags |= SHFL_MF_AUTOMOUNT;
+
+                    rc = vbsfMappingsQuery(pClient, pMappings, &cMappings);
+                    if (RT_SUCCESS(rc))
+                    {
+                        /* Update parameters. */
                         paParms[1].u.uint32 = cMappings;
                     }
@@ -346,6 +345,6 @@
                 rc = VERR_INVALID_PARAMETER;
             }
-            else if (   paParms[0].type != VBOX_HGCM_SVC_PARM_32BIT /* root */
-                     || paParms[1].type != VBOX_HGCM_SVC_PARM_PTR     /* name */
+            else if (   paParms[0].type != VBOX_HGCM_SVC_PARM_32BIT /* Root. */
+                     || paParms[1].type != VBOX_HGCM_SVC_PARM_PTR   /* Name. */
                     )
             {
@@ -366,10 +365,10 @@
                 {
                     /* Execute the function. */
-                    rc = vbsfMappingsQueryName (pClient, root, pString);
+                    rc = vbsfMappingsQueryName(pClient, root, pString);
 
                     if (RT_SUCCESS(rc))
                     {
                         /* Update parameters.*/
-                        ; /* none */
+                        ; /* None. */
                     }
                 }
@@ -1162,5 +1161,7 @@
 
         /* Verify parameter count and types. */
-        if (cParms != SHFL_CPARMS_ADD_MAPPING)
+        if (   (cParms != SHFL_CPARMS_ADD_MAPPING)
+            && (cParms != SHFL_CPARMS_ADD_MAPPING2) /* With auto-mount flag. */
+           )
         {
             rc = VERR_INVALID_PARAMETER;
@@ -1169,5 +1170,7 @@
                  || paParms[1].type != VBOX_HGCM_SVC_PARM_PTR     /* guest map name */
                  || paParms[2].type != VBOX_HGCM_SVC_PARM_32BIT   /* fWritable */
-                )
+                 /* With auto-mount flag? */
+                 || (   cParms == SHFL_CPARMS_ADD_MAPPING2
+                     && paParms[3].type != VBOX_HGCM_SVC_PARM_32BIT))
         {
             rc = VERR_INVALID_PARAMETER;
@@ -1179,4 +1182,9 @@
             SHFLSTRING *pMapName    = (SHFLSTRING *)paParms[1].u.pointer.addr;
             uint32_t fWritable      = paParms[2].u.uint32;
+            uint32_t fAutoMount     = 0; /* Disabled by default. */
+
+            /* Handle auto-mount flag if present. */
+            if (cParms == SHFL_CPARMS_ADD_MAPPING2)
+                fAutoMount = paParms[3].u.uint32;
 
             /* Verify parameters values. */
@@ -1190,6 +1198,5 @@
             {
                 /* Execute the function. */
-                rc = vbsfMappingsAdd (pFolderName, pMapName, fWritable);
-
+                rc = vbsfMappingsAdd(pFolderName, pMapName, fWritable, fAutoMount);
                 if (RT_SUCCESS(rc))
                 {
Index: /trunk/src/VBox/Main/ConsoleImpl.cpp
===================================================================
--- /trunk/src/VBox/Main/ConsoleImpl.cpp	(revision 31001)
+++ /trunk/src/VBox/Main/ConsoleImpl.cpp	(revision 31002)
@@ -1174,4 +1174,7 @@
         vrc = SSMR3PutBool(pSSM, !!folder->isWritable());
         AssertRC(vrc);
+
+        vrc = SSMR3PutBool(pSSM, !!folder->isAutoMounted());
+        AssertRC(vrc);
     }
 
@@ -1236,4 +1239,5 @@
         Bstr hostPath;
         bool writable = true;
+        bool autoMount = false;
 
         uint32_t szBuf = 0;
@@ -1259,7 +1263,10 @@
             SSMR3GetBool(pSSM, &writable);
 
+        if (u32Version > 0x00010000) // ???
+            SSMR3GetBool(pSSM, &autoMount);
+
         ComObjPtr<SharedFolder> sharedFolder;
         sharedFolder.createObject();
-        HRESULT rc = sharedFolder->init(this, name, hostPath, writable);
+        HRESULT rc = sharedFolder->init(this, name, hostPath, writable, autoMount);
         AssertComRCReturn(rc, VERR_INTERNAL_ERROR);
 
@@ -2660,5 +2667,5 @@
 
 STDMETHODIMP
-Console::CreateSharedFolder(IN_BSTR aName, IN_BSTR aHostPath, BOOL aWritable)
+Console::CreateSharedFolder(IN_BSTR aName, IN_BSTR aHostPath, BOOL aWritable, BOOL aAutoMount)
 {
     CheckComArgStrNotEmptyOrNull(aName);
@@ -2692,5 +2699,5 @@
 
     sharedFolder.createObject();
-    rc = sharedFolder->init(this, aName, aHostPath, aWritable);
+    rc = sharedFolder->init(this, aName, aHostPath, aWritable, aAutoMount);
     if (FAILED(rc)) return rc;
 
@@ -2712,5 +2719,5 @@
 
         /* second, create the given folder */
-        rc = createSharedFolder(aName, SharedFolderData(aHostPath, aWritable));
+        rc = createSharedFolder(aName, SharedFolderData(aHostPath, aWritable, aAutoMount));
         if (FAILED(rc)) return rc;
     }
@@ -5123,5 +5130,7 @@
         for (SharedFolderMap::const_iterator it = mSharedFolders.begin();
              it != mSharedFolders.end(); ++ it)
-            sharedFolders[it->first] = SharedFolderData(it->second->getHostPath(), it->second->isWritable());
+            sharedFolders[it->first] = SharedFolderData(it->second->getHostPath(),
+                                                        it->second->isWritable(),
+                                                        it->second->isAutoMounted());
     }
 
@@ -5751,4 +5760,5 @@
             Bstr hostPath;
             BOOL writable;
+            BOOL autoMount;
 
             rc = folder->COMGETTER(Name)(name.asOutParam());
@@ -5757,6 +5767,9 @@
             if (FAILED(rc)) break;
             rc = folder->COMGETTER(Writable)(&writable);
-
-            mMachineSharedFolders.insert(std::make_pair(name, SharedFolderData(hostPath, writable)));
+            if (FAILED(rc)) break;
+            rc = folder->COMGETTER(AutoMount)(&autoMount);
+            if (FAILED(rc)) break;
+
+            mMachineSharedFolders.insert(std::make_pair(name, SharedFolderData(hostPath, writable, autoMount)));
 
             /* send changes to HGCM if the VM is running */
@@ -5780,5 +5793,5 @@
                             rc = removeSharedFolder(name);
                         /* create the new machine folder */
-                        rc = createSharedFolder(name, SharedFolderData(hostPath, writable));
+                        rc = createSharedFolder(name, SharedFolderData(hostPath, writable, autoMount));
                     }
                 }
@@ -5868,5 +5881,5 @@
     AssertReturn(mVMMDev->isShFlActive(), E_FAIL);
 
-    VBOXHGCMSVCPARM parms[SHFL_CPARMS_ADD_MAPPING];
+    VBOXHGCMSVCPARM parms[SHFL_CPARMS_ADD_MAPPING2];
     SHFLSTRING *pFolderName, *pMapName;
     size_t cbString;
@@ -5908,7 +5921,16 @@
     parms[2].u.uint32 = aData.mWritable;
 
+    /*
+     * Auto-mount flag; is indicated by using the SHFL_CPARMS_ADD_MAPPING2
+     * define below.  This shows the host service that we have supplied
+     * an additional parameter (auto-mount) and keeps the actual command
+     * backwards compatible.
+     */
+    parms[3].type = VBOX_HGCM_SVC_PARM_32BIT;
+    parms[3].u.uint32 = aData.mAutoMount;
+
     int vrc = mVMMDev->hgcmHostCall("VBoxSharedFolders",
                                     SHFL_FN_ADD_MAPPING,
-                                    SHFL_CPARMS_ADD_MAPPING, &parms[0]);
+                                    SHFL_CPARMS_ADD_MAPPING2, &parms[0]);
     RTMemFree(pFolderName);
     RTMemFree(pMapName);
Index: /trunk/src/VBox/Main/MachineImpl.cpp
===================================================================
--- /trunk/src/VBox/Main/MachineImpl.cpp	(revision 31001)
+++ /trunk/src/VBox/Main/MachineImpl.cpp	(revision 31002)
@@ -3938,5 +3938,5 @@
 }
 
-STDMETHODIMP Machine::CreateSharedFolder(IN_BSTR aName, IN_BSTR aHostPath, BOOL aWritable)
+STDMETHODIMP Machine::CreateSharedFolder(IN_BSTR aName, IN_BSTR aHostPath, BOOL aWritable, BOOL aAutoMount)
 {
     CheckComArgStrNotEmptyOrNull(aName);
@@ -3959,5 +3959,5 @@
 
     sharedFolder.createObject();
-    rc = sharedFolder->init(getMachine(), aName, aHostPath, aWritable);
+    rc = sharedFolder->init(getMachine(), aName, aHostPath, aWritable, aAutoMount);
     if (FAILED(rc)) return rc;
 
@@ -6895,5 +6895,5 @@
         {
             const settings::SharedFolder &sf = *it;
-            rc = CreateSharedFolder(Bstr(sf.strName), Bstr(sf.strHostPath), sf.fWritable);
+            rc = CreateSharedFolder(Bstr(sf.strName), Bstr(sf.strHostPath), sf.fWritable, sf.fAutoMount);
             if (FAILED(rc)) return rc;
         }
@@ -7959,4 +7959,5 @@
             sf.strHostPath = pFolder->getHostPath();
             sf.fWritable = !!pFolder->isWritable();
+            sf.fAutoMount = !!pFolder->isAutoMounted();
 
             data.llSharedFolders.push_back(sf);
Index: /trunk/src/VBox/Main/SharedFolderImpl.cpp
===================================================================
--- /trunk/src/VBox/Main/SharedFolderImpl.cpp	(revision 31001)
+++ /trunk/src/VBox/Main/SharedFolderImpl.cpp	(revision 31002)
@@ -5,5 +5,5 @@
 
 /*
- * Copyright (C) 2006-2007 Oracle Corporation
+ * Copyright (C) 2006-2010 Oracle Corporation
  *
  * This file is part of VirtualBox Open Source Edition (OSE), as
@@ -63,9 +63,10 @@
  *  @param aHostPath    full path to the shared folder on the host
  *  @param aWritable    writable if true, readonly otherwise
+ *  @param aAutoMount   if auto mounted by guest true, false otherwise
  *
  *  @return          COM result indicator
  */
 HRESULT SharedFolder::init (Machine *aMachine,
-                            CBSTR aName, CBSTR aHostPath, BOOL aWritable)
+                            CBSTR aName, CBSTR aHostPath, BOOL aWritable, BOOL aAutoMount)
 {
     /* Enclose the state transition NotReady->InInit->Ready */
@@ -75,5 +76,5 @@
     unconst(mMachine) = aMachine;
 
-    HRESULT rc = protectedInit(aMachine, aName, aHostPath, aWritable);
+    HRESULT rc = protectedInit(aMachine, aName, aHostPath, aWritable, aAutoMount);
 
     /* Confirm a successful initialization when it's the case */
@@ -105,5 +106,5 @@
 
     HRESULT rc = protectedInit (aMachine, aThat->m.name,
-                                aThat->m.hostPath, aThat->m.writable);
+                                aThat->m.hostPath, aThat->m.writable, aThat->m.autoMount);
 
     /* Confirm a successful initialization when it's the case */
@@ -125,5 +126,5 @@
  */
 HRESULT SharedFolder::init(Console *aConsole,
-                            CBSTR aName, CBSTR aHostPath, BOOL aWritable)
+                            CBSTR aName, CBSTR aHostPath, BOOL aWritable, BOOL aAutoMount)
 {
     /* Enclose the state transition NotReady->InInit->Ready */
@@ -133,5 +134,5 @@
     unconst(mConsole) = aConsole;
 
-    HRESULT rc = protectedInit(aConsole, aName, aHostPath, aWritable);
+    HRESULT rc = protectedInit(aConsole, aName, aHostPath, aWritable, aAutoMount);
 
     /* Confirm a successful initialization when it's the case */
@@ -153,5 +154,5 @@
  */
 HRESULT SharedFolder::init (VirtualBox *aVirtualBox,
-                            CBSTR aName, CBSTR aHostPath, BOOL aWritable)
+                            CBSTR aName, CBSTR aHostPath, BOOL aWritable, BOOL aAutoMount)
 {
     /* Enclose the state transition NotReady->InInit->Ready */
@@ -161,5 +162,5 @@
     unconst(mVirtualBox) = aVirtualBox;
 
-    HRESULT rc = protectedInit(aVirtualBox, aName, aHostPath, aWritable);
+    HRESULT rc = protectedInit(aVirtualBox, aName, aHostPath, aWritable, aAutoMount);
 
     /* Confirm a successful initialization when it's the case */
@@ -177,10 +178,11 @@
  */
 HRESULT SharedFolder::protectedInit(VirtualBoxBase *aParent,
-                                    CBSTR aName,
-                                    CBSTR aHostPath,
-                                    BOOL aWritable)
-{
-    LogFlowThisFunc(("aName={%ls}, aHostPath={%ls}, aWritable={%d}\n",
-                      aName, aHostPath, aWritable));
+                                    CBSTR           aName,
+                                    CBSTR           aHostPath,
+                                    BOOL            aWritable,
+                                    BOOL            aAutoMount)
+{
+    LogFlowThisFunc(("aName={%ls}, aHostPath={%ls}, aWritable={%d}, aAutoMount={%d}\n",
+                      aName, aHostPath, aWritable, aAutoMount));
 
     ComAssertRet(aParent && aName && aHostPath, E_INVALIDARG);
@@ -228,4 +230,5 @@
     unconst(m.hostPath) = hostPath;
     m.writable = aWritable;
+    m.autoMount = aAutoMount;
 
     return S_OK;
@@ -318,4 +321,9 @@
     CheckComArgOutPointerValid(aWritable);
 
+    AutoCaller autoCaller(this);
+    if (FAILED(autoCaller.rc())) return autoCaller.rc();
+
+    AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
+
     *aWritable = m.writable;
 
@@ -323,4 +331,18 @@
 }
 
+STDMETHODIMP SharedFolder::COMGETTER(AutoMount) (BOOL *aAutoMount)
+{
+    CheckComArgOutPointerValid(aAutoMount);
+
+    AutoCaller autoCaller(this);
+    if (FAILED(autoCaller.rc())) return autoCaller.rc();
+
+    AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
+
+    *aAutoMount = m.autoMount;
+
+    return S_OK;
+}
+
 STDMETHODIMP SharedFolder::COMGETTER(LastAccessError) (BSTR *aLastAccessError)
 {
Index: /trunk/src/VBox/Main/VirtualBoxImpl.cpp
===================================================================
--- /trunk/src/VBox/Main/VirtualBoxImpl.cpp	(revision 31001)
+++ /trunk/src/VBox/Main/VirtualBoxImpl.cpp	(revision 31002)
@@ -1719,5 +1719,6 @@
 }
 
-STDMETHODIMP VirtualBox::CreateSharedFolder(IN_BSTR aName, IN_BSTR aHostPath, BOOL /* aWritable */)
+STDMETHODIMP VirtualBox::CreateSharedFolder(IN_BSTR aName,        IN_BSTR aHostPath,
+                                            BOOL /* aWritable */, BOOL /* aAutoMount */)
 {
     CheckComArgStrNotEmptyOrNull(aName);
Index: /trunk/src/VBox/Main/idl/VirtualBox.xidl
===================================================================
--- /trunk/src/VBox/Main/idl/VirtualBox.xidl	(revision 31001)
+++ /trunk/src/VBox/Main/idl/VirtualBox.xidl	(revision 31002)
@@ -1324,5 +1324,5 @@
   <interface
     name="IVirtualBox" extends="$unknown"
-    uuid="2275c97d-31b0-41c7-a138-c77d3c28406e"
+    uuid="ec6cc7e7-06a2-4c5d-8993-1e3619c53817"
     wsmap="managed"
   >
@@ -2173,4 +2173,8 @@
       <param name="writable" type="boolean" dir="in">
         <desc>Whether the share is writable or readonly</desc>
+      </param>
+      <param name="automount" type="boolean" dir="in">
+        <desc>Whether the share gets automatically mounted by the guest
+          or not.</desc>
       </param>
     </method>
@@ -3876,5 +3880,5 @@
   <interface
      name="IMachine" extends="$unknown"
-     uuid="276e0f43-889b-4b87-b05f-35f1db814700"
+     uuid="de8f0b23-f285-4779-acf4-08eddda7ec75"
      wsmap="managed"
      >
@@ -5382,5 +5386,9 @@
       </param>
       <param name="writable" type="boolean" dir="in">
-        <desc>Whether the share is writable or readonly</desc>
+        <desc>Whether the share is writable or readonly.</desc>
+      </param>
+      <param name="automount" type="boolean" dir="in">
+        <desc>Whether the share gets automatically mounted by the guest
+          or not.</desc>
       </param>
     </method>
@@ -5957,5 +5965,5 @@
   <interface
      name="IConsole" extends="$unknown"
-     uuid="6375231a-c17c-464b-92cb-ae9e128d71c3"
+     uuid="9e467cff-98fc-4f5b-83aa-048d903694c9"
      wsmap="managed"
      >
@@ -6470,4 +6478,8 @@
       <param name="writable" type="boolean" dir="in">
         <desc>Whether the share is writable or readonly</desc>
+      </param>
+      <param name="automount" type="boolean" dir="in">
+        <desc>Whether the share gets automatically mounted by the guest
+          or not.</desc>
       </param>
     </method>
@@ -12259,5 +12271,5 @@
   <interface
      name="ISharedFolder" extends="$unknown"
-     uuid="64637bb2-9e17-471c-b8f3-f8968dd9884e"
+     uuid="8388da11-b559-4574-a5b7-2bd7acd5cef8"
      wsmap="struct"
      >
@@ -12334,4 +12346,10 @@
         Whether the folder defined by the host path is writable or
         not.
+      </desc>
+    </attribute>
+
+    <attribute name="autoMount" type="boolean" readonly="yes">
+      <desc>
+        Whether the folder gets automatically mounted by the guest or not.
       </desc>
     </attribute>
Index: /trunk/src/VBox/Main/include/ConsoleImpl.h
===================================================================
--- /trunk/src/VBox/Main/include/ConsoleImpl.h	(revision 31001)
+++ /trunk/src/VBox/Main/include/ConsoleImpl.h	(revision 31002)
@@ -145,5 +145,5 @@
     STDMETHOD(FindUSBDeviceByAddress)(IN_BSTR aAddress, IUSBDevice **aDevice);
     STDMETHOD(FindUSBDeviceById)(IN_BSTR aId, IUSBDevice **aDevice);
-    STDMETHOD(CreateSharedFolder)(IN_BSTR aName, IN_BSTR aHostPath, BOOL aWritable);
+    STDMETHOD(CreateSharedFolder)(IN_BSTR aName, IN_BSTR aHostPath, BOOL aWritable, BOOL aAutoMount);
     STDMETHOD(RemoveSharedFolder)(IN_BSTR aName);
     STDMETHOD(TakeSnapshot)(IN_BSTR aName, IN_BSTR aDescription,
@@ -389,12 +389,15 @@
     public:
         SharedFolderData() {}
-        SharedFolderData(Bstr aHostPath, BOOL aWritable)
+        SharedFolderData(Bstr aHostPath, BOOL aWritable, BOOL aAutoMount)
            : mHostPath(aHostPath)
-           , mWritable(aWritable) {}
+           , mWritable(aWritable)
+           , mAutoMount(aAutoMount) {}
         SharedFolderData(const SharedFolderData& aThat)
            : mHostPath(aThat.mHostPath)
-           , mWritable(aThat.mWritable) {}
+           , mWritable(aThat.mWritable)
+           , mAutoMount(aThat.mAutoMount) {}
         Bstr mHostPath;
         BOOL mWritable;
+        BOOL mAutoMount;
     };
     typedef std::map <Bstr, ComObjPtr<SharedFolder> > SharedFolderMap;
Index: /trunk/src/VBox/Main/include/MachineImpl.h
===================================================================
--- /trunk/src/VBox/Main/include/MachineImpl.h	(revision 31001)
+++ /trunk/src/VBox/Main/include/MachineImpl.h	(revision 31002)
@@ -487,5 +487,5 @@
     STDMETHOD(FindSnapshot)(IN_BSTR aName, ISnapshot **aSnapshot);
     STDMETHOD(SetCurrentSnapshot)(IN_BSTR aId);
-    STDMETHOD(CreateSharedFolder)(IN_BSTR aName, IN_BSTR aHostPath, BOOL aWritable);
+    STDMETHOD(CreateSharedFolder)(IN_BSTR aName, IN_BSTR aHostPath, BOOL aWritable, BOOL aAutoMount);
     STDMETHOD(RemoveSharedFolder)(IN_BSTR aName);
     STDMETHOD(CanShowConsoleWindow)(BOOL *aCanShow);
Index: /trunk/src/VBox/Main/include/SharedFolderImpl.h
===================================================================
--- /trunk/src/VBox/Main/include/SharedFolderImpl.h	(revision 31001)
+++ /trunk/src/VBox/Main/include/SharedFolderImpl.h	(revision 31002)
@@ -5,5 +5,5 @@
 
 /*
- * Copyright (C) 2006-2009 Oracle Corporation
+ * Copyright (C) 2006-2010 Oracle Corporation
  *
  * This file is part of VirtualBox Open Source Edition (OSE), as
@@ -37,4 +37,5 @@
         const Bstr hostPath;
         BOOL       writable;
+        BOOL       autoMount;
         Bstr       lastAccessError;
     };
@@ -58,8 +59,8 @@
 
     // public initializer/uninitializer for internal purposes only
-    HRESULT init(Machine *aMachine, CBSTR aName, CBSTR aHostPath, BOOL aWritable);
+    HRESULT init(Machine *aMachine, CBSTR aName, CBSTR aHostPath, BOOL aWritable, BOOL aAutoMount);
     HRESULT initCopy(Machine *aMachine, SharedFolder *aThat);
-    HRESULT init(Console *aConsole, CBSTR aName, CBSTR aHostPath, BOOL aWritable);
-    HRESULT init(VirtualBox *aVirtualBox, CBSTR aName, CBSTR aHostPath, BOOL aWritable);
+    HRESULT init(Console *aConsole, CBSTR aName, CBSTR aHostPath, BOOL aWritable, BOOL aAutoMount);
+    HRESULT init(VirtualBox *aVirtualBox, CBSTR aName, CBSTR aHostPath, BOOL aWritable, BOOL aAutoMount);
     void uninit();
 
@@ -69,4 +70,5 @@
     STDMETHOD(COMGETTER(Accessible)) (BOOL *aAccessible);
     STDMETHOD(COMGETTER(Writable)) (BOOL *aWritable);
+    STDMETHOD(COMGETTER(AutoMount)) (BOOL *aAutoMount);
     STDMETHOD(COMGETTER(LastAccessError)) (BSTR *aLastAccessError);
 
@@ -80,10 +82,11 @@
     const Bstr& getHostPath() const { return m.hostPath; }
     BOOL isWritable() const { return m.writable; }
+    BOOL isAutoMounted() const { return m.autoMount; }
 
 protected:
 
     HRESULT protectedInit(VirtualBoxBase *aParent,
-                          CBSTR aName, CBSTR aHostPath, BOOL aWritable);
-
+                          CBSTR aName, CBSTR aHostPath,
+                          BOOL aWritable, BOOL aAutoMount);
 private:
 
Index: /trunk/src/VBox/Main/include/VirtualBoxImpl.h
===================================================================
--- /trunk/src/VBox/Main/include/VirtualBoxImpl.h	(revision 31001)
+++ /trunk/src/VBox/Main/include/VirtualBoxImpl.h	(revision 31002)
@@ -150,5 +150,5 @@
 
     STDMETHOD(GetGuestOSType) (IN_BSTR aId, IGuestOSType **aType);
-    STDMETHOD(CreateSharedFolder) (IN_BSTR aName, IN_BSTR aHostPath, BOOL aWritable);
+    STDMETHOD(CreateSharedFolder) (IN_BSTR aName, IN_BSTR aHostPath, BOOL aWritable, BOOL aAutoMount);
     STDMETHOD(RemoveSharedFolder) (IN_BSTR aName);
     STDMETHOD(GetExtraDataKeys) (ComSafeArrayOut(BSTR, aKeys));
Index: /trunk/src/VBox/Main/xml/Settings.cpp
===================================================================
--- /trunk/src/VBox/Main/xml/Settings.cpp	(revision 31001)
+++ /trunk/src/VBox/Main/xml/Settings.cpp	(revision 31002)
@@ -1438,4 +1438,5 @@
                   && (strHostPath   == g.strHostPath)
                   && (fWritable     == g.fWritable)
+                  && (fAutoMount    == g.fAutoMount)
                 )
            );
@@ -2497,4 +2498,5 @@
                 pelmFolder->getAttributeValue("hostPath", sf.strHostPath);
                 pelmFolder->getAttributeValue("writable", sf.fWritable);
+                pelmFolder->getAttributeValue("autoMount", sf.fAutoMount);
                 hw.llSharedFolders.push_back(sf);
             }
@@ -3540,4 +3542,5 @@
         pelmThis->setAttribute("hostPath", sf.strHostPath);
         pelmThis->setAttribute("writable", sf.fWritable);
+        pelmThis->setAttribute("autoMount", sf.fAutoMount);
     }
 
