summaryrefslogtreecommitdiffstats
path: root/usr.sbin/pciconf
diff options
context:
space:
mode:
authorse <se@FreeBSD.org>2007-10-04 22:18:53 +0000
committerse <se@FreeBSD.org>2007-10-04 22:18:53 +0000
commit38b0f76e4a8bb685aa9eac22e1a6838bf32bccaf (patch)
tree07858f3b726f8c7ebcf9e6aaac57765f4941a688 /usr.sbin/pciconf
parent4a797d19e272b1802eb4e259e4d0703093aae4fa (diff)
downloadFreeBSD-src-38b0f76e4a8bb685aa9eac22e1a6838bf32bccaf.zip
FreeBSD-src-38b0f76e4a8bb685aa9eac22e1a6838bf32bccaf.tar.gz
Restore compatibility with version before introduction of PCI domains.
PCI selectors with 2 or 3 elements behave exactly as before (i.e. the domain is 0 and in the 2 element case, the function is also 0). The form with 4 selector elements works as in the previous revision and provides the PCI domain number as the left-most selector element. This change allows old scripts (which used the 2 or 3 selector element formats) to be kept. Without this patch, the 3 element form was parsed as starting with a domain number (and the function was assumed to be 0), with this patch, the domain is assumed to be 0 (and the last value is used as the function number). The man page is updated to describe the new selector semantics. Approved by: re (Ken Smith)
Diffstat (limited to 'usr.sbin/pciconf')
-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