[[RFC PATCH] v2 10/14] sysinfo: Display system name

Samuel Mendoza-Jonas sam at mendozajonas.com
Thu Jan 18 16:05:13 AEDT 2018


Signed-off-by: Samuel Mendoza-Jonas <sam at mendozajonas.com>
---
 discover/platform-powerpc.c   | 6 ++++++
 lib/pb-protocol/pb-protocol.c | 7 ++++++-
 lib/types/types.h             | 1 +
 ui/ncurses/nc-sysinfo.c       | 1 +
 4 files changed, 14 insertions(+), 1 deletion(-)

diff --git a/discover/platform-powerpc.c b/discover/platform-powerpc.c
index df95e02..11b5b60 100644
--- a/discover/platform-powerpc.c
+++ b/discover/platform-powerpc.c
@@ -1333,6 +1333,12 @@ static int get_sysinfo(struct platform *p, struct system_info *sysinfo)
 		sysinfo->type = talloc_steal(sysinfo, buf);
 	talloc_free(filename);
 
+	filename = talloc_asprintf(platform, "%smodel-name", devtree_dir);
+	rc = read_file(platform, filename, &buf, &len);
+	if (rc == 0)
+		sysinfo->name = talloc_steal(sysinfo, buf);
+	talloc_free(filename);
+
 	filename = talloc_asprintf(platform, "%ssystem-id", devtree_dir);
 	rc = read_file(platform, filename, &buf, &len);
 	if (rc == 0)
diff --git a/lib/pb-protocol/pb-protocol.c b/lib/pb-protocol/pb-protocol.c
index cd258a5..e63a237 100644
--- a/lib/pb-protocol/pb-protocol.c
+++ b/lib/pb-protocol/pb-protocol.c
@@ -246,6 +246,7 @@ int pb_protocol_system_info_len(const struct system_info *sysinfo)
 	unsigned int len, i;
 
 	len =	4 + optional_strlen(sysinfo->type) +
+		4 + optional_strlen(sysinfo->name) +
 		4 + optional_strlen(sysinfo->identifier) +
 		4 + 4;
 
@@ -495,6 +496,7 @@ int pb_protocol_serialise_system_info(const struct system_info *sysinfo,
 	unsigned int i;
 
 	pos += pb_protocol_serialise_string(pos, sysinfo->type);
+	pos += pb_protocol_serialise_string(pos, sysinfo->name);
 	pos += pb_protocol_serialise_string(pos, sysinfo->identifier);
 
 	*(uint32_t *)pos = __cpu_to_be32(sysinfo->n_primary);
@@ -1012,10 +1014,13 @@ int pb_protocol_deserialise_system_info(struct system_info *sysinfo,
 	len = message->payload_len;
 	pos = message->payload;
 
-	/* type and identifier strings */
+	/* type, name, and identifier strings */
 	if (read_string(sysinfo, &pos, &len, &sysinfo->type))
 		goto out;
 
+	if (read_string(sysinfo, &pos, &len, &sysinfo->name))
+		goto out;
+
 	if (read_string(sysinfo, &pos, &len, &sysinfo->identifier))
 		goto out;
 
diff --git a/lib/types/types.h b/lib/types/types.h
index 434dbb4..7550a33 100644
--- a/lib/types/types.h
+++ b/lib/types/types.h
@@ -133,6 +133,7 @@ struct firmware_version {
 
 struct system_info {
 	char			*type;
+	char			*name;
 	char			*identifier;
 
 	struct firmware_version *platform_primary;
diff --git a/ui/ncurses/nc-sysinfo.c b/ui/ncurses/nc-sysinfo.c
index c2bcf5b..7930693 100644
--- a/ui/ncurses/nc-sysinfo.c
+++ b/ui/ncurses/nc-sysinfo.c
@@ -64,6 +64,7 @@ static void sysinfo_screen_populate(struct sysinfo_screen *screen,
 
 	line("%-12s %s", _("System type:"), sysinfo->type ?: "");
 	line("%-12s %s", _("System id:"),   sysinfo->identifier ?: "");
+	line("%-12s %s", _("System name:"),   sysinfo->name ?: "");
 
 	if (sysinfo->n_primary) {
 		line(NULL);
-- 
2.15.1



More information about the Petitboot mailing list