blockdev-list: also ignore ramdisk
This renames BLOCKDEV_LIST_IGNORE_ZRAM to BLOCKDEV_LIST_IGNORE_RAMDISK,
and make it ignores both /dev/ramX and /dev/zramX.
Note, linux-stable by Alpine/postmarketOS has CONFIG_BLK_DEV_RAM=y,
hence the kernel creates /dev/ramX by default. Without this change,
the test case added by 236e7d8a4c fails,
as io.systemd.Repart.ListCandidateDevices varlink method lists the
ramdisks.
This commit is contained in:
committed by
Daan De Meyer
parent
3fe57d03a3
commit
77c51f4e97
@@ -162,7 +162,7 @@ int vl_method_list_candidate_devices(
|
||||
const BlockDevListFlags listflags =
|
||||
BLOCKDEV_LIST_SHOW_SYMLINKS|
|
||||
BLOCKDEV_LIST_REQUIRE_PARTITION_SCANNING|
|
||||
BLOCKDEV_LIST_IGNORE_ZRAM|
|
||||
BLOCKDEV_LIST_IGNORE_RAMDISK|
|
||||
BLOCKDEV_LIST_IGNORE_READ_ONLY|
|
||||
BLOCKDEV_LIST_METADATA|
|
||||
BLOCKDEV_LIST_DISKSEQ|
|
||||
|
||||
+1
-1
@@ -10692,7 +10692,7 @@ static int parse_argv(int argc, char *argv[]) {
|
||||
r = blockdev_list(
|
||||
BLOCKDEV_LIST_SHOW_SYMLINKS|
|
||||
BLOCKDEV_LIST_REQUIRE_PARTITION_SCANNING|
|
||||
BLOCKDEV_LIST_IGNORE_ZRAM|
|
||||
BLOCKDEV_LIST_IGNORE_RAMDISK|
|
||||
BLOCKDEV_LIST_IGNORE_READ_ONLY,
|
||||
/* ret_devices= */ NULL,
|
||||
/* ret_n_devices= */ NULL);
|
||||
|
||||
@@ -205,8 +205,8 @@ int blockdev_list_one(
|
||||
goto no_match;
|
||||
}
|
||||
|
||||
if (FLAGS_SET(flags, BLOCKDEV_LIST_IGNORE_ZRAM)) {
|
||||
r = device_sysname_startswith(dev, "zram");
|
||||
if (FLAGS_SET(flags, BLOCKDEV_LIST_IGNORE_RAMDISK)) {
|
||||
r = device_sysname_startswith(dev, "ram", "zram");
|
||||
if (r < 0) {
|
||||
log_device_warning_errno(dev, r, "Failed to check device name of discovered block device '%s', ignoring: %m", node);
|
||||
goto skipped;
|
||||
|
||||
@@ -9,7 +9,7 @@ typedef enum BlockDevListFlags {
|
||||
BLOCKDEV_LIST_IGNORE_VIRTUAL = 1 << 2, /* Ignore virtual devices (devices under /sys/devices/virtual/), except loopback devices */
|
||||
BLOCKDEV_LIST_IGNORE_LOOP = 1 << 3, /* Ignore loopback devices */
|
||||
BLOCKDEV_LIST_IGNORE_PARTITIONS = 1 << 4, /* Ignore partitions */
|
||||
BLOCKDEV_LIST_IGNORE_ZRAM = 1 << 5, /* Ignore ZRAM */
|
||||
BLOCKDEV_LIST_IGNORE_RAMDISK = 1 << 5, /* Ignore RAMDISK (by brd module) and ZRAM (by zram module) */
|
||||
BLOCKDEV_LIST_IGNORE_ROOT = 1 << 6, /* Ignore the block device we are currently booted from */
|
||||
BLOCKDEV_LIST_IGNORE_EMPTY = 1 << 7, /* Ignore disks of zero size (usually drives without a medium) */
|
||||
BLOCKDEV_LIST_IGNORE_READ_ONLY = 1 << 8, /* Ignore read-only block devices */
|
||||
|
||||
@@ -88,7 +88,8 @@ static int parse_argv(int argc, char *argv[]) {
|
||||
|
||||
OPTION_LONG("list-devices", NULL,
|
||||
"List candidate block devices to operate on"):
|
||||
r = blockdev_list(BLOCKDEV_LIST_SHOW_SYMLINKS|BLOCKDEV_LIST_IGNORE_ZRAM, /* ret_devices= */ NULL, /* ret_n_devices= */ NULL);
|
||||
r = blockdev_list(BLOCKDEV_LIST_SHOW_SYMLINKS|BLOCKDEV_LIST_IGNORE_RAMDISK,
|
||||
/* ret_devices= */ NULL, /* ret_n_devices= */ NULL);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
@@ -912,7 +913,7 @@ static int device_added(Context *c, sd_device *device) {
|
||||
|
||||
log_device_debug(device, "new block device '%s'", sysname);
|
||||
|
||||
if (STARTSWITH_SET(sysname, "loop", "zram")) /* Ignore some devices */
|
||||
if (STARTSWITH_SET(sysname, "loop", "ram", "zram")) /* Ignore some devices */
|
||||
return 0;
|
||||
|
||||
const char *devname;
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
* $SYSTEMD_SYSINSTALL_PERMIT_AUTO_TARGET_LOOP env var says otherwise, see auto_device_list_flags()). */
|
||||
#define AUTO_DEVICE_LIST_FLAGS \
|
||||
(BLOCKDEV_LIST_REQUIRE_PARTITION_SCANNING | \
|
||||
BLOCKDEV_LIST_IGNORE_ZRAM | \
|
||||
BLOCKDEV_LIST_IGNORE_RAMDISK | \
|
||||
BLOCKDEV_LIST_IGNORE_READ_ONLY | \
|
||||
BLOCKDEV_LIST_IGNORE_ROOT | \
|
||||
BLOCKDEV_LIST_IGNORE_EMPTY | \
|
||||
|
||||
Reference in New Issue
Block a user