[systemd-commits] TODO src/shared
Lennart Poettering
lennart at kemper.freedesktop.org
Mon May 21 11:02:56 PDT 2012
TODO | 2 --
src/shared/util.c | 16 +++++-----------
2 files changed, 5 insertions(+), 13 deletions(-)
New commits:
commit 8f33b5b8b3e85f9c3b00eb004e601f7a72fa6461
Author: Lennart Poettering <lennart at poettering.net>
Date: Mon May 21 20:00:58 2012 +0200
util: rework in_initrd() logic
Checking the device major/minor is not a good idea. Let's replace this
with an explicit flag file, which we model after /etc/os-release and
call /etc/initrd-release.
diff --git a/TODO b/TODO
index b147d3a..da8bef6 100644
--- a/TODO
+++ b/TODO
@@ -53,8 +53,6 @@ Features:
* actually queue the new default unit after switch-root
-* remove old root in switch-root logic
-
* improve !/proc/*/loginuid situation: make /proc/*/loginuid less dependent on CONFIG_AUDIT,
or use the users cgroup information when /proc/*/loginuid is not available.
diff --git a/src/shared/util.c b/src/shared/util.c
index 5acddd3..4b84149 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;
}
More information about the systemd-commits
mailing list