Hell[o]

The affs suppors is broken ATM for ieee1275 as it uses total_sectors
from grub_disk_t and this field is not valid on OF. There is still
some problems for partitions with block size != 512, but at last it
makes possible to use it in most cases.

-- 
--- Marcin 'Morgoth' Kurek ---
diff -urN grub2.org/fs/affs.c grub2/fs/affs.c
--- grub2.org/fs/affs.c	2007-08-02 20:40:36.000000000 +0200
+++ grub2/fs/affs.c	2007-09-15 10:23:35.550133111 +0200
@@ -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
@@ -97,6 +98,9 @@
   struct grub_fshelp_node diropen;
   grub_disk_t disk;
 
+  /* Size in sectors */
+  grub_uint64_t len;
+
   /* Blocksize in sectors.  */
   int blocksize;
 
@@ -170,10 +174,17 @@
   int checksumr = 0;
   int blocksize = 0;
 
+
   data = grub_malloc (sizeof (struct grub_affs_data));
   if (!data)
     return 0;
 
+  /* total_sectors are not valid on ieee1275 */
+  if(disk->partition)
+    data->len = grub_partition_get_len (disk->partition);
+  else
+    data->len = disk->total_sectors;
+
   /* Read the bootblock.  */
   grub_disk_read (disk, 0, 0, sizeof (struct grub_affs_bblock),
 		  (char *) &data->bblock);
@@ -194,12 +205,6 @@
       goto fail;
     }
 
-  /* Read the bootblock.  */
-  grub_disk_read (disk, 0, 0, sizeof (struct grub_affs_bblock),
-		  (char *) &data->bblock);
-  if (grub_errno)
-    goto fail;
-
   /* No sane person uses more than 8KB for a block.  At least I hope
      for that person because in that case this won't work.  */
   rootblock = grub_malloc (GRUB_DISK_SECTOR_SIZE * 16);
@@ -209,7 +214,7 @@
   rblock = (struct grub_affs_rblock *) rootblock;
 
   /* Read the rootblock.  */
-  grub_disk_read (disk, (disk->total_sectors >> 1) + blocksize, 0,
+  grub_disk_read (disk, (data->len >> 1) + blocksize, 0,
 		  GRUB_DISK_SECTOR_SIZE * 16, (char *) rootblock);
   if (grub_errno)
     goto fail;
@@ -241,7 +246,7 @@
   data->disk = disk;
   data->htsize = grub_be_to_cpu32 (rblock->htsize);
   data->diropen.data = data;
-  data->diropen.block = (disk->total_sectors >> 1);
+  data->diropen.block = (data->len >> 1);
 
   grub_free (rootblock);
 
@@ -522,7 +527,7 @@
     {
       /* The rootblock maps quite well on a file header block, it's
 	 something we can use here.  */
-      grub_disk_read (data->disk, disk->total_sectors >> 1,
+      grub_disk_read (data->disk, data->len >> 1,
 		      data->blocksize * (GRUB_DISK_SECTOR_SIZE
 					 - GRUB_AFFS_FILE_LOCATION),
 		      sizeof (file), (char *) &file);
_______________________________________________
Grub-devel mailing list
Grub-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/grub-devel

Reply via email to