Hacking Possible fix for the WBFS corruption

AllWiidUp

Well-Known Member
OP
Newcomer
Joined
Dec 17, 2008
Messages
84
Trophies
0
XP
31
Country
Canada
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
 

jwcgator

Well-Known Member
Member
Joined
May 10, 2007
Messages
141
Trophies
0
Age
32
Website
Visit site
XP
159
Country
United States
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:
 

AllWiidUp

Well-Known Member
OP
Newcomer
Joined
Dec 17, 2008
Messages
84
Trophies
0
XP
31
Country
Canada
Added in official v1.4
tongue.gif


Waninkoko v1.4
 

AllWiidUp

Well-Known Member
OP
Newcomer
Joined
Dec 17, 2008
Messages
84
Trophies
0
XP
31
Country
Canada
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.
 

piratesmack

Well-Known Member
Member
Joined
Mar 28, 2009
Messages
787
Trophies
0
Age
32
Location
$(pwd)
XP
148
Country
United States
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.
 

kedest

Well-Known Member
Member
Joined
Feb 6, 2007
Messages
3,289
Trophies
0
Website
Visit site
XP
534
Country
Netherlands
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!
 

WiiShizzza

Graphics juggler
Member
Joined
Oct 10, 2008
Messages
1,201
Trophies
1
Website
Visit site
XP
241
Country
Gambia, The
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;
}
 

AllWiidUp

Well-Known Member
OP
Newcomer
Joined
Dec 17, 2008
Messages
84
Trophies
0
XP
31
Country
Canada
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
 

darkten

Well-Known Member
Member
Joined
Mar 31, 2009
Messages
174
Trophies
0
XP
304
Country
United States
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
 

twig123

Well-Known Member
Member
Joined
Apr 4, 2009
Messages
261
Trophies
1
XP
267
Country
United States
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...
 

oldskool75

Active Member
Newcomer
Joined
Aug 9, 2007
Messages
31
Trophies
1
Age
48
Website
Visit site
XP
303
Country
Canada
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

General chit-chat
Help Users
    Xdqwerty @ Xdqwerty: https://www.youtube.com/watch?v=2e1d3daJ0HE