summaryrefslogtreecommitdiffstats
path: root/pci.c
diff options
context:
space:
mode:
authorThierry Vignaud <tvignaud@mandriva.org>2002-08-22 10:27:33 +0000
committerThierry Vignaud <tvignaud@mandriva.org>2002-08-22 10:27:33 +0000
commit723537d056f0e3ab906da118e5b22815d1db1fb1 (patch)
treef0c484f3d59199a9db59124b83aacc3a907cd0d9 /pci.c
parent48380b3127eab88835b538cb1e2c4e3acd497e05 (diff)
downloadldetect-723537d056f0e3ab906da118e5b22815d1db1fb1.tar
ldetect-723537d056f0e3ab906da118e5b22815d1db1fb1.tar.gz
ldetect-723537d056f0e3ab906da118e5b22815d1db1fb1.tar.bz2
ldetect-723537d056f0e3ab906da118e5b22815d1db1fb1.tar.xz
ldetect-723537d056f0e3ab906da118e5b22815d1db1fb1.zip
try to not freeze on buggy motherboard by preventing:
- seeking in /proc/bus/pci/<bus>/<device>.<function> - not reading the whole /proc/bus/pci/<bus>/<device>.<function> we now read 48 linear bytes the same way lspci read 64 linear bytes.
Diffstat (limited to 'pci.c')
-rw-r--r--pci.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/pci.c b/pci.c
index 157b15b..05d1c40 100644
--- a/pci.c
+++ b/pci.c
@@ -44,11 +44,12 @@ extern struct pciusb_entries pci_probe(int probe_type) {
FILE *f;
snprintf(file, sizeof(file), "/proc/bus/pci/%02x/%02x.%d", e->pci_bus, e->pci_device, e->pci_function);
if ((f = fopen(file, "r"))) {
- if (fseek(f, 10, SEEK_SET) == 0)
- fread(&e->class_, 2, 1, f);
- if (fseek(f, 0x2c, SEEK_SET) == 0)
- fread(&e->subvendor, 2, 1, f), fread(&e->subdevice, 2, 1, f);
-
+ unsigned short *bufi = (unsigned short *) &buf;
+ fread(&buf, 0x30, 1, f); /* these files're 256 bytes but we only need first 48 bytes*/
+ e->class_ = bufi[5];
+ e->subvendor = bufi[0x16];
+ e->subdevice = bufi[0x17];
+
if ((e->subvendor == 0 && e->subdevice == 0) ||
(e->subvendor == e->vendor && e->subdevice == e->device)) {
e->subvendor = 0xffff;