]> git.ipfire.org Git - thirdparty/grub.git/commitdiff
osdep/freebsd: Fix partition calculation for EBR entries
authorJames Clarke <jrtc27@jrtc27.com>
Tue, 26 Feb 2019 18:40:14 +0000 (18:40 +0000)
committerDaniel Kiper <daniel.kiper@oracle.com>
Tue, 5 Mar 2019 09:21:54 +0000 (10:21 +0100)
For EBR partitions, "start" is the relative starting sector of the EBR
header itself, whereas "offset" is the relative starting byte of the
partition's contents, excluding the EBR header and any padding. Thus we
must use "offset", and divide by the sector size to convert to sectors.

Fixes Debian bug #923253.

Signed-off-by: James Clarke <jrtc27@jrtc27.com>
Reviewed-by: Colin Watson <cjwatson@ubuntu.com>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
grub-core/osdep/freebsd/getroot.c

index ccc1d7028d8c56737a8bf50bac3feed16a27aa93..b1e8244952cefdeb97957564c3c266fb51c6ff4d 100644 (file)
@@ -338,8 +338,8 @@ 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;