From 2ae10668f117ca8fe0a338b6007944d9209dc869 Mon Sep 17 00:00:00 2001 From: Colin Guthrie <colin@mageia.org> Date: Tue, 4 Nov 2014 21:21:07 +0000 Subject: [PATCH] Revert "udev hwdb: Support shipping pre-compiled database in system images" This reverts commit 33488f19793dc0a86fdee27266c5319b5b78d695. This doesn't seem to find a valid hwdb in /etc/udev/hwdb.bin --- man/udev.xml | 4 +-- man/udevadm.xml | 9 ------- src/libudev/libudev-hwdb.c | 42 +++++-------------------------- src/udev/udevadm-hwdb.c | 13 +--------- units/systemd-udev-hwdb-update.service.in | 3 --- 5 files changed, 8 insertions(+), 63 deletions(-) diff --git a/man/udev.xml b/man/udev.xml index 87c16c7..d77cbb0 100644 --- a/man/udev.xml +++ b/man/udev.xml @@ -766,9 +766,7 @@ <para>The content of all hwdb files is read by <citerefentry><refentrytitle>udevadm</refentrytitle><manvolnum>8</manvolnum></citerefentry> - and compiled to a binary database located at <filename>/etc/udev/hwdb.bin</filename>, - or alternatively <filename>/usr/lib/udev/hwdb.bin</filename> if you want ship the compiled - database in an immutable image. + and compiled to a binary database located at <filename>/etc/udev/hwdb.bin</filename>. During runtime only the binary database is used.</para> </refsect1> diff --git a/man/udevadm.xml b/man/udevadm.xml index fd17f40..6ed7273 100644 --- a/man/udevadm.xml +++ b/man/udevadm.xml @@ -499,15 +499,6 @@ </listitem> </varlistentry> <varlistentry> - <term><option>--usr</option></term> - <listitem> - <para>Put the compiled database into <filename>/usr/lib/udev/hwdb.bin</filename> instead. - Use this if you want to ship a pre-compiled database in immutable system images, or - don't use <filename>/etc/udev/hwdb.d</filename> and want to avoid large binary files in - <filename>/etc</filename>.</para> - </listitem> - </varlistentry> - <varlistentry> <term><option>-t</option></term> <term><option>--test=<replaceable>string</replaceable></option></term> <listitem> diff --git a/src/libudev/libudev-hwdb.c b/src/libudev/libudev-hwdb.c index a1cfc0b..8fb7240 100644 --- a/src/libudev/libudev-hwdb.c +++ b/src/libudev/libudev-hwdb.c @@ -256,11 +256,6 @@ static int trie_search_f(struct udev_hwdb *hwdb, const char *search) { return 0; } -static const char hwdb_bin_paths[] = - "/etc/udev/hwdb.bin\0" - UDEVLIBEXECDIR "/hwdb.bin\0"; - - /** * udev_hwdb_new: * @udev: udev library context @@ -271,7 +266,6 @@ static const char hwdb_bin_paths[] = **/ _public_ struct udev_hwdb *udev_hwdb_new(struct udev *udev) { struct udev_hwdb *hwdb; - const char *hwdb_bin_path; const char sig[] = HWDB_SIG; hwdb = new0(struct udev_hwdb, 1); @@ -281,43 +275,30 @@ _public_ struct udev_hwdb *udev_hwdb_new(struct udev *udev) { hwdb->refcount = 1; udev_list_init(udev, &hwdb->properties_list, true); - /* find hwdb.bin in hwdb_bin_paths */ - NULSTR_FOREACH(hwdb_bin_path, hwdb_bin_paths) { - hwdb->f = fopen(hwdb_bin_path, "re"); - if (hwdb->f) - break; - else if (errno == ENOENT) - continue; - else { - udev_dbg(udev, "error reading %s: %m", hwdb_bin_path); - udev_hwdb_unref(hwdb); - return NULL; - } - } - + hwdb->f = fopen("/etc/udev/hwdb.bin", "re"); if (!hwdb->f) { - udev_dbg(udev, "hwdb.bin does not exist, please run udevadm hwdb --update"); + udev_dbg(udev, "error reading /etc/udev/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) { - udev_dbg(udev, "error reading %s: %m", hwdb_bin_path); + udev_dbg(udev, "error reading /etc/udev/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) { - udev_dbg(udev, "error mapping %s: %m", hwdb_bin_path); + udev_dbg(udev, "error mapping /etc/udev/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)) { - udev_dbg(udev, "error recognizing the format of %s", hwdb_bin_path); + udev_dbg(udev, "error recognizing the format of /etc/udev/hwdb.bin"); udev_hwdb_unref(hwdb); return NULL; } @@ -371,25 +352,14 @@ _public_ struct udev_hwdb *udev_hwdb_unref(struct udev_hwdb *hwdb) { } bool udev_hwdb_validate(struct udev_hwdb *hwdb) { - bool found = false; - const char* p; struct stat st; if (!hwdb) return false; if (!hwdb->f) return false; - - /* if hwdb.bin doesn't exist anywhere, we need to update */ - NULSTR_FOREACH(p, hwdb_bin_paths) { - if (stat(p, &st) >= 0) { - found = true; - break; - } - } - if (!found) + if (stat("/etc/udev/hwdb.bin", &st) < 0) return true; - if (timespec_load(&hwdb->st.st_mtim) != timespec_load(&st.st_mtim)) return true; return false; diff --git a/src/udev/udevadm-hwdb.c b/src/udev/udevadm-hwdb.c index 3ca755e..64273fb 100644 --- a/src/udev/udevadm-hwdb.c +++ b/src/udev/udevadm-hwdb.c @@ -536,20 +536,14 @@ static int import_file(struct udev *udev, struct trie *trie, const char *filenam static void help(void) { printf("Usage: udevadm hwdb OPTIONS\n" " -u,--update update the hardware database\n" - " --usr generate in " UDEVLIBEXECDIR " instead of /etc/udev\n" " -t,--test=MODALIAS query database and print result\n" " -r,--root=PATH alternative root path in the filesystem\n" " -h,--help\n\n"); } static int adm_hwdb(struct udev *udev, int argc, char *argv[]) { - enum { - ARG_USR = 0x100, - }; - static const struct option options[] = { { "update", no_argument, NULL, 'u' }, - { "usr", no_argument, NULL, ARG_USR }, { "test", required_argument, NULL, 't' }, { "root", required_argument, NULL, 'r' }, { "help", no_argument, NULL, 'h' }, @@ -557,7 +551,6 @@ static int adm_hwdb(struct udev *udev, int argc, char *argv[]) { }; const char *test = NULL; const char *root = ""; - const char *hwdb_bin_dir = "/etc/udev"; bool update = false; struct trie *trie = NULL; int err, c; @@ -568,9 +561,6 @@ static int adm_hwdb(struct udev *udev, int argc, char *argv[]) { case 'u': update = true; break; - case ARG_USR: - hwdb_bin_dir = UDEVLIBEXECDIR; - break; case 't': test = optarg; break; @@ -644,8 +634,7 @@ static int adm_hwdb(struct udev *udev, int argc, char *argv[]) { log_debug("strings dedup'ed: %8zu bytes (%8zu)", trie->strings->dedup_len, trie->strings->dedup_count); - hwdb_bin = strjoin(root, "/", hwdb_bin_dir, "/hwdb.bin", NULL); - if (!hwdb_bin) { + if (asprintf(&hwdb_bin, "%s/etc/udev/hwdb.bin", root) < 0) { rc = EXIT_FAILURE; goto out; } diff --git a/units/systemd-udev-hwdb-update.service.in b/units/systemd-udev-hwdb-update.service.in index 5b1f75d..cdbcd83 100644 --- a/units/systemd-udev-hwdb-update.service.in +++ b/units/systemd-udev-hwdb-update.service.in @@ -13,9 +13,6 @@ Conflicts=shutdown.target After=systemd-remount-fs.service Before=sysinit.target shutdown.target systemd-update-done.service ConditionNeedsUpdate=/etc -ConditionPathExists=|!@udevlibexecdir@/hwdb.bin -ConditionPathExists=|/etc/udev/hwdb.bin -ConditionDirectoryNotEmpty=|/etc/udev/hwdb.d/ [Service] Type=oneshot -- 2.1.3