Skip to content

Commit

Permalink
general cleanup and fixes
Browse files Browse the repository at this point in the history
added optional id changing
merged improvements to the Mac OS X port
  • Loading branch information
caristat committed Apr 8, 2009
1 parent 56c1dd8 commit 77070e4
Show file tree
Hide file tree
Showing 7 changed files with 525 additions and 108 deletions.
3 changes: 3 additions & 0 deletions README
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,7 @@ enables modifications apparently used by "WBFS for MAc OS X", a GUI wrapper
ENABLE_RENAME
enable the rename functionality for non-win32 systems

ENABLE_CHANGE_DISKID
enable the id change functionality for non-win32 systems

April 2009
339 changes: 339 additions & 0 deletions gpl-2.0.txt

Large diffs are not rendered by default.

46 changes: 30 additions & 16 deletions libwbfs/libwbfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -651,6 +651,31 @@ u32 wbfs_ren_disc(wbfs_t*p, u8* discid, u8* newname)
}
#endif

#ifdef ENABLE_CHANGE_DISKID
u32 wbfs_nid_disc(wbfs_t*p, u8* discid, u8* newid)
{
wbfs_disc_t *d = wbfs_open_disc(p, discid);
int disc_info_sz_lba = p->disc_info_sz>>p->hd_sec_sz_s;

if(!d)
return 1;

if(strlen((const char *)newid) > 0x6)
return 1;

strcpy((char *)(d->header->disc_header_copy+0x0), (const char *)newid);

p->write_hdsector(p->callback_data,
p->part_lba+1+d->i*disc_info_sz_lba,
disc_info_sz_lba,
d->header);

wbfs_close_disc(d);
wbfs_sync(p);
return 0;
}
#endif

