summaryrefslogtreecommitdiff
path: root/src/udev/udevadm-hwdb.c
AgeCommit message (Collapse)AuthorFilesLines
2018-11-22coccinelle: make use of SYNTHETIC_ERRNOZbigniew Jędrzejewski-Szmek1-4/+3
Ideally, coccinelle would strip unnecessary braces too. But I do not see any option in coccinelle for this, so instead, I edited the patch text using search&replace to remove the braces. Unfortunately this is not fully automatic, in particular it didn't deal well with if-else-if-else blocks and ifdefs, so there is an increased likelikehood be some bugs in such spots. I also removed part of the patch that coccinelle generated for udev, where we returns -1 for failure. This should be fixed independently.
2018-11-06udev: setting the same log level to SYSTEMD realmYu Watanabe1-2/+0
Otherwise, many debug logs from libsystemd are dropped.
2018-09-21udevadm: show only version number for '--version' optionYu Watanabe1-1/+1
This effectively reverts 2bc54be485def3d1697a00209ff73ae21aa7f268 and relevant changes in #9920, as it is used to determine the version of udev, e.g., dracut. Fixes dracutdevs/dracut#468.
2018-09-19hwdb,udevadm: also unify hwdb_query() and hwdb_test()Yu Watanabe1-20/+1
2018-09-19hwdb: unify duplicated code and move it to hwdb-util.cYu Watanabe1-604/+7
Both 'systemd-hwdb update' and 'udevadm hwdb --update' creates hwdb database. The database created by systemd-hwdb containes additional information such that priority, line number, and source filename. The unified function 'hwdb_update()' can take a flag 'compat' which controls the format version of created database.
2018-09-19tree-wide: use typesafe_bsearch() or typesafe_bsearch_r()Yu Watanabe1-4/+2
2018-09-19tree-wide: use typesafe_qsort_r()Yu Watanabe1-9/+5
2018-09-19tree-wide: use typesafe_qsort()Yu Watanabe1-7/+4
2018-09-10udevadm-hwdb: modernize code a bitYu Watanabe1-111/+133
2018-09-10udevadm: use dispatch_verb() and drop udevadm_cmd structYu Watanabe1-6/+2
2018-09-10udev: drop unused udev structYu Watanabe1-4/+4
2018-06-20tree-wide: drop copyright headers from frequent contributorsZbigniew Jędrzejewski-Szmek1-3/+0
Fixes #9320. for p in Shapovalov Chevalier Rozhkov Sievers Mack Herrmann Schmidt Rudenberg Sahani Landden Andersen Watanabe; do git grep -e 'Copyright.*'$p -l|xargs perl -i -0pe 's|/([*][*])?[*]\s+([*#]\s+)?Copyright[^\n]*'$p'[^\n]*\s*[*]([*][*])?/\n*|\n|gms; s|\s+([*#]\s+)?Copyright[^\n]*'$p'[^\n]*\n*|\n|gms' done
2018-06-14tree-wide: beautify remaining copyright statementsLennart Poettering1-1/+1
Let's unify an beautify our remaining copyright statements, with a unicode ©. This means our copyright statements are now always formatted the same way. Yay.
2018-06-14tree-wide: drop 'This file is part of systemd' blurbLennart Poettering1-2/+0
This part of the copyright blurb stems from the GPL use recommendations: https://www.gnu.org/licenses/gpl-howto.en.html The concept appears to originate in times where version control was per file, instead of per tree, and was a way to glue the files together. Ultimately, we nowadays don't live in that world anymore, and this information is entirely useless anyway, as people are very welcome to copy these files into any projects they like, and they shouldn't have to change bits that are part of our copyright header for that. hence, let's just get rid of this old cruft, and shorten our codebase a bit.
2018-05-10udevadm: fix null dererefence on allocation errorZbigniew Jędrzejewski-Szmek1-1/+2
CID #1390936.
2018-04-23udevadm/hwdb: Return non-zero exit code on error when --strict is usedNicolas Boichat1-5/+20
- Add a new flag --strict to tell udevadm hwdb to return a non-zero code on error. - Make udevadm hwdb --update return an error when any parsing error occurs (only if strict flag is set).
2018-04-06tree-wide: drop license boilerplateZbigniew Jędrzejewski-Szmek1-13/+0
Files which are installed as-is (any .service and other unit files, .conf files, .policy files, etc), are left as is. My assumption is that SPDX identifiers are not yet that well known, so it's better to retain the extended header to avoid any doubt. I also kept any copyright lines. We can probably remove them, but it'd nice to obtain explicit acks from all involved authors before doing that.
2018-03-27Merge pull request #8576 from keszybz/oss-fuzzEvgeny Vereshchagin1-1/+3
oss-fuzz adjustments and other cleanups
2018-03-27label: rework label_fix() implementations (#8583)Lennart Poettering1-1/+1
This reworks the SELinux and SMACK label fixing calls in a number of ways: 1. The two separate boolean arguments of these functions are converted into a flags type LabelFixFlags. 2. The operations are now implemented based on O_PATH. This should resolve TTOCTTOU races between determining the label for the file system object and applying it, as it it allows to pin the object while we are operating on it. 3. When changing a label fails we'll query the label previously set, and if matches what we want to set anyway we'll suppress the error. Also, all calls to label_fix() are now (void)ified, when we ignore the return values. Fixes: #8566
2018-03-26tree-wide: add bsearch_safe and use where appropriateZbigniew Jędrzejewski-Szmek1-1/+3
Should fix #8557.
2018-03-02coccinelle: add reallocarray() coccinelle scriptLennart Poettering1-2/+2
Let's systematically make use of reallocarray() whereever we invoke realloc() with a product of two values.
2017-12-05udevadm: getopt() and help message cleanupYu Watanabe1-12/+22
This adds missing options, mainly '--version' in getopt(), removes an unused option from getopt(). Also, this adds a deprecate message in `udevadm hwdb`, and cleanups help messages. Follow-up for 65eb4378c3e1de25383d8cd606909e64c71edc80.
2017-11-19Add SPDX license identifiers to source files under the LGPLZbigniew Jędrzejewski-Szmek1-0/+1
This follows what the kernel is doing, c.f. https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=5fd54ace4721fc5ce2bb5aef6318fcf17f421460.
2017-09-13exec-util,conf-files: skip non-executable files in execute_directories()Lennart Poettering1-1/+1
Fixes: #6787
2017-08-17"Don't fear the fsync()"Alan Jenkins1-20/+22
For files which are vital to boot 1. Avoid opening any window where power loss will zero them out or worse. I know app developers all coded to the ext3 implementation, but the only formal documentation we have says we're broken if we actually rely on it. E.g. * `man mount`, search for `auto_da_alloc`. * http://www.linux-mtd.infradead.org/faq/ubifs.html#L_atomic_change * https://thunk.org/tytso/blog/2009/03/15/dont-fear-the-fsync/ 2. If we tell the kernel we're interested in writing them to disk, it will tell us if that fails. So at minimum, this means we play our part in notifying the user about errors. I refactored error-handling in `udevadm-hwdb` a little. It turns out I did exactly the same as had already been done in the `systemd-hwdb` version, i.e. commit d702dcd.
2017-04-04tree-wide: standardize on $(PACKAGE_VERSION) for the version stringZbigniew Jędrzejewski-Szmek1-1/+1
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-10-23tree-wide: drop NULL sentinel from strjoinZbigniew Jędrzejewski-Szmek1-1/+1
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-07-08udevadm: explicitly relabel /etc/udev/hwdb.bin after rename (#3686)Michal Sekletar1-1/+7
This is basically the same change as ea68351.
2016-02-10tree-wide: remove Emacs lines from all filesDaniel Mack1-2/+0
This should be handled fine now by .dir-locals.el, so need to carry that stuff in every file.
2015-12-07udev: add emacs header lineZbigniew Jędrzejewski-Szmek1-0/+2
Otherwise emacs wants to use 2-space indentation and other attrocities.
2015-11-27tree-wide: expose "p"-suffix unref calls in public APIs to make gcc cleanup easyLennart Poettering1-1/+1
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 Poettering1-0/+1
2015-10-27util-lib: move a number of fs operations into fs-util.[ch]Lennart Poettering1-0/+1
2015-10-27util-lib: move more file I/O related calls into fileio.[ch]Lennart Poettering1-0/+1
2015-10-24util-lib: split our string related calls from util.[ch] into its own file ↵Lennart Poettering1-6/+6
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-06-09Revert "hwdb: actually search /run/udev/hwdb.d"Lennart Poettering1-1/+0
2015-06-09hwdb: actually search /run/udev/hwdb.dPeter Hutterer1-0/+1
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 Andersen1-1/+0
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-01-22Assorted format fixesZbigniew Jędrzejewski-Szmek1-1/+1
Types used for pids and uids in various interfaces are unpredictable. Too bad.
2014-12-18systemd-hwdb: introduce new toolTom Gundersen1-1/+0
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.
2014-12-15udevadm: port to sd-hwdbTom Gundersen1-6/+8
2014-12-11libudev: make libudev-hwdb a wrapper around sd-hwdbTom Gundersen1-1/+1
2014-11-28udevadm hwdb: discard extra leading whitespaces in hwdbPeter Hutterer1-0/+4
Currently a property in the form of FOO=bar is stored as " FOO=bar", i.e. the property name contains a leading space. That's quite hard to spot. This patch discards all extra whitespaces but the first one which is required by libudev's hwdb_add_property. [zj: modify the check a bit] https://bugs.freedesktop.org/show_bug.cgi?id=82311
2014-11-28treewide: no need to negate errno for log_*_errno()Michal Schmidt1-2/+2
It corrrectly handles both positive and negative errno values.
2014-11-28treewide: auto-convert the simple cases to log_*_errno()Michal Schmidt1-2/+2
As a followup to 086891e5c1 "log: add an "error" parameter to all low-level logging calls and intrdouce log_error_errno() as log calls that take error numbers", use sed to convert the simple cases to use the new macros: find . -name '*.[ch]' | xargs sed -r -i -e \ 's/log_(debug|info|notice|warning|error|emergency)\("(.*)%s"(.*), strerror\(-([a-zA-Z_]+)\)\);/log_\1_errno(-\4, "\2%m"\3);/' Multi-line log_*() invocations are not covered. And we also should add log_unit_*_errno().
2014-10-28udev hwdb: Support shipping pre-compiled database in system imagesMartin Pitt1-1/+12
In some cases it is preferable to ship system images with a pre-generated binary hwdb database, to avoid having to build it at runtime, avoid shipping the source hwdb files, or avoid storing large binary files in /etc. So if hwdb.bin does not exist in /etc/udev/, fall back to looking for it in UDEVLIBEXECDIR. This keeps the possibility to add files to /etc/udev/hwdb.d/ and re-generating the database which trumps the one in /usr/lib. Add a new --usr flag to "udevadm hwdb --update" which puts the database into UDEVLIBEXECDIR. Adjust systemd-udev-hwdb-update.service to not generate the file in /etc if we already have it in /usr.
2014-09-18udevadm: hwdb - check return value of fseeko()Tom Gundersen1-2/+12
Fonud by Coverity. Fixes CID #996255.
2014-02-19udev: make sure we always return a valid error code in trie_store()Lennart Poettering1-6/+5
2014-02-13everywhere: make use of new0() and macro() macros, and stop using perror()Lennart Poettering1-4/+4
2014-02-05Update some message formatsZbigniew Jędrzejewski-Szmek1-9/+9
Use PID_FMT/USEC_FMT/... in more places. Also update logind error messages to print the full path to a file that failed. This should make debugging easier for people who do not know off the top of their head where logind stores it state.