summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2018-09-26 07:15:55 +0200
committerSven Eden <sven.eden@prydeworx.com>2018-10-29 10:18:29 +0100
commit9b52f3360e2a499991bc1565d6d97e9a7e3d758b (patch)
tree1d0250aa37509f3fb46c5dd3e00f5d362f392417 /src
parentc4705b5d1886b1d4f8a6e0ef55a4e3f3b620e97e (diff)
Add $SYSTEMD_IN_INITRD=yes|no override for debugging
(cherry picked from commit 0307ea49c70b1ed4f3af3c80566c8c098dc080bb)
Diffstat (limited to 'src')
-rw-r--r--src/basic/util.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/src/basic/util.c b/src/basic/util.c
index d2ebb4516..6f3f505f7 100644
--- a/src/basic/util.c
+++ b/src/basic/util.c
@@ -23,6 +23,7 @@
//#include "def.h"
//#include "device-nodes.h"
#include "dirent-util.h"
+//#include "env-util.h"
#include "fd-util.h"
#include "fileio.h"
//#include "format-util.h"
@@ -135,6 +136,7 @@ int prot_from_flags(int flags) {
bool in_initrd(void) {
struct statfs s;
+ int r;
if (saved_in_initrd >= 0)
return saved_in_initrd;
@@ -149,9 +151,16 @@ bool in_initrd(void) {
* emptying when transititioning to the main systemd.
*/
- saved_in_initrd = access("/etc/initrd-release", F_OK) >= 0 &&
- statfs("/", &s) >= 0 &&
- is_temporary_fs(&s);
+ r = getenv_bool_secure("SYSTEMD_IN_INITRD");
+ if (r < 0 && r != -ENXIO)
+ log_debug_errno(r, "Failed to parse $SYSTEMD_IN_INITRD, ignoring: %m");
+
+ if (r >= 0)
+ saved_in_initrd = r > 0;
+ else
+ saved_in_initrd = access("/etc/initrd-release", F_OK) >= 0 &&
+ statfs("/", &s) >= 0 &&
+ is_temporary_fs(&s);
return saved_in_initrd;
}