Index: trunk/src/VBox/Additions/solaris/SharedFolders/Makefile.kmk
===================================================================
--- trunk/src/VBox/Additions/solaris/SharedFolders/Makefile.kmk	(revision 10066)
+++ trunk/src/VBox/Additions/solaris/SharedFolders/Makefile.kmk	(revision 10067)
@@ -30,5 +30,6 @@
 vboxvfs_SOURCES       = \
 	vboxvfs_vfsops.c \
-	vboxvfs_vnops.c
+	vboxvfs_vnops.c \
+	vboxvfs_utils.c
 vboxvfs_LIBS          = \
 	$(VBOX_LIB_VBGL_R0) \
Index: trunk/src/VBox/Additions/solaris/SharedFolders/vboxvfs.h
===================================================================
--- trunk/src/VBox/Additions/solaris/SharedFolders/vboxvfs.h	(revision 10066)
+++ trunk/src/VBox/Additions/solaris/SharedFolders/vboxvfs.h	(revision 10067)
@@ -21,4 +21,9 @@
 #define MAX_NLS_NAME    32
 
+/** The module name. */
+#define DEVICE_NAME              "vboxvfs"
+/** The module description as seen in 'modinfo'. */
+#define DEVICE_DESC              "filesystem for VirtualBox Shared Folders"
+
 /* Not sure if we need this; it seems only necessary for kernel mounts. */
 #if 0
@@ -39,18 +44,42 @@
 #include <sys/vfs_opreg.h>
 
+/** VNode for VBoxVFS */
+typedef struct vboxvfs_vnode
+{
+    vnode_t     *pVNode;
+    vattr_t     Attr;
+    SHFLSTRING  *pPath;
+    kmutex_t    MtxContents;
+} vboxvfs_vnode_t;
+
+
 /** Per-file system mount instance data. */
 typedef struct vboxvfs_globinfo
 {
-    VBSFMAP Map;
-    int Ttl;
-    int Uid;
-    int Gid;
-    vfs_t *pVFS;
-    vnode_t *pVNodeDev;
-    vnode_t *pVNodeRoot;
+    VBSFMAP         Map;
+    int             Ttl;
+    int             Uid;
+    int             Gid;
+    vfs_t           *pVFS;
+    vnode_t         *pVNodeDev;
+    vboxvfs_vnode_t *pVNodeRoot;
 } vboxvfs_globinfo_t;
 
 extern struct vnodeops *g_pVBoxVFS_vnodeops;
 extern const fs_operation_def_t g_VBoxVFS_vnodeops_template[];
+extern VBSFCLIENT g_VBoxVFSClient;
+
+/** Helper functions */
+extern int vboxvfs_Stat(const char *pszCaller, vboxvfs_globinfo_t *pVBoxVFSGlobalInfo, SHFLSTRING *pPath,
+            RTFSOBJINFO *pResult, boolean_t fAllowFailure);
+extern void vboxvfs_InitVNode(vboxvfs_globinfo_t *pVBoxVFSGlobalInfo, vboxvfs_vnode_t *pVBoxVNode,
+            RTFSOBJINFO *pFSInfo);
+
+
+/** Helper macros */
+#define VFS_TO_VBOXVFS(vfs)      ((vboxvfs_globinfo_t *)((vfs)->vfs_data))
+#define VBOXVFS_TO_VFS(vboxvfs)  ((vboxvfs)->pVFS)
+#define VN_TO_VBOXVN(vnode)      ((vboxvfs_vnode_t *)((vnode)->v_data))
+#define VBOXVN_TO_VN(vboxvnode)  ((vboxvnode)->pVNode)
 
 #endif /* _KERNEL */
