grub-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: RDB partition tables in AROS


From: Alain Greppin
Subject: Re: RDB partition tables in AROS
Date: Sat, 08 Mar 2008 17:11:13 +0100

Hello,

Here is a diff againt our svn repository. We have grub2 version 1.96
here.

The changes log:
- recognize RDB partion tables inside MBR, this is needed for AROS to
boot on a PC
- fix AFFS filesystem for AROS
- minor bug fix in SFS: count of nodes in extent-btree is written as big
endian on disk
- fixed gensymlist.sh to let us build with a compiler command having
arguments

Regards,
Alain Greppin


Index: fs/affs.c
===================================================================
--- fs/affs.c   (revision 27991)
+++ fs/affs.c   (working copy)
@@ -25,6 +25,9 @@
#include <grub/dl.h>
#include <grub/types.h>
#include <grub/fshelp.h>
+#ifdef __AROS__
+#include <grub/partition.h>
+#endif

/* The affs bootblock.  */
struct grub_affs_bblock
@@ -209,8 +212,22 @@
   rblock = (struct grub_affs_rblock *) rootblock;

   /* Read the rootblock.  */
+#ifdef __AROS__
+  grub_uint64_t reservedblocks = 2;
+  grub_uint64_t countblocks;
+  if (disk->partition)
+    countblocks = disk->partition->len;
+  else
+    countblocks = disk->total_sectors;
+
+  grub_disk_addr_t rblknum = (countblocks - 1 + reservedblocks) / 2;
+
+  grub_disk_read (disk, rblknum, 0,
+                 GRUB_DISK_SECTOR_SIZE * 16, (char *) rootblock);
+#else
   grub_disk_read (disk, (disk->total_sectors >> 1) + blocksize, 0,
                  GRUB_DISK_SECTOR_SIZE * 16, (char *) rootblock);
+#endif
   if (grub_errno)
     goto fail;

@@ -241,7 +258,11 @@
   data->disk = disk;
   data->htsize = grub_be_to_cpu32 (rblock->htsize);
   data->diropen.data = data;
+#ifdef __AROS__
+  data->diropen.block = rblknum;
+#else
   data->diropen.block = (disk->total_sectors >> 1);
+#endif

   grub_free (rootblock);

Index: fs/sfs.c
===================================================================
--- fs/sfs.c    (revision 27991)
+++ fs/sfs.c    (working copy)
@@ -172,7 +172,8 @@
          return grub_errno;
        }

-      for (i = 0; i < tree->nodes; i++)
+      grub_uint16_t nodescount = grub_be_to_cpu16(tree->nodes);
+      for (i = 0; i < nodescount; i++)
        {

#define EXTNODE(tree, index)                                           \
@@ -189,7 +190,7 @@

          /* In case the last node is reached just use that one, it is
             the right match.  */
-         if (i + 1 == tree->nodes && !tree->leaf)
+         if (i + 1 == nodescount && !tree->leaf)
            {
              next = grub_be_to_cpu32 (EXTNODE (tree, i)->data);
              break;
Index: gensymlist.sh.in
===================================================================
--- gensymlist.sh.in    (revision 27991)
+++ gensymlist.sh.in    (working copy)
@@ -14,7 +14,7 @@
### The configure script will replace these variables.

address@hidden@
address@hidden@
+CC="@CC@"


cat <<EOF
Index: include/grub/pc_partition.h
===================================================================
--- include/grub/pc_partition.h (revision 27991)
+++ include/grub/pc_partition.h (working copy)
@@ -206,4 +206,10 @@
          || type == GRUB_PC_PARTITION_TYPE_NETBSD);
}

+static inline int
+grub_pc_partition_is_rdb(int type)
+{
+  return (type == 0x30);
+}
+
#endif /* ! GRUB_PC_PARTITION_HEADER */
Index: partmap/amiga.c
===================================================================
--- partmap/amiga.c     (revision 27991)
+++ partmap/amiga.c     (working copy)
@@ -87,7 +87,10 @@

   /* Enforce raw disk access.  */
   raw = *disk;
+#ifndef __AROS__
   raw.partition = 0;
+#endif
+  part.data = NULL;

   /* The RDSK block is one of the first 15 blocks.  */
   for (pos = 0; pos < 15; pos++)
@@ -210,7 +213,13 @@

GRUB_MOD_INIT(amiga_partition_map)
{
+#ifdef __AROS__
+  extern struct grub_partition_map *grub_rdb_partition_map;
+  grub_rdb_partition_map = &grub_amiga_partition_map;
+#endif
+
   grub_partition_map_register (&grub_amiga_partition_map);
+
#ifndef GRUB_UTIL
   my_mod = mod;
#endif
Index: partmap/pc.c
===================================================================
--- partmap/pc.c        (revision 27991)
+++ partmap/pc.c        (working copy)
@@ -24,6 +24,9 @@
#include <grub/misc.h>
#include <grub/dl.h>

+/* RDB partition tables for AROS */
+struct grub_partition_map *grub_rdb_partition_map = NULL;
+
static struct grub_partition_map grub_pc_partition_map;

#ifndef GRUB_UTIL
@@ -149,8 +152,42 @@
              && ! grub_pc_partition_is_extended (e->type))
            {
              pcdata.dos_part++;
-             
-             if (hook (disk, &p))
+
+            /* Check if this is a RDB partition table.  */
+            if (grub_rdb_partition_map &&
grub_pc_partition_is_rdb(e->type))
+            {
+               struct grub_partition p2;
+               struct grub_disk raw2;
+               int ok = 0;
+
+               auto int rdb_hook(grub_disk_t disk, const
grub_partition_t p);
+
+               int rdb_hook(grub_disk_t disk __attribute__((unused)),
+                            const grub_partition_t part)
+               {
+                 p2 = *part;
+                 pcdata.bsd_part = part->index;
+
+                 p2.start  += p.start;
+                 p2.offset += p.offset;
+                 p2.data    = &pcdata;
+                 p2.partmap = &grub_pc_partition_map;
+
+                 grub_dprintf("partition", "RDB part %c start=%ld\n",
+                              (char)('a' + part->index),
(long)p2.start);
+
+                 ok = hook(disk, &p2);
+                 return ok;
+               }
+
+               raw2 = raw;
+               raw2.partition = &p;
+
+               grub_rdb_partition_map->iterate(&raw2, rdb_hook);
+               if (ok)
+                   goto finish;
+             }
+             else if (hook (disk, &p))
                goto finish;

              /* Check if this is a BSD partition.  */






reply via email to

[Prev in Thread] Current Thread [Next in Thread]