manager.h revision e46b13c8c7f48f81d4e09912f2265daaa7f6d27e
2087a7aff26ea5d1bc2c7c29add3275328f36baaLennart Poettering/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
2087a7aff26ea5d1bc2c7c29add3275328f36baaLennart Poettering This file is part of systemd.
2087a7aff26ea5d1bc2c7c29add3275328f36baaLennart Poettering Copyright 2010 Lennart Poettering
2087a7aff26ea5d1bc2c7c29add3275328f36baaLennart Poettering systemd is free software; you can redistribute it and/or modify it
2087a7aff26ea5d1bc2c7c29add3275328f36baaLennart Poettering under the terms of the GNU Lesser General Public License as published by
2087a7aff26ea5d1bc2c7c29add3275328f36baaLennart Poettering the Free Software Foundation; either version 2.1 of the License, or
2087a7aff26ea5d1bc2c7c29add3275328f36baaLennart Poettering (at your option) any later version.
2087a7aff26ea5d1bc2c7c29add3275328f36baaLennart Poettering systemd is distributed in the hope that it will be useful, but
2087a7aff26ea5d1bc2c7c29add3275328f36baaLennart Poettering WITHOUT ANY WARRANTY; without even the implied warranty of
2087a7aff26ea5d1bc2c7c29add3275328f36baaLennart Poettering MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
2087a7aff26ea5d1bc2c7c29add3275328f36baaLennart Poettering Lesser General Public License for more details.
2087a7aff26ea5d1bc2c7c29add3275328f36baaLennart Poettering You should have received a copy of the GNU Lesser General Public License
2087a7aff26ea5d1bc2c7c29add3275328f36baaLennart Poettering along with systemd; If not, see <http://www.gnu.org/licenses/>.
4d7859d173282e16bb75254c2b4ec14a915ef30bKay Sievers/* Enforce upper limit how many names we allow */
2087a7aff26ea5d1bc2c7c29add3275328f36baaLennart Poettering /* Note that the set of units we know of is allowed to be
2087a7aff26ea5d1bc2c7c29add3275328f36baaLennart Poettering * inconsistent. However the subset of it that is loaded may
2087a7aff26ea5d1bc2c7c29add3275328f36baaLennart Poettering * not, and the list of jobs may neither. */
2087a7aff26ea5d1bc2c7c29add3275328f36baaLennart Poettering /* Active jobs and units */
2087a7aff26ea5d1bc2c7c29add3275328f36baaLennart Poettering Hashmap *units; /* name string => Unit object n:1 */
2087a7aff26ea5d1bc2c7c29add3275328f36baaLennart Poettering Hashmap *jobs; /* job id => Job object 1:1 */
2087a7aff26ea5d1bc2c7c29add3275328f36baaLennart Poettering /* To make it easy to iterate through the units of a specific
2087a7aff26ea5d1bc2c7c29add3275328f36baaLennart Poettering * type we maintain a per type linked list */
2087a7aff26ea5d1bc2c7c29add3275328f36baaLennart Poettering LIST_HEAD(Unit, units_by_type[_UNIT_TYPE_MAX]);
2087a7aff26ea5d1bc2c7c29add3275328f36baaLennart Poettering /* Units that need to be loaded */
2087a7aff26ea5d1bc2c7c29add3275328f36baaLennart Poettering LIST_HEAD(Unit, load_queue); /* this is actually more a stack than a queue, but uh. */
2087a7aff26ea5d1bc2c7c29add3275328f36baaLennart Poettering /* Jobs that need to be run */
2087a7aff26ea5d1bc2c7c29add3275328f36baaLennart Poettering LIST_HEAD(Job, run_queue); /* more a stack than a queue, too */
2087a7aff26ea5d1bc2c7c29add3275328f36baaLennart Poettering /* Units and jobs that have not yet been announced via
2087a7aff26ea5d1bc2c7c29add3275328f36baaLennart Poettering * D-Bus. When something about a job changes it is added here
2087a7aff26ea5d1bc2c7c29add3275328f36baaLennart Poettering * if it is not in there yet. This allows easy coalescing of
2087a7aff26ea5d1bc2c7c29add3275328f36baaLennart Poettering * D-Bus change signals. */
2087a7aff26ea5d1bc2c7c29add3275328f36baaLennart Poettering /* Units to remove */
2087a7aff26ea5d1bc2c7c29add3275328f36baaLennart Poettering /* Units to check when doing GC */
9f6eb1cd58f2ddf2eb6ba0e4de056e13d938af75Kay Sievers /* Units that should be realized */
9f6eb1cd58f2ddf2eb6ba0e4de056e13d938af75Kay Sievers /* We use two hash tables here, since the same PID might be
9f6eb1cd58f2ddf2eb6ba0e4de056e13d938af75Kay Sievers * watched by two different units: once the unit that forked
9f6eb1cd58f2ddf2eb6ba0e4de056e13d938af75Kay Sievers * it off, and possibly a different unit to which it was
9f6eb1cd58f2ddf2eb6ba0e4de056e13d938af75Kay Sievers * joined as cgroup member. Since we know that it is either
ffc06c3513d9a0693c7f810d03b20705127ba55aKay Sievers * one or two units for each PID we just use to hashmaps
ffc06c3513d9a0693c7f810d03b20705127ba55aKay Sievers Hashmap *watch_pids1; /* pid => Unit object n:1 */
2087a7aff26ea5d1bc2c7c29add3275328f36baaLennart Poettering Hashmap *watch_pids2; /* pid => Unit object n:1 */
2087a7aff26ea5d1bc2c7c29add3275328f36baaLennart Poettering /* A set contains all units which cgroup should be refreshed after startup */
ffc06c3513d9a0693c7f810d03b20705127ba55aKay Sievers /* A set which contains all currently failed units */
2087a7aff26ea5d1bc2c7c29add3275328f36baaLennart Poettering dual_timestamp security_finish_timestamp;
2087a7aff26ea5d1bc2c7c29add3275328f36baaLennart Poettering dual_timestamp generators_finish_timestamp;
2087a7aff26ea5d1bc2c7c29add3275328f36baaLennart Poettering dual_timestamp units_load_finish_timestamp;
2087a7aff26ea5d1bc2c7c29add3275328f36baaLennart Poettering /* Data specific to the device subsystem */
2087a7aff26ea5d1bc2c7c29add3275328f36baaLennart Poettering /* Data specific to the mount subsystem */
2087a7aff26ea5d1bc2c7c29add3275328f36baaLennart Poettering /* Data specific to the swap filesystem */
2087a7aff26ea5d1bc2c7c29add3275328f36baaLennart Poettering /* Data specific to the D-Bus subsystem */
2087a7aff26ea5d1bc2c7c29add3275328f36baaLennart Poettering sd_event_source *private_listen_event_source;
2087a7aff26ea5d1bc2c7c29add3275328f36baaLennart Poettering /* Contains all the clients that are subscribed to signals via
2087a7aff26ea5d1bc2c7c29add3275328f36baaLennart Poettering the API bus. Note that private bus connections are always
2087a7aff26ea5d1bc2c7c29add3275328f36baaLennart Poettering considered subscribes, since they last for very short only,
2087a7aff26ea5d1bc2c7c29add3275328f36baaLennart Poettering and it is much simpler that way. */
2087a7aff26ea5d1bc2c7c29add3275328f36baaLennart Poettering sd_bus_message *queued_message; /* This is used during reloading:
2087a7aff26ea5d1bc2c7c29add3275328f36baaLennart Poettering * before the reload we queue the
2087a7aff26ea5d1bc2c7c29add3275328f36baaLennart Poettering * reply message here, and
2087a7aff26ea5d1bc2c7c29add3275328f36baaLennart Poettering * afterwards we send it */
2087a7aff26ea5d1bc2c7c29add3275328f36baaLennart Poettering sd_bus *queued_message_bus; /* The connection to send the queued message on */
2087a7aff26ea5d1bc2c7c29add3275328f36baaLennart Poettering Hashmap *watch_bus; /* D-Bus names => Unit object n:1 */
2087a7aff26ea5d1bc2c7c29add3275328f36baaLennart Poettering /* Data specific to the Automount subsystem */
2087a7aff26ea5d1bc2c7c29add3275328f36baaLennart Poettering /* Data specific to the cgroup subsystem */
2087a7aff26ea5d1bc2c7c29add3275328f36baaLennart Poettering /* Make sure the user cannot accidentally unmount our cgroup
2087a7aff26ea5d1bc2c7c29add3275328f36baaLennart Poettering * file system */
2087a7aff26ea5d1bc2c7c29add3275328f36baaLennart Poettering ExecOutput default_std_output, default_std_error;
2087a7aff26ea5d1bc2c7c29add3275328f36baaLennart Poettering usec_t default_restart_usec, default_timeout_start_usec, default_timeout_stop_usec;
2f7a4867babd3fd382e5495f21724358f30fa67dMichal Sekletar /* non-zero if we are reloading or reexecuting, */
2087a7aff26ea5d1bc2c7c29add3275328f36baaLennart Poettering /* Jobs in progress watching */
0affed79d2e30013f07cb94e6f07e3fcb81c02faLennart Poettering /* Do we have any outstanding password prompts? */
2087a7aff26ea5d1bc2c7c29add3275328f36baaLennart Poettering sd_event_source *ask_password_event_source;
2087a7aff26ea5d1bc2c7c29add3275328f36baaLennart Poettering /* Type=idle pipes */
2087a7aff26ea5d1bc2c7c29add3275328f36baaLennart Poettering /* This maps all possible path prefixes to the units needing
2087a7aff26ea5d1bc2c7c29add3275328f36baaLennart Poettering * them. It's a hashmap with a path string as key and a Set as
2087a7aff26ea5d1bc2c7c29add3275328f36baaLennart Poettering * value where Unit objects are contained. */
17d33cecaa762f7e43200307328af5e9135e2091Giovanni Campagna /* Reference to the kdbus bus control fd */
17d33cecaa762f7e43200307328af5e9135e2091Giovanni Campagna /* Used for processing polkit authorization responses */
17d33cecaa762f7e43200307328af5e9135e2091Giovanni Campagnaint manager_new(SystemdRunningAs running_as, bool test_run, Manager **m);
17d33cecaa762f7e43200307328af5e9135e2091Giovanni Campagnaint manager_startup(Manager *m, FILE *serialization, FDSet *fds);
17d33cecaa762f7e43200307328af5e9135e2091Giovanni CampagnaJob *manager_get_job(Manager *m, uint32_t id);
17d33cecaa762f7e43200307328af5e9135e2091Giovanni CampagnaUnit *manager_get_unit(Manager *m, const char *name);
17d33cecaa762f7e43200307328af5e9135e2091Giovanni Campagnaint manager_get_unit_by_path(Manager *m, const char *path, const char *suffix, Unit **_found);
17d33cecaa762f7e43200307328af5e9135e2091Giovanni Campagnaint manager_get_job_from_dbus_path(Manager *m, const char *s, Job **_j);
17d33cecaa762f7e43200307328af5e9135e2091Giovanni Campagnaint manager_load_unit_prepare(Manager *m, const char *name, const char *path, sd_bus_error *e, Unit **_ret);
17d33cecaa762f7e43200307328af5e9135e2091Giovanni Campagnaint manager_load_unit(Manager *m, const char *name, const char *path, sd_bus_error *e, Unit **_ret);
17d33cecaa762f7e43200307328af5e9135e2091Giovanni Campagnaint manager_load_unit_from_dbus_path(Manager *m, const char *s, sd_bus_error *e, Unit **_u);
17d33cecaa762f7e43200307328af5e9135e2091Giovanni Campagnaint manager_add_job(Manager *m, JobType type, Unit *unit, JobMode mode, bool force, sd_bus_error *e, Job **_ret);
17d33cecaa762f7e43200307328af5e9135e2091Giovanni Campagnaint manager_add_job_by_name(Manager *m, JobType type, const char *name, JobMode mode, bool force, sd_bus_error *e, Job **_ret);
17d33cecaa762f7e43200307328af5e9135e2091Giovanni Campagnavoid manager_dump_units(Manager *s, FILE *f, const char *prefix);
17d33cecaa762f7e43200307328af5e9135e2091Giovanni Campagnavoid manager_dump_jobs(Manager *s, FILE *f, const char *prefix);
bac3c8eefe23a820caac930d41629cebafbfc7b2Zbigniew Jędrzejewski-Szmekvoid manager_clear_jobs(Manager *m);
ef42202ac8ed27e7ff1fc90ef8bc2590046dff25Zbigniew Jędrzejewski-Szmekunsigned manager_dispatch_load_queue(Manager *m);
ef42202ac8ed27e7ff1fc90ef8bc2590046dff25Zbigniew Jędrzejewski-Szmekint manager_environment_add(Manager *m, char **minus, char **plus);
ef42202ac8ed27e7ff1fc90ef8bc2590046dff25Zbigniew Jędrzejewski-Szmekint manager_set_default_rlimits(Manager *m, struct rlimit **default_rlimit);
17d33cecaa762f7e43200307328af5e9135e2091Giovanni Campagnavoid manager_dispatch_bus_name_owner_changed(Manager *m, const char *name, const char* old_owner, const char *new_owner);
8333c77edf8fd1654cd96f3f6ee0f078dd64b58bZbigniew Jędrzejewski-Szmekint manager_open_serialization(Manager *m, FILE **_f);
bac3c8eefe23a820caac930d41629cebafbfc7b2Zbigniew Jędrzejewski-Szmekint manager_serialize(Manager *m, FILE *f, FDSet *fds, bool switching_root);
17d33cecaa762f7e43200307328af5e9135e2091Giovanni Campagnaint manager_deserialize(Manager *m, FILE *f, FDSet *fds);
17d33cecaa762f7e43200307328af5e9135e2091Giovanni Campagnabool manager_is_reloading_or_reexecuting(Manager *m) _pure_;
bac3c8eefe23a820caac930d41629cebafbfc7b2Zbigniew Jędrzejewski-Szmekvoid manager_reset_failed(Manager *m);
17d33cecaa762f7e43200307328af5e9135e2091Giovanni Campagnavoid manager_send_unit_audit(Manager *m, Unit *u, int type, bool success);
17d33cecaa762f7e43200307328af5e9135e2091Giovanni Campagnavoid manager_send_unit_plymouth(Manager *m, Unit *u);
17d33cecaa762f7e43200307328af5e9135e2091Giovanni Campagnabool manager_unit_inactive_or_pending(Manager *m, const char *name);
bac3c8eefe23a820caac930d41629cebafbfc7b2Zbigniew Jędrzejewski-Szmekvoid manager_undo_generators(Manager *m);
bac3c8eefe23a820caac930d41629cebafbfc7b2Zbigniew Jędrzejewski-Szmekvoid manager_set_show_status(Manager *m, ShowStatus mode);
17d33cecaa762f7e43200307328af5e9135e2091Giovanni Campagnavoid manager_set_first_boot(Manager *m, bool b);
bac3c8eefe23a820caac930d41629cebafbfc7b2Zbigniew Jędrzejewski-Szmekvoid manager_status_printf(Manager *m, bool ephemeral, const char *status, const char *format, ...) _printf_(4,5);
bac3c8eefe23a820caac930d41629cebafbfc7b2Zbigniew Jędrzejewski-Szmekvoid manager_flip_auto_status(Manager *m, bool enable);
2087a7aff26ea5d1bc2c7c29add3275328f36baaLennart PoetteringSet *manager_get_units_requiring_mounts_for(Manager *m, const char *path);
2087a7aff26ea5d1bc2c7c29add3275328f36baaLennart Poetteringconst char *manager_get_runtime_prefix(Manager *m);
7c2d80944afb4196f2eff614e8da1450dffcbeaaThomas Hindoe Paaboel AndersenManagerState manager_state(Manager *m);
bac3c8eefe23a820caac930d41629cebafbfc7b2Zbigniew Jędrzejewski-Szmekconst char *manager_state_to_string(ManagerState m) _const_;