* fs/affs.c (grub_sfs_read_extent ): Allow AFFS to be used on MBR style partitions.
Index: fs/affs.c
===================================================================
--- fs/affs.c (revision 27991)
+++ fs/affs.c (working copy)
@@ -25,6 +25,7 @@
#include <grub/dl.h>
#include <grub/types.h>
#include <grub/fshelp.h>
+#include <grub/partition.h>
/* The affs bootblock. */
struct grub_affs_bblock
@@ -166,6 +167,8 @@
struct grub_affs_data *data;
grub_uint32_t *rootblock = 0;
struct grub_affs_rblock *rblock;
+ grub_uint64_t rdb_blockcount, rdb_reserved;
+ grub_disk_addr_t rblknum;
int checksum = 0;
int checksumr = 0;
@@ -210,8 +213,16 @@
rblock = (struct grub_affs_rblock *) rootblock;
/* Read the rootblock. */
- grub_disk_read (disk, (disk->total_sectors >> 1) + blocksize, 0,
- GRUB_DISK_SECTOR_SIZE * 16, (char *) rootblock);
+ rdb_blockcount = disk->total_sectors;
+ rdb_reserved = 2;
+
+ if (disk->partition)
+ rdb_blockcount = disk->partition->len;
+
+ rblknum = (rdb_blockcount - 1 + rdb_reserved) >> 1;
+
+ grub_disk_read (disk, rblknum, 0,
+ GRUB_DISK_SECTOR_SIZE * 16, (char *) rootblock);
if (grub_errno)
goto fail;
@@ -242,7 +253,7 @@
data->disk = disk;
data->htsize = grub_be_to_cpu32 (rblock->htsize);
data->diropen.data = "">- data->diropen.block = (disk->total_sectors >> 1);
+ data->diropen.block = rblknum;
grub_free (rootblock);