|
|
8631a2 |
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
|
8631a2 |
From: Peter Jones <pjones@redhat.com>
|
|
|
8631a2 |
Date: Fri, 19 Oct 2018 10:03:28 -0400
|
|
|
8631a2 |
Subject: [PATCH] Make blscfg debug messages more useful
|
|
|
8631a2 |
|
|
|
8631a2 |
Related: rhbz#1640979
|
|
|
8631a2 |
Signed-off-by: Peter Jones <pjones@redhat.com>
|
|
|
8631a2 |
---
|
|
|
8631a2 |
grub-core/commands/blscfg.c | 12 +++++-------
|
|
|
8631a2 |
grub-core/commands/legacycfg.c | 4 ++--
|
|
|
8631a2 |
grub-core/commands/menuentry.c | 18 ++++++++++++++----
|
|
|
8631a2 |
include/grub/normal.h | 2 +-
|
|
|
8631a2 |
4 files changed, 22 insertions(+), 14 deletions(-)
|
|
|
8631a2 |
|
|
|
8631a2 |
diff --git a/grub-core/commands/blscfg.c b/grub-core/commands/blscfg.c
|
|
|
09e3cc |
index 347128c9d..42892cbfd 100644
|
|
|
8631a2 |
--- a/grub-core/commands/blscfg.c
|
|
|
8631a2 |
+++ b/grub-core/commands/blscfg.c
|
|
|
8631a2 |
@@ -46,8 +46,6 @@ GRUB_MOD_LICENSE ("GPLv3+");
|
|
|
8631a2 |
#define GRUB_BOOT_DEVICE "($root)"
|
|
|
8631a2 |
#endif
|
|
|
8631a2 |
|
|
|
8631a2 |
-#define grub_free(x) ({grub_dprintf("blscfg", "%s freeing %p\n", __func__, x); grub_free(x); })
|
|
|
8631a2 |
-
|
|
|
8631a2 |
struct keyval
|
|
|
8631a2 |
{
|
|
|
8631a2 |
const char *key;
|
|
|
8631a2 |
@@ -134,7 +132,7 @@ static int bls_add_keyval(struct bls_entry *entry, char *key, char *val)
|
|
|
8631a2 |
kv->val = v;
|
|
|
8631a2 |
|
|
|
8631a2 |
entry->keyvals[entry->nkeyvals] = kv;
|
|
|
8631a2 |
- grub_dprintf("blscfg", "new keyval at %p:%p:%p\n", entry->keyvals[entry->nkeyvals], k, v);
|
|
|
8631a2 |
+ grub_dprintf("blscfg", "new keyval at %p:%s:%s\n", entry->keyvals[entry->nkeyvals], k, v);
|
|
|
8631a2 |
entry->nkeyvals = new_n;
|
|
|
8631a2 |
|
|
|
8631a2 |
return 0;
|
|
|
8631a2 |
@@ -144,7 +142,6 @@ static void bls_free_entry(struct bls_entry *entry)
|
|
|
8631a2 |
{
|
|
|
8631a2 |
int i;
|
|
|
8631a2 |
|
|
|
8631a2 |
- grub_dprintf("blscfg", "%s got here\n", __func__);
|
|
|
8631a2 |
for (i = 0; i < entry->nkeyvals; i++)
|
|
|
8631a2 |
{
|
|
|
8631a2 |
struct keyval *kv = entry->keyvals[i];
|
|
|
8631a2 |
@@ -206,7 +203,7 @@ static int vercmp(const char * a, const char * b)
|
|
|
8631a2 |
int isnum;
|
|
|
8631a2 |
int ret = 0;
|
|
|
8631a2 |
|
|
|
8631a2 |
- grub_dprintf("blscfg", "%s got here\n", __func__);
|
|
|
8631a2 |
+ grub_dprintf("blscfg", "%s comparing %s and %s\n", __func__, a, b);
|
|
|
8631a2 |
if (!grub_strcmp(a, b))
|
|
|
8631a2 |
return 0;
|
|
|
8631a2 |
|
|
|
8631a2 |
@@ -682,7 +679,7 @@ static void create_entry (struct bls_entry *entry)
|
|
|
8631a2 |
char **args = NULL;
|
|
|
8631a2 |
|
|
|
8631a2 |
char *src = NULL;
|
|
|
8631a2 |
- int i;
|
|
|
8631a2 |
+ int i, index;
|
|
|
8631a2 |
|
|
|
8631a2 |
grub_dprintf("blscfg", "%s got here\n", __func__);
|
|
|
8631a2 |
clinux = bls_get_val (entry, "linux", NULL);
|
|
|
8631a2 |
@@ -756,7 +753,8 @@ static void create_entry (struct bls_entry *entry)
|
|
|
8631a2 |
GRUB_BOOT_DEVICE, clinux, options ? " " : "", options ? options : "",
|
|
|
8631a2 |
initrd ? initrd : "");
|
|
|
8631a2 |
|
|
|
8631a2 |
- grub_normal_add_menu_entry (argc, argv, classes, id, users, hotkey, NULL, src, 0);
|
|
|
8631a2 |
+ grub_normal_add_menu_entry (argc, argv, classes, id, users, hotkey, NULL, src, 0, &index);
|
|
|
8631a2 |
+ grub_dprintf ("blscfg", "Added entry %d id:\"%s\"\n", index, id);
|
|
|
8631a2 |
|
|
|
8631a2 |
finish:
|
|
|
8631a2 |
grub_free (initrd);
|
|
|
8631a2 |
diff --git a/grub-core/commands/legacycfg.c b/grub-core/commands/legacycfg.c
|
|
|
09e3cc |
index b32f3c74c..f9d7627bd 100644
|
|
|
8631a2 |
--- a/grub-core/commands/legacycfg.c
|
|
|
8631a2 |
+++ b/grub-core/commands/legacycfg.c
|
|
|
8631a2 |
@@ -133,7 +133,7 @@ legacy_file (const char *filename)
|
|
|
8631a2 |
args[0] = oldname;
|
|
|
8631a2 |
grub_normal_add_menu_entry (1, args, NULL, NULL, "legacy",
|
|
|
8631a2 |
NULL, NULL,
|
|
|
8631a2 |
- entrysrc, 0);
|
|
|
8631a2 |
+ entrysrc, 0, NULL);
|
|
|
8631a2 |
grub_free (args);
|
|
|
8631a2 |
entrysrc[0] = 0;
|
|
|
8631a2 |
grub_free (oldname);
|
|
|
8631a2 |
@@ -186,7 +186,7 @@ legacy_file (const char *filename)
|
|
|
8631a2 |
}
|
|
|
8631a2 |
args[0] = entryname;
|
|
|
8631a2 |
grub_normal_add_menu_entry (1, args, NULL, NULL, NULL,
|
|
|
8631a2 |
- NULL, NULL, entrysrc, 0);
|
|
|
8631a2 |
+ NULL, NULL, entrysrc, 0, NULL);
|
|
|
8631a2 |
grub_free (args);
|
|
|
8631a2 |
}
|
|
|
8631a2 |
|
|
|
8631a2 |
diff --git a/grub-core/commands/menuentry.c b/grub-core/commands/menuentry.c
|
|
|
09e3cc |
index 2c5363da7..8d242b018 100644
|
|
|
8631a2 |
--- a/grub-core/commands/menuentry.c
|
|
|
8631a2 |
+++ b/grub-core/commands/menuentry.c
|
|
|
8631a2 |
@@ -78,7 +78,7 @@ grub_normal_add_menu_entry (int argc, const char **args,
|
|
|
8631a2 |
char **classes, const char *id,
|
|
|
8631a2 |
const char *users, const char *hotkey,
|
|
|
8631a2 |
const char *prefix, const char *sourcecode,
|
|
|
8631a2 |
- int submenu)
|
|
|
8631a2 |
+ int submenu, int *index)
|
|
|
8631a2 |
{
|
|
|
8631a2 |
int menu_hotkey = 0;
|
|
|
8631a2 |
char **menu_args = NULL;
|
|
|
8631a2 |
@@ -149,9 +149,12 @@ grub_normal_add_menu_entry (int argc, const char **args,
|
|
|
8631a2 |
if (! menu_title)
|
|
|
8631a2 |
goto fail;
|
|
|
8631a2 |
|
|
|
8631a2 |
+ grub_dprintf ("menu", "id:\"%s\"\n", id);
|
|
|
8631a2 |
+ grub_dprintf ("menu", "title:\"%s\"\n", menu_title);
|
|
|
8631a2 |
menu_id = grub_strdup (id ? : menu_title);
|
|
|
8631a2 |
if (! menu_id)
|
|
|
8631a2 |
goto fail;
|
|
|
8631a2 |
+ grub_dprintf ("menu", "menu_id:\"%s\"\n", menu_id);
|
|
|
8631a2 |
|
|
|
8631a2 |
/* Save argc, args to pass as parameters to block arg later. */
|
|
|
8631a2 |
menu_args = grub_malloc (sizeof (char*) * (argc + 1));
|
|
|
8631a2 |
@@ -170,8 +173,12 @@ grub_normal_add_menu_entry (int argc, const char **args,
|
|
|
8631a2 |
}
|
|
|
8631a2 |
|
|
|
8631a2 |
/* Add the menu entry at the end of the list. */
|
|
|
8631a2 |
+ int ind=0;
|
|
|
8631a2 |
while (*last)
|
|
|
8631a2 |
- last = &(*last)->next;
|
|
|
8631a2 |
+ {
|
|
|
8631a2 |
+ ind++;
|
|
|
8631a2 |
+ last = &(*last)->next;
|
|
|
8631a2 |
+ }
|
|
|
8631a2 |
|
|
|
8631a2 |
*last = grub_zalloc (sizeof (**last));
|
|
|
8631a2 |
if (! *last)
|
|
|
8631a2 |
@@ -190,6 +197,8 @@ grub_normal_add_menu_entry (int argc, const char **args,
|
|
|
8631a2 |
(*last)->submenu = submenu;
|
|
|
8631a2 |
|
|
|
8631a2 |
menu->size++;
|
|
|
8631a2 |
+ if (index)
|
|
|
8631a2 |
+ *index = ind;
|
|
|
8631a2 |
return GRUB_ERR_NONE;
|
|
|
8631a2 |
|
|
|
8631a2 |
fail:
|
|
|
8631a2 |
@@ -286,7 +295,8 @@ grub_cmd_menuentry (grub_extcmd_context_t ctxt, int argc, char **args)
|
|
|
8631a2 |
users,
|
|
|
8631a2 |
ctxt->state[2].arg, 0,
|
|
|
8631a2 |
ctxt->state[3].arg,
|
|
|
8631a2 |
- ctxt->extcmd->cmd->name[0] == 's');
|
|
|
8631a2 |
+ ctxt->extcmd->cmd->name[0] == 's',
|
|
|
8631a2 |
+ NULL);
|
|
|
8631a2 |
|
|
|
8631a2 |
src = args[argc - 1];
|
|
|
8631a2 |
args[argc - 1] = NULL;
|
|
|
8631a2 |
@@ -303,7 +313,7 @@ grub_cmd_menuentry (grub_extcmd_context_t ctxt, int argc, char **args)
|
|
|
8631a2 |
ctxt->state[0].args, ctxt->state[4].arg,
|
|
|
8631a2 |
users,
|
|
|
8631a2 |
ctxt->state[2].arg, prefix, src + 1,
|
|
|
8631a2 |
- ctxt->extcmd->cmd->name[0] == 's');
|
|
|
8631a2 |
+ ctxt->extcmd->cmd->name[0] == 's', NULL);
|
|
|
8631a2 |
|
|
|
8631a2 |
src[len - 1] = ch;
|
|
|
8631a2 |
args[argc - 1] = src;
|
|
|
8631a2 |
diff --git a/include/grub/normal.h b/include/grub/normal.h
|
|
|
09e3cc |
index 218cbabcc..cb9901f41 100644
|
|
|
8631a2 |
--- a/include/grub/normal.h
|
|
|
8631a2 |
+++ b/include/grub/normal.h
|
|
|
8631a2 |
@@ -145,7 +145,7 @@ grub_normal_add_menu_entry (int argc, const char **args, char **classes,
|
|
|
8631a2 |
const char *id,
|
|
|
8631a2 |
const char *users, const char *hotkey,
|
|
|
8631a2 |
const char *prefix, const char *sourcecode,
|
|
|
8631a2 |
- int submenu);
|
|
|
8631a2 |
+ int submenu, int *index);
|
|
|
8631a2 |
|
|
|
8631a2 |
grub_err_t
|
|
|
8631a2 |
grub_normal_set_password (const char *user, const char *password);
|