VirtualBox

Changeset 69845 in vbox


Ignore:
Timestamp:
Nov 27, 2017 3:49:27 PM (7 years ago)
Author:
vboxsync
Message:

ext2vfs.cpp: style cleanups

File:
1 edited

Legend:

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

    r69844 r69845  
    11/* $Id$ */
    22/** @file
    3  * IPRT Filesystem API (FileSys) - ext2/3 format.
     3 * IPRT - Ext2/3/4 Virtual Filesystem.
    44 */
    55
     
    9292static int rtFsExtLoadBlkGrpDesc(PRTFILESYSTEMEXT pThis, uint32_t iBlkGrp)
    9393{
    94     int rc = VINF_SUCCESS;
    95     PRTFILESYSTEMEXTBLKGRP pBlkGrpDesc = pThis->pBlkGrpDesc;
    96     uint64_t offRead = (pThis->iSbBlock + 1) * pThis->cbBlock;
    97     EXT2BLOCKGROUPDESC BlkDesc;
    98     size_t cbBlockBitmap;
    99 
    100     cbBlockBitmap = pThis->cBlocksPerGroup / 8;
     94    size_t cbBlockBitmap = pThis->cBlocksPerGroup / 8;
    10195    if (pThis->cBlocksPerGroup % 8)
    10296        cbBlockBitmap++;
    10397
     98    PRTFILESYSTEMEXTBLKGRP pBlkGrpDesc = pThis->pBlkGrpDesc;
    10499    if (!pBlkGrpDesc)
    105100    {
     
    110105    }
    111106
    112     rc = RTVfsFileReadAt(pThis->hVfsFile, offRead, &BlkDesc, sizeof(BlkDesc), NULL);
     107    uint64_t            offRead = (pThis->iSbBlock + 1) * pThis->cbBlock;
     108    EXT2BLOCKGROUPDESC  BlkDesc;
     109    int rc = RTVfsFileReadAt(pThis->hVfsFile, offRead, &BlkDesc, sizeof(BlkDesc), NULL);
    113110    if (RT_SUCCESS(rc))
    114111    {
     
    120117
    121118    pThis->pBlkGrpDesc = pBlkGrpDesc;
    122 
    123119    return rc;
    124120}
    125121
     122
    126123static bool rtFsExtIsBlockRangeInUse(PRTFILESYSTEMEXTBLKGRP pBlkGrpDesc, uint32_t offBlockStart, size_t cBlocks)
    127124{
    128     bool fUsed = false;
    129 
    130125    while (cBlocks)
    131126    {
     
    134129
    135130        if (pBlkGrpDesc->abBlockBitmap[idxByte] & RT_BIT(iBit))
    136         {
    137             fUsed = true;
    138             break;
    139         }
     131            return true;
    140132
    141133        cBlocks--;
     
    143135    }
    144136
    145     return fUsed;
     137    return false;
    146138}
    147139
     
    187179static DECLCALLBACK(int) rtFsExt2_QueryRangeState(void *pvThis, uint64_t off, size_t cb, bool *pfUsed)
    188180{
    189     int rc = VINF_SUCCESS;
    190     uint64_t offStart = (uint64_t)off;
    191     PRTFILESYSTEMEXT pThis = (PRTFILESYSTEMEXT)pvThis;
     181    int                 rc    = VINF_SUCCESS;
     182    PRTFILESYSTEMEXT    pThis = (PRTFILESYSTEMEXT)pvThis;
    192183
    193184    *pfUsed = false;
     
    195186    while (cb > 0)
    196187    {
    197         bool fUsed;
    198         uint32_t offBlockStart = (uint32_t)(offStart / pThis->cbBlock);
    199         uint32_t iBlockGroup = (offBlockStart - pThis->iSbBlock) / pThis->cBlocksPerGroup;
    200         uint32_t offBlockRelStart = offBlockStart - iBlockGroup * pThis->cBlocksPerGroup;
    201         size_t cbThis = 0;
    202 
    203         if (   offStart < pThis->pBlkGrpDesc->offStart
    204             || offStart > pThis->pBlkGrpDesc->offLast)
     188        uint32_t const offBlockStart    = (uint32_t)(off / pThis->cbBlock);
     189        uint32_t const iBlockGroup      = (offBlockStart - pThis->iSbBlock) / pThis->cBlocksPerGroup;
     190        uint32_t const offBlockRelStart = offBlockStart - iBlockGroup * pThis->cBlocksPerGroup;
     191
     192        if (   off < pThis->pBlkGrpDesc->offStart
     193            || off > pThis->pBlkGrpDesc->offLast)
    205194        {
    206195            /* Load new block descriptor. */
     
    210199        }
    211200
    212         cbThis = RT_MIN(cb, pThis->pBlkGrpDesc->offLast - offStart + 1);
    213         fUsed = rtFsExtIsBlockRangeInUse(pThis->pBlkGrpDesc, offBlockRelStart,
    214                                          cbThis / pThis->cbBlock +
    215                                          (cbThis % pThis->cbBlock ? 1 : 0));
    216 
    217         if (fUsed)
     201        size_t cbThis = RT_MIN(cb, pThis->pBlkGrpDesc->offLast - off + 1);
     202        if (rtFsExtIsBlockRangeInUse(pThis->pBlkGrpDesc,
     203                                     offBlockRelStart,
     204                                     cbThis / pThis->cbBlock + (cbThis % pThis->cbBlock ? 1 : 0)) )
    218205        {
    219206            *pfUsed = true;
     
    221208        }
    222209
    223         cb       -= cbThis;
    224         offStart += cbThis;
     210        cb  -= cbThis;
     211        off += cbThis;
    225212    }
    226213
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