j
: Next unread message k
: Previous unread message j a
: Jump to all threads
j l
: Jump to MailingList overview
Author: mcayland Date: Sun Oct 7 17:26:46 2012 New Revision: 1064 URL: http://tracker.coreboot.org/trac/openbios/changeset/1064
Log: Fix bug related to opening backup volumes in libhfsp's volume_open().
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
Modified: trunk/openbios-devel/fs/hfsplus/hfsp_volume.c
Modified: trunk/openbios-devel/fs/hfsplus/hfsp_volume.c ============================================================================== --- trunk/openbios-devel/fs/hfsplus/hfsp_volume.c Tue Aug 21 00:29:42 2012 (r1063) +++ trunk/openbios-devel/fs/hfsplus/hfsp_volume.c Sun Oct 7 17:26:46 2012 (r1064) @@ -171,7 +171,9 @@ 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 @@ } 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: