]> mj.ucw.cz Git - pciutils.git/commitdiff
Fixes for NetBSD
authorMartin Mares <mj@ucw.cz>
Mon, 12 Dec 2005 12:03:28 +0000 (12:03 +0000)
committerMartin Mares <mj@ucw.cz>
Fri, 5 May 2006 12:18:34 +0000 (14:18 +0200)
git-archimport-id: mj@ucw.cz--public/pciutils--main--2.2--patch-90

ChangeLog
Makefile
lib/nbsd-libpci.c

index bdea16fdaae20eedae0c85b5504c42c237a217be..cbcfe7b14aee932292e25a7adb5079d8cb61ed2f 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2005-12-12  Martin Mares  <mj@ucw.cz>
+
+       * lib/nbsd-libpci.c: If libpci is used by an ordinary user, allow
+       at least read-only access. Patch by Pavel Celeda <celeda@liberouter.org>.
+
+       * Makefile: Corrected library path on NetBSD.
+
 2005-11-26  Martin Mares  <mj@ucw.cz>
 
        * Released as 2.2.1.
index 94a5d4abce3b7514e3ddc91ba9225ce827765dc1..7c8cf65bad1a943198b489250ce145eb0d691c28 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -18,7 +18,7 @@ PCILIB=lib/libpci.a
 PCIINC=lib/config.h lib/header.h lib/pci.h lib/types.h lib/sysdep.h
 
 ifeq ($(shell uname),NetBSD)
-PCILIB=libpciutils.a
+PCILIB=lib/libpciutils.a
 LDFLAGS+=-lpci
 else
 ifeq ($(shell uname),AIX)
index c9305017f4b0941de6651c82ed7d7616adf02072..00c6878249b9ed155a31944a11ada5fb90db18cd 100644 (file)
@@ -38,6 +38,11 @@ nbsd_detect(struct pci_access *a)
       a->warning("Cannot open %s", name);
       return 0;
     }
+
+  if (!access(name, W_OK))
+    {
+      a->writeable = O_RDWR;
+    }
   a->debug("...using %s", name);
   return 1;
 }
@@ -46,8 +51,9 @@ static void
 nbsd_init(struct pci_access *a)
 {
   char *name = a->method_params[PCI_ACCESS_NBSD_LIBPCI];
+  int mode = a->writeable ? O_RDWR : O_RDONLY;
 
-  a->fd = open(name, O_RDWR, 0);
+  a->fd = open(name, mode, 0);
   if (a->fd < 0)
     a->error("nbsd_init: %s open failed", name);
 }