From: Daan De Meyer Date: Sat, 8 Feb 2025 11:44:19 +0000 (+0100) Subject: storagetm: Check if /sys/kernel/config is a mountpoint X-Git-Tag: v258-rc1~1376 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=dc90f083d0e05c38b64e103d4ac984a4bba0fbea;p=thirdparty%2Fsystemd.git storagetm: Check if /sys/kernel/config is a mountpoint Otherwise we'll fail with an unclear error later on so let's check this first before continuing. --- diff --git a/src/storagetm/storagetm.c b/src/storagetm/storagetm.c index ca8e886d37d..c0735c4658f 100644 --- a/src/storagetm/storagetm.c +++ b/src/storagetm/storagetm.c @@ -18,6 +18,7 @@ #include "local-addresses.h" #include "loop-util.h" #include "main-func.h" +#include "mountpoint-util.h" #include "os-util.h" #include "parse-argument.h" #include "path-util.h" @@ -1128,6 +1129,14 @@ static int run(int argc, char* argv[]) { if (r <= 0) return r; + /* If systemd-storagetm is invoked outside of it's unit /sys/kernel/config/ might not be mounted yet, + * so let's check explicitly whether it is mounted or not. */ + r = path_is_mount_point("/sys/kernel/config"); + if (r < 0) + return log_error_errno(r, "Failed to check if the configfs filesystem is mounted at /sys/kernel/config/: %m"); + if (r == 0) + return log_error_errno(SYNTHETIC_ERRNO(ENOENT), "The configfs filesystem must be mounted at /sys/kernel/config/ to be able to use systemd-storagetm"); + r = sd_event_new(&event); if (r < 0) return log_error_errno(r, "Failed to allocate event loop: %m");