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