VirtualBox

Changeset 77256 in vbox


Ignore:
Timestamp:
Feb 11, 2019 12:19:52 PM (6 years ago)
Author:
vboxsync
Message:

Runtime/RTDvm: Add flag to indicate that a volume is contiguous on the underlying medium and add method to query start and end offset of the volume

Location:
trunk
Files:
8 edited

Legend:

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

    r76585 r77256  
    121121
    122122
    123 /** @defgroup grp_dvm_vol_flags     Volume flags used by DVMVolumeGetFlags.
     123/** @defgroup grp_dvm_vol_flags     Volume flags used by RTDvmVolumeGetFlags().
    124124 * @{ */
    125125/** Volume flags - Volume is bootable. */
     
    127127/** Volume flags - Volume is active. */
    128128#define DVMVOLUME_FLAGS_ACTIVE      RT_BIT_64(1)
     129/** Volume is contiguous on the underlying medium and RTDvmVolumeQueryRange(). */
     130#define DVMVOLUME_F_CONTIGUOUS      RT_BIT_64(2)
    129131/** @}  */
    130132
     
    224226    RTDVMFORMATTYPE_GPT,
    225227    /** BSD labels. */
    226     RTDVMFORMATTYPE_BSD_LABLE,
     228    RTDVMFORMATTYPE_BSD_LABEL,
    227229    /** End of valid values. */
    228230    RTDVMFORMATTYPE_END,
     
    354356
    355357/**
     358 * Queries the range of the given volume on the underyling medium.
     359 *
     360 * @returns IPRT status code.
     361 * @retval  VERR_NOT_SUPPORTED if the DVMVOLUME_F_CONTIGUOUS flag is not returned by RTDvmVolumeGetFlags().
     362 * @param   hVol            The volume handle.
     363 * @param   poffStart       Where to store the start offset in bytes on the underlying medium.
     364 * @param   poffEnd         Where to store the end offset in bytes on the underlying medium (inclusive).
     365 */
     366RTDECL(int) RTDvmVolumeQueryRange(RTDVMVOLUME hVol, uint64_t *poffStart, uint64_t *poffEnd);
     367
     368/**
    356369 * Reads data from the given volume.
    357370 *
  • trunk/include/iprt/mangling.h

    r77047 r77256  
    829829# define RTDvmVolumeGetType                             RT_MANGLER(RTDvmVolumeGetType)
    830830# define RTDvmVolumeGetFlags                            RT_MANGLER(RTDvmVolumeGetFlags)
     831# define RTDvmVolumeQueryRange                          RT_MANGLER(RTDvmVolumeQueryRange)
    831832# define RTDvmVolumeRead                                RT_MANGLER(RTDvmVolumeRead)
    832833# define RTDvmVolumeWrite                               RT_MANGLER(RTDvmVolumeWrite)
  • trunk/src/VBox/Runtime/common/dvm/dvm.cpp

    r76553 r77256  
    380380            }
    381381
    382             /** @todo shouldn't we close the format too here?  */
     382            pDvmFmtOpsMatch->pfnClose(pThis->hVolMgrFmt);
    383383        }
    384384    }
     
    663663}
    664664
     665RTDECL(int) RTDvmVolumeQueryRange(RTDVMVOLUME hVol, uint64_t *poffStart, uint64_t *poffEnd)
     666{
     667    PRTDVMVOLUMEINTERNAL pThis = hVol;
     668    AssertPtrReturn(pThis, VERR_INVALID_HANDLE);
     669    AssertReturn(pThis->u32Magic == RTDVMVOLUME_MAGIC, VERR_INVALID_HANDLE);
     670    AssertPtrReturn(poffStart, VERR_INVALID_POINTER);
     671    AssertPtrReturn(poffEnd, VERR_INVALID_POINTER);
     672
     673    return pThis->pVolMgr->pDvmFmtOps->pfnVolumeQueryRange(pThis->hVolFmt, poffStart, poffEnd);
     674}
     675
    665676RTDECL(int) RTDvmVolumeRead(RTDVMVOLUME hVol, uint64_t off, void *pvBuf, size_t cbRead)
    666677{
  • trunk/src/VBox/Runtime/common/dvm/dvmbsdlabel.cpp

    r76553 r77256  
    480480{
    481481    NOREF(hVolFmt);
    482     return 0;
     482    return DVMVOLUME_F_CONTIGUOUS;
     483}
     484
     485static DECLCALLBACK(int) rtDvmFmtBsdLblVolumeQueryRange(RTDVMVOLUMEFMT hVolFmt, uint64_t *poffStart, uint64_t *poffEnd)
     486{
     487    PRTDVMVOLUMEFMTINTERNAL pVol = hVolFmt;
     488    *poffStart = pVol->offStart;
     489    *poffEnd   = pVol->offStart + pVol->cbVolume - 1;
     490    return VINF_SUCCESS;
    483491}
    484492
     
    522530    "BsdLabel",
    523531    /* enmFormat, */
    524     RTDVMFORMATTYPE_BSD_LABLE,
     532    RTDVMFORMATTYPE_BSD_LABEL,
    525533    /* pfnProbe */
    526534    rtDvmFmtBsdLblProbe,
     
    551559    /* pfnVolumeGetFlags */
    552560    rtDvmFmtBsdLblVolumeGetFlags,
     561    /* pfnVolumeQueryRange */
     562    rtDvmFmtBsdLblVolumeQueryRange,
    553563    /* pfnVolumeIsRangeIntersecting */
    554564    rtDvmFmtBsdLblVolumeIsRangeIntersecting,
  • trunk/src/VBox/Runtime/common/dvm/dvmgpt.cpp

    r76553 r77256  
    493493static DECLCALLBACK(uint64_t) rtDvmFmtGptVolumeGetFlags(RTDVMVOLUMEFMT hVolFmt)
    494494{
    495     NOREF(hVolFmt); /* No supported flags for now. */
    496     return 0;
     495    NOREF(hVolFmt);
     496    return DVMVOLUME_F_CONTIGUOUS;
     497}
     498
     499static DECLCALLBACK(int) rtDvmFmtGptVolumeQueryRange(RTDVMVOLUMEFMT hVolFmt, uint64_t *poffStart, uint64_t *poffEnd)
     500{
     501    PRTDVMVOLUMEFMTINTERNAL pVol = hVolFmt;
     502    *poffStart = pVol->offStart;
     503    *poffEnd   = pVol->offStart + pVol->cbVolume - 1;
     504    return VINF_SUCCESS;
    497505}
    498506
     
    563571    /* pfnVolumeGetFlags */
    564572    rtDvmFmtGptVolumeGetFlags,
     573    /* pfnVolumeQueryRange */
     574    rtDvmFmtGptVolumeQueryRange,
    565575    /* pfnVolumeIsRangeIntersecting */
    566576    rtDvmFmtGptVolumeIsRangeIntersecting,
  • trunk/src/VBox/Runtime/common/dvm/dvmmbr.cpp

    r76553 r77256  
    641641    PRTDVMVOLUMEFMTINTERNAL pVol = hVolFmt;
    642642
    643     uint64_t fFlags = 0;
     643    uint64_t fFlags = DVMVOLUME_F_CONTIGUOUS;
    644644    if (pVol->pEntry->bType & 0x80)
    645645        fFlags |= DVMVOLUME_FLAGS_BOOTABLE | DVMVOLUME_FLAGS_ACTIVE;
    646646
    647647    return fFlags;
     648}
     649
     650static DECLCALLBACK(int) rtDvmFmtMbrVolumeQueryRange(RTDVMVOLUMEFMT hVolFmt, uint64_t *poffStart, uint64_t *poffEnd)
     651{
     652    PRTDVMVOLUMEFMTINTERNAL pVol = hVolFmt;
     653    *poffStart = pVol->pEntry->offPart;
     654    *poffEnd   = pVol->pEntry->offPart + pVol->pEntry->cbPart - 1;
     655    return VINF_SUCCESS;
    648656}
    649657
     
    712720    /* pfnVolumeGetFlags */
    713721    rtDvmFmtMbrVolumeGetFlags,
     722    /* pfnVolumeQueryRange */
     723    rtDvmFmtMbrVolumeQueryRange,
    714724    /* pfnVOlumeIsRangeIntersecting */
    715725    rtDvmFmtMbrVolumeIsRangeIntersecting,
  • trunk/src/VBox/Runtime/include/internal/dvm.h

    r76585 r77256  
    216216
    217217    /**
     218     * Queries the range of the given volume on the underyling medium.
     219     *
     220     * @returns IPRT status code.
     221     * @param   hVolFmt         The format specific volume handle.
     222     * @param   poffStart       Where to store the start offset in bytes on the underlying medium.
     223     * @param   poffEnd         Where to store the end offset in bytes on the underlying medium (inclusive).
     224     */
     225    DECLCALLBACKMEMBER(int, pfnVolumeQueryRange)(RTDVMVOLUMEFMT hVolFmt, uint64_t *poffStart, uint64_t *poffEnd);
     226
     227    /**
    218228     * Returns whether the supplied range is at least partially intersecting
    219229     * with the given volume.
  • trunk/src/VBox/Runtime/testcase/tstRTDvm.cpp

    r76905 r77256  
    7171    {
    7272        RTTestIFailed("RTDvmOpen -> %Rrc", rc);
     73        RTDvmRelease(hVolMgr);
    7374        return RTTestSummaryAndDestroy(hTest);
    7475    }
    7576    if (rc == VERR_NOT_SUPPORTED)
     77    {
     78        RTDvmRelease(hVolMgr);
    7679        return VINF_SUCCESS;
     80    }
    7781
    7882    RTTestIPrintf(RTTESTLVL_ALWAYS, "%s Successfully opened map with format: %s.\n", szPrefix, RTDvmMapGetFormatName(hVolMgr));
     
    9498        RTTestIPrintf(RTTESTLVL_ALWAYS, "%s Volume type  %s\n", szPrefix, RTDvmVolumeTypeGetDescr(enmVolType));
    9599        RTTestIPrintf(RTTESTLVL_ALWAYS, "%s Volume size  %llu\n", szPrefix, RTDvmVolumeGetSize(hVol));
    96         RTTestIPrintf(RTTESTLVL_ALWAYS, "%s Volume flags %s %s\n\n", szPrefix,
     100        RTTestIPrintf(RTTESTLVL_ALWAYS, "%s Volume flags %s %s %s\n", szPrefix,
    97101                      fVolFlags & DVMVOLUME_FLAGS_BOOTABLE ? "Bootable" : "",
    98                       fVolFlags & DVMVOLUME_FLAGS_ACTIVE ? "Active" : "");
     102                      fVolFlags & DVMVOLUME_FLAGS_ACTIVE ? "Active" : "",
     103                      fVolFlags & DVMVOLUME_F_CONTIGUOUS ? "Contiguous" : "");
    99104
    100105        rc = RTDvmVolumeQueryName(hVol, &pszVolName);
     
    108113        else
    109114            rc = VINF_SUCCESS;
     115
     116        if (fVolFlags & DVMVOLUME_F_CONTIGUOUS)
     117        {
     118            uint64_t offStart, offEnd;
     119            rc = RTDvmVolumeQueryRange(hVol, &offStart, &offEnd);
     120            if (RT_SUCCESS(rc))
     121                RTTestIPrintf(RTTESTLVL_ALWAYS, "%s Volume range %llu:%llu\n", szPrefix, offStart, offEnd);
     122            else
     123                RTTestIFailed("RTDvmVolumeQueryRange -> %Rrc", rc);
     124        }
     125
     126        RTTestIPrintf(RTTESTLVL_ALWAYS, "\n");
    110127
    111128        /*
     
    185202    RTTESTI_CHECK(rc == VINF_SUCCESS);
    186203
     204    RTVfsFileRelease(hVfsDisk);
     205
    187206    /*
    188207     * Summary
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