[systemd-devel] Using the hwdb in external programs

Kay Sievers kay at vrfy.org
Wed Aug 14 03:41:28 PDT 2013


On Wed, Aug 14, 2013 at 12:03 PM, Richard Hughes <hughsient at gmail.com> wrote:
> I'm aware of at least half a dozen programs and daemons that read and
> parse /usr/share/hwdata/pnp.ids to convert PNP_IDS to actual vendor
> names. Although this file will be in hot cache at login, it does seem
> a waste of a lot of duplicated parsing and hashing code. I'm aware the
> PNP_ID database is used in the hwdb, and hashed in an efficient way.
> I'm wondering if external applications (like gnome-settings-daemon)
> could use the data there.

Sure, that's what the hwdb is there for. Parsing the potentially huge
old sequential files over and over is not how things should work
today.

Just use libudev to lookup the key/value pairs for a given key/string:
  http://www.freedesktop.org/software/systemd/libudev/libudev-udev-hwdb.html

An example is here:
  http://cgit.freedesktop.org/systemd/systemd/tree/src/test/test-libudev.c#n432

That's what's currently in the db:
  http://cgit.freedesktop.org/systemd/systemd/tree/hwdb

Kay


More information about the systemd-devel mailing list