summaryrefslogtreecommitdiff
path: root/src/hwdb
AgeCommit message (Collapse)Author
2017-04-04tree-wide: standardize on $(PACKAGE_VERSION) for the version stringZbigniew Jędrzejewski-Szmek
We defined both $(VERSION) and $(PACKAGE_VERSION) with the same contents. $(PACKAGE_VERSION) is slightly more descriptive, so settle on that, and drop the other define.
2016-12-11hwdb: emit warning when matches are specified at the very end of fileZbigniew Jędrzejewski-Szmek
This is also an error, but it wasn't caught. [/tmp/tmp.YWeKax4fMI/etc/udev/hwdb.d/10-bad.hwdb:26] Property expected, ignoring record with no properties
2016-12-01hwdb: fix detection of assignments with no keyZbigniew Jędrzejewski-Szmek
The code was trying to detect an empty key, but property lines always start with a space, so the condition was wrong. Now: [/tmp/tmp.YWeKax4fMI/etc/udev/hwdb.d/10-bad.hwdb:14] Empty key in " =NO_NAME", ignoring [/tmp/tmp.YWeKax4fMI/etc/udev/hwdb.d/10-bad.hwdb:15] Empty value in " NO_VALUE=", ignoring
2016-12-01hwdb: improve and test syntax error messagesZbigniew Jędrzejewski-Szmek
Since syntax error are non-fatal, downgrade them to warnings. Use log_syntax to have uniform formatting including the line number. State machine states like DATA and MATCH are internal, user-facing messages should use the names from hwdb(7): match, property, record. Also change "key/value" to "key-value", since there's no alternative here, both parts must be present. [/tmp/tmp.KFwEhm74n4/etc/udev/hwdb.d/10-bad.hwdb:2] Property expected, ignoring record with no properties [/tmp/tmp.KFwEhm74n4/etc/udev/hwdb.d/10-bad.hwdb:5] Property expected, ignoring record with no properties [/tmp/tmp.KFwEhm74n4/etc/udev/hwdb.d/10-bad.hwdb:9] Property expected, ignoring record with no properties [/tmp/tmp.KFwEhm74n4/etc/udev/hwdb.d/10-bad.hwdb:11] Key/value pair expected but got " NO_VALUE", ignoring [/tmp/tmp.KFwEhm74n4/etc/udev/hwdb.d/10-bad.hwdb:18] Property or empty line expected, got "BAD:7:match at wrong place", ignoring record [/tmp/tmp.KFwEhm74n4/etc/udev/hwdb.d/10-bad.hwdb:22] Property or empty line expected, got "BAD:8:match at wrong place", ignoring record [/tmp/tmp.KFwEhm74n4/etc/udev/hwdb.d/10-bad.hwdb:23] Match expected but got indented property " Z=z", ignoring line squash! hwdb: improve syntax error messages
2016-11-30hwdb: rename err to r and use _cleanup_ in two more placesZbigniew Jędrzejewski-Szmek
2016-11-30hwdb: simplify error handling in trie_storeZbigniew Jędrzejewski-Szmek
fclose() can also set errno, so the attempts to protect errno that the code made were not successful. Simplify things by immediately saving errno to r.
2016-11-30hwdb, sd-hwdb: rework priority comparison when loading propertiesZbigniew Jędrzejewski-Szmek
We cannot compare filenames directly, because paths are not sortable lexicographically, e.g. /etc/udev is "later" (has higher priority) than /usr/lib/udev. The on-disk format is changed to have a separate field for "file priority", which is stored when writing the binary file, and then loaded and used in comparisons. For data in the previous format (as generated by systemd 232), this information is not available, and we use a trick where the offset into the string table is used as a proxy for priority. Most of the time strings are stored in the order in which the files were processed. This is not entirely reliable, but is good enough to properly order /usr/lib and /etc/, which are the two most common cases. This hack is included because it allows proper parsing of files until the binary hwdb is regenerated. Instead of adding a new field, I reduced the size of line_number from 64 to 32 bits, and added a 16 bit priority field, and 16 bits of padding. Adding a new field of 16 bytes would significantly screw up alignment and increase file size, and line number realistically don't need more than ~20 bits. Fixes #4750.
2016-11-30hwdb: remove path comparison which broke overriding of propertiesZbigniew Jędrzejewski-Szmek
Partial fix for #4750. We would compare strings like "/usr/lib/udev/hwdb.d/something.hwdb" and "/etc/udev/hwdb.db/something.hwdb" and conclude that the first has higher priority. Since we process files in order (higher priority later), no comparison is necessary when loading. This partially undoes 3a04b789c6f17dff2000a3cdbeaaf86baa604524 (not in spirit, but in the implementation).
2016-11-03Merge pull request #4510 from keszybz/tree-wide-cleanupsLennart Poettering
Tree wide cleanups
2016-10-26hwdb: fix error check of wrong variable (#4499)Thomas H. P. Andersen
We updated 'fn' but checked 'v' instead. From 698c5a17 Spotted with PVS
2016-10-23tree-wide: drop NULL sentinel from strjoinZbigniew Jędrzejewski-Szmek
This makes strjoin and strjoina more similar and avoids the useless final argument. spatch -I . -I ./src -I ./src/basic -I ./src/basic -I ./src/shared -I ./src/shared -I ./src/network -I ./src/locale -I ./src/login -I ./src/journal -I ./src/journal -I ./src/timedate -I ./src/timesync -I ./src/nspawn -I ./src/resolve -I ./src/resolve -I ./src/systemd -I ./src/core -I ./src/core -I ./src/libudev -I ./src/udev -I ./src/udev/net -I ./src/udev -I ./src/libsystemd/sd-bus -I ./src/libsystemd/sd-event -I ./src/libsystemd/sd-login -I ./src/libsystemd/sd-netlink -I ./src/libsystemd/sd-network -I ./src/libsystemd/sd-hwdb -I ./src/libsystemd/sd-device -I ./src/libsystemd/sd-id128 -I ./src/libsystemd-network --sp-file coccinelle/strjoin.cocci --in-place $(git ls-files src/*.c) git grep -e '\bstrjoin\b.*NULL' -l|xargs sed -i -r 's/strjoin\((.*), NULL\)/strjoin(\1)/' This might have missed a few cases (spatch has a really hard time dealing with _cleanup_ macros), but that's no big issue, they can always be fixed later.
2016-09-21hwdb: store file-name and file-number with propertiesDavid Herrmann
Extend the hwdb to store the source file-name and file-number for each property. We simply extend the stored value struct with the new information. It is fully backwards compatible and old readers will continue to work. The libudev/sd-hwdb reader is updated in a followup. Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
2016-06-07hwdb: selinuxify a bit (#3460)Evgeny Vereshchagin
-bash-4.3# rm /etc/udev/hwdb.bin -bash-4.3# systemd-hwdb update -bash-4.3# ls -Z /etc/udev/hwdb.bin system_u:object_r:systemd_hwdb_etc_t:s0 /etc/udev/hwdb.bin Fixes: #3458
2015-11-27tree-wide: expose "p"-suffix unref calls in public APIs to make gcc cleanup easyLennart Poettering
GLIB has recently started to officially support the gcc cleanup attribute in its public API, hence let's do the same for our APIs. With this patch we'll define an xyz_unrefp() call for each public xyz_unref() call, to make it easy to use inside a __attribute__((cleanup())) expression. Then, all code is ported over to make use of this. The new calls are also documented in the man pages, with examples how to use them (well, I only added docs where the _unref() call itself already had docs, and the examples, only cover sd_bus_unrefp() and sd_event_unrefp()). This also renames sd_lldp_free() to sd_lldp_unref(), since that's how we tend to call our destructors these days. Note that this defines no public macro that wraps gcc's attribute and makes it easier to use. While I think it's our duty in the library to make our stuff easy to use, I figure it's not our duty to make gcc's own features easy to use on its own. Most likely, client code which wants to make use of this should define its own: #define _cleanup_(function) __attribute__((cleanup(function))) Or similar, to make the gcc feature easier to use. Making this logic public has the benefit that we can remove three header files whose only purpose was to define these functions internally. See #2008.
2015-10-27util-lib: split out allocation calls into alloc-util.[ch]Lennart Poettering
2015-10-27util-lib: move a number of fs operations into fs-util.[ch]Lennart Poettering
2015-10-27util-lib: move more file I/O related calls into fileio.[ch]Lennart Poettering
2015-10-25util-lib: split out fd-related operations into fd-util.[ch]Lennart Poettering
There are more than enough to deserve their own .c file, hence move them over.
2015-10-24util-lib: split our string related calls from util.[ch] into its own file ↵Lennart Poettering
string-util.[ch] There are more than enough calls doing string manipulations to deserve its own files, hence do something about it. This patch also sorts the #include blocks of all files that needed to be updated, according to the sorting suggestions from CODING_STYLE. Since pretty much every file needs our string manipulation functions this effectively means that most files have sorted #include blocks now. Also touches a few unrelated include files.
2015-09-29util: introduce common version() implementation and use it everywhereLennart Poettering
This also allows us to drop build.h from a ton of files, hence do so. Since we touched the #includes of those files, let's order them properly according to CODING_STYLE.
2015-06-09Revert "hwdb: actually search /run/udev/hwdb.d"Lennart Poettering
2015-06-09hwdb: actually search /run/udev/hwdb.dPeter Hutterer
The documentation claims hwdb entries may be placed in the volatile /run/udev/hwdb.d directory but nothing actually looked at it.
2015-02-23remove unused includesThomas Hindoe Paaboel Andersen
This patch removes includes that are not used. The removals were found with include-what-you-use which checks if any of the symbols from a header is in use.
2015-02-12hwdb: adjust --help text to be more like other --help textsLennart Poettering
Fix capitalization, indentation, make sure we support --version, and similar.
2015-01-22Assorted format fixesZbigniew Jędrzejewski-Szmek
Types used for pids and uids in various interfaces are unpredictable. Too bad.
2014-12-19systemd-hwdb: port to new verbs helperTom Gundersen
2014-12-18systemd-hwdb: introduce new toolTom Gundersen
This pulls out the hwdb managment from udevadm into an independent tool. The old code is left in place for backwards compatibility, and easy of testing, but all documentation is dropped to encourage use of the new tool instead.