OvmfPkg/FswHfsPlus/fsw_hfsplus.c
/* Retrieve file data mapping information. This function is called by
 * the core when fsw_shandle_read needs to know where on the disk the
 * required piece of the file's data can be found. The core makes sure
 * that fsw_hfsplus_dno_fill has been called on the dnode before.
 * Our task here is to get the physical disk block number for the
 * requested logical block number.
 * NOTE: logical and physical block sizes are the same (see mount method).
 */
Retrieve file data mapping information. This function is called by
the core when fsw_shandle_read needs to know where on the disk the
required piece of the file's data can be found. The core makes sure
that fsw_hfsplus_dno_fill has been called on the dnode before.
Our task here is to get the physical disk block number for the
requested logical block number.
NOTE: logical and physical block sizes are the same .
Retrieve file data mapping information . This function is called by the core when fsw_shandle_read needs to know where on the disk the required piece of the file ' s data can be found . The core makes sure that fsw_hfsplus_dno_fill has been called on the dnode before . Our task here is to get the physical disk block number for the requested logical block number . NOTE : logical and physical block sizes are the same .
static fsw_status_t
fsw_hfsplus_get_ext(struct fsw_hfsplus_volume *v, struct fsw_hfsplus_dnode *d,
                    struct fsw_extent *e)
{
    fsw_u32             off, bc;
    HFSPlusExtentRecord *er;
    int                 i;
    off = e->log_start;
    er = &d->extents;
    for (i = 0; i < kHFSPlusExtentDensity; i++) {
        bc = fsw_u32_be_swap((*er)[i].blockCount);
        if (bc == 0)
            return FSW_NOT_FOUND;
        if (off < bc) {
            e->type = FSW_EXTENT_TYPE_PHYSBLOCK;
            e->phys_start = fsw_u32_be_swap((*er)[i].startBlock) + off;
            e->log_count = bc - off;
            return FSW_SUCCESS;
        }
        off -= bc;
    }
DEBUG ((EFI_D_INFO, "GLS: get_ext: got here\n"));
    return FSW_UNSUPPORTED;
}
static fsw_status_t fsw_hfsplus_get_ext ( struct fsw_hfsplus_volume * v , struct fsw_hfsplus_dnode * d , struct fsw_extent * e ) { fsw_u32 off , bc ; HFSPlusExtentRecord * er ; int i ; off = e -> log_start ; er = & d -> extents ; for ( i = 0 ; i < kHFSPlusExtentDensity ; i ++ ) { bc = fsw_u32_be_swap ( ( * er ) [ i ] . blockCount ) ; if ( bc == 0 ) return FSW_NOT_FOUND ; if ( off < bc ) { e -> type = FSW_EXTENT_TYPE_PHYSBLOCK ; e -> phys_start = fsw_u32_be_swap ( ( * er ) [ i ] . startBlock ) + off ; e -> log_count = bc - off ; return FSW_SUCCESS ; } off -= bc ; } DEBUG ( ( EFI_D_INFO , " \n " ) ) ; return FSW_UNSUPPORTED ; }
Retrieve file data mapping information.
Retrieve file data mapping information .
// set initial offset to provided starting logical block number: // start with dnode's initial extent record: // search extent record: // get block count for current extent descriptor: // have we exhausted all available extents? // offset is relative to current extent's physical startBlock: // update offset to NEXT extent descriptor: // FIXME: more than 8 fragments not yet supported!