#ifdef WIN32
// Could this be useful for other platforms? - g3power
u32 wbfs_estimate_disc
Expand Down Expand Up @@ -760,18 +785,14 @@ u32 wbfs_extract_disc(wbfs_disc_t*d, rw_sector_callback_t write_dst_wii_sector,v
{
wbfs_t *p = d->p;
u8* copy_buffer = 0;
#ifdef WIN32
int tot = 0, cur = 0;
#endif
int i;
int src_wbs_nlb=p->wbfs_sec_sz/p->hd_sec_sz;
int dst_wbs_nlb=p->wbfs_sec_sz/p->wii_sec_sz;
copy_buffer = wbfs_ioalloc(p->wbfs_sec_sz);
if(!copy_buffer)
ERROR("alloc memory");

#ifdef WIN32
// Test for other plattforms - g3power
if (spinner)
{
// count total number to write for spinner
Expand All @@ -785,24 +806,16 @@ u32 wbfs_extract_disc(wbfs_disc_t*d, rw_sector_callback_t write_dst_wii_sector,v
}
}
}
#endif

for( i=0; i< p->n_wbfs_sec_per_disc; i++)
for ( i=0; i< p->n_wbfs_sec_per_disc; i++)
{
u32 iwlba = wbfs_ntohs(d->header->wlba_table[i]);
if (iwlba)
{
#ifdef WIN32
cur++;
#endif
if (spinner)
{
#ifdef WIN32
if (spinner)
spinner(cur,tot);
#else
spinner(i,p->n_wbfs_sec_per_disc);
#endif
}

p->read_hdsector(p->callback_data, p->part_lba + iwlba*src_wbs_nlb, src_wbs_nlb, copy_buffer);
write_dst_wii_sector(callback_data, i*dst_wbs_nlb, dst_wbs_nlb, copy_buffer);
}
Expand All @@ -812,4 +825,5 @@ u32 wbfs_extract_disc(wbfs_disc_t*d, rw_sector_callback_t write_dst_wii_sector,v
error:
return 1;
}
u32 wbfs_extract_file(wbfs_disc_t*d, char *path);

u32 wbfs_extract_file(wbfs_disc_t* d, char *path);
7 changes: 7 additions & 0 deletions libwbfs/libwbfs.h
Original file line number Diff line number Diff line change
Expand Up @@ -233,8 +233,15 @@ u32 wbfs_estimate_disc(wbfs_t*p,read_wiidisc_callback_t read_src_wii_disc, void
/*! remove a wiidvd inside a partition */
u32 wbfs_rm_disc(wbfs_t*p, u8* discid);

#ifdef ENABLE_RENAME
/*! rename a wiidvd inside a partition */
u32 wbfs_ren_disc(wbfs_t*p, u8* discid, u8* newname);
#endif

#ifdef ENABLE_CHANGE_DISKID
/*! edit a wiidvd diskid */
u32 wbfs_nid_disc(wbfs_t*p, u8* discid, u8* newid);
#endif

/*! trim the file-system to its minimum size
This allows to use wbfs as a wiidisc container
Expand Down
18 changes: 8 additions & 10 deletions libwbfs/libwbfs_macosx.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@


static int wbfs_read_sector(void *_fp, u32 lba, u32 count, void *buf) {
int file_des = *((int *)_fp);
int file_des = fileno((FILE *)_fp);
u64 off = lba;
off *= 512ULL;
size_t size = count * 512ULL;
Expand All @@ -38,7 +38,7 @@ static int wbfs_read_sector(void *_fp, u32 lba, u32 count, void *buf) {
}

static int wbfs_write_sector(void *_fp, u32 lba, u32 count, void *buf) {
int file_des = *((int *)_fp);
int file_des = fileno((FILE *)_fp);
u64 off = lba;
off *= 512ULL;
size_t size = count * 512ULL;
Expand Down Expand Up @@ -98,34 +98,32 @@ static int get_capacity(char *file, u32 *sector_size, u32 *n_sector) {
}

wbfs_t * wbfs_try_open_hd(char *fn, int reset) {
int *file_des_p = wbfs_malloc(sizeof(int));
u32 sector_size, n_sector;

if (!get_capacity(fn, &sector_size, &n_sector))
return NULL;

*file_des_p = open(fn, O_RDWR);
FILE *f = fopen(fn, "r+");

if (*file_des_p == 0)
if (!f)
return NULL;

return wbfs_open_hd(wbfs_read_sector, wbfs_write_sector, file_des_p,
return wbfs_open_hd(wbfs_read_sector, wbfs_write_sector, f,
sector_size , n_sector, reset);
}

wbfs_t * wbfs_try_open_partition(char *fn, int reset) {
int *file_des_p = wbfs_malloc(sizeof(int));
u32 sector_size, n_sector;

if (!get_capacity(fn, &sector_size, &n_sector))
return NULL;

*file_des_p = open(fn, O_RDWR);
FILE *f = fopen(fn, "r+");

if (*file_des_p == 0)
if (!f)
return NULL;

return wbfs_open_partition(wbfs_read_sector, wbfs_write_sector, file_des_p,
return wbfs_open_partition(wbfs_read_sector, wbfs_write_sector, f,
sector_size , n_sector, 0, reset);
}

Expand Down
2 changes: 2 additions & 0 deletions macosx/wbfs/wbfs.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,7 @@
GCC_PREPROCESSOR_DEFINITIONS = (
MAC_UI_STUFF,
ENABLE_RENAME,
ENABLE_CHANGE_DISKID,
);
INSTALL_PATH = /usr/local/bin;
PRODUCT_NAME = wbfs;
Expand All @@ -323,6 +324,7 @@
GCC_PREPROCESSOR_DEFINITIONS = (
MAC_UI_STUFF,
ENABLE_RENAME,
ENABLE_CHANGE_DISKID,
);
INSTALL_PATH = /usr/local/bin;
PRODUCT_NAME = wbfs;
Expand Down
Loading

0 comments on commit 77070e4

Please sign in to comment.