aboutsummaryrefslogtreecommitdiff
path: root/hardinfo2/arch
diff options
context:
space:
mode:
authorLeandro A. F. Pereira <leandro@hardinfo.org>2009-02-21 12:59:39 -0300
committerLeandro A. F. Pereira <leandro@hardinfo.org>2009-02-21 12:59:39 -0300
commit6bc92795d0855cc08cf93e00a13f11595d36c7ec (patch)
treee9d06bfe56afa6ce0cc056011a657e064a915019 /hardinfo2/arch
parentbd76c170d0b57077574e2d3f75c5ae029f8a379e (diff)
Don't rely on hardcoded paths anymore
Diffstat (limited to 'hardinfo2/arch')
-rw-r--r--hardinfo2/arch/linux/common/modules.h10
-rw-r--r--hardinfo2/arch/linux/common/pci.h15
2 files changed, 20 insertions, 5 deletions
diff --git a/hardinfo2/arch/linux/common/modules.h b/hardinfo2/arch/linux/common/modules.h
index 32c9c0d6..7ea238b7 100644
--- a/hardinfo2/arch/linux/common/modules.h
+++ b/hardinfo2/arch/linux/common/modules.h
@@ -36,6 +36,7 @@ scan_modules_do(void)
{
FILE *lsmod;
gchar buffer[1024];
+ gchar *lsmod_path;
if (!_module_hash_table) {
_module_hash_table = g_hash_table_new(g_str_hash, g_str_equal);
@@ -48,9 +49,12 @@ scan_modules_do(void)
module_list = NULL;
g_hash_table_foreach_remove(moreinfo, remove_module_devices, NULL);
- lsmod = popen("/sbin/lsmod", "r");
- if (!lsmod)
+ lsmod_path = find_program("lsmod");
+ lsmod = popen(lsmod_path, "r");
+ if (!lsmod) {
+ g_free(lsmod_path);
return;
+ }
fgets(buffer, 1024, lsmod); /* Discards the first line */
@@ -160,4 +164,6 @@ scan_modules_do(void)
g_free(filename);
}
pclose(lsmod);
+
+ g_free(lsmod_path);
}
diff --git a/hardinfo2/arch/linux/common/pci.h b/hardinfo2/arch/linux/common/pci.h
index 7358090a..a1ea1021 100644
--- a/hardinfo2/arch/linux/common/pci.h
+++ b/hardinfo2/arch/linux/common/pci.h
@@ -33,9 +33,15 @@ __scan_pci(void)
{
FILE *lspci;
gchar buffer[256], *buf, *strhash = NULL, *strdevice = NULL;
- gchar *category = NULL, *name = NULL, *icon;
+ gchar *category = NULL, *name = NULL, *icon, *lspci_path, *command_line;
gint n = 0, x = 0;
+ if ((lspci_path = find_program("lspci")) == NULL) {
+ goto pci_error;
+ } else {
+ command_line = g_strdup_printf("%s -v", lspci_path);
+ }
+
if (!_pci_devices) {
_pci_devices = g_hash_table_new(g_str_hash, g_str_equal);
}
@@ -44,13 +50,13 @@ __scan_pci(void)
if (!g_file_test(buf, G_FILE_TEST_EXISTS)) {
DEBUG("using system-provided PCI IDs");
g_free(buf);
- if (!(lspci = popen(LSPCI, "r"))) {
+ if (!(lspci = popen(command_line, "r"))) {
goto pci_error;
}
} else {
gchar *tmp;
- tmp = g_strdup_printf("%s -i '%s'", LSPCI, buf);
+ tmp = g_strdup_printf("%s -i '%s'", command_line, buf);
g_free(buf);
buf = tmp;
@@ -232,4 +238,7 @@ pci_error:
g_free(category);
g_free(name);
}
+
+ g_free(lspci_path);
+ g_free(command_line);
}