VirtualBox

Changeset 33973 in vbox for trunk/src/VBox/Runtime/common


Ignore:
Timestamp:
Nov 11, 2010 11:10:10 AM (14 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
67635
Message:

vfs: the gunzip stream works, except for some double frees somewhere.

Location:
trunk/src/VBox/Runtime/common
Files:
1 added
4 edited

Legend:

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

    r33948 r33973  
    10841084
    10851085
    1086 RTDECL(int) RTVfsNewIoStream(PCRTVFSFSSTREAMOPS pFsStreamOps, size_t cbInstance, RTVFS hVfs, RTSEMRW hSemRW,
     1086RTDECL(int) RTVfsNewFsStream(PCRTVFSFSSTREAMOPS pFsStreamOps, size_t cbInstance, RTVFS hVfs, RTSEMRW hSemRW,
    10871087                             PRTVFSFSSTREAM phVfsFss, void **ppvInstance)
    10881088{
     
    12311231
    12321232    RTVFSINTERNAL *pVfs = NULL;
    1233     if (hVfs == NIL_RTVFS)
     1233    if (hVfs != NIL_RTVFS)
    12341234    {
    12351235        pVfs = hVfs;
     
    12521252    pThis->Base.uMagic  = RTVFSOBJ_MAGIC;
    12531253    pThis->Base.pvThis  = (char *)pThis + RT_ALIGN_Z(sizeof(*pThis), RTVFS_INST_ALIGNMENT);
     1254    pThis->Base.pOps    = &pIoStreamOps->Obj;
    12541255    pThis->Base.hSemRW  = hSemRW != NIL_RTSEMRW ? hSemRW : pVfs ? pVfs->Base.hSemRW : NIL_RTSEMRW;
    12551256    pThis->Base.hVfs    = hVfs;
     
    12991300
    13001301
    1301 RTDECL(int)         RTVfsIoStrmQueryInfo(RTVFSIOSTREAM hVfsIos, PRTFSOBJINFO pObjInfo, RTFSOBJATTRADD enmAddAttr)
     1302RTDECL(int) RTVfsIoStrmQueryInfo(RTVFSIOSTREAM hVfsIos, PRTFSOBJINFO pObjInfo, RTFSOBJATTRADD enmAddAttr)
    13021303{
    13031304    RTVFSIOSTREAMINTERNAL *pThis = hVfsIos;
     
    13081309
    13091310
    1310 RTDECL(int)         RTVfsIoStrmRead(RTVFSIOSTREAM hVfsIos, void *pvBuf, size_t cbToRead, size_t *pcbRead)
     1311RTDECL(int) RTVfsIoStrmRead(RTVFSIOSTREAM hVfsIos, void *pvBuf, size_t cbToRead, bool fBlocking, size_t *pcbRead)
    13111312{
    13121313    AssertPtrNullReturn(pcbRead, VERR_INVALID_POINTER);
     
    13161317    AssertPtrReturn(pThis, VERR_INVALID_HANDLE);
    13171318    AssertReturn(pThis->uMagic == RTVFSIOSTREAM_MAGIC, VERR_INVALID_HANDLE);
     1319    AssertReturn(fBlocking || pcbRead, VERR_INVALID_PARAMETER);
    13181320
    13191321    RTSGSEG Seg = { pvBuf, cbToRead };
     
    13221324
    13231325    rtVfsObjWriteLock(&pThis->Base);
    1324     int rc = pThis->pOps->pfnRead(pThis->Base.pvThis, -1 /*off*/, &SgBuf, pcbRead == NULL /*fBlocking*/, pcbRead);
     1326    int rc = pThis->pOps->pfnRead(pThis->Base.pvThis, -1 /*off*/, &SgBuf, fBlocking, pcbRead);
    13251327    rtVfsObjWriteUnlock(&pThis->Base);
    13261328    return rc;
     
    13281330
    13291331
    1330 RTDECL(int)         RTVfsIoStrmWrite(RTVFSIOSTREAM hVfsIos, const void *pvBuf, size_t cbToWrite, size_t *pcbWritten)
     1332RTDECL(int) RTVfsIoStrmWrite(RTVFSIOSTREAM hVfsIos, const void *pvBuf, size_t cbToWrite, bool fBlocking, size_t *pcbWritten)
    13311333{
    13321334    AssertPtrNullReturn(pcbWritten, VERR_INVALID_POINTER);
     
    13361338    AssertPtrReturn(pThis, VERR_INVALID_HANDLE);
    13371339    AssertReturn(pThis->uMagic == RTVFSIOSTREAM_MAGIC, VERR_INVALID_HANDLE);
     1340    AssertReturn(fBlocking || pcbWritten, VERR_INVALID_PARAMETER);
    13381341
    13391342    RTSGSEG Seg = { (void *)pvBuf, cbToWrite };
     
    13421345
    13431346    rtVfsObjWriteLock(&pThis->Base);
    1344     int rc = pThis->pOps->pfnWrite(pThis->Base.pvThis, -1 /*off*/, &SgBuf, pcbWritten == NULL /*fBlocking*/, pcbWritten);
     1347    int rc = pThis->pOps->pfnWrite(pThis->Base.pvThis, -1 /*off*/, &SgBuf, fBlocking, pcbWritten);
    13451348    rtVfsObjWriteUnlock(&pThis->Base);
    13461349    return rc;
     
    13481351
    13491352
    1350 RTDECL(int)         RTVfsIoStrmSgRead(RTVFSIOSTREAM hVfsIos, PCRTSGBUF pSgBuf, bool fBlocking, size_t *pcbRead)
     1353RTDECL(int) RTVfsIoStrmSgRead(RTVFSIOSTREAM hVfsIos, PCRTSGBUF pSgBuf, bool fBlocking, size_t *pcbRead)
    13511354{
    13521355    AssertPtrNullReturn(pcbRead, VERR_INVALID_POINTER);
     
    13661369
    13671370
    1368 RTDECL(int)         RTVfsIoStrmSgWrite(RTVFSIOSTREAM hVfsIos, PCRTSGBUF pSgBuf, bool fBlocking, size_t *pcbWritten)
     1371RTDECL(int) RTVfsIoStrmSgWrite(RTVFSIOSTREAM hVfsIos, PCRTSGBUF pSgBuf, bool fBlocking, size_t *pcbWritten)
    13691372{
    13701373    AssertPtrNullReturn(pcbWritten, VERR_INVALID_POINTER);
     
    13841387
    13851388
    1386 RTDECL(int)         RTVfsIoStrmFlush(RTVFSIOSTREAM hVfsIos)
     1389RTDECL(int) RTVfsIoStrmFlush(RTVFSIOSTREAM hVfsIos)
    13871390{
    13881391    RTVFSIOSTREAMINTERNAL *pThis = hVfsIos;
     
    13971400
    13981401
    1399 RTDECL(RTFOFF)      RTVfsIoStrmPoll(RTVFSIOSTREAM hVfsIos, uint32_t fEvents, RTMSINTERVAL cMillies, bool fIntr,
    1400                                     uint32_t *pfRetEvents)
     1402RTDECL(RTFOFF) RTVfsIoStrmPoll(RTVFSIOSTREAM hVfsIos, uint32_t fEvents, RTMSINTERVAL cMillies, bool fIntr,
     1403                               uint32_t *pfRetEvents)
    14011404{
    14021405    RTVFSIOSTREAMINTERNAL *pThis = hVfsIos;
     
    14111414
    14121415
    1413 RTDECL(RTFOFF)      RTVfsIoStrmTell(RTVFSIOSTREAM hVfsIos)
     1416RTDECL(RTFOFF) RTVfsIoStrmTell(RTVFSIOSTREAM hVfsIos)
    14141417{
    14151418    RTVFSIOSTREAMINTERNAL *pThis = hVfsIos;
     
    14271430
    14281431
    1429 RTDECL(int)         RTVfsIoStrmSkip(RTVFSIOSTREAM hVfsIos, RTFOFF cb)
     1432RTDECL(int) RTVfsIoStrmSkip(RTVFSIOSTREAM hVfsIos, RTFOFF cb)
    14301433{
    14311434    RTVFSIOSTREAMINTERNAL *pThis = hVfsIos;
     
    14511454                size_t cbToRead = RT_MIN(cb, _64K);
    14521455                rtVfsObjWriteLock(&pThis->Base);
    1453                 rc = RTVfsIoStrmRead(hVfsIos, pvBuf, cbToRead, NULL);
     1456                rc = RTVfsIoStrmRead(hVfsIos, pvBuf, cbToRead, true /*fBlocking*/, NULL);
    14541457                rtVfsObjWriteUnlock(&pThis->Base);
    14551458                if (RT_FAILURE(rc))
     
    14671470
    14681471
    1469 RTDECL(int)         RTVfsIoStrmZeroFill(RTVFSIOSTREAM hVfsIos, RTFOFF cb)
     1472RTDECL(int) RTVfsIoStrmZeroFill(RTVFSIOSTREAM hVfsIos, RTFOFF cb)
    14701473{
    14711474    RTVFSIOSTREAMINTERNAL *pThis = hVfsIos;
     
    14901493                size_t cbToWrite = RT_MIN(cb, _64K);
    14911494                rtVfsObjWriteLock(&pThis->Base);
    1492                 rc = RTVfsIoStrmWrite(hVfsIos, pvBuf, cbToWrite, NULL);
     1495                rc = RTVfsIoStrmWrite(hVfsIos, pvBuf, cbToWrite, true /*fBlocking*/, NULL);
    14931496                rtVfsObjWriteUnlock(&pThis->Base);
    14941497                if (RT_FAILURE(rc))
     
    15341537
    15351538    RTVFSINTERNAL *pVfs = NULL;
    1536     if (hVfs == NIL_RTVFS)
     1539    if (hVfs != NIL_RTVFS)
    15371540    {
    15381541        pVfs = hVfs;
     
    15571560    pThis->Stream.pOps          = &pFileOps->Stream;
    15581561    pThis->Stream.Base.pvThis   = (char *)pThis + RT_ALIGN_Z(sizeof(*pThis), RTVFS_INST_ALIGNMENT);
     1562    pThis->Stream.Base.pOps     = &pFileOps->Stream.Obj;
    15591563    pThis->Stream.Base.hSemRW   = pVfs ? pVfs->Base.hSemRW : NIL_RTSEMRW;
    15601564    pThis->Stream.Base.hVfs     = hVfs;
  • trunk/src/VBox/Runtime/common/vfs/vfschain.cpp

    r33950 r33973  
    431431        }
    432432
    433 
    434433        /*
    435434         * Ok, there should be an element here so add one to the return struct.
     
    440439        pElement->enmAction = enmAction;
    441440
    442         /* First comes a type which is followed by a '('. */
     441        /*
     442         * First up is the VFS object type followed by a parentheses.
     443         */
    443444        if (strncmp(pszSrc, "base", cch = 4) == 0)
    444445            pElement->enmTypeOut = RTVFSOBJTYPE_BASE;
     
    495496        }
    496497
    497         /* Must end with a right parantheses. */
     498        /* Must end with a right parentheses. */
    498499        if (*pszSrc != ')')
    499500        {
     
    657658
    658659
     660RTDECL(bool) RTVfsChainIsSpec(const char *pszSpec)
     661{
     662    return pszSpec
     663        && strcmp(pszSpec, RTVFSCHAIN_SPEC_PREFIX) == 0;
     664}
     665
  • trunk/src/VBox/Runtime/common/vfs/vfsstdfile.cpp

    r33903 r33973  
    446446}
    447447
     448
     449RTDECL(int)         RTVfsIoStrmFromRTFile(RTFILE hFile, uint32_t fOpen, bool fLeaveOpen, PRTVFSIOSTREAM phVfsIos)
     450{
     451    RTVFSFILE hVfsFile;
     452    int rc = RTVfsFileFromRTFile(hFile, fOpen, fLeaveOpen, &hVfsFile);
     453    if (RT_SUCCESS(rc))
     454        *phVfsIos = RTVfsFileToIoStream(hVfsFile);
     455    return rc;
     456}
     457
     458
     459
  • trunk/src/VBox/Runtime/common/zip/zipgzip.cpp

    r33945 r33973  
    3030*******************************************************************************/
    3131#include "internal/iprt.h"
    32 #include <iprt/vfslowlevel.h>
     32#include <iprt/zip.h>
    3333
    3434#include <iprt/assert.h>
     
    3737#include <iprt/poll.h>
    3838#include <iprt/string.h>
     39#include <iprt/vfslowlevel.h>
     40
    3941#include <zlib.h>
    4042
     
    477479    AssertPtrReturn(phVfsIosOut, VERR_INVALID_POINTER);
    478480
     481    uint32_t cRefs = RTVfsIoStrmRetain(hVfsIosIn);
     482    AssertReturn(cRefs != UINT32_MAX, VERR_INVALID_HANDLE);
     483
    479484    /*
    480485     * Create the decompression I/O stream.
     
    507512             */
    508513            size_t cbRead = 0;
    509             rc = RTVfsIoStrmRead(pThis->hVfsIos, pThis->abBuffer, sizeof(RTZIPGZIPHDR), NULL /*pcbRead*/);
     514            rc = RTVfsIoStrmRead(pThis->hVfsIos, pThis->abBuffer, sizeof(RTZIPGZIPHDR), true /*fBlocking*/, NULL /*pcbRead*/);
    510515            if (RT_SUCCESS(rc))
    511516            {
     
    539544        }
    540545        else
    541             rc = rtZipGzipConvertErrFromZlib(pThis, rc);
     546            rc = rtZipGzipConvertErrFromZlib(pThis, rc); /** @todo cleaning up in this situation is going to go wrong. */
     547        RTVfsIoStrmRelease(hVfsIos);
    542548    }
     549    else
     550        RTVfsIoStrmRelease(hVfsIosIn);
    543551    return rc;
    544552}
Note: See TracChangeset for help on using the changeset viewer.

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