manager.h revision bd8f585b9996667db89764ece1cacf37672e3223
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann#pragma once
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann/***
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann This file is part of systemd.
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann Copyright 2010 Lennart Poettering
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann
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
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
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***/
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann#include <stdbool.h>
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann#include <inttypes.h>
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann#include <stdio.h>
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann#include "sd-bus.h"
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann#include "sd-event.h"
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann#include "fdset.h"
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann#include "cgroup-util.h"
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann/* Enforce upper limit how many names we allow */
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann#define MANAGER_MAX_NAMES 131072 /* 128K */
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmanntypedef struct Manager Manager;
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmanntypedef enum ManagerState {
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann MANAGER_STARTING,
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann MANAGER_RUNNING,
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann MANAGER_DEGRADED,
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann MANAGER_MAINTENANCE,
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann MANAGER_STOPPING,
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann _MANAGER_STATE_MAX,
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann _MANAGER_STATE_INVALID = -1
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann} ManagerState;
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmanntypedef enum ManagerExitCode {
5476ad087c0f2d45ab0dab1bab9ef3e9d70418bcMarcel Holtmann MANAGER_OK,
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann MANAGER_EXIT,
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann MANAGER_RELOAD,
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann MANAGER_REEXECUTE,
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann MANAGER_REBOOT,
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann MANAGER_POWEROFF,
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann MANAGER_HALT,
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann MANAGER_KEXEC,
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann MANAGER_SWITCH_ROOT,
5476ad087c0f2d45ab0dab1bab9ef3e9d70418bcMarcel Holtmann _MANAGER_EXIT_CODE_MAX,
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann _MANAGER_EXIT_CODE_INVALID = -1
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann} ManagerExitCode;
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann#include "unit.h"
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann#include "job.h"
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann#include "hashmap.h"
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann#include "list.h"
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann#include "set.h"
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann#include "path-lookup.h"
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann#include "execute.h"
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann#include "unit-name.h"
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann#include "exit-status.h"
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann#include "show-status.h"
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmannstruct Manager {
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
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 */
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann
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
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
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann /* Jobs that need to be run */
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann LIST_HEAD(Job, run_queue); /* more a stack than a queue, too */
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann
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 LIST_HEAD(Unit, dbus_unit_queue);
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann LIST_HEAD(Job, dbus_job_queue);
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann /* Units to remove */
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann LIST_HEAD(Unit, cleanup_queue);
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann /* Units to check when doing GC */
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann LIST_HEAD(Unit, gc_queue);
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann /* Units that should be realized */
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann LIST_HEAD(Unit, cgroup_queue);
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann sd_event *event;
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann
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 * here. */
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann Hashmap *watch_pids1; /* pid => Unit object n:1 */
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann Hashmap *watch_pids2; /* pid => Unit object n:1 */
7cfa80f07e94c3e48703d145ef03a73dd6e7b983Marcel Holtmann
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann /* A set which contains all currently failed units */
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann Set *failed_units;
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann sd_event_source *run_queue_event_source;
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann char *notify_socket;
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann int notify_fd;
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann sd_event_source *notify_event_source;
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann int signal_fd;
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann sd_event_source *signal_event_source;
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann int time_change_fd;
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann sd_event_source *time_change_event_source;
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann sd_event_source *jobs_in_progress_event_source;
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann unsigned n_snapshots;
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann LookupPaths lookup_paths;
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann Set *unit_path_cache;
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann char **environment;
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann usec_t runtime_watchdog;
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann usec_t shutdown_watchdog;
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann dual_timestamp firmware_timestamp;
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann dual_timestamp loader_timestamp;
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann dual_timestamp kernel_timestamp;
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann dual_timestamp initrd_timestamp;
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann dual_timestamp userspace_timestamp;
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann dual_timestamp finish_timestamp;
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann dual_timestamp security_start_timestamp;
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann dual_timestamp security_finish_timestamp;
5476ad087c0f2d45ab0dab1bab9ef3e9d70418bcMarcel Holtmann dual_timestamp generators_start_timestamp;
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann dual_timestamp generators_finish_timestamp;
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann dual_timestamp units_load_start_timestamp;
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann dual_timestamp units_load_finish_timestamp;
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann char *generator_unit_path;
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann char *generator_unit_path_early;
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann char *generator_unit_path_late;
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann struct udev* udev;
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann /* Data specific to the device subsystem */
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann struct udev_monitor* udev_monitor;
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann sd_event_source *udev_event_source;
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann Hashmap *devices_by_sysfs;
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann /* Data specific to the mount subsystem */
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann FILE *proc_self_mountinfo;
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann sd_event_source *mount_event_source;
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann /* Data specific to the swap filesystem */
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann FILE *proc_swaps;
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann sd_event_source *swap_event_source;
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann Hashmap *swaps_by_devnode;
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann /* Data specific to the D-Bus subsystem */
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann sd_bus *api_bus, *system_bus;
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann Set *private_buses;
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann int private_listen_fd;
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann sd_event_source *private_listen_event_source;
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann
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_track *subscribed;
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann char **deserialized_subscribed;
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann
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
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann Hashmap *watch_bus; /* D-Bus names => Unit object n:1 */
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann bool send_reloading_done;
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann
5476ad087c0f2d45ab0dab1bab9ef3e9d70418bcMarcel Holtmann uint32_t current_job_id;
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann uint32_t default_unit_job_id;
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann /* Data specific to the Automount subsystem */
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann int dev_autofs_fd;
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann /* Data specific to the cgroup subsystem */
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann Hashmap *cgroup_unit;
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann CGroupControllerMask cgroup_supported;
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann char *cgroup_root;
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann int gc_marker;
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann unsigned n_in_gc_queue;
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann /* Make sure the user cannot accidentally unmount our cgroup
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann * file system */
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann int pin_cgroupfs_fd;
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann /* Flags */
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann SystemdRunningAs running_as;
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann ManagerExitCode exit_code:5;
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann bool dispatching_load_queue:1;
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann bool dispatching_dbus_queue:1;
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann bool taint_usr:1;
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann ShowStatus show_status;
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann bool confirm_spawn;
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann bool no_console_output;
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann ExecOutput default_std_output, default_std_error;
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann usec_t default_restart_usec, default_timeout_start_usec, default_timeout_stop_usec;
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann usec_t default_start_limit_interval;
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann unsigned default_start_limit_burst;
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann bool default_cpu_accounting;
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann bool default_memory_accounting;
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann bool default_blockio_accounting;
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann usec_t default_timer_accuracy_usec;
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann struct rlimit *rlimit[_RLIMIT_MAX];
5476ad087c0f2d45ab0dab1bab9ef3e9d70418bcMarcel Holtmann
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann /* non-zero if we are reloading or reexecuting, */
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann int n_reloading;
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann unsigned n_installed_jobs;
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann unsigned n_failed_jobs;
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann /* Jobs in progress watching */
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann unsigned n_running_jobs;
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann unsigned n_on_console;
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann unsigned jobs_in_progress_iteration;
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann /* Type=idle pipes */
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann int idle_pipe[4];
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann sd_event_source *idle_pipe_event_source;
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann char *switch_root;
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann char *switch_root_init;
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann
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 Hashmap *units_requiring_mounts_for;
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann /* Reference to the kdbus bus control fd */
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann int kdbus_fd;
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann};
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmannint manager_new(SystemdRunningAs running_as, Manager **m);
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmannvoid manager_free(Manager *m);
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmannint manager_enumerate(Manager *m);
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmannint manager_startup(Manager *m, FILE *serialization, FDSet *fds);
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel HoltmannJob *manager_get_job(Manager *m, uint32_t id);
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel HoltmannUnit *manager_get_unit(Manager *m, const char *name);
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmannint manager_get_unit_by_path(Manager *m, const char *path, const char *suffix, Unit **_found);
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmannint manager_get_job_from_dbus_path(Manager *m, const char *s, Job **_j);
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann
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 Holtmann
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 Holtmann
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 Holtmann
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmannvoid manager_clear_jobs(Manager *m);
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmannunsigned manager_dispatch_load_queue(Manager *m);
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmannint manager_environment_add(Manager *m, char **minus, char **plus);
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmannint manager_set_default_rlimits(Manager *m, struct rlimit **default_rlimit);
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmannint manager_loop(Manager *m);
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmannvoid manager_dispatch_bus_name_owner_changed(Manager *m, const char *name, const char* old_owner, const char *new_owner);
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmannint manager_open_serialization(Manager *m, FILE **_f);
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmannint manager_serialize(Manager *m, FILE *f, FDSet *fds, bool switching_root);
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmannint manager_deserialize(Manager *m, FILE *f, FDSet *fds);
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmannint manager_reload(Manager *m);
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmannbool manager_is_reloading_or_reexecuting(Manager *m) _pure_;
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmannvoid manager_reset_failed(Manager *m);
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann
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 Holtmann
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmannbool manager_unit_inactive_or_pending(Manager *m, const char *name);
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmannvoid manager_check_finished(Manager *m);
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmannvoid manager_run_generators(Manager *m);
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmannvoid manager_undo_generators(Manager *m);
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmannvoid manager_recheck_journal(Manager *m);
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann
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 Holtmann
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel HoltmannSet *manager_get_units_requiring_mounts_for(Manager *m, const char *path);
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmannconst char *manager_get_runtime_prefix(Manager *m);
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel HoltmannManagerState manager_state(Manager *m);
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmannconst char *manager_state_to_string(ManagerState m) _const_;
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel HoltmannManagerState manager_state_from_string(const char *s) _pure_;
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann