return 1;
}
+static char *
+sysfs_deref_link(struct pci_dev *d, char *link_name)
+{
+ char path[2*OBJNAMELEN], rel_path[OBJNAMELEN];
+
+ sysfs_obj_name(d, link_name, path);
+ memset(rel_path, 0, sizeof(rel_path));
+
+ if (readlink(path, rel_path, sizeof(rel_path)) < 0)
+ return NULL;
+
+ sysfs_obj_name(d, "", path);
+ strcat(path, rel_path);
+
+ // Returns a pointer to malloc'ed memory
+ return realpath(path, NULL);
+}
+
static int
sysfs_get_value(struct pci_dev *d, char *object, int mandatory)
{
{
for (d = a->devices; d; d = d->next)
if (dom == (unsigned)d->domain && bus == d->bus && dev == d->dev && !d->phy_slot)
- d->phy_slot = pci_strdup(a, entry->d_name);
+ d->phy_slot = pci_set_property(d, PCI_FILL_PHYS_SLOT, entry->d_name);
}
fclose(file);
}
{
char buf[OBJBUFSIZE];
if (sysfs_get_string(d, "modalias", buf, 0))
- d->module_alias = pci_strdup(d->access, buf);
+ d->module_alias = pci_set_property(d, PCI_FILL_MODULE_ALIAS, buf);
}
if ((flags & PCI_FILL_LABEL) && !(d->known_fields & PCI_FILL_LABEL))
{
char buf[OBJBUFSIZE];
if (sysfs_get_string(d, "label", buf, 0))
- d->label = pci_strdup(d->access, buf);
+ d->label = pci_set_property(d, PCI_FILL_LABEL, buf);
}
if ((flags & PCI_FILL_NUMA_NODE) && !(d->known_fields & PCI_FILL_NUMA_NODE))
d->numa_node = sysfs_get_value(d, "numa_node", 0);
+ if ((flags & PCI_FILL_DT_NODE) && !(d->known_fields & PCI_FILL_DT_NODE))
+ {
+ char *node = sysfs_deref_link(d, "of_node");
+ if (node)
+ {
+ pci_set_property(d, PCI_FILL_DT_NODE, node);
+ free(node);
+ }
+ }
+
return pci_generic_fill_info(d, flags);
}