From: Yu Watanabe Date: Mon, 12 Dec 2022 13:03:52 +0000 (+0900) Subject: sd-id128: make sd_id128_get_boot() and friend return -ENOSYS when /proc/ is not mounted X-Git-Tag: v253-rc1~315^2~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e2720340e9fdf3aee2e8998dc72798de50be3630;p=thirdparty%2Fsystemd.git sd-id128: make sd_id128_get_boot() and friend return -ENOSYS when /proc/ is not mounted --- diff --git a/src/libsystemd/sd-id128/sd-id128.c b/src/libsystemd/sd-id128/sd-id128.c index 70b1a10c748..8f9801ae37a 100644 --- a/src/libsystemd/sd-id128/sd-id128.c +++ b/src/libsystemd/sd-id128/sd-id128.c @@ -15,6 +15,7 @@ #include "macro.h" #include "missing_syscall.h" #include "random-util.h" +#include "stat-util.h" #include "user-util.h" _public_ char *sd_id128_to_string(sd_id128_t id, char s[_SD_ARRAY_STATIC SD_ID128_STRING_MAX]) { @@ -146,6 +147,8 @@ _public_ int sd_id128_get_boot(sd_id128_t *ret) { if (sd_id128_is_null(saved_boot_id)) { r = id128_read("/proc/sys/kernel/random/boot_id", ID128_FORMAT_UUID, &saved_boot_id); + if (r == -ENOENT && proc_mounted() == 0) + return -ENOSYS; if (r < 0) return r;