Skip to contentSkip to conversation

blsuki: fix misc comments/issues

PATCH Superseded Radoslav Kolev via Grub-devel 2 participants 11 messages Nov 24, 2025 – Dec 18, 2025

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

v2 cover blsuki: fix misc comments/issues

A number of small fixes to comments/description in the blsuki command. Also add a check that no arguments are supplied (none are expected) and if any are found display an error instead of ignoring them silently.

The only change in behaviour is in the fallback case for blscfg, where currently it always falls back to the device pointed by $root, even if another one was specified via the -p option.

v2:
* Moved the no arguments check to caller functions
* Added description of type fix in patch #1

Radoslav Kolev (5):
blsuki: fix typo in entry parameter description
blsuki: fix blscfg command summary
blsuki: use specified device in case of fallback
blsuki: fix default location in commment to /loader/entries
blsuki: error out if unexpected arguments are supplied

 grub-core/commands/blsuki.c | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)
Signature · 7 lines
2.51.1


_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel
#1 lore raw

PATCH v2 1/5 blsuki: fix typo in entry parameter description

change "specificUKII entries" to "specific UKI entries"

---
 grub-core/commands/blsuki.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
grub-core/commands/blsuki.c +1 -1
index d089dec62..8837e11c9 100644
@@ -88,7 +88,7 @@ static const struct grub_arg_option uki_opt[] =
     {"enable-fallback", 'f', 0, "Fallback to the default BLS path if --path fails to find UKI entries.", 0, ARG_TYPE_NONE},
     {"show-default", 'd', 0, N_("Allow the default UKI entry to be added to the GRUB menu."), 0, ARG_TYPE_NONE},
     {"show-non-default", 'n', 0, N_("Allow the non-default UKI entries to be added to the GRUB menu."), 0, ARG_TYPE_NONE},
-    {"entry", 'e', 0, N_("Allow specificUKII entries to be added to the GRUB menu."), N_("FILE"), ARG_TYPE_FILE},
+    {"entry", 'e', 0, N_("Allow specific UKI entries to be added to the GRUB menu."), N_("FILE"), ARG_TYPE_FILE},
     {0, 0, 0, 0, 0, 0}
   };
 #endif
Signature · 7 lines
2.51.1


_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel
#2 lore raw

PATCH v2 2/5 blsuki: fix blscfg command summary

In reply to Radoslav Kolev via Grub-devel
---
 grub-core/commands/blsuki.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
