manager.h revision bbc2908635ca3ded9162504683fa126809f0ec14
/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
#pragma once
/***
This file is part of systemd.
Copyright 2010 Lennart Poettering
under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 2.1 of the License, or
(at your option) any later version.
systemd is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with systemd; If not, see <http://www.gnu.org/licenses/>.
***/
#include <stdbool.h>
#include <stdio.h>
#include "sd-bus.h"
#include "sd-event.h"
#include "fdset.h"
#include "cgroup-util.h"
#include "hashmap.h"
#include "list.h"
#include "ratelimit.h"
/* Enforce upper limit how many names we allow */
typedef enum ManagerState {
} ManagerState;
typedef enum ManagerExitCode {
typedef enum StatusType {
} StatusType;
#include "job.h"
#include "path-lookup.h"
#include "execute.h"
#include "unit-name.h"
#include "show-status.h"
struct Manager {
/* Note that the set of units we know of is allowed to be
* inconsistent. However the subset of it that is loaded may
* not, and the list of jobs may neither. */
/* Active jobs and units */
/* To make it easy to iterate through the units of a specific
* type we maintain a per type linked list */
/* Units that need to be loaded */
/* Jobs that need to be run */
/* Units and jobs that have not yet been announced via
* D-Bus. When something about a job changes it is added here
* if it is not in there yet. This allows easy coalescing of
* D-Bus change signals. */
/* Units to remove */
/* Units to check when doing GC */
/* Units that should be realized */
/* We use two hash tables here, since the same PID might be
* watched by two different units: once the unit that forked
* it off, and possibly a different unit to which it was
* joined as cgroup member. Since we know that it is either
* one or two units for each PID we just use to hashmaps
* here. */
/* A set contains all units which cgroup should be refreshed after startup */
/* A set which contains all currently failed units */
char *notify_socket;
int notify_fd;
int signal_fd;
int time_change_fd;
unsigned n_snapshots;
char **environment;
char *generator_unit_path;
char *generator_unit_path_early;
char *generator_unit_path_late;
/* Data specific to the device subsystem */
struct udev_monitor* udev_monitor;
/* Data specific to the mount subsystem */
int utab_inotify_fd;
/* Data specific to the swap filesystem */
/* Data specific to the D-Bus subsystem */
int private_listen_fd;
/* Contains all the clients that are subscribed to signals via
the API bus. Note that private bus connections are always
considered subscribes, since they last for very short only,
and it is much simpler that way. */
char **deserialized_subscribed;
/* This is used during reloading: before the reload we queue
* the reply message here, and afterwards we send it */
bool send_reloading_done;
/* Data specific to the Automount subsystem */
int dev_autofs_fd;
/* Data specific to the cgroup subsystem */
char *cgroup_root;
int gc_marker;
unsigned n_in_gc_queue;
/* Make sure the user cannot accidentally unmount our cgroup
* file system */
int pin_cgroupfs_fd;
/* Flags */
bool dispatching_load_queue:1;
bool dispatching_dbus_queue:1;
bool taint_usr:1;
bool first_boot:1;
bool test_run:1;
bool confirm_spawn;
bool no_console_output;
unsigned default_start_limit_burst;
bool default_cpu_accounting;
/* non-zero if we are reloading or reexecuting, */
int n_reloading;
unsigned n_installed_jobs;
unsigned n_failed_jobs;
/* Jobs in progress watching */
unsigned n_running_jobs;
unsigned n_on_console;
unsigned jobs_in_progress_iteration;
/* Do we have any outstanding password prompts? */
int have_ask_password;
/* Type=idle pipes */
int idle_pipe[4];
char *switch_root;
char *switch_root_init;
/* This maps all possible path prefixes to the units needing
* them. It's a hashmap with a path string as key and a Set as
* value where Unit objects are contained. */
/* Reference to the kdbus bus control fd */
int kdbus_fd;
/* Used for processing polkit authorization responses */
/* When the user hits C-A-D more than 7 times per 2s, reboot immediately... */
const char *unit_log_field;
const char *unit_log_format_string;
};
int manager_enumerate(Manager *m);
int manager_load_unit_prepare(Manager *m, const char *name, const char *path, sd_bus_error *e, Unit **_ret);
int manager_load_unit(Manager *m, const char *name, const char *path, sd_bus_error *e, Unit **_ret);
int manager_add_job(Manager *m, JobType type, Unit *unit, JobMode mode, bool force, sd_bus_error *e, Job **_ret);
int manager_add_job_by_name(Manager *m, JobType type, const char *name, JobMode mode, bool force, sd_bus_error *e, Job **_ret);
void manager_clear_jobs(Manager *m);
unsigned manager_dispatch_load_queue(Manager *m);
int manager_loop(Manager *m);
int manager_reload(Manager *m);
void manager_reset_failed(Manager *m);
void manager_check_finished(Manager *m);
void manager_recheck_journal(Manager *m);
void manager_set_first_boot(Manager *m, bool b);
void manager_status_printf(Manager *m, StatusType type, const char *status, const char *format, ...) _printf_(4,5);
const char *manager_get_runtime_prefix(Manager *m);