diff options
author | Leandro A. F. Pereira <leandro@hardinfo.org> | 2009-02-21 12:59:39 -0300 |
---|---|---|
committer | Leandro A. F. Pereira <leandro@hardinfo.org> | 2009-02-21 12:59:39 -0300 |
commit | 6bc92795d0855cc08cf93e00a13f11595d36c7ec (patch) | |
tree | e9d06bfe56afa6ce0cc056011a657e064a915019 /hardinfo2/arch/linux/common/pci.h | |
parent | bd76c170d0b57077574e2d3f75c5ae029f8a379e (diff) |
Don't rely on hardcoded paths anymore
Diffstat (limited to 'hardinfo2/arch/linux/common/pci.h')
-rw-r--r-- | hardinfo2/arch/linux/common/pci.h | 15 |
1 files changed, 12 insertions, 3 deletions
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); } |