Commit Graph
2924 Commits
Author SHA1 Message Date
Zbigniew Jędrzejewski-Szmek 4d5713bb7e Merge pull request #23119 from yuwata/test-sd-device-exclude-bdi
test: exclude "bdi" subsystem
2022-04-27 16:56:53 +02:00
Yu Watanabe ff56124b11 test: exclude "bdi" subsystem and loop block devices
On several CI environments, it seems that some loop block devices and
corresponding bdi devices are sometimes removed during the test is
running. Let's exclude them.

Fixes #22970.
2022-04-27 16:32:42 +09:00
Yu Watanabe 9409710097 sd-device-enumerator: introduce sd_device_enumerator_add_nomatch_sysname() 2022-04-27 16:32:42 +09:00
Yu Watanabe c11810ed30 sd-device-enumerator: use set_fnmatch() 2022-04-27 16:32:42 +09:00
Lennart Poettering d4cc5c8037 journal-verify: tighten check for compression of non-objects 2022-04-26 21:55:49 +02:00
Lennart Poettering 4d698d12de compress: make Compression a regular non-sparse enum
Given we have two different types for the journal object flags and the
Compression enum, let's make the latter a regular non-sparse enum, and
thus remove some surprises. We have to convert anyway between the two,
and already do via COMPRESSION_FROM_OBJECT().
2022-04-26 21:55:49 +02:00
Lennart Poettering acc50c92eb basic: move compress.[ch] → src/basic/
The compression helpers are used both in journal code and in coredump
code, and there's a good chance we'll use them later for other stuff.

Let's hence move them into src/basic/, to make them a proper internal
API we can use from everywhere where that's desirable. (pstore might be
a candidate, for example)

No real code changes, just some moving around, build system
rearrangements, and stripping of journal-def.h inclusion.
2022-04-26 21:45:03 +02:00
Zbigniew Jędrzejewski-Szmek 23ce0271dc Merge pull request #23160 from keszybz/compress-defines
meson: simplify setting of default compression
2022-04-25 10:57:51 +02:00
Yu Watanabe 8ac6b05b7c tree-wide: Fix typo 2022-04-25 10:06:08 +09:00
Zbigniew Jędrzejewski-Szmek ee00684c50 meson: use a single constant for default compression setting
Suggested by Daniele Nicolodi:
https://github.com/systemd/systemd/pull/23160#discussion_r855853716

This is possible only if the macro is never used in #if, but only in C code.
This means that all places that use #if have to be refactored into C, but we
reduce the duplication a bit, and C is nicer to read than preprocessor
conditionals.
2022-04-22 15:08:28 +02:00
Zbigniew Jędrzejewski-Szmek 1d997b8114 meson: simplify setting of default compression
Follow-up for da13d2ca07. Instead of having
separate definitions of the bitmask flags, just define DEFAULT_COMPRESSION_FOO=0|1
directly.

