Hacking Discussion about a little WBFS extension

Wiimm

Developer
OP
Member
Joined
Aug 11, 2009
Messages
2,292
Trophies
1
Location
Germany
Website
wiimmfi.de
XP
1,519
Country
Germany
Discussion about a little WBFS extension

Each WBFS partition/file has an internal data structure for each disc. I call this info area wbfs inode or short inode. Each inode consists of 2 parts:
  • A copy of the first 256 bytes of the disc. This parts contains ID, name, language and some more infos.
  • The block mapping (Wii block -> WBFS block)
I missing some infos like ctime, mtime and other infos for a better recovery.

My idea: Only some bytes of the disc header copy are needed by usb loaders and wbfs managers. The second half of the disc header copy is completely senseless. And so I want to use this second half to hold more infos.

And this is my first idea:
Code:
// Some definitions. The inode is located in the padding area of the ISO header
// see http://www.wiibrew.org/wiki/Wiidisc#Header for more details

#define WBFS_INODE_INFO_VERSIONÂÂÂÂÂÂÂÂ 1
#define WBFS_INODE_INFO_HEAD_SIZEÂÂÂÂ12
#define WBFS_INODE_INFO_HEAD_CMP_SIZEÂÂÂÂ10
#define WBFS_INODE_INFO_OFFÂÂÂÂÂÂÂÂ0x80
#define WBFS_INODE_INFO_SIZEÂÂÂÂÂÂÂÂ(0x100-WBFS_INODE_INFO_OFF)

// all binary data are store in network byte order (big endian)

typedef struct wbfs_inode_info_s
{
ÂÂÂÂ// A complete copy of the first WBFS_INODE_INFO_HEAD_SIZE (12) bytes
ÂÂÂÂ// of the WBFS header. The first WBFS_INODE_INFO_HEAD_CMP_SIZE (10)
ÂÂÂÂ// bytes can be used to validate the existence of this info block.
ÂÂÂÂ// They are also good for recovery.

ÂÂÂÂbe32_t magic;ÂÂÂÂÂÂÂÂ// the magic (char*)"WBFS"
ÂÂÂÂbe32_t n_hd_sec;ÂÂÂÂ// total number of hd_sec in this partition
ÂÂÂÂu8ÂÂhd_sec_sz_s;ÂÂÂÂ// sector size in this partition
ÂÂÂÂu8ÂÂwbfs_sec_sz_s;ÂÂÂÂ// size of a wbfs sec

ÂÂÂÂu8ÂÂwbfs_version;ÂÂÂÂ// informative version number
ÂÂÂÂu8ÂÂhead_padding;

ÂÂÂÂ// The version number of this data structure.
ÂÂÂÂ// I may be importand for future extensions

ÂÂÂÂbe32_t info_version;ÂÂÂÂ// == 1

ÂÂÂÂ// 64 bit time stamps: They are only informative but nice to have.
ÂÂÂÂ//ÂÂ- itime is ths disc inserting time.
ÂÂÂÂ//ÂÂÂÂIf 2 discs uses the same wbfs block a repair function knows
ÂÂÂÂ//ÂÂÂÂwhich one disc are newer and which is definitly bad.
ÂÂÂÂ//ÂÂ- mtime is a copy of the mtime of the source file.
ÂÂÂÂ//ÂÂÂÂIt is also changed if the the ISO-header is modified (renamed).
ÂÂÂÂ//ÂÂÂÂWhile extrating the mtime of dest file is set by this mtime.
ÂÂÂÂ//ÂÂ- ctime is updated if adding, renaming.
ÂÂÂÂ//ÂÂ- atime can be updated by usb loaders when loading the disc.
ÂÂÂÂ//ÂÂ- dtime is only set for deleted games.

ÂÂÂÂbe64_t itime;ÂÂÂÂÂÂÂÂ// the disc insertion time
ÂÂÂÂbe64_t mtime;ÂÂÂÂÂÂÂÂ// the last modification time (copied from source)
ÂÂÂÂbe64_t ctime;ÂÂÂÂÂÂÂÂ// the last status changed time
ÂÂÂÂbe64_t atime;ÂÂÂÂÂÂÂÂ// the last access time
ÂÂÂÂbe64_t dtime;ÂÂÂÂÂÂÂÂ// the deletion time

ÂÂÂÂ// there is enough space for more information like a game load counter
ÂÂÂÂ// or other statistics and game settings. This infos can be share across
ÂÂÂÂ// usb loaders.

ÂÂÂÂ// EXAMPLES:
ÂÂÂÂ//ÂÂÂÂbe32_tÂÂÂÂload_count;
ÂÂÂÂ//ÂÂÂÂu8ÂÂÂÂfavorite
ÂÂÂÂ//ÂÂÂÂu8ÂÂÂÂios

ÂÂÂÂ// padding up to WBFS_INODE_INFO_SIZE bytes, always filled with zeros

ÂÂÂÂu8 padding[ WBFS_INODE_INFO_SIZE - WBFS_INODE_INFO_HEAD_SIZE
ÂÂÂÂÂÂÂÂÂÂÂÂ- 0 /* num ofÂÂ8 bit parameters */ * sizeof(u8)
ÂÂÂÂÂÂÂÂÂÂÂÂ- 0 /* num of 16 bit parameters */ * sizeof(be16_t)
ÂÂÂÂÂÂÂÂÂÂÂÂ- 1 /* num of 32 bit parameters */ * sizeof(be32_t)
ÂÂÂÂÂÂÂÂÂÂÂÂ- 5 /* num of 64 bit parameters */ * sizeof(be64_t) ];

} wbfs_inode_info_t;

