lkml.org 
[lkml]   [2004]   [Jan]   [14]   [last100]   RSS Feed
Views: [more markup]  [less markup]  [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
DateThu, 15 Jan 2004 14:28:39 +1100
FromKieran Morrissey <>
Subject[PATCH] 2.6.1: Update PCI Name database, fix gen-devlist.c for long device names.
Hi all and sundry..

Although /proc/pci and by extension the name database is allegedly legacy 
and therefore deprecated, some (including myself) still use it for things 
such as phpSysInfo, and the still-widespread usage of it is obvious in the 
regularity of slight patches to pci.ids. So, this is an all-inclusive patch 
to bring things up to date:

* Updates pci.ids with a snapshot from http://pciids.sourceforge.net/ as at 
14 Jan 04.
* Fixes gen-devlist.c to truncate long device names rather than reject the 
whole database
   (previously the latest databases had some devices that were too long and 
caused a kernel with the latest db to fail to compile)

I've included the (minor) changes to gen-devlist.c in this email if anyone 
cares to discuss them, but since the pci database changes aren't really 
that worthy of discussion on the list and the patch is 83kb, THE COMPLETE 
PATCH has been posted on the web:

http://digital.mgpenguin.net/linux/patch-2.6.1.pci-db/patch.2.6.1.pci-db.diff

or http://digital.mgpenguin.net/linux/ for bzipped versions if you're that 
way inclined..

Cheers,

	Kieran Morrissey


diff -urN -X dontdiff a/drivers/pci/gen-devlist.c b/drivers/pci/gen-devlist.c
--- a/drivers/pci/gen-devlist.c	2003-12-18 13:58:49.000000000 +1100
+++ b/drivers/pci/gen-devlist.c	2004-01-15 13:30:54.929783941 +1100
@@ -10,9 +10,10 @@
  #define MAX_NAME_SIZE 79

  static void
-pq(FILE *f, const char *c)
+pq(FILE *f, const char *c, int len)
  {
-	while (*c) {
+	int i = 1;
+	while (*c && i != len) {
  		if (*c == '"')
  			fprintf(f, "\\\"");
  		else {
@@ -23,6 +24,7 @@
  			}
  		}
  		c++;
+		i++;
  	}
  }

@@ -72,13 +74,13 @@
  						if (bra && bra > c && bra[-1] == ' ')
  							bra[-1] = 0;
  						if (vendor_len + strlen(c) + 1 > MAX_NAME_SIZE) {
-							fprintf(stderr, "Line %d: Device name too long\n", lino);
+							fprintf(stderr, "Line %d: Device name too long. Name truncated.\n", 
lino);
  							fprintf(stderr, "%s\n", c);
-							return 1;
+							/*return 1;*/
  						}
  					}
  					fprintf(devf, "\tDEVICE(%s,%s,\"", vend, line+1);
-					pq(devf, c);
+					pq(devf, c, MAX_NAME_SIZE - vendor_len - 1);
  					fputs("\")\n", devf);
  				} else goto err;
  				break;
@@ -107,7 +109,7 @@
  				return 1;
  			}
  			fprintf(devf, "VENDOR(%s,\"", vend);
-			pq(devf, c);
+			pq(devf, c, 0);
  			fputs("\")\n", devf);
  			mode = 1;
  		} else {
\
 
 \ /
  Last update: 2005-03-22 13:00    [W:0.069 / U:0.160 seconds]
©2003-2008 Jasper Spaans