Improve support for mac partition tables with logical sector size != 512
On 12/16/2010 04:01 PM, Peter Jones wrote:
On mac partition tables which specify a sector size larger than the
physical sector size, we need to reallocate the buffer after we
determine the correct sector size.
This appears to be a normal condition on disks in the wild that are>2TB
and use Mac partition tables (for example, the rescue image for the
MacBookAir3,1), so also don't raise an exception in _disk_analyse_block_size()
when we find that.
This paragraph is wrong. I'll send a reply with a corrected patch.
Also simplify the code in _disk_analyse_block_size() a bit since there's
no reason to ever do the byteswapping more than once or convert everything to
512-byte multiples since we neither load nor store it that way.
---
libparted/labels/mac.c | 44 ++++++++++++++++++++++++++------------------
1 files changed, 26 insertions(+), 18 deletions(-)
+ sector_size = disk->dev->sector_size;
if (!_disk_analyse_block_size (disk, raw_disk))
goto error;
+
+ /* If dev->sector_size changed when we did ptt_read_sector(),
+ then the buffer size is wrong and we'll take a segfault
+ down the line unless we re-allocate it here. */
+ if (disk->dev->sector_size != sector_size) {
+ free(buf);
+ buf = 0;
+ if (!ptt_read_sector(disk->dev, 0,&buf))
+ return 0;
+
+ MacRawDisk *raw_disk = (MacRawDisk *) buf;
+
+ if (!_check_signature (raw_disk))
+ goto error;
+
+ if (!_disk_analyse_block_size (disk, raw_disk))
+ goto error;
+ }
+
if (!_disk_analyse_ghost_size (disk))
goto error;
ghost_size = mac_disk_data->ghost_size;
--
Peter
Growth for the sake of growth is the ideology of the cancer cell.