Hacking Compiling WBFS on Mac OS X

eddanx

Active Member
OP
Newcomer
Joined
Jun 6, 2007
Messages
32
Trophies
0
XP
91
Country
United States
Update #2: For the latest version of the WBFS GUI Manager for Mac OS X, visit http://wiki.gbatemp.net/wiki/index.php/WBF...s#WBFS_Managers

Update: We got the wbfs tool to work on Mac OS X. If you want to head right to the action, you can get the diff/patch to wbfs to compile it yourself or get the compiled binary for Mac OS X. The changes have been emailed to Kwiirk who'll include it in the next official release of wbfs.

First of all, thanks for all the effort that has been put in to making all of this possible.

I'm trying to compile the WBFS tool under Mac OS X. First, I just tried the naive approach:

Code:
Eia:cios_usb2 2 eirikh$ ls -l
total 720
-rw-r--r--@ÂÂ1 eiaÂÂstaffÂÂ365312 Mar 30 19:49 cios_dip_usb2_install.dol
drwxr-xr-x@ 16 eiaÂÂstaffÂÂÂÂ 544 Mar 31 12:56 sources
drwxr-xr-x@ÂÂ6 eiaÂÂstaffÂÂÂÂ 204 Mar 30 19:49 wbfs_linux
Eia:cios_usb2 2 eia$ cd sources/wbfs/
Eia:wbfs eia$ make clean
rm -f negentig.o scrub.o wbfs.o tools.o bn.o ec.o disc_usage_table.o libwbfs.o libwbfs_linux.o wiidisc.o rijndael.o negentig scrub wbfs 
Eia:wbfs eia$ make
gcc -Wall -m32 -WÂÂ-ggdb -Ilibwbfs -I. -DLARGE_FILES -D_FILE_OFFSET_BITS=64 -c negentig.c -o negentig.o 
gcc -Wall -m32 -WÂÂ-ggdb -Ilibwbfs -I. -DLARGE_FILES -D_FILE_OFFSET_BITS=64 -c tools.c -o tools.o 
gcc -Wall -m32 -WÂÂ-ggdb -Ilibwbfs -I. -DLARGE_FILES -D_FILE_OFFSET_BITS=64 -c bn.c -o bn.o 
bn.c:11: warning: 'bn_print' defined but not used
gcc -Wall -m32 -WÂÂ-ggdb -Ilibwbfs -I. -DLARGE_FILES -D_FILE_OFFSET_BITS=64 -c ec.c -o ec.o 
ec.c:28: warning: 'elt_print' defined but not used
ec.c:189: warning: 'point_is_on_curve' defined but not used
gcc -Wall -m32 -WÂÂ-ggdb -Ilibwbfs -I. -DLARGE_FILES -D_FILE_OFFSET_BITS=64 -c disc_usage_table.c -o disc_usage_table.o 
gcc -Wall -m32 -WÂÂ-ggdb -Ilibwbfs -I. -DLARGE_FILES -D_FILE_OFFSET_BITS=64 -c libwbfs/libwbfs.c -o libwbfs.o 
gcc -Wall -m32 -WÂÂ-ggdb -Ilibwbfs -I. -DLARGE_FILES -D_FILE_OFFSET_BITS=64 -c libwbfs/libwbfs_linux.c -o libwbfs_linux.o 
gcc -Wall -m32 -WÂÂ-ggdb -Ilibwbfs -I. -DLARGE_FILES -D_FILE_OFFSET_BITS=64 -c libwbfs/wiidisc.c -o wiidisc.o 
libwbfs/wiidisc.c:308: warning: unused parameter 'd'
gcc -Wall -m32 -WÂÂ-ggdb -Ilibwbfs -I. -DLARGE_FILES -D_FILE_OFFSET_BITS=64 -c libwbfs/rijndael.c -o rijndael.o 
gcc -Wall -m32 -WÂÂ-ggdb -Ilibwbfs -I. -m32 -static negentig.o tools.o bn.o ec.o disc_usage_table.o libwbfs.o libwbfs_linux.o wiidisc.o rijndael.o -lcrypto -o negentig
ld_classic: can't locate file for: -lcrt0.o
collect2: ld returned 1 exit status
make: *** [negentig] Error 1
Eia:wbfs eirikh$

Ok, the not-so-unusual problem with building static binaries under Mac OS.

So I removed -static from LDFLAGS in the Makefile and tried again:

Code:
Eia:wbfs eia$ vi Makefile 
Eia:wbfs eia$ make clean
rm -f negentig.o scrub.o wbfs.o tools.o bn.o ec.o disc_usage_table.o libwbfs.o libwbfs_linux.o wiidisc.o rijndael.o negentig scrub wbfs 
Eia:wbfs eirikh$ make
gcc -Wall -m32 -WÂÂ-ggdb -Ilibwbfs -I. -DLARGE_FILES -D_FILE_OFFSET_BITS=64 -c negentig.c -o negentig.o 
gcc -Wall -m32 -WÂÂ-ggdb -Ilibwbfs -I. -DLARGE_FILES -D_FILE_OFFSET_BITS=64 -c tools.c -o tools.o 
gcc -Wall -m32 -WÂÂ-ggdb -Ilibwbfs -I. -DLARGE_FILES -D_FILE_OFFSET_BITS=64 -c bn.c -o bn.o 
bn.c:11: warning: 'bn_print' defined but not used
gcc -Wall -m32 -WÂÂ-ggdb -Ilibwbfs -I. -DLARGE_FILES -D_FILE_OFFSET_BITS=64 -c ec.c -o ec.o 
ec.c:28: warning: 'elt_print' defined but not used
ec.c:189: warning: 'point_is_on_curve' defined but not used
gcc -Wall -m32 -WÂÂ-ggdb -Ilibwbfs -I. -DLARGE_FILES -D_FILE_OFFSET_BITS=64 -c disc_usage_table.c -o disc_usage_table.o 
gcc -Wall -m32 -WÂÂ-ggdb -Ilibwbfs -I. -DLARGE_FILES -D_FILE_OFFSET_BITS=64 -c libwbfs/libwbfs.c -o libwbfs.o 
gcc -Wall -m32 -WÂÂ-ggdb -Ilibwbfs -I. -DLARGE_FILES -D_FILE_OFFSET_BITS=64 -c libwbfs/libwbfs_linux.c -o libwbfs_linux.o 
gcc -Wall -m32 -WÂÂ-ggdb -Ilibwbfs -I. -DLARGE_FILES -D_FILE_OFFSET_BITS=64 -c libwbfs/wiidisc.c -o wiidisc.o 
libwbfs/wiidisc.c:308: warning: unused parameter 'd'
gcc -Wall -m32 -WÂÂ-ggdb -Ilibwbfs -I. -DLARGE_FILES -D_FILE_OFFSET_BITS=64 -c libwbfs/rijndael.c -o rijndael.o 
gcc -Wall -m32 -WÂÂ-ggdb -Ilibwbfs -I. -m32 negentig.o tools.o bn.o ec.o disc_usage_table.o libwbfs.o libwbfs_linux.o wiidisc.o rijndael.o -lcrypto -o negentig
gcc -Wall -m32 -WÂÂ-ggdb -Ilibwbfs -I. -DLARGE_FILES -D_FILE_OFFSET_BITS=64 -c scrub.c -o scrub.o 
gcc -Wall -m32 -WÂÂ-ggdb -Ilibwbfs -I. -m32 scrub.o tools.o bn.o ec.o disc_usage_table.o libwbfs.o libwbfs_linux.o wiidisc.o rijndael.o -lcrypto -o scrub
gcc -Wall -m32 -WÂÂ-ggdb -Ilibwbfs -I. -DLARGE_FILES -D_FILE_OFFSET_BITS=64 -c wbfs.c -o wbfs.o 
gcc -Wall -m32 -WÂÂ-ggdb -Ilibwbfs -I. -m32 wbfs.o tools.o bn.o ec.o disc_usage_table.o libwbfs.o libwbfs_linux.o wiidisc.o rijndael.o -lcrypto -o wbfs
Undefined symbols:
ÂÂ"_wbfs_try_open", referenced from:
ÂÂÂÂÂÂ_main in wbfs.o
ÂÂ"_wbfs_try_open_partition", referenced from:
ÂÂÂÂÂÂ_wbfs_applet_create in wbfs.o
ld: symbol(s) not found
collect2: ld returned 1 exit status
make: *** [wbfs] Error 1

