diff options
| author | tron <tron@NetBSD.org> | 2001-11-08 08:05:05 +0000 |
|---|---|---|
| committer | tron <tron@NetBSD.org> | 2001-11-08 08:05:05 +0000 |
| commit | 4c61cd90ba38f433a452136b9597e9ac74fb2379 (patch) | |
| tree | 09b51098235144fef98a62466e96520f7f9bc742 /usr.sbin/pcictl | |
| parent | 2cd41580a70551f19471b6acb457629837c7538a (diff) | |
Don't abuse opendisk(3) to open PCI bus devices which are no disks. This
fixes PR bin/14468 by Valeriy E. Ushakov.
Diffstat (limited to 'usr.sbin/pcictl')
| -rw-r--r-- | usr.sbin/pcictl/pcictl.c | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/usr.sbin/pcictl/pcictl.c b/usr.sbin/pcictl/pcictl.c index e418dc82958..9bacd005c1e 100644 --- a/usr.sbin/pcictl/pcictl.c +++ b/usr.sbin/pcictl/pcictl.c @@ -1,4 +1,4 @@ -/* $NetBSD: pcictl.c,v 1.4 2001/09/17 10:05:57 joda Exp $ */ +/* $NetBSD: pcictl.c,v 1.5 2001/11/08 08:05:05 tron Exp $ */ /* * Copyright 2001 Wasabi Systems, Inc. @@ -44,6 +44,7 @@ #include <err.h> #include <errno.h> #include <fcntl.h> +#include <paths.h> #include <pci.h> #include <stdio.h> #include <stdlib.h> @@ -123,13 +124,14 @@ main(int argc, char *argv[]) argnames = commands[i].arg_names; /* Open the device. */ - pcifd = opendisk(dvname, commands[i].open_flags, dvname_store, - sizeof(dvname_store), 1); - if (pcifd == -1) + if ((strchr(dvname, '/') == NULL) && + (snprintf(dvname_store, sizeof(dvname_store), _PATH_DEV "%s", + dvname) < sizeof(dvname_store))) + dvname = dvname_store; + pcifd = open(dvname, commands[i].open_flags); + if (pcifd < 0) err(1, "%s", dvname); - dvname = dvname_store; - /* Make sure the device is a PCI bus. */ if (ioctl(pcifd, PCI_IOC_BUSINFO, &pci_businfo) != 0) errx(1, "%s: not a PCI bus device\n", dvname); |
