This is just paranoia, to ensure that we don't accidentally
initiate resume if the initrd is entered through soft-reboot
rather than the initial one for booting up.
return 0;
}
+ if (generator_soft_rebooted()) {
+ log_debug("Running in an initrd entered through soft-reboot, not initiating resume.");
+ return 0;
+ }
+
r = proc_cmdline_parse(parse_proc_cmdline_item, NULL, 0);
if (r < 0)
log_warning_errno(r, "Failed to parse kernel command line, ignoring: %m");
#include "macro.h"
#include "mkdir-label.h"
#include "mountpoint-util.h"
+#include "parse-util.h"
#include "path-util.h"
#include "process-util.h"
#include "special.h"
log_parse_environment();
log_open();
}
+
+bool generator_soft_rebooted(void) {
+ static int cached = -1;
+ int r;
+
+ if (cached >= 0)
+ return cached;
+
+ const char *e = secure_getenv("SYSTEMD_SOFT_REBOOTS_COUNT");
+ if (!e)
+ return (cached = false);
+
+ unsigned u;
+
+ r = safe_atou(e, &u);
+ if (r < 0) {
+ log_debug_errno(r, "Failed to parse $SYSTEMD_SOFT_REBOOTS_COUNT, assuming the system hasn't soft-rebooted: %m");
+ return (cached = false);
+ }
+
+ return (cached = u > 0);
+}
void log_setup_generator(void);
+bool generator_soft_rebooted(void);
+
/* Similar to DEFINE_MAIN_FUNCTION, but initializes logging and assigns positional arguments. */
#define DEFINE_MAIN_GENERATOR_FUNCTION(impl) \
_DEFINE_MAIN_FUNCTION( \