Index: trunk/src/VBox/Additions/solaris/SharedFolders/vboxvfs_utils.c
===================================================================
--- trunk/src/VBox/Additions/solaris/SharedFolders/vboxvfs_utils.c	(revision 10067)
+++ trunk/src/VBox/Additions/solaris/SharedFolders/vboxvfs_utils.c	(revision 10067)
@@ -0,0 +1,158 @@
+/* $Id$ */
+/** @file
+ * VirtualBox File System Driver for Solaris Guests, Utility functions.
+ */
+
+/*
+ * Copyright (C) 2008 Sun Microsystems, Inc.
+ *
+ * Sun Microsystems, Inc. confidential
+ * All rights reserved
+ */
+
+
+/*******************************************************************************
+*   Header Files                                                               *
+*******************************************************************************/
+#include <time.h>
+#include <sys/stat.h>
+#include <sys/vnode.h>
+#include <sys/sunddi.h>
+#include "vboxvfs.h"
+
+#include <VBox/log.h>
+#include <iprt/time.h>
+
+/**
+ * Convert from RTTIMESPEC to timestruct_t.
+ *
+ * @param   pTime       Pointer to destination timestruct_t object.
+ * @param   pRTTime     Pointer to source time RTTIMESPEC object.
+ */
+static void vboxvfs_FileTimeFromTimeSpec(timestruc_t *pTime, PRTTIMESPEC pRTTime)
+{
+    int64_t t = RTTimeSpecGetNano(pRTTime);
+    int64_t nsec = t / 1000000000;
+
+    pTime->tv_sec = t;
+    pTime->tv_nsec = nsec;
+}
+
+
+/**
+ * Stat for a file on the host.
+ *
+ * @returns errno error code.
+ * @param   pszCaller               Entity calling this function (just used for logging sake)
+ * @param   pVBoxVFSGlobalInfo      Pointer to the global filesystem info. struct.
+ * @param   pPath                   Pointer to file path on the guest to stat.
+ * @param   pResult                 Where to store the result of stat.
+ * @param   fAllowFailure           Whether failure is acceptable to the caller (currently just logging).
+ */
+int vboxvfs_Stat(const char *pszCaller, vboxvfs_globinfo_t *pVBoxVFSGlobalInfo, SHFLSTRING *pPath,
+            RTFSOBJINFO *pResult, boolean_t fAllowFailure)
+{
+    int rc;
+    SHFLCREATEPARMS Params;
+
+    LogFlow((DEVICE_NAME ":vboxvfs_Stat caller=%s fAllowFailure=%d\n", pszCaller, fAllowFailure));
+
+    Params.CreateFlags = SHFL_CF_LOOKUP | SHFL_CF_ACT_FAIL_IF_NEW;
+    rc = vboxCallCreate(&g_VBoxVFSClient, &pVBoxVFSGlobalInfo->Map, pPath, &Params);
+    if (VBOX_FAILURE(rc))
+    {
+        Log((DEVICE_NAME ":vboxCallCreate failed! caller=%s rc=%Vrc\n", pszCaller, rc));
+        return EPROTO;
+    }
+
+    if (Params.Result != SHFL_FILE_EXISTS)
+    {
+        if (fAllowFailure)
+        {
+            LogRel((DEVICE_NAME ":vboxCallCreate(%s) file does not exist. caller=%s result=%d\n",
+                    pPath->String.utf8, Params.Result, pszCaller));
+        }
+        return ENOENT;
+    }
+    *pResult = Params.Info;
+    return 0;
+}
+
+/**
+ * Initializes VNode structure.
+ *
+ * @param   pVBoxVFSGlobalInfo      Pointer to the global filesystem info. struct.
+ * @param   pVBoxVNode              Pointer to the pre-allocated vboxvfs_vnode_t object to initialize.
+ * @param   pInfo                   Pointer to the RTFSOBJINFO used for initialization.
+ */
+void vboxvfs_InitVNode(vboxvfs_globinfo_t *pVBoxVFSGlobalInfo, vboxvfs_vnode_t *pVBoxVNode,
+            RTFSOBJINFO *pFSInfo)
+{
+    RTFSOBJATTR *pFSAttr;
+    int fDir;
+    vfs_t *pVFS;
+
+    mutex_enter(&pVBoxVNode->MtxContents);
+
+    pVFS = VBOXVFS_TO_VFS(pVBoxVFSGlobalInfo);
+    pFSAttr = &pFSInfo->Attr;
+    fDir = RTFS_IS_DIRECTORY(pFSAttr->fMode);
+    int Mode = 0;
+
+#define VBOXMODESET(r) pFSAttr->fMode & (RTFS_UNIX_##r) ? (S_##r) : 0;
+    Mode |= VBOXMODESET(ISUID);
+    Mode |= VBOXMODESET(ISGID);
+
+    Mode |= VBOXMODESET(IRUSR);
+    Mode |= VBOXMODESET(IWUSR);
+    Mode |= VBOXMODESET(IXUSR);
+
+    Mode |= VBOXMODESET(IRGRP);
+    Mode |= VBOXMODESET(IWGRP);
+    Mode |= VBOXMODESET(IXGRP);
+
+    Mode |= VBOXMODESET(IROTH);
+    Mode |= VBOXMODESET(IWOTH);
+    Mode |= VBOXMODESET(IXOTH);
+#undef VBOXMODESET
+
+    bzero(&pVBoxVNode->Attr, sizeof(vattr_t));
+    if (fDir)
+    {
+        pVBoxVNode->Attr.va_mode = (mode_t)(S_IFDIR | Mode);
+        pVBoxVNode->Attr.va_type = VDIR;
+    }
+    else
+    {
+        pVBoxVNode->Attr.va_mode = (mode_t)(S_IFREG | Mode);
+        pVBoxVNode->Attr.va_type = VREG;
+    }
+
+    pVBoxVNode->Attr.va_rdev = 0;   /* @todo Verify if setting it to zero is okay, not sure of this. */
+    pVBoxVNode->Attr.va_mask = 0;
+    pVBoxVNode->Attr.va_seq = 0;
+    pVBoxVNode->Attr.va_nlink = 1;
+    pVBoxVNode->Attr.va_uid = pVBoxVFSGlobalInfo->Uid;
+    pVBoxVNode->Attr.va_gid = pVBoxVFSGlobalInfo->Gid;
+    pVBoxVNode->Attr.va_fsid = pVFS->vfs_dev;
+    pVBoxVNode->Attr.va_size = pFSInfo->cbObject;
+    pVBoxVNode->Attr.va_nblocks = (pFSInfo->cbObject + 4095) / 4096;
+    pVBoxVNode->Attr.va_blksize = 4096;
+
+    vboxvfs_FileTimeFromTimeSpec(&pVBoxVNode->Attr.va_atime, &pFSInfo->AccessTime);
+    vboxvfs_FileTimeFromTimeSpec(&pVBoxVNode->Attr.va_ctime, &pFSInfo->ChangeTime);
+    vboxvfs_FileTimeFromTimeSpec(&pVBoxVNode->Attr.va_mtime, &pFSInfo->ModificationTime);
+
+    /* Allocate and initialize the vnode */
+    pVBoxVNode->pVNode = vn_alloc(KM_SLEEP);
+
+    vn_setops(pVBoxVNode->pVNode, g_pVBoxVFS_vnodeops);
+    pVBoxVNode->pVNode->v_data = pVBoxVNode;
+    pVBoxVNode->pVNode->v_vfsp = pVFS;
+    pVBoxVNode->pVNode->v_type = pVBoxVNode->Attr.va_type;
+    pVBoxVNode->pVNode->v_rdev = pVBoxVNode->Attr.va_rdev;
+
+    mutex_exit(&pVBoxVNode->MtxContents);
+    vn_exists(pVBoxVNode->pVNode);
+}
+
Index: trunk/src/VBox/Additions/solaris/SharedFolders/vboxvfs_vfsops.c
===================================================================
--- trunk/src/VBox/Additions/solaris/SharedFolders/vboxvfs_vfsops.c	(revision 10066)
+++ trunk/src/VBox/Additions/solaris/SharedFolders/vboxvfs_vfsops.c	(revision 10067)
@@ -1,5 +1,5 @@
 /* $Id$ */
 /** @file
- * VirtualBox File System Driver for Solaris Guests.
+ * VirtualBox File System Driver for Solaris Guests. VFS operations.
  */
 
