From: Martin Mares Date: Mon, 29 Jun 2009 17:55:24 +0000 (+0200) Subject: proc: Work around broken /proc/bus/pci/ on some architectures. X-Git-Tag: v3.1.3~12 X-Git-Url: http://mj.ucw.cz/gitweb/?a=commitdiff_plain;h=0208ff057da35fa3fb18b5c3734a60b2eab02e67;p=pciutils.git proc: Work around broken /proc/bus/pci/ on some architectures. Several architectures (e.g., sparc64) use domains in proc directory names, which is inconsistent, because /proc/bus/pci/devices is still unable to represent domains. Work around it, so that the proc back-end works at least on single-domain machines. Suggested by Matthew Wilcox. --- diff --git a/lib/proc.c b/lib/proc.c index e9ca24d..cb9d08d 100644 --- a/lib/proc.c +++ b/lib/proc.c @@ -130,6 +130,15 @@ proc_setup(struct pci_dev *d, int rw) a->error("File name too long"); a->fd_rw = a->writeable || rw; a->fd = open(buf, a->fd_rw ? O_RDWR : O_RDONLY); + if (a->fd < 0) + { + e = snprintf(buf, sizeof(buf), "%s/%04x:%02x/%02x.%d", + pci_get_param(a, "proc.path"), + d->domain, d->bus, d->dev, d->func); + if (e < 0 || e >= (int) sizeof(buf)) + a->error("File name too long"); + a->fd = open(buf, a->fd_rw ? O_RDWR : O_RDONLY); + } if (a->fd < 0) a->warning("Cannot open %s", buf); a->cached_dev = d;