X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=src%2Fcore%2Fmanager.h;h=a3049b5e5b665fe7937ca4cf2a3274cdb8670732;hb=da7e457c5b9339721454ae8401a03ffdd781e6a9;hp=b29d0a79353e43af072579bd01b21f6e325b60a5;hpb=07719a21b6425d378b36bb8d7f47ad5ec5296d28;p=elogind.git diff --git a/src/core/manager.h b/src/core/manager.h index b29d0a793..a3049b5e5 100644 --- a/src/core/manager.h +++ b/src/core/manager.h @@ -1,7 +1,6 @@ /*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/ -#ifndef foomanagerhfoo -#define foomanagerhfoo +#pragma once /*** This file is part of systemd. @@ -28,6 +27,7 @@ #include #include "fdset.h" +#include "cgroup-util.h" /* Enforce upper limit how many names we allow */ #define MANAGER_MAX_NAMES 131072 /* 128K */ @@ -50,13 +50,6 @@ typedef enum ManagerExitCode { _MANAGER_EXIT_CODE_INVALID = -1 } ManagerExitCode; -typedef enum ManagerRunningAs { - MANAGER_SYSTEM, - MANAGER_USER, - _MANAGER_RUNNING_AS_MAX, - _MANAGER_RUNNING_AS_INVALID = -1 -} ManagerRunningAs; - enum WatchType { WATCH_INVALID, WATCH_SIGNAL, @@ -68,7 +61,10 @@ enum WatchType { WATCH_SWAP, WATCH_UDEV, WATCH_DBUS_WATCH, - WATCH_DBUS_TIMEOUT + WATCH_DBUS_TIMEOUT, + WATCH_TIME_CHANGE, + WATCH_JOBS_IN_PROGRESS, + WATCH_IDLE_PIPE, }; struct Watch { @@ -91,6 +87,8 @@ struct Watch { #include "set.h" #include "dbus.h" #include "path-lookup.h" +#include "execute.h" +#include "unit-name.h" struct Manager { /* Note that the set of units we know of is allowed to be @@ -105,9 +103,6 @@ struct Manager { * type we maintain a per type linked list */ LIST_HEAD(Unit, units_by_type[_UNIT_TYPE_MAX]); - /* To optimize iteration of units that have requires_mounts_for set */ - LIST_HEAD(Unit, has_requires_mounts_for); - /* Units that need to be loaded */ LIST_HEAD(Unit, load_queue); /* this is actually more a stack than a queue, but uh. */ @@ -127,12 +122,18 @@ struct Manager { /* Units to check when doing GC */ LIST_HEAD(Unit, gc_queue); + /* Units that should be realized */ + LIST_HEAD(Unit, cgroup_queue); + Hashmap *watch_pids; /* pid => Unit object n:1 */ char *notify_socket; Watch notify_watch; Watch signal_watch; + Watch time_change_watch; + Watch jobs_in_progress_watch; + Watch idle_pipe_watch; int epoll_fd; @@ -142,14 +143,20 @@ struct Manager { Set *unit_path_cache; char **environment; - char **default_controllers; usec_t runtime_watchdog; usec_t shutdown_watchdog; + dual_timestamp firmware_timestamp; + dual_timestamp loader_timestamp; + dual_timestamp kernel_timestamp; dual_timestamp initrd_timestamp; - dual_timestamp startup_timestamp; + dual_timestamp userspace_timestamp; dual_timestamp finish_timestamp; + dual_timestamp generators_start_timestamp; + dual_timestamp generators_finish_timestamp; + dual_timestamp unitsload_start_timestamp; + dual_timestamp unitsload_finish_timestamp; char *generator_unit_path; char *generator_unit_path_early; @@ -187,6 +194,8 @@ struct Manager { int32_t conn_data_slot; int32_t subscribed_data_slot; + bool send_reloading_done; + uint32_t current_job_id; uint32_t default_unit_job_id; @@ -194,10 +203,10 @@ struct Manager { int dev_autofs_fd; /* Data specific to the cgroup subsystem */ - Hashmap *cgroup_bondings; /* path string => CGroupBonding object 1:n */ - char *cgroup_hierarchy; + Hashmap *cgroup_unit; + CGroupControllerMask cgroup_supported; + char *cgroup_root; - usec_t gc_queue_timestamp; int gc_marker; unsigned n_in_gc_queue; @@ -205,13 +214,8 @@ struct Manager { * file system */ int pin_cgroupfs_fd; - /* Audit fd */ -#ifdef HAVE_AUDIT - int audit_fd; -#endif - /* Flags */ - ManagerRunningAs running_as; + SystemdRunningAs running_as; ManagerExitCode exit_code:5; bool dispatching_load_queue:1; @@ -222,9 +226,7 @@ struct Manager { bool show_status; bool confirm_spawn; -#ifdef HAVE_SYSV_COMPAT - bool sysv_console; -#endif + bool no_console_output; ExecOutput default_std_output, default_std_error; @@ -236,14 +238,24 @@ struct Manager { unsigned n_installed_jobs; unsigned n_failed_jobs; + /* Jobs in progress watching */ + unsigned n_running_jobs; + unsigned n_on_console; + unsigned jobs_in_progress_iteration; + /* Type=idle pipes */ - int idle_pipe[2]; + int idle_pipe[4]; char *switch_root; char *switch_root_init; + + /* 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. */ + Hashmap *units_requiring_mounts_for; }; -int manager_new(ManagerRunningAs running_as, Manager **m); +int manager_new(SystemdRunningAs running_as, bool reexecuting, Manager **m); void manager_free(Manager *m); int manager_enumerate(Manager *m); @@ -253,6 +265,8 @@ int manager_startup(Manager *m, FILE *serialization, FDSet *fds); Job *manager_get_job(Manager *m, uint32_t id); Unit *manager_get_unit(Manager *m, const char *name); +int manager_get_unit_by_path(Manager *m, const char *path, const char *suffix, Unit **_found); + int manager_get_job_from_dbus_path(Manager *m, const char *s, Job **_j); int manager_load_unit_prepare(Manager *m, const char *name, const char *path, DBusError *e, Unit **_ret); @@ -271,7 +285,7 @@ unsigned manager_dispatch_load_queue(Manager *m); unsigned manager_dispatch_run_queue(Manager *m); unsigned manager_dispatch_dbus_queue(Manager *m); -int manager_set_default_controllers(Manager *m, char **controllers); +int manager_environment_add(Manager *m, char **environment); int manager_set_default_rlimits(Manager *m, struct rlimit **default_rlimit); int manager_loop(Manager *m); @@ -281,19 +295,20 @@ void manager_dispatch_bus_query_pid_done(Manager *m, const char *name, pid_t pid int manager_open_serialization(Manager *m, FILE **_f); -int manager_serialize(Manager *m, FILE *f, FDSet *fds); +int manager_serialize(Manager *m, FILE *f, FDSet *fds, bool switching_root); int manager_deserialize(Manager *m, FILE *f, FDSet *fds); +int manager_distribute_fds(Manager *m, FDSet *fds); int manager_reload(Manager *m); -bool manager_is_booting_or_shutting_down(Manager *m); +bool manager_is_reloading_or_reexecuting(Manager *m) _pure_; void manager_reset_failed(Manager *m); void manager_send_unit_audit(Manager *m, Unit *u, int type, bool success); void manager_send_unit_plymouth(Manager *m, Unit *u); -bool manager_unit_pending_inactive(Manager *m, const char *name); +bool manager_unit_inactive_or_pending(Manager *m, const char *name); void manager_check_finished(Manager *m); @@ -303,9 +318,8 @@ void manager_undo_generators(Manager *m); void manager_recheck_journal(Manager *m); void manager_set_show_status(Manager *m, bool b); -bool manager_get_show_status(Manager *m); +void manager_status_printf(Manager *m, bool ephemeral, const char *status, const char *format, ...) _printf_attr_(4,5); -const char *manager_running_as_to_string(ManagerRunningAs i); -ManagerRunningAs manager_running_as_from_string(const char *s); +Set *manager_get_units_requiring_mounts_for(Manager *m, const char *path); -#endif +void watch_init(Watch *w);