]> mj.ucw.cz Git - pciutils.git/blobdiff - lib/sysfs.c
pciutils: Decode available DVSEC details
[pciutils.git] / lib / sysfs.c
index b826e97ccf8fbbd87695ea12f1e883e002b33780..42c88c69f7c2326eb2ada9b9deaa86c8c857c286 100644 (file)
@@ -133,7 +133,8 @@ sysfs_deref_link(struct pci_dev *d, char *link_name)
   sysfs_obj_name(d, "", path);
   strcat(path, rel_path);
 
-  return canonicalize_file_name(path);
+  // Returns a pointer to malloc'ed memory
+  return realpath(path, NULL);
 }
 
 static int
@@ -293,7 +294,7 @@ sysfs_fill_slots(struct pci_access *a)
        {
          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);
     }
@@ -315,21 +316,28 @@ sysfs_fill_info(struct pci_dev *d, int flags)
     {
       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))
-    pci_set_property(d, PCI_FILL_DT_NODE, sysfs_deref_link(d, "of_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);
 }