/***
This file is part of systemd.
Copyright 2012 Kay Sievers <kay@vrfy.org>
Copyright 2008 Alan Jenkins <alan.christopher.jenkins@googlemail.com>
Copyright 2014 Tom Gundersen <teg@jklm.no>
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 <errno.h>
#include <fnmatch.h>
#include <inttypes.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "sd-hwdb.h"
#include "alloc-util.h"
#include "fd-util.h"
#include "hashmap.h"
#include "hwdb-internal.h"
#include "hwdb-util.h"
#include "refcnt.h"
#include "string-util.h"
struct sd_hwdb {
int refcount;
FILE *f;
union {
const char *map;
};
char *modalias;
bool properties_modified;
};
struct linebuf {
};
}
return NULL;
}
return false;
return true;
}
return false;
return true;
}
}
}
static const struct trie_child_entry_f *trie_node_children(sd_hwdb *hwdb, const struct trie_node_f *node) {
}
static const struct trie_value_entry_f *trie_node_values(sd_hwdb *hwdb, const struct trie_node_f *node) {
return (const struct trie_value_entry_f *)base;
}
}
}
}
static const struct trie_node_f *node_lookup_f(sd_hwdb *hwdb, const struct trie_node_f *node, uint8_t c) {
search.c = c;
if (child)
return NULL;
}
int r;
/*
* Silently ignore all properties which do not start with a
* space; future extensions might use additional prefixes.
*/
if (key[0] != ' ')
return 0;
key++;
if (r < 0)
return r;
if (r < 0)
return r;
hwdb->properties_modified = true;
return 0;
}
size_t i;
const char *prefix;
int err;
for (i = 0; i < node->children_count; i++) {
if (err < 0)
return err;
}
if (err < 0)
return err;
}
return 0;
}
size_t i = 0;
int err;
linebuf_init(&buf);
while (node) {
size_t p = 0;
if (node->prefix_off) {
uint8_t c;
if (c == '*' || c == '?' || c == '[')
if (c != search[i + p])
return 0;
}
i += p;
}
if (child) {
if (err < 0)
return err;
}
if (child) {
if (err < 0)
return err;
}
if (child) {
if (err < 0)
return err;
}
if (search[i] == '\0') {
size_t n;
if (err < 0)
return err;
}
return 0;
}
i++;
}
return 0;
}
static const char hwdb_bin_paths[] =
#ifdef HAVE_SPLIT_USR
#endif
UDEVLIBEXECDIR "/hwdb.bin\0";
const char *hwdb_bin_path;
if (!hwdb)
return -ENOMEM;
/* find hwdb.bin in hwdb_bin_paths */
if (hwdb->f)
break;
continue;
else
}
if (!hwdb->f) {
log_debug("hwdb.bin does not exist, please run udevadm hwdb --update");
return -ENOENT;
}
return -EINVAL;
}
log_debug("=== trie on-disk ===");
return 0;
}
return hwdb;
}
safe_fclose(hwdb->f);
}
return NULL;
}
bool found = false;
const char* p;
if (!hwdb)
return false;
if (!hwdb->f)
return false;
/* if hwdb.bin doesn't exist anywhere, we need to update */
found = true;
break;
}
}
if (!found)
return true;
return true;
return false;
}
int r;
return 0;
if (!mod)
return -ENOMEM;
hwdb->properties_modified = true;
if (r < 0)
return r;
return 0;
}
_public_ int sd_hwdb_get(sd_hwdb *hwdb, const char *modalias, const char *key, const char **_value) {
const char *value;
int r;
if (r < 0)
return r;
if (!value)
return -ENOENT;
return 0;
}
int r;
if (r < 0)
return r;
hwdb->properties_modified = false;
return 0;
}
const void *k;
void *v;
if (hwdb->properties_modified)
return -EAGAIN;
if (!k)
return 0;
*key = k;
*value = v;
return 1;
}