aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CMakeLists.txt8
-rw-r--r--hardinfo/cpu_util.c (renamed from modules/devices/cpu_util.c)0
-rw-r--r--hardinfo/cpubits.c (renamed from modules/devices/cpubits.c)0
-rw-r--r--hardinfo/dmi_util.c150
-rw-r--r--hardinfo/dt_util.c (renamed from modules/devices/devicetree/dt_util.c)0
-rw-r--r--includes/devices.h7
-rw-r--r--includes/dmi_util.h8
-rw-r--r--modules/computer.c2
-rw-r--r--modules/devices/dmi.c129
9 files changed, 168 insertions, 136 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index d4c60fec..5cd014d3 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -137,13 +137,11 @@ set(MODULE_computer_SOURCES
)
set(MODULE_devices_SOURCES
modules/devices.c
- modules/devices/cpu_util.c
modules/devices/${HARDINFO_ARCH}/processor.c
modules/devices/battery.c
modules/devices/devmemory.c
modules/devices/dmi.c
modules/devices/devicetree.c
- modules/devices/devicetree/dt_util.c
modules/devices/inputdevices.c
modules/devices/pci.c
modules/devices/printers.c
@@ -222,6 +220,9 @@ add_executable(hardinfo
hardinfo/util.c
hardinfo/vendor.c
hardinfo/info.c
+ hardinfo/cpu_util.c
+ hardinfo/dmi_util.c
+ hardinfo/dt_util.c
shell/callbacks.c
shell/iconcache.c
shell/menu.c
@@ -247,6 +248,9 @@ add_executable(hardinfo
hardinfo/util.c
hardinfo/vendor.c
hardinfo/info.c
+ hardinfo/cpu_util.c
+ hardinfo/dmi_util.c
+ hardinfo/dt_util.c
shell/callbacks.c
shell/iconcache.c
shell/menu.c
diff --git a/modules/devices/cpu_util.c b/hardinfo/cpu_util.c
index f5bddd5c..f5bddd5c 100644
--- a/modules/devices/cpu_util.c
+++ b/hardinfo/cpu_util.c
diff --git a/modules/devices/cpubits.c b/hardinfo/cpubits.c
index ba9bffc7..ba9bffc7 100644
--- a/modules/devices/cpubits.c
+++ b/hardinfo/cpubits.c
diff --git a/hardinfo/dmi_util.c b/hardinfo/dmi_util.c
new file mode 100644
index 00000000..cacca715
--- /dev/null
+++ b/hardinfo/dmi_util.c
@@ -0,0 +1,150 @@
+/*
+ * HardInfo - Displays System Information
+ * Copyright (C) 2003-2017 Leandro A. F. Pereira <leandro@hardinfo.org>
+ * This file
+ * Copyright (C) 2017 Burt P. <pburt0@gmail.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, version 2.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "hardinfo.h"
+#include "dmi_util.h"
+
+const char *dmi_sysfs_root() {
+ char *candidates[] = {
+ "/sys/devices/virtual/dmi",
+ "/sys/class/dmi",
+ NULL
+ };
+ int i = 0;
+ while (candidates[i] != NULL) {
+ if(access(candidates[i], F_OK) != -1)
+ return candidates[i];
+ i++;
+ }
+ return NULL;
+}
+
+char *dmi_get_str(const char *id_str) {
+ static struct {
+ char *id;
+ char *path;
+ } tab_dmi_sysfs[] = {
+ /* dmidecode -> sysfs */
+ { "bios-release-date", "id/bios_date" },
+ { "bios-vendor", "id/bios_vendor" },
+ { "bios-version", "id/bios_version" },
+ { "baseboard-product-name", "id/board_name" },
+ { "baseboard-manufacturer", "id/board_vendor" },
+ { "baseboard-version", "id/board_version" },
+ { "baseboard-serial-number", "id/board_serial" },
+ { "baseboard-asset-tag", "id/board_asset_tag" },
+ { "system-product-name", "id/product_name" },
+ { "system-manufacturer", "id/sys_vendor" },
+ { "system-serial-number", "id/product_serial" },
+ { "system-product-family", "id/product_family" },
+ { "system-version", "id/product_version" },
+ { "system-uuid", "product_uuid" },
+ { "chassis-type", "id/chassis_type" },
+ { "chassis-serial-number", "id/chassis_serial" },
+ { "chassis-manufacturer", "id/chassis_vendor" },
+ { "chassis-version", "id/chassis_version" },
+ { "chassis-asset-tag", "id/chassis_asset_tag" },
+ { NULL, NULL }
+ };
+ const gchar *dmi_root = dmi_sysfs_root();
+ gchar *full_path = NULL, *ret = NULL;
+ gboolean spawned;
+ gchar *out, *err;
+
+ int i = 0;
+
+ /* try sysfs first */
+ if (dmi_root) {
+ while (tab_dmi_sysfs[i].id != NULL) {
+ if (strcmp(id_str, tab_dmi_sysfs[i].id) == 0) {
+ full_path = g_strdup_printf("%s/%s", dmi_root, tab_dmi_sysfs[i].path);
+ if (g_file_get_contents(full_path, &ret, NULL, NULL) )
+ goto dmi_str_done;
+ }
+ i++;
+ }
+ }
+
+ /* try dmidecode, but may require root */
+ full_path = g_strconcat("dmidecode -s ", id_str, NULL);
+ spawned = g_spawn_command_line_sync(full_path,
+ &out, &err, &i, NULL);
+ if (spawned) {
+ if (i == 0)
+ ret = out;
+ else
+ g_free(out);
+ g_free(err);
+ }
+
+dmi_str_done:
+ if (ret != NULL) {
+ ret = strend(ret, '\n');
+ ret = g_strstrip(ret);
+ if (strlen(ret) == 0) {
+ g_free(ret);
+ ret = NULL;
+ }
+ }
+ g_free(full_path);
+ return ret;
+}
+
+char *dmi_chassis_type_str(int with_val) {
+ gchar *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 */
+ N_("Unknown chassis type"),
+ N_("Desktop"),
+ N_("Low-profile Desktop"),
+ N_("Pizza Box"),
+ N_("Mini Tower"),
+ N_("Tower"),
+ N_("Portable"),
+ N_("Laptop"),
+ N_("Notebook"),
+ N_("Handheld"),
+ N_("Docking Station"),
+ N_("All-in-one"),
+ N_("Subnotebook"),
+ N_("Space-saving"),
+ N_("Lunch Box"),
+ N_("Main Server Chassis"),
+ N_("Expansion Chassis"),
+ N_("Sub Chassis"),
+ N_("Bus Expansion Chassis"),
+ N_("Peripheral Chassis"),
+ N_("RAID Chassis"),
+ N_("Rack Mount Chassis"),
+ N_("Sealed-case PC"),
+ };
+ int chassis_type = atoi(chassis);
+ g_free(chassis);
+
+ if (chassis_type >= 0 && chassis_type < G_N_ELEMENTS(types))
+ if (with_val)
+ return g_strdup_printf("[%d] %s", chassis_type, _(types[chassis_type]));
+ else
+ return g_strdup(_(types[chassis_type]));
+ }
+ return NULL;
+}
diff --git a/modules/devices/devicetree/dt_util.c b/hardinfo/dt_util.c
index 9678042d..9678042d 100644
--- a/modules/devices/devicetree/dt_util.c
+++ b/hardinfo/dt_util.c
diff --git a/includes/devices.h b/includes/devices.h
index a05baf2f..0508c819 100644
--- a/includes/devices.h
+++ b/includes/devices.h
@@ -3,6 +3,7 @@
#include "hardinfo.h"
#include "processor-platform.h"
+#include "dmi_util.h"
typedef struct _Processor Processor;
@@ -72,10 +73,6 @@ void sensors_shutdown(void);
void scan_spd_do(void);
#endif /* ARCH_x86 */
-/* DMI */
-char *dmi_get_str(const char *id_str);
-char *dmi_chassis_type_str(int with_val);
-
extern gchar *battery_list;
extern gchar *input_icons;
extern gchar *input_list;
@@ -96,9 +93,9 @@ extern GModule *cups;
#if defined(ARCH_x86) || defined(ARCH_x86_64)
extern gchar *spd_info;
+extern gchar *dmi_info;
#endif
-extern gchar *dmi_info;
extern gchar *dtree_info;
#endif /* __DEVICES_H__ */
diff --git a/includes/dmi_util.h b/includes/dmi_util.h
new file mode 100644
index 00000000..b92d4ff2
--- /dev/null
+++ b/includes/dmi_util.h
@@ -0,0 +1,8 @@
+#ifndef __DMI_UTIL_H__
+#define __DMI_UTIL_H__
+
+const char *dmi_sysfs_root(void);
+char *dmi_get_str(const char *id_str);
+char *dmi_chassis_type_str(int with_val);
+
+#endif
diff --git a/modules/computer.c b/modules/computer.c
index 05d27ba6..5f346733 100644
--- a/modules/computer.c
+++ b/modules/computer.c
@@ -33,7 +33,7 @@
#include "computer.h"
-#include "devices.h" /* for dmi_get_str() */
+#include "dmi_util.h" /* for dmi_get_str() */
#include "dt_util.h" /* for dtr_get_string() */
#include "info.h"
diff --git a/modules/devices/dmi.c b/modules/devices/dmi.c
index 55b55245..a3620959 100644
--- a/modules/devices/dmi.c
+++ b/modules/devices/dmi.c
@@ -22,6 +22,7 @@
#include <sys/types.h>
#include "devices.h"
+#include "dmi_util.h"
typedef struct _DMIInfo DMIInfo;
@@ -57,134 +58,6 @@ DMIInfo dmi_info_table[] = {
gchar *dmi_info = NULL;
-const char *dmi_sysfs_root() {
- char *candidates[] = {
- "/sys/devices/virtual/dmi",
- "/sys/class/dmi",
- NULL
- };
- int i = 0;
- while (candidates[i] != NULL) {
- if(access(candidates[i], F_OK) != -1)
- return candidates[i];
- i++;
- }
- return NULL;
-}
-
-char *dmi_get_str(const char *id_str) {
- static struct {
- char *id;
- char *path;
- } tab_dmi_sysfs[] = {
- /* dmidecode -> sysfs */
- { "bios-release-date", "id/bios_date" },
- { "bios-vendor", "id/bios_vendor" },
- { "bios-version", "id/bios_version" },
- { "baseboard-product-name", "id/board_name" },
- { "baseboard-manufacturer", "id/board_vendor" },
- { "baseboard-version", "id/board_version" },
- { "baseboard-serial-number", "id/board_serial" },
- { "baseboard-asset-tag", "id/board_asset_tag" },
- { "system-product-name", "id/product_name" },
- { "system-manufacturer", "id/sys_vendor" },
- { "system-serial-number", "id/product_serial" },
- { "system-product-family", "id/product_family" },
- { "system-version", "id/product_version" },
- { "system-uuid", "product_uuid" },
- { "chassis-type", "id/chassis_type" },
- { "chassis-serial-number", "id/chassis_serial" },
- { "chassis-manufacturer", "id/chassis_vendor" },
- { "chassis-version", "id/chassis_version" },
- { "chassis-asset-tag", "id/chassis_asset_tag" },
- { NULL, NULL }
- };
- const gchar *dmi_root = dmi_sysfs_root();
- gchar *full_path = NULL, *ret = NULL;
- gboolean spawned;
- gchar *out, *err;
-
- int i = 0;
-
- /* try sysfs first */
- if (dmi_root) {
- while (tab_dmi_sysfs[i].id != NULL) {
- if (strcmp(id_str, tab_dmi_sysfs[i].id) == 0) {
- full_path = g_strdup_printf("%s/%s", dmi_root, tab_dmi_sysfs[i].path);
- if (g_file_get_contents(full_path, &ret, NULL, NULL) )
- goto dmi_str_done;
- }
- i++;
- }
- }
-
- /* try dmidecode, but may require root */
- full_path = g_strconcat("dmidecode -s ", id_str, NULL);
- spawned = g_spawn_command_line_sync(full_path,
- &out, &err, &i, NULL);
- if (spawned) {
- if (i == 0)
- ret = out;
- else
- g_free(out);
- g_free(err);
- }
-
-dmi_str_done:
- if (ret != NULL) {
- ret = strend(ret, '\n');
- ret = g_strstrip(ret);
- if (strlen(ret) == 0) {
- g_free(ret);
- ret = NULL;
- }
- }
- g_free(full_path);
- return ret;
-}
-
-char *dmi_chassis_type_str(int with_val) {
- gchar *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 */
- N_("Unknown chassis type"),
- N_("Desktop"),
- N_("Low-profile Desktop"),
- N_("Pizza Box"),
- N_("Mini Tower"),
- N_("Tower"),
- N_("Portable"),
- N_("Laptop"),
- N_("Notebook"),
- N_("Handheld"),
- N_("Docking Station"),
- N_("All-in-one"),
- N_("Subnotebook"),
- N_("Space-saving"),
- N_("Lunch Box"),
- N_("Main Server Chassis"),
- N_("Expansion Chassis"),
- N_("Sub Chassis"),
- N_("Bus Expansion Chassis"),
- N_("Peripheral Chassis"),
- N_("RAID Chassis"),
- N_("Rack Mount Chassis"),
- N_("Sealed-case PC"),
- };
- int chassis_type = atoi(chassis);
- g_free(chassis);
-
- if (chassis_type >= 0 && chassis_type < G_N_ELEMENTS(types))
- if (with_val)
- return g_strdup_printf("[%d] %s", chassis_type, _(types[chassis_type]));
- else
- return g_strdup(_(types[chassis_type]));
- }
- return NULL;
-}
-
static void add_to_moreinfo(const char *group, const char *key, char *value)
{
char *new_key = g_strconcat("DMI:", group, ":", key, NULL);