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