X-Git-Url: http://mj.ucw.cz/gitweb/?a=blobdiff_plain;ds=sidebyside;f=lib%2Ffilter.c;h=0b7ce6e6e9bb6df8500683caf2001d2e0f07b3c1;hb=caeac5c38e34c5282a0646a697acaa1fea22ddb7;hp=37e15cc5fe5115276543af1710aea80d576ba8f4;hpb=a832f6f13a5068c00c121bd9a01fec28587ba351;p=pciutils.git diff --git a/lib/filter.c b/lib/filter.c index 37e15cc..0b7ce6e 100644 --- a/lib/filter.c +++ b/lib/filter.c @@ -1,5 +1,5 @@ /* - * Linux PCI Library -- Device Filtering + * The PCI Library -- Device Filtering * * Copyright (c) 1998--2003 Martin Mares * @@ -14,27 +14,42 @@ void pci_filter_init(struct pci_access *a UNUSED, struct pci_filter *f) { - f->bus = f->slot = f->func = -1; + f->domain = f->bus = f->slot = f->func = -1; f->vendor = f->device = -1; } -/* Slot filter syntax: [[bus]:][slot][.[func]] */ +/* Slot filter syntax: [[[domain]:][bus]:][slot][.[func]] */ char * pci_filter_parse_slot(struct pci_filter *f, char *str) { - char *colon = strchr(str, ':'); + char *colon = strrchr(str, ':'); char *dot = strchr((colon ? colon + 1 : str), '.'); char *mid = str; - char *e; + char *e, *bus, *colon2; if (colon) { *colon++ = 0; mid = colon; - if (str[0] && strcmp(str, "*")) + colon2 = strchr(str, ':'); + if (colon2) { - long int x = strtol(str, &e, 16); + *colon2++ = 0; + bus = colon2; + if (str[0] && strcmp(str, "*")) + { + long int x = strtol(str, &e, 16); + if ((e && *e) || (x < 0 || x > 0xffff)) + return "Invalid domain number"; + f->domain = x; + } + } + else + bus = str; + if (bus[0] && strcmp(bus, "*")) + { + long int x = strtol(bus, &e, 16); if ((e && *e) || (x < 0 || x > 0xff)) return "Invalid bus number"; f->bus = x; @@ -75,14 +90,14 @@ pci_filter_parse_id(struct pci_filter *f, char *str) if (str[0] && strcmp(str, "*")) { long int x = strtol(str, &e, 16); - if ((e && *e) || (x < 0 || x >= 0xffff)) + if ((e && *e) || (x < 0 || x > 0xffff)) return "Invalid vendor ID"; f->vendor = x; } if (s[0] && strcmp(s, "*")) { long int x = strtol(s, &e, 16); - if ((e && *e) || (x < 0 || x >= 0xffff)) + if ((e && *e) || (x < 0 || x > 0xffff)) return "Invalid device ID"; f->device = x; } @@ -92,13 +107,14 @@ pci_filter_parse_id(struct pci_filter *f, char *str) int pci_filter_match(struct pci_filter *f, struct pci_dev *d) { - if ((f->bus >= 0 && f->bus != d->bus) || + if ((f->domain >= 0 && f->domain != d->domain) || + (f->bus >= 0 && f->bus != d->bus) || (f->slot >= 0 && f->slot != d->dev) || (f->func >= 0 && f->func != d->func)) return 0; if (f->device >= 0 || f->vendor >= 0) { - pci_fill_info(d, PCI_FILL_IDENT); + pci_fill_info_v31(d, PCI_FILL_IDENT); if ((f->device >= 0 && f->device != d->device_id) || (f->vendor >= 0 && f->vendor != d->vendor_id)) return 0;