(It *should* be possible to do this more simply, but the problem is that
anything that is used in #if cannot refer to C constants or enums. This is the
simplest I could come up with that preserves the property that we don't use #ifdef.)

The return value from compress_blob() is changed to propagate the error instead
of always returning -EOPNOTSUPP. The callers don't care about the specific error
value. compress_blob_*() are changed to return the compression method on success, so
that compress_blob() can be simplified. compress_stream_*() and compress_stream() are
changed in the same way for consistency, even though the callers do not currently use
this information (outside of tests).
2022-04-22 12:02:29 +02:00
Lennart Poettering 7f40cb7c86 sd-bus: switch to a manual overflow check in sd_bus_track_add_name()
This is generally used in a directly client controllable way, hence we
should handle ref count overflow gracefully, instead of hitting an
assert().

As discussed:

https://github.com/systemd/systemd/pull/23099#discussion_r854341850
2022-04-21 08:58:35 +09:00
Lennart Poettering 947914cb44 Merge pull request #23099 from yuwata/sd-bus-track-fixlets
sd-bus: fix counter
2022-04-20 18:23:05 +02:00
Daan De Meyer b9b156ea3c Merge pull request #23124 from yuwata/fixes-for-post-merge-review
Fixes for post merge review
2022-04-20 17:15:40 +02:00
Luca Boccassi da13d2ca07 compression: add separate pre-processor definitions
Follow-up for https://github.com/systemd/systemd/commit/cd3c6322dbc6370448bafc216ee4e19e32a79d9e

journal-def.h should be self-contained too, as it represents the journal object ABI.
Duplicate the enums, as they also need to be in config.h for it to be self-contained,
and enums are not available to the preprocessor. Use an assert to ensure they don't
diverge.
2022-04-19 23:18:19 +02:00
Yu Watanabe 9dbfcaf229 sd-device: use string_replace_char() and strspn_from_end() 2022-04-20 02:19:44 +09:00
Yu Watanabe e4e1353c25 sd-device: refuse O_DIRECTORY returned from path_extract_filename()
In both cases, it is expected that the symlink targets do not end with '/'.

Addresses https://github.com/systemd/systemd/pull/23089#discussion_r853007218.
2022-04-20 01:43:27 +09:00
Yu Watanabe 056a18e465 test: add several tests for track item 2022-04-19 18:02:10 +09:00
Yu Watanabe 63ec7a8490 test: shorten code a bit 2022-04-19 18:02:10 +09:00
Yu Watanabe c399ed923d sd-bus: use hashmap_contains() and drop unnecessary cast 2022-04-19 18:02:10 +09:00
Yu Watanabe 55bfacc6c3 sd-bus: do not return negative errno when unknown name is specified
When 'recursive' is false, then sd_bus_track_remove_name() does not
return negative errno when unknown name is specified. Let's follow the
same pattern for the case that 'recursive' is true.
2022-04-19 18:02:10 +09:00
Yu Watanabe 6a7ca27740 sd-bus: do not read unused value 2022-04-19 18:02:10 +09:00
Yu Watanabe c2d7dd35d2 sd-bus: introduce ref/unref function for track_item 2022-04-19 18:01:46 +09:00
Yu Watanabe b21f237d99 sd-bus: fix reference counter to be incremented
Fixes #23097.
2022-04-19 17:58:08 +09:00
Yu Watanabe 915774ecb8 Merge pull request #23101 from yuwata/sd-device-cleanups
sd-device: several cleanups
2022-04-18 07:01:42 +09:00
Luca Boccassi cd3c6322db compression: add build-time option to select default
Compression and decompression are controlled by the same build flag,
so if one wants to use, say, LZ4 to compress, ZSTD has to be disabled,
which means one loses the ability to read zstd-compressed journals.

Add a default-compression meson option, that allows to select any of
the available compression algorithms as the default.
2022-04-18 05:43:59 +09:00
Yu Watanabe 23d20adc05 sd-device: rename arguments and variables 2022-04-18 04:34:14 +09:00
Yu Watanabe 9c5d7151c1 sd-device: fix possible use-of-uninitialized-value 2022-04-18 04:34:14 +09:00
Yu Watanabe 17761fb3bf sd-device: use ERRNO_IS_DEVICE_ABSENT() at one more place 2022-04-18 04:34:14 +09:00
Yu Watanabe d82827a107 sd-device: rename function arguments for storing results 2022-04-18 04:34:14 +09:00
Yu Watanabe c77c1cc201 sd-device: use correct type and parser for device node uid and gid 2022-04-18 04:34:14 +09:00
Yu Watanabe d37c69c1bf sd-device: shorten code a bit 2022-04-18 04:34:14 +09:00
Yu Watanabe ce1d08ba94 sd-device: use path_extract_filename() at one more place
This also does several cleanups.
2022-04-18 04:34:14 +09:00
Yu Watanabe 60e50fb20d sd-device: reset sysname and sysnum on renaming 2022-04-18 04:34:14 +09:00
Yu Watanabe f5a75f2027 sd-device: reduce indentation 2022-04-18 04:34:14 +09:00
Yu Watanabe ff58f2ae2a sd-device: verify new syspath on renaming 2022-04-18 04:34:14 +09:00
Yu Watanabe bd4297e761 udevadm: info: also show parent devices by --tree 2022-04-17 21:27:33 +02:00
Yu Watanabe b9d8209065 test: add tests for sd_device_get_sysnum() 2022-04-16 00:52:24 +09:00
Yu Watanabe 5fa9d220c2 sd-device: shorten code a bit 2022-04-16 00:52:24 +09:00
Yu Watanabe c58e0ce677 sd-device: use path_extract_filename() at one more place 2022-04-16 00:52:16 +09:00
Yu Watanabe cc41c084cd sd-netlink: use correct type of iterator 2022-04-15 17:37:52 +09:00
Lennart Poettering 4bcf5c11c8 Merge pull request #23011 from mrc0mmand/TEST-64-md
test: add MD-related tests to TEST-64
2022-04-13 22:26:50 +02:00
Yu Watanabe bd1f75d5fb Merge pull request #23070 from poettering/devnum-split
basic: some devnum handling tweaks and refactorings
2022-04-14 03:45:39 +09:00
Yu Watanabe 03b894fc09 sd-device: skip diskseq verification when ID_IGNORE_DISKSEQ property is set
Some drivers do not announce the diskseq change.
E.g. for md devices, the kernel increments the diskseq *after*
emitting a 'change' uevent when backing block devices are added to
a md device, and udevd does not receive no uevent which contains
the new diskseq.
2022-04-14 00:10:28 +09:00
Lennart Poettering 7176f06c9e basic: split out dev_t related calls into new devno-util.[ch]
No actual code changes, just splitting out of some dev_t handling
related calls from stat-util.[ch], they are quite a number already, and
deserve their own module now I think.

Also, try to settle on the name "devnum" as the name for the concept,
instead of "devno" or "dev" or "devid". "devnum" is the name exported in
udev APIs, hence probably best to stick to that. (this just renames a
few symbols to "devum", local variables are left untouched, to make the
patch not too invasive)

No actual code changes.
2022-04-13 16:26:31 +02:00
Lennart Poettering 00dfbf35fd sd-device: include parent devices in enumeration 2022-04-13 14:41:05 +02:00
Lennart Poettering 0b859c9773 sd-device: properly support some corner case syspath 2022-04-13 14:41:05 +02:00
Lennart Poettering be247835c7 sd-device: add some comments 2022-04-13 14:41:05 +02:00
Lennart Poettering 29a5428f1c sd-device: filter regular files when enumerating
Currently if enumerating with debug logging you'll likely see something
like this:

sd-device: the syspath "/sys/class/devcoredump/disabled" is not a directory.
sd-device: the syspath "/sys/class/firmware/timeout" is not a directory.
sd-device: the syspath "/sys/class/zram-control/hot_remove" is not a directory.
sd-device: the syspath "/sys/class/zram-control/hot_add" is not a directory.
sd-device: the syspath "/sys/class/drm/version" is not a directory.

This is because these sysfs classes place regular files in these
directories, which we so far didn't expect.

Let's filter them early, and only bother with enumerated inodes if they
actually are dirs or symlinks, i.e. can be kobject dirs. Regular file
definitely never are kobject dirs...
2022-04-13 14:41:04 +02:00
Lennart Poettering e7c7d79d52 sd-device: split out checking of matches from enumerator_scan_dir_and_add_devices()
No change in behaviour, just some splitting out of code.
2022-04-13 14:41:04 +02:00