[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 1/1] Fix partition offset for EBR partitions on FreeBSD
From: |
James Clarke |
Subject: |
[PATCH 1/1] Fix partition offset for EBR partitions on FreeBSD |
Date: |
Tue, 26 Feb 2019 15:12:36 +0000 |
User-agent: |
NeoMutt/20170113 (1.7.2) |
On FreeBSD, grub uses the "start" rather than the "offset" config
property to calculate the starting sector for partitions, which gives
the wrong value for EBR partitions:
> address@hidden:/home/jrtc27/src/grub2/grub2-2.02+dfsg1# geom part list
> (output trimmed and annotated)
> Geom name: ada0
> scheme: MBR
> Providers:
> 1. Name: ada0s1
> offset: 1048576 # ie 2048 sectors
> start: 2048
> 2. Name: ada0s2
> offset: 64000883712 # ie 125001726 sectors
> start: 125001726
>
> Geom name: ada0s2
> scheme: EBR
> Providers:
> 1. Name: ada0s5
> offset: 1024 # ie 2 sectors; add 125001726 from ada0s2 to get 125001728
> start: 0
> 2. Name: ada0s6
> offset: 183628727296 # ie 358649858 sectors; add 125001726 from ada0s2 to
> get 483651584
> start: 358647810 # add 125001726 from ada0s2 to get 483649536
> address@hidden:~# fdisk -l /dev/ada0
> Disk /dev/ada0: 238.5 GiB, 256060514304 bytes, 500118192 sectors
> Units: sectors of 1 * 512 = 512 bytes
> Sector size (logical/physical): 512 bytes / 512 bytes
> I/O size (minimum/optimal): 512 bytes / 512 bytes
> Disklabel type: dos
> Disk identifier: 0x20b8cc40
>
> Device Boot Start End Sectors Size Id Type
> /dev/ada0p1 * 2048 124999679 124997632 59.6G 83 Linux
> /dev/ada0p2 125001726 500117503 375115778 178.9G 5 Extended
> /dev/ada0p5 125001728 483649535 358647808 171G a5 FreeBSD
> /dev/ada0p6 483651584 500117503 16465920 7.9G 82 Linux swap / Solaris
This clearly shows that the "start" field is wrong and "offset" should
be used instead. The attached patch does this and has been tested on the
above system.
Signed-off-by: James Clarke <address@hidden>
Reviewed-by: Colin Watson <address@hidden>
---
grub-core/osdep/freebsd/getroot.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/grub-core/osdep/freebsd/getroot.c
b/grub-core/osdep/freebsd/getroot.c
index ccc1d7028..4f1720451 100644
--- a/grub-core/osdep/freebsd/getroot.c
+++ b/grub-core/osdep/freebsd/getroot.c
@@ -338,8 +338,9 @@ grub_util_follow_gpart_up (const char *name,
grub_disk_addr_t *off_out, char **n
grub_util_follow_gpart_up (name_tmp, &off, name_out);
free (name_tmp);
LIST_FOREACH (config, &provider->lg_config, lg_config)
- if (strcasecmp (config->lg_name, "start") == 0)
- off += strtoull (config->lg_val, 0, 10);
+ if (strcasecmp (config->lg_name, "offset") == 0)
+ off += strtoull (config->lg_val, 0, 10)
+ / provider->lg_sectorsize;
if (off_out)
*off_out = off;
return;
--
2.20.1