Index: trunk/src/VBox/Additions/haiku/SharedFolders/vboxsf.c
===================================================================
--- trunk/src/VBox/Additions/haiku/SharedFolders/vboxsf.c	(revision 43398)
+++ trunk/src/VBox/Additions/haiku/SharedFolders/vboxsf.c	(revision 43404)
@@ -46,6 +46,7 @@
 #include "vboxsf.h"
 
-#define MODULE_NAME "file_systems/vboxsf"
-#define FS_NAME "vboxsf"
+#define MODULE_NAME     "file_systems/vboxsf"
+#define FS_NAME         "vboxsf"
+#define FS_PRETTY_NAME  "VirtualBox Shared Folders"
 
 VBSFCLIENT g_clientHandle;
@@ -55,4 +56,41 @@
 status_t init_module(void)
 {
+#if 0
+    /* @todo enable this soon */
+    int rc = get_module(VBOXGUEST_MODULE_NAME, (module_info **)&g_VBoxGuest);
+    if (RT_LIKELY(rc == B_OK)
+    {
+        rc = vboxInit();
+        if (RT_SUCCESS(rc))
+        {
+            rc = vboxConnect(&g_clientHandle);
+            if (RT_SUCCESS(rc))
+            {
+                rc = vboxCallSetUtf8(&g_clientHandle);
+                if (RT_SUCCESS(rc))
+                {
+                    rc = vboxCallSetSymlinks(&g_clientHandle);
+                    if (RT_FAILURE(rc))
+                        LogRel((FS_NAME ":Warning! vboxCallSetSymlinks failed (rc=%d) - symlink will appear as copies.\n", rc));
+
+                    mutex_init(&g_vnodeCacheLock, "vboxsf vnode cache lock");
+                    Log((FS_NAME ":init_module succeeded.\n");
+                    return B_OK;
+                }
+                else
+                    LogRel((FS_NAME ":vboxCallSetUtf8 failed. rc=%d\n", rc));
+            }
+            else
+                LogRel((FS_NAME ":vboxConnect failed. rc=%d\n", rc));
+        }
+        else
+            LogRel((FS_NAME ":vboxInit failed. rc=%d\n", rc));
+    }
+    else
+        LogRel((FS_NAME ":get_module failed for '%s'. rc=%d\n", VBOXGUEST_MODULE_NAME, rc));
+
+    return B_ERROR;
+#endif
+
     if (get_module(VBOXGUEST_MODULE_NAME, (module_info **)&g_VBoxGuest) != B_OK)
     {
@@ -157,5 +195,4 @@
 PSHFLSTRING build_path(vboxsf_vnode* dir, const char* const name)
 {
-
     dprintf("*** build_path(%p, %p)\n", dir, name);
     if (!dir || !name)
@@ -265,17 +302,17 @@
     }
 
-    st->st_dev = 0;
-    st->st_ino = vnode->vnode;
-    st->st_mode = mode_from_fmode(params.Info.Attr.fMode);
-    st->st_nlink = 1;
-    st->st_uid = 0;
-    st->st_gid = 0;
-    st->st_rdev = 0;
-    st->st_size = params.Info.cbObject;
+    st->st_dev     = 0;
+    st->st_ino     = vnode->vnode;
+    st->st_mode    = mode_from_fmode(params.Info.Attr.fMode);
+    st->st_nlink   = 1;
+    st->st_uid     = 0;
+    st->st_gid     = 0;
+    st->st_rdev    = 0;
+    st->st_size    = params.Info.cbObject;
     st->st_blksize = 1;
-    st->st_blocks = params.Info.cbAllocated;
-    st->st_atime = RTTimeSpecGetSeconds(&params.Info.AccessTime);
-    st->st_mtime = RTTimeSpecGetSeconds(&params.Info.ModificationTime);
-    st->st_ctime = RTTimeSpecGetSeconds(&params.Info.BirthTime);
+    st->st_blocks  = params.Info.cbAllocated;
+    st->st_atime   = RTTimeSpecGetSeconds(&params.Info.AccessTime);
+    st->st_mtime   = RTTimeSpecGetSeconds(&params.Info.ModificationTime);
+    st->st_ctime   = RTTimeSpecGetSeconds(&params.Info.BirthTime);
     return B_OK;
 }
@@ -290,6 +327,5 @@
     RT_ZERO(params);
     params.Handle = SHFL_HANDLE_NIL;
-    params.CreateFlags = SHFL_CF_DIRECTORY | SHFL_CF_ACT_OPEN_IF_EXISTS
-        | SHFL_CF_ACT_FAIL_IF_NEW | SHFL_CF_ACCESS_READ;
+    params.CreateFlags = SHFL_CF_DIRECTORY | SHFL_CF_ACT_OPEN_IF_EXISTS | SHFL_CF_ACT_FAIL_IF_NEW | SHFL_CF_ACCESS_READ;
 
     int rc = vboxCallCreate(&g_clientHandle, &volume->map, vnode->path, &params);
@@ -332,6 +368,6 @@
         cookie->buffer_start = cookie->buffer = malloc(cookie->buffer_length);
 
-        int rc = vboxCallDirInfo(&g_clientHandle, &volume->map, cookie->handle, cookie->path,
-            0, cookie->index, &cookie->buffer_length, cookie->buffer, &cookie->num_files);
+        int rc = vboxCallDirInfo(&g_clientHandle, &volume->map, cookie->handle, cookie->path, 0, cookie->index,
+                                 &cookie->buffer_length, cookie->buffer, &cookie->num_files);
 
         if (rc != 0 && rc != VERR_NO_MORE_FILES)
@@ -372,4 +408,5 @@
         return rv;
     }
+
     buffer->d_dev = 0;
     buffer->d_pdev = 0;
@@ -453,12 +490,12 @@
         info->flags |= B_FS_IS_READONLY;
 
-    info->dev = 0;
-    info->root = 1;
-    info->block_size = volume_info.ulBytesPerAllocationUnit;
-    info->io_size = volume_info.ulBytesPerAllocationUnit;
+    info->dev          = 0;
+    info->root         = 1;
+    info->block_size   = volume_info.ulBytesPerAllocationUnit;
+    info->io_size      = volume_info.ulBytesPerAllocationUnit;
     info->total_blocks = volume_info.ullTotalAllocationBytes / info->block_size;
-    info->free_blocks = volume_info.ullAvailableAllocationBytes / info->block_size;
-    info->total_nodes = LONGLONG_MAX;
-    info->free_nodes = LONGLONG_MAX;
+    info->free_blocks  = volume_info.ullAvailableAllocationBytes / info->block_size;
+    info->total_nodes  = LONGLONG_MAX;
+    info->free_nodes   = LONGLONG_MAX;
     strcpy(info->volume_name, "VBox share");
     return B_OK;
@@ -730,5 +767,5 @@
 
     uint32_t l = *length;
-    void* other_buffer = malloc(l); // TODO map the user memory into kernel space here for efficiency
+    void* other_buffer = malloc(l);  /* @todo map the user memory into kernel space here for efficiency */
     int rc = vboxCallRead(&g_clientHandle, &volume->map, cookie->handle, pos, &l, other_buffer, false);
     memcpy(buffer, other_buffer, l);
@@ -751,5 +788,5 @@
 
     uint32_t l = *length;
-    void* other_buffer = malloc(l); // TODO map the user memory into kernel space here for efficiency
+    void* other_buffer = malloc(l);  /* @todo map the user memory into kernel space here for efficiency */
     memcpy(other_buffer, buffer, l);
     int rc = vboxCallWrite(&g_clientHandle, &volume->map, cookie->handle, pos, &l, other_buffer, false);
@@ -763,5 +800,5 @@
 status_t vboxsf_write_stat(fs_volume *volume, fs_vnode *vnode, const struct stat *stat, uint32 statMask)
 {
-    // the host handles updating the stat info - in the guest, this is a no-op
+    /* The host handles updating the stat info - in the guest, this is a no-op */
     return B_OK;
 }
@@ -781,4 +818,6 @@
     int rc = vboxCallCreate(&g_clientHandle, &volume->map, path, &params);
     free(path);
+    /** @todo r=ramshankar: we should perhaps also check rc here and change
+     *        Handle initialization from 0 to SHFL_HANDLE_NIL. */
     if (params.Handle == SHFL_HANDLE_NIL)
         return vbox_err_to_haiku_err(rc);
@@ -864,20 +903,22 @@
 
 
-// TODO move this into the runtime
+/* @todo move this into the runtime */
 status_t vbox_err_to_haiku_err(int rc)
 {
-    switch (rc) {
-        case VINF_SUCCESS: return B_OK;
-        case VERR_INVALID_POINTER: return B_BAD_ADDRESS;
-        case VERR_INVALID_PARAMETER: return B_BAD_VALUE;
-        case VERR_PERMISSION_DENIED: return B_PERMISSION_DENIED;
-        case VERR_NOT_IMPLEMENTED: return B_UNSUPPORTED;
-        case VERR_FILE_NOT_FOUND: return B_ENTRY_NOT_FOUND;
-
-        case SHFL_FILE_EXISTS: return B_FILE_EXISTS;
+    switch (rc)
+    {
+        case VINF_SUCCESS:              return B_OK;
+        case VERR_INVALID_POINTER:      return B_BAD_ADDRESS;
+        case VERR_INVALID_PARAMETER:    return B_BAD_VALUE;
+        case VERR_PERMISSION_DENIED:    return B_PERMISSION_DENIED;
+        case VERR_NOT_IMPLEMENTED:      return B_UNSUPPORTED;
+        case VERR_FILE_NOT_FOUND:       return B_ENTRY_NOT_FOUND;
+
         case SHFL_PATH_NOT_FOUND:
-        case SHFL_FILE_NOT_FOUND: return B_ENTRY_NOT_FOUND;
-
-        default: return B_ERROR;
+        case SHFL_FILE_NOT_FOUND:       return B_ENTRY_NOT_FOUND;
+        case SHFL_FILE_EXISTS:          return B_FILE_EXISTS;
+
+        default:
+            return B_ERROR;
     }
 }
@@ -904,82 +945,82 @@
 {
     unmount,
-    vboxsf_read_fs_info, // read_fs_info
-    NULL, // write_fs_info
-    NULL, // sync
-    vboxsf_get_vnode, // get_vnode
-    NULL, // open_index_dir
-    NULL, // close_index_dir
-    NULL, // free_index_dir_cookie
-    NULL, // read_index_dir
-    NULL, // rewind_index_dir
-    NULL, // create_index
-    NULL, // remove_index
-    NULL, // read_index_stat
-    NULL, // open_query
-    NULL, // close_query
-    NULL, // free_query_cookie
-    NULL, // read_query
-    NULL, // rewind_query
-    NULL, // all_layers_mounted
-    NULL, // create_sub_vnode
-    NULL, // delete_sub_vnode
+    vboxsf_read_fs_info,
+    NULL,                   /* write_fs_info */
+    NULL,                   /* sync */
+    vboxsf_get_vnode,
+    NULL,                   /* open_index_dir */
+    NULL,                   /* close_index_dir */
+    NULL,                   /* free_index_dir_cookie */
+    NULL,                   /* read_index_dir */
+    NULL,                   /* rewind_index_dir */
+    NULL,                   /* create_index */
+    NULL,                   /* remove_index */
+    NULL,                   /* read_index_stat */
+    NULL,                   /* open_query */
+    NULL,                   /* close_query */
+    NULL,                   /* free_query_cookie */
+    NULL,                   /* read_query */
+    NULL,                   /* rewind_query */
+    NULL,                   /* all_layers_mounted */
+    NULL,                   /* create_sub_vnode */
+    NULL,                   /* delete_sub_vnode */
 };
 
 static fs_vnode_ops vboxsf_vnode_ops =
 {
-    vboxsf_lookup, // lookup
-    NULL, // get_vnode_name
-    vboxsf_put_vnode, // put_vnode
-    NULL, // remove_vnode
-    NULL, // can_page
-    NULL, // read_pages
-    NULL, // write_pages
-    NULL, // io
-    NULL, // cancel_io
-    NULL, // get_file_map
-    NULL, // ioctl
-    NULL, // set_flags
-    NULL, // select
-    NULL, // deselect
-    NULL, // fsync
-    vboxsf_read_symlink, // read_symlink
-    vboxsf_create_symlink, // create_symlink
-    vboxsf_link, // link
-    vboxsf_unlink, // unlink
-    vboxsf_rename, // rename
-    NULL, // access
-    vboxsf_read_stat, // read_stat
-    vboxsf_write_stat, // write_stat
-    NULL, // preallocate
-    vboxsf_create, // create
-    vboxsf_open, // open
-    vboxsf_close, // close
-    vboxsf_free_cookie, // free_cookie
-    vboxsf_read, // read
-    vboxsf_write, // write
-    vboxsf_create_dir, // create_dir
-    vboxsf_remove_dir, // remove_dir
-    vboxsf_open_dir, // open_dir
-    vboxsf_close_dir, // close_dir
-    vboxsf_free_dir_cookie, // free_dir_cookie
-    vboxsf_read_dir, // read_dir
-    vboxsf_rewind_dir, // rewind_dir
-    NULL, // open_attr_dir
-    NULL, // close_attr_dir
-    NULL, // free_attr_dir_cookie
-    NULL, // read_attr_dir
-    NULL, // rewind_attr_dir
-    NULL, // create_attr
-    NULL, // open_attr
-    NULL, // close_attr
-    NULL, // free_attr_cookie
-    NULL, // read_attr
-    NULL, // write_attr
-    NULL, // read_attr_stat
-    NULL, // write_attr_stat
-    NULL, // rename_attr
-    NULL, // remove_attr
-    NULL, // create_special_node
-    NULL, // get_super_vnode
+    vboxsf_lookup,
+    NULL,                   /* get_vnode_name */
+    vboxsf_put_vnode,
+    NULL,                   /* remove_vnode */
+    NULL,                   /* can_page */
+    NULL,                   /* read_pages */
+    NULL,                   /* write_pages */
+    NULL,                   /* io */
+    NULL,                   /* cancel_io */
+    NULL,                   /* get_file_map */
+    NULL,                   /* ioctl */
+    NULL,                   /* set_flags */
+    NULL,                   /* select */
+    NULL,                   /* deselect */
+    NULL,                   /* fsync */
+    vboxsf_read_symlink,
+    vboxsf_create_symlink,
+    vboxsf_link,
+    vboxsf_unlink,
+    vboxsf_rename,
+    NULL,                   /* access */
+    vboxsf_read_stat,
+    vboxsf_write_stat
+    NULL,                   /* preallocate */
+    vboxsf_create,
+    vboxsf_open,
+    vboxsf_close,
+    vboxsf_free_cookie,
+    vboxsf_read,
+    vboxsf_write,
+    vboxsf_create_dir,
+    vboxsf_remove_dir,
+    vboxsf_open_dir,
+    vboxsf_close_dir,
+    vboxsf_free_dir_cookie,
+    vboxsf_read_dir,
+    vboxsf_rewind_dir,
+    NULL,                   /* open_attr_dir */
+    NULL,                   /* close_attr_dir */
+    NULL,                   /* free_attr_dir_cookie */
+    NULL,                   /* read_attr_dir */
+    NULL,                   /* rewind_attr_dir */
+    NULL,                   /* create_attr */
+    NULL,                   /* open_attr */
+    NULL,                   /* close_attr */
+    NULL,                   /* free_attr_cookie */
+    NULL,                   /* read_attr */
+    NULL,                   /* write_attr */
+    NULL,                   /* read_attr_stat */
+    NULL,                   /* write_attr_stat */
+    NULL,                   /* rename_attr */
+    NULL,                   /* remove_attr */
+    NULL,                   /* create_special_node */
+    NULL,                   /* get_super_vnode */
 };
 
@@ -991,12 +1032,11 @@
         std_ops,
     },
-    FS_NAME,                        // short_name
-    "VirtualBox shared folders",    // pretty_name
-    0, //B_DISK_SYSTEM_SUPPORTS_WRITING,    // DDM flags
-    // scanning
-    NULL, // identify_partition
-    NULL, // scan_partition
-    NULL, // free_identify_partition_cookie
-    NULL,    // free_partition_content_cookie()
+    FS_NAME,
+    FS_PRETTY_NAME,
+    0,                      /* DDM flags */
+    NULL,                   /* identify_partition */
+    NULL,                   /* scan_partition */
+    NULL,                   /* free_identify_partition_cookie */
+    NULL,                   /* free_partition_content_cookie */
     mount,
 };
Index: trunk/src/VBox/Additions/haiku/SharedFolders/vboxsf.h
===================================================================
--- trunk/src/VBox/Additions/haiku/SharedFolders/vboxsf.h	(revision 43398)
+++ trunk/src/VBox/Additions/haiku/SharedFolders/vboxsf.h	(revision 43404)
@@ -91,4 +91,5 @@
 extern "C" {
 #endif
+
 status_t vboxsf_new_vnode(PVBSFMAP map, PSHFLSTRING path, PSHFLSTRING name, vboxsf_vnode** p);
 status_t vboxsf_get_vnode(fs_volume* volume, ino_t id, fs_vnode* vnode, int* _type, uint32* _flags, bool reenter);
@@ -98,8 +99,9 @@
 status_t vbox_err_to_haiku_err(int rc);
 extern mutex g_vnodeCacheLock;
+
 #ifdef __cplusplus
 }
 #endif
 
-#endif
+#endif /* ___vboxsf_h */
 
Index: trunk/src/VBox/Additions/haiku/SharedFolders/vnode_cache.cpp
===================================================================
--- trunk/src/VBox/Additions/haiku/SharedFolders/vnode_cache.cpp	(revision 43398)
+++ trunk/src/VBox/Additions/haiku/SharedFolders/vnode_cache.cpp	(revision 43404)
@@ -49,6 +49,6 @@
 struct HashTableDefinition
 {
-    typedef uint32 KeyType;
-    typedef    vboxsf_vnode ValueType;
+    typedef uint32       KeyType;
+    typedef vboxsf_vnode ValueType;
 
     size_t HashKey(uint32 key) const
@@ -116,5 +116,5 @@
 
 extern "C" status_t vboxsf_get_vnode(fs_volume* volume, ino_t id, fs_vnode* vnode,
-    int* _type, uint32* _flags, bool reenter)
+                                     int* _type, uint32* _flags, bool reenter)
 {
     vboxsf_vnode* vn = g_cache.Lookup(id);
