C. P. Ghost wrote: > On Wed, May 19, 2010 at 12:06 AM, C. P. Ghost <[email protected]> wrote: > >> 2010/5/18 Vladimir 'φ-coder/phcoder' Serbinenko <[email protected]>: >> >>> This bsdlabel has 2 strangenesses. First one is seen in your log: >>> >>> a: 497936 16 unused 0 0 >>> In other words for some strange reason it's declared as unused entry slot. >>> >> Ah, you're right! My mistake. I'll edit the type to "4.2BSD" >> and will try again. >> > > Okay, first with the original non-patched 1.98 grub2 version, > after setting the type to 4.2BSD in bsdlabel: > > phenom# bsdlabel /dev/md5555s1 > # /dev/md5555s1: > 8 partitions: > # size offset fstype [fsize bsize bps/cpg] > a: 48116 16 4.2BSD 0 0 0 > c: 48132 0 unused 0 0 # "raw" part, don't > edit > > phenom# newfs /dev/md5555s1a > /dev/md5555s1a: 23.5MB (48116 sectors) block size 16384, fragment size 2048 > using 4 cylinder groups of 5.88MB, 376 blks, 768 inodes. > super-block backups (for fsck -b #) at: > 160, 12192, 24224, 36256 > > phenom# mount /dev/md5555s1a /mnt > > phenom# grub-install --root-directory=/mnt --modules=ufs2 /dev/md5555 > /usr/local/sbin/grub-probe: error: unknown filesystem. > Installation finished. No error reported. > > This copies /boot/grub/* to /mnt as before. Now, if I run qemu, I get > dropped into grub-rescue: > > % qemu -hda bsddisk.img > GRUB loading. > Welcome to GRUB! > > error: unknown filesystem. > Entering rescue mode... > grub rescue> _ > > grub rescue> insmod part_msdos > grub rescue> insmod part_bsd > error: unknown filesystem. > > Unfortunately, the patch doesn't apply cleanly (against the > bzr version): > > % patch -p0 < ../../patch-002 > Hmm... Looks like a unified diff to me... > The text leading up to this was: > -------------------------- > |--- partmap/bsdlabel.c 2010-03-26 14:44:13 +0000 > |+++ partmap/bsdlabel.c 2010-05-18 22:13:37 +0000 > -------------------------- > Patching file partmap/bsdlabel.c using Plan A... > Hunk #1 succeeded at 37 with fuzz 1. > Hunk #2 succeeded at 46. > Hunk #3 failed at 86. > 1 out of 3 hunks failed--saving rejects to partmap/bsdlabel.c.rej > Hmm... Ignoring the trailing garbage. > done > > % cat partmap/bsdlabel.c.rej > *************** > *** 68,78 **** > p.len = grub_le_to_cpu32 (be.size); > p.partmap = &grub_bsdlabel_partition_map; > > - if (be.fs_type != GRUB_PC_PARTITION_BSD_TYPE_UNUSED) > if (hook (disk, &p)) > return grub_errno; > - > - pos += sizeof (struct grub_partition_bsd_entry); > } > > return GRUB_ERR_NONE; > --- 86,94 ---- > p.len = grub_le_to_cpu32 (be.size); > p.partmap = &grub_bsdlabel_partition_map; > > + if (p.len != 0) > if (hook (disk, &p)) > return grub_errno; > } > > return GRUB_ERR_NONE; > > Any idea? > > Mailer. Now I attach it > Thanks, > -cpghost. > >
-- Regards Vladimir 'φ-coder/phcoder' Serbinenko
=== modified file 'include/grub/bsdlabel.h'
--- include/grub/bsdlabel.h 2010-02-06 17:43:37 +0000
+++ include/grub/bsdlabel.h 2010-05-18 22:05:09 +0000
@@ -63,6 +63,8 @@
#define GRUB_PC_PARTITION_OPENBSD_TYPE_NTFS 18
#define GRUB_PC_PARTITION_OPENBSD_TYPE_RAID 19
+#define GRUB_PC_PARTITION_BSD_LABEL_WHOLE_DISK_PARTITION 2
+
/* The BSD partition entry. */
struct grub_partition_bsd_entry
{
=== modified file 'partmap/bsdlabel.c'
--- partmap/bsdlabel.c 2010-03-26 14:44:13 +0000
+++ partmap/bsdlabel.c 2010-05-18 22:13:37 +0000
@@ -37,9 +37,6 @@
grub_disk_addr_t delta = 0;
unsigned pos;
- /* BSDLabel offsets are absolute even when it's embed inside partition. */
- delta = grub_partition_get_start (disk->partition);
-
/* Read the BSD label. */
if (grub_disk_read (disk, GRUB_PC_PARTITION_BSD_LABEL_SECTOR,
0, sizeof (label), &label))
@@ -49,15 +46,36 @@
if (label.magic != grub_cpu_to_le32 (GRUB_PC_PARTITION_BSD_LABEL_MAGIC))
return grub_error (GRUB_ERR_BAD_PART_TABLE, "no signature");
+ /* A kludge to determine a base of be.offset. */
+ if (GRUB_PC_PARTITION_BSD_LABEL_WHOLE_DISK_PARTITION
+ < grub_cpu_to_le16 (label.num_partitions))
+ {
+ struct grub_partition_bsd_entry whole_disk_be;
+
+ pos = sizeof (label) + GRUB_PC_PARTITION_BSD_LABEL_SECTOR
+ * GRUB_DISK_SECTOR_SIZE + sizeof (struct grub_partition_bsd_entry)
+ * GRUB_PC_PARTITION_BSD_LABEL_WHOLE_DISK_PARTITION;
+
+ if (grub_disk_read (disk, pos / GRUB_DISK_SECTOR_SIZE,
+ pos % GRUB_DISK_SECTOR_SIZE, sizeof (whole_disk_be),
+ &whole_disk_be))
+ return grub_errno;
+
+ delta = grub_le_to_cpu32 (whole_disk_be.offset);
+ }
+
pos = sizeof (label) + GRUB_PC_PARTITION_BSD_LABEL_SECTOR
* GRUB_DISK_SECTOR_SIZE;
for (p.number = 0;
p.number < grub_cpu_to_le16 (label.num_partitions);
- p.number++)
+ p.number++, pos += sizeof (struct grub_partition_bsd_entry))
{
struct grub_partition_bsd_entry be;
+ if (p.number == GRUB_PC_PARTITION_BSD_LABEL_WHOLE_DISK_PARTITION)
+ continue;
+
p.offset = pos / GRUB_DISK_SECTOR_SIZE;
p.index = pos % GRUB_DISK_SECTOR_SIZE;
@@ -68,11 +86,9 @@
p.len = grub_le_to_cpu32 (be.size);
p.partmap = &grub_bsdlabel_partition_map;
- if (be.fs_type != GRUB_PC_PARTITION_BSD_TYPE_UNUSED)
+ if (p.len != 0)
if (hook (disk, &p))
return grub_errno;
-
- pos += sizeof (struct grub_partition_bsd_entry);
}
return GRUB_ERR_NONE;
signature.asc
Description: OpenPGP digital signature
_______________________________________________ Grub-devel mailing list [email protected] http://lists.gnu.org/mailman/listinfo/grub-devel