// sizeof(wbfs_inode_info_t) == WBFS_INODE_INFO_SIZE

Constructive ideas and discussions are welcome. Flames like 'FAT is better' are not constructive!
 

Wiimm

Developer
OP
Member
Joined
Aug 11, 2009
Messages
2,292
Trophies
1
Location
Germany
Website
wiimmfi.de
XP
1,519
Country
Germany
I have implemented the ideas of above into WWT. Here is an extract of the document WBFS.txt which is part of WWT.

Code:

*******************************************************************************
*******ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂExtension called 'INODE INFO'ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ*******
*******************************************************************************

I have implemented a WBFS extension that I call 'INODE INFO'.

There is a discussion thread about this in GBAtemp:
http://gbatemp.net/index.php?showtopic=210772

The idea:
For each disc slot within WBFS there is place to manage the disc. I call this
area INODE (It's not a real inode, but simmilar). Every inode habe two parts:
- Copy of the first 256 bytes of the ISO image
- Memory mapping table (location if the ISO blocks within the WBFS).
To manage the disc only the first 128 bytes of the ISO header copy are needed.
The second half is unused memory. Up from wwt v0.33a I use this area for
additional information.

This are definitons and data structure of the INODE INFO (extract of libwbfs.h):

#define WBFS_INODE_INFO_VERSIONÂÂÂÂÂÂÂÂÂÂ 1
#define WBFS_INODE_INFO_HEAD_SIZEÂÂÂÂÂÂÂÂ12
#define WBFS_INODE_INFO_HEAD_CMP_SIZEÂÂÂÂ10
#define WBFS_INODE_INFO_OFFÂÂÂÂÂÂÂÂÂÂÂÂ0x80
#define WBFS_INODE_INFO_SIZEÂÂÂÂÂÂÂÂÂÂ (0x100-WBFS_INODE_INFO_OFF)

typedef struct wbfs_inode_info_s
{
ÂÂÂÂ// A complete copy of the first WBFS_INODE_INFO_HEAD_SIZE (12) bytes
ÂÂÂÂ// of the WBFS header. The first WBFS_INODE_INFO_HEAD_CMP_SIZE (10)
ÂÂÂÂ// bytes can be used to validate the existence of this info block.
ÂÂÂÂ// They are also good for recovery.

ÂÂÂÂbe32_t magic;ÂÂÂÂÂÂÂÂ // the magic (char*)"WBFS"
ÂÂÂÂbe32_t n_hd_sec;ÂÂÂÂÂÂ// total number of hd_sec in this partition
ÂÂÂÂu8ÂÂhd_sec_sz_s;ÂÂÂÂÂÂ// sector size in this partition
ÂÂÂÂu8ÂÂwbfs_sec_sz_s;ÂÂÂÂ// size of a wbfs sec

ÂÂÂÂu8ÂÂwbfs_version;ÂÂÂÂ // informative version number
ÂÂÂÂu8ÂÂhead_padding;

ÂÂÂÂ// The version number of this data structure.
ÂÂÂÂ// I may be importand for future extensions

ÂÂÂÂbe32_t info_version;ÂÂ// == 1

ÂÂÂÂ// 64 bit time stamps: They are only informative but nice to have.
ÂÂÂÂ//ÂÂ- itime is ths disc inserting time.
ÂÂÂÂ//ÂÂÂÂIf 2 discs uses the same wbfs block a repair function knows
ÂÂÂÂ//ÂÂÂÂwhich one disc are newer and which is definitly bad.
ÂÂÂÂ//ÂÂ- mtime is a copy of the mtime of the source file.
ÂÂÂÂ//ÂÂÂÂIt is also changed if the the ISO-header is modified (renamed).
ÂÂÂÂ//ÂÂÂÂWhile extrating the mtime of dest file is set by this mtime.
ÂÂÂÂ//ÂÂ- ctime is updated if adding, renaming.
ÂÂÂÂ//ÂÂ- atime can be updated by usb loaders when loading the disc.
ÂÂÂÂ//ÂÂ- dtime is only set for deleted games.

ÂÂÂÂbe64_t itime;ÂÂ// the disc insertion time
ÂÂÂÂbe64_t mtime;ÂÂ// the last modification time (copied from source)
ÂÂÂÂbe64_t ctime;ÂÂ// the last status changed time
ÂÂÂÂbe64_t atime;ÂÂ// the last access time
ÂÂÂÂbe64_t dtime;ÂÂ// the deletion time

ÂÂÂÂ// there is enough space for more information like a game load counter
ÂÂÂÂ// or other statistics and game settings. This infos can be share across
ÂÂÂÂ// usb loaders.

ÂÂÂÂ// EXAMPLES:
ÂÂÂÂ//ÂÂÂÂbe32_tÂÂload_count;
ÂÂÂÂ//ÂÂÂÂu8ÂÂÂÂÂÂfavorite
ÂÂÂÂ//ÂÂÂÂu8ÂÂÂÂÂÂios

ÂÂÂÂ// padding up to WBFS_INODE_INFO_SIZE bytes, always filled with zeros

ÂÂÂÂu8 padding[ WBFS_INODE_INFO_SIZE - WBFS_INODE_INFO_HEAD_SIZE
ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ- 0 /* num ofÂÂ8 bit parameters */ * sizeof(u8)
ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ- 0 /* num of 16 bit parameters */ * sizeof(be16_t)
ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ- 1 /* num of 32 bit parameters */ * sizeof(be32_t)
ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ- 5 /* num of 64 bit parameters */ * sizeof(be64_t) ];

} wbfs_inode_info_t;

The first 10 bytes can be used to check the existence of a valid inode info.
This data is also good for recovering. Because of this validation check this
extension is abolut compatible with all other USB loaders and WBFS managers:
1.) They ignore this indoe information.
2.) They copy the contents of the ISO image and the INDOE-INFO-area is always
ÂÂÂÂ filled with garbage (zeros).

