diff options
Diffstat (limited to 'src/shared')
-rw-r--r-- | src/shared/util.c | 16 |
1 files changed, 5 insertions, 11 deletions
diff --git a/src/shared/util.c b/src/shared/util.c index 5acddd3e0f..4b841491aa 100644 --- a/src/shared/util.c +++ b/src/shared/util.c @@ -5654,16 +5654,10 @@ bool is_valid_documentation_url(const char *url) { } bool in_initrd(void) { - static bool checked=false; - static bool is_in_initrd=false; - - if (!checked) { - struct stat sb; - if (stat("/", &sb) == 0) { - is_in_initrd = (sb.st_dev == 1); - checked = true; - } - } + static int saved = -1; + + if (saved < 0) + saved = access("/etc/initrd-release", F_OK) >= 0; - return is_in_initrd; + return saved; } |