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

Message ID 20180118050517.2442-11-sam@mendozajonas.com
State RFC
Headers show
Series
  • [[RFC] v2 10/14] sysinfo: Display system name
Related show

Commit Message

Samuel Mendoza-Jonas Jan. 18, 2018, 5:05 a.m.
Signed-off-by: Samuel Mendoza-Jonas <sam@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(-)

Patch

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);