The existing code in hfsp_volume.c tries to locate the alternate volume header at the block vol->maxblocks - 2. Currently for unwrapped HFS+ volumes, vol->maxblocks is never set from the main volume header once it is located and so it tries to find the backup volume at the (dummy) block 3 which inevitably fails.
On a secondary note until towards the end of the function, volume_open() assumes the block size is 512 bytes. Therefore once we determine the size of the volume from the main volume header in blocks, we need to convert it from the block size indicated in the volume header to a fixed 512 byte block size in order for the alternate volume header to be located correctly.
Signed-off-by: Mark Cave-Ayland mark.cave-ayland@ilande.co.uk --- openbios-devel/fs/hfsplus/hfsp_volume.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-)
diff --git a/openbios-devel/fs/hfsplus/hfsp_volume.c b/openbios-devel/fs/hfsplus/hfsp_volume.c index 802d700..e6d9d60 100644 --- a/openbios-devel/fs/hfsplus/hfsp_volume.c +++ b/openbios-devel/fs/hfsplus/hfsp_volume.c @@ -171,7 +171,9 @@ volume_read_wrapper(volume * vol, hfsp_vh* vh) UInt16 signature; char buf[vol->blksize]; char *p = buf; - + int ret; + UInt64 vol_size; + if( volume_readinbuf(vol, buf, 2) ) // Wrapper or volume header starts here return -1;
@@ -202,7 +204,14 @@ volume_read_wrapper(volume * vol, hfsp_vh* vh) } else if( signature == HFSP_VOLHEAD_SIG) { /* Native HFS+ volume */ p = buf; // Restore to begin of block - return volume_readbuf(vh, p); + ret = volume_readbuf(vh, p); + if( !ret ) { + /* When reading the initial partition we must use 512 byte blocks */ + vol_size = vh->blocksize * vh->total_blocks; + vol->maxblocks = vol_size / HFSP_BLOCKSZ; + } + + return ret; } else HFSP_ERROR(-1, "Neither Wrapper nor native HFS+ volume header found"); fail: