kerne-command-line: introduce option 'systemd.restore_state'

When set to 0 this will stop tools like the backlight and rfkill tools to
restore state from previous boot. This is useful in case the stored state
is bogus to the extent that it is preventing you from resetting it (e.g.,
the backlight settings cause the screen to be off on boot on a system where
the backlight can not be adjusted directly from the keyboard).
This commit is contained in:
Tom Gundersen
2013-10-19 00:46:10 +02:00
parent efc815a13d
commit 295edddf5a
7 changed files with 86 additions and 2 deletions
+23
View File
@@ -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;
@@ -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 0;
}
FOREACH_WORD_QUOTED(w, l, line, state)
if (strneq(w, "systemd.restore_state=0", l))
return false;
return true;
}
+2
View File
@@ -765,6 +765,8 @@ void parse_user_at_host(char *arg, char **user, char **host);
int split_pair(const char *s, const char *sep, char **l, char **r);
bool restore_state(void);
/**
* Normal qsort requires base to be nonnull. Here were require
* that only if nmemb > 0.