Re: minor bug in pciutils libpci for sparc64 when /sys is not mounted

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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;

-- 
Matthew Wilcox				Intel Open Source Technology Centre
"Bill, look, we understand that you're interested in selling us this
operating system, but compare it to ours.  We can't possibly take such
a retrograde step."
--
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

[Index of Archives]     [DMA Engine]     [Linux Coverity]     [Linux USB]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Greybus]

  Powered by Linux