manager.h revision cb8ccb2271727fc114ca43104d3333ee4635cc79
139b011ab81ccea1d51f09e0261a1c390115c6ffPatrik Flykt/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
7bd8e95d44977833d0de3fc4e893eb3bc84351d6Patrik Flykt This file is part of systemd.
139b011ab81ccea1d51f09e0261a1c390115c6ffPatrik Flykt Copyright 2010 Lennart Poettering
139b011ab81ccea1d51f09e0261a1c390115c6ffPatrik Flykt systemd is free software; you can redistribute it and/or modify it
139b011ab81ccea1d51f09e0261a1c390115c6ffPatrik Flykt under the terms of the GNU Lesser General Public License as published by
139b011ab81ccea1d51f09e0261a1c390115c6ffPatrik Flykt the Free Software Foundation; either version 2.1 of the License, or
139b011ab81ccea1d51f09e0261a1c390115c6ffPatrik Flykt (at your option) any later version.
139b011ab81ccea1d51f09e0261a1c390115c6ffPatrik Flykt systemd is distributed in the hope that it will be useful, but
139b011ab81ccea1d51f09e0261a1c390115c6ffPatrik Flykt WITHOUT ANY WARRANTY; without even the implied warranty of
139b011ab81ccea1d51f09e0261a1c390115c6ffPatrik Flykt MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
139b011ab81ccea1d51f09e0261a1c390115c6ffPatrik Flykt Lesser General Public License for more details.
139b011ab81ccea1d51f09e0261a1c390115c6ffPatrik Flykt You should have received a copy of the GNU Lesser General Public License
139b011ab81ccea1d51f09e0261a1c390115c6ffPatrik Flykt along with systemd; If not, see <http://www.gnu.org/licenses/>.
f12abb48fc510b8b349c05e35ba048134debaf25Patrik Flykt/* Enforce upper limit how many names we allow */
d1b0afe3653b4316a6361d204169620726d468a0Patrik Flykt /* Note that the set of units we know of is allowed to be
d1b0afe3653b4316a6361d204169620726d468a0Patrik Flykt * inconsistent. However the subset of it that is loaded may
d1b0afe3653b4316a6361d204169620726d468a0Patrik Flykt * not, and the list of jobs may neither. */
139b011ab81ccea1d51f09e0261a1c390115c6ffPatrik Flykt /* Active jobs and units */
764aad6258eec3bd4ae62ea341ea507bd69ce628Tom Gundersen Hashmap *units; /* name string => Unit object n:1 */
139b011ab81ccea1d51f09e0261a1c390115c6ffPatrik Flykt /* To make it easy to iterate through the units of a specific
da6fe470e17fa02f3adedc779585caf8669252bdPatrik Flykt * type we maintain a per type linked list */
da6fe470e17fa02f3adedc779585caf8669252bdPatrik Flykt LIST_HEAD(Unit, units_by_type[_UNIT_TYPE_MAX]);
da6fe470e17fa02f3adedc779585caf8669252bdPatrik Flykt /* Units that need to be loaded */
da6fe470e17fa02f3adedc779585caf8669252bdPatrik Flykt LIST_HEAD(Unit, load_queue); /* this is actually more a stack than a queue, but uh. */
a9aff3615b430f86bd0a824214d95f634efaf894Patrik Flykt /* Jobs that need to be run */
a9aff3615b430f86bd0a824214d95f634efaf894Patrik Flykt LIST_HEAD(Job, run_queue); /* more a stack than a queue, too */
a9aff3615b430f86bd0a824214d95f634efaf894Patrik Flykt /* Units and jobs that have not yet been announced via
a9aff3615b430f86bd0a824214d95f634efaf894Patrik Flykt * D-Bus. When something about a job changes it is added here
a9aff3615b430f86bd0a824214d95f634efaf894Patrik Flykt * if it is not in there yet. This allows easy coalescing of
a9aff3615b430f86bd0a824214d95f634efaf894Patrik Flykt * D-Bus change signals. */
a9aff3615b430f86bd0a824214d95f634efaf894Patrik Flykt /* Units to remove */
a9aff3615b430f86bd0a824214d95f634efaf894Patrik Flykt /* Units to check when doing GC */
a9aff3615b430f86bd0a824214d95f634efaf894Patrik Flykt /* Units that should be realized */
631bbe71298ec892f77f44f94feb612646fe6853Patrik Flykt Hashmap *watch_pids; /* pid => Unit object n:1 */
c3e2adeaba8e043caed0ef139eeaea016bd152d0Patrik Flykt sd_event_source *jobs_in_progress_event_source;
76253e73f9c9c24fec755e485516f3b55d0707b4Dan Williams /* Data specific to the device subsystem */
76253e73f9c9c24fec755e485516f3b55d0707b4Dan Williams /* Data specific to the mount subsystem */
76253e73f9c9c24fec755e485516f3b55d0707b4Dan Williams /* Data specific to the swap filesystem */
139b011ab81ccea1d51f09e0261a1c390115c6ffPatrik Flykt /* Data specific to the D-Bus subsystem */
cc22955cfefb4bd6e7a135f1ec95fb5a07ba9ce3Thomas Haller sd_bus_message *queued_message; /* This is used during reloading:
cc22955cfefb4bd6e7a135f1ec95fb5a07ba9ce3Thomas Haller * before the reload we queue the
cc22955cfefb4bd6e7a135f1ec95fb5a07ba9ce3Thomas Haller * reply message here, and
cc22955cfefb4bd6e7a135f1ec95fb5a07ba9ce3Thomas Haller * afterwards we send it */
ebe207d4acf38165adbc45298662982eecdb9e9fTom Gundersen sd_bus *queued_message_bus; /* The connection to send the queued message on */
66eac1201a9c1596f5901f8dbbf24bda7e350878Dan Williams Hashmap *watch_bus; /* D-Bus names => Unit object n:1 */
764aad6258eec3bd4ae62ea341ea507bd69ce628Tom Gundersen /* Data specific to the Automount subsystem */
fe4b2156256c5bdf52341576571ce9f095d9f085Tom Gundersen /* Data specific to the cgroup subsystem */
fe4b2156256c5bdf52341576571ce9f095d9f085Tom Gundersen /* Make sure the user cannot accidentally unmount our cgroup
764aad6258eec3bd4ae62ea341ea507bd69ce628Tom Gundersen * file system */
bbfa43ca37df0718287c25a8e39ee7477ebf33f6Patrik Flykt ExecOutput default_std_output, default_std_error;
bbfa43ca37df0718287c25a8e39ee7477ebf33f6Patrik Flykt usec_t default_restart_usec, default_timeout_start_usec,
bbfa43ca37df0718287c25a8e39ee7477ebf33f6Patrik Flykt /* non-zero if we are reloading or reexecuting, */
bbfa43ca37df0718287c25a8e39ee7477ebf33f6Patrik Flykt /* Jobs in progress watching */
da6fe470e17fa02f3adedc779585caf8669252bdPatrik Flykt /* Type=idle pipes */
da6fe470e17fa02f3adedc779585caf8669252bdPatrik Flykt /* This maps all possible path prefixes to the units needing
da6fe470e17fa02f3adedc779585caf8669252bdPatrik Flykt * them. It's a hashmap with a path string as key and a Set as
da6fe470e17fa02f3adedc779585caf8669252bdPatrik Flykt * value where Unit objects are contained. */
da6fe470e17fa02f3adedc779585caf8669252bdPatrik Flykt /* Reference to the kdbus bus control fd */
da6fe470e17fa02f3adedc779585caf8669252bdPatrik Flyktint manager_new(SystemdRunningAs running_as, Manager **m);
da6fe470e17fa02f3adedc779585caf8669252bdPatrik Flyktint manager_startup(Manager *m, FILE *serialization, FDSet *fds);
da6fe470e17fa02f3adedc779585caf8669252bdPatrik FlyktUnit *manager_get_unit(Manager *m, const char *name);
da6fe470e17fa02f3adedc779585caf8669252bdPatrik Flyktint manager_get_unit_by_path(Manager *m, const char *path, const char *suffix, Unit **_found);
da6fe470e17fa02f3adedc779585caf8669252bdPatrik Flyktint manager_get_job_from_dbus_path(Manager *m, const char *s, Job **_j);
ea3b3a75abb3f8b853f7da454b9b8e258a120eeaPatrik Flyktint manager_load_unit_prepare(Manager *m, const char *name, const char *path, sd_bus_error *e, Unit **_ret);
ea3b3a75abb3f8b853f7da454b9b8e258a120eeaPatrik Flyktint manager_load_unit(Manager *m, const char *name, const char *path, sd_bus_error *e, Unit **_ret);
ea3b3a75abb3f8b853f7da454b9b8e258a120eeaPatrik Flyktint manager_load_unit_from_dbus_path(Manager *m, const char *s, sd_bus_error *e, Unit **_u);
ea3b3a75abb3f8b853f7da454b9b8e258a120eeaPatrik Flyktint manager_add_job(Manager *m, JobType type, Unit *unit, JobMode mode, bool force, sd_bus_error *e, Job **_ret);
ea3b3a75abb3f8b853f7da454b9b8e258a120eeaPatrik Flyktint manager_add_job_by_name(Manager *m, JobType type, const char *name, JobMode mode, bool force, sd_bus_error *e, Job **_ret);
ea3b3a75abb3f8b853f7da454b9b8e258a120eeaPatrik Flyktvoid manager_dump_units(Manager *s, FILE *f, const char *prefix);
ea3b3a75abb3f8b853f7da454b9b8e258a120eeaPatrik Flyktvoid manager_dump_jobs(Manager *s, FILE *f, const char *prefix);
3f0c075f8ef3344da5a6bda524540201f9204e61Patrik Flyktunsigned manager_dispatch_load_queue(Manager *m);
139b011ab81ccea1d51f09e0261a1c390115c6ffPatrik Flyktint manager_environment_add(Manager *m, char **minus, char **plus);
139b011ab81ccea1d51f09e0261a1c390115c6ffPatrik Flyktint manager_set_default_rlimits(Manager *m, struct rlimit **default_rlimit);
4e3e6679e8f73b83d38e4b20d8b025e12991d1cbPatrik Flyktvoid manager_dispatch_bus_name_owner_changed(Manager *m, const char *name, const char* old_owner, const char *new_owner);
4e3e6679e8f73b83d38e4b20d8b025e12991d1cbPatrik Flyktint manager_open_serialization(Manager *m, FILE **_f);
4e3e6679e8f73b83d38e4b20d8b025e12991d1cbPatrik Flyktint manager_serialize(Manager *m, FILE *f, FDSet *fds, bool switching_root);
a9aff3615b430f86bd0a824214d95f634efaf894Patrik Flyktint manager_deserialize(Manager *m, FILE *f, FDSet *fds);
a9aff3615b430f86bd0a824214d95f634efaf894Patrik Flyktbool manager_is_reloading_or_reexecuting(Manager *m) _pure_;
f12abb48fc510b8b349c05e35ba048134debaf25Patrik Flyktvoid manager_send_unit_audit(Manager *m, Unit *u, int type, bool success);
f12abb48fc510b8b349c05e35ba048134debaf25Patrik Flyktvoid manager_send_unit_plymouth(Manager *m, Unit *u);
f12abb48fc510b8b349c05e35ba048134debaf25Patrik Flyktbool manager_unit_inactive_or_pending(Manager *m, const char *name);
139b011ab81ccea1d51f09e0261a1c390115c6ffPatrik Flyktvoid manager_set_show_status(Manager *m, ShowStatus mode);
139b011ab81ccea1d51f09e0261a1c390115c6ffPatrik Flyktvoid manager_status_printf(Manager *m, bool ephemeral, const char *status, const char *format, ...) _printf_(4,5);
139b011ab81ccea1d51f09e0261a1c390115c6ffPatrik Flyktvoid manager_flip_auto_status(Manager *m, bool enable);