]> git.ipfire.org Git - thirdparty/systemd.git/blob - manager.h
watch mount status file
[thirdparty/systemd.git] / manager.h
1 /*-*- Mode: C; c-basic-offset: 8 -*-*/
2
3 #ifndef foomanagerhfoo
4 #define foomanagerhfoo
5
6 #include <stdbool.h>
7 #include <inttypes.h>
8 #include <stdio.h>
9
10 typedef struct Manager Manager;
11 typedef enum WatchType WatchType;
12 typedef struct Watch Watch;
13
14 enum WatchType {
15 WATCH_INVALID,
16 WATCH_SIGNAL,
17 WATCH_FD,
18 WATCH_TIMER,
19 WATCH_MOUNT
20 };
21
22 struct Watch {
23 int fd;
24 WatchType type;
25 union Unit *unit;
26 };
27
28 #include "unit.h"
29 #include "job.h"
30 #include "hashmap.h"
31 #include "list.h"
32 #include "set.h"
33
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"
40
41 struct Manager {
42 uint32_t current_job_id;
43
44 /* Note that the set of units we know of is allowed to be
45 * incosistent. However the subset of it that is loaded may
46 * not, and the list of jobs may neither. */
47
48 /* Active jobs and units */
49 Hashmap *units; /* name string => Unit object n:1 */
50 Hashmap *jobs; /* job id => Job object 1:1 */
51
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
56 /* Units that need to be loaded */
57 LIST_HEAD(Meta, load_queue); /* this is actually more a stack than a queue, but uh. */
58
59 /* Jobs that need to be run */
60 LIST_HEAD(Job, run_queue); /* more a stack than a queue, too */
61
62 /* Jobs to be added */
63 Hashmap *transaction_jobs; /* Unit object => Job object list 1:1 */
64 JobDependency *transaction_anchor;
65
66 bool dispatching_load_queue:1;
67 bool dispatching_run_queue:1;
68
69 Hashmap *watch_pids; /* pid => Unit object n:1 */
70
71 int epoll_fd;
72
73 Watch signal_watch;
74
75 /* Data specific to the device subsystem */
76 struct udev* udev;
77
78 /* Data specific to the mount subsystem */
79 FILE *proc_self_mountinfo;
80 Watch mount_watch;
81 };
82
83 Manager* manager_new(void);
84 void manager_free(Manager *m);
85
86 int manager_coldplug(Manager *m);
87
88 Job *manager_get_job(Manager *m, uint32_t id);
89 Unit *manager_get_unit(Manager *m, const char *name);
90
91 int manager_load_unit(Manager *m, const char *path_or_name, Unit **_ret);
92 int manager_add_job(Manager *m, JobType type, Unit *unit, JobMode mode, bool force, Job **_ret);
93
94 void manager_dump_units(Manager *s, FILE *f, const char *prefix);
95 void manager_dump_jobs(Manager *s, FILE *f, const char *prefix);
96
97 void manager_transaction_unlink_job(Manager *m, Job *j);
98
99 void manager_clear_jobs(Manager *m);
100
101 void manager_dispatch_load_queue(Manager *m);
102 void manager_dispatch_run_queue(Manager *m);
103
104 int manager_loop(Manager *m);
105
106 #endif