@@ -38,16 +38,7 @@
 *   Defined Constants And Macros                                               *
 *******************************************************************************/
-/** The module name. */
-#define DEVICE_NAME              "vboxvfs"
-/** The module description as seen in 'modinfo'. */
-#define DEVICE_DESC              "filesystem for VirtualBox Shared Folders"
-
 /** Mount Options */
 #define MNTOPT_VBOXVFS_UID       "uid"
 #define MNTOPT_VBOXVFS_GID       "gid"
-
-/** Helpers */
-#define VFS2VBOXVFS(vfs)         ((vboxvfs_globinfo_t *)((vfs)->vfs_data))
-#define VBOXVFS2VFS(vboxvfs)     ((vboxvfs)->pVFS)
 
 
@@ -141,5 +132,5 @@
 unsigned __gxx_personality_v0 = 0xdecea5ed;
 /** Global connection to the client. */
-static VBSFCLIENT g_VBoxVFSClient;
+VBSFCLIENT g_VBoxVFSClient;
 /** Global VFS Operations pointer. */
 vfsops_t *g_pVBoxVFS_vfsops;
@@ -262,8 +253,10 @@
     size_t cbShare = NULL;
     pathname_t PathName;
+    vboxvfs_vnode_t *pVNodeRoot = NULL;
     vnode_t *pVNodeSpec = NULL;
     vnode_t *pVNodeDev = NULL;
     dev_t Dev = 0;
     SHFLSTRING *pShflShareName = NULL;
