Index: trunk/src/VBox/Additions/darwin/VBoxSF/Makefile.kmk
===================================================================
--- trunk/src/VBox/Additions/darwin/VBoxSF/Makefile.kmk	(revision 75677)
+++ trunk/src/VBox/Additions/darwin/VBoxSF/Makefile.kmk	(revision 75678)
@@ -59,5 +59,5 @@
 
 #
-# mount.vboxvfs - The Shared Folders mouning tool.
+# mount.vboxsf - The Shared Folders mounting tool.
 #
 PROGRAMS += mount.vboxsf
Index: trunk/src/VBox/Additions/darwin/VBoxSF/VBoxSF-VNodeOps.cpp
===================================================================
--- trunk/src/VBox/Additions/darwin/VBoxSF/VBoxSF-VNodeOps.cpp	(revision 75677)
+++ trunk/src/VBox/Additions/darwin/VBoxSF/VBoxSF-VNodeOps.cpp	(revision 75678)
@@ -742,5 +742,5 @@
 	VnParms.vnfs_dvp        = pParent;
 	VnParms.vnfs_fsnode     = pVnData;
-	VnParms.vnfs_vops       = g_papfnVBoxVFSVnodeDirOpsVector;
+	VnParms.vnfs_vops       = g_papfnVBoxSfDwnVnDirOpsVector;
 	VnParms.vnfs_markroot   = pParent == NULL;
 	VnParms.vnfs_marksystem = 0;
@@ -821,5 +821,5 @@
 
 /** ??? */
-int (**g_papfnVBoxVFSVnodeDirOpsVector)(void *);
+int (**g_papfnVBoxSfDwnVnDirOpsVector)(void *);
 
 /**
@@ -828,5 +828,5 @@
 struct vnodeopv_desc g_VBoxSfVnodeOpvDesc =
 {
-    &g_papfnVBoxVFSVnodeDirOpsVector,
+    &g_papfnVBoxSfDwnVnDirOpsVector,
     g_VBoxSfDirOpsDescList
 };
Index: trunk/src/VBox/Additions/darwin/VBoxSF/VBoxSF-VfsOps.cpp
===================================================================
--- trunk/src/VBox/Additions/darwin/VBoxSF/VBoxSF-VfsOps.cpp	(revision 75677)
+++ trunk/src/VBox/Additions/darwin/VBoxSF/VBoxSF-VfsOps.cpp	(revision 75678)
@@ -28,12 +28,4 @@
 #include <iprt/string.h>
 #include <VBox/log.h>
-
-
-/* States of VBoxVFS object used in atomic variables
- * in order to reach sync between several concurrently running threads. */
-#define VBOXVFS_OBJECT_UNINITIALIZED    (0)
-#define VBOXVFS_OBJECT_INITIALIZING     (1)
-#define VBOXVFS_OBJECT_INITIALIZED      (2)
-#define VBOXVFS_OBJECT_INVALID          (3)
 
 
@@ -84,5 +76,5 @@
         pReq->Parms.pInfo.u.Embedded.fFlags     = VBOX_HGCM_F_PARM_DIRECTION_FROM_HOST;
 
-	int vrc = VbglR0HGCMFastCall(g_SfClientDarwin.handle, &pReq->Hdr, sizeof(*pReq));
+        int vrc = VbglR0HGCMFastCall(g_SfClientDarwin.handle, &pReq->Hdr, sizeof(*pReq));
         if (RT_SUCCESS(vrc))
             vrc = pReq->Call.header.result;
Index: trunk/src/VBox/Additions/darwin/VBoxSF/VBoxSF.cpp
===================================================================
--- trunk/src/VBox/Additions/darwin/VBoxSF/VBoxSF.cpp	(revision 75677)
+++ trunk/src/VBox/Additions/darwin/VBoxSF/VBoxSF.cpp	(revision 75678)
@@ -47,5 +47,5 @@
 uint32_t volatile               g_cVBoxSfMounts = 0;
 
-/* VBoxVFS filesystem handle. Needed for FS unregistering. */
+/** VFS table entry for our file system (for vfs_fsremove). */
 static vfstable_t               g_pVBoxSfVfsTableEntry;
 /** For vfs_fsentry. */
@@ -78,5 +78,5 @@
 extern kern_return_t _stop(struct kmod_info *pKModInfo, void *pvData);
 
