[PATCH] Support gzip-compressed pci.ids

Danny Kukawka danny.kukawka at web.de
Thu Jun 21 05:39:32 PDT 2007


On Donnerstag, 21. Juni 2007, Daniel Drake wrote:
> There is some idiocy involved with gzipping pci.ids, but pciutils
> upstream appears to be going that way.
>
> This patch adds in a fallback to read a .gz version if the plaintext
> version is not available. As zlib is used for decompression, hald now links
> against libz.

Not sure if we really need this at all. See the discussion on the list.

> I have assumed that embedded users who truly care about footprint won't
> be using pci.ids support anyway so the extra link isn't significant [...]

Have embedded user/systems a original pci.ids file? This make no sense, you 
have a small and well known number of devices in such system, you need only a 
very small and specific pci.ids file.

Comments to the patch:

> diff --git a/configure.in b/configure.in
> index bc1eb8a..0f434af 100644
> --- a/configure.in
> +++ b/configure.in
[...]
> +elif test "x$ZLIB_AVAILABLE" != "xyes"; then
> +  AC_ERROR([pci.ids support requires zlib])

This prevent finish configure if there is no zlib, also if you use an older 
pciutils package or if you have pci.ids decompressed available. Very bad, 
better check if pci.ids.gz or/and pci.ids is available and handle the 
specific situation.

> -if test "x$with_libpci" != xno ; then
> +if test "x$with_libpci" != xno -a test "x$ZLIB_AVAILABLE" != "xyes"; then
> +   AC_ERROR([libpci support requires zlib])
> +elif test "x$with_libpci" != xno ; then
>    dnl check for libpci
>    AC_CHECK_HEADERS([pci/pci.h],
>                     [AC_CHECK_LIB([pci], [pci_init], [USE_LIBPCI="yes"],

Same as above. It should also compile without compressed pci.ids!

> --- a/hald/ids.c
> +++ b/hald/ids.c
> @@ -45,6 +45,8 @@
>  #include "ids.h"
>

#ifdef HAVE_Z_LIB /* or whatever the define is*/

>  #ifdef USE_PCI_IDS
> +#include <zlib.h>
> +

endif /* HAVE_Z_LIB  */

same with pci_ids_load_gz () and related calls.

> +static dbus_bool_t
> +pci_ids_load_gz (const char *path)
> +{
> +#define ZLIB_BUFFER_STEP 0x40000 /* 256kb */

If you want this for embedded users as you wrote, why such big steps? If there 
are e.g. only 270kb needed you have to allocate additional 256kb ...



> +	/* Load /usr/share/hwdata/pci.ids or fallback on .gz version */
> +	if (!pci_ids_load_text (PCI_IDS_DIR "/pci.ids"))
#ifdef HAVE_Z_LIB /* or whatever the define is*/
> +		pci_ids_load_gz (PCI_IDS_DIR "/pci.ids.gz");
>  }
>
>  #endif /*USE_PCI_IDS*/

Danny



More information about the hal mailing list