udev-builtin-hwdb.c revision 1c574591db5a62aa40aaac02645be1521ea85771
/***
This file is part of systemd.
Copyright 2012 Kay Sievers <kay.sievers@vrfy.org>
Copyright 2008 Alan Jenkins <alan.christopher.jenkins@googlemail.com>
under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 2.1 of the License, or
(at your option) any later version.
systemd is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with systemd; If not, see <http://www.gnu.org/licenses/>.
***/
#include <stdio.h>
#include <errno.h>
#include <string.h>
#include <inttypes.h>
#include <ctype.h>
#include <stdlib.h>
#include <fnmatch.h>
#include <getopt.h>
#include "udev.h"
#include "udev-hwdb.h"
struct linebuf {
};
}
return NULL;
}
return false;
return true;
}
{
return false;
return true;
}
}
}
struct trie_f {
struct udev_device *dev;
bool test;
FILE *f;
union {
struct trie_header_f *head;
const char *map;
};
};
static const struct trie_child_entry_f *trie_node_children(struct trie_f *trie, const struct trie_node_f *node) {
}
static const struct trie_value_entry_f *trie_node_values(struct trie_f *trie, const struct trie_node_f *node) {
return (const struct trie_value_entry_f *)base;
}
}
}
}
static const struct trie_node_f *node_lookup_f(struct trie_f *trie, const struct trie_node_f *node, uint8_t c) {
struct trie_child_entry_f *child;
struct trie_child_entry_f search;
search.c = c;
if (child)
return NULL;
}
size_t i;
const char *prefix;
for (i = 0; i < node->children_count; i++) {
}
for (i = 0; i < node->values_count; i++)
}
const struct trie_node_f *node;
size_t i = 0;
linebuf_init(&buf);
while (node) {
const struct trie_node_f *child;
size_t p = 0;
if (node->prefix_off) {
uint8_t c;
if (c == '*' || c == '?' || c == '[') {
return;
}
if (c != search[i + p])
return;
}
i += p;
}
if (child) {
}
if (child) {
}
if (child) {
}
if (search[i] == '\0') {
size_t n;
for (n = 0; n < node->values_count; n++)
return;
}
i++;
}
}
/* TODO: add sub-matches (+) against DMI data */
if (key[0] == ' ')
}
struct udev_device *d;
const char *modalias;
char str[UTIL_NAME_SIZE];
int rc = EXIT_SUCCESS;
/* search the first parent device with a modalias */
for (d = dev; d; d = udev_device_get_parent(d)) {
const char *dsubsys = udev_device_get_subsystem(d);
/* look only at devices of a specific subsystem */
continue;
if (modalias)
break;
/* the usb_device does not have modalias, compose one */
const char *v, *p;
v = udev_device_get_sysattr_value(d, "idVendor");
if (!v)
continue;
p = udev_device_get_sysattr_value(d, "idProduct");
if (!p)
continue;
if (vn <= 0)
continue;
if (pn <= 0)
continue;
break;
}
}
if (!modalias)
return EXIT_FAILURE;
return rc;
}
{}
};
for (;;) {
int option;
if (option == -1)
break;
switch (option) {
case 's':
break;
}
}
return EXIT_FAILURE;
return EXIT_SUCCESS;
}
/* called at udev startup and reload */
{
if (!trie.f)
return -errno;
if (fstat(fileno(trie.f), &st) < 0 || (size_t)st.st_size < offsetof(struct trie_header_f, strings_len) + 8) {
return -EINVAL;
}
return -EINVAL;
}
if (memcmp(trie.map, sig, sizeof(trie.head->signature)) != 0 || (size_t)st.st_size != le64toh(trie.head->file_size)) {
log_error("Please try 'udevadm hwdb --update' to re-create it.");
return EINVAL;
}
log_debug("=== trie on-disk ===\n");
return 0;
}
/* called on udev shutdown and reload request */
{
if (!trie.f)
return;
}
/* called every couple of seconds during event activity; 'true' if config has changed */
{
return true;
return true;
return false;
}
const struct udev_builtin udev_builtin_hwdb = {
.name = "hwdb",
.cmd = builtin_hwdb,
.help = "hardware database",
};