summaryrefslogtreecommitdiffstats
path: root/src/shared/udev-util.h (follow)
Commit message (Collapse)AuthorAgeFilesLines
* udev-util: rename device_is_processing() -> device_is_processed()Yu Watanabe2024-04-041-1/+1
| | | | And make it also check the existence of the udev database.
* udev-util: introduce device_is_processing() helper functionYu Watanabe2024-02-111-0/+1
|
* udev-util: introduce reset_cached_udev_availability()Yu Watanabe2024-01-191-0/+1
|
* udev: factor out config parser call into functionDavid Tardon2024-01-111-0/+2
| | | | | | ... which is then called from both places. This makes sure that the configuration is parsed by udevd and other tools in exactly the same way.
* udev-util: drop unused functionDavid Tardon2024-01-111-1/+0
|
* udev-util: add wrapper for sd_device_get_property_value()David Tardon2023-11-131-0/+7
| | | | ... that allows to pass additional properties to fall back to.
* udev-util: add generic device_get_{vendor,model}_string() helpersLennart Poettering2023-11-131-0/+3
| | | | | We chck the same props in various places, add a single implementation of a call to inquire this.
* udev: move declaration of ResolveNameTiming to udev-rules.cYu Watanabe2023-07-311-15/+0
| | | | | | It is only used by udevd and udevadm, not necessary in src/shared. This also moves UDEV_NAME_SIZE and friends.
* udev: move udev_parse_config_full() to udevd.cYu Watanabe2023-07-311-10/+2
| | | | | | Then, rename it to manager_parse_udev_config(). No functional change, just refactoring.
* udev: move several functions from udev-util.c to relevant udevd source filesYu Watanabe2023-07-311-5/+0
| | | | | The functions are only used by udevd (and relevant tests), hence it is not necessary to be in src/shared.
* udev: move DEVICE_TRACE() to udev-trace.hYu Watanabe2023-07-311-32/+0
| | | | It is only used by udevd, and not necessary in src/shared.
* udev-util: drop udev_queue_init() from sharedYu Watanabe2023-07-311-1/+0
| | | | It is only used in libudev, let's move it.
* battery-util: split out code that checks AC power state into its own .c/.h pairLennart Poettering2023-06-051-2/+0
| | | | | | | | No code change, just some splitting out of the relevant code from udev-util.[ch]. This makes sense on its own, but is also prepartion to move the code that checks for low battery state into battery-util.[ch], too.
* udev-util: make device_wait_for_initialization() take relative timeoutYu Watanabe2022-08-311-2/+2
| | | | Also make the timer event source floating.
* udev: make newer event also blocked by DEVPATH_OLDYu Watanabe2022-05-041-0/+2
| | | | | | | | | | | | | | | | | | Previously, a device has DEVPATH_OLD is blocked by a previous event whose devpath is equivalent to the DEVPATH_OLD. This extends the condtion. 1. an event has DEVPATH_OLD is blocked by a previous event whose devpath is a parent of, child of, or equivalent to the DEVPATH_OLD. 2. an event is blocked by a previous event whose DEVPATH_OLD is a parent of, child of, or equivalent to the devpath of the new event. I am not sure such check is really necessary. But, the cost of the check is expected to be extremely small, as device renaming does not occur so frequently. Hence, it should not introduce any significant performance regression.
* tree-wide: add a space after if, switch, for, and whileYu Watanabe2022-04-011-1/+1
|
* udev-util: introduce udev_available() helper functionYu Watanabe2022-02-171-0/+2
|
* util: move on_ac_power() from util.c -> udev-util.cYu Watanabe2022-01-061-0/+2
|
* udev-util: introduce udev_replace_ifname()Yu Watanabe2021-06-231-0/+1
|
* udev: add basic set of user-space defined tracepoints (USDT)Michal Sekletár2021-06-151-0/+32
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Debugging udev issues especially during the early boot is fairly difficult. Currently, you need to enable (at least) debug logging and start monitoring uevents, try to reproduce the issue and then analyze and correlate two (usually) huge log files. This is not ideal. This patch aims to provide much more focused debugging tool, tracepoints. More often then not we tend to have at least the basic idea about the issue we are trying to debug further, e.g. we know it is storage related. Hence all of the debug data generated for network devices is useless, adds clutter to the log files and generally slows things down. Using this set of tracepoints you can start asking very specific questions related to event processing for given device or subsystem. Tracepoints can be used with various tracing tools but I will provide examples using bpftrace. Another important aspect to consider is that using tracepoints you can debug production systems. There is no need to install test packages with added logging, no debuginfo packages, etc... Example usage (you might be asking such questions during the debug session), Q: How can I list all tracepoints? A: bpftrace -l 'usdt:/usr/lib/systemd/systemd-udevd:udev:*' Q: What are the arguments for each tracepoint? A: Look at the code and search for use of DEVICE_TRACE_POINT macro. Q: How many times we have executed external binary? A: bpftrace -e 'usdt:/usr/lib/systemd/systemd-udevd:udev:spawn_exec { @cnt = count(); }' Q: What binaries where executed while handling events for "dm-0" device? A bpftrace -e 'usdt:/usr/lib/systemd/systemd-udevd:udev:spawn_exec / str(arg1) == "dm-0"/ { @cmds[str(arg4)] = count(); }' Thanks to Thomas Weißschuh <thomas@t-8ch.de> for reviewing this patch and contributions that allowed us to drop the dependency on dtrace tool and made the resulting code much more concise.
* sd-device: add sd_device_get_action() + sd_device_get_seqnum() + ↵Lennart Poettering2021-02-181-2/+2
| | | | | | | | | | | | | | | | 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: use -EINVAL for enum invalid valuesZbigniew Jędrzejewski-Szmek2021-02-101-1/+1
| | | | | | | | | As suggested in https://github.com/systemd/systemd/pull/11484#issuecomment-775288617. This does not touch anything exposed in src/systemd. Changing the defines there would be a compatibility break. Note that tests are broken after this commit. They will be fixed in the next one.
* udev: introduce udev_queue_is_empty() and udev_queue_init()Yu Watanabe2020-12-151-0/+3
|
* udev: rename UTIL_LINE_SIZE -> UDEV_LINE_SIZE and friendsYu Watanabe2020-12-151-0/+4
| | | | This also moves them to udev-util.h
* udev: move util_resolve_subsys_kernel() to udev-util.cYu Watanabe2020-12-151-0/+1
|
* udev: move util_replace_chars() to udev-util.cYu Watanabe2020-12-151-0/+1
|
* udev: move util_replace_whitespace() to udev-util.cYu Watanabe2020-12-151-0/+1
|
* udev: introduce log_device_uevent() helper functionYu Watanabe2020-12-101-0/+2
| | | | And this drops duplicated check for seqnum and device action.
* license: LGPL-2.1+ -> LGPL-2.1-or-laterYu Watanabe2020-11-091-1/+1
|
* Merge pull request #17399 from afq984/udev-escaped-stringYu Watanabe2020-10-301-0/+2
|\ | | | | Allow escaped string in udev rules
| * udev: escaped string syntax e"..." in rule filesYu, Li-Yu2020-10-291-0/+2
| | | | | | | | | | | | | | * Existing valid rule files written with KEY="value" are not affected * Now, KEY=e"value\n" becomes valid. Where `\n` is a newline character * Escape sequences supported by src/basic/escape.h:cunescape() is supported
* | udev-util: use absolute rather than relative timeout when waiting for devicesLennart Poettering2020-10-221-2/+2
|/ | | | This makes it easier to accurately wait for a overall deadline.
* udev-util: add device_wait_for_devlinkLuca Boccassi2020-08-141-0/+1
| | | | | Allows to wait for an event by matching on the devlink that gets created.
* udev: make signal that we use to kill workers on timeout configurableMichal Sekletár2020-06-051-2/+3
|
* util: make device_wait_for_initialization() optionally takes timeout valueYu Watanabe2019-06-031-1/+1
|
* util: introduce device_for_action()Yu Watanabe2019-03-111-0/+2
| | | | It will be used in later commits.
* util: introduce device_is_renaming()Yu Watanabe2019-03-051-0/+1
| | | | It will be used in the later commit.
* rfkill: move wait_for_initialized() to shared/Zbigniew Jędrzejewski-Szmek2018-12-171-0/+4
| | | | | | | | | | | | | | | | | | The function interface is the same, except that the output pointer may be NULL. The implementation is slightly simplified by taking advantage of changes in ancestor commit 'sd-device: attempt to read db again if it wasn't found', by not creating a new sd_device object before re-checking the is_initialized status. v2: - In v1, the old object was always used and the device received back from the sd_device_monitor_start callback was ignored. I *think* the result will be equivalent in both cases, because by the time we the callback gets called, the db entry in the filesystem will also exist, and any subsequent access to properties of the object would trigger a read of the database from disk. But I'm not certain, and anyway, using the device object received in the callback seems cleaner.
* udev: also allow resolve_names= to be specified in udev.confZbigniew Jędrzejewski-Szmek2018-11-131-2/+3
|
* udev: move ResolveNameTiming definition and parsers to udev-util.hZbigniew Jędrzejewski-Szmek2018-11-131-0/+11
| | | | | Follow-up for c4d44cba4d9bd9d92c86e06f21d5936cca1b8c16. No functional change, but the parser is moved to libsystemd-shared.so.
* udevd: allow more parameters to be set through udev.confZbigniew Jędrzejewski-Szmek2018-11-131-1/+10
| | | | | | | | Rebooting to set change the kernel command line to set some udev parameters is inconvenient. Let's allow setting more stuff in the config file. Also drop quotes from around "info" in udev.conf. We need to accept them for compatibility, but there is no reason to use them.
* udev: move udev cleanup functions from udev-util.h to udev.hYu Watanabe2018-08-221-9/+0
|
* udev-util: drop unused function udev_device_new_from_stat_rdev()Yu Watanabe2018-08-221-2/+0
|
* libudev: move cleanup functions from udev-util.h to libudev-private.hYu Watanabe2018-08-221-4/+0
|
* Drop my copyright headersZbigniew Jędrzejewski-Szmek2018-06-141-4/+0
| | | | | | | perl -i -0pe 's/\s*Copyright © .... Zbigniew Jędrzejewski.*?\n/\n/gms' man/*xml git grep -e 'Copyright.*Jędrzejewski' -l | xargs perl -i -0pe 's/(#\n)?# +Copyright © [0-9, -]+ Zbigniew Jędrzejewski.*?\n//gms' git grep -e 'Copyright.*Jędrzejewski' -l | xargs perl -i -0pe 's/\s*\/\*\*\*\s+Copyright © [0-9, -]+ Zbigniew Jędrzejewski[^\n]*?\s*\*\*\*\/\s*/\n\n/gms' git grep -e 'Copyright.*Jędrzejewski' -l | xargs perl -i -0pe 's/\s+Copyright © [0-9, -]+ Zbigniew Jędrzejewski[^\n]*//gms'
* tree-wide: beautify remaining copyright statementsLennart Poettering2018-06-141-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.
* tree-wide: drop 'This file is part of systemd' blurbLennart Poettering2018-06-141-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.
* udev: add helper udev_device_new_from_stat_rdev()Lennart Poettering2018-06-071-0/+2
| | | | | | This is a simple wrapper around udev_device_new_from_devnum(), and uses the data from a struct stat's .st_rdev field to derive the udev_device object.
* tree-wide: drop redundant _cleanup_ macros (#8810)Lennart Poettering2018-04-251-11/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* tree-wide: drop license boilerplateZbigniew Jędrzejewski-Szmek2018-04-061-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.