Hello all, right now, udev stores its binary hwdb cache in /etc/udev/, which is ugly IMHO. This is neither user-editable nor configuration of any kind. It's just a cache file, and does not need to appear in backup, VCSes of /etc and the like.
Can we move it to the libdir instead? Attached patch does that. Thanks for considering! Martin -- Martin Pitt | http://www.piware.de Ubuntu Developer (www.ubuntu.com) | Debian Developer (www.debian.org)
From 0d5c4f5d492d13c99ac1a8619ccb0dc3fe438d16 Mon Sep 17 00:00:00 2001 From: Martin Pitt <martinp...@gnome.org> Date: Fri, 14 Jun 2013 12:21:38 +0200 Subject: [PATCH] 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. --- Makefile.am | 2 +- man/udevadm.xml | 6 +++--- src/libudev/libudev-hwdb.c | 10 +++++----- src/udev/udevadm-hwdb.c | 2 +- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/Makefile.am b/Makefile.am index a74c19d..a4db4a9 100644 --- a/Makefile.am +++ b/Makefile.am @@ -2179,7 +2179,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 += \ diff --git a/man/udevadm.xml b/man/udevadm.xml index d0b257d..75a73c2 100644 --- a/man/udevadm.xml +++ b/man/udevadm.xml @@ -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> diff --git a/src/libudev/libudev-hwdb.c b/src/libudev/libudev-hwdb.c index a56ad75..b8de7ed 100644 --- a/src/libudev/libudev-hwdb.c +++ b/src/libudev/libudev-hwdb.c @@ -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; } diff --git a/src/udev/udevadm-hwdb.c b/src/udev/udevadm-hwdb.c index 3e849aa..65f08f0 100644 --- a/src/udev/udevadm-hwdb.c +++ b/src/udev/udevadm-hwdb.c @@ -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; } -- 1.8.3.1
signature.asc
Description: Digital signature
_______________________________________________ systemd-devel mailing list systemd-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/systemd-devel