Source-Changes-HG archive

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

[src/trunk]: src/usr.sbin/pcictl Don't abuse opendisk(3) to open PCI bus devi...



details:   https://anonhg.NetBSD.org/src/rev/eda782885214
branches:  trunk
changeset: 517187:eda782885214
user:      tron <tron%NetBSD.org@localhost>
date:      Thu Nov 08 08:05:05 2001 +0000

description:
Don't abuse opendisk(3) to open PCI bus devices which are no disks. This
fixes PR bin/14468 by Valeriy E. Ushakov.

diffstat:

 usr.sbin/pcictl/pcictl.c |  14 ++++++++------
 1 files changed, 8 insertions(+), 6 deletions(-)

diffs (37 lines):

diff -r 2ddae36d5a9b -r eda782885214 usr.sbin/pcictl/pcictl.c
--- a/usr.sbin/pcictl/pcictl.c  Thu Nov 08 07:45:25 2001 +0000
+++ b/usr.sbin/pcictl/pcictl.c  Thu Nov 08 08:05:05 2001 +0000
@@ -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 @@
        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);



Home | Main Index | Thread Index | Old Index