static void wbfs_load_header(void) { head = wbfs_malloc(sizeof(*head)); read_sectors(0,1,head); if(wbfs_ntohl(head->magic)!=MAGIC) wbfs_fatal("not a WBFS partition!"); D( wblk_sz_shift, head->blk_sz_log2-2+15 ); D( iwlba_shift, head->blk_sz_log2-9+15 ); D( lba_mask, ((1<<(wblk_sz_shift-blk_sz_shift))-1)); D( nsblk , wbfs_ntohl(head->nsblk) ); D( nblk , nsblk*512LL/(blk_sz*0x8000) ); D( freeblks_size, ALIGN512(nblk/8) ); D( disc_nblk, (143432/(1<<head->blk_sz_log2))+1 ); D( table_size, (disc_nblk)*2 ); D( header_size, ALIGN512(table_size+0x100) ); D( freeblks_o, blk_sz*0x8000-freeblks_size ); // end of first block D( max_disc, (freeblks_o-512)/header_size ); if(max_disc > MAX_MAXDISC) max_disc = MAX_MAXDISC; header = wbfs_malloc(header_size); tmp_buffer = wbfs_malloc(blk_sz); }
static void disc_read(wiidisc_t *d,u32 offset, u8 *data, u32 len) { if(data){ int ret=0; if(len==0) return ; ret = d->read(d->fp,offset,len,data); if(ret) wbfs_fatal("error reading disc (disc_read)"); } if(d->sector_usage_table) { u32 blockno = offset>>13; do { d->sector_usage_table[blockno]=1; blockno+=1; if(len>0x8000) len-=0x8000; }while(len>0x8000); }