Possible fix for the WBFS corruption

Discussion in 'Wii - Hacking' started by AllWiidUp, Apr 12, 2009.

Apr 12, 2009
  1. AllWiidUp
    OP

    Newcomer AllWiidUp Advanced Member

    Joined:
    Dec 17, 2008
    Messages:
    84
    Country:
    Canada
    Looking at the WBFS alloc and free functions I noticed an off by 1 error, that likely frees the wrong block.

    in libwbfs.c:

    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 | 1freeblks);
    ÂÂÂÂÂÂÂÂp->freeblks = wbfs_htonl(v | 1wlba_table); // bl = info->wlba_table
    ÂÂÂÂÂÂÂÂÂÂif (iwlba)
    ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂfree_block(p,iwlba); // should have beenÂÂfree_block(p,iwlba - 1);[/code]
    but since "alloc_block" adds the +1 then "free_block" should have the -1, otherwise someone else might introduce the bug again, if the use free_block in another place since both block functions are used for "wlba_table".



    EDIT:
    WiiNinja compiled and tested a windows version with the fix and all it well ;P
    WBFS.Windows.with.free.space.fix

    now supported in WBFuse

    Managers with Support:
    WBFS Manager 2.2


    Loaders with support:
    KongsNutz Loader
    Waninkoko v1.4
     


  2. Mark McDonut

    Member Mark McDonut GBAtemp Fan

    Joined:
    Oct 8, 2008
    Messages:
    495
    Country:
    United States
    you should contact qwiirk or waninkoko, you really may be on to something.
     
  3. AllWiidUp
    OP

    Newcomer AllWiidUp Advanced Member

    Joined:
    Dec 17, 2008
    Messages:
    84
    Country:
    Canada

    I don't know Kwiirk's contact info and since he did up this version, I thought I'd put it out there in case he could see.
     
  4. OuahOuah

    Member OuahOuah GBAtemp Advanced Fan

    Joined:
    Oct 2, 2006
    Messages:
    948
    Location:
    France
    Country:
    France
    He's on Wiibrew [​IMG]
     
  5. FenrirWolf

    Member FenrirWolf GBAtemp Psycho!

    Joined:
    Nov 19, 2008
    Messages:
    4,343
    Location:
    Beaverton, OR
    Country:
    United States
    So in what manner would this possibly fix the corruption? Would it cause a game to move the other games out of the way instead of overwriting them or something?
     
  6. kongsnutz

    Member kongsnutz QuickTimeEvent

    Joined:
    Jul 19, 2008
    Messages:
    1,447
    Country:
    Australia
    pretty much .......yeh
     
  7. FoGBaV

    Newcomer FoGBaV Advanced Member

    Joined:
    Jan 31, 2008
    Messages:
    82
    Country:
    Sweden
    Can someone confirm this fix - this would be the best Loader out there ... a Loader with no corruption in the file system ! 8)
     
  8. FenrirWolf

    Member FenrirWolf GBAtemp Psycho!

    Joined:
    Nov 19, 2008
    Messages:
    4,343
    Location:
    Beaverton, OR
    Country:
    United States
    From what I gather this has to do with the wbfs filesystem itself and not any loader application, but correct me if I'm wrong.
     
  9. FoGBaV

    Newcomer FoGBaV Advanced Member

    Joined:
    Jan 31, 2008
    Messages:
    82
    Country:
    Sweden
    Its the libwbfs ... so its part of something when compiled ... so the usb loader has this code in it i guess ...
    also the wbfs tools ...
     
  10. maglat

    Newcomer maglat Advanced Member

    Joined:
    Dec 21, 2006
    Messages:
    59
    Country:
    Germany
    I think we musst reformat our hdd`s when they build in this fix
     
  11. FenrirWolf

    Member FenrirWolf GBAtemp Psycho!

    Joined:
    Nov 19, 2008
    Messages:
    4,343
    Location:
    Beaverton, OR
    Country:
    United States
    I'm thinking the same thing. It'll be well worth it since you have to reinstall games when they get corrupted anyway.
     
  12. djtaz

    Member djtaz PM's Full - Wadder Me

    Joined:
    Sep 21, 2008
    Messages:
    2,997
    Country:
    Ireland
    It would be a great find if its the fix - its been bugging everyone and makes the format seem a little unstable for most.
    well done AllWiidup
     
  13. Blue-K

    Member Blue-K No right of appeal.

    Joined:
    Jun 21, 2008
    Messages:
    2,572
    Location:
    Helvetica
    Country:
    Switzerland
    That's awesome!!! [​IMG].Good work! Have you maybe also found the bug why games can't be dumped by the Wii to a Partition over 512GB [​IMG]? That would be also awesome [​IMG].
     
  14. waninkoko

    Member waninkoko GBAtemp Fan

    Joined:
    Feb 1, 2008
    Messages:
    300
    Location:
    Salamanca, Spain
    Country:
    Spain
    You're completely right. It frees an incorrect block (we don't free the first block of the game, but we free the first block next to the last block of the game).
     
  15. wiiNinja

    Member wiiNinja GBAtemp Fan

    Joined:
    Jan 13, 2009
    Messages:
    378
    Country:
    United States
    Finally, the bug is found. Thanks AllWiidup.
     
  16. --=ZerO=--

    Member --=ZerO=-- GBAtemp Regular

    Joined:
    Jan 18, 2006
    Messages:
    271
    Country:
    Germany
    So... i see... i'm sure u and kwiirk will fix this very soon... CIOS11 is on it's way. [​IMG]
    U guys are great!
     
  17. Linuks

    Member Linuks GBAtemp Regular

    Joined:
    Aug 30, 2008
    Messages:
    299
    Location:
    France
    Country:
    France
    USB Loader 1.3 is already here.
     
  18. --=ZerO=--

    Member --=ZerO=-- GBAtemp Regular

    Joined:
    Jan 18, 2006
    Messages:
    271
    Country:
    Germany
    yeah, and? I thougth it's a problem of libwbfs and not the loader...
     
  19. wiiNinja

    Member wiiNinja GBAtemp Fan

    Joined:
    Jan 13, 2009
    Messages:
    378
    Country:
    United States
    THe loader contains wbfs code for adding/deleting ISOs.

    Version 1.3 does not fix this problem. I suspect 1.4.
     
  20. AllWiidUp
    OP

    Newcomer AllWiidUp Advanced Member

    Joined:
    Dec 17, 2008
    Messages:
    84
    Country:
    Canada
    Thanks wiiNinja for compiling and testing the fix, to verify it works.
     

Share This Page