diff options
author | cinap_lenrek <cinap_lenrek@centraldogma> | 2011-05-23 23:11:29 +0000 |
---|---|---|
committer | cinap_lenrek <cinap_lenrek@centraldogma> | 2011-05-23 23:11:29 +0000 |
commit | 8987674d48c2e95b21f0c79cfd6cedf61d7de395 (patch) | |
tree | b85dafc06cd3073efc59d8621ed96c434894fd1b /sys/src/cmd/aux/vga/pci.c | |
parent | 10415cbb8e94ad88b102169ff876665d6977d41c (diff) |
aux/vga: pci.c dircount bug
Diffstat (limited to 'sys/src/cmd/aux/vga/pci.c')
-rw-r--r-- | sys/src/cmd/aux/vga/pci.c | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/sys/src/cmd/aux/vga/pci.c b/sys/src/cmd/aux/vga/pci.c index 784ccf238..cc5babecb 100644 --- a/sys/src/cmd/aux/vga/pci.c +++ b/sys/src/cmd/aux/vga/pci.c @@ -27,8 +27,11 @@ pcicfginit(void) for(i=0; i<n; i++) { if(strstr(d[i].name, "ctl") == nil) continue; + if((j = strlen(d[i].name)-3) < 5) + continue; + + sprint(buf, "%.*s", j, d[i].name); - sprint(buf, "%s", d[i].name); bno = strtoul(buf, &s, 10); dno = strtoul(s+1, &s, 10); fno = strtoul(s+1, nil, 10); @@ -37,22 +40,25 @@ pcicfginit(void) p->tbdf = MKBUS(BusPCI, bno, dno, fno); sprint(buf, "%s/%d.%d.%draw", base, bno, dno, fno); if((p->rawfd = open(buf, ORDWR)) < 0){ + fprint(2, "raw: %r\n"); free(p); continue; } sprint(buf, "%s/%d.%d.%dctl", base, bno, dno, fno); if((fd = open(buf, OREAD)) < 0){ + fprint(2, "ctl: %r\n"); close(p->rawfd); free(p); continue; } - if((n = read(fd, buf, sizeof(buf)-1)) <= 0){ + if((j = read(fd, buf, sizeof(buf)-1)) <= 0){ + fprint(2, "read: %r\n"); close(p->rawfd); close(fd); free(p); continue; } - buf[n] = 0; + buf[j] = 0; close(fd); p->ccru = strtol(buf + 3, nil, 16); |