Hacking Possible fix for the WBFS corruption

  • Thread starter Thread starter AllWiidUp
  • Start date Start date
  • Views Views 29,100
  • Replies Replies 49
Patch file

CODE--- a/libwbfs.cÂÂ 2009-03-31 18:26:00.000000000 -0700
+++ b/libwbfs.cÂÂÂÂ 2009-04-12 12:28:23.516024000 -0700
@@ -389,8 +389,8 @@
}
static void free_block(wbfs_t *p,int bl)
{
-ÂÂÂÂÂÂÂÂint i = bl/(32);
-ÂÂÂÂÂÂÂÂint j = bl&31;
+ÂÂÂÂÂÂÂÂint i = (bl-1)/(32);
+ÂÂÂÂÂÂÂÂint j = (bl-1)&31;
ÂÂÂÂÂÂÂÂ u32 v = wbfs_ntohl(p->freeblks);
ÂÂÂÂÂÂÂÂ p->freeblks = wbfs_htonl(v | 1
 
I'm going to try this compiled into the USB loader 1.3 source code and deleting and adding a couple ISOs to see how it works >_>
 
jwcgator said:
I'm going to try this compiled into the USB loader 1.3 source code and deleting and adding a couple ISOs to see how it works >_>

I'm not sure if this is a problem on my part or on the loader's part, But installing a game took FOREVER and it didn't even finish, just froze.

D:
 
Added in official v1.4
tongue.gif


Waninkoko v1.4
 
piratesmack said:
Good job, allwiidup

So do I have to reformat my wbfs partition?

Only if you deleted a bunch of games, every delete of a game in the old version of libwbfs would leak a block ( not a ton of space unless it's a large HDD ). If there are enough people with problems I could code up something to fix the freeblock list.
 
AllWiidUp said:
piratesmack said:
Good job, allwiidup

So do I have to reformat my wbfs partition?

Only if you deleted a bunch of games, every delete of a game in the old version of libwbfs would leak a block ( not a ton of space unless it's a large HDD ). If there are enough people with problems I could code up something to fix the freeblock list.

Thanks, I haven't deleted any games yet.
 
TroyTheZombie said:
AllWiidUp, Great job on finding the fix for this. Its already being implemented in many loaders and WBFS managers.

Just had to say that, lol.
grog.gif

yeah, a very good job indeed. That's the power of open source!
 
isn't it enough to just change the following?


u32 wbfs_rm_disc(wbfs_t*p, u8* discid)
{
wbfs_disc_t *d = wbfs_open_disc(p,discid);
int i;
int discn = 0;
int disc_info_sz_lba = p->disc_info_sz>>p->hd_sec_sz_s;
if(!d)
return 1;
load_freeblocks(p);
discn = d->i;
for( i=0; i< p->n_wbfs_sec_per_disc; i++)
{
u32 iwlba = wbfs_ntohs(d->header->wlba_table);
if (iwlba)
free_block(p,iwlba); free_block(p, iwlba - 1);
}
memset(d->header,0,p->disc_info_sz);
p->write_hdsector(p->callback_data,p->part_lba+1+discn*disc_info_sz_lba,disc_info_sz_lba,d->header);
p->head->disc_table[discn] = 0;
wbfs_close_disc(d);
wbfs_sync(p);
return 0;
}
 
WiiShizzza said:
isn't it enough to just change the following?


u32 wbfs_rm_disc(wbfs_t*p, u8* discid)
{
wbfs_disc_t *d = wbfs_open_disc(p,discid);
int i;
int discn = 0;
int disc_info_sz_lba = p->disc_info_sz>>p->hd_sec_sz_s;
if(!d)
return 1;
load_freeblocks(p);
discn = d->i;
for( i=0; i< p->n_wbfs_sec_per_disc; i++)
{
u32 iwlba = wbfs_ntohs(d->header->wlba_table);
if (iwlba)
free_block(p,iwlba); free_block(p, iwlba - 1);
}
memset(d->header,0,p->disc_info_sz);
p->write_hdsector(p->callback_data,p->part_lba+1+discn*disc_info_sz_lba,disc_info_sz_lba,d->header);
p->head->disc_table[discn] = 0;
wbfs_close_disc(d);
wbfs_sync(p);
return 0;
}


As noted in my first post, it is, however since "alloc_block" returns the number +1 and that's what is stored in "wlba_table", I decided that putting the fix inside "free_block", would keep the api to the 2 functions ("free_block" and "alloc_block" ) consistent and would make it less likely for someone to introduce a bug, if someone added new code using "free_block" and forgot the -1
tongue.gif
 
For the coders out there, Waninkoko included (
smile.gif
), when we did the mac os x changes and ported some of Sorg's code for the wbfs cli tool we set up a git for those changes, plus Sorg's changes and anything else we could find, *properly #ifdef'd by the supported platforms* here:

http://github.com/caristat/wbfs/tree/master

Is there some sort of master source repository/svn/other managed solution somewhere so that it is easy to keep everything sync'd up?

Anyone is welcome to use it of course, and in the spirit of openess and cooperation, etc just letting everyone know it is there. We'll try to get this fix into the OS X code soon.

d10
 
AllWiidUp said:
piratesmack said:
Good job, allwiidup

So do I have to reformat my wbfs partition?

Only if you deleted a bunch of games, every delete of a game in the old version of libwbfs would leak a block ( not a ton of space unless it's a large HDD ). If there are enough people with problems I could code up something to fix the freeblock list.
This would be great if we had something that could fix the games that are corrupt for those of us who have deleted games...
 
darkten said:
For the coders out there, Waninkoko included (
smile.gif
), when we did the mac os x changes and ported some of Sorg's code for the wbfs cli tool we set up a git for those changes, plus Sorg's changes and anything else we could find, *properly #ifdef'd by the supported platforms* here:

http://github.com/caristat/wbfs/tree/master

Is there some sort of master source repository/svn/other managed solution somewhere so that it is easy to keep everything sync'd up?

Anyone is welcome to use it of course, and in the spirit of openess and cooperation, etc just letting everyone know it is there. We'll try to get this fix into the OS X code soon.

d10

Sourceforge would be a great idea... (or something like it)
 

Site & Scene News

Popular threads in this forum