VirtualBox

Changeset 10067 in vbox for trunk/src/VBox


Ignore:
Timestamp:
Jul 1, 2008 11:07:51 AM (17 years ago)
Author:
vboxsync
Message:

Solaris vboxvfs: root vnode.

Location:
trunk/src/VBox/Additions/solaris/SharedFolders
Files:
1 added
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Additions/solaris/SharedFolders/Makefile.kmk

    r10030 r10067  
    3030vboxvfs_SOURCES       = \
    3131        vboxvfs_vfsops.c \
    32         vboxvfs_vnops.c
     32        vboxvfs_vnops.c \
     33        vboxvfs_utils.c
    3334vboxvfs_LIBS          = \
    3435        $(VBOX_LIB_VBGL_R0) \
  • trunk/src/VBox/Additions/solaris/SharedFolders/vboxvfs.h

    r9672 r10067  
    2121#define MAX_NLS_NAME    32
    2222
     23/** The module name. */
     24#define DEVICE_NAME              "vboxvfs"
     25/** The module description as seen in 'modinfo'. */
     26#define DEVICE_DESC              "filesystem for VirtualBox Shared Folders"
     27
    2328/* Not sure if we need this; it seems only necessary for kernel mounts. */
    2429#if 0
     
    3944#include <sys/vfs_opreg.h>
    4045
     46/** VNode for VBoxVFS */
     47typedef struct vboxvfs_vnode
     48{
     49    vnode_t     *pVNode;
     50    vattr_t     Attr;
     51    SHFLSTRING  *pPath;
     52    kmutex_t    MtxContents;
     53} vboxvfs_vnode_t;
     54
     55
    4156/** Per-file system mount instance data. */
    4257typedef struct vboxvfs_globinfo
    4358{
    44     VBSFMAP Map;
    45     int Ttl;
    46     int Uid;
    47     int Gid;
    48     vfs_t *pVFS;
    49     vnode_t *pVNodeDev;
    50     vnode_t *pVNodeRoot;
     59    VBSFMAP         Map;
     60    int             Ttl;
     61    int             Uid;
     62    int             Gid;
     63    vfs_t           *pVFS;
     64    vnode_t         *pVNodeDev;
     65    vboxvfs_vnode_t *pVNodeRoot;
    5166} vboxvfs_globinfo_t;
    5267
    5368extern struct vnodeops *g_pVBoxVFS_vnodeops;
    5469extern const fs_operation_def_t g_VBoxVFS_vnodeops_template[];
     70extern VBSFCLIENT g_VBoxVFSClient;
     71
     72/** Helper functions */
     73extern int vboxvfs_Stat(const char *pszCaller, vboxvfs_globinfo_t *pVBoxVFSGlobalInfo, SHFLSTRING *pPath,
     74            RTFSOBJINFO *pResult, boolean_t fAllowFailure);
     75extern void vboxvfs_InitVNode(vboxvfs_globinfo_t *pVBoxVFSGlobalInfo, vboxvfs_vnode_t *pVBoxVNode,
     76            RTFSOBJINFO *pFSInfo);
     77
     78
     79/** Helper macros */
     80#define VFS_TO_VBOXVFS(vfs)      ((vboxvfs_globinfo_t *)((vfs)->vfs_data))
     81#define VBOXVFS_TO_VFS(vboxvfs)  ((vboxvfs)->pVFS)
     82#define VN_TO_VBOXVN(vnode)      ((vboxvfs_vnode_t *)((vnode)->v_data))
     83#define VBOXVN_TO_VN(vboxvnode)  ((vboxvnode)->pVNode)
    5584
    5685#endif /* _KERNEL */
  • trunk/src/VBox/Additions/solaris/SharedFolders/vboxvfs_vfsops.c

    r10023 r10067  
    11/* $Id$ */
    22/** @file
    3  * VirtualBox File System Driver for Solaris Guests.
     3 * VirtualBox File System Driver for Solaris Guests. VFS operations.
    44 */
    55
     
    3838*   Defined Constants And Macros                                               *
    3939*******************************************************************************/
    40 /** The module name. */
    41 #define DEVICE_NAME              "vboxvfs"
    42 /** The module description as seen in 'modinfo'. */
    43 #define DEVICE_DESC              "filesystem for VirtualBox Shared Folders"
    44 
    4540/** Mount Options */
    4641#define MNTOPT_VBOXVFS_UID       "uid"
    4742#define MNTOPT_VBOXVFS_GID       "gid"
    48 
    49 /** Helpers */
    50 #define VFS2VBOXVFS(vfs)         ((vboxvfs_globinfo_t *)((vfs)->vfs_data))
    51 #define VBOXVFS2VFS(vboxvfs)     ((vboxvfs)->pVFS)
    5243
    5344
     
    141132unsigned __gxx_personality_v0 = 0xdecea5ed;
    142133/** Global connection to the client. */
    143 static VBSFCLIENT g_VBoxVFSClient;
     134VBSFCLIENT g_VBoxVFSClient;
    144135/** Global VFS Operations pointer. */
    145136vfsops_t *g_pVBoxVFS_vfsops;
     
    262253    size_t cbShare = NULL;
    263254    pathname_t PathName;
     255    vboxvfs_vnode_t *pVNodeRoot = NULL;
    264256    vnode_t *pVNodeSpec = NULL;
    265257    vnode_t *pVNodeDev = NULL;
    266258    dev_t Dev = 0;
    267259    SHFLSTRING *pShflShareName = NULL;
     260    RTFSOBJINFO FSInfo;
    268261    size_t cbShflShareName = 0;
    269262    vboxvfs_globinfo_t *pVBoxVFSGlobalInfo = NULL;
     
    418411
    419412    /* Allocate the global info. structure. */
    420     pVBoxVFSGlobalInfo = RTMemAllocZ(sizeof(*pVBoxVFSGlobalInfo));
     413    pVBoxVFSGlobalInfo = RTMemAlloc(sizeof(*pVBoxVFSGlobalInfo));
    421414    if (!pVBoxVFSGlobalInfo)
    422415    {
    423         LogRel((DEVICE_NAME ":VBoxVFS_Mount: RTMemAllocZ failed to alloc %d bytes for global struct.\n", sizeof(*pVBoxVFSGlobalInfo)));
     416        LogRel((DEVICE_NAME ":VBoxVFS_Mount: RTMemAlloc failed to alloc %d bytes for global struct.\n", sizeof(*pVBoxVFSGlobalInfo)));
    424417        return ENOMEM;
    425418    }
     
    457450    vfs_make_fsid(&pVFS->vfs_fsid, Dev, g_VBoxVFSType);
    458451
    459     /* @todo root vnode */
     452    /* Allocate root vboxvfs_vnode_t object */
     453    pVNodeRoot = RTMemAlloc(sizeof(*pVNodeRoot));
     454    if (!pVNodeRoot)
     455    {
     456        LogRel((DEVICE_NAME ":VBoxVFS_Mount: RTMemAlloc failed to alloc %d bytes for root node.\n", sizeof(*pVNodeRoot)));
     457        return ENOMEM;
     458    }
     459
     460    /* Initialize the mutex */
     461    mutex_init(&pVNodeRoot->MtxContents, "VNodeMtx", MUTEX_DEFAULT, NULL);
     462
     463    /* Allocate root path */
     464    pVNodeRoot->pPath = RTMemAllocZ(sizeof(SHFLSTRING) + 1);
     465    if (!pVNodeRoot->pPath)
     466    {
     467        LogRel((DEVICE_NAME ":VBoxVFS_Mount: RTMemAllocZ failed to alloc %d bytes for root path.\n", sizeof(SHFLSTRING) + 1));
     468        return ENOMEM;
     469    }
     470
     471    /* Initialize root path */
     472    pVNodeRoot->pPath->u16Length = 1;
     473    pVNodeRoot->pPath->u16Size = 2;
     474    pVNodeRoot->pPath->String.utf8[0] = '/';
     475    pVNodeRoot->pPath->String.utf8[1] = '\0';
     476
     477    /* Stat root node info from host */
     478    rc = vboxvfs_Stat(__func__, pVBoxVFSGlobalInfo, pVNodeRoot->pPath, &FSInfo, B_FALSE);
     479    if (rc)
     480    {
     481        LogRel((DEVICE_NAME ":VBoxVFS_Mount: vboxvfs_Stat failed rc(errno)=%d\n", rc));
     482        return rc;
     483    }
     484
     485    /* Initialize the root vboxvfs_node_t object */
     486    vboxvfs_InitVNode(pVBoxVFSGlobalInfo, pVNodeRoot, &FSInfo);
    460487
    461488    return 0;
     
    482509    /* @todo implement ref-counting of active vnodes & check for busy state here. */
    483510    /* @todo mutex protection needed here */
    484     pVBoxVFSGlobalInfo = VFS2VBOXVFS(pVFS);
     511    pVBoxVFSGlobalInfo = VFS_TO_VBOXVFS(pVFS);
    485512
    486513    rc = vboxCallUnmapFolder(&g_VBoxVFSClient, &pVBoxVFSGlobalInfo->Map);
     
    488515        LogRel((DEVICE_NAME ":VBoxVFS_Unmount: failed to unmap shared folder. rc=%d\n", rc));
    489516
    490     VN_RELE(pVBoxVFSGlobalInfo->pVNodeRoot);
     517    VN_RELE(VBOXVN_TO_VN(pVBoxVFSGlobalInfo->pVNodeRoot));
    491518
    492519    RTMemFree(pVBoxVFSGlobalInfo);
     
    498525static int VBoxVFS_Root(vfs_t *pVFS, vnode_t **ppVNode)
    499526{
    500     vboxvfs_globinfo_t *pVBoxVFSGlobalInfo = VFS2VBOXVFS(pVFS);
    501     *ppVNode = pVBoxVFSGlobalInfo->pVNodeRoot;
     527    vboxvfs_globinfo_t *pVBoxVFSGlobalInfo = VFS_TO_VBOXVFS(pVFS);
     528    *ppVNode = VBOXVN_TO_VN(pVBoxVFSGlobalInfo->pVNodeRoot);
    502529    VN_HOLD(*ppVNode);
    503530
     
    513540    int                 rc;
    514541
    515     pVBoxVFSGlobalInfo = VFS2VBOXVFS(pVFS);
     542    pVBoxVFSGlobalInfo = VFS_TO_VBOXVFS(pVFS);
    516543    cbBuffer = sizeof(VolumeInfo);
    517544    rc = vboxCallFSInfo(&g_VBoxVFSClient, &pVBoxVFSGlobalInfo->Map, 0, SHFL_INFO_GET | SHFL_INFO_VOLUME, &cbBuffer,
  • trunk/src/VBox/Additions/solaris/SharedFolders/vboxvfs_vnops.c

    r9177 r10067  
    11/* $Id$ */
    22/** @file
    3  * VirtualBox File System Driver for Solaris Guests.
     3 * VirtualBox File System Driver for Solaris Guests, VNode Operations.
    44 */
    55
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette