----- Original Message ----- From: "Matthew Wilcox" <matthew@xxxxxx> To: "Gilles Espinasse" <g.esp@xxxxxxx> Cc: <linux-pci@xxxxxxxxxxxxxxx>; <mj@xxxxxx> Sent: Saturday, June 27, 2009 7:11 PM Subject: Re: minor bug in pciutils libpci for sparc64 when /sys is notmounted > On Sat, Jun 27, 2009 at 06:18:15PM +0200, Gilles Espinasse wrote: > > I know there is a specific define for PCI_ARCH_SPARC64 in types.h. > > But I franckly don't know how fix the code (except that' probably in > > lib/proc.c). > > How about something as simple as this -- try to open both? > > diff --git a/lib/proc.c b/lib/proc.c > index e9ca24d..cb9d08d 100644 > --- a/lib/proc.c > +++ b/lib/proc.c > @@ -131,6 +131,15 @@ proc_setup(struct pci_dev *d, int rw) > 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; > a->fd_pos = 0; > > -- Yes that work. [chroot-sparc64] root:/$ lspci -G Trying method 1......cannot open /sys/bus/pci...No. Trying method 2......using /proc/bus/pci...OK Decided to use linux-proc 00:00.0 Host bridge: Sun Microsystems Computer Corp. Psycho UPA-PCI Bus Module [pcipsy] 00:01.0 PCI bridge: Sun Microsystems Computer Corp. Simba Advanced PCI Bridge (rev 13) 00:01.1 PCI bridge: Sun Microsystems Computer Corp. Simba Advanced PCI Bridge (rev 13) 01:01.0 Bridge: Sun Microsystems Computer Corp. EBUS (rev 01) 01:01.1 Ethernet controller: Sun Microsystems Computer Corp. Happy Meal 10/100 Ethernet [hme] (rev 01) 01:02.0 VGA compatible controller: ATI Technologies Inc 3D Rage Pro 215GP (rev 5c) 01:03.0 IDE interface: Silicon Image, Inc. PCI0646 (rev 03) 02:03.0 Ethernet controller: Realtek Semiconductor Co., Ltd. RTL-8139/8139C/8139C+ (rev 10) Just to check [chroot-sparc64] root:/$ lspci -G -D Trying method 1......cannot open /sys/bus/pci...No. Trying method 2......using /proc/bus/pci...OK Decided to use linux-proc 0000:00:00.0 Host bridge: Sun Microsystems Computer Corp. Psycho UPA-PCI Bus Module [pcipsy] 0000:00:01.0 PCI bridge: Sun Microsystems Computer Corp. Simba Advanced PCI Bridge (rev 13) 0000:00:01.1 PCI bridge: Sun Microsystems Computer Corp. Simba Advanced PCI Bridge (rev 13) 0000:01:01.0 Bridge: Sun Microsystems Computer Corp. EBUS (rev 01) 0000:01:01.1 Ethernet controller: Sun Microsystems Computer Corp. Happy Meal 10/100 Ethernet [hme] (rev 01) 0000:01:02.0 VGA compatible controller: ATI Technologies Inc 3D Rage Pro 215GP (rev 5c) 0000:01:03.0 IDE interface: Silicon Image, Inc. PCI0646 (rev 03) 0000:02:03.0 Ethernet controller: Realtek Semiconductor Co., Ltd. RTL-8139/8139C/8139C+ (rev 10) Gilles -- To unsubscribe from this list: send the line "unsubscribe linux-pci" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html