OvmfPkg/FswHfsPlus/fsw_hfsplus.c
/* Mount an HFS+ volume. Read volume header (equivalent of superblock),
 * and set up dnodes for the root folder and B-Tree file(s).
 * Return FSW_SUCCESS or error code.
 */
Mount an HFS+ volume. Read volume header (equivalent of superblock),
and set up dnodes for the root folder and B-Tree file(s).
Return FSW_SUCCESS or error code.
Mount an HFS + volume . Read volume header ( equivalent of superblock ) and set up dnodes for the root folder and B - Tree file ( s ) . Return FSW_SUCCESS or error code .
static fsw_status_t
fsw_hfsplus_vol_mount(struct fsw_hfsplus_volume *v)
{
    void         *buf;
    fsw_u32      bs;
    fsw_status_t status;
    status = fsw_alloc(sizeof(HFSPlusVolumeHeader), &v->vh);
    if (status)
        return status;
    fsw_set_blocksize(v, kHFSBlockSize, kHFSBlockSize);
    status = fsw_block_get(v, kMasterDirectoryBlock, 0, &buf);
    if (status)
        return status;
    fsw_memcpy(v->vh, buf, sizeof(HFSPlusVolumeHeader));
    fsw_block_release(v, kMasterDirectoryBlock, buf);
    if (fsw_u16_be_swap(v->vh->signature) != kHFSPlusSigWord)
        return FSW_UNSUPPORTED;
    bs = fsw_u32_be_swap(v->vh->blockSize);
    fsw_set_blocksize(v, bs, bs);
    status = fsw_hfsplus_btf_setup(v, kHFSCatalogFileID, &v->vh->catalogFile,
                                   &v->catf);
    if (status)
        return status;
    status = fsw_dnode_create_root(v, kHFSRootFolderID, &v->g.root);
    if (status)
        return status;
    return FSW_SUCCESS;
}
static fsw_status_t fsw_hfsplus_vol_mount ( struct fsw_hfsplus_volume * v ) { void * buf ; fsw_u32 bs ; fsw_status_t status ; status = fsw_alloc ( sizeof ( HFSPlusVolumeHeader ) , & v -> vh ) ; if ( status ) return status ; fsw_set_blocksize ( v , kHFSBlockSize , kHFSBlockSize ) ; status = fsw_block_get ( v , kMasterDirectoryBlock , 0 , & buf ) ; if ( status ) return status ; fsw_memcpy ( v -> vh , buf , sizeof ( HFSPlusVolumeHeader ) ) ; fsw_block_release ( v , kMasterDirectoryBlock , buf ) ; if ( fsw_u16_be_swap ( v -> vh -> signature ) != kHFSPlusSigWord ) return FSW_UNSUPPORTED ; bs = fsw_u32_be_swap ( v -> vh -> blockSize ) ; fsw_set_blocksize ( v , bs , bs ) ; status = fsw_hfsplus_btf_setup ( v , kHFSCatalogFileID , & v -> vh -> catalogFile , & v -> catf ) ; if ( status ) return status ; status = fsw_dnode_create_root ( v , kHFSRootFolderID , & v -> g . root ) ; if ( status ) return status ; return FSW_SUCCESS ; }
Mount an HFS+ volume.
Mount an HFS + volume .
// allocate memory for vol. header // read vol. header into buffer // check vol. header // use block size specified by vol. header // set up catalog B-Tree file: // set up root folder: