summaryrefslogtreecommitdiff
path: root/src/systemd/sd-device.h
Commit message (Collapse)AuthorAgeFilesLines
* sd-device: introduce sd_device_get_child_first() and _next()Yu Watanabe2022-09-231-0/+2
| | | | | | | These functions provide a high-level interface for enumerating child devices. Suggested at https://github.com/systemd/systemd/pull/24731#discussion_r973987065.
* sd-device-monitor: introduce sd_device_monitor_{set,get}_description()Yu Watanabe2022-08-121-0/+2
|
* sd-device: introduce sd_device_new_child()Yu Watanabe2022-08-051-0/+2
|
* sd-device: shorten code a bitYu Watanabe2022-07-111-2/+2
|
* Use https for gnu.orgMichael Biebl2022-06-281-1/+1
|
* meson: Build header tests with -pedanticJan Janssen2022-05-301-2/+2
| | | | | | | | | | | | By using __extension__, we can silence pedantic errors we cannot or do not want to fix. This in particular silences: - enum values being outside of int range - variadic macros - long long being C99 - type of bit-field ‘type’ is a GCC extension - use of C99 bool in public header functions
* sd-device-enumerator: introduce sd_device_enumerator_add_nomatch_sysname()Yu Watanabe2022-04-271-0/+1
|
* sd-device: introduce sd_device_open()Yu Watanabe2022-04-011-0/+1
| | | | | | | | | | | | We usually open() device node obtained by sd_device_get_devname(). However, the device node corresponds to the sd-device object may be already removed, and another device node with the same path may be created, hence an unexpected device may be opened. The sd_device_open() opens device node, and checks the devnum and diskseq of opened devnum, to avoid the above possibility. Prompted by https://github.com/systemd/systemd/issues/22906#issuecomment-1082736443.
* sd-device: introduce sd_device_new_from_devname()Yu Watanabe2022-04-011-0/+2
| | | | and sd_device_new_from_path() which takes devname or syspath.
* udev/sd: add support for DISKSEQLuca Boccassi2021-07-281-0/+1
| | | | | | | DISKSEQ is a monotonic per-use unique sequence number, incremented on each block device create/attach. For example, the same loop device will have different diskseq each time an object is attached to it. Add sd/udev helpers to parse/expose it.
* sd-device: introduce sd_device_new_from_ifname/ifindex()Yu Watanabe2021-06-121-0/+2
|
* sd-device: add API for triggering synthetic uevents with UUIDLennart Poettering2021-05-261-0/+3
| | | | | | | | | | | | | | | | | | | | Since kernel 4.13 the kerne allows passing a UUID to generated uevents. Optionally do so via a new sd_device_trigger_with_uuid() call, and add sd_device_get_trigger_uuid() as helper to retrieve the UUID from a uevent we receive. This is useful for tracking uevents through the udev system, and waiting for specific triggers. (Note that the 4.13 patch allows passing arbitrary meta-info into the uevent as well. This does not add an API for that, because I am not convinced it makes sense — as it conflicts with our general rule that events are "stateless" if you so will — and it complicates the interface quite a bit). This replaces #13881 in a way, which added a similar infra, but which stalled, and whose synchronous settling APIs are somewhat problematic and probably not material to merge.
* sd-device: add API to query from when a udev database entry isLennart Poettering2021-04-201-0/+1
| | | | | | | | | We already store a CLOCK_MONOTONIC timestamp for each device appearance, let' make this queriable. This is useful to determine whether a udev device database entry is from a current appearance of the device or a previous one, by comparing it with appropriately taken timestamps.
* sd-device-monitor: introduce sd_device_monitor_filter_add_match_parent()Yu Watanabe2021-04-021-0/+1
|
* sd-device-monitor: introduce sd_device_monitor_filter_add_match_sysattr()Yu Watanabe2021-04-021-0/+1
|
* sd-device: introduce tiny wrapper sd_device_trigger()Yu Watanabe2021-02-211-0/+1
|
* sd-device: add sd_device_get_action() + sd_device_get_seqnum() + ↵Lennart Poettering2021-02-181-0/+19
| | | | | | | | | | | | | | | | 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.
* license: LGPL-2.1+ -> LGPL-2.1-or-laterYu Watanabe2020-11-091-1/+1
|
* sd-device: introduce sd_device_set_sysattr_valuef()Yu Watanabe2020-09-111-0/+1
|
* udev: make tags "sticky"Lennart Poettering2020-09-011-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This tries to address the "bind"/"unbind" uevent kernel API breakage, by changing the semantics of device tags. Previously, tags would be applied on uevents (and the database entries they result in) only depending on the immediate context. This means that if one uevent causes the tag to be set and the next to be unset, this would immediately effect what apps would see and the database entries would contain each time. This is problematic however, as tags are a filtering concept, and if tags vanish then clients won't hence notice when a device stops being relevant to them since not only the tags disappear but immediately also the uevents for it are filtered including the one necessary for the app to notice that the device lost its tag and hence relevance. With this change tags become "sticky". If a tag is applied is once applied to a device it will stay in place forever, until the device is removed. Tags can never be removed again. This means that an app watching a specific set of devices by filtering for a tag is guaranteed to not only see the events where the tag is set but also all follow-up events where the tags might be removed again. This change of behaviour is unfortunate, but is required due to the kernel introducing new "bind" and "unbind" uevents that generally have the effect that tags and properties disappear and apps hence don't notice when a device looses relevance to it. "bind"/"unbind" events were introduced in kernel 4.12, and are now used in more and more subsystems. The introduction broke userspace widely, and this commit is an attempt to provide a way for apps to deal with it. While tags are now "sticky" a new automatic device property CURRENT_TAGS is introduced (matching the existing TAGS property) that always reflects the precise set of tags applied on the most recent events. Thus, when subscribing to devices through tags, all devices that ever had the tag put on them will be be seen, and by CURRENT_TAGS it may be checked whether the device right at the moment matches the tag requirements. See: #7587 #7018 #8221
* sd-device: drop priority and description from ↵Yu Watanabe2018-11-101-2/+2
| | | | | | | sd_device_monitor_attach_event() and sd_device_monitor_start() Now we have sd_device_monitor_get_event_soruce(). So, it is not necessary to include these parameters in the functions for sd_device_monitor.
* sd-device: add sd_device_monitor_get_event_source()Yu Watanabe2018-11-101-0/+1
|
* sd-device: make sd_device_get_is_initialized() returns is_initialized by ↵Yu Watanabe2018-10-291-1/+1
| | | | return value
* sd-device: introduce sd_device_monitorYu Watanabe2018-10-171-0/+26
|
* sd-device,libudev: make an argument for *_set_sysattr_value() constYu Watanabe2018-09-111-1/+1
|
* tree-wide: drop copyright headers from frequent contributorsZbigniew Jędrzejewski-Szmek2018-06-201-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
* tree-wide: beautify remaining copyright statementsLennart Poettering2018-06-141-2/+2
| | | | | | 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.
* 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.
* include sys/sysmacros.h in more placesMike Frysinger2016-03-141-0/+1
| | | | | | Since glibc is moving away from implicitly including sys/sysmacros.h all the time via sys/types.h, include the header directly in more places. This seems to cover most makedev/major/minor usage.
* 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.
* tree-wide: expose "p"-suffix unref calls in public APIs to make gcc cleanup easyLennart Poettering2015-11-271-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* tree-wide: sort includes in *.hThomas Hindoe Paaboel Andersen2015-11-181-1/+1
| | | | | This is a continuation of the previous include sort patch, which only sorted for .c files.
* sd-*.h: clean up exported (or to-be-exported) header filesLennart Poettering2015-10-241-1/+1
| | | | | | | | | | | | | | | | | Exported header files should not include internal headers. Fix that. Exported header files should not use the bool type. So far we opted to stick to C89 for exported headers, and hence use "int" for bools in them. Continue to do so. Exported header files should have #include lines for everything they use including inttypes.h and sys/types.h, so that they may be included in any order. Exported header files should have C++ guards, hence add them. Exported header files should not use gcc extensions like #pragma once, get rid of it.
* sd-device: enumerator - match only on initialized devices by defaultTom Gundersen2015-04-171-1/+1
| | | | | | | | It is still possible to include uninitialized ones, but now that is opt-in. In most cases people only want initialized devices. Exception is if you want to work without udev running. Suggested by David Herrmann.
* sd-device: enumerator - don't expose add_device()Tom Gundersen2015-04-171-2/+0
| | | | | | | This is rarely, if ever, used. Drop it from the new public API and only keep it for the legacy API. Suggested by David Herrmann.
* sd-device: add device-enumerator libraryTom Gundersen2015-04-161-1/+25
|
* libsystemd: add sd-device libraryTom Gundersen2015-04-021-0/+77
This provides equivalent functionality to libudev-device, but in the systemd style. The public API only caters to creating sd_device objects from for devices that already exist in /sys, there is no support for listening for monitoring events or creating devices received over the udev netlink protocol. The private API contains the necessary functionality to make sd-device a drop-in replacement for libudev-device, but which we would not otherwise want to export.