Yu Watanabe
62ccd11d38
sd-device: use device_opendir()
2022-09-19 19:42:36 +09:00
Yu Watanabe
db3049b6f0
sd-device: introduce device_opendir()
2022-09-19 19:42:02 +09:00
Yu Watanabe
4bc9d8165b
sd-device: re-implement device_sysattrs_read_all() without recursion
2022-09-19 18:04:13 +09:00
Yu Watanabe
5b304c7052
sd-device: use faccessat()
...
No functional changes, just refactoring.
2022-09-19 18:04:13 +09:00
Yu Watanabe
65c0f14bc1
sd-device: use fstatat()
...
No functional changes, just refactoring.
2022-09-19 18:04:13 +09:00
Yu Watanabe
bc5e8ebbfb
sd-device: use path_hash_ops to store sysattrs
...
As the stored values are actually path. Just for safety.
This also drops unnecessary duplication of path.
2022-09-19 18:04:12 +09:00
Yu Watanabe
23d3dfc369
sd-device: refuse block device without subsystem
...
Previously, even if sd_device_get_subsystem() returns -ENOENT for block
device, we accepted that. This makes the check slightly stricter.
2022-09-18 15:35:56 +02: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
Yu Watanabe
8dcc66cefc
uid-range: tie up number and array of uid range entries
...
This renames UidRange -> UidRangeEntry, and reintroduces UidRange which
contains the array of UidRangeEntry and its size.
No fucntional changes, just refactoring.
2022-09-16 20:56:58 +09:00
Yu Watanabe
f91c23f785
sd-device-monitor: do not trigger assertion when uid_map is not empty
...
Follow-up for c0aa23cf1e .
2022-09-16 13:05:51 +02:00
j00512545
365c2885f0
fix typo in log
2022-09-15 17:46:04 +02:00
David Tardon
995340074e
tree-wide: use ASSERT_PTR more
2022-09-13 08:13:27 +02:00
Yu Watanabe
3fb94c7062
sd-device: move device_new_from_watch_handle_at() to udev-watch.c
...
And drop unused watch handle related functions.
2022-09-12 01:36:06 +09:00
Yu Watanabe
88b5080ea9
sd-device-enumerator: use _cleanup_free_ attribute for safety
...
No functional changes, just improve readability.
Suggested by https://github.com/systemd/systemd/pull/24601#discussion_r966883459 .
2022-09-09 21:16:37 +09:00
Yu Watanabe
89ad604839
sd-device-enumerator: always ignore ENOENT from opendir()
...
But logs all errors.
2022-09-09 21:16:37 +09:00
Yu Watanabe
0f519b9c2e
sd-device-enumerator: check sysname earlier
2022-09-09 21:16:32 +09:00
Yu Watanabe
2d9c58d786
test: add test for sd_device_enumerator_add_match_parent()
2022-09-08 18:10:50 +09:00
Yu Watanabe
6c876f0c20
sd-device-enumerator: rewrite child enumeration without recursion
2022-09-08 18:10:50 +09:00
Yu Watanabe
bae477676a
sd-device-enumerator: do not fail when a directory vanishes on enumerate
2022-09-08 18:10:50 +09:00
Yu Watanabe
cdffb95cce
sd-device-enumerator: use test_matches() more
2022-09-08 18:10:50 +09:00
Yu Watanabe
c0aa23cf1e
sd-device-monitor: relax sender uid check when running in user namespace
...
If sd-device-monitor is running in a user namespace, the sender uid is
not zero. Let's relax the verification in that case.
2022-09-08 11:08:43 +09:00
Yu Watanabe
778912a659
sd-device: introduce devname_from_stat_rdev()
2022-09-03 00:42:31 +09:00
Yu Watanabe
4fe46c349d
sd-device: rename devpath_from_devnum() -> devname_from_devnum()
...
In sd-device, `devpath` is a kind of syspath without '/sys' prefix, e.g.
/devices/pci0000:00/0000:00:1c.4/0000:3c:00.0/nvme/nvme0/nvme0n1,
and `devname` is a path to the device node, e.g. /dev/nvme0n1.
Let's use the consistent name for the helper function.
2022-09-03 00:42:31 +09:00
Jan Janssen
f996072fe0
tree-wide: Fix field width specifier warnings
...
The casting here isn't pretty, but at least it makes it obvious what is
happening instead of implicit and it allows enabling -Wformat-signedness.
2022-08-30 12:03:33 +02:00
Jan Janssen
1dbab956ba
journal: Show grcrypt error message instead of a raw code
2022-08-30 12:03:33 +02:00
Jan Janssen
c0f86d66f3
tree-wide: Use correct format specifiers
...
gcc will complain about all these with -Wformat-signedness.
2022-08-30 12:03:28 +02:00
Topi Miettinen
5b198025de
sd-netlink: add NetLabel support
2022-08-29 14:23:17 +09:00
Yu Watanabe
42899bcee5
sd-device: skip to check diskseq if device is not initialized
2022-08-28 10:10:44 +09:00
Yu Watanabe
ff65036cfe
sd-device: introduce device_open_from_devnum()
2022-08-28 09:08:21 +09:00
Yu Watanabe
f79fdea6fd
sd-device: introduce devpath_from_devnum()
2022-08-28 09:08:21 +09:00
Yu Watanabe
a2ded81f73
sd-device: rename device-util.c -> device-filter.c
...
The functions provided by the file are only used in sd-device.
2022-08-28 09:08:21 +09:00
Yu Watanabe
6dd3b818bb
tree-wide: fix typo
2022-08-28 00:03:36 +09:00
Luca Boccassi
34f166d601
Merge pull request #24456 from yuwata/network-tcp-congctl
...
network: introduce TCPCongestionControlAlgorithm=
2022-08-26 18:04:51 +01:00
Yu Watanabe
5342810bcf
test-sd-device: run subsystem filter test several times
...
The test is quite racy. Let's wait for all queued udev events to be
processed, and run the test several times.
Fixes #24400 .
2022-08-26 07:29:36 +00:00
Yu Watanabe
51b8753017
sd-netlink: fix attribute type for RTAX_CC_ALGO
2022-08-26 14:33:54 +09:00
Lennart Poettering
98f3e84342
Merge pull request #24420 from keszybz/mouse-power
...
Rework on_ac_power()
2022-08-24 10:16:14 +02:00
Zbigniew Jędrzejewski-Szmek
48a511cf92
sd-device: add helper to read a unsigned int attribute
...
There are dozens of places where this could be used, but I don't
want to do the conversion now because it's quite a bit of work.
I think we could export this function later on, because reading
numerical attributes is so common. But for now, I'm just adding the
helper to use it one place.
2022-08-23 17:04:31 +02:00
Lennart Poettering
45519d13a4
tree-wide: port things dirname_malloc() → path_extract_directory()
2022-08-23 15:10:15 +02:00
Lennart Poettering
8e7e4a730b
tree-wide: use path_join() instead of prefix_roota() in various cases
...
prefix_roota() is something we should stop using. It is bad for three
reasons:
1. As it names suggests it's supposed to be used when working relative
to some root directory, but given it doesn't follow symlinks (and
instead just stupidly joins paths) it is not a good choice for that.
2. More often than not it is currently used with inputs under control of
the user, and that is icky given it typically allocates memory on the
stack.
3. It's a redundant interface, where chase_symlinks() and path_join()
already exist as better, safer interfaces.
Hence, let's start moving things from prefix_roota() to path_join() for
the cases where that's appropriate.
2022-08-22 19:15:29 +01:00
Frantisek Sumsal
94510784e1
sd-journal: drop an unused variable
2022-08-20 20:46:23 +02:00
Yu Watanabe
0f27758ae9
Merge pull request #24356 from keszybz/sd-netlink-api
...
Small improvements to the sd-netlink api
2022-08-20 19:11:02 +09:00
Zbigniew Jędrzejewski-Szmek
93c0a5eccf
sd-netlink: use SD_EVENT_ONESHOT for a time-based callback
2022-08-19 17:43:56 +02:00
Lennart Poettering
2ab1fb77e2
tree-wide: pass proper values (not bools) to sd_event_source_set_enabled()
2022-08-19 14:56:26 +02:00
Zbigniew Jędrzejewski-Szmek
40c864afe0
sd-netlink: simplify error code retention
2022-08-19 11:52:25 +02: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
Zbigniew Jędrzejewski-Szmek
f4f81a6b35
sd-netlink: constify parameters in public api and adjust pointer formatting
...
In the internal api, 'char* const*' is used instead of 'const char* const*'
because otherwise we'd get a mismatch with the various strv apis.
2022-08-19 11:52:25 +02:00
Zbigniew Jędrzejewski-Szmek
b44662fee5
sd-netlink: prefix output param names with 'ret'
...
In some places, the code was already using that, so only the header file needed
to be adjusted.
We use 'nl' for the sd_netlink* when it's passed in as input. I was considering
renaming to 'netlink', but that'd add a lot of verbosity and also we have
'sd_journal *j' in sd-journal, so the short name matches in style.
2022-08-19 11:52:21 +02:00
Yu Watanabe
9d9bc6fc57
Merge pull request #24285 from yuwata/sd-device-new-from-path
...
sd-device: make sd_device_new_from_path() support symlink outside of /sys
2022-08-13 03:27:26 +09:00
Yu Watanabe
284ef480d0
test: add more tests for sd_device_new_from_path()
2022-08-12 21:42:00 +09:00