summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--usr.sbin/pciconf/pciconf.810
-rw-r--r--usr.sbin/pciconf/pciconf.c30
2 files changed, 22 insertions, 18 deletions
diff --git a/usr.sbin/pciconf/pciconf.8 b/usr.sbin/pciconf/pciconf.8
index 4195d28..3ba827c 100644
--- a/usr.sbin/pciconf/pciconf.8
+++ b/usr.sbin/pciconf/pciconf.8
@@ -142,10 +142,12 @@ except for
require a
.Ar selector
of the form
-.Li pci Ns Va domain Ns \&: Ns Va bus Ns \&: Ns Va device
-(optionally followed by
-.Li \&: Ns Va function ) .
-A final colon may be appended and
+.Li pci Ns Va domain Ns \&: Ns Va bus Ns \&: Ns Va device Ns \&: \
+Ns Va function Ns ,
+.Li pci Ns Va bus Ns \&: Ns Va device Ns \&: Ns Va function Ns , or
+.Li pci Ns Va bus Ns \&: Ns Va device Ns .
+In case of an abrigded form, omitted selector components are assumed to be 0.
+An optional leading device name followed by @ and an optional final colon
will be ignored; this is so that the first column in the output of
.Nm
.Fl l
diff --git a/usr.sbin/pciconf/pciconf.c b/usr.sbin/pciconf/pciconf.c
index 07b6feb..c679314 100644
--- a/usr.sbin/pciconf/pciconf.c
+++ b/usr.sbin/pciconf/pciconf.c
@@ -486,6 +486,8 @@ getsel(const char *str)
char *ep = strchr(str, '@');
char *epbase;
struct pcisel sel;
+ unsigned long selarr[4];
+ int i;
if (ep == NULL)
ep = (char *)str;
@@ -496,21 +498,21 @@ getsel(const char *str)
if (strncmp(ep, "pci", 3) == 0) {
ep += 3;
- sel.pc_domain = strtoul(ep, &ep, 0);
- if (!ep || *ep++ != ':')
- errx(1, "cannot parse selector %s", str);
- sel.pc_bus = strtoul(ep, &ep, 0);
- if (!ep || *ep++ != ':')
- errx(1, "cannot parse selector %s", str);
- sel.pc_dev = strtoul(ep, &ep, 0);
- if (!ep || *ep != ':') {
+ i = 0;
+ do {
+ selarr[i++] = strtoul(ep, &ep, 10);
+ } while (*ep == ':' && *++ep != '\0' && i < 4);
+
+ if (i > 2)
+ sel.pc_func = selarr[--i];
+ else
sel.pc_func = 0;
- } else {
- ep++;
- sel.pc_func = strtoul(ep, &ep, 0);
- }
- if (*ep == ':')
- ep++;
+ sel.pc_dev = selarr[--i];
+ sel.pc_bus = selarr[--i];
+ if (i > 0)
+ sel.pc_domain = selarr[--i];
+ else
+ sel.pc_domain = 0;
}
if (*ep != '\x0' || ep == epbase)
errx(1, "cannot parse selector %s", str);
OpenPOWER on IntegriCloud