Commit 9561630d authored by Martin Pitt's avatar Martin Pitt Committed by Michael Biebl

udev hwdb: Store binary database in libdir, not in /etc

Storing huge binary files in /etc/ is ugly, as this is neither user-editable
nor configuration of any kind. This is just a cache file, and does not need
backing up.

Move it to udevlibexecdir instead.
parent d5051f76
......@@ -2088,7 +2088,7 @@ INSTALL_DATA_HOOKS += \
hwdb-update-hook
hwdb-remove-hook:
-test -n "$(DESTDIR)" || rm -f /etc/udev/hwdb.bin
-test -n "$(DESTDIR)" || rm -f $(udevlibexecdir)/hwdb.bin
# ------------------------------------------------------------------------------
TESTS += \
......
......@@ -424,13 +424,13 @@
</refsect2>
<refsect2><title>udevadm hwdb <optional>options</optional></title>
<para>Maintain the hardware database index in <filename>/etc/udev/hwdb.bin</filename>.</para>
<para>Maintain the hardware database index in <filename>/lib/udev/hwdb.bin</filename>.</para>
<variablelist>
<varlistentry>
<term><option>--update</option></term>
<listitem>
<para>Compile the hardware database information located in /usr/lib/udev/hwdb.d/,
/etc/udev/hwdb.d/ and store it in <filename>/etc/udev/hwdb.bin</filename>. This should be done after
<para>Compile the hardware database information located in /lib/udev/hwdb.d/,
/etc/udev/hwdb.d/ and store it in <filename>/lib/udev/hwdb.bin</filename>. This should be done after
any update to the source files; it will not be called automatically. The running
udev daemon will detect a new database on its own and does not need to be
notified about it.</para>
......
......@@ -271,30 +271,30 @@ _public_ struct udev_hwdb *udev_hwdb_new(struct udev *udev) {
hwdb->refcount = 1;
udev_list_init(udev, &hwdb->properties_list, true);
hwdb->f = fopen("/etc/udev/hwdb.bin", "re");
hwdb->f = fopen(UDEVLIBEXECDIR "/hwdb.bin", "re");
if (!hwdb->f) {
log_debug("error reading /etc/udev/hwdb.bin: %m");
log_debug("error reading " UDEVLIBEXECDIR "/hwdb.bin: %m");
udev_hwdb_unref(hwdb);
return NULL;
}
if (fstat(fileno(hwdb->f), &hwdb->st) < 0 ||
(size_t)hwdb->st.st_size < offsetof(struct trie_header_f, strings_len) + 8) {
log_debug("error reading /etc/udev/hwdb.bin: %m");
log_debug("error reading " UDEVLIBEXECDIR "/hwdb.bin: %m");
udev_hwdb_unref(hwdb);
return NULL;
}
hwdb->map = mmap(0, hwdb->st.st_size, PROT_READ, MAP_SHARED, fileno(hwdb->f), 0);
if (hwdb->map == MAP_FAILED) {
log_debug("error mapping /etc/udev/hwdb.bin: %m");
log_debug("error mapping " UDEVLIBEXECDIR "/hwdb.bin: %m");
udev_hwdb_unref(hwdb);
return NULL;
}
if (memcmp(hwdb->map, sig, sizeof(hwdb->head->signature)) != 0 ||
(size_t)hwdb->st.st_size != le64toh(hwdb->head->file_size)) {
log_debug("error recognizing the format of /etc/udev/hwdb.bin");
log_debug("error recognizing the format of " UDEVLIBEXECDIR "/hwdb.bin");
udev_hwdb_unref(hwdb);
return NULL;
}
......
......@@ -569,7 +569,7 @@ static int adm_hwdb(struct udev *udev, int argc, char *argv[]) {
log_debug("strings dedup'ed: %8zu bytes (%8zu)\n",
trie->strings->dedup_len, trie->strings->dedup_count);
if (asprintf(&hwdb_bin, "%s/etc/udev/hwdb.bin", root) < 0) {
if (asprintf(&hwdb_bin, "%s/" UDEVLIBEXECDIR "/hwdb.bin", root) < 0) {
rc = EXIT_FAILURE;
goto out;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment