VirtualBox

Ignore:
Timestamp:
Jun 1, 2012 5:29:05 PM (13 years ago)
Author:
vboxsync
Message:

VFS/Filesystem: Convert the filesystem specific code to the VFS framework and make it work

Location:
trunk/src/VBox/Runtime/common/filesystem
Files:
2 edited

Legend:

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

    r40038 r41549  
    4141
    4242/*******************************************************************************
    43 *   Structures and Typedefs                                                    *
    44 *******************************************************************************/
    45 
    46 /**
    47  * Medium descriptor.
    48  */
    49 typedef struct RTFILESYSTEMMEDIUMINT
    50 {
    51     /** Size of the medium in bytes. */
    52     uint64_t                cbMedium;
    53     /** Sector size. */
    54     uint64_t                cbSector;
    55     /** Read callback */
    56     PFNRTFILESYSTEMREAD     pfnRead;
    57     /** Write callback. */
    58     PFNRTFILESYSTEMWRITE    pfnWrite;
    59     /** Opaque user data. */
    60     void                    *pvUser;
    61 } RTFILESYSTEMMEDIUMINT;
    62 /** Pointer to a disk descriptor. */
    63 typedef RTFILESYSTEMMEDIUMINT *PRTFILESYSTEMMEDIUMINT;
    64 /** Pointer to a const descriptor. */
    65 typedef const RTFILESYSTEMMEDIUMINT *PCRTFILESYSTEMMEDIUMINT;
    66 
    67 /**
    68  * The internal filesystem object structure.
    69  */
    70 typedef struct RTFILESYSTEMINT
    71 {
    72     /** The filesytem object magic (RTFILESYSTEM_MAGIC). */
    73     uint32_t              u32Magic;
    74     /** Medium descriptor. */
    75     RTFILESYSTEMMEDIUMINT Medium;
    76     /** Filesystem format operations */
    77     PCRTFILESYSTEMFMTOPS  pcFsFmtOps;
    78     /** Filesystem format handle. */
    79     RTFILESYSTEMFMT       hFsFmt;
    80     /** Reference counter. */
    81     uint32_t volatile     cRefs;
    82 } RTFILESYSTEMINT;
    83 /** Pointer to an internal volume manager. */
    84 typedef RTFILESYSTEMINT *PRTFILESYSTEMINT;
    85 
    86 /*******************************************************************************
    8743*  Global variables                                                            *
    8844*******************************************************************************/
    89 extern RTFILESYSTEMFMTOPS g_rtFilesystemFmtExt;
    9045
    9146/**
    9247 * Supported volume formats.
    9348 */
    94 static PCRTFILESYSTEMFMTOPS g_aFilesystemFmts[] =
     49static PCRTFILESYSTEMDESC g_aFsFmts[] =
    9550{
    96     &g_rtFilesystemFmtExt
     51    &g_rtFsExt
    9752};
    9853
    99 DECLHIDDEN(uint64_t) rtFilesystemMediumGetSize(RTFILESYSTEMMEDIUM hMedium)
    100 {
    101     PRTFILESYSTEMMEDIUMINT pMedInt = hMedium;
    102     AssertPtrReturn(pMedInt, 0);
    103 
    104     return pMedInt->cbMedium;
    105 }
    106 
    107 DECLHIDDEN(int) rtFilesystemMediumRead(RTFILESYSTEMMEDIUM hMedium, uint64_t off,
    108                                        void *pvBuf, size_t cbRead)
    109 {
    110     PRTFILESYSTEMMEDIUMINT pMedInt = hMedium;
    111     AssertPtrReturn(pMedInt, VERR_INVALID_HANDLE);
    112 
    113     return pMedInt->pfnRead(pMedInt->pvUser, off, pvBuf, cbRead);
    114 }
    115 
    116 DECLHIDDEN(int) rtFilesystemMediumWrite(RTFILESYSTEMMEDIUM hMedium, uint64_t off,
    117                                         const void *pvBuf, size_t cbWrite)
    118 {
    119     PRTFILESYSTEMMEDIUMINT pMedInt = hMedium;
    120     AssertPtrReturn(pMedInt, VERR_INVALID_HANDLE);
    121 
    122     return pMedInt->pfnWrite(pMedInt->pvUser, off, pvBuf, cbWrite);
    123 }
    124 
    125 RTDECL(uint32_t) RTFilesystemRetain(RTFILESYSTEM hFs)
    126 {
    127     PRTFILESYSTEMINT pThis = hFs;
    128     AssertPtrReturn(pThis, UINT32_MAX);
    129     AssertReturn(pThis->u32Magic == RTFILESYSTEM_MAGIC, UINT32_MAX);
    130 
    131     uint32_t cRefs = ASMAtomicIncU32(&pThis->cRefs);
    132     AssertMsg(cRefs > 1 && cRefs < _1M, ("%#x %p\n", cRefs, pThis));
    133     return cRefs;
    134 }
    135 
    136 /**
    137  * Destroys a volume manager handle.
    138  *
    139  * @param   pThis               The filesystem object to destroy.
    140  */
    141 static void rtFilesystemDestroy(PRTFILESYSTEMINT pThis)
    142 {
    143     if (pThis->hFsFmt != NIL_RTFILESYSTEMFMT)
    144     {
    145         AssertPtr(pThis->pcFsFmtOps);
    146 
    147         /* Let the backend do it's own cleanup first. */
    148         pThis->pcFsFmtOps->pfnClose(pThis->hFsFmt);
    149         pThis->hFsFmt = NIL_RTFILESYSTEMFMT;
    150     }
    151 
    152     pThis->Medium.cbMedium   = 0;
    153     pThis->Medium.pvUser   = NULL;
    154     pThis->Medium.pfnRead  = NULL;
    155     pThis->Medium.pfnWrite = NULL;
    156     pThis->u32Magic        = RTFILESYSTEM_MAGIC_DEAD;
    157     RTMemFree(pThis);
    158 }
    159 
    160 RTDECL(uint32_t) RTFilesystemRelease(RTFILESYSTEM hFs)
    161 {
    162     PRTFILESYSTEMINT pThis = hFs;
    163     if (pThis == NIL_RTFILESYSTEM)
    164         return 0;
    165     AssertPtrReturn(pThis, UINT32_MAX);
    166     AssertReturn(pThis->u32Magic == RTFILESYSTEM_MAGIC, UINT32_MAX);
    167 
    168     uint32_t cRefs = ASMAtomicDecU32(&pThis->cRefs);
    169     AssertMsg(cRefs < _1M, ("%#x %p\n", cRefs, pThis));
    170     if (cRefs == 0)
    171         rtFilesystemDestroy(pThis);
    172     return cRefs;
    173 }
    174 
    175 RTDECL(int) RTFilesystemOpen(PRTFILESYSTEM phFs, PFNRTFILESYSTEMREAD pfnRead,
    176                              PFNRTFILESYSTEMWRITE pfnWrite, uint64_t cbMedium,
    177                              uint64_t cbSector, void *pvUser, uint32_t fFlags)
     54static int rtFsGetFormat(RTVFSFILE hVfsFile, PCRTFILESYSTEMDESC *ppFsDesc)
    17855{
    17956    int                   rc = VINF_SUCCESS;
    18057    uint32_t              uScoreMax = RTFILESYSTEM_MATCH_SCORE_UNSUPPORTED;
    181     PCRTFILESYSTEMFMTOPS  pcFsFmtOpsMatch = NULL;
    182     PRTFILESYSTEMINT      pThis = NULL;
    183     AssertPtrReturn(phFs, VERR_INVALID_POINTER);
    184     AssertPtrReturn(pfnRead, VERR_INVALID_POINTER);
     58    PCRTFILESYSTEMDESC    pFsFmtMatch = NULL;
    18559
    186     pThis = (PRTFILESYSTEMINT)RTMemAllocZ(sizeof(RTFILESYSTEMINT));
    187     if (!pThis)
    188         return VERR_NO_MEMORY;
    189 
    190     pThis->u32Magic        = RTFILESYSTEM_MAGIC;
    191     pThis->Medium.cbMedium = cbMedium;
    192     pThis->Medium.cbSector = cbSector;
    193     pThis->Medium.pfnRead  = pfnRead;
    194     pThis->Medium.pfnWrite = pfnWrite;
    195     pThis->Medium.pvUser   = pvUser;
    196     pThis->cRefs           = 1;
    197 
    198     for (unsigned i = 0; i < RT_ELEMENTS(g_aFilesystemFmts); i++)
     60    for (unsigned i = 0; i < RT_ELEMENTS(g_aFsFmts); i++)
    19961    {
    20062        uint32_t uScore;
    201         PCRTFILESYSTEMFMTOPS pcFsFmtOps = g_aFilesystemFmts[i];
     63        PCRTFILESYSTEMDESC pFsFmt = g_aFsFmts[i];
    20264
    203         rc = pcFsFmtOps->pfnProbe(&pThis->Medium, &uScore);
     65        rc = pFsFmt->pfnProbe(hVfsFile, &uScore);
    20466        if (   RT_SUCCESS(rc)
    20567            && uScore > uScoreMax)
    20668        {
    207             pcFsFmtOpsMatch = pcFsFmtOps;
    208             uScoreMax       = uScore;
     69            pFsFmtMatch = pFsFmt;
     70            uScoreMax   = uScore;
    20971        }
    21072        else if (RT_FAILURE(rc))
     
    21678        if (uScoreMax > RTFILESYSTEM_MATCH_SCORE_UNSUPPORTED)
    21779        {
    218             AssertPtr(pcFsFmtOpsMatch);
    219 
    220             /* Open the format. */
    221             rc = pcFsFmtOpsMatch->pfnOpen(&pThis->Medium, &pThis->hFsFmt);
    222             if (RT_SUCCESS(rc))
    223                 pThis->pcFsFmtOps = pcFsFmtOpsMatch;
     80            AssertPtr(pFsFmtMatch);
     81            *ppFsDesc = pFsFmtMatch;
    22482        }
    22583        else
     
    22785    }
    22886
     87    return rc;
     88}
     89
     90RTDECL(int) RTFilesystemVfsFromFile(RTVFSFILE hVfsFile, PRTVFS phVfs)
     91{
     92    int rc = VINF_SUCCESS;
     93    PCRTFILESYSTEMDESC pFsDesc = NULL;
     94    RTVFS hVfs = NIL_RTVFS;
     95    void *pvThis = NULL;
     96
     97    AssertPtrReturn(hVfsFile, VERR_INVALID_HANDLE);
     98    AssertPtrReturn(phVfs, VERR_INVALID_POINTER);
     99
     100    rc = rtFsGetFormat(hVfsFile, &pFsDesc);
    229101    if (RT_SUCCESS(rc))
    230         *phFs = pThis;
    231     else
    232         RTMemFree(pThis);
     102    {
     103        rc = RTVfsNew(&pFsDesc->VfsOps, pFsDesc->cbFs, NIL_RTVFS, NIL_RTVFSLOCK,
     104                      &hVfs, &pvThis);
     105        if (RT_SUCCESS(rc))
     106        {
     107            rc = pFsDesc->pfnInit(pvThis, hVfsFile);
     108            if (RT_SUCCESS(rc))
     109                *phVfs = hVfs;
     110            else
     111                RTVfsRelease(hVfs);
     112        }
     113    }
    233114
    234115    return rc;
    235116}
    236117
    237 RTDECL(const char *) RTFilesystemGetFormat(RTFILESYSTEM hFs)
    238 {
    239     PRTFILESYSTEMINT pThis = hFs;
    240     AssertPtrReturn(pThis, NULL);
    241     AssertReturn(pThis->u32Magic == RTFILESYSTEM_MAGIC, NULL);
    242118
    243     return pThis->pcFsFmtOps->pcszFmt;
    244 }
    245 
    246 RTDECL(uint64_t) RTFilesystemGetBlockSize(RTFILESYSTEM hFs)
    247 {
    248     PRTFILESYSTEMINT pThis = hFs;
    249     AssertPtrReturn(pThis, 0);
    250     AssertReturn(pThis->u32Magic == RTFILESYSTEM_MAGIC, 0);
    251 
    252     return pThis->pcFsFmtOps->pfnGetBlockSize(pThis->hFsFmt);
    253 }
    254 
    255 RTDECL(int) RTFilesystemQueryRangeUse(RTFILESYSTEM hFs, uint64_t offStart, size_t cb,
    256                                       bool *pfUsed)
    257 {
    258     PRTFILESYSTEMINT pThis = hFs;
    259     AssertPtrReturn(pThis, VERR_INVALID_HANDLE);
    260     AssertReturn(pThis->u32Magic == RTFILESYSTEM_MAGIC, VERR_INVALID_HANDLE);
    261     AssertPtrReturn(pfUsed, VERR_INVALID_POINTER);
    262     AssertReturn(offStart + cb <= pThis->Medium.cbMedium, VERR_OUT_OF_RANGE);
    263 
    264     return pThis->pcFsFmtOps->pfnQueryRangeUse(pThis->hFsFmt, offStart, cb, pfUsed);
    265 }
  • trunk/src/VBox/Runtime/common/filesystem/filesystemext.cpp

    r40038 r41549  
    3535#include <iprt/filesystem.h>
    3636#include <iprt/string.h>
     37#include <iprt/vfs.h>
    3738#include "internal/filesystem.h"
    3839
     
    151152 * Cached block group descriptor data.
    152153 */
    153 typedef struct RTFILESYSTEMFMTEXTBLKGRP
     154typedef struct RTFILESYSTEMEXTBLKGRP
    154155{
    155156    /** Start offset (in bytes and from the start of the disk). */
     
    160161     * and number of blocks per group). */
    161162    uint8_t     abBlockBitmap[1];
    162 } RTFILESYSTEMFMTEXTBLKGRP;
     163} RTFILESYSTEMEXTBLKGRP;
    163164/** Pointer to block group descriptor data. */
    164 typedef RTFILESYSTEMFMTEXTBLKGRP *PRTFILESYSTEMFMTEXTBLKGRP;
     165typedef RTFILESYSTEMEXTBLKGRP *PRTFILESYSTEMEXTBLKGRP;
    165166
    166167/**
    167168 * Ext2/3 filesystem data.
    168169 */
    169 typedef struct RTFILESYSTEMFMTINT
    170 {
    171     /** Handle to the underlying medium. */
    172     RTFILESYSTEMMEDIUM        hMedium;
     170typedef struct RTFILESYSTEMEXT
     171{
     172    /** VFS file handle. */
     173    RTVFSFILE                 hVfsFile;
    173174    /** Block number of the superblock. */
    174175    uint32_t                  iSbBlock;
     
    180181    unsigned                  cBlockGroups;
    181182    /** Cached block group descriptor data. */
    182     PRTFILESYSTEMFMTEXTBLKGRP pBlkGrpDesc;
    183 } RTFILESYSTEMFMTINT;
     183    PRTFILESYSTEMEXTBLKGRP    pBlkGrpDesc;
     184} RTFILESYSTEMEXT;
    184185/** Pointer to the ext filesystem data. */
    185 typedef RTFILESYSTEMFMTINT *PRTFILESYSTEMFMTINT;
     186typedef RTFILESYSTEMEXT *PRTFILESYSTEMEXT;
    186187
    187188/*******************************************************************************
     
    196197 * @param   iBlkGrp  Block group number to load.
    197198 */
    198 static int rtFilesystemExtLoadBlkGrpDesc(PRTFILESYSTEMFMTINT pThis, uint32_t iBlkGrp)
     199static int rtFsExtLoadBlkGrpDesc(PRTFILESYSTEMEXT pThis, uint32_t iBlkGrp)
    199200{
    200201    int rc = VINF_SUCCESS;
    201     PRTFILESYSTEMFMTEXTBLKGRP pBlkGrpDesc = pThis->pBlkGrpDesc;
     202    PRTFILESYSTEMEXTBLKGRP pBlkGrpDesc = pThis->pBlkGrpDesc;
    202203    uint64_t offRead = (pThis->iSbBlock + 1) * pThis->cbBlock;
    203204    BlockGroupDesc BlkDesc;
     
    210211    if (!pBlkGrpDesc)
    211212    {
    212         size_t cbBlkDesc = RT_OFFSETOF(RTFILESYSTEMFMTEXTBLKGRP, abBlockBitmap[cbBlockBitmap]);
    213         pBlkGrpDesc = (PRTFILESYSTEMFMTEXTBLKGRP)RTMemAllocZ(cbBlkDesc);
     213        size_t cbBlkDesc = RT_OFFSETOF(RTFILESYSTEMEXTBLKGRP, abBlockBitmap[cbBlockBitmap]);
     214        pBlkGrpDesc = (PRTFILESYSTEMEXTBLKGRP)RTMemAllocZ(cbBlkDesc);
    214215        if (!pBlkGrpDesc)
    215216            return VERR_NO_MEMORY;
    216217    }
    217218
    218     rc = rtFilesystemMediumRead(pThis->hMedium, offRead, &BlkDesc, sizeof(BlkDesc));
     219    rc = RTVfsFileReadAt(pThis->hVfsFile, offRead, &BlkDesc, sizeof(BlkDesc), NULL);
    219220    if (RT_SUCCESS(rc))
    220221    {
    221222        pBlkGrpDesc->offStart = pThis->iSbBlock + (uint64_t)iBlkGrp * pThis->cBlocksPerGroup * pThis->cbBlock;
    222223        pBlkGrpDesc->offLast  = pBlkGrpDesc->offStart + pThis->cBlocksPerGroup * pThis->cbBlock;
    223         rc = rtFilesystemMediumRead(pThis->hMedium, BlkDesc.offBlockBitmap * pThis->cbBlock,
    224                                     &pBlkGrpDesc->abBlockBitmap[0], cbBlockBitmap);
     224        rc = RTVfsFileReadAt(pThis->hVfsFile, BlkDesc.offBlockBitmap * pThis->cbBlock,
     225                             &pBlkGrpDesc->abBlockBitmap[0], cbBlockBitmap, NULL);
    225226    }
    226227
     
    230231}
    231232
    232 static DECLCALLBACK(int) rtFilesystemExtProbe(RTFILESYSTEMMEDIUM hMedium, uint32_t *puScore)
     233static bool rtFsExtIsBlockRangeInUse(PRTFILESYSTEMEXTBLKGRP pBlkGrpDesc,
     234                                     uint32_t offBlockStart, uint32_t cBlocks)
     235{
     236    bool fUsed = false;
     237
     238    while (cBlocks)
     239    {
     240        uint32_t idxByte = offBlockStart / 8;
     241        uint32_t iBit = offBlockStart % 8;
     242
     243        if (pBlkGrpDesc->abBlockBitmap[idxByte] & RT_BIT(iBit))
     244        {
     245            fUsed = true;
     246            break;
     247        }
     248
     249        cBlocks--;
     250        offBlockStart++;
     251    }
     252
     253    return fUsed;
     254}
     255
     256
     257static DECLCALLBACK(int) rtFsExtProbe(RTVFSFILE hVfsFile, uint32_t *puScore)
    233258{
    234259    int rc = VINF_SUCCESS;
    235     uint64_t cbMedium = rtFilesystemMediumGetSize(hMedium);
     260    uint64_t cbMedium = 0;
    236261
    237262    *puScore = RTFILESYSTEM_MATCH_SCORE_UNSUPPORTED;
    238263
    239     if (cbMedium >= 2*sizeof(ExtSuperBlock))
    240     {
    241         ExtSuperBlock SuperBlock;
    242 
    243         rc = rtFilesystemMediumRead(hMedium, 1024, &SuperBlock, sizeof(ExtSuperBlock));
    244         if (RT_SUCCESS(rc))
     264    rc = RTVfsFileGetSize(hVfsFile, &cbMedium);
     265    if (RT_SUCCESS(rc))
     266    {
     267        if (cbMedium >= 2*sizeof(ExtSuperBlock))
    245268        {
     269            ExtSuperBlock SuperBlock;
     270
     271            rc = RTVfsFileReadAt(hVfsFile, 1024, &SuperBlock, sizeof(ExtSuperBlock), NULL);
     272            if (RT_SUCCESS(rc))
     273            {
    246274#if defined(RT_BIGENDIAN)
    247             /** @todo: Convert to host endianess. */
     275                /** @todo: Convert to host endianess. */
    248276#endif
    249             if (SuperBlock.u16Signature == RTFILESYSTEM_EXT2_SIGNATURE)
    250                 *puScore = RTFILESYSTEM_MATCH_SCORE_SUPPORTED;
     277                if (SuperBlock.u16Signature == RTFILESYSTEM_EXT2_SIGNATURE)
     278                    *puScore = RTFILESYSTEM_MATCH_SCORE_SUPPORTED;
     279            }
    251280        }
    252281    }
     
    255284}
    256285
    257 static DECLCALLBACK(int) rtFilesystemExtOpen(RTFILESYSTEMMEDIUM hMedium, PRTFILESYSTEMFMT phFsFmt)
     286static DECLCALLBACK(int) rtFsExtInit(void *pvThis, RTVFSFILE hVfsFile)
    258287{
    259288    int rc = VINF_SUCCESS;
    260     PRTFILESYSTEMFMTINT pThis;
     289    PRTFILESYSTEMEXT pThis = (PRTFILESYSTEMEXT)pvThis;
    261290    ExtSuperBlock SuperBlock;
    262291
    263     pThis = (PRTFILESYSTEMFMTINT)RTMemAllocZ(sizeof(RTFILESYSTEMFMTINT));
    264     if (!pThis)
    265         return VERR_NO_MEMORY;
    266 
    267     pThis->hMedium     = hMedium;
     292    pThis->hVfsFile    = hVfsFile;
    268293    pThis->pBlkGrpDesc = NULL;
    269294
    270     rc = rtFilesystemMediumRead(hMedium, 1024, &SuperBlock, sizeof(ExtSuperBlock));
     295    rc = RTVfsFileReadAt(hVfsFile, 1024, &SuperBlock, sizeof(ExtSuperBlock), NULL);
    271296    if (RT_SUCCESS(rc))
    272297    {
     
    284309
    285310            /* Load first block group descriptor. */
    286             rc = rtFilesystemExtLoadBlkGrpDesc(pThis, 0);
     311            rc = rtFsExtLoadBlkGrpDesc(pThis, 0);
    287312        }
    288313    }
    289314
    290     if (RT_SUCCESS(rc))
    291         *phFsFmt = pThis;
    292     else
    293     {
    294         if (pThis->pBlkGrpDesc)
    295             RTMemFree(pThis->pBlkGrpDesc);
    296         RTMemFree(pThis);
    297     }
    298 
    299315    return rc;
    300316}
    301317
    302 static DECLCALLBACK(int) rtFilesystemExtClose(RTFILESYSTEMFMT hFsFmt)
    303 {
    304     PRTFILESYSTEMFMTINT pThis = hFsFmt;
     318static DECLCALLBACK(void) rtFsExtDestroy(void *pvThis)
     319{
     320    PRTFILESYSTEMEXT pThis = (PRTFILESYSTEMEXT)pvThis;
    305321
    306322    if (pThis->pBlkGrpDesc)
    307323        RTMemFree(pThis->pBlkGrpDesc);
    308     RTMemFree(pThis);
    309 
    310     return VINF_SUCCESS;
    311 }
    312 
    313 static DECLCALLBACK(uint64_t) rtFilesystemExtGetBlockSize(RTFILESYSTEMFMT hFsFmt)
    314 {
    315     PRTFILESYSTEMFMTINT pThis = hFsFmt;
    316 
    317     return pThis->cbBlock;
    318 }
    319 
    320 static bool rtFilesystemExtIsBlockRangeInUse(PRTFILESYSTEMFMTEXTBLKGRP pBlkGrpDesc,
    321                                              uint32_t offBlockStart,
    322                                              uint32_t cBlocks)
    323 {
    324     bool fUsed = false;
    325 
    326     while (cBlocks)
    327     {
    328         uint32_t idxByte = offBlockStart / 8;
    329         uint32_t iBit = offBlockStart % 8;
    330 
    331         if (pBlkGrpDesc->abBlockBitmap[idxByte] & RT_BIT(iBit))
    332         {
    333             fUsed = true;
    334             break;
    335         }
    336 
    337         cBlocks--;
    338         offBlockStart++;
    339     }
    340 
    341     return fUsed;
    342 }
    343 
    344 static DECLCALLBACK(int) rtFilesystemExtQueryRangeUse(RTFILESYSTEMFMT hFsFmt, uint64_t offStart,
    345                                                       size_t cb, bool *pfUsed)
     324}
     325
     326static DECLCALLBACK(int) rtFsExtOpenRoot(void *pvThis, PRTVFSDIR phVfsDir)
     327{
     328    return VERR_NOT_IMPLEMENTED;
     329}
     330
     331static DECLCALLBACK(int) rtFsExtIsRangeInUse(void *pvThis, RTFOFF off, size_t cb,
     332                                             bool *pfUsed)
    346333{
    347334    int rc = VINF_SUCCESS;
    348     PRTFILESYSTEMFMTINT pThis = hFsFmt;
     335    uint64_t offStart = (uint64_t)off;
     336    PRTFILESYSTEMEXT pThis = (PRTFILESYSTEMEXT)pvThis;
     337
     338    *pfUsed = false;
    349339
    350340    while (cb > 0)
     
    360350        {
    361351            /* Load new block descriptor. */
    362             rc = rtFilesystemExtLoadBlkGrpDesc(pThis, iBlockGroup);
     352            rc = rtFsExtLoadBlkGrpDesc(pThis, iBlockGroup);
    363353            if (RT_FAILURE(rc))
    364354                break;
     
    366356
    367357        cbThis = RT_MIN(cb, pThis->pBlkGrpDesc->offLast - offStart + 1);
    368         fUsed = rtFilesystemExtIsBlockRangeInUse(pThis->pBlkGrpDesc, offBlockRelStart,
    369                                                  cbThis / pThis->cbBlock +
    370                                                  cbThis % pThis->cbBlock
    371                                                  ? 1
    372                                                  : 0);
     358        fUsed = rtFsExtIsBlockRangeInUse(pThis->pBlkGrpDesc, offBlockRelStart,
     359                                         cbThis / pThis->cbBlock +
     360                                         (cbThis % pThis->cbBlock ? 1 : 0));
    373361
    374362        if (fUsed)
     
    378366        }
    379367
    380         cb -= cbThis;
     368        cb       -= cbThis;
    381369        offStart += cbThis;
    382370    }
     
    385373}
    386374
    387 RTFILESYSTEMFMTOPS g_rtFilesystemFmtExt =
    388 {
    389     /* pcszFmt */
    390     "EXT",
    391     /* pfnProbe */
    392     rtFilesystemExtProbe,
    393     /* pfnOpen */
    394     rtFilesystemExtOpen,
    395     /* pfnClose */
    396     rtFilesystemExtClose,
    397     /* pfnGetBlockSize */
    398     rtFilesystemExtGetBlockSize,
    399     /* pfnQueryRangeUse */
    400     rtFilesystemExtQueryRangeUse
     375DECL_HIDDEN_CONST(RTFILESYSTEMDESC) const g_rtFsExt =
     376{
     377    /** cbFs */
     378    sizeof(RTFILESYSTEMEXT),
     379    /** VfsOps */
     380    {
     381        /** uVersion. */
     382        RTVFSOPS_VERSION,
     383        /** fFeatures */
     384        0,
     385        /** pszName */
     386        "ExtVfsOps",
     387        /** pfnDestroy */
     388        rtFsExtDestroy,
     389        /** pfnOpenRoot */
     390        rtFsExtOpenRoot,
     391        /** pfnIsRangeInUse */
     392        rtFsExtIsRangeInUse,
     393        /** uEndMarker */
     394        RTVFSOPS_VERSION
     395    },
     396    /** pfnProbe */
     397    rtFsExtProbe,
     398    /** pfnInit */
     399    rtFsExtInit
    401400};
    402401
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