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