Anyone got any further or have any tips?
 

eddanx

Active Member
OP
Newcomer
Joined
Jun 6, 2007
Messages
32
Trophies
0
XP
91
Country
United States
collin said:
Heh, that is where I got to before I just gave up and decided to use a virtual machines.
I see
smile.gif
Did you use VirtualBox? Which distro did you go for?
 

collin

Member
Newcomer
Joined
Nov 16, 2006
Messages
24
Trophies
0
XP
52
Country
eddanx said:
I see
smile.gif
Did you use VirtualBox? Which distro did you go for?

I'm not sure about VirtualBox's usb2 support. Its awkward in Linux, so I never bothered for OS X. I plan to use the old standby's of Ubuntu and Parallels.

Although compiling on OS X is likely doable if one of the programmers can give advice.
 

eddanx

Active Member
OP
Newcomer
Joined
Jun 6, 2007
Messages
32
Trophies
0
XP
91
Country
United States
collin said:
I'm not sure about VirtualBox's usb2 support. Its awkward in Linux, so I never bothered for OS X. I plan to use the old standby's of Ubuntu and Parallels.
There is usb2.0 support in the VirtualBox settings. I'm installing Ubuntu now to test, will report back.

QUOTE(collin @ Mar 31 2009, 12:46 PM) Although compiling on OS X is likely doable if one of the programmers can give advice.
Yes, it should be really easy for someone with a little bit more experience than us ./configure | make | make install guys
smile.gif
 

gibbed

Member
Newcomer
Joined
Mar 31, 2009
Messages
14
Trophies
0
XP
127
Country
United States
libwbfs_linux.c has a #ifdef check to explicitly look for __linux__.

Ideally you would copy libwbfs_linux.c to libwbfs_macosx.c (and update the makefile to include it) and fix any problems in that code that would break macosx support.
 

eddanx

Active Member
OP
Newcomer
Joined
Jun 6, 2007
Messages
32
Trophies
0
XP
91
Country
United States
Just wanted to update about virtualbox and ubuntu: It works.

Partition the disk without any partitions in Disk Utility (only free space) and eject the disk from disk utility. Set up usb 2.0 support in virtualbox. Fire up ubuntu, add the disk from the usb device list in virtualbox, open gparted and partition it to have one partition with "unknown" file system type. Use wbfs as described in the readme that comes with it.

Posts merged

gibbed said:
libwbfs_linux.c has a #ifdef check to explicitly look for __linux__.

Ideally you would copy libwbfs_linux.c to libwbfs_macosx.c (and update the makefile to include it) and fix any problems in that code that would break macosx support.
I see, would look into it. Thanks!
 

gibbed

Member
Newcomer
Joined
Mar 31, 2009
Messages
14
Trophies
0
XP
127
Country
United States
I think the largest problem would be fixing get_capacity, since that uses linux ioctl stuff. The rest of it ...should... work.
 

eddanx

Active Member
OP
Newcomer
Joined
Jun 6, 2007
Messages
32
Trophies
0
XP
91
Country
United States
I got it compiled now, but I'm not sure if I dare to run it..

Anyone running Mac OS X in a safe environment (e.g. virtual) or have a system they dare to screw up?
 

