From fd80023b17513c6a9f87209377a854368fd3d1ba Mon Sep 17 00:00:00 2001 From: Kim Holviala Date: Tue, 29 Dec 2015 15:06:17 +0200 Subject: [PATCH] Get hardware vendor and type from DMI data on Linux --- platform.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/platform.c b/platform.c index 31fdce3..52b0efd 100644 --- a/platform.c +++ b/platform.c @@ -134,6 +134,24 @@ void platform(state *st) } #endif + /* Get hardware type from DMI data */ + if (!*st->server_description && (fp = fopen("/sys/class/dmi/id/board_vendor" , "r"))) { + fgets(buf, sizeof(buf), fp); + fclose(fp); + + sstrlcpy(st->server_description, buf); + chomp(st->server_description); + + if ((fp = fopen("/sys/class/dmi/id/board_name" , "r"))) { + fgets(buf, sizeof(buf), fp); + fclose(fp); + + if (*st->server_description) sstrlcat(st->server_description, " "); + sstrlcat(st->server_description, buf); + chomp(st->server_description); + } + } + /* Identify RedHat */ if (!*sysname && (fp = fopen("/etc/redhat-release", "r"))) { fgets(sysname, sizeof(sysname), fp);