manager.h revision cb8ccb2271727fc114ca43104d3333ee4635cc79
139b011ab81ccea1d51f09e0261a1c390115c6ffPatrik Flykt/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
139b011ab81ccea1d51f09e0261a1c390115c6ffPatrik Flykt
139b011ab81ccea1d51f09e0261a1c390115c6ffPatrik Flykt#pragma once
139b011ab81ccea1d51f09e0261a1c390115c6ffPatrik Flykt
139b011ab81ccea1d51f09e0261a1c390115c6ffPatrik Flykt/***
7bd8e95d44977833d0de3fc4e893eb3bc84351d6Patrik Flykt This file is part of systemd.
139b011ab81ccea1d51f09e0261a1c390115c6ffPatrik Flykt
139b011ab81ccea1d51f09e0261a1c390115c6ffPatrik Flykt Copyright 2010 Lennart Poettering
139b011ab81ccea1d51f09e0261a1c390115c6ffPatrik Flykt
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
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
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/>.
139b011ab81ccea1d51f09e0261a1c390115c6ffPatrik Flykt***/
139b011ab81ccea1d51f09e0261a1c390115c6ffPatrik Flykt
631bbe71298ec892f77f44f94feb612646fe6853Patrik Flykt#include <stdbool.h>
76253e73f9c9c24fec755e485516f3b55d0707b4Dan Williams#include <inttypes.h>
139b011ab81ccea1d51f09e0261a1c390115c6ffPatrik Flykt#include <stdio.h>
f12abb48fc510b8b349c05e35ba048134debaf25Patrik Flykt
f12abb48fc510b8b349c05e35ba048134debaf25Patrik Flykt#include "sd-bus.h"
139b011ab81ccea1d51f09e0261a1c390115c6ffPatrik Flykt#include "sd-event.h"
139b011ab81ccea1d51f09e0261a1c390115c6ffPatrik Flykt#include "fdset.h"
3df3e884ae1237ef0d4d23b0e80f4ffda95ac135Ronny Chevalier#include "cgroup-util.h"
139b011ab81ccea1d51f09e0261a1c390115c6ffPatrik Flykt
f12abb48fc510b8b349c05e35ba048134debaf25Patrik Flykt/* Enforce upper limit how many names we allow */
139b011ab81ccea1d51f09e0261a1c390115c6ffPatrik Flykt#define MANAGER_MAX_NAMES 131072 /* 128K */
139b011ab81ccea1d51f09e0261a1c390115c6ffPatrik Flykt
f12abb48fc510b8b349c05e35ba048134debaf25Patrik Flykttypedef struct Manager Manager;
631bbe71298ec892f77f44f94feb612646fe6853Patrik Flykt
764aad6258eec3bd4ae62ea341ea507bd69ce628Tom Gundersentypedef enum ManagerExitCode {
139b011ab81ccea1d51f09e0261a1c390115c6ffPatrik Flykt MANAGER_RUNNING,
76253e73f9c9c24fec755e485516f3b55d0707b4Dan Williams MANAGER_EXIT,
76253e73f9c9c24fec755e485516f3b55d0707b4Dan Williams MANAGER_RELOAD,
139b011ab81ccea1d51f09e0261a1c390115c6ffPatrik Flykt MANAGER_REEXECUTE,
139b011ab81ccea1d51f09e0261a1c390115c6ffPatrik Flykt MANAGER_REBOOT,
139b011ab81ccea1d51f09e0261a1c390115c6ffPatrik Flykt MANAGER_POWEROFF,
139b011ab81ccea1d51f09e0261a1c390115c6ffPatrik Flykt MANAGER_HALT,
139b011ab81ccea1d51f09e0261a1c390115c6ffPatrik Flykt MANAGER_KEXEC,
139b011ab81ccea1d51f09e0261a1c390115c6ffPatrik Flykt MANAGER_SWITCH_ROOT,
139b011ab81ccea1d51f09e0261a1c390115c6ffPatrik Flykt _MANAGER_EXIT_CODE_MAX,
76253e73f9c9c24fec755e485516f3b55d0707b4Dan Williams _MANAGER_EXIT_CODE_INVALID = -1
76253e73f9c9c24fec755e485516f3b55d0707b4Dan Williams} ManagerExitCode;
76253e73f9c9c24fec755e485516f3b55d0707b4Dan Williams
f12abb48fc510b8b349c05e35ba048134debaf25Patrik Flykt#include "unit.h"
a9aff3615b430f86bd0a824214d95f634efaf894Patrik Flykt#include "job.h"
346e13a25dc6f76d3bc9d8decd40dc4782b02d2aPatrik Flykt#include "hashmap.h"
631bbe71298ec892f77f44f94feb612646fe6853Patrik Flykt#include "list.h"
a9aff3615b430f86bd0a824214d95f634efaf894Patrik Flykt#include "set.h"
bbfa43ca37df0718287c25a8e39ee7477ebf33f6Patrik Flykt#include "path-lookup.h"
da6fe470e17fa02f3adedc779585caf8669252bdPatrik Flykt#include "execute.h"
da6fe470e17fa02f3adedc779585caf8669252bdPatrik Flykt#include "unit-name.h"
da6fe470e17fa02f3adedc779585caf8669252bdPatrik Flykt#include "exit-status.h"
a9aff3615b430f86bd0a824214d95f634efaf894Patrik Flykt
d1b0afe3653b4316a6361d204169620726d468a0Patrik Flyktstruct Manager {
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
139b011ab81ccea1d51f09e0261a1c390115c6ffPatrik Flykt /* Active jobs and units */
764aad6258eec3bd4ae62ea341ea507bd69ce628Tom Gundersen Hashmap *units; /* name string => Unit object n:1 */
66eac1201a9c1596f5901f8dbbf24bda7e350878Dan Williams Hashmap *jobs; /* job id => Job object 1:1 */
139b011ab81ccea1d51f09e0261a1c390115c6ffPatrik Flykt
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
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. */
da6fe470e17fa02f3adedc779585caf8669252bdPatrik Flykt
a9aff3615b430f86bd0a824214d95f634efaf894Patrik Flykt /* Jobs that need to be run */
a9aff3615b430f86bd0a824214d95f634efaf894Patrik Flykt LIST_HEAD(Job, run_queue); /* more a stack than a queue, too */
a9aff3615b430f86bd0a824214d95f634efaf894Patrik Flykt
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 LIST_HEAD(Unit, dbus_unit_queue);
a9aff3615b430f86bd0a824214d95f634efaf894Patrik Flykt LIST_HEAD(Job, dbus_job_queue);
a9aff3615b430f86bd0a824214d95f634efaf894Patrik Flykt
a9aff3615b430f86bd0a824214d95f634efaf894Patrik Flykt /* Units to remove */
a9aff3615b430f86bd0a824214d95f634efaf894Patrik Flykt LIST_HEAD(Unit, cleanup_queue);
a9aff3615b430f86bd0a824214d95f634efaf894Patrik Flykt
a9aff3615b430f86bd0a824214d95f634efaf894Patrik Flykt /* Units to check when doing GC */
a9aff3615b430f86bd0a824214d95f634efaf894Patrik Flykt LIST_HEAD(Unit, gc_queue);
a9aff3615b430f86bd0a824214d95f634efaf894Patrik Flykt
a9aff3615b430f86bd0a824214d95f634efaf894Patrik Flykt /* Units that should be realized */
a9aff3615b430f86bd0a824214d95f634efaf894Patrik Flykt LIST_HEAD(Unit, cgroup_queue);
631bbe71298ec892f77f44f94feb612646fe6853Patrik Flykt
631bbe71298ec892f77f44f94feb612646fe6853Patrik Flykt sd_event *event;
631bbe71298ec892f77f44f94feb612646fe6853Patrik Flykt
631bbe71298ec892f77f44f94feb612646fe6853Patrik Flykt Hashmap *watch_pids; /* pid => Unit object n:1 */
631bbe71298ec892f77f44f94feb612646fe6853Patrik Flykt
631bbe71298ec892f77f44f94feb612646fe6853Patrik Flykt sd_event_source *run_queue_event_source;
631bbe71298ec892f77f44f94feb612646fe6853Patrik Flykt
631bbe71298ec892f77f44f94feb612646fe6853Patrik Flykt char *notify_socket;
631bbe71298ec892f77f44f94feb612646fe6853Patrik Flykt int notify_fd;
631bbe71298ec892f77f44f94feb612646fe6853Patrik Flykt sd_event_source *notify_event_source;
631bbe71298ec892f77f44f94feb612646fe6853Patrik Flykt
3f0c075f8ef3344da5a6bda524540201f9204e61Patrik Flykt int signal_fd;
3f0c075f8ef3344da5a6bda524540201f9204e61Patrik Flykt sd_event_source *signal_event_source;
3f0c075f8ef3344da5a6bda524540201f9204e61Patrik Flykt
3f0c075f8ef3344da5a6bda524540201f9204e61Patrik Flykt int time_change_fd;
3f0c075f8ef3344da5a6bda524540201f9204e61Patrik Flykt sd_event_source *time_change_event_source;
3f0c075f8ef3344da5a6bda524540201f9204e61Patrik Flykt
c3e2adeaba8e043caed0ef139eeaea016bd152d0Patrik Flykt sd_event_source *jobs_in_progress_event_source;
c3e2adeaba8e043caed0ef139eeaea016bd152d0Patrik Flykt
139b011ab81ccea1d51f09e0261a1c390115c6ffPatrik Flykt unsigned n_snapshots;
139b011ab81ccea1d51f09e0261a1c390115c6ffPatrik Flykt
139b011ab81ccea1d51f09e0261a1c390115c6ffPatrik Flykt LookupPaths lookup_paths;
139b011ab81ccea1d51f09e0261a1c390115c6ffPatrik Flykt Set *unit_path_cache;
139b011ab81ccea1d51f09e0261a1c390115c6ffPatrik Flykt
139b011ab81ccea1d51f09e0261a1c390115c6ffPatrik Flykt char **environment;
139b011ab81ccea1d51f09e0261a1c390115c6ffPatrik Flykt
139b011ab81ccea1d51f09e0261a1c390115c6ffPatrik Flykt usec_t runtime_watchdog;
139b011ab81ccea1d51f09e0261a1c390115c6ffPatrik Flykt usec_t shutdown_watchdog;
139b011ab81ccea1d51f09e0261a1c390115c6ffPatrik Flykt
139b011ab81ccea1d51f09e0261a1c390115c6ffPatrik Flykt dual_timestamp firmware_timestamp;
139b011ab81ccea1d51f09e0261a1c390115c6ffPatrik Flykt dual_timestamp loader_timestamp;
139b011ab81ccea1d51f09e0261a1c390115c6ffPatrik Flykt dual_timestamp kernel_timestamp;
139b011ab81ccea1d51f09e0261a1c390115c6ffPatrik Flykt dual_timestamp initrd_timestamp;
139b011ab81ccea1d51f09e0261a1c390115c6ffPatrik Flykt dual_timestamp userspace_timestamp;
139b011ab81ccea1d51f09e0261a1c390115c6ffPatrik Flykt dual_timestamp finish_timestamp;
139b011ab81ccea1d51f09e0261a1c390115c6ffPatrik Flykt dual_timestamp security_start_timestamp;
139b011ab81ccea1d51f09e0261a1c390115c6ffPatrik Flykt dual_timestamp security_finish_timestamp;
139b011ab81ccea1d51f09e0261a1c390115c6ffPatrik Flykt dual_timestamp generators_start_timestamp;
139b011ab81ccea1d51f09e0261a1c390115c6ffPatrik Flykt dual_timestamp generators_finish_timestamp;
139b011ab81ccea1d51f09e0261a1c390115c6ffPatrik Flykt dual_timestamp units_load_start_timestamp;
76253e73f9c9c24fec755e485516f3b55d0707b4Dan Williams dual_timestamp units_load_finish_timestamp;
76253e73f9c9c24fec755e485516f3b55d0707b4Dan Williams
139b011ab81ccea1d51f09e0261a1c390115c6ffPatrik Flykt char *generator_unit_path;
139b011ab81ccea1d51f09e0261a1c390115c6ffPatrik Flykt char *generator_unit_path_early;
76253e73f9c9c24fec755e485516f3b55d0707b4Dan Williams char *generator_unit_path_late;
76253e73f9c9c24fec755e485516f3b55d0707b4Dan Williams
76253e73f9c9c24fec755e485516f3b55d0707b4Dan Williams struct udev* udev;
76253e73f9c9c24fec755e485516f3b55d0707b4Dan Williams
76253e73f9c9c24fec755e485516f3b55d0707b4Dan Williams /* Data specific to the device subsystem */
76253e73f9c9c24fec755e485516f3b55d0707b4Dan Williams struct udev_monitor* udev_monitor;
76253e73f9c9c24fec755e485516f3b55d0707b4Dan Williams sd_event_source *udev_event_source;
76253e73f9c9c24fec755e485516f3b55d0707b4Dan Williams Hashmap *devices_by_sysfs;
139b011ab81ccea1d51f09e0261a1c390115c6ffPatrik Flykt
76253e73f9c9c24fec755e485516f3b55d0707b4Dan Williams /* Data specific to the mount subsystem */
76253e73f9c9c24fec755e485516f3b55d0707b4Dan Williams FILE *proc_self_mountinfo;
76253e73f9c9c24fec755e485516f3b55d0707b4Dan Williams sd_event_source *mount_event_source;
76253e73f9c9c24fec755e485516f3b55d0707b4Dan Williams
76253e73f9c9c24fec755e485516f3b55d0707b4Dan Williams /* Data specific to the swap filesystem */
76253e73f9c9c24fec755e485516f3b55d0707b4Dan Williams FILE *proc_swaps;
76253e73f9c9c24fec755e485516f3b55d0707b4Dan Williams sd_event_source *swap_event_source;
76253e73f9c9c24fec755e485516f3b55d0707b4Dan Williams Hashmap *swaps_by_devnode;
76253e73f9c9c24fec755e485516f3b55d0707b4Dan Williams
139b011ab81ccea1d51f09e0261a1c390115c6ffPatrik Flykt /* Data specific to the D-Bus subsystem */
139b011ab81ccea1d51f09e0261a1c390115c6ffPatrik Flykt sd_bus *api_bus, *system_bus;
139b011ab81ccea1d51f09e0261a1c390115c6ffPatrik Flykt Set *private_buses;
139b011ab81ccea1d51f09e0261a1c390115c6ffPatrik Flykt int private_listen_fd;
cc22955cfefb4bd6e7a135f1ec95fb5a07ba9ce3Thomas Haller sd_event_source *private_listen_event_source;
cc22955cfefb4bd6e7a135f1ec95fb5a07ba9ce3Thomas Haller Set *subscribed;
cc22955cfefb4bd6e7a135f1ec95fb5a07ba9ce3Thomas Haller
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
66eac1201a9c1596f5901f8dbbf24bda7e350878Dan Williams Hashmap *watch_bus; /* D-Bus names => Unit object n:1 */
66eac1201a9c1596f5901f8dbbf24bda7e350878Dan Williams
66eac1201a9c1596f5901f8dbbf24bda7e350878Dan Williams bool send_reloading_done;
66eac1201a9c1596f5901f8dbbf24bda7e350878Dan Williams
66eac1201a9c1596f5901f8dbbf24bda7e350878Dan Williams uint32_t current_job_id;
fe4b2156256c5bdf52341576571ce9f095d9f085Tom Gundersen uint32_t default_unit_job_id;
fe4b2156256c5bdf52341576571ce9f095d9f085Tom Gundersen
764aad6258eec3bd4ae62ea341ea507bd69ce628Tom Gundersen /* Data specific to the Automount subsystem */
fe4b2156256c5bdf52341576571ce9f095d9f085Tom Gundersen int dev_autofs_fd;
fe4b2156256c5bdf52341576571ce9f095d9f085Tom Gundersen
fe4b2156256c5bdf52341576571ce9f095d9f085Tom Gundersen /* Data specific to the cgroup subsystem */
764aad6258eec3bd4ae62ea341ea507bd69ce628Tom Gundersen Hashmap *cgroup_unit;
fe4b2156256c5bdf52341576571ce9f095d9f085Tom Gundersen CGroupControllerMask cgroup_supported;
fe4b2156256c5bdf52341576571ce9f095d9f085Tom Gundersen char *cgroup_root;
fe4b2156256c5bdf52341576571ce9f095d9f085Tom Gundersen
764aad6258eec3bd4ae62ea341ea507bd69ce628Tom Gundersen int gc_marker;
fe4b2156256c5bdf52341576571ce9f095d9f085Tom Gundersen unsigned n_in_gc_queue;
fe4b2156256c5bdf52341576571ce9f095d9f085Tom Gundersen
fe4b2156256c5bdf52341576571ce9f095d9f085Tom Gundersen /* Make sure the user cannot accidentally unmount our cgroup
764aad6258eec3bd4ae62ea341ea507bd69ce628Tom Gundersen * file system */
fe4b2156256c5bdf52341576571ce9f095d9f085Tom Gundersen int pin_cgroupfs_fd;
fe4b2156256c5bdf52341576571ce9f095d9f085Tom Gundersen
fe4b2156256c5bdf52341576571ce9f095d9f085Tom Gundersen /* Flags */
fe4b2156256c5bdf52341576571ce9f095d9f085Tom Gundersen SystemdRunningAs running_as;
fe4b2156256c5bdf52341576571ce9f095d9f085Tom Gundersen ManagerExitCode exit_code:5;
fe4b2156256c5bdf52341576571ce9f095d9f085Tom Gundersen
fe4b2156256c5bdf52341576571ce9f095d9f085Tom Gundersen bool dispatching_load_queue:1;
764aad6258eec3bd4ae62ea341ea507bd69ce628Tom Gundersen bool dispatching_dbus_queue:1;
ebe207d4acf38165adbc45298662982eecdb9e9fTom Gundersen
764aad6258eec3bd4ae62ea341ea507bd69ce628Tom Gundersen bool taint_usr:1;
66eac1201a9c1596f5901f8dbbf24bda7e350878Dan Williams
66eac1201a9c1596f5901f8dbbf24bda7e350878Dan Williams ShowStatus show_status;
66eac1201a9c1596f5901f8dbbf24bda7e350878Dan Williams bool confirm_spawn;
66eac1201a9c1596f5901f8dbbf24bda7e350878Dan Williams bool no_console_output;
bbfa43ca37df0718287c25a8e39ee7477ebf33f6Patrik Flykt
bbfa43ca37df0718287c25a8e39ee7477ebf33f6Patrik Flykt ExecOutput default_std_output, default_std_error;
bbfa43ca37df0718287c25a8e39ee7477ebf33f6Patrik Flykt
bbfa43ca37df0718287c25a8e39ee7477ebf33f6Patrik Flykt usec_t default_restart_usec, default_timeout_start_usec,
bbfa43ca37df0718287c25a8e39ee7477ebf33f6Patrik Flykt default_timeout_stop_usec;
bbfa43ca37df0718287c25a8e39ee7477ebf33f6Patrik Flykt
bbfa43ca37df0718287c25a8e39ee7477ebf33f6Patrik Flykt usec_t default_start_limit_interval;
bbfa43ca37df0718287c25a8e39ee7477ebf33f6Patrik Flykt unsigned default_start_limit_burst;
bbfa43ca37df0718287c25a8e39ee7477ebf33f6Patrik Flykt
bbfa43ca37df0718287c25a8e39ee7477ebf33f6Patrik Flykt struct rlimit *rlimit[RLIMIT_NLIMITS];
bbfa43ca37df0718287c25a8e39ee7477ebf33f6Patrik Flykt
bbfa43ca37df0718287c25a8e39ee7477ebf33f6Patrik Flykt /* non-zero if we are reloading or reexecuting, */
bbfa43ca37df0718287c25a8e39ee7477ebf33f6Patrik Flykt int n_reloading;
bbfa43ca37df0718287c25a8e39ee7477ebf33f6Patrik Flykt
bbfa43ca37df0718287c25a8e39ee7477ebf33f6Patrik Flykt unsigned n_installed_jobs;
bbfa43ca37df0718287c25a8e39ee7477ebf33f6Patrik Flykt unsigned n_failed_jobs;
bbfa43ca37df0718287c25a8e39ee7477ebf33f6Patrik Flykt
bbfa43ca37df0718287c25a8e39ee7477ebf33f6Patrik Flykt /* Jobs in progress watching */
bbfa43ca37df0718287c25a8e39ee7477ebf33f6Patrik Flykt unsigned n_running_jobs;
da6fe470e17fa02f3adedc779585caf8669252bdPatrik Flykt unsigned n_on_console;
da6fe470e17fa02f3adedc779585caf8669252bdPatrik Flykt unsigned jobs_in_progress_iteration;
da6fe470e17fa02f3adedc779585caf8669252bdPatrik Flykt
da6fe470e17fa02f3adedc779585caf8669252bdPatrik Flykt /* Type=idle pipes */
da6fe470e17fa02f3adedc779585caf8669252bdPatrik Flykt int idle_pipe[4];
da6fe470e17fa02f3adedc779585caf8669252bdPatrik Flykt sd_event_source *idle_pipe_event_source;
da6fe470e17fa02f3adedc779585caf8669252bdPatrik Flykt
da6fe470e17fa02f3adedc779585caf8669252bdPatrik Flykt char *switch_root;
da6fe470e17fa02f3adedc779585caf8669252bdPatrik Flykt char *switch_root_init;
da6fe470e17fa02f3adedc779585caf8669252bdPatrik Flykt
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 Hashmap *units_requiring_mounts_for;
da6fe470e17fa02f3adedc779585caf8669252bdPatrik Flykt
da6fe470e17fa02f3adedc779585caf8669252bdPatrik Flykt /* Reference to the kdbus bus control fd */
da6fe470e17fa02f3adedc779585caf8669252bdPatrik Flykt int kdbus_fd;
da6fe470e17fa02f3adedc779585caf8669252bdPatrik Flykt};
da6fe470e17fa02f3adedc779585caf8669252bdPatrik Flykt
da6fe470e17fa02f3adedc779585caf8669252bdPatrik Flyktint manager_new(SystemdRunningAs running_as, Manager **m);
da6fe470e17fa02f3adedc779585caf8669252bdPatrik Flyktvoid manager_free(Manager *m);
da6fe470e17fa02f3adedc779585caf8669252bdPatrik Flykt
da6fe470e17fa02f3adedc779585caf8669252bdPatrik Flyktint manager_enumerate(Manager *m);
da6fe470e17fa02f3adedc779585caf8669252bdPatrik Flyktint manager_startup(Manager *m, FILE *serialization, FDSet *fds);
da6fe470e17fa02f3adedc779585caf8669252bdPatrik Flykt
da6fe470e17fa02f3adedc779585caf8669252bdPatrik FlyktJob *manager_get_job(Manager *m, uint32_t id);
da6fe470e17fa02f3adedc779585caf8669252bdPatrik FlyktUnit *manager_get_unit(Manager *m, const char *name);
da6fe470e17fa02f3adedc779585caf8669252bdPatrik Flykt
da6fe470e17fa02f3adedc779585caf8669252bdPatrik Flyktint manager_get_unit_by_path(Manager *m, const char *path, const char *suffix, Unit **_found);
da6fe470e17fa02f3adedc779585caf8669252bdPatrik Flykt
da6fe470e17fa02f3adedc779585caf8669252bdPatrik Flyktint manager_get_job_from_dbus_path(Manager *m, const char *s, Job **_j);
ea3b3a75abb3f8b853f7da454b9b8e258a120eeaPatrik Flykt
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 Flykt
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 Flykt
ea3b3a75abb3f8b853f7da454b9b8e258a120eeaPatrik Flyktvoid manager_dump_units(Manager *s, FILE *f, const char *prefix);
ea3b3a75abb3f8b853f7da454b9b8e258a120eeaPatrik Flyktvoid manager_dump_jobs(Manager *s, FILE *f, const char *prefix);
ea3b3a75abb3f8b853f7da454b9b8e258a120eeaPatrik Flykt
ea3b3a75abb3f8b853f7da454b9b8e258a120eeaPatrik Flyktvoid manager_clear_jobs(Manager *m);
3f0c075f8ef3344da5a6bda524540201f9204e61Patrik Flykt
3f0c075f8ef3344da5a6bda524540201f9204e61Patrik Flyktunsigned manager_dispatch_load_queue(Manager *m);
139b011ab81ccea1d51f09e0261a1c390115c6ffPatrik Flykt
139b011ab81ccea1d51f09e0261a1c390115c6ffPatrik Flyktint manager_environment_add(Manager *m, char **minus, char **plus);
139b011ab81ccea1d51f09e0261a1c390115c6ffPatrik Flyktint manager_set_default_rlimits(Manager *m, struct rlimit **default_rlimit);
c806ffb9592fa9a2b13a1f9f9be4c77cd5b211aaZbigniew Jędrzejewski-Szmek
139b011ab81ccea1d51f09e0261a1c390115c6ffPatrik Flyktint manager_loop(Manager *m);
139b011ab81ccea1d51f09e0261a1c390115c6ffPatrik Flykt
4e3e6679e8f73b83d38e4b20d8b025e12991d1cbPatrik Flyktvoid manager_dispatch_bus_name_owner_changed(Manager *m, const char *name, const char* old_owner, const char *new_owner);
4e3e6679e8f73b83d38e4b20d8b025e12991d1cbPatrik Flykt
4e3e6679e8f73b83d38e4b20d8b025e12991d1cbPatrik Flyktint manager_open_serialization(Manager *m, FILE **_f);
4e3e6679e8f73b83d38e4b20d8b025e12991d1cbPatrik Flykt
4e3e6679e8f73b83d38e4b20d8b025e12991d1cbPatrik Flyktint manager_serialize(Manager *m, FILE *f, FDSet *fds, bool switching_root);
a9aff3615b430f86bd0a824214d95f634efaf894Patrik Flyktint manager_deserialize(Manager *m, FILE *f, FDSet *fds);
a9aff3615b430f86bd0a824214d95f634efaf894Patrik Flykt
a9aff3615b430f86bd0a824214d95f634efaf894Patrik Flyktint manager_reload(Manager *m);
c806ffb9592fa9a2b13a1f9f9be4c77cd5b211aaZbigniew Jędrzejewski-Szmek
a9aff3615b430f86bd0a824214d95f634efaf894Patrik Flyktbool manager_is_reloading_or_reexecuting(Manager *m) _pure_;
c3e2adeaba8e043caed0ef139eeaea016bd152d0Patrik Flykt
346e13a25dc6f76d3bc9d8decd40dc4782b02d2aPatrik Flyktvoid manager_reset_failed(Manager *m);
a9aff3615b430f86bd0a824214d95f634efaf894Patrik Flykt
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 Flykt
f12abb48fc510b8b349c05e35ba048134debaf25Patrik Flyktbool manager_unit_inactive_or_pending(Manager *m, const char *name);
f12abb48fc510b8b349c05e35ba048134debaf25Patrik Flykt
d1b0afe3653b4316a6361d204169620726d468a0Patrik Flyktvoid manager_check_finished(Manager *m);
d1b0afe3653b4316a6361d204169620726d468a0Patrik Flykt
d1b0afe3653b4316a6361d204169620726d468a0Patrik Flyktvoid manager_run_generators(Manager *m);
d1b0afe3653b4316a6361d204169620726d468a0Patrik Flyktvoid manager_undo_generators(Manager *m);
d1b0afe3653b4316a6361d204169620726d468a0Patrik Flykt
d1b0afe3653b4316a6361d204169620726d468a0Patrik Flyktvoid manager_recheck_journal(Manager *m);
139b011ab81ccea1d51f09e0261a1c390115c6ffPatrik Flykt
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);
139b011ab81ccea1d51f09e0261a1c390115c6ffPatrik Flykt
3f0c075f8ef3344da5a6bda524540201f9204e61Patrik FlyktSet *manager_get_units_requiring_mounts_for(Manager *m, const char *path);
3f0c075f8ef3344da5a6bda524540201f9204e61Patrik Flykt