tps2d

Active Member
Newcomer
Joined
Mar 31, 2009
Messages
34
Trophies
0
XP
2
Country
United States
I was able to compile it as well, but I had to manually define BLKSSZGET and BLKGETSIZE for the "get_capacity" function (I copy and pasted it from a random google result, most likely incorrect). So... it doesn't do anything. I can run it, it will output the help, but when I try to init the partition, it doesn't say anything. Just breaks.

If I try to do a "df" command, it says unsupported by disk or something along those lines. It seems like the get_capacity function is the culprit, as expected.
 

eddanx

Active Member
OP
Newcomer
Joined
Jun 6, 2007
Messages
32
Trophies
0
XP
91
Country
United States
Mb* said:
what might happen if it goes wrong?
i may test:S
It might screw up your partitions I guess .. But it _should_ only mess up on the disk/partition you specify with the -d or -p option .. But I won't guarantee anything, it might kill everything.. Thus I recommend running it on a system where you don't have any sensitive data or have complete backup of everything.

If you have an intel mac running mac os x 32bit, try: *LINK REMOVED (doesn't work)*

Use it just as the linux version. For those that want to compile it themselves I've basically only:

CODEEia:wbfs eia$ diff -u libwbfs/libwbfs_linux.c libwbfs/libwbfs_macosx.c
--- libwbfs/libwbfs_linux.cÂÂÂÂ2009-03-28 14:52:50.000000000 +0100
+++ libwbfs/libwbfs_macosx.cÂÂÂÂ2009-03-31 17:52:42.000000000 +0200
@@ -1,9 +1,9 @@
-#ifdef __linux__
+#ifdef __APPLE__
#include
#include
#include
#include
-#include
+#include
#include
#include

@@ -51,7 +51,7 @@
ÂÂÂÂÂÂÂÂ if(fd
 

tps2d

Active Member
Newcomer
Joined
Mar 31, 2009
Messages
34
Trophies
0
XP
2
Country
United States
I made the same changes you just made (DKIOCGETBLOCKCOUNT, etc), and same results:

$ sudo ./wbfs -p /dev/rdisk3s2 df
error reading disc: Operation not supported by device
$ sudo ./wbfs -p /dev/disk3s2 df
error reading disc: Operation not supported by device

$ ./wbfs -p /dev/disk3s2 init
$
 

tps2d

Active Member
Newcomer
Joined
Mar 31, 2009
Messages
34
Trophies
0
XP
2
Country
United States
I should also say I'm doing this on a disk that hasn't been formatted by USB Loader yet (haven't installed it on my Wii yet), but I was hoping to at least format the disk using this program. The disk has 2 partitions, 1 FAT32 and 1 free space.

If I run init on the FAT32 partition:

$ sudo ./wbfs -p /dev/disk3s1 init
Floating point exception
 

om_nous

Active Member
Newcomer
Joined
Mar 31, 2009
Messages
29
Trophies
0
Website
Visit site
XP
26
Country
United States
Found this thread trying to fix an error I am getting.

In linux I can read the partition fine (created in gparted then ripped a disk to it using the wii)
Code:
wbfs# ./wbfs -p /dev/sdb1 ls
RHAE01ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂPARTY PACK for REVOLUTION 0.09G

I have made similar changes to the source as eddanx but I have been unsuccessful at getting it to work in OS X.

Code:
$diskutil list
/dev/disk3
ÂÂ #:ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ TYPE NAMEÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂSIZEÂÂÂÂÂÂ IDENTIFIER
ÂÂ 0:ÂÂÂÂ FDisk_partition_schemeÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ*37.3 GiÂÂÂÂdisk3
ÂÂ 1:ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂLinuxÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ 37.3 GiÂÂÂÂdisk3s1

$ ./wbfs -p /dev/disk3s1 ls
Floating point exception

Going to try to narrow this down but I am not getting any build errors. Anyone have any ideas?
 

eddanx

Active Member
OP
Newcomer
Joined
Jun 6, 2007
Messages
32
Trophies
0
XP
91
Country
United States
I realized sector_size and n_sector never was set from the ioctl call, so...

CODEEia:wbfs eia$ diff -u libwbfs/libwbfs_linux.c libwbfs/libwbfs_macosx.c
--- libwbfs/libwbfs_linux.cÂÂÂÂ2009-03-28 14:52:50.000000000 +0100
+++ libwbfs/libwbfs_macosx.cÂÂÂÂ2009-03-31 18:30:43.000000000 +0200
@@ -1,9 +1,9 @@
-#ifdef __linux__
+#ifdef __APPLE__
#include
#include
#include
#include
-#include
+#include
#include
#include

@@ -51,7 +51,9 @@
ÂÂÂÂÂÂÂÂ if(fd
 

gibbed

Member
Newcomer
Joined
Mar 31, 2009
Messages
14
Trophies
0
XP
127
Country
United States
n_sector / sector_size are pointers to their respective values, so what you're doing is telling ioctl to write over the pointer to those values.
 

gibbed

Member
Newcomer
Joined
Mar 31, 2009
Messages
14
Trophies
0
XP
127
Country
United States
Apparently DKIOCGETBLOCKCOUNT returns a 64-bit number (long long) not a 32-bit number which is probably why you get a floating point exception.

Code:
long long my_n_sector;
ret = ioctl(fd,DKIOCGETBLOCKCOUNT,&my_n_sector);
*n_sector = (u32)my_n_sector;
 

Site & Scene News

Popular threads in this forum

General chit-chat
Help Users
  • No one is chatting at the moment.
  • Veho @ Veho:
    I only wish it was actually playable.
  • Veho @ Veho:
    There's a guy on the Tube of You that makes playable mechanical arcade games out of Lego. This could work on the same principle.
  • Veho @ Veho:
    Just a couple of guys taking their manatee out for some fresh air, why you have to molest them?
  • Veho @ Veho:
    Stupid Chinese shop switched their shipping company and this one is slooooooow.
  • LeoTCK @ LeoTCK:
    STOP BUYING CHINESE CRAP THEN
  • LeoTCK @ LeoTCK:
    SUPPORT LOCAL PRODUCTS, MAKE REVOLUTION
  • LeoTCK @ LeoTCK:
    THEY KEEP REMOVING LOCAL SHIt AND REPLACING WItH INFERIOR CHINESE CRAP
  • LeoTCK @ LeoTCK:
    THATS WHY MY PARTNER CANT GET A GOOTWEAR HIS SIZE ANYMORE
  • LeoTCK @ LeoTCK:
    HE HAS BIG FOOT AND BIG DUCK
  • LeoTCK @ LeoTCK:
    d*ck i mean*
  • LeoTCK @ LeoTCK:
    lol
  • Veho @ Veho:
    Mkay.
  • Veho @ Veho:
    I just ordered another package from China just to spite you.
  • SylverReZ @ SylverReZ:
    Communism lol
  • SylverReZ @ SylverReZ:
    OUR products
  • The Real Jdbye @ The Real Jdbye:
    @LeoTCK actually good quality products are dying out because they can't compete with dropshipped chinese crap
    +2
  • BakerMan @ BakerMan:
    @LeoTCK is your partner the sascrotch or smth?
  • Xdqwerty @ Xdqwerty:
    Good morning
  • Xdqwerty @ Xdqwerty:
    Out of nowhere I got several scars on my forearm and part of my arm and it really itches.
  • AdRoz78 @ AdRoz78:
    Hey, I bought a modchip today and it says "New 2040plus" in the top left corner. Is this a legit chip or was I scammed?
  • Veho @ Veho:
    @AdRoz78 start a thread and post a photo of the chip.
    +2
    Veho @ Veho: @AdRoz78 start a thread and post a photo of the chip. +2