These files can have tabs, but they are currently parsed as separate
lines. Fix this.

Also, some files provide a separate 'menu label' which has more
information than the 'label', so use that if available.

Finally, we don't yet have the ability to parse all entries in the
file until the user actually boots the extlinux.conf file. At present,
this means that the last entry is shown. It seems better to use the
first entry, so update it.

Signed-off-by: Simon Glass <s...@chromium.org>
---

 boot/bootmeth_extlinux.c | 19 +++++++++++++++++--
 1 file changed, 17 insertions(+), 2 deletions(-)

diff --git a/boot/bootmeth_extlinux.c b/boot/bootmeth_extlinux.c
index 71a9009479b..4b9e22b8d7c 100644
--- a/boot/bootmeth_extlinux.c
+++ b/boot/bootmeth_extlinux.c
@@ -83,13 +83,28 @@ static int extlinux_fill_info(struct bootflow *bflow)
        log_debug("parsing bflow file size %x\n", bflow->size);
        membuf_init(&mb, bflow->buf, bflow->size);
        membuf_putraw(&mb, bflow->size, true, &data);
-       while (len = membuf_readline(&mb, line, sizeof(line) - 1, ' ', true), 
len) {
+       while (len = membuf_readline(&mb, line, sizeof(line) - 1, 0, true), 
len) {
                char *tok, *p = line;
+               const char *name = NULL;
 
+               if (*p == '#')
+                       continue;
+               while (*p == ' ' || *p == '\t')
+                       p++;
                tok = strsep(&p, " ");
                if (p) {
                        if (!strcmp("label", tok)) {
-                               bflow->os_name = strdup(p);
+                               name = p;
+                               if (bflow->os_name)
+                                       break;  /* just find the first */
+                       } else if (!strcmp("menu", tok)) {
+                               tok = strsep(&p, " ");
+                               if (!strcmp("label", tok))
+                                       name = p;
+                       }
+                       if (name) {
+                               free(bflow->os_name);
+                               bflow->os_name = strdup(name);
                                if (!bflow->os_name)
                                        return log_msg_ret("os", -ENOMEM);
                        }
-- 
2.43.0

base-commit: e3ced530e543c9f24cbc66430abc6109ce8df015
branch: boo

Reply via email to