X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=elogind.git;a=blobdiff_plain;f=src%2Fcore%2Fmanager.h;h=bd068ac3c9627fdd96f797d19d3e083685e804eb;hp=9ecc926cbfd403ad851e46b66bb7d039f9c7579a;hb=ddc77f62244bb41d5c8261517e2e1ff1b763fc94;hpb=b30e2f4c18ad81b04e4314fd191a5d458553773c diff --git a/src/core/manager.h b/src/core/manager.h index 9ecc926cb..bd068ac3c 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. @@ -9,16 +8,16 @@ Copyright 2010 Lennart Poettering systemd is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or + under the terms of the GNU Lesser General Public License as published by + the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. systemd is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. + Lesser General Public License for more details. - You should have received a copy of the GNU General Public License + You should have received a copy of the GNU Lesser General Public License along with systemd; If not, see . ***/ @@ -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 */ @@ -45,17 +45,11 @@ typedef enum ManagerExitCode { MANAGER_POWEROFF, MANAGER_HALT, MANAGER_KEXEC, + MANAGER_SWITCH_ROOT, _MANAGER_EXIT_CODE_MAX, _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, @@ -67,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 { @@ -90,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 @@ -104,6 +103,9 @@ 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. */ @@ -123,9 +125,8 @@ struct Manager { /* Units to check when doing GC */ LIST_HEAD(Unit, gc_queue); - /* Jobs to be added */ - Hashmap *transaction_jobs; /* Unit object => Job object list 1:1 */ - JobDependency *transaction_anchor; + /* Units that should be realized */ + LIST_HEAD(Unit, cgroup_queue); Hashmap *watch_pids; /* pid => Unit object n:1 */ @@ -133,6 +134,9 @@ struct Manager { Watch notify_watch; Watch signal_watch; + Watch time_change_watch; + Watch jobs_in_progress_watch; + Watch idle_pipe_watch; int epoll_fd; @@ -142,16 +146,24 @@ 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; + char *generator_unit_path_late; /* Data specific to the device subsystem */ struct udev* udev; @@ -185,6 +197,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; @@ -192,10 +206,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; @@ -203,13 +217,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; @@ -220,22 +229,31 @@ struct Manager { bool show_status; bool confirm_spawn; -#ifdef HAVE_SYSV_COMPAT - bool sysv_console; -#endif - bool mount_auto; - bool swap_auto; + bool no_console_output; ExecOutput default_std_output, default_std_error; + struct rlimit *rlimit[RLIMIT_NLIMITS]; + /* non-zero if we are reloading or reexecuting, */ int n_reloading; 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[4]; + + char *switch_root; + char *switch_root_init; }; -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); @@ -245,11 +263,11 @@ 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_from_dbus_path(Manager *m, const char *s, Unit **_u); 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); int manager_load_unit(Manager *m, const char *name, const char *path, DBusError *e, Unit **_ret); +int manager_load_unit_from_dbus_path(Manager *m, const char *s, DBusError *e, Unit **_u); int manager_add_job(Manager *m, JobType type, Unit *unit, JobMode mode, bool force, DBusError *e, Job **_ret); int manager_add_job_by_name(Manager *m, JobType type, const char *name, JobMode mode, bool force, DBusError *e, Job **_ret); @@ -257,15 +275,14 @@ int manager_add_job_by_name(Manager *m, JobType type, const char *name, JobMode void manager_dump_units(Manager *s, FILE *f, const char *prefix); void manager_dump_jobs(Manager *s, FILE *f, const char *prefix); -void manager_transaction_unlink_job(Manager *m, Job *j, bool delete_dependencies); - void manager_clear_jobs(Manager *m); 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_set_default_environment(Manager *m, char **environment); +int manager_set_default_rlimits(Manager *m, struct rlimit **default_rlimit); int manager_loop(Manager *m); @@ -274,19 +291,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); @@ -296,9 +314,6 @@ 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); - -const char *manager_running_as_to_string(ManagerRunningAs i); -ManagerRunningAs manager_running_as_from_string(const char *s); +void manager_status_printf(Manager *m, bool ephemeral, const char *status, const char *format, ...) _printf_attr_(4,5); -#endif +void watch_init(Watch *w);