b24a048
diff -up pciutils-3.0.0/lib/names-parse.c.dird pciutils-3.0.0/lib/names-parse.c
b24a048
--- pciutils-3.0.0/lib/names-parse.c.dird	2008-04-10 21:15:47.000000000 +0200
6962467
+++ pciutils-3.0.0/lib/names-parse.c	2008-09-01 15:17:23.000000000 +0200
b24a048
@@ -6,10 +6,13 @@
b24a048
  *	Can be freely distributed and used under the terms of the GNU GPL.
b24a048
  */
117a700
 
b24a048
+#define _GNU_SOURCE
b24a048
 #include <stdio.h>
b24a048
 #include <stdlib.h>
117a700
 #include <string.h>
117a700
 #include <errno.h>
117a700
+#include <dirent.h>
117a700
+#include <libgen.h>
117a700
 
117a700
 #include "internal.h"
b24a048
 #include "names.h"
b24a048
@@ -82,7 +85,7 @@ static inline int id_white_p(int c)
117a700
 }
117a700
 
b24a048
 
117a700
-static const char *id_parse_list(struct pci_access *a, pci_file f, int *lino)
117a700
+static const char *id_parse_list(struct pci_access *a, pci_file f, int *lino, int flags)
117a700
 {
117a700
   char line[MAX_LINE];
117a700
   char *p;
b24a048
@@ -207,7 +210,7 @@ static const char *id_parse_list(struct 
117a700
 	p++;
117a700
       if (!*p)
117a700
 	return parse_error;
b24a048
-      if (pci_id_insert(a, cat, id1, id2, id3, id4, p, SRC_LOCAL))
b24a048
+      if (pci_id_insert(a, cat, id1, id2, id3, id4, p, SRC_LOCAL) && flags)
117a700
 	return "Duplicate entry";
117a700
     }
117a700
   return NULL;
b24a048
@@ -223,13 +226,14 @@ pci_load_name_list(struct pci_access *a)
117a700
   pci_free_name_list(a);
b24a048
   a->id_load_failed = 1;
117a700
   if (!(f = pci_open(a)))
117a700
-    return 0;
117a700
-  err = id_parse_list(a, f, &lino);
51c9b68
+    return pci_new_load_name_list(a);
117a700
+  err = id_parse_list(a, f, &lino, 0);
117a700
   PCI_ERROR(f, err);
117a700
   pci_close(f);
117a700
   if (err)
117a700
     a->error("%s at %s, line %d\n", err, a->id_file_name, lino);
b24a048
   a->id_load_failed = 0;
117a700
+  pci_new_load_name_list(a);
117a700
   return 1;
117a700
 }
117a700
 
b24a048
@@ -249,3 +253,48 @@ pci_set_name_list_path(struct pci_access
117a700
   a->id_file_name = name;
117a700
   a->free_id_name = to_be_freed;
117a700
 }
117a700
+int pci_new_load_name_list(struct pci_access *a)
117a700
+{
117a700
+  pci_file f;
117a700
+  int lino, tempsize;
117a700
+  const char *err;
117a700
+  char *temp;
d1645e3
+  char new_id_path[PATH_MAX+1] = {0,};
117a700
+  DIR *pci_ids_dir;
117a700
+  struct dirent *dp;
117a700
+  
117a700
+  strncpy(new_id_path, a->id_file_name, PATH_MAX);
117a700
+  new_id_path[PATH_MAX] = 0;
117a700
+  strncat(new_id_path, ".d/", PATH_MAX - strnlen(new_id_path, PATH_MAX));
117a700
+  /* printf("new_id_path is %s\n", new_id_path); */
117a700
+  pci_ids_dir = opendir(new_id_path); 
91b1c68
+  if (pci_ids_dir == NULL)
91b1c68
+    return 0;
91b1c68
+
117a700
+  do
117a700
+    {
117a700
+     if ((dp = readdir(pci_ids_dir)) != NULL)
117a700
+       {
117a700
+          if (! strcmp(dp->d_name, "..") || ! strcmp(dp->d_name, "."))
117a700
+            continue;
117a700
+          if (strstr(dp->d_name, ".ids")) 
117a700
+            {
117a700
+             tempsize = strnlen(new_id_path, PATH_MAX) + dp->d_reclen + 1;
117a700
+             temp = malloc(tempsize);      /* This malloced memory is freed in the function pci_set_name_list_path() */ 
117a700
+             memset(temp, 0, tempsize);
b24a048
+             strncpy(temp, new_id_path, (strnlen(new_id_path, PATH_MAX))+1);
117a700
+             strncat(temp, dp->d_name, PATH_MAX - strnlen(temp, PATH_MAX));
117a700
+             /* printf("Found file %s, processing it\n", temp); */
117a700
+             pci_set_name_list_path(a, temp, 1);
117a700
+             if (!(f = pci_open(a)))
117a700
+               continue;
117a700
+             err = id_parse_list(a, f, &lino, 0);
117a700
+             PCI_ERROR(f, err);
117a700
+             pci_close(f);
117a700
+             if (err)
117a700
+               a->error("%s at %s, line %d\n", err, a->id_file_name, lino);
117a700
+            }
117a700
+       }
117a700
+    }while (dp != NULL);
117a700
+  return 1;
117a700
+}   
b24a048
diff -up pciutils-3.0.0/lib/pci.h.dird pciutils-3.0.0/lib/pci.h
b24a048
--- pciutils-3.0.0/lib/pci.h.dird	2008-04-10 21:23:05.000000000 +0200
6962467
+++ pciutils-3.0.0/lib/pci.h	2008-09-01 15:17:23.000000000 +0200
b24a048
@@ -194,6 +194,7 @@ int pci_load_name_list(struct pci_access
b24a048
 void pci_free_name_list(struct pci_access *a) PCI_ABI;	/* Called automatically by pci_cleanup() */
b24a048
 void pci_set_name_list_path(struct pci_access *a, char *name, int to_be_freed) PCI_ABI;
b24a048
 void pci_id_cache_flush(struct pci_access *a) PCI_ABI;
b24a048
+int pci_new_load_name_list(struct pci_access *a);
b24a048
 
b24a048
 enum pci_lookup_mode {
b24a048
   PCI_LOOKUP_VENDOR = 1,		/* Vendor name (args: vendorID) */