diff options
| author | Burt P <pburt0@gmail.com> | 2017-08-15 13:54:56 -0500 | 
|---|---|---|
| committer | Leandro A. F. Pereira <leandro@hardinfo.org> | 2017-08-27 08:21:05 -0700 | 
| commit | e526b009955325cc9645e223bea9c45ff420d9e6 (patch) | |
| tree | 73a866e0ca3fc3189c9317113df343c3c4a82a3d /modules | |
| parent | 90ef50fd3877856769acb87ba19d864db106c760 (diff) | |
Use dmi_get_str() to get chassis type; start to detect SBC
Removes a FIXME.
Signed-off-by: Burt P <pburt0@gmail.com>
Diffstat (limited to 'modules')
| -rw-r--r-- | modules/computer.c | 23 | 
1 files changed, 19 insertions, 4 deletions
| diff --git a/modules/computer.c b/modules/computer.c index 51a221ae..42adf196 100644 --- a/modules/computer.c +++ b/modules/computer.c @@ -32,6 +32,10 @@  #include <vendor.h>  #include "computer.h" + +#include "devices.h" /* for dmi_get_str() */ +#include "dt_util.h" /* for dtr_get_string() */ +  #include "info.h"  /* Callbacks */ @@ -303,7 +307,8 @@ static gchar *detect_machine_type(void)      GDir *dir;      gchar *chassis; -    if (g_file_get_contents("/sys/devices/virtual/dmi/id/chassis_type", &chassis, NULL, NULL)) { +    chassis = dmi_get_str("chassis-type"); +    if (chassis != NULL) {          static const char *types[] = {              N_("Invalid chassis type (0)"),              N_("Unknown chassis type"), /* 1 is "Other", but not helpful in HardInfo */ @@ -331,12 +336,24 @@ static gchar *detect_machine_type(void)              N_("Rack Mount Chassis"),              N_("Sealed-case PC"),          }; -        int chassis_type = atoi(idle_free(chassis)); +        int chassis_type = atoi(chassis); +        g_free(chassis);          if (chassis_type >= 0 && chassis_type < G_N_ELEMENTS(types))              return g_strdup(_(types[chassis_type]));      } +    chassis = dtr_get_string("/model", 0); +    if (chassis) { +        if (strstr(chassis, "Raspberry Pi") != NULL +            || strstr(chassis, "ODROID") != NULL +            /* etc */ ) { +                g_free(chassis); +                return g_strdup(_("Single-board computer")); +        } +        g_free(chassis); +    } +      if (g_file_test("/proc/pmu/info", G_FILE_TEST_EXISTS))          return g_strdup(_("Laptop")); @@ -381,8 +398,6 @@ static gchar *detect_machine_type(void)      /* FIXME: check if batteries are found using /proc/apm */ -    /* FIXME: use dmidecode if available to get chassis type */ -      return g_strdup(_("Unknown physical machine type"));  } | 
