summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
Diffstat (limited to 'modules')
-rw-r--r--modules/devices.c51
-rw-r--r--modules/devices/resources.c18
2 files changed, 55 insertions, 14 deletions
diff --git a/modules/devices.c b/modules/devices.c
index 82484a23..c57fd433 100644
--- a/modules/devices.c
+++ b/modules/devices.c
@@ -68,23 +68,40 @@ void scan_spd(gboolean reload);
#endif
void scan_device_resources(gboolean reload);
+gboolean root_required_for_resources(void);
+
gchar *hi_more_info(gchar *entry);
+enum {
+ ENTRY_PROCESSOR,
+ ENTRY_MEMORY,
+ ENTRY_PCI,
+ ENTRY_USB,
+ ENTRY_PRINTERS,
+ ENTRY_BATTERY,
+ ENTRY_SENSORS,
+ ENTRY_INPUT,
+ ENTRY_STORAGE,
+ ENTRY_DMI,
+ ENTRY_SPD,
+ ENTRY_RESOURCES
+};
+
static ModuleEntry entries[] = {
- {N_("Processor"), "processor.png", callback_processors, scan_processors, MODULE_FLAG_NONE},
- {N_("Memory"), "memory.png", callback_memory, scan_memory, MODULE_FLAG_NONE},
- {N_("PCI Devices"), "devices.png", callback_pci, scan_pci, MODULE_FLAG_NONE},
- {N_("USB Devices"), "usb.png", callback_usb, scan_usb, MODULE_FLAG_NONE},
- {N_("Printers"), "printer.png", callback_printers, scan_printers, MODULE_FLAG_NONE},
- {N_("Battery"), "battery.png", callback_battery, scan_battery, MODULE_FLAG_NONE},
- {N_("Sensors"), "therm.png", callback_sensors, scan_sensors, MODULE_FLAG_NONE},
- {N_("Input Devices"), "inputdevices.png", callback_input, scan_input, MODULE_FLAG_NONE},
- {N_("Storage"), "hdd.png", callback_storage, scan_storage, MODULE_FLAG_NONE},
+ [ENTRY_PROCESSOR] = {N_("Processor"), "processor.png", callback_processors, scan_processors, MODULE_FLAG_NONE},
+ [ENTRY_MEMORY] = {N_("Memory"), "memory.png", callback_memory, scan_memory, MODULE_FLAG_NONE},
+ [ENTRY_PCI] = {N_("PCI Devices"), "devices.png", callback_pci, scan_pci, MODULE_FLAG_NONE},
+ [ENTRY_USB] = {N_("USB Devices"), "usb.png", callback_usb, scan_usb, MODULE_FLAG_NONE},
+ [ENTRY_PRINTERS] = {N_("Printers"), "printer.png", callback_printers, scan_printers, MODULE_FLAG_NONE},
+ [ENTRY_BATTERY] = {N_("Battery"), "battery.png", callback_battery, scan_battery, MODULE_FLAG_NONE},
+ [ENTRY_SENSORS] = {N_("Sensors"), "therm.png", callback_sensors, scan_sensors, MODULE_FLAG_NONE},
+ [ENTRY_INPUT] = {N_("Input Devices"), "inputdevices.png", callback_input, scan_input, MODULE_FLAG_NONE},
+ [ENTRY_STORAGE] = {N_("Storage"), "hdd.png", callback_storage, scan_storage, MODULE_FLAG_NONE},
#if defined(ARCH_x86) || defined(ARCH_x86_64)
- {N_("DMI"), "computer.png", callback_dmi, scan_dmi, MODULE_FLAG_NONE},
- {N_("Memory SPD"), "memory.png", callback_spd, scan_spd, MODULE_FLAG_NONE},
+ [ENTRY_DMI] = {N_("DMI"), "computer.png", callback_dmi, scan_dmi, MODULE_FLAG_NONE},
+ [ENTRY_SPD] = {N_("Memory SPD"), "memory.png", callback_spd, scan_spd, MODULE_FLAG_NONE},
#endif /* x86 or x86_64 */
- {N_("Resources"), "resources.png", callback_device_resources, scan_device_resources, MODULE_FLAG_NONE},
+ [ENTRY_RESOURCES] = {N_("Resources"), "resources.png", callback_device_resources, scan_device_resources, MODULE_FLAG_NONE},
{NULL}
};
@@ -475,3 +492,13 @@ gchar **hi_module_get_dependencies(void)
return deps;
}
+
+const gchar *hi_note_func(gint entry)
+{
+ if (entry == ENTRY_RESOURCES) {
+ if (root_required_for_resources()) {
+ return "Resource information requires superuser privileges";
+ }
+ }
+ return NULL;
+}
diff --git a/modules/devices/resources.c b/modules/devices/resources.c
index 270000dd..15cb8f21 100644
--- a/modules/devices/resources.c
+++ b/modules/devices/resources.c
@@ -16,9 +16,12 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
+#include <string.h>
+
#include "devices.h"
-gchar *_resources = NULL;
+static gchar *_resources = NULL;
+static gboolean _require_root = FALSE;
#if GLIB_CHECK_VERSION(2,14,0)
static GRegex *_regex_pci = NULL,
@@ -64,6 +67,7 @@ void scan_device_resources(gboolean reload)
FILE *io;
gchar buffer[256];
gint i;
+ gint zero_to_zero_addr = 0;
struct {
gchar *file;
@@ -85,6 +89,9 @@ void scan_device_resources(gboolean reload)
gchar **temp = g_strsplit(buffer, ":", 2);
gchar *name = _resource_obtain_name(temp[1]);
+ if (strstr(temp[0], "0000-0000"))
+ zero_to_zero_addr++;
+
_resources = h_strdup_cprintf("<tt>%s</tt>=%s\n", _resources,
temp[0], name);
@@ -95,7 +102,9 @@ void scan_device_resources(gboolean reload)
fclose(io);
}
}
-
+
+ _require_root = zero_to_zero_addr > 16;
+
SCAN_END();
}
@@ -103,3 +112,8 @@ gchar *callback_device_resources(void)
{
return g_strdup(_resources);
}
+
+gboolean root_required_for_resources(void)
+{
+ return _require_root;
+}