VirtualBox

Changeset 33867 in vbox for trunk/src


Ignore:
Timestamp:
Nov 8, 2010 6:54:57 PM (14 years ago)
Author:
vboxsync
Message:

vfsbase.cpp: build fix and adding RTVfsNewIoStream.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Runtime/common/vfs/vfsbase.cpp

    r33859 r33867  
    530530    AssertPtr(pPath);
    531531    AssertPtr(ppVfsParentDir);
     532    *ppVfsParentDir = NULL;
    532533    AssertReturn(pPath->cComponents > 0, VERR_INTERNAL_ERROR_3);
    533534
     
    776777 */
    777778
     779RTDECL(int) RTVfsNewIoStream(PCRTVFSIOSTREAMOPS pIoStreamOps, size_t cbInstance, uint32_t fOpen, RTVFS hVfs, RTSEMRW hSemRW,
     780                             PRTVFSIOSTREAM phVfsIos, void **ppvInstance)
     781{
     782    /*
     783     * Validate the input, be extra strict in strict builds.
     784     */
     785    AssertPtr(pIoStreamOps);
     786    AssertReturn(pIoStreamOps->uVersion   == RTVFSIOSTREAMOPS_VERSION, VERR_VERSION_MISMATCH);
     787    AssertReturn(pIoStreamOps->uEndMarker == RTVFSIOSTREAMOPS_VERSION, VERR_VERSION_MISMATCH);
     788    Assert(!pIoStreamOps->fReserved);
     789    Assert(cbInstance > 0);
     790    Assert(fOpen & RTFILE_O_ACCESS_MASK);
     791    AssertPtr(ppvInstance);
     792    AssertPtr(phVfsIos);
     793
     794    RTVFSINTERNAL *pVfs = NULL;
     795    if (hVfs == NIL_RTVFS)
     796    {
     797        pVfs = hVfs;
     798        AssertPtrReturn(pVfs, VERR_INVALID_HANDLE);
     799        AssertReturn(pVfs->uMagic == RTVFS_MAGIC, VERR_INVALID_HANDLE);
     800    }
     801
     802    /*
     803     * Allocate the handle + instance data.
     804     */
     805    size_t const cbThis = RT_ALIGN_Z(sizeof(RTVFSIOSTREAMINTERNAL), RTVFS_INST_ALIGNMENT)
     806                        + RT_ALIGN_Z(cbInstance, RTVFS_INST_ALIGNMENT);
     807    RTVFSIOSTREAMINTERNAL *pThis = (RTVFSIOSTREAMINTERNAL *)RTMemAllocZ(cbThis);
     808    if (!pThis)
     809        return VERR_NO_MEMORY;
     810
     811    pThis->uMagic   = RTVFSIOSTREAM_MAGIC;
     812    pThis->fFlags   = fOpen;
     813    pThis->pvThis   = (char *)pThis + RT_ALIGN_Z(sizeof(*pThis), RTVFS_INST_ALIGNMENT);
     814    pThis->pOps     = pIoStreamOps;
     815    pThis->hSemRW   = hSemRW != NIL_RTSEMRW ? hSemRW : pVfs ? pVfs->hSemRW : NIL_RTSEMRW;
     816    pThis->hVfs     = hVfs;
     817    pThis->cRefs    = 1;
     818    if (hVfs != NIL_RTVFS)
     819        rtVfsRetainVoid(&pVfs->cRefs);
     820
     821    *phVfsIos    = pThis;
     822    *ppvInstance = pThis->pvThis;
     823    return VINF_SUCCESS;
     824}
     825
     826
    778827RTDECL(uint32_t)    RTVfsIoStrmRetain(RTVFSIOSTREAM hVfsIos)
    779828{
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