+    RTFSOBJINFO FSInfo;
     size_t cbShflShareName = 0;
     vboxvfs_globinfo_t *pVBoxVFSGlobalInfo = NULL;
@@ -418,8 +411,8 @@
 
     /* Allocate the global info. structure. */
-    pVBoxVFSGlobalInfo = RTMemAllocZ(sizeof(*pVBoxVFSGlobalInfo));
+    pVBoxVFSGlobalInfo = RTMemAlloc(sizeof(*pVBoxVFSGlobalInfo));
     if (!pVBoxVFSGlobalInfo)
     {
-        LogRel((DEVICE_NAME ":VBoxVFS_Mount: RTMemAllocZ failed to alloc %d bytes for global struct.\n", sizeof(*pVBoxVFSGlobalInfo)));
+        LogRel((DEVICE_NAME ":VBoxVFS_Mount: RTMemAlloc failed to alloc %d bytes for global struct.\n", sizeof(*pVBoxVFSGlobalInfo)));
         return ENOMEM;
     }
@@ -457,5 +450,39 @@
     vfs_make_fsid(&pVFS->vfs_fsid, Dev, g_VBoxVFSType);
 
-    /* @todo root vnode */
+    /* Allocate root vboxvfs_vnode_t object */
+    pVNodeRoot = RTMemAlloc(sizeof(*pVNodeRoot));
+    if (!pVNodeRoot)
+    {
+        LogRel((DEVICE_NAME ":VBoxVFS_Mount: RTMemAlloc failed to alloc %d bytes for root node.\n", sizeof(*pVNodeRoot)));
+        return ENOMEM;
+    }
+
+    /* Initialize the mutex */
+    mutex_init(&pVNodeRoot->MtxContents, "VNodeMtx", MUTEX_DEFAULT, NULL);
+
+    /* Allocate root path */
+    pVNodeRoot->pPath = RTMemAllocZ(sizeof(SHFLSTRING) + 1);
+    if (!pVNodeRoot->pPath)
+    {
+        LogRel((DEVICE_NAME ":VBoxVFS_Mount: RTMemAllocZ failed to alloc %d bytes for root path.\n", sizeof(SHFLSTRING) + 1));
+        return ENOMEM;
+    }
+
+    /* Initialize root path */
+    pVNodeRoot->pPath->u16Length = 1;
+    pVNodeRoot->pPath->u16Size = 2;
+    pVNodeRoot->pPath->String.utf8[0] = '/';
+    pVNodeRoot->pPath->String.utf8[1] = '\0';
+
+    /* Stat root node info from host */
+    rc = vboxvfs_Stat(__func__, pVBoxVFSGlobalInfo, pVNodeRoot->pPath, &FSInfo, B_FALSE);
+    if (rc)
+    {
+        LogRel((DEVICE_NAME ":VBoxVFS_Mount: vboxvfs_Stat failed rc(errno)=%d\n", rc));
+        return rc;
+    }
+
+    /* Initialize the root vboxvfs_node_t object */
+    vboxvfs_InitVNode(pVBoxVFSGlobalInfo, pVNodeRoot, &FSInfo);
 
     return 0;