-KMOD_EXPLICIT_DECL(VBoxVFS, VBOX_VERSION_STRING, _start, _stop)
+KMOD_EXPLICIT_DECL(VBoxSF, VBOX_VERSION_STRING, _start, _stop)
 DECLHIDDEN(kmod_start_func_t *) _realmain      = vboxSfDwnModuleLoad;
 DECLHIDDEN(kmod_stop_func_t *)  _antimain      = vboxSfDwnModuleUnload;
@@ -212,5 +212,5 @@
 
     /*
-     * Are we busy?  If so fail.
+     * Are we busy?  If so fail.  Otherwise try deregister the file system.
      */
     if (g_cVBoxSfMounts > 0)
@@ -220,8 +220,17 @@
     }
 
+    if (g_pVBoxSfVfsTableEntry)
+    {
+        int rc = vfs_fsremove(g_pVBoxSfVfsTableEntry);
+        if (rc != 0)
+        {
+            LogRel(("VBoxSF: vfs_fsremove failed: %d\n", rc));
+            return KERN_NO_ACCESS;
+        }
+    }
+
     /*
      * Disconnect and terminate libraries we're using.
      */
-
     if (g_SfClientDarwin.handle != NULL)
     {
Index: trunk/src/VBox/Additions/darwin/VBoxSF/VBoxSFInternal.h
===================================================================
--- trunk/src/VBox/Additions/darwin/VBoxSF/VBoxSFInternal.h	(revision 75677)
+++ trunk/src/VBox/Additions/darwin/VBoxSF/VBoxSFInternal.h	(revision 75678)
@@ -48,9 +48,4 @@
 
 /*********************************************************************************************************************************
-*   Defined Constants And Macros                                                                                                 *
-*********************************************************************************************************************************/
-
-
-/*********************************************************************************************************************************
 *   Structures and Typedefs                                                                                                      *
 *********************************************************************************************************************************/
@@ -77,5 +72,6 @@
 typedef struct VBOXSFDWNVNDATA
 {
-    SHFLHANDLE      hHandle;                /** VBoxVFS object handle. */
+    /** The handle to the host object.  */
+    SHFLHANDLE      hHandle;
     ///PSHFLSTRING     pPath;                  /** Path within shared folder */
     ///lck_attr_t     *pLockAttr;              /** BSD locking stuff */
@@ -94,5 +90,5 @@
 extern struct vfsops        g_VBoxSfVfsOps;
 extern struct vnodeopv_desc g_VBoxSfVnodeOpvDesc;
-extern int (**g_papfnVBoxVFSVnodeDirOpsVector)(void *);
+extern int (**g_papfnVBoxSfDwnVnDirOpsVector)(void *);
 
 
@@ -105,144 +101,4 @@
 
 
-#if 0 /* old code, rewriting. */
-
-/**
- * Helper function to create XNU VFS vnode object.
- *
- * @param mp        Mount data structure
- * @param type      vnode type (directory, regular file, etc)
- * @param pParent   Parent vnode object (NULL for VBoxVFS root vnode)
- * @param fIsRoot   Flag that indicates if created vnode object is
- *                  VBoxVFS root vnode (TRUE for VBoxVFS root vnode, FALSE
- *                  for all aother vnodes)
- * @param           Path within Shared Folder
- * @param ret       Returned newly created vnode
- *
- * @return 0 on success, error code otherwise
- */
-extern int vboxvfs_create_vnode_internal(struct mount *mp, enum vtype type, vnode_t pParent, int fIsRoot, PSHFLSTRING Path, vnode_t *ret);
-
-/**
- * Convert guest absolute VFS path (starting from VFS root) to a host path
- * within mounted shared folder (returning it as a char *).
- *
- * @param mp            Mount data structure
- * @param pszGuestPath  Guest absolute VFS path (starting from VFS root)
- * @param cbGuestPath   Size of pszGuestPath
- * @param pszHostPath   Returned char * wich contains host path
- * @param cbHostPath    Returned pszHostPath size
- *
- * @return 0 on success, error code otherwise
- */
-extern int vboxvfs_guest_path_to_char_path_internal(mount_t mp, char *pszGuestPath, int cbGuestPath, char **pszHostPath, int *cbHostPath);
-
-/**
- * Convert guest absolute VFS path (starting from VFS root) to a host path
- * within mounted shared folder.
- *
- * @param mp            Mount data structure
- * @param pszGuestPath  Guest absolute VFS path (starting from VFS root)
- * @param cbGuestPath   Size of pszGuestPath
- * @param ppResult      Returned PSHFLSTRING object wich contains host path
- *
- * @return 0 on success, error code otherwise
- */
-extern int vboxvfs_guest_path_to_shflstring_path_internal(mount_t mp, char *pszGuestPath, int cbGuestPath, PSHFLSTRING *ppResult);
-
-/**
- * Wrapper function for vboxvfs_guest_path_to_char_path_internal() which
- * converts guest path to host path using vnode object information.
- *
- * @param vnode     Guest's VFS object
- * @param ppPath    Allocated  char * which contain a path
- * @param pcbPath   Size of ppPath
- *
- * @return 0 on success, error code otherwise.
- */
-extern int vboxvfs_guest_vnode_to_char_path_internal(vnode_t vnode, char **ppHostPath, int *pcbHostPath);
-
-/**
- * Wrapper function for vboxvfs_guest_path_to_shflstring_path_internal() which
- * converts guest path to host path using vnode object information.
- *
- * @param vnode     Guest's VFS object
- * @param ppResult  Allocated  PSHFLSTRING object which contain a path
- *
- * @return 0 on success, error code otherwise.
- */
-extern int vboxvfs_guest_vnode_to_shflstring_path_internal(vnode_t vnode, PSHFLSTRING *ppResult);
-
-/**
- * Free resources allocated by vboxvfs_path_internal() and vboxvfs_guest_vnode_to_shflstring_path_internal().
- *
- * @param ppHandle  Reference to object to be freed.
- */
-extern void vboxvfs_put_path_internal(void **ppHandle);
-
-/**
- * Open existing VBoxVFS object and return its handle.
- *
- * @param pMount            Mount session data.
- * @param pPath             VFS path to the object relative to mount point.
- * @param fFlags            For directory object it should be
- *                          SHFL_CF_DIRECTORY and 0 for any other object.
- * @param pHandle           Returned handle.
- *
- * @return 0 on success, error code otherwise.
- */
-extern int vboxvfs_open_internal(vboxvfs_mount_t *pMount, PSHFLSTRING pPath, uint32_t fFlags, SHFLHANDLE *pHandle);
-
-/**
- * Release VBoxVFS object handle openned by vboxvfs_open_internal().
- *
- * @param pMount            Mount session data.
- * @param pHandle           Handle to close.
- *
- * @return 0 on success, IPRT error code otherwise.
- */
-extern int vboxvfs_close_internal(vboxvfs_mount_t *pMount, SHFLHANDLE pHandle);
-
-/**
- * Get information about host VFS object.
- *
- * @param mp           Mount point data
- * @param pSHFLDPath   Path to VFS object within mounted shared folder
- * @param Info         Returned info
- *
- * @return  0 on success, error code otherwise.
- */
-extern int vboxvfs_get_info_internal(mount_t mp, PSHFLSTRING pSHFLDPath, PSHFLFSOBJINFO Info);
-
-/**
- * Check if VFS object exists on a host side.
- *
- * @param vnode     Guest VFS vnode that corresponds to host VFS object
- *
- * @return 1 if exists, 0 otherwise.
- */
-extern int vboxvfs_exist_internal(vnode_t vnode);
-
-/**
- * Convert host VFS object mode flags into guest ones.
- *
- * @param fHostMode     Host flags
- *
- * @return Guest flags
- */
-extern mode_t vboxvfs_h2g_mode_inernal(RTFMODE fHostMode);
-
-/**
- * Convert guest VFS object mode flags into host ones.
- *
- * @param fGuestMode     Host flags
- *
- * @return Host flags
- */
-extern uint32_t vboxvfs_g2h_mode_inernal(mode_t fGuestMode);
-
-extern SHFLSTRING *vboxvfs_construct_shflstring(const char *pszName, size_t cchName);
 #endif
 
-#endif
-
-
Index: trunk/src/VBox/Additions/darwin/VBoxSF/VBoxSFMount.h
===================================================================
--- trunk/src/VBox/Additions/darwin/VBoxSF/VBoxSFMount.h	(revision 75677)
+++ trunk/src/VBox/Additions/darwin/VBoxSF/VBoxSFMount.h	(revision 75678)
@@ -27,7 +27,7 @@
  * Mount information that gets passed from userland on mount.
  */
-typedef struct vboxvfs_mount_info
+typedef struct VBOXSFDRWNMOUNTINFO
 {
-    /** Magic value (VBOXVFS_MOUNTINFO_MAGIC).   */
+    /** Magic value (VBOXSFDRWNMOUNTINFO_MAGIC).   */
     uint32_t    u32Magic;
     /** The shared folder name.   */
