diff options
author | se <se@FreeBSD.org> | 2007-10-04 22:18:53 +0000 |
---|---|---|
committer | se <se@FreeBSD.org> | 2007-10-04 22:18:53 +0000 |
commit | 38b0f76e4a8bb685aa9eac22e1a6838bf32bccaf (patch) | |
tree | 07858f3b726f8c7ebcf9e6aaac57765f4941a688 /usr.sbin/pciconf/pciconf.c | |
parent | 4a797d19e272b1802eb4e259e4d0703093aae4fa (diff) | |
download | FreeBSD-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/pciconf.c')
-rw-r--r-- | usr.sbin/pciconf/pciconf.c | 30 |
1 files changed, 16 insertions, 14 deletions
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); |