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 > 0x7fffffff))
return "Invalid domain number";
f->domain = x;
}
}
void
-pci_init(struct pci_access *a)
+pci_init_v34(struct pci_access *a)
{
if (!a->error)
a->error = pci_generic_error;
a->methods->init(a);
}
+STATIC_ALIAS(void pci_init(struct pci_access *a), pci_init_v34(a));
+SYMBOL_VERSION(pci_init_v34, pci_init@@LIBPCI_3.4);
+
void
pci_cleanup(struct pci_access *a)
{
void pci_mfree(void *);
char *pci_strdup(struct pci_access *a, const char *s);
+void pci_init_v34(struct pci_access *a) VERSIONED_ABI;
+
/* access.c */
struct pci_dev *pci_alloc_dev(struct pci_access *);
int pci_link_dev(struct pci_access *, struct pci_dev *);
struct pci_dev {
struct pci_dev *next; /* Next device in the chain */
- u16 domain; /* PCI domain (host bridge) */
+ u16 domain_16; /* 16-bit PCI domain (host bridge) */
u8 bus, dev, func; /* Bus inside domain, device and function */
/* These fields are set by pci_fill_info() */
char *module_alias; /* Linux kernel module alias */
char *label; /* Device name as exported by BIOS */
int numa_node; /* NUMA node */
+ int domain; /* 32-bit PCI domain (host bridge) */
/* Fields used internally: */
struct pci_access *access;
d = pci_alloc_dev(a);
if (sscanf(entry->d_name, "%x:%x:%x.%d", &dom, &bus, &dev, &func) < 4)
a->error("sysfs_scan: Couldn't parse entry name %s", entry->d_name);
+
+ /* Ensure kernel provided domain that fits in a signed integer */
+ if (dom > 0x7fffffff)
+ a->error("sysfs_scan: invalid domain:%x", dom);
+
+ /*
+ * The domain value is truncated to 16 bits and stored in the pci_dev
+ * structure's legacy 16-bit domain offset for compatibility with
+ * applications compiled with libpci pre-32 bit domains. Such
+ * applications may not work as expected if they are on a machine
+ * utilizing PCI domain numbers requiring more than 16 bits.
+ */
+ d->domain_16 = dom;
d->domain = dom;
d->bus = bus;
d->dev = dev;
else
{
for (d = a->devices; d; d = d->next)
- if (dom == d->domain && bus == d->bus && dev == d->dev && !d->phy_slot)
+ if (dom == (unsigned)d->domain && bus == d->bus && dev == d->dev && !d->phy_slot)
d->phy_slot = pci_strdup(a, entry->d_name);
}
fclose(file);
{
struct bridge *c;
for (c=b->child; c; c=c->next)
- if (c->domain == p->domain && c->secondary <= p->bus && p->bus <= c->subordinate)
+ if (c->domain == (unsigned)p->domain && c->secondary <= p->bus && p->bus <= c->subordinate)
{
insert_dev(d, c);
return;