The time stamps are informative. wwt and wit uses them in the following way:

All commands:
ÂÂÂÂIf creating a indode info because the previous is invalid, then itime,
ÂÂÂÂmtime, ctime and atime are set to the current time and dtime is cleared.

wwt FORMAT:
ÂÂÂÂClear all time stamps. dtime is set to current time.

wwt ADD:
ÂÂÂÂSet itime, ctime, and atime to the current time. mtime is copied from the
ÂÂÂÂsource mtime. dtime is cleared. Adding can be done conditionally with the
ÂÂÂÂoption --newer.

wwt PHANTOM:
ÂÂÂÂSet itime, mtime, ctime, and atime to the current time. dtime is cleared.

wwt EXTRACT:
ÂÂÂÂUse mtime to set mtime of the destination file. If extracting to a WBFS
ÂÂÂÂthen the time stamps within the inode is set like the ADD command. The
ÂÂÂÂatime of the source is set to the current time.

wwt RENAME+SETTITLE:
ÂÂÂÂIf only ID or title of the inode info is changed, then ctime and atime are
ÂÂÂÂset to the current time. If ID or title of the ISO are changed, then mtime,
ÂÂÂÂctime and atime are set.

wwt REMOVE:
ÂÂÂÂThe dtime is set to the current time.

wwt TOUCH:
ÂÂÂÂitime, mtime, ctime and/or atime can be changed to the current time or
ÂÂÂÂto a user defined time.

wwt LIST:
ÂÂÂÂIn the extended view it shows the mtime (default) or any other time, but
ÂÂÂÂonly one, controlled by options. Sorting by time is also possible.

wwt DUMP:
ÂÂÂÂIn disc view it shows all non zero time stamps of each valid inode.
 

Site & Scene News

Popular threads in this forum

General chit-chat
Help Users
    SylverReZ @ SylverReZ: @Sonic Angel Knight, Yes.