VirtualBox

Changeset 33867 in vbox


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

vfsbase.cpp: build fix and adding RTVfsNewIoStream.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/iprt/vfslowlevel.h

    r33861 r33867  
    523523/** The RTVFSIOSTREAMOPS structure version. */
    524524#define RTVFSIOSTREAMOPS_VERSION    RT_MAKE_U32_FROM_U8(0xff,0x5f,1,0)
     525
     526
     527/**
     528 * Creates a new VFS I/O stream handle.
     529 *
     530 * @returns IPRT status code
     531 * @param   pIoStreamOps        The I/O stream operations.
     532 * @param   cbInstance          The size of the instance data.
     533 * @param   fOpen               The open flags.  The minimum is the access mask.
     534 * @param   hVfs                The VFS handle to associate this file with.
     535 *                              NIL_VFS is ok.
     536 * @param   hSemRW              The read-write semaphore to use to protect the
     537 *                              handle if this differs from the one the VFS
     538 *                              uses.  NIL_RTSEMRW is ok if no locking is
     539 *                              desired.
     540 * @param   phVfsIos            Where to return the new handle.
     541 * @param   ppvInstance         Where to return the pointer to the instance data
     542 *                              (size is @a cbInstance).
     543 */
     544RTDECL(int) RTVfsNewStream(PCRTVFSIOSTREAMOPS pIoStreamOps, size_t cbInstance, uint32_t fOpen, RTVFS hVfs, RTSEMRW hSemRW,
     545                           PRTVFSIOSTREAM phVfsIos, void **ppvInstance);
    525546
    526547
  • 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