Commit Graph
11 Commits
Author SHA1 Message Date
Lennart Poettering 5af1038123 blockdev-list: split per-device filtering into blockdev_list_one()
Subscribers to block-device uevents need to apply the same filter set
blockdev_list() uses over the bulk enumeration, one device at a time.
Pull the per-device body out as blockdev_list_one(), expose
blockdev_list_get_root_devnos() so callers can compute the IGNORE_ROOT
devnos once up-front, and introduce a 4-valued return code so callers
can distinguish:

  MATCH_NO       - fails a static filter (subsystem, ZRAM, IGNORE_ROOT,
                   REQUIRE_PARTITION_SCANNING, REQUIRE_LUKS)
  MATCH_YES      - fully matches
  MATCH_FILTERED - passes static filters but fails a dynamic one
                   (IGNORE_EMPTY, IGNORE_READ_ONLY) - useful to surface
                   as "device just became invisible" transitions when
                   the kernel flips size/ro at runtime
  MATCH_SKIPPED  - soft error during filter evaluation; callers should
                   treat this like MATCH_FILTERED, but the distinct code
                   makes the soft failure visible rather than silently
                   swallowed inside blockdev_list_one()

*ret is initialized on every non-negative return (BLOCK_DEVICE_NULL for
MATCH_NO / MATCH_SKIPPED, fully populated for MATCH_YES / MATCH_FILTERED),
and untouched on negative return. blockdev_list() itself collapses
everything except MATCH_YES back into "skip", so existing callers see
no behavior change.
2026-06-01 11:26:06 +02:00
Lennart Poettering a69f0b8b28 repart: hide read-only block devices from candidates
If they are read-only they are no candidates, since we cannot write to
them.
2026-04-30 08:04:55 +02:00
Lennart Poettering 41a8cc281e blockdev-list: pick up read_only property 2026-04-26 21:21:49 +02:00
Lennart Poettering 5f076e44fe repart: report vendor/model/subsystem fields in ListCandidateDevices
Prompted by: #39435
2025-11-01 22:01:35 +01:00
Daan De Meyer f102bc3e5f tree-wide: Introduce sd-forward.h and shared-forward.h headers
Let's not leak details from src/shared and src/libsystemd into
src/basic, even though you can't actually do anything useful with
just forward declarations from src/shared.

The sd-forward.h header is put in src/libsystemd/sd-common as we
don't have a directory for shared internal headers for libsystemd
yet.

Let's also rename forward.h to basic-forward.h to keep things
self-explanatory.
2025-10-16 17:00:29 +02:00
Lennart Poettering ba793df4b9 blockdev-list,repart: optionally hide zero-size block devices
Block devices with removable media (e.g. SD card readers) indicate a
missing medium with a zero size. Optionally ignore such block devices
that carry no medium currently.
2025-09-23 09:25:11 +02:00
Lennart Poettering ed90a0cdc9 blockdev-list,repart: optionally, filter list of candidate block device and remove OS root disk 2025-09-23 09:23:55 +02:00
Lennart Poettering e863e2dbb5 blockdev-list: also pick up block device size 2025-09-23 09:18:21 +02:00
Lennart Poettering 9f6b2745ea blockdev-list: optionally return finds as list instead of writing it to stdout 2025-09-23 09:13:13 +02:00
Daan De Meyer 69a283c5f2 shared: Clean up includes
Split out of #37344.
2025-05-24 14:00:44 +02:00
Lennart Poettering 68ff31fa0a util: add generic block device listener helper
Various of our tools operate on block devices, and it's not always
obvious to know which block devices are actually appropriate for use.
Hence, let's add a helper that allows to list block devices, and
supports some limited filtering.
2024-07-01 16:39:40 +02:00