forked from pool/grub2
Accepting request 962647 from home:michael-chang:branches:Base:System
- Fix duplicated insmod part_gpt lines in grub.cfg (bsc#1197186) * 0001-grub-probe-Deduplicate-probed-partmap-output.patch OBS-URL: https://build.opensuse.org/request/show/962647 OBS-URL: https://build.opensuse.org/package/show/Base:System/grub2?expand=0&rev=409
This commit is contained in:
parent
91bf25e435
commit
a4bd7dba38
110
0001-grub-probe-Deduplicate-probed-partmap-output.patch
Normal file
110
0001-grub-probe-Deduplicate-probed-partmap-output.patch
Normal file
@ -0,0 +1,110 @@
|
||||
From ed0ac581ad3866197fc05c7cf48e39419a51f606 Mon Sep 17 00:00:00 2001
|
||||
From: Michael Chang <mchang@suse.com>
|
||||
Date: Fri, 18 Mar 2022 13:19:33 +0800
|
||||
Subject: [PATCH] grub-probe: Deduplicate probed partmap output
|
||||
|
||||
If the target device being probed is staked on top of other physical or logical
|
||||
devices, all containing device's partition map type will be printed once if
|
||||
--target=partmap is used. This usually results in duplicated output as same
|
||||
partition map type.
|
||||
|
||||
This in turn may clutter grub.cfg with many duplicated insmod part_[a-z]+ if
|
||||
the /boot is RAIDed because --target=partmap output is used to producing
|
||||
partmap modules required to access disk device.
|
||||
|
||||
Let's deduplicate that to make the grub.cfg looks better and disciplined.
|
||||
|
||||
Signed-off-by: Michael Chang <mchang@suse.com>
|
||||
---
|
||||
util/grub-probe.c | 59 +++++++++++++++++++++++++++++++++++++++++++----
|
||||
1 file changed, 55 insertions(+), 4 deletions(-)
|
||||
|
||||
diff --git a/util/grub-probe.c b/util/grub-probe.c
|
||||
index c08e46bbb..fb94f28fd 100644
|
||||
--- a/util/grub-probe.c
|
||||
+++ b/util/grub-probe.c
|
||||
@@ -153,6 +153,50 @@ do_print (const char *x, void *data)
|
||||
grub_printf ("%s%c", x, delim);
|
||||
}
|
||||
|
||||
+static int
|
||||
+check_duplicate_partmap (const char *name)
|
||||
+{
|
||||
+ static int alloc, used;
|
||||
+ static char **partmaps;
|
||||
+ int i;
|
||||
+
|
||||
+ if (!name)
|
||||
+ {
|
||||
+ if (partmaps)
|
||||
+ {
|
||||
+ for (i= 0; i < used; ++i)
|
||||
+ free (partmaps[i]);
|
||||
+ free (partmaps);
|
||||
+ partmaps = NULL;
|
||||
+ alloc = 0;
|
||||
+ used = 0;
|
||||
+ }
|
||||
+ return 1;
|
||||
+ }
|
||||
+
|
||||
+ for (i= 0; i < used; ++i)
|
||||
+ if (strcmp (partmaps[i], name) == 0)
|
||||
+ return 1;
|
||||
+
|
||||
+ if (alloc <= used)
|
||||
+ {
|
||||
+ alloc = (alloc) ? (alloc << 1) : 4;
|
||||
+ partmaps = xrealloc (partmaps, alloc * sizeof (*partmaps));
|
||||
+ }
|
||||
+
|
||||
+ partmaps[used++] = strdup (name);
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+static void
|
||||
+do_print_partmap (const char *x, void *data)
|
||||
+{
|
||||
+ char delim = *(const char *) data;
|
||||
+ if (check_duplicate_partmap (x) != 0)
|
||||
+ return;
|
||||
+ grub_printf ("%s%c", x, delim);
|
||||
+}
|
||||
+
|
||||
static void
|
||||
probe_partmap (grub_disk_t disk, char delim)
|
||||
{
|
||||
@@ -165,10 +209,14 @@ probe_partmap (grub_disk_t disk, char delim)
|
||||
}
|
||||
|
||||
for (part = disk->partition; part; part = part->parent)
|
||||
- printf ("%s%c", part->partmap->name, delim);
|
||||
+ {
|
||||
+ if (check_duplicate_partmap (part->partmap->name) != 0)
|
||||
+ continue;
|
||||
+ printf ("%s%c", part->partmap->name, delim);
|
||||
+ }
|
||||
|
||||
if (disk->dev->id == GRUB_DISK_DEVICE_DISKFILTER_ID)
|
||||
- grub_diskfilter_get_partmap (disk, do_print, &delim);
|
||||
+ grub_diskfilter_get_partmap (disk, do_print_partmap, &delim);
|
||||
|
||||
/* In case of LVM/RAID, check the member devices as well. */
|
||||
if (disk->dev->disk_memberlist)
|
||||
@@ -674,8 +722,11 @@ probe (const char *path, char **device_names, char delim)
|
||||
probe_cryptodisk_uuid (dev->disk, delim);
|
||||
|
||||
else if (print == PRINT_PARTMAP)
|
||||
- /* Check if dev->disk itself is contained in a partmap. */
|
||||
- probe_partmap (dev->disk, delim);
|
||||
+ {
|
||||
+ /* Check if dev->disk itself is contained in a partmap. */
|
||||
+ probe_partmap (dev->disk, delim);
|
||||
+ check_duplicate_partmap (NULL);
|
||||
+ }
|
||||
|
||||
else if (print == PRINT_PARTUUID)
|
||||
{
|
||||
--
|
||||
2.35.1
|
||||
|
@ -1,3 +1,9 @@
|
||||
-------------------------------------------------------------------
|
||||
Fri Mar 18 09:10:07 UTC 2022 - Michael Chang <mchang@suse.com>
|
||||
|
||||
- Fix duplicated insmod part_gpt lines in grub.cfg (bsc#1197186)
|
||||
* 0001-grub-probe-Deduplicate-probed-partmap-output.patch
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Wed Mar 16 14:57:02 UTC 2022 - Michael Chang <mchang@suse.com>
|
||||
|
||||
|
@ -362,6 +362,7 @@ Patch844: 0001-install-fix-software-raid1-on-esp.patch
|
||||
Patch845: 0001-mkimage-Fix-dangling-pointer-may-be-used-error.patch
|
||||
Patch846: 0002-Fix-Werror-array-bounds-array-subscript-0-is-outside.patch
|
||||
Patch847: 0003-reed_solomon-Fix-array-subscript-0-is-outside-array-.patch
|
||||
Patch848: 0001-grub-probe-Deduplicate-probed-partmap-output.patch
|
||||
|
||||
Requires: gettext-runtime
|
||||
%if 0%{?suse_version} >= 1140
|
||||
|
Loading…
Reference in New Issue
Block a user