X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=src%2Fshared%2Futil.c;h=ef3b67b597594597e0c005fa628565158b493076;hb=275b39fe4bf19f244114dbefa58e0d77047eff4a;hp=182277030440d34840ce9d1ad032736d25f5b6be;hpb=a8ccacf5344c4434b1d5ff3837307acb8fcf93d2;p=elogind.git diff --git a/src/shared/util.c b/src/shared/util.c index 182277030..ef3b67b59 100644 --- a/src/shared/util.c +++ b/src/shared/util.c @@ -76,6 +76,7 @@ #include "device-nodes.h" #include "utf8.h" #include "gunicode.h" +#include "virt.h" int saved_argc = 0; char **saved_argv = NULL; @@ -1362,7 +1363,7 @@ char *bus_path_escape(const char *s) { assert(s); /* Escapes all chars that D-Bus' object path cannot deal - * with. Can be reverse with bus_path_unescape(). We special + * with. Can be reversed with bus_path_unescape(). We special * case the empty string. */ if (*s == 0) @@ -5990,3 +5991,25 @@ int split_pair(const char *s, const char *sep, char **l, char **r) { return 0; } + +bool restore_state(void) { + _cleanup_free_ char *line; + char *w, *state; + int r; + size_t l; + + if (detect_container(NULL) > 0) + return true; + + r = read_one_line_file("/proc/cmdline", &line); + if (r < 0) { + log_warning("Failed to read /proc/cmdline, ignoring: %s", strerror(-r)); + return true; /* something is very wrong, let's not make it worse */ + } + + FOREACH_WORD_QUOTED(w, l, line, state) + if (strneq(w, "systemd.restore_state=0", l)) + return false; + + return true; +}