diff options
author | Lennart Poettering <lennart@poettering.net> | 2017-12-15 18:53:03 +0100 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2017-12-15 20:52:28 +0100 |
commit | aa40ff070391e1a5eebafcec834a59973fbaac00 (patch) | |
tree | d3cbb7ead601e7446633e69cdc75849dab341040 /src | |
parent | b9e90f3aa6af0ee5b59bbf249ec852d56e814c83 (diff) | |
download | systemd-aa40ff070391e1a5eebafcec834a59973fbaac00.tar.gz systemd-aa40ff070391e1a5eebafcec834a59973fbaac00.tar.bz2 systemd-aa40ff070391e1a5eebafcec834a59973fbaac00.zip |
main: split out 'skip_setup' check into its own functions
And let's optimize it a tiny bit, by only iterating through the argument
list once, instead of twice.
Diffstat (limited to 'src')
-rw-r--r-- | src/core/main.c | 32 |
1 files changed, 21 insertions, 11 deletions
diff --git a/src/core/main.c b/src/core/main.c index ab9f3db276..20d5c53bb5 100644 --- a/src/core/main.c +++ b/src/core/main.c @@ -2270,6 +2270,25 @@ static void setup_console_terminal(bool skip_setup) { (void) console_setup(); } +static bool early_skip_setup_check(int argc, char *argv[]) { + bool found_deserialize = false; + int i; + + /* Determine if this is a reexecution or normal bootup. We do the full command line parsing much later, so + * let's just have a quick peek here. Note that if we have switched root, do all the special setup things + * anyway, even if in that case we also do deserialization. */ + + for (i = 1; i < argc; i++) { + + if (streq(argv[i], "--switched-root")) + return false; /* If we switched root, don't skip the setup. */ + else if (streq(argv[i], "--deserialize")) + found_deserialize = true; + } + + return found_deserialize; /* When we are deserializing, then we are reexecuting, hence avoid the extensive setup */ +} + int main(int argc, char *argv[]) { Manager *m = NULL; int r, retval = EXIT_FAILURE; @@ -2284,7 +2303,7 @@ int main(int argc, char *argv[]) { dual_timestamp security_start_timestamp = DUAL_TIMESTAMP_NULL; dual_timestamp security_finish_timestamp = DUAL_TIMESTAMP_NULL; static char systemd[] = "systemd"; - bool skip_setup = false; + bool skip_setup; bool loaded_policy = false; bool queue_default_job = false; bool first_boot = false; @@ -2297,16 +2316,7 @@ int main(int argc, char *argv[]) { dual_timestamp_from_monotonic(&kernel_timestamp, 0); dual_timestamp_get(&userspace_timestamp); - /* Determine if this is a reexecution or normal bootup. We do - * the full command line parsing much later, so let's just - * have a quick peek here. */ - if (strv_find(argv+1, "--deserialize")) - skip_setup = true; - - /* If we have switched root, do all the special setup - * things */ - if (strv_find(argv+1, "--switched-root")) - skip_setup = false; + skip_setup = early_skip_setup_check(argc, argv); /* If we get started via the /sbin/init symlink then we are called 'init'. After a subsequent reexecution we are then |