From 28369699d22b0c4c1b8d2373e61b10e685314a4f Mon Sep 17 00:00:00 2001 From: Guillaume Cottenceau Date: Wed, 13 Aug 2003 20:36:57 +0000 Subject: full pci probe can't be run with fopen/fread because we might read too many bytes. this was the reason for freezes on some boxes from drakx, that may impact stage1 also, so better change that. --- mdk-stage1/probing.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'mdk-stage1') diff --git a/mdk-stage1/probing.c b/mdk-stage1/probing.c index 123d42c4e..3fc80db51 100644 --- a/mdk-stage1/probing.c +++ b/mdk-stage1/probing.c @@ -235,15 +235,19 @@ void probe_that_type(enum driver_type type, enum media_bus bus __attribute__ ((u int device_p = (devbusfn & 0xff) >> 3; int function = (devbusfn & 0xff) & 0x07; char file[100]; - FILE * sf; + int sf; log_message("PCI: device %04x %04x needs full pci probe", vendor, device); sprintf(file, "/proc/bus/pci/%02x/%02x.%d", bus, device_p, function); - if (!(sf = fopen(file, "rb"))) { + if ((sf = open(file, O_RDONLY)) == -1) { log_message("PCI: could not open file for full probe (%s)", file); continue; } - fread(&buf, 48, 1, sf); - fclose(sf); + if (read(sf, buf, 48) == -1) { + log_message("PCI: could not read 48 bytes from %s", file); + close(sf); + continue; + } + close(sf); memcpy(&subvendor, buf+44, 2); memcpy(&subdevice, buf+46, 2); log_message("PCI: device is actually %04x %04x %04x %04x", vendor, device, subvendor, subdevice); -- cgit v1.2.1