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