]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
kerne-command-line: introduce option 'systemd.restore_state'
authorTom Gundersen <teg@jklm.no>
Fri, 18 Oct 2013 22:46:07 +0000 (00:46 +0200)
committerTom Gundersen <teg@jklm.no>
Fri, 18 Oct 2013 22:46:10 +0000 (00:46 +0200)
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).

man/kernel-command-line.xml
man/systemd-backlight@.service.xml
man/systemd-rfkill@.service.xml
src/backlight/backlight.c
src/rfkill/rfkill.c
src/shared/util.c
src/shared/util.h

index abe68e549689edc6f917aeafbdb2a061dc9b7c71..612dc28cd513997e3cc2a67bf42e43224283a85c 100644 (file)
                                 </listitem>
                         </varlistentry>
 
+                        <varlistentry>
+                                <term><varname>systemd.restore_state=</varname></term>
+                                <listitem>
+                                        <para>Parameter understood by
+                                        several system tools to control
+                                        whether or not they should restore
+                                        system state from the previous boot.
+                                        For details, see
+                                        <citerefentry><refentrytitle>systemd-backlight@.service</refentrytitle><manvolnum>8</manvolnum></citerefentry>
+                                        and
+                                        <citerefentry><refentrytitle>systemd-rfkill@.service</refentrytitle><manvolnum>8</manvolnum></citerefentry>.
+                                        </para>
+                                </listitem>
+                        </varlistentry>
+
                         <varlistentry>
                                 <term><varname>quiet</varname></term>
                                 <listitem>
                           <citerefentry><refentrytitle>systemd-cryptsetup-generator</refentrytitle><manvolnum>8</manvolnum></citerefentry>,
                           <citerefentry><refentrytitle>systemd-fstab-generator</refentrytitle><manvolnum>8</manvolnum></citerefentry>,
                           <citerefentry><refentrytitle>systemd-modules-load.service</refentrytitle><manvolnum>8</manvolnum></citerefentry>
+                          <citerefentry><refentrytitle>systemd-backlight@.service</refentrytitle><manvolnum>8</manvolnum></citerefentry>
+                          <citerefentry><refentrytitle>systemd-rfkill@.service</refentrytitle><manvolnum>8</manvolnum></citerefentry>
                   </para>
         </refsect1>
 
index 6d26d4b2edda2a0b19999b854ae8bb9e1d3b70b8..672fd05eb354374e1a4dda0010229160abef1bba 100644 (file)
                 <filename>/var/lib/systemd/backlight/</filename>.</para>
         </refsect1>
 
+        <refsect1>
+                <title>Kernel Command Line</title>
+
+                <para><filename>systemd-backlight</filename> understands
+                the following kernel command line parameter:</para>
+
+                <variablelist class='kernel-commandline-options'>
+                        <varlistentry>
+                                <term><varname>systemd.restore_state=</varname></term>
+
+                                <listitem><para>Takes a boolean
+                                argument. Defaults to
+                                <literal>1</literal>. If
+                                <literal>0</literal>, does not restore
+                                the backlight settings on boot. However,
+                                settings will still be stored on shutdown.
+                        </varlistentry>
+                </variablelist>
+        </refsect1>
+
         <refsect1>
                 <title>See Also</title>
                 <para>
index b274cb818b6e33c345deb60712ac6a2369eb55eb..9ae834d5dd187ae3ebbbbd4aa41175caefa75fa4 100644 (file)
                 <filename>/var/lib/systemd/rfkill/</filename>.</para>
         </refsect1>
 
+        <refsect1>
+                <title>Kernel Command Line</title>
+
+                <para><filename>systemd-rfkill</filename> understands
+                the following kernel command line parameter:</para>
+
+                <variablelist class='kernel-commandline-options'>
+                        <varlistentry>
+                                <term><varname>systemd.restore_state=</varname></term>
+
+                                <listitem><para>Takes a boolean
+                                argument. Defaults to
+                                <literal>1</literal>. If
+                                <literal>0</literal>, does not restore
+                                the rfkill settings on boot. However,
+                                settings will still be stored on shutdown.
+                        </varlistentry>
+                </variablelist>
+        </refsect1>
+
         <refsect1>
                 <title>See Also</title>
                 <para>
index e8cdad61edad67b2b34aab8d82d10f4f11879f94..6c00b00d82c64e385948cf3a52139ddf69822c7f 100644 (file)
@@ -24,6 +24,7 @@
 #include "fileio.h"
 #include "libudev.h"
 #include "udev-util.h"
+#include "util.h"
 
 static struct udev_device *find_pci_or_platform_parent(struct udev_device *device) {
         struct udev_device *parent;
@@ -290,7 +291,7 @@ int main(int argc, char *argv[]) {
          * device probing should be complete), so that the validity
          * check at boot time doesn't have to be reliable. */
 
-        if (streq(argv[1], "load")) {
+        if (streq(argv[1], "load") && restore_state()) {
                 _cleanup_free_ char *value = NULL;
 
                 if (!validate_device(udev, device))
index 812cf408fb2aacbe20f890f3e153e470b8f58b07..b814e5c5fc5d287c44dcb36ff6d25fb042c48278 100644 (file)
@@ -24,6 +24,7 @@
 #include "fileio.h"
 #include "libudev.h"
 #include "udev-util.h"
+#include "utils.h"
 
 int main(int argc, char *argv[]) {
         _cleanup_udev_unref_ struct udev *udev = NULL;
@@ -95,7 +96,7 @@ int main(int argc, char *argv[]) {
                 return EXIT_FAILURE;
         }
 
-        if (streq(argv[1], "load")) {
+        if (streq(argv[1], "load") && restore_state()) {
                 _cleanup_free_ char *value = NULL;
 
                 r = read_one_line_file(saved, &value);
index 182277030440d34840ce9d1ad032736d25f5b6be..d086fac7f805c0540458230506af69a289f00524 100644 (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;
+}
index 63cb4ac636967adc8bb8101c725ae4c597a9f60b..dc35b4d9801466fb0d992f45f28828d78a36940f 100644 (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.