VirtualBox

Changeset 10140 in vbox


Ignore:
Timestamp:
Jul 3, 2008 8:45:37 AM (17 years ago)
Author:
vboxsync
Message:

Solaris vboxvfs stuff.

Location:
trunk/src/VBox/Additions/solaris/SharedFolders
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Additions/solaris/SharedFolders/vboxvfs.h

    r10067 r10140  
    6464    vnode_t         *pVNodeDev;
    6565    vboxvfs_vnode_t *pVNodeRoot;
     66    kmutex_t        MtxFS;
    6667} vboxvfs_globinfo_t;
    6768
  • trunk/src/VBox/Additions/solaris/SharedFolders/vboxvfs_vfsops.c

    r10067 r10140  
    111111    NULL                    /* terminate array of linkage structures */
    112112};
    113 
    114 /**
    115  * state info. for vboxvfs
    116  */
    117 typedef struct
    118 {
    119     /** Device Info handle. */
    120     dev_info_t             *pDip;
    121     /** Driver Mutex. */
    122     kmutex_t                Mtx;
    123 } vboxvfs_state_t;
    124113
    125114
     
    146135    LogFlow((DEVICE_NAME ":_init\n"));
    147136
    148     int rc = ddi_soft_state_init(&g_pVBoxVFSState, sizeof(vboxvfs_state_t), 1);
    149     if (!rc)
    150     {
    151         rc = mod_install(&g_VBoxVFSModLinkage);
    152         if (rc)
    153             ddi_soft_state_fini(&g_pVBoxVFSState);
    154     }
    155     return rc;
     137    return mod_install(&g_VBoxVFSModLinkage);;
    156138}
    157139
     
    162144
    163145    int rc = mod_remove(&g_VBoxVFSModLinkage);
    164     if (!rc)
    165         ddi_soft_state_fini(&g_pVBoxVFSState);
    166     return rc;
     146    if (rc)
     147        return rc;
     148
     149    /* Blow away the operation vectors*/
     150    vfs_freevfsops_by_type(g_VBoxVFSType);
     151    vn_freevnodeops(g_pVBoxVFS_vnodeops);
    167152}
    168153
     
    181166
    182167    LogFlow((DEVICE_NAME ":VBoxVFS_Init\n"));
     168
     169    g_VBoxVFSType = fType;
    183170
    184171    /* Initialize the R0 guest library. */
     
    213200                    if (!rc)
    214201                    {
    215                         g_VBoxVFSType = fType;
    216202                        LogFlow((DEVICE_NAME ":Successfully loaded vboxvfs.\n"));
    217203                        return 0;
     
    262248    vboxvfs_globinfo_t *pVBoxVFSGlobalInfo = NULL;
    263249    int AddrSpace = (pMount->flags & MS_SYSSPACE) ? UIO_SYSSPACE : UIO_USERSPACE;
    264 #if 0
    265     caddr_t pData;
    266     size_t cbData;
    267     vboxvfs_mountinfo_t Args;
    268 #endif
    269250
    270251    LogFlow((DEVICE_NAME ":VBoxVFS_Mount\n"));
     
    304285        return EINVAL;
    305286    }
    306 
    307     /* Will be removed eventually... */
    308 #if 0
    309     /* Retreive arguments. */
    310     bzero(&Args, sizeof(Args));
    311     cbData = pMount->datalen;
    312     pData = pMount->data;
    313     if (   (pMount->flags & MS_DATA)
    314         && pData != NULL
    315         && cbData > 0)
    316     {
    317         if (cbData > sizeof(Args))
    318         {
    319             LogRel((DEVICE_NAME: "VBoxVFS_Mount: argument length too long. expected=%d. received=%d\n", sizeof(Args), cbData));
    320             return EINVAL;
    321         }
    322 
    323         /* Copy arguments; they can be in kernel or user space. */
    324         rc = ddi_copyin(pData, &Args, cbData, (pMount->flags & MS_SYSSPACE) ? FKIOCTL : 0);
    325         if (rc)
    326         {
    327             LogRel((DEVICE_NAME: "VBoxVFS_Mount: ddi_copyin failed to copy arguments.rc=%d\n", rc));
    328             return EFAULT;
    329         }
    330     }
    331     else
    332     {
    333         cbData = 0;
    334         pData = NULL;
    335     }
    336 #endif
    337287
    338288    /* Get UID argument (optional). */
     
    412362    /* Allocate the global info. structure. */
    413363    pVBoxVFSGlobalInfo = RTMemAlloc(sizeof(*pVBoxVFSGlobalInfo));
    414     if (!pVBoxVFSGlobalInfo)
     364    if (pVBoxVFSGlobalInfo)
     365    {
     366        cbShflShareName = offsetof(SHFLSTRING, String.utf8) + cbShare + 1;
     367        pShflShareName  = RTMemAllocZ(cbShflShareName);
     368        if (pShflShareName)
     369        {
     370            pShflShareName->u16Length = cbShflShareName;
     371            pShflShareName->u16Size   = cbShflShareName + 1;
     372            memcpy (pShflShareName->String.utf8, pszShare, cbShare + 1);
     373
     374            rc = vboxCallMapFolder(&g_VBoxVFSClient, pShflShareName, &pVBoxVFSGlobalInfo->Map);
     375            RTMemFree(pShflShareName);
     376            if (VBOX_SUCCESS(rc))
     377                rc = 0;
     378            else
     379            {
     380                LogRel((DEVICE_NAME ":VBoxVFS_Mount: vboxCallMapFolder failed rc=%d\n", rc));
     381                rc = EPROTO;
     382            }
     383        }
     384        else
     385        {
     386            LogRel((DEVICE_NAME ":VBoxVFS_Mount: RTMemAllocZ failed to alloc %d bytes for ShFlShareName.\n", cbShflShareName));           
     387            rc = ENOMEM;
     388        }
     389        RTMemFree(pVBoxVFSGlobalInfo);
     390    }
     391    else
    415392    {
    416393        LogRel((DEVICE_NAME ":VBoxVFS_Mount: RTMemAlloc failed to alloc %d bytes for global struct.\n", sizeof(*pVBoxVFSGlobalInfo)));
    417         return ENOMEM;
    418     }
    419 
    420     cbShflShareName = offsetof(SHFLSTRING, String.utf8) + cbShare + 1;
    421     pShflShareName  = RTMemAllocZ(cbShflShareName);
    422     if (!pShflShareName)
    423     {
    424         RTMemFree(pVBoxVFSGlobalInfo);
    425         LogRel((DEVICE_NAME ":VBoxVFS_Mount: RTMemAllocZ failed to alloc %d bytes for ShFlShareName.\n", cbShflShareName));
    426         return ENOMEM;
    427     }
    428 
    429     pShflShareName->u16Length = cbShflShareName;
    430     pShflShareName->u16Size   = cbShflShareName + 1;
    431     memcpy (pShflShareName->String.utf8, pszShare, cbShare + 1);
    432 
    433     rc = vboxCallMapFolder(&g_VBoxVFSClient, pShflShareName, &pVBoxVFSGlobalInfo->Map);
    434     RTMemFree(pShflShareName);
    435     if (VBOX_FAILURE (rc))
    436     {
    437         RTMemFree(pVBoxVFSGlobalInfo);
    438         LogRel((DEVICE_NAME ":VBoxVFS_Mount: vboxCallMapFolder failed rc=%d\n", rc));
    439         return EPROTO;
    440     }
    441 
    442     /* @todo mutex for protecting the structure. */
     394        rc = ENOMEM;
     395    }
     396
     397    /* Undo work on failure. */
     398    if (rc)
     399        goto mntError1;
     400   
     401    /* Initialize the per-filesystem mutex */
     402    mutex_init(&pVBoxVFSGlobalInfo->MtxFS, "VBoxVFS_FSMtx", MUTEX_DEFAULT, NULL);
     403
    443404    pVBoxVFSGlobalInfo->Uid = Uid;
    444405    pVBoxVFSGlobalInfo->Gid = Gid;
     
    452413    /* Allocate root vboxvfs_vnode_t object */
    453414    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);
    487 
    488     return 0;
     415    if (pVNodeRoot)
     416    {
     417        /* Initialize vnode protection mutex */
     418        mutex_init(&pVNodeRoot->MtxContents, "VBoxVFS_VNodeMtx", MUTEX_DEFAULT, NULL);
     419
     420        pVBoxVFSGlobalInfo->pVNodeRoot = pVNodeRoot;
     421
     422        /* Allocate root path */
     423        pVNodeRoot->pPath = RTMemAllocZ(sizeof(SHFLSTRING) + 1);
     424        if (pVNodeRoot->pPath)
     425        {
     426            /* Initialize root path */
     427            pVNodeRoot->pPath->u16Length = 1;
     428            pVNodeRoot->pPath->u16Size = 2;
     429            pVNodeRoot->pPath->String.utf8[0] = '/';
     430            pVNodeRoot->pPath->String.utf8[1] = '\0';
     431
     432            /* Stat root node info from host */
     433            rc = vboxvfs_Stat(__func__, pVBoxVFSGlobalInfo, pVNodeRoot->pPath, &FSInfo, B_FALSE);
     434            if (!rc)
     435            {
     436                /* Initialize the root vboxvfs_node_t object */
     437                vboxvfs_InitVNode(pVBoxVFSGlobalInfo, pVNodeRoot, &FSInfo);
     438
     439                /* Success! */
     440                return 0;
     441            }
     442            else
     443                LogRel((DEVICE_NAME ":VBoxVFS_Mount: vboxvfs_Stat failed rc(errno)=%d\n", rc));
     444            RTMemFree(pVNodeRoot->pPath);
     445        }
     446        else
     447        {
     448            LogRel((DEVICE_NAME ":VBoxVFS_Mount: failed to alloc memory for root node path.\n"));
     449            rc = ENOMEM;
     450        }
     451        RTMemFree(pVNodeRoot);
     452    }
     453    else
     454    {
     455        LogRel((DEVICE_NAME ":VBoxVFS_Mount: failed to alloc memory for root node.\n"));
     456        rc = ENOMEM;
     457    }
     458
     459    /* Undo work in reverse. */
     460mntError1:           
     461    /* Just release the mount location. */
     462    VOP_CLOSE(pVNodeDev, (pVFS->vfs_flag & VFS_RDONLY) ? FREAD : FREAD | FWRITE, 1, (offset_t)0, pCred, NULL);
     463    VN_RELE(pVNodeDev);       
     464    return rc;
    489465}
    490466
     
    504480    }
    505481
     482    /* @todo -XXX - Not sure of supporting force unmounts. What this means is that a failed force mount could bring down
     483     * the entire system as hanging about vnode releases would no longer be valid after unloading ourselves...
     484     */
    506485    if (fUnmount & MS_FORCE)
    507486        pVFS->vfs_flag |= VFS_UNMOUNTED;
     
    517496    VN_RELE(VBOXVN_TO_VN(pVBoxVFSGlobalInfo->pVNodeRoot));
    518497
     498    RTMemFree(pVBoxVFSGlobalInfo->pVNodeRoot->pPath);
     499    RTMemFree(pVBoxVFSGlobalInfo->pVNodeRoot);
    519500    RTMemFree(pVBoxVFSGlobalInfo);
     501    pVBoxVFSGlobalInfo = NULL;
    520502    pVFS->vfs_data = NULL;
    521503
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