From 4f9215e70f0c2c589f6d2a4ff43459901ee7d93b Mon Sep 17 00:00:00 2001 From: David Teigland Date: Mon, 5 Feb 2024 13:15:37 -0600 Subject: [PATCH] devices file: rename unused system.devices If lvm.conf has use_devicesfile=0 and /etc/lvm/device/system.devices exists, then rename it to system.devices-unused.YYYYMMDD.HHMMSS. This prevents an old, incorrect system.devices from being used in the future if lvm.conf is changed to use_devicesfile=1. --- lib/device/dev-cache.c | 57 +++++++++++++++++++++++++++++++-- test/shell/devicesfile-basic.sh | 17 ++++++++++ 2 files changed, 72 insertions(+), 2 deletions(-) diff --git a/lib/device/dev-cache.c b/lib/device/dev-cache.c index d61185ff4..3e87ddc3a 100644 --- a/lib/device/dev-cache.c +++ b/lib/device/dev-cache.c @@ -29,6 +29,7 @@ #include #include #include +#include /* coverity[unnecessary_header] needed for MuslC */ #include @@ -1812,7 +1813,51 @@ static int _setup_devices_file_dmeventd(struct cmd_context *cmd) (void) dm_strncpy(cmd->devices_file_path, path, sizeof(cmd->devices_file_path)); return 1; } - + +/* + * When lvm.conf use_devicesfile=0, then an existing system.devices + * is renamed to system.devices-unused..