make host information more useful

This commit is contained in:
Joshix 2021-07-23 22:13:42 +02:00
parent 3fd554a873
commit a62805d9ce

View file

@ -386,7 +386,9 @@ void get_info()
#else #else
FILE *cpuinfo = popen("sysctl -a | egrep -i 'hw.model'", "r"); FILE *cpuinfo = popen("sysctl -a | egrep -i 'hw.model'", "r");
#endif #endif
FILE *host_model_info = fopen("/sys/devices/virtual/dmi/id/product_version", "r"); FILE *host_model_info = fopen("/sys/devices/virtual/dmi/id/board_name", "r");
if (!host_model_info) host_model_info = fopen("/sys/devices/virtual/dmi/id/product_name", "r");
FILE *host_model_version = fopen("/sys/devices/virtual/dmi/id/product_version", "r");
#ifdef __CYGWIN__ #ifdef __CYGWIN__
iscygwin = 1; iscygwin = 1;
#endif #endif
@ -405,6 +407,19 @@ void get_info()
while (fgets(line, sizeof(line), host_model_info)) while (fgets(line, sizeof(line), host_model_info))
if (sscanf(line, "%[^\n]", host_model)) if (sscanf(line, "%[^\n]", host_model))
break; break;
if (host_model_version)
{
char version[32];
while (fgets(line, sizeof(line), host_model_version))
{
if (sscanf(line, "%[^\n]", version))
{
strcat(host_model, " ");
strcat(host_model, version);
break;
}
}
}
} }
} }
while (fgets(line, sizeof(line), cpuinfo)) while (fgets(line, sizeof(line), cpuinfo))