grub-core/commands/blsuki.c +1 -1
index 8837e11c9..cdd8dcc1e 100644
@@ -1476,7 +1476,7 @@ static grub_extcmd_t uki_cmd;
 GRUB_MOD_INIT(blsuki)
 {
   bls_cmd = grub_register_extcmd ("blscfg", grub_cmd_blscfg, 0,
-				  N_("[-p|--path] [-f|--enable-fallback] DIR [-d|--show-default] [-n|--show-non-default] [-e|--entry] FILE"),
+				  N_("[-p|--path] DIR [-f|--enable-fallback] [-d|--show-default] [-n|--show-non-default] [-e|--entry] FILE"),
 				  N_("Import Boot Loader Specification snippets."),
 				  bls_opt);
 #ifdef GRUB_MACHINE_EFI
Signature · 7 lines
2.51.1


_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel
#3 lore raw

Re: [PATCH v2 2/5] blsuki: fix blscfg command summary

Quoted 10 lines · Radoslav Kolev via Grub-devel
---
 grub-core/commands/blsuki.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
grub-core/commands/blsuki.c +0 -0
index 8837e11c9..cdd8dcc1e 100644

grub-core/commands/blsuki.c static grub_extcmd_t uki_cmd; · line 1479

Quoted 5 lines
grub-core/commands/blsuki.c +1 -1
@@ -1476,7 +1476,7 @@ static grub_extcmd_t uki_cmd;
 GRUB_MOD_INIT(blsuki)
 {
   bls_cmd = grub_register_extcmd ("blscfg", grub_cmd_blscfg, 0,
-				  N_("[-p|--path] [-f|--enable-fallback] DIR [-d|--show-default] [-n|--show-non-default] [-e|--entry] FILE"),
+				  N_("[-p|--path] DIR [-f|--enable-fallback] [-d|--show-default] [-n|--show-non-default] [-e|--entry] FILE"),

I think the patch should have at least one sentence of explanation in the commit message what is fixed. Otherwise it is not obvious at first sight what is going on here.

Daniel

_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel

#4 lore raw

PATCH v2 3/5 blsuki: use specified device in case of fallback

In reply to Radoslav Kolev via Grub-devel

Currently if the fallback option is enabled and no files are found in the specified directory it searches the default (loader/conf) directory but always in the device set by the root environment variable. It makes more sense and also the comment in the code implies, that the default directory on the current device should be searched.

---
 grub-core/commands/blsuki.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
grub-core/commands/blsuki.c +1 -1
index cdd8dcc1e..e930b7312 100644
@@ -1231,7 +1231,7 @@ blsuki_find_entry (struct find_entry_info *info, bool enable_fallback, enum blsu
 	  tmp = blsuki_update_boot_device (default_dir);
 	  tmp = grub_stpcpy (tmp, cmd_dir);
 
-	  blsuki_set_find_entry_info (info, default_dir, NULL, cmd_type);
+	  blsuki_set_find_entry_info (info, default_dir, info->devid, cmd_type);
 	  grub_dprintf ("blsuki", "Entries weren't found in %s, fallback to %s\n",
 			read_entry_info.dirname, info->dirname);
 	  fallback = true;
Signature · 7 lines
2.51.1


_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel
#5 lore raw

PATCH v2 4/5 blsuki: fix default location in commment to /loader/entries

In reply to Radoslav Kolev via Grub-devel
---
 grub-core/commands/blsuki.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
grub-core/commands/blsuki.c +1 -1
index e930b7312..0fd4458e6 100644
@@ -1210,7 +1210,7 @@ blsuki_find_entry (struct find_entry_info *info, bool enable_fallback, enum blsu
 
       /*
        * If we aren't able to find BLS entries in the directory given by info->dirname,
-       * we can fallback to the default location "/boot/loader/entries/" and see if we
+       * we can fallback to the default location of "/loader/entries/" and see if we
        * can find the files there. If we can't find UKI entries, fallback to
        * "/EFI/Linux" on the EFI system partition.
        */
Signature · 7 lines
2.51.1


_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel
#6 lore raw

PATCH v2 5/5 blsuki: error out if unexpected arguments are supplied

In reply to Radoslav Kolev via Grub-devel

This can be especially helpful, as the Fedora version of the blscfg actually made use of arguments. In case of old configs/scripts the new implementation will now error out instead of falling back to defaults silently.

---
 grub-core/commands/blsuki.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
grub-core/commands/blsuki.c +6 -2
index 0fd4458e6..09f6bb4ef 100644
@@ -1454,9 +1454,11 @@ blsuki_cmd (grub_extcmd_context_t ctxt, enum blsuki_cmd_type cmd_type)
 }
 
 static grub_err_t
-grub_cmd_blscfg (grub_extcmd_context_t ctxt, int argc __attribute__ ((unused)),
+grub_cmd_blscfg (grub_extcmd_context_t ctxt, int argc,
 		 char **args __attribute__ ((unused)))
 {
+  if (argc != 0)
+    return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("no arguments expected, see --help"));
   return blsuki_cmd (ctxt, BLSUKI_BLS_CMD);
 }
 
@@ -1464,9 +1466,11 @@ static grub_extcmd_t bls_cmd;
 
 #ifdef GRUB_MACHINE_EFI
 static grub_err_t
-grub_cmd_uki (grub_extcmd_context_t ctxt, int argc __attribute__ ((unused)),
+grub_cmd_uki (grub_extcmd_context_t ctxt, int argc,
 		 char **args __attribute__ ((unused)))
 {
+  if (argc != 0)
+    return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("no arguments expected, see --help"));
   return blsuki_cmd (ctxt, BLSUKI_UKI_CMD);
 }
 
Signature · 7 lines
2.51.1


_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel
#7 lore raw

Re: [PATCH v2 5/5] blsuki: error out if unexpected arguments are supplied

Adding Alec, Peter, Steve, Marta, Leo, Luca, Mate and Julian. Please keep these folks in the loop for this patch set.

Quoted 29 lines · Radoslav Kolev via Grub-devel

This can be especially helpful, as the Fedora version of the blscfg actually made use of arguments. In case of old configs/scripts the new implementation will now error out instead of falling back to defaults silently.

---
 grub-core/commands/blsuki.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
grub-core/commands/blsuki.c +3 -1
index 0fd4458e6..09f6bb4ef 100644
@@ -1454,9 +1454,11 @@ blsuki_cmd (grub_extcmd_context_t ctxt, enum blsuki_cmd_type cmd_type)
 }
 
 static grub_err_t
-grub_cmd_blscfg (grub_extcmd_context_t ctxt, int argc __attribute__ ((unused)),
+grub_cmd_blscfg (grub_extcmd_context_t ctxt, int argc,
 		 char **args __attribute__ ((unused)))
 {
+  if (argc != 0)
+    return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("no arguments expected, see --help"));
   return blsuki_cmd (ctxt, BLSUKI_BLS_CMD);
 }
 
@@ -1464,9 +1466,11 @@ static grub_extcmd_t bls_cmd;
 

grub-core/commands/blsuki.c static grub_extcmd_t bls_cmd; · line 1475

Quoted 10 lines
grub-core/commands/blsuki.c +3 -1
 #ifdef GRUB_MACHINE_EFI
 static grub_err_t
-grub_cmd_uki (grub_extcmd_context_t ctxt, int argc __attribute__ ((unused)),
+grub_cmd_uki (grub_extcmd_context_t ctxt, int argc,
 		 char **args __attribute__ ((unused)))
 {
+  if (argc != 0)
+    return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("no arguments expected, see --help"));
   return blsuki_cmd (ctxt, BLSUKI_UKI_CMD);
 }

I am not convinced we have to have this. I want to hear other folks opinion here. If you convince me to have this behavior for these commands I think this exception have to be documented in the GRUB documentation.

Daniel

_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel

#8 lore raw

Re: [PATCH v2 5/5] blsuki: error out if unexpected arguments are supplied

Quoted 4 lines · Daniel Kiper

I am not convinced we have to have this. I want to hear other folks opinion here. If you convince me to have this behavior for these commands I think this exception have to be documented in the GRUB documentation.

I have found myself sometimes forgetting to add the -p, so for example having something like "blscfg (hd0,gpt2)/..." instead of "blscfg -p (hd0,gpt2)/..." and taking me a while to figure out why things didn't work as I expected them to.

Coincidentally, this was the way a path was supposed to be passed to the implementation of the same command in the earlier versions of these patches. My logic was that it's better to error out explicitly when an unsupported argument
is passed instead of just ignoring it silently, but let's see what others think.

Thank you for the quick response and I'll prepare a new revision when a decision is
made to keep this functionality or not.

Best regards,
Radoslav

_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel

#9 lore raw

Re: [PATCH v2 5/5] blsuki: error out if unexpected arguments are supplied

Quoted 16 lines · Radoslav Kolev
Quoted 4 lines · Daniel Kiper

I am not convinced we have to have this. I want to hear other folks opinion here. If you convince me to have this behavior for these commands I think this exception have to be documented in the GRUB documentation.

I have found myself sometimes forgetting to add the -p, so for example having something like "blscfg (hd0,gpt2)/..." instead of "blscfg -p (hd0,gpt2)/..." and taking me a while to figure out why things didn't work as I expected them to.

Coincidentally, this was the way a path was supposed to be passed to the implementation of the same command in the earlier versions of these patches. My logic was that it's better to error out explicitly when an unsupported argument
is passed instead of just ignoring it silently, but let's see what others think.

Quoted 6 lines

Thank you for the quick response and I'll prepare a new revision when a decision is
made to keep this functionality or not.

Best regards,
Radoslav

I'm not opposed to erroring out when receiving an argument without an option prior, but if it is preferred to maintain the current behavior, we could print a debug message instead of an error to indicate the command doesn't take standalone arguments. That way it won't be silently ignored if someone else runs into the same issue.

Alec Brown
_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel

#10 lore raw

Re: [PATCH v2 5/5] blsuki: error out if unexpected arguments are supplied

In reply to Daniel Kiper
Quoted 33 lines · Daniel Kiper

Adding Alec, Peter, Steve, Marta, Leo, Luca, Mate and Julian. Please keep these folks in the loop for this patch set.

Quoted 29 lines · Radoslav Kolev via Grub-devel

This can be especially helpful, as the Fedora version of the blscfg actually made use of arguments. In case of old configs/scripts the new implementation will now error out instead of falling back to defaults silently.

---
 grub-core/commands/blsuki.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
grub-core/commands/blsuki.c +3 -1
index 0fd4458e6..09f6bb4ef 100644
@@ -1454,9 +1454,11 @@ blsuki_cmd (grub_extcmd_context_t ctxt, enum blsuki_cmd_type cmd_type)
 }
 
 static grub_err_t
-grub_cmd_blscfg (grub_extcmd_context_t ctxt, int argc __attribute__ ((unused)),
+grub_cmd_blscfg (grub_extcmd_context_t ctxt, int argc,
 		 char **args __attribute__ ((unused)))
 {
+  if (argc != 0)
+    return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("no arguments expected, see --help"));
   return blsuki_cmd (ctxt, BLSUKI_BLS_CMD);
 }
 
@@ -1464,9 +1466,11 @@ static grub_extcmd_t bls_cmd;
 
Quoted 15 lines

grub-core/commands/blsuki.c static grub_extcmd_t bls_cmd; · line 1475

Quoted 10 lines
grub-core/commands/blsuki.c +3 -1
 #ifdef GRUB_MACHINE_EFI
 static grub_err_t
-grub_cmd_uki (grub_extcmd_context_t ctxt, int argc __attribute__ ((unused)),
+grub_cmd_uki (grub_extcmd_context_t ctxt, int argc,
 		 char **args __attribute__ ((unused)))
 {
+  if (argc != 0)
+    return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("no arguments expected, see --help"));
   return blsuki_cmd (ctxt, BLSUKI_UKI_CMD);
 }

I am not convinced we have to have this. I want to hear other folks opinion here. If you convince me to have this behavior for these commands I think this exception have to be documented in the GRUB documentation.

It looks nobody strongly objects. So, I am OK with behavior change. Though grub_error() message is confusing for me because the commands get arguments. So, I think it should be better phrased.

Please do not forget to update patch #2 too.

Daniel

_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel