diff options
author | Ivan Shapovalov <intelfx@intelfx.name> | 2016-06-13 18:28:42 +0400 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2016-06-13 16:28:42 +0200 |
commit | dcd61450026c281c916f12c2affa220e0994ba19 (patch) | |
tree | c860dab75fc7750b38c4752c87dfd19f82a48b47 /src/basic/util.c | |
parent | 68884a0b8a29ce8a7c2a2671b84e2c7b9c6cb674 (diff) |
core: parse `rd.rescue` and `rd.emergency` as initrd-specific shorthands (#3488)
Typing `rd.rescue` is easier than `rd.systemd.unit=rescue.target`.
Diffstat (limited to 'src/basic/util.c')
-rw-r--r-- | src/basic/util.c | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/src/basic/util.c b/src/basic/util.c index 756c663be4..f2f92fb3b7 100644 --- a/src/basic/util.c +++ b/src/basic/util.c @@ -64,6 +64,7 @@ assert_cc(EAGAIN == EWOULDBLOCK); int saved_argc = 0; char **saved_argv = NULL; +static int saved_in_initrd = -1; size_t page_size(void) { static thread_local size_t pgsz = 0; @@ -454,11 +455,10 @@ int fork_agent(pid_t *pid, const int except[], unsigned n_except, const char *pa } bool in_initrd(void) { - static int saved = -1; struct statfs s; - if (saved >= 0) - return saved; + if (saved_in_initrd >= 0) + return saved_in_initrd; /* We make two checks here: * @@ -470,11 +470,15 @@ bool in_initrd(void) { * emptying when transititioning to the main systemd. */ - saved = access("/etc/initrd-release", F_OK) >= 0 && - statfs("/", &s) >= 0 && - is_temporary_fs(&s); + saved_in_initrd = access("/etc/initrd-release", F_OK) >= 0 && + statfs("/", &s) >= 0 && + is_temporary_fs(&s); - return saved; + return saved_in_initrd; +} + +void in_initrd_force(bool value) { + saved_in_initrd = value; } /* hey glibc, APIs with callbacks without a user pointer are so useless */ |