udev-builtin-hwdb.c revision 33c770b174ec77d7da6e7e830e0bca9f74d54367
c51d84dc09476d9c06b8aac726220bf3c7d62e8dKay Sievers This file is part of systemd.
c51d84dc09476d9c06b8aac726220bf3c7d62e8dKay Sievers Copyright 2012 Kay Sievers <kay@vrfy.org>
c51d84dc09476d9c06b8aac726220bf3c7d62e8dKay Sievers systemd is free software; you can redistribute it and/or modify it
c51d84dc09476d9c06b8aac726220bf3c7d62e8dKay Sievers under the terms of the GNU Lesser General Public License as published by
c51d84dc09476d9c06b8aac726220bf3c7d62e8dKay Sievers the Free Software Foundation; either version 2.1 of the License, or
c51d84dc09476d9c06b8aac726220bf3c7d62e8dKay Sievers (at your option) any later version.
c51d84dc09476d9c06b8aac726220bf3c7d62e8dKay Sievers systemd is distributed in the hope that it will be useful, but
c51d84dc09476d9c06b8aac726220bf3c7d62e8dKay Sievers WITHOUT ANY WARRANTY; without even the implied warranty of
c51d84dc09476d9c06b8aac726220bf3c7d62e8dKay Sievers MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
c51d84dc09476d9c06b8aac726220bf3c7d62e8dKay Sievers Lesser General Public License for more details.
c51d84dc09476d9c06b8aac726220bf3c7d62e8dKay Sievers You should have received a copy of the GNU Lesser General Public License
c51d84dc09476d9c06b8aac726220bf3c7d62e8dKay Sievers along with systemd; If not, see <http://www.gnu.org/licenses/>.
3ffd4af22052963e7a29431721ee204e634bea75Lennart Poetteringint udev_builtin_hwdb_lookup(struct udev_device *dev, const char *modalias, bool test) {
c51d84dc09476d9c06b8aac726220bf3c7d62e8dKay Sievers udev_list_entry_foreach(entry, udev_hwdb_get_properties_list_entry(hwdb, modalias, 0)) {
c51d84dc09476d9c06b8aac726220bf3c7d62e8dKay Sieversstatic const char *modalias_usb(struct udev_device *dev, char *s, size_t size) {
c51d84dc09476d9c06b8aac726220bf3c7d62e8dKay Sievers const char *v, *p;
c51d84dc09476d9c06b8aac726220bf3c7d62e8dKay Sievers v = udev_device_get_sysattr_value(dev, "idVendor");
c51d84dc09476d9c06b8aac726220bf3c7d62e8dKay Sievers p = udev_device_get_sysattr_value(dev, "idProduct");
c51d84dc09476d9c06b8aac726220bf3c7d62e8dKay Sieversstatic int udev_builtin_hwdb_search(struct udev_device *dev, const char *subsystem, bool test) {
c51d84dc09476d9c06b8aac726220bf3c7d62e8dKay Sievers for (d = dev; d; d = udev_device_get_parent(d)) {
c51d84dc09476d9c06b8aac726220bf3c7d62e8dKay Sievers /* look only at devices of a specific subsystem */
39883f622f392d8579f4428fc5a789a102efbb10Lennart Poettering /* the usb_device does not have a modalias, compose one */
c51d84dc09476d9c06b8aac726220bf3c7d62e8dKay Sievers modalias = udev_device_get_property_value(d, "MODALIAS");
c51d84dc09476d9c06b8aac726220bf3c7d62e8dKay Sievers n = udev_builtin_hwdb_lookup(dev, modalias, test);
c51d84dc09476d9c06b8aac726220bf3c7d62e8dKay Sieversstatic int builtin_hwdb(struct udev_device *dev, int argc, char *argv[], bool test) {
c51d84dc09476d9c06b8aac726220bf3c7d62e8dKay Sievers option = getopt_long(argc, argv, "s", options, NULL);
c51d84dc09476d9c06b8aac726220bf3c7d62e8dKay Sievers if (udev_builtin_hwdb_search(dev, subsystem, test) < 0)
c51d84dc09476d9c06b8aac726220bf3c7d62e8dKay Sievers/* called at udev startup and reload */
c51d84dc09476d9c06b8aac726220bf3c7d62e8dKay Sievers/* called on udev shutdown and reload request */
c51d84dc09476d9c06b8aac726220bf3c7d62e8dKay Sievers/* called every couple of seconds during event activity; 'true' if config has changed */
c51d84dc09476d9c06b8aac726220bf3c7d62e8dKay Sieversstatic bool builtin_hwdb_validate(struct udev *udev)