]>
Commit | Line | Data |
---|---|---|
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 LP |
9 | |
10 | typedef struct Manager Manager; | |
acbb0225 LP |
11 | typedef enum WatchType WatchType; |
12 | typedef struct Watch Watch; | |
13 | ||
14 | enum WatchType { | |
15 | WATCH_INVALID, | |
ef734fd6 | 16 | WATCH_SIGNAL, |
acbb0225 | 17 | WATCH_FD, |
ef734fd6 LP |
18 | WATCH_TIMER, |
19 | WATCH_MOUNT | |
acbb0225 LP |
20 | }; |
21 | ||
22 | struct Watch { | |
23 | int fd; | |
24 | WatchType type; | |
25 | union Unit *unit; | |
26 | }; | |
60918275 | 27 | |
87f0e418 | 28 | #include "unit.h" |
60918275 LP |
29 | #include "job.h" |
30 | #include "hashmap.h" | |
31 | #include "list.h" | |
32 | #include "set.h" | |
33 | ||
f50e0a01 LP |
34 | #define SPECIAL_DEFAULT_TARGET "default.target" |
35 | #define SPECIAL_SYSLOG_SERVICE "syslog.service" | |
36 | #define SPECIAL_DBUS_SERVICE "messagebus.service" | |
37 | #define SPECIAL_LOGGER_SOCKET "systemd-logger.socket" | |
38 | #define SPECIAL_KBREQUEST_TARGET "kbrequest.target" | |
39 | #define SPECIAL_CTRL_ALT_DEL_TARGET "ctrl-alt-del.target" | |
ce578209 | 40 | |
60918275 LP |
41 | struct Manager { |
42 | uint32_t current_job_id; | |
43 | ||
87f0e418 | 44 | /* Note that the set of units we know of is allowed to be |
87d1515d LP |
45 | * incosistent. However the subset of it that is loaded may |
46 | * not, and the list of jobs may neither. */ | |
47 | ||
87f0e418 LP |
48 | /* Active jobs and units */ |
49 | Hashmap *units; /* name string => Unit object n:1 */ | |
60918275 LP |
50 | Hashmap *jobs; /* job id => Job object 1:1 */ |
51 | ||
ef734fd6 LP |
52 | /* To make it easy to iterate through the units of a specific |
53 | * type we maintain a per type linked list */ | |
54 | LIST_HEAD(Meta, units_per_type[_UNIT_TYPE_MAX]); | |
55 | ||
87f0e418 | 56 | /* Units that need to be loaded */ |
60918275 LP |
57 | LIST_HEAD(Meta, load_queue); /* this is actually more a stack than a queue, but uh. */ |
58 | ||
034c6ed7 LP |
59 | /* Jobs that need to be run */ |
60 | LIST_HEAD(Job, run_queue); /* more a stack than a queue, too */ | |
61 | ||
e5b5ae50 | 62 | /* Jobs to be added */ |
87f0e418 | 63 | Hashmap *transaction_jobs; /* Unit object => Job object list 1:1 */ |
e5b5ae50 | 64 | JobDependency *transaction_anchor; |
223dabab LP |
65 | |
66 | bool dispatching_load_queue:1; | |
034c6ed7 | 67 | bool dispatching_run_queue:1; |
5cb5a6ff | 68 | |
87f0e418 | 69 | Hashmap *watch_pids; /* pid => Unit object n:1 */ |
9152c765 LP |
70 | |
71 | int epoll_fd; | |
acbb0225 LP |
72 | |
73 | Watch signal_watch; | |
ce578209 | 74 | |
ef734fd6 | 75 | /* Data specific to the device subsystem */ |
25ac040b | 76 | struct udev* udev; |
ef734fd6 LP |
77 | |
78 | /* Data specific to the mount subsystem */ | |
79 | FILE *proc_self_mountinfo; | |
80 | Watch mount_watch; | |
60918275 LP |
81 | }; |
82 | ||
83 | Manager* manager_new(void); | |
84 | void manager_free(Manager *m); | |
85 | ||
f50e0a01 LP |
86 | int manager_coldplug(Manager *m); |
87 | ||
60918275 | 88 | Job *manager_get_job(Manager *m, uint32_t id); |
87f0e418 | 89 | Unit *manager_get_unit(Manager *m, const char *name); |
60918275 | 90 | |
0301abf4 | 91 | int manager_load_unit(Manager *m, const char *path_or_name, Unit **_ret); |
87f0e418 | 92 | int manager_add_job(Manager *m, JobType type, Unit *unit, JobMode mode, bool force, Job **_ret); |
60918275 | 93 | |
87f0e418 | 94 | void manager_dump_units(Manager *s, FILE *f, const char *prefix); |
cea8e32e | 95 | void manager_dump_jobs(Manager *s, FILE *f, const char *prefix); |
a66d02c3 | 96 | |
302d0040 | 97 | void manager_transaction_unlink_job(Manager *m, Job *j); |
e5b5ae50 | 98 | |
7fad411c LP |
99 | void manager_clear_jobs(Manager *m); |
100 | ||
f50e0a01 | 101 | void manager_dispatch_load_queue(Manager *m); |
034c6ed7 | 102 | void manager_dispatch_run_queue(Manager *m); |
f50e0a01 | 103 | |
9152c765 | 104 | int manager_loop(Manager *m); |
83c60c9f | 105 | |
60918275 | 106 | #endif |