summaryrefslogtreecommitdiff
path: root/src/shared/udev-util.h
Commit message (Collapse)AuthorAgeFilesLines
* 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-161-0/+3
|
* udev: rename UTIL_LINE_SIZE -> UDEV_LINE_SIZE and friendsYu Watanabe2020-12-161-0/+4
| | | | This also moves them to udev-util.h
* udev: move util_resolve_subsys_kernel() to udev-util.cYu Watanabe2020-12-161-0/+1
|
* udev: move util_replace_chars() to udev-util.cYu Watanabe2020-12-161-0/+1
|
* udev: move util_replace_whitespace() to udev-util.cYu Watanabe2020-12-161-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-041-1/+1
|
* util: introduce device_for_action()Yu Watanabe2019-03-121-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-231-9/+0
|
* udev-util: drop unused function udev_device_new_from_stat_rdev()Yu Watanabe2018-08-231-2/+0
|
* libudev: move cleanup functions from udev-util.h to libudev-private.hYu Watanabe2018-08-231-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.
* Add SPDX license identifiers to source files under the LGPLZbigniew Jędrzejewski-Szmek2017-11-191-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.
* Rip out setting of the log level from udev_new and put it in a new functionZbigniew Jędrzejewski-Szmek2017-05-071-0/+2
| | | | | | | | This function is internal to systemd code, so external users of libudev will not see those log messages. I think this is better. If we want to allow that, the function could be put in libudev and exported. v2: check that the string is more than one char before stripping quotes
* tree-wide: remove Emacs lines from all filesDaniel Mack2016-02-101-2/+0
| | | | | This should be handled fine now by .dir-locals.el, so need to carry that stuff in every file.
* udevd: make udev_ctrl_connection globalTom Gundersen2015-05-121-0/+4
| | | | | This allows us to simplify the ctrl_msg handler. Eventually all this global state should move to a Manager object or so.
* udev: builtin-hwdb - port to sd-hwdbTom Gundersen2014-12-151-2/+0
|
* shared: udev-util - add hwdb cleanup macroTom Gundersen2014-12-021-0/+2
|
* udev: remove seqnum API and all assumptions about seqnumsKay Sievers2014-04-131-2/+0
| | | | | | | | | | | | The way the kernel namespaces have been implemented breaks assumptions udev made regarding uevent sequence numbers. Creating devices in a namespace "steals" uevents and its sequence numbers from the host. It confuses the "udevadmin settle" logic, which might block until util a timeout is reached, even when no uevent is pending. Remove any assumptions about sequence numbers and deprecate libudev's API exposing these numbers; none of that can reliably be used anymore when namespaces are involved.
* udevadm: modernizationZbigniew Jędrzejewski-Szmek2013-12-181-0/+7
|
* util: allow trailing semicolons on define_trivial_cleanup_func linesLennart Poettering2013-10-141-5/+5
| | | | | | | | | | | | | | | | Emacs C indenting really gets confused by these lines if they carry no trailing semicolon, hence let's make this nicer for good old emacs. The other macros which define functions already do this too, so let's copy the scheme here. Also, let's use an uppercase name for the macro. So far our rough rule was that macros that are totally not function-like (like this ones, which define a function) are uppercase. (Well, admittedly it is a rough rule only, for example function and variable decorators are all lower-case SINCE THE CONSTANT YELLING IN THE SOURCES WOULD SUCK, and also they at least got underscore prefixes.) Also, the macros that define functions that we already have are all uppercase, so let's do the same here...
* Introduce udev object cleanup functionsZbigniew Jędrzejewski-Szmek2013-10-131-0/+37