summaryrefslogtreecommitdiffstats
path: root/src/udev/udevadm-test.c (follow)
Commit message (Collapse)AuthorAgeFilesLines
* udev: warn when result of string substitution is truncatedYu Watanabe2021-12-251-1/+4
|
* udevadm: introduce parse_device_action() helper functionYu Watanabe2021-08-171-14/+6
|
* udevadm: introduce find_device_with_action() helper functionYu Watanabe2021-08-171-13/+8
|
* Drop the text argument from assert_not_reached()Zbigniew Jędrzejewski-Szmek2021-08-031-1/+1
| | | | | | | | | | | | | | | | | In general we almost never hit those asserts in production code, so users see them very rarely, if ever. But either way, we just need something that users can pass to the developers. We have quite a few of those asserts, and some have fairly nice messages, but many are like "WTF?" or "???" or "unexpected something". The error that is printed includes the file location, and function name. In almost all functions there's at most one assert, so the function name alone is enough to identify the failure for a developer. So we don't get much extra from the message, and we might just as well drop them. Dropping them makes our code a tiny bit smaller, and most importantly, improves development experience by making it easy to insert such an assert in the code without thinking how to phrase the argument.
* udev: do not store inotify fd in a global variableYu Watanabe2021-04-301-1/+1
| | | | | | | When manager_exit() or manager_free() is called, the global variable in udev-watch.c is not set '-1'. Of course, that is safe, as the event source for the inotify fd is unref()ed in manager_exit() and manager_free(). But let's not store fd globally.
* udevadm: after validating action, use our internal string instead of optargLennart Poettering2021-02-181-3/+2
| | | | | | | | This doesn't really change anything, but feels nicer, since it abstracts away what device_action_from_string()/device_action_to_string() do internally, and always uses a normalized action string (yes, there's no ambiguity, but it's nice to stay abstract, maybe one day there is ambiguity around this)
* sd-device: add sd_device_get_action() + sd_device_get_seqnum() + ↵Lennart Poettering2021-02-181-1/+1
| | | | | | | | | | | | | | | | sd_device_new_from_stat_rdev() To make sd-device properly usable for all programs we need to provide an API for the "action" field of an event, it's one of the most relevant ones, and it was so far missing. This also adds sd_device_get_seqnum(), which isn't that interesting, except for generating pretty debug output, which we use it ourselves for. This also makes device_new_from_stat_rdev() public, as it is truly useful, as we can see in our own uses of it, and I think is fairly generic to show up in the public APIs.
* tree-wide: Drop custom formatting for print() help messagesDaan De Meyer2021-01-311-2/+2
| | | | | | | | | | | | I think this formatting was originally used because it simplified adding new options to the help messages. However, these days, most tools their help message end with "\nSee the %s for details.\n" so the final line almost never has to be edited which eliminates the benefit of the custom formatting used for printf() help messages. Let's make things more consistent and use the same formatting for printf() help messages that we use everywhere else. Prompted by https://github.com/systemd/systemd/pull/18355#discussion_r567241580
* udev: drop unnecessary libudev-util.h inclusionsYu Watanabe2020-12-151-1/+0
|
* udev: rename UTIL_LINE_SIZE -> UDEV_LINE_SIZE and friendsYu Watanabe2020-12-151-2/+2
| | | | This also moves them to udev-util.h
* udev: introduce new OPTIONS="log_level=" udev ruleYu Watanabe2020-12-101-1/+1
|
* license: GPL-2.0+ -> GPL-2.0-or-laterYu Watanabe2020-11-091-1/+1
|
* tree-wide: define iterator inside of the macroZbigniew Jędrzejewski-Szmek2020-09-081-2/+1
|
* udev: use path_startswith() instead of startswith() in two more casesLennart Poettering2020-08-271-1/+2
|
* udev: split rules object creation and loadingZbigniew Jędrzejewski-Szmek2020-06-231-1/+1
| | | | | The only functional change is to downgrade the log line to avoid double logging.
* udev: udev_event_apply_format() always make buf NUL terminatedYu Watanabe2020-06-181-1/+1
| | | | | The return value of udev_event_apply_format() is always ignored. So, the destination buffer must be always NUL terminated.
* udev: make signal that we use to kill workers on timeout configurableMichal Sekletár2020-06-051-1/+1
|
* udevadm: support special value 'help' for --action optionYu Watanabe2019-06-281-1/+6
|
* udev: modernize udev-rules.cYu Watanabe2019-06-021-1/+1
| | | | | | | | | | | This does the following: - rename enum udev_builtin_cmd -> UdevBuiltinCmd - rename struct udev_builtin -> UdevBuiltin - move type definitions to udev-rules.h - move prototypes of functions defined in udev-rules.c to udev-rules.h - drop to use strbuf - propagate critical errors in applying rules, - drop limitation for number of tokens per line.
* udevadm-test: check action string earlierYu Watanabe2019-03-111-1/+9
| | | | | The string will be checked later in device_new_from_synthetic_event(), but let's check it earlier in parse_argv().
* udev: run programs in the specified orderYu Watanabe2019-03-051-1/+1
| | | | | | | | | | | | This fixes bugs introduced by 29448498c724da7ade1b5efb20d7472c1b128d2c and d838e14515c82b05a07f2bf393cce057b45b2b53. Previously, RUN and SECLABEL keys are stored in udev_list with its unique flag is false. If the flag is false, then udev_list is just a linked list and new entries are always added in the last. So, we should use OrderedHashmap instead of Hashmap. Fixes #11368.
* udevadm: add two more assertionsYu Watanabe2018-12-211-2/+2
| | | | | | Suggested by Coverity. Closes CID#1397033 and CID#1395708.
* udev: use typedef for struct udev_eventZbigniew Jędrzejewski-Szmek2018-12-171-1/+1
|
* udev: use typedef for struct udev_rulesZbigniew Jędrzejewski-Szmek2018-12-171-1/+1
|
* udev: make udev_rules_new() return a proper error codeZbigniew Jędrzejewski-Szmek2018-12-141-4/+3
|
* udev: rename udev_rules_unref() to udev_rules_free()Yu Watanabe2018-11-221-1/+1
| | | | As udev_rules do not have a reference counter.
* coccinelle: make use of SYNTHETIC_ERRNOZbigniew Jędrzejewski-Szmek2018-11-221-8/+6
| | | | | | | | | | | 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.
* libudev-list: move libudev-list related definitions to libudev-list-internal.hYu Watanabe2018-11-201-0/+2
| | | | | This also rename libudev-private.h to libudev-util.h, and cleanups several unnecessary headers from udev.h and libudev-util.h
* udev: do not pass timeout_warn_usec around, calculate it on demandZbigniew Jędrzejewski-Szmek2018-11-131-4/+1
| | | | | | | | | | | It was always set to one third of timeout_usec, so let's simplify things by calculating it using a helper function right before it is used. Before 9d9264ba39f797d20100c8acfda3df895ab5aaa2, udevd.c would avoid setting timeout_warn_usec to 0, using 1 instead. This wasn't necessary, because when timeout_warn_usec is finally used in spawn_wait(), it is ignored if timeout_usec is 0 or timeout_warn_usec is 0. So there was no need to handle this case specially.
* udev: introduce enum ResolveNameTiming for --resolve-names argumentYu Watanabe2018-11-121-10/+5
|
* udevadm-test: replace udev_device by sd_deviceYu Watanabe2018-11-071-11/+13
|
* udev-event: make udev_event_new() take sd_device instead of udev_deviceYu Watanabe2018-11-071-1/+2
|
* udev-event: make udev_event_new() take sd_netlink and take a reference of thatYu Watanabe2018-11-071-1/+1
|
* udev-event: make udev_event_new() take exec_delayYu Watanabe2018-11-071-1/+1
|
* udev-event: rename udev_event_unref() to udev_event_free()Yu Watanabe2018-10-271-1/+1
| | | | As struct udev_event does not have a reference counter.
* udev: use Hashmap for storing PROGRAM or BUILTINYu Watanabe2018-10-161-2/+5
|
* udevadm: assert_se() around sigprocmask()Lennart Poettering2018-10-131-1/+1
| | | | CID #1395708
* udev-builtin: move definitions related to builtin commands to udev-builtin.hYu Watanabe2018-10-101-0/+1
|
* udevadm: show only version number for '--version' optionYu Watanabe2018-09-211-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.
* udevadm-test: modernize codeYu Watanabe2018-09-101-47/+52
|
* udevadm: use dispatch_verb() and drop udevadm_cmd structYu Watanabe2018-09-101-8/+3
|
* udev: drop unused udev structYu Watanabe2018-09-101-5/+5
|
* udev: move udev cleanup functions from udev-util.h to udev.hYu Watanabe2018-08-221-1/+0
|
* tree-wide: drop empty lines in commentsYu Watanabe2018-07-231-1/+0
|
* tree-wide: drop copyright headers from frequent contributorsZbigniew Jędrzejewski-Szmek2018-06-201-1/+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
* Drop more license boilerplateZbigniew Jędrzejewski-Szmek2018-06-141-12/+0
| | | | | | | | $ git grep -e 'This program is free software' -l |grep -v LICENSE | \ xargs perl -i -0pe 's/ \* This program.*?for more details.\s*\*\n( \* You should have.*licenses.>.\n)?//gms' For some reason they were missed previously. All those files seem to have proper SDPX tags.
* tree-wide: use proper unicode © instead of (C) where we canLennart Poettering2018-06-141-2/+2
| | | | | | Let's use a proper unicode copyright symbol where we can, it's prettier. This important patch is very important.
* tree-wide: drop redundant _cleanup_ macros (#8810)Lennart Poettering2018-04-251-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | This drops a good number of type-specific _cleanup_ macros, and patches all users to just use the generic ones. In most recent code we abstained from defining type-specific macros, and this basically removes all those added already, with the exception of the really low-level ones. Having explicit macros for this is not too useful, as the expression without the extra macro is generally just 2ch wider. We should generally emphesize generic code, unless there are really good reasons for specific code, hence let's follow this in this case too. Note that _cleanup_free_ and similar really low-level, libc'ish, Linux API'ish macros continue to be defined, only the really high-level OO ones are dropped. From now on this should really be the rule: for really low-level stuff, such as memory allocation, fd handling and so one, go ahead and define explicit per-type macros, but for high-level, specific program code, just use the generic _cleanup_() macro directly, in order to keep things simple and as readable as possible for the uninitiated. Note that before this patch some of the APIs (notable libudev ones) were already used with the high-level macros at some places and with the generic _cleanup_ macro at others. With this patch we hence unify on the latter.
* udevadm: getopt() and help message cleanupYu Watanabe2017-12-051-6/+11
| | | | | | | | | 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.
* Add SPDX license identifiers to source files under the GPLZbigniew Jędrzejewski-Szmek2017-11-191-0/+1
|