]> git.ipfire.org Git - thirdparty/systemd.git/blame - manager.h
expose more properties
[thirdparty/systemd.git] / manager.h
CommitLineData
60918275
LP
1/*-*- Mode: C; c-basic-offset: 8 -*-*/
2
3#ifndef foomanagerhfoo
4#define foomanagerhfoo
5
6#include <stdbool.h>
7#include <inttypes.h>
a66d02c3 8#include <stdio.h>
60918275 9
ea430986
LP
10#include <dbus/dbus.h>
11
60918275 12typedef struct Manager Manager;
acbb0225
LP
13typedef enum WatchType WatchType;
14typedef struct Watch Watch;
15
16enum WatchType {
17 WATCH_INVALID,
ef734fd6 18 WATCH_SIGNAL,
acbb0225 19 WATCH_FD,
ef734fd6 20 WATCH_TIMER,
f94ea366 21 WATCH_MOUNT,
ea430986
LP
22 WATCH_UDEV,
23 WATCH_DBUS_WATCH,
24 WATCH_DBUS_TIMEOUT
acbb0225
LP
25};
26
27struct Watch {
28 int fd;
29 WatchType type;
ea430986
LP
30 bool fd_is_dupped;
31 union {
32 union Unit *unit;
33 DBusWatch *bus_watch;
34 DBusTimeout *bus_timeout;
35 } data;
acbb0225 36};
60918275 37
87f0e418 38#include "unit.h"
60918275
LP
39#include "job.h"
40#include "hashmap.h"
41#include "list.h"
42#include "set.h"
ea430986 43#include "dbus.h"
60918275 44
f50e0a01
LP
45#define SPECIAL_DEFAULT_TARGET "default.target"
46#define SPECIAL_SYSLOG_SERVICE "syslog.service"
47#define SPECIAL_DBUS_SERVICE "messagebus.service"
48#define SPECIAL_LOGGER_SOCKET "systemd-logger.socket"
49#define SPECIAL_KBREQUEST_TARGET "kbrequest.target"
50#define SPECIAL_CTRL_ALT_DEL_TARGET "ctrl-alt-del.target"
ce578209 51
60918275
LP
52struct Manager {
53 uint32_t current_job_id;
54
87f0e418 55 /* Note that the set of units we know of is allowed to be
87d1515d
LP
56 * incosistent. However the subset of it that is loaded may
57 * not, and the list of jobs may neither. */
58
87f0e418
LP
59 /* Active jobs and units */
60 Hashmap *units; /* name string => Unit object n:1 */
60918275
LP
61 Hashmap *jobs; /* job id => Job object 1:1 */
62
ef734fd6
LP
63 /* To make it easy to iterate through the units of a specific
64 * type we maintain a per type linked list */
65 LIST_HEAD(Meta, units_per_type[_UNIT_TYPE_MAX]);
66
87f0e418 67 /* Units that need to be loaded */
60918275
LP
68 LIST_HEAD(Meta, load_queue); /* this is actually more a stack than a queue, but uh. */
69
034c6ed7
LP
70 /* Jobs that need to be run */
71 LIST_HEAD(Job, run_queue); /* more a stack than a queue, too */
72
e5b5ae50 73 /* Jobs to be added */
87f0e418 74 Hashmap *transaction_jobs; /* Unit object => Job object list 1:1 */
e5b5ae50 75 JobDependency *transaction_anchor;
223dabab
LP
76
77 bool dispatching_load_queue:1;
034c6ed7 78 bool dispatching_run_queue:1;
5cb5a6ff 79
ea430986
LP
80 bool is_init:1;
81
82 bool request_bus_dispatch:1;
83
87f0e418 84 Hashmap *watch_pids; /* pid => Unit object n:1 */
9152c765
LP
85
86 int epoll_fd;
acbb0225
LP
87
88 Watch signal_watch;
ce578209 89
ef734fd6 90 /* Data specific to the device subsystem */
25ac040b 91 struct udev* udev;
f94ea366
LP
92 struct udev_monitor* udev_monitor;
93 Watch udev_watch;
ef734fd6
LP
94
95 /* Data specific to the mount subsystem */
96 FILE *proc_self_mountinfo;
97 Watch mount_watch;
ea430986
LP
98
99 /* Data specific to the D-Bus subsystem */
100 DBusConnection *bus;
60918275
LP
101};
102
103Manager* manager_new(void);
104void manager_free(Manager *m);
105
f50e0a01
LP
106int manager_coldplug(Manager *m);
107
60918275 108Job *manager_get_job(Manager *m, uint32_t id);
87f0e418 109Unit *manager_get_unit(Manager *m, const char *name);
60918275 110
ea430986
LP
111int manager_get_unit_from_dbus_path(Manager *m, const char *s, Unit **_u);
112
0301abf4 113int manager_load_unit(Manager *m, const char *path_or_name, Unit **_ret);
87f0e418 114int manager_add_job(Manager *m, JobType type, Unit *unit, JobMode mode, bool force, Job **_ret);
60918275 115
87f0e418 116void manager_dump_units(Manager *s, FILE *f, const char *prefix);
cea8e32e 117void manager_dump_jobs(Manager *s, FILE *f, const char *prefix);
a66d02c3 118
302d0040 119void manager_transaction_unlink_job(Manager *m, Job *j);
e5b5ae50 120
7fad411c
LP
121void manager_clear_jobs(Manager *m);
122
f50e0a01 123void manager_dispatch_load_queue(Manager *m);
034c6ed7 124void manager_dispatch_run_queue(Manager *m);
f50e0a01 125
9152c765 126int manager_loop(Manager *m);
83c60c9f 127
60918275 128#endif