From: Martin Mares Date: Mon, 12 Dec 2005 12:03:28 +0000 (+0000) Subject: Fixes for NetBSD X-Git-Tag: v3.0.0~75 X-Git-Url: http://mj.ucw.cz/gitweb/?a=commitdiff_plain;h=e6859953f86aa9a7bf5d0a7280e2d7be80387571;p=pciutils.git Fixes for NetBSD git-archimport-id: mj@ucw.cz--public/pciutils--main--2.2--patch-90 --- diff --git a/ChangeLog b/ChangeLog index bdea16f..cbcfe7b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2005-12-12 Martin Mares + + * lib/nbsd-libpci.c: If libpci is used by an ordinary user, allow + at least read-only access. Patch by Pavel Celeda . + + * Makefile: Corrected library path on NetBSD. + 2005-11-26 Martin Mares * Released as 2.2.1. diff --git a/Makefile b/Makefile index 94a5d4a..7c8cf65 100644 --- 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) diff --git a/lib/nbsd-libpci.c b/lib/nbsd-libpci.c index c930501..00c6878 100644 --- a/lib/nbsd-libpci.c +++ b/lib/nbsd-libpci.c @@ -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); }