You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
74 lines
2.7 KiB
74 lines
2.7 KiB
From 6204aa43883fdf02d72bd0db6d3cfbfa7c075213 Mon Sep 17 00:00:00 2001
|
|
From: Gerd Hoffmann <kraxel@redhat.com>
|
|
Date: Fri, 20 Jan 2023 15:40:36 +0100
|
|
Subject: [PATCH] bootctl: kernel-inspect: print os info
|
|
|
|
(cherry picked from commit 2d4260482cb8463f4de9502efd26bf8c64262669)
|
|
|
|
Related: RHEL-16354
|
|
---
|
|
src/boot/bootctl-uki.c | 29 ++++++++++++++++++++++++++++-
|
|
1 file changed, 28 insertions(+), 1 deletion(-)
|
|
|
|
diff --git a/src/boot/bootctl-uki.c b/src/boot/bootctl-uki.c
|
|
index 3085f703a8..6bdf926350 100644
|
|
--- a/src/boot/bootctl-uki.c
|
|
+++ b/src/boot/bootctl-uki.c
|
|
@@ -1,6 +1,7 @@
|
|
/* SPDX-License-Identifier: LGPL-2.1-or-later */
|
|
|
|
#include "bootctl-uki.h"
|
|
+#include "env-file.h"
|
|
#include "fd-util.h"
|
|
#include "parse-util.h"
|
|
#include "pe-header.h"
|
|
@@ -142,10 +143,31 @@ static int read_pe_section(FILE *uki, const struct PeSectionHeader *section,
|
|
return 0;
|
|
}
|
|
|
|
+static void inspect_osrel(char *osrel, size_t osrel_size) {
|
|
+ _cleanup_fclose_ FILE *s = NULL;
|
|
+ _cleanup_free_ char *pname = NULL, *name = NULL;
|
|
+ int r;
|
|
+
|
|
+ assert(osrel);
|
|
+ s = fmemopen(osrel, osrel_size, "r");
|
|
+ if (!s)
|
|
+ return (void) log_warning_errno(errno, "Failed to open embedded os-release file, ignoring: %m");
|
|
+
|
|
+ r = parse_env_file(s, NULL,
|
|
+ "PRETTY_NAME", &pname,
|
|
+ "NAME", &name);
|
|
+ if (r < 0)
|
|
+ return (void) log_warning_errno(r, "Failed to parse embedded os-release file, ignoring: %m");
|
|
+
|
|
+ if (pname || name)
|
|
+ printf(" OS: %s\n", pname ?: name);
|
|
+}
|
|
+
|
|
static void inspect_uki(FILE *uki, struct PeSectionHeader *sections, size_t scount) {
|
|
_cleanup_free_ char *cmdline = NULL;
|
|
_cleanup_free_ char *uname = NULL;
|
|
- size_t idx;
|
|
+ _cleanup_free_ char *osrel = NULL;
|
|
+ size_t osrel_size, idx;
|
|
|
|
if (find_pe_section(sections, scount, name_cmdline, sizeof(name_cmdline), &idx))
|
|
read_pe_section(uki, sections + idx, (void**)&cmdline, NULL);
|
|
@@ -153,10 +175,15 @@ static void inspect_uki(FILE *uki, struct PeSectionHeader *sections, size_t scou
|
|
if (find_pe_section(sections, scount, name_uname, sizeof(name_uname), &idx))
|
|
read_pe_section(uki, sections + idx, (void**)&uname, NULL);
|
|
|
|
+ if (find_pe_section(sections, scount, name_osrel, sizeof(name_osrel), &idx))
|
|
+ read_pe_section(uki, sections + idx, (void**)&osrel, &osrel_size);
|
|
+
|
|
if (cmdline)
|
|
printf(" Cmdline: %s\n", cmdline);
|
|
if (uname)
|
|
printf(" Version: %s\n", uname);
|
|
+ if (osrel)
|
|
+ inspect_osrel(osrel, osrel_size);
|
|
}
|
|
|
|
int verb_kernel_inspect(int argc, char *argv[], void *userdata) {
|