seabios/seabios-add-romfile_loadbool.patch
Jon Maloy 160dabd64a * Fri Aug 21 2026 Jon Maloy <jmaloy@redhat.com> - 1.16.3-6
- seabios-add-romfile_loadbool.patch [RHEL-236811]
- seabios-update-pci_pad_mem64-handling.patch [RHEL-236811]
- Resolves: RHEL-236811
  (Backport opt/org.seabios/pci64 to SeaBIOS 1.16 / el9)
2026-08-21 18:27:23 -04:00

73 lines
2.1 KiB
Diff

From 6cd6830764979960144b63e7aecb0981b1445e43 Mon Sep 17 00:00:00 2001
From: Gerd Hoffmann <kraxel@redhat.com>
Date: Fri, 22 Nov 2024 15:16:32 +0100
Subject: [PATCH 1/2] add romfile_loadbool()
RH-Author: Gerd Hoffmann <kraxel@redhat.com>
RH-MergeRequest: 14: update pci_pad_mem64 handling
RH-Jira: RHEL-236811
RH-Acked-by: Luigi Leonardi <None>
RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
RH-Commit: [1/2] af1e580e50ce2405a9fe286ee296a343e811a618 (kraxel.rh/centos-src-seabios)
Translates strings in fw_cfg files into boolean values.
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
(cherry picked from commit a4fc1845b43687fe01c6f53fca9d7c1ac1b725d7)
Resolves: RHEL-236811
---
src/romfile.c | 23 +++++++++++++++++++++++
src/romfile.h | 1 +
2 files changed, 24 insertions(+)
diff --git a/src/romfile.c b/src/romfile.c
index b598274e..8072a915 100644
--- a/src/romfile.c
+++ b/src/romfile.c
@@ -99,6 +99,29 @@ romfile_loadint(const char *name, u64 defval)
return val;
}
+u32
+romfile_loadbool(const char *name, u32 defval)
+{
+ static const char *true_strings[] = { "1", "on", "yes" };
+ static const char *false_strings[] = { "0", "off", "no" };
+ char *str = romfile_loadfile(name, NULL);
+ int i;
+
+ if (!str)
+ return defval;
+
+ for (i = 0; i < ARRAY_SIZE(true_strings); i++)
+ if (0 == strcmp(str, true_strings[i]))
+ return 1;
+
+ for (i = 0; i < ARRAY_SIZE(false_strings); i++)
+ if (0 == strcmp(str, false_strings[i]))
+ return 0;
+
+ dprintf(1, "%s: unknown bool string: %s\n", __func__, str);
+ return defval;
+}
+
struct const_romfile_s {
struct romfile_s file;
void *data;
diff --git a/src/romfile.h b/src/romfile.h
index 3e0f8200..ae2f4ac7 100644
--- a/src/romfile.h
+++ b/src/romfile.h
@@ -15,6 +15,7 @@ struct romfile_s *romfile_findprefix(const char *prefix, struct romfile_s *prev)
struct romfile_s *romfile_find(const char *name);
void *romfile_loadfile(const char *name, int *psize);
u64 romfile_loadint(const char *name, u64 defval);
+u32 romfile_loadbool(const char *name, u32 defval);
void const_romfile_add_int(char *name, u32 value);
--
2.52.0