@@ -482,5 +509,5 @@
     /* @todo implement ref-counting of active vnodes & check for busy state here. */
     /* @todo mutex protection needed here */
-    pVBoxVFSGlobalInfo = VFS2VBOXVFS(pVFS);
+    pVBoxVFSGlobalInfo = VFS_TO_VBOXVFS(pVFS);
 
     rc = vboxCallUnmapFolder(&g_VBoxVFSClient, &pVBoxVFSGlobalInfo->Map);
@@ -488,5 +515,5 @@
         LogRel((DEVICE_NAME ":VBoxVFS_Unmount: failed to unmap shared folder. rc=%d\n", rc));
 
-    VN_RELE(pVBoxVFSGlobalInfo->pVNodeRoot);
+    VN_RELE(VBOXVN_TO_VN(pVBoxVFSGlobalInfo->pVNodeRoot));
 
     RTMemFree(pVBoxVFSGlobalInfo);
@@ -498,6 +525,6 @@
 static int VBoxVFS_Root(vfs_t *pVFS, vnode_t **ppVNode)
 {
-    vboxvfs_globinfo_t *pVBoxVFSGlobalInfo = VFS2VBOXVFS(pVFS);
-    *ppVNode = pVBoxVFSGlobalInfo->pVNodeRoot;
+    vboxvfs_globinfo_t *pVBoxVFSGlobalInfo = VFS_TO_VBOXVFS(pVFS);
+    *ppVNode = VBOXVN_TO_VN(pVBoxVFSGlobalInfo->pVNodeRoot);
     VN_HOLD(*ppVNode);
 
@@ -513,5 +540,5 @@
     int                 rc;
 
-    pVBoxVFSGlobalInfo = VFS2VBOXVFS(pVFS);
+    pVBoxVFSGlobalInfo = VFS_TO_VBOXVFS(pVFS);
     cbBuffer = sizeof(VolumeInfo);
     rc = vboxCallFSInfo(&g_VBoxVFSClient, &pVBoxVFSGlobalInfo->Map, 0, SHFL_INFO_GET | SHFL_INFO_VOLUME, &cbBuffer,
Index: trunk/src/VBox/Additions/solaris/SharedFolders/vboxvfs_vnops.c
===================================================================
--- trunk/src/VBox/Additions/solaris/SharedFolders/vboxvfs_vnops.c	(revision 10066)
+++ trunk/src/VBox/Additions/solaris/SharedFolders/vboxvfs_vnops.c	(revision 10067)
@@ -1,5 +1,5 @@
 /* $Id$ */
 /** @file
- * VirtualBox File System Driver for Solaris Guests.
+ * VirtualBox File System Driver for Solaris Guests, VNode Operations.
  */
 
