summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGuillaume Cottenceau <gc@mandriva.com>2003-08-13 20:36:57 +0000
committerGuillaume Cottenceau <gc@mandriva.com>2003-08-13 20:36:57 +0000
commit28369699d22b0c4c1b8d2373e61b10e685314a4f (patch)
treee8aa3291f83edca9864399db600a51e2432ad382
parent0007625f8c483901965549fcc8cc90ad96aa3b07 (diff)
downloaddrakx-28369699d22b0c4c1b8d2373e61b10e685314a4f.tar
drakx-28369699d22b0c4c1b8d2373e61b10e685314a4f.tar.gz
drakx-28369699d22b0c4c1b8d2373e61b10e685314a4f.tar.bz2
drakx-28369699d22b0c4c1b8d2373e61b10e685314a4f.tar.xz
drakx-28369699d22b0c4c1b8d2373e61b10e685314a4f.zip
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.
-rw-r--r--mdk-stage1/probing.c12
1 files changed, 8 insertions, 4 deletions
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);