#33 grub-core: add flag to only search root dev
Closed 7 months ago by nfrayer. Opened 7 months ago by nfrayer.
rpms/ nfrayer/grub2 rawhide  into  rawhide

@@ -0,0 +1,84 @@ 

+ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001

+ From: Marta Lewandowska <mlewando@redhat.com>

+ Date: Mon, 9 Oct 2023 08:53:18 +0200

+ Subject: [PATCH] add flag to only search root dev

+ 

+ fixes bz#2223437

+ 

+ Signed-off-by: Marta Lewandowska <mlewando@redhat.com>

+ ---

+  grub-core/commands/search.c      | 8 ++++++++

+  grub-core/commands/search_wrap.c | 5 +++++

+  include/grub/search.h            | 3 ++-

+  3 files changed, 15 insertions(+), 1 deletion(-)

+ 

+ diff --git a/grub-core/commands/search.c b/grub-core/commands/search.c

+ index 57d26ced8a8e..188d4c49d1ae 100644

+ --- a/grub-core/commands/search.c

+ +++ b/grub-core/commands/search.c

+ @@ -59,6 +59,7 @@ static int

+  iterate_device (const char *name, void *data)

+  {

+    struct search_ctx *ctx = data;

+ +  const char *root_dev;

+    int found = 0;

+  

+    /* Skip floppy drives when requested.  */

+ @@ -85,6 +86,13 @@ iterate_device (const char *name, void *data)

+        grub_device_close (dev);

+      }

+  

+ +  /* Skip it if it's not the root device when requested. */

+ +  root_dev = grub_env_get ("root");

+ +  if (ctx->flags & SEARCH_FLAGS_ROOTDEV_ONLY &&

+ +      (name[0] != root_dev[0] || name[1] != root_dev[1] ||

+ +       name[2] != root_dev[2]))

+ +    return 0;

+ +

+  #ifdef DO_SEARCH_FS_UUID

+  #define compare_fn grub_strcasecmp

+  #else

+ diff --git a/grub-core/commands/search_wrap.c b/grub-core/commands/search_wrap.c

+ index 0b62acf85359..06b5f51eefb5 100644

+ --- a/grub-core/commands/search_wrap.c

+ +++ b/grub-core/commands/search_wrap.c

+ @@ -41,6 +41,7 @@ static const struct grub_arg_option options[] =

+       ARG_TYPE_STRING},

+      {"no-floppy",	'n', 0, N_("Do not probe any floppy drive."), 0, 0},

+      {"efidisk-only",	0, 0, N_("Only probe EFI disks."), 0, 0},

+ +    {"root-dev-only",  'r', 0, N_("Only probe root device."), 0, 0},

+      {"hint",	        'h', GRUB_ARG_OPTION_REPEATABLE,

+       N_("First try the device HINT. If HINT ends in comma, "

+  	"also try subpartitions"), N_("HINT"), ARG_TYPE_STRING},

+ @@ -75,6 +76,7 @@ enum options

+      SEARCH_SET,

+      SEARCH_NO_FLOPPY,

+      SEARCH_EFIDISK_ONLY,

+ +    SEARCH_ROOTDEV_ONLY,

+      SEARCH_HINT,

+      SEARCH_HINT_IEEE1275,

+      SEARCH_HINT_BIOS,

+ @@ -189,6 +191,9 @@ grub_cmd_search (grub_extcmd_context_t ctxt, int argc, char **args)

+    if (state[SEARCH_EFIDISK_ONLY].set)

+      flags |= SEARCH_FLAGS_EFIDISK_ONLY;

+  

+ +  if (state[SEARCH_ROOTDEV_ONLY].set)

+ +    flags |= SEARCH_FLAGS_ROOTDEV_ONLY;

+ +

+    if (state[SEARCH_LABEL].set)

+      grub_search_label (id, var, flags, hints, nhints);

+    else if (state[SEARCH_FS_UUID].set)

+ diff --git a/include/grub/search.h b/include/grub/search.h

+ index 4190aeb2cbf5..321d1400e451 100644

+ --- a/include/grub/search.h

+ +++ b/include/grub/search.h

+ @@ -22,7 +22,8 @@

+  enum search_flags

+    {

+      SEARCH_FLAGS_NO_FLOPPY	= 1,

+ -    SEARCH_FLAGS_EFIDISK_ONLY	= 2

+ +    SEARCH_FLAGS_EFIDISK_ONLY	= 2,

+ +    SEARCH_FLAGS_ROOTDEV_ONLY	= 4

+    };

+  

+  void grub_search_fs_file (const char *key, const char *var,

file modified
+1
@@ -335,3 +335,4 @@ 

  Patch0335: 0335-Add-Install-section-to-aux-systemd-units.patch

  Patch0336: 0336-arm64-Use-proper-memory-type-for-kernel-allocation.patch

  Patch0337: 0337-Fix-missing-include-in-ofdisk.c.patch

+ Patch0338: 0338-add-flag-to-only-search-root-dev.patch

file modified
+6 -2
@@ -17,7 +17,7 @@ 

  Name:		grub2

  Epoch:		1

  Version:	2.06

- Release:	104%{?dist}

+ Release:	105%{?dist}

  Summary:	Bootloader with support for Linux, Multiboot and more

  License:	GPLv3+

  URL:		http://www.gnu.org/software/grub/
@@ -364,7 +364,7 @@ 

  GRUB_DIR=$(grub2-mkrelpath ${GRUB_HOME})

  

  cat << EOF > ${EFI_HOME}/grub.cfg.stb

- search --no-floppy --fs-uuid --set=dev ${BOOT_UUID}

+ search --no-floppy --fs-uuid --root-dev-only --set=dev ${BOOT_UUID}

  set prefix=(\$dev)${GRUB_DIR}

  export \$prefix

  configfile \$prefix/grub.cfg
@@ -548,6 +548,10 @@ 

  %endif

  

  %changelog

+ * Mon Oct 16 2023 Nicolas Frayer <nfrayer@redhat.com> - 2.06-105

+ - grub-core: add flag to only search root dev

+ - Resolves: #2223437

+ 

  * Wed Oct 11 2023 Janne Grunau <j@jannau.net> - 2.06-104

  - 20-grub.install: Copy device-tree directory recursively

  - Resolves: #2243060

Resolves: #2223437
Signed-off-by: Nicolas Frayer nfrayer@redhat.com

Metadata Update from @nfrayer:
- Request assigned

7 months ago

Build succeeded.
https://fedora.softwarefactory-project.io/zuul/buildset/474f278a1f1944ff804a9eacd511e037

Pull-Request has been closed by nfrayer

7 months ago