Commit Graph
162 Commits
Author SHA1 Message Date
Lennart Poettering 107986a33e sd-varlink: expose api to get input/output fd separately 2025-01-02 16:35:42 +01:00
Thorsten Kukuk 50994b2f91 sd-varlink: add sd_varlink_server_listen_name (#35697) 2024-12-22 17:25:55 +00:00
Federico Giovanardi 7fd45eec37 udev: add option to trigger parent devices despite filters
This commit add the `-i` option to `udevadm trigger` that force it to
match parent devices even if they're excluded from filters.
The rationale is that some embedded devices have a huge number of
platform devices ( ~ 4k for MX8 ) they are there because they're defined
in the device tree but there isn't any action or udev rules associated
with them.

So at boot a significant time is spend triggering and processing rules
for devices that don't produce any effect and we would like to filter
them by calling:

```
udevadm trigger --type=device --action=add -s block -s tty
```

instead of the normal

```
udevadm trigger --type=device --action=add
```

so we can use filter to filter out only subsystems for we we know that
we have rules in place that do something useful.

On the other side action / rules are not triggered until the parent is
triggered ( which is part of another subsystem), so the additional option
will allows udev to complete the coldplug with only the devices we care.

Example on iMX8:

.Without the new option
```
root@dev:~# udevadm trigger --dry-run  -s block --action=add -v
/sys/devices/platform/bus@5b000000/5b010000.mmc/mmc_host/mmc0/mmc0:0001/block/mmcblk0
/sys/devices/platform/bus@5b000000/5b010000.mmc/mmc_host/mmc0/mmc0:0001/block/mmcblk0/mmcblk0boot0
/sys/devices/platform/bus@5b000000/5b010000.mmc/mmc_host/mmc0/mmc0:0001/block/mmcblk0/mmcblk0boot1
/sys/devices/platform/bus@5b000000/5b010000.mmc/mmc_host/mmc0/mmc0:0001/block/mmcblk0/mmcblk0p1
/sys/devices/platform/bus@5b000000/5b010000.mmc/mmc_host/mmc0/mmc0:0001/block/mmcblk0/mmcblk0p2
/sys/devices/platform/bus@5b000000/5b010000.mmc/mmc_host/mmc0/mmc0:0001/block/mmcblk0/mmcblk0p3
/sys/devices/platform/bus@5b000000/5b010000.mmc/mmc_host/mmc0/mmc0:0001/block/mmcblk0/mmcblk0p4
```

.With the new option
```
root@dev:~# udevadm trigger --dry-run -i -s block --action=add -v
/sys/devices/platform
/sys/devices/platform/bus@5b000000
/sys/devices/platform/bus@5b000000/5b010000.mmc
/sys/devices/platform/bus@5b000000/5b010000.mmc/mmc_host/mmc0
/sys/devices/platform/bus@5b000000/5b010000.mmc/mmc_host/mmc0/mmc0:0001
/sys/devices/platform/bus@5b000000/5b010000.mmc/mmc_host/mmc0/mmc0:0001/block/mmcblk0
/sys/devices/platform/bus@5b000000/5b010000.mmc/mmc_host/mmc0/mmc0:0001/block/mmcblk0/mmcblk0boot0
/sys/devices/platform/bus@5b000000/5b010000.mmc/mmc_host/mmc0/mmc0:0001/block/mmcblk0/mmcblk0boot1
/sys/devices/platform/bus@5b000000/5b010000.mmc/mmc_host/mmc0/mmc0:0001/block/mmcblk0/mmcblk0p1
/sys/devices/platform/bus@5b000000/5b010000.mmc/mmc_host/mmc0/mmc0:0001/block/mmcblk0/mmcblk0p2
/sys/devices/platform/bus@5b000000/5b010000.mmc/mmc_host/mmc0/mmc0:0001/block/mmcblk0/mmcblk0p3
/sys/devices/platform/bus@5b000000/5b010000.mmc/mmc_host/mmc0/mmc0:0001/block/mmcblk0/mmcblk0p4
```
Boot time reduction with this is place is ~ 1 second.
2024-12-16 15:43:52 +01:00
Yu Watanabe 5fcabde35b sd-json: properly export sd_json_variant_type_from_string() and _to_string()
These exist in the header file, but were not exporeted.

Continuation of e11f5aa722.
2024-12-12 13:08:35 +09:00
Lennart Poettering e11f5aa722 sd-varlink: properly export sd_varlink_reset_fds()
This function was listed in the public sd-varlink.h header, but not
actually made public. Fix that. It's quite useful, the comment in it
describes the usecase nicely.

Fixes: #35554
2024-12-12 05:13:12 +09:00
Zbigniew Jędrzejewski-Szmek 29f63c67b0 sd-varlink: add sd_varlink_server_set_info
Fixes https://github.com/systemd/systemd/issues/35508.

As reported in the bug, the values were hardcoded for the systemd project.
https://varlink.org/Service lists vendor, product, version, url, and interfaces
as the mandatory parameters, so add an interface to set the first four. The
last field is set automatically based on the registered interfaces as before.

If the values are not filled in, we return empty strings. With NULL,
'varlinkctl info' would say:
  (string):1:25: Object field 'vendor' has wrong type null, expected string.
2024-12-10 10:43:14 +01:00
Mike YuanandThorsten Kukuk 804dd670d1 sd-varlink: mark sd_varlink_server_{ref,unref} as _public_ (#35241)
Co-authored-by: Thorsten Kukuk <kukuk@suse.com>
2024-11-20 05:21:15 +09:00
Lennart Poettering 12641ecd67 sd-varlink: add new sd_varlink_error_is_invalid_parameter() helper 2024-10-15 14:15:21 +02:00
Lennart Poettering 625f109604 sd-json: drop sd_json_dispatch_pid() again, as we prefer json_dispatch_pidref() now
The calls are now unused, and we generally prefer if people send a PID
triplet rather than a single PID, hence stop supporting a high-level
dispacher for pid_t.
2024-10-14 12:47:17 +02:00
Ivan Kruglov dafd44de4f sd-json: add sd_json_dispatch_pid() 2024-10-10 13:40:45 +02:00
Ivan Kruglov 729fbe78df sd-json: add sd_json_dispatch_signal() 2024-10-10 13:40:45 +02:00
Yu Watanabe 9f563bcd74 Merge pull request #34123 from yuwata/sd-device
sd-device: expose sd_device_get_device_id() and sd_device_get_driver_subsystem()
2024-08-28 11:33:09 +09:00
Yu Watanabe 5ab1250534 sd-device-monitor: introduce sd_device_monitor_get_events() and _get_timeout()
Follow-up for bab889c51e (#33032).

Currently, they unconditionally returns EPOLLIN and USEC_INFINITY, respectively.
Just for consistency with sd-bus, sd-journal, sd-varlink, and so on. All
they have _get_fd(), _get_events(), and _get_timeout().

Closes #34094.
2024-08-28 05:35:07 +09:00
Yu Watanabe 1ff0164be5 sd-device: make device_get_device_id() public
We have already exposed sd_device_new_from_device_id(), but we have
never provide the way to get device ID from an existing sd_device
object.
2024-08-28 05:26:04 +09:00
Yu Watanabe 44bc6f3cab sd-device: introduce sd_device_get_driver_subsystem()
To create the sd_device object of a driver, the function
sd_device_new_from_subsystem_sysname() requires "drivers" for subsystem
and e.g. "pci:iwlwifi" for sysname. Similarly, sd_device_new_from_device_id()
also requires driver subsystem. However, we have never provided a
way to get the driver subsystem ("pci" for the previous example) from
an existing sd_device object.

Let's introduce a way to get driver subsystem.
2024-08-28 05:18:14 +09:00
Yu Watanabe 9ec6d26e41 sd-json: add sd_json_variant_set_field_id128() and _uuid() 2024-08-14 15:52:39 +09:00
Yu Watanabe bab889c51e sd-device-monitor: expose low-level functions
To make it work without sd-event.

Prompted by recent chat:
> Hey all!
> reading man libudev, it says to use sd-device instead now. I've read that
> APIs header file and it seems it no longer has an equivalent to libudev's
> udev_monitor_get_fd, which AFAICT means I have to use sd-event to watch
> for events I'm interested in. I know I can "embed" sd-event in other event
> loops I might already have, but that seems overkill when I'm only interested
> in this one type of event and don't need sd-event for anything else.
2024-08-02 11:22:24 +09:00
Yu Watanabe ece1e280ee sd-device-monitor: introduce sd_device_monitor_is_running() 2024-08-02 11:16:33 +09:00
Lennart Poettering 25ff515b39 sd-varlink: make our internal Varlink API public as sd-varlink.[ch]
It's time. sd-json was already done earlier in this cycle, let's now
make sd-varlink public too.

This is mostly just a search/replace job of epical proportions.

I left some functions internal (mostly IDL handling), and I turned some
static inline calls into regular calls.
2024-07-16 11:57:32 +02:00
Lennart Poettering 4fae650ad8 json: add sd_json_dispatch_double() helper 2024-06-15 00:43:56 +01:00
Lennart Poettering 309a747fa6 libsystemd: turn json.[ch] into a public API
This is preparation for making our Varlink API a public API. Since our
Varlink API is built on top of our JSON API we need to make that public
first (it's a nice API, but JSON APIs there are already enough, this is
purely about the Varlink angle).

I made most of the json.h APIs public, and just placed them in
sd-json.h. Sometimes I wasn't so sure however, since the underlying data
structures would have to be made public too. If in doubt I didn#t risk
it, and moved the relevant API to src/libsystemd/sd-json/json-util.h
instead (without any sd_* symbol prefixes).

This is mostly a giant search/replace patch.
2024-06-12 18:42:22 +02:00
Lennart Poettering 48ce0824dc sd-bus: add new sd_bus_pending_method_calls() call 2024-06-11 23:17:38 +01:00
Lennart Poettering 615906cdcf sd-id128: add an app-specific flavour of the invocation ID too 2024-04-20 12:10:42 +02:00
Yu Watanabe 74c4231ce5 sd-event: introduce sd_event_source_get_inotify_path()
This may be useful when there are multiple inotify event sources exist.
Without this, users need to manage the event sources and paths.
2024-04-19 14:23:11 +09:00
Mike Yuan 32104d3251 sd-journal: introduce sd_journal_stream_fd_with_namespace 2024-03-14 14:25:52 +08:00
Lennart Poettering 71be64064c sd-bus: add pidfd to the sd_bus_creds structure
Let's continue with the pidfd'ification, and include pidfd in our
sd_bus_creds structure tha tracks a peers credentials.
2024-01-29 14:41:58 +01:00
Daan De Meyer fe2a6dce6c sd-device: Support matching all properties
Let's support enumerating over devices that match all of the given
properties instead of any of the given properties by adding a new
function sd_device_enumerator_add_match_property_required() which
specifies properties that should all be matched instead of just one.

Fixes #28372
2023-10-11 19:57:49 +02:00
Zbigniew Jędrzejewski-Szmek 62b4bee9bc sd-id128: export sd_id128_get_app_specific()
We exported sd_id128_get_machine_app_specific() and
sd_id128_get_boot_app_specific(). But those operate on the current machine,
and sometimes the user might want to do the same calculation for a different
machine, or an earlier boot, etc. We expose the underlying implementation
to make this easy.
2023-08-29 17:06:47 +03:00
Thorsten Kukuk 403082602d sd-login: add sd_session_get_leader interface 2023-06-07 09:33:36 +01:00
Yu Watanabe b78f9481bc sd-journal: introduce sd_journal_step_one()
After the commit 7a4ee86161,
sd_journal_next() following sd_journal_seek_tail() takes no-op,
and we need to call sd_journal_previous(). This may be useful in
some cases, e.g. to fix the issue explained in the previous commit.
2023-05-28 23:53:18 +09:00
Lennart Poettering 2fdc274c66 sd-event: add an explicit API for leaving the ratelimit state
Sometimes, it might make sense to end the ratelimit window early.
2023-05-24 10:52:08 +02:00
Lennart Poettering 0de3431871 sd-daemon: add sd_pid_notify_barrier() call and use it in systemd-notify
Previously we'd honour --pid= from the main notification we send, but
not from the barrier. This is confusing at best. Let's fix that.
2023-05-03 18:21:42 +02:00
Daan De Meyer 77b7026668 libsystemd: Add missing memory pressure functions to public symbols 2023-04-28 21:19:38 +02:00
Lennart Poettering 4054d76151 sd-daemon: add sd_pid_notifyf_with_fds()
I guess it was only a question of time until we need to add the final
frontier of notification functions: one that combines the features of
all the others:

1. specifiying a source PID
2. taking a list of fds to send along
3. accepting a format string for the status string

Hence, let's add it.
2023-04-25 17:38:57 +02:00
Yu Watanabe e6faa55878 Merge pull request #26578 from thkukuk/main
sd-login: add sd_uid_get_login_time interface #26574
2023-02-26 07:54:11 +09:00
Thorsten Kukuk d622fefc00 sd-login: add sd_uid_get_login_time interface #26574 2023-02-25 16:14:11 +01:00
Lennart Poettering ccacde77f3 libsystemd: sd_journal_get_seqnum() must be tagged with 254 symver, not 253
This is a follow-up for b1712fabd1 which
was prepped for 253, but merged into early 254 development cycle. It
thus had the symbol it adds at the wrong symver. Fix thta.
2023-02-24 13:49:45 +01:00
Mike Yuan c4ef14dc2a sd-login: add sd_session_get_start_time 2023-02-24 02:12:36 +08:00
Mike Yuan d71f5b1217 sd-login: add sd_session_get_username 2023-02-24 02:12:08 +08:00
Lennart Poettering b1712fabd1 sd-journal: add high-level API for querying seqnum for journal entries, along with seqnum id 2023-02-08 13:42:29 +01:00
Luca Boccassi da20baaecc sd-login: add sd_pidfd_* APIs
Same as the sd_pid_* counterparts, but take a pid file descriptor instead of
a pid, so that the callers can be sure that the returned values are really
about the process they asked for, and not about a recycled PID.
2023-01-20 12:18:05 +00:00
Erik Moqvist 85bc6b0549 sd-bus: convenience functions to emit a signal to a destination (#25123)
* sd-bus: convenience functions to emit a signal to a destination
2022-10-31 20:11:48 +00:00
Lennart Poettering baf3fdec27 sd-event: add helper for exiting event loop on SIGTERM/SIGINT
In many (most?) of our event loops we want to exit once SIGTERM/SIGINT
is seen. Add a common helper for that, that does the right things in a
single call.
2022-09-30 14:18:43 +02:00
Yu Watanabe ec9b4f2b92 sd-device: introduce sd_device_get_child_first() and _next()
These functions provide a high-level interface for enumerating
child devices.

Suggested at https://github.com/systemd/systemd/pull/24731#discussion_r973987065.
2022-09-23 07:03:15 +09:00
Yu Watanabe dd35a61caf sd-netlink: unexport sd-netlink
This effectively reverts 84e1001541.

The sd-netlink library has several issues, and we should not export it
without solving them. See issues #24258 and #24124.
2022-09-17 01:31:57 +09:00
Zbigniew Jędrzejewski-Szmek 3310e0647c sd-netlink: delete sd_netlink_new_from_fd()
It was somewhat similar to sd_netlink_open_fd(), and unused.
2022-08-19 11:52:25 +02:00
Zbigniew Jędrzejewski-Szmek 24c0f38591 sd-netlink: rename sd_netlink_message_request_dump to sd_netlink_message_set_request_dump 2022-08-19 11:52:25 +02:00
Yu Watanabe 39f11aa422 sd-device-monitor: introduce sd_device_monitor_{set,get}_description() 2022-08-12 21:27:14 +09:00
Yu Watanabe 68a52f5973 sd-device: introduce sd_device_new_child() 2022-08-05 21:49:23 +09:00
Yu Watanabe 2c08455eed sd-netlink: introduce sd_netlink_message_append_container_data() 2022-07-23 23:52:42 +09:00