core: introduce MANAGER_IS_SWITCHING_ROOT() helper function

Will be used by the following commit.
This commit is contained in:
Franck Bui
2022-08-05 22:13:43 +09:00
committed by Yu Watanabe
parent 578355684d
commit d35fe8c0af
3 changed files with 15 additions and 0 deletions
+3
View File
@@ -1966,6 +1966,8 @@ static int invoke_main_loop(
return objective;
case MANAGER_SWITCH_ROOT:
manager_set_switching_root(m, true);
if (!m->switch_root_init) {
r = prepare_reexecute(m, &arg_serialization, ret_fds, true);
if (r < 0) {
@@ -2943,6 +2945,7 @@ int main(int argc, char *argv[]) {
set_manager_defaults(m);
set_manager_settings(m);
manager_set_first_boot(m, first_boot);
manager_set_switching_root(m, arg_switched_root);
/* Remember whether we should queue the default job */
queue_default_job = !arg_serialization || arg_switched_root;
+6
View File
@@ -807,6 +807,10 @@ static int manager_find_credentials_dirs(Manager *m) {
return 0;
}
void manager_set_switching_root(Manager *m, bool switching_root) {
m->switching_root = MANAGER_IS_SYSTEM(m) && switching_root;
}
int manager_new(LookupScope scope, ManagerTestRunFlags test_run_flags, Manager **_m) {
_cleanup_(manager_freep) Manager *m = NULL;
int r;
@@ -1872,6 +1876,8 @@ int manager_startup(Manager *m, FILE *serialization, FDSet *fds, const char *roo
manager_ready(m);
manager_set_switching_root(m, false);
return 0;
}
+6
View File
@@ -406,6 +406,9 @@ struct Manager {
char *switch_root;
char *switch_root_init;
/* This is true before and after switching root. */
bool switching_root;
/* This maps all possible path prefixes to the units needing
* them. It's a hashmap with a path string as key and a Set as
* value where Unit objects are contained. */
@@ -476,6 +479,8 @@ static inline usec_t manager_default_timeout_abort_usec(Manager *m) {
/* The objective is set to OK as soon as we enter the main loop, and set otherwise as soon as we are done with it */
#define MANAGER_IS_RUNNING(m) ((m)->objective == MANAGER_OK)
#define MANAGER_IS_SWITCHING_ROOT(m) ((m)->switching_root)
#define MANAGER_IS_TEST_RUN(m) ((m)->test_run_flags != 0)
int manager_new(LookupScope scope, ManagerTestRunFlags test_run_flags, Manager **m);
@@ -541,6 +546,7 @@ void manager_set_show_status(Manager *m, ShowStatus mode, const char *reason);
void manager_override_show_status(Manager *m, ShowStatus mode, const char *reason);
void manager_set_first_boot(Manager *m, bool b);
void manager_set_switching_root(Manager *m, bool switching_root);
void manager_status_printf(Manager *m, StatusType type, const char *status, const char *format, ...) _printf_(4,5);