manager.h revision cf1265e188e876dda906dca0029248a06dc80c33
/*-*- 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 <inttypes.h>
#include <stdio.h>
#include "fdset.h"
#include "cgroup-util.h"
/* Enforce upper limit how many names we allow */
typedef enum ManagerExitCode {
enum WatchType {
};
struct Watch {
int fd;
union {
} data;
bool fd_is_dupped:1;
bool socket_accept:1;
};
#include "unit.h"
#include "job.h"
#include "hashmap.h"
#include "list.h"
#include "set.h"
#include "dbus.h"
#include "path-lookup.h"
#include "execute.h"
#include "unit-name.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 */
/* To optimize iteration of units that have requires_mounts_for set */
/* 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 */
char *notify_socket;
int epoll_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 */
/* Data specific to the swap filesystem */
bool request_reload;
/* Data specific to the D-Bus subsystem */
* before the reload we queue the
* reply message here, and
* afterwards we send it */
/* 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_run_queue:1;
bool dispatching_dbus_queue:1;
bool taint_usr:1;
bool show_status;
bool confirm_spawn;
/* 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;
/* Type=idle pipes */
int idle_pipe[2];
char *switch_root;
char *switch_root_init;
};
void manager_free(Manager *m);
int manager_enumerate(Manager *m);
int manager_coldplug(Manager *m);
int manager_load_unit_prepare(Manager *m, const char *name, const char *path, DBusError *e, Unit **_ret);
int manager_add_job(Manager *m, JobType type, Unit *unit, JobMode mode, bool force, DBusError *e, Job **_ret);
int manager_add_job_by_name(Manager *m, JobType type, const char *name, JobMode mode, bool force, DBusError *e, Job **_ret);
void manager_clear_jobs(Manager *m);
unsigned manager_dispatch_load_queue(Manager *m);
unsigned manager_dispatch_run_queue(Manager *m);
unsigned manager_dispatch_dbus_queue(Manager *m);
int manager_loop(Manager *m);
void manager_dispatch_bus_name_owner_changed(Manager *m, const char *name, const char* old_owner, const char *new_owner);
int manager_reload(Manager *m);
void manager_reset_failed(Manager *m);
void manager_check_finished(Manager *m);
void manager_run_generators(Manager *m);
void manager_undo_generators(Manager *m);
void manager_recheck_journal(Manager *m);
void manager_set_show_status(Manager *m, bool b);
void manager_status_printf(Manager *m, bool ephemeral, const char *status, const char *format, ...) _printf_attr_(4,5);
void watch_init(Watch *w);