File: | build-scan/../src/analyze/analyze.c |
Warning: | line 1047, column 9 Null pointer passed to 1st parameter expecting 'nonnull' |
Press '?' to see keyboard shortcuts
Keyboard shortcuts:
1 | /* SPDX-License-Identifier: LGPL-2.1+ */ | |||
2 | /*** | |||
3 | Copyright © 2013 Simon Peeters | |||
4 | ***/ | |||
5 | ||||
6 | #include <getopt.h> | |||
7 | #include <locale.h> | |||
8 | #include <stdio.h> | |||
9 | #include <stdlib.h> | |||
10 | ||||
11 | #include "sd-bus.h" | |||
12 | ||||
13 | #include "alloc-util.h" | |||
14 | #include "analyze-security.h" | |||
15 | #include "analyze-verify.h" | |||
16 | #include "bus-error.h" | |||
17 | #include "bus-unit-util.h" | |||
18 | #include "bus-util.h" | |||
19 | #include "calendarspec.h" | |||
20 | #include "def.h" | |||
21 | #include "conf-files.h" | |||
22 | #include "copy.h" | |||
23 | #include "fd-util.h" | |||
24 | #include "glob-util.h" | |||
25 | #include "hashmap.h" | |||
26 | #include "locale-util.h" | |||
27 | #include "log.h" | |||
28 | #include "pager.h" | |||
29 | #include "parse-util.h" | |||
30 | #include "path-util.h" | |||
31 | #if HAVE_SECCOMP1 | |||
32 | #include "seccomp-util.h" | |||
33 | #endif | |||
34 | #include "special.h" | |||
35 | #include "strv.h" | |||
36 | #include "strxcpyx.h" | |||
37 | #include "terminal-util.h" | |||
38 | #include "unit-name.h" | |||
39 | #include "util.h" | |||
40 | #include "verbs.h" | |||
41 | ||||
42 | #define SCALE_X(0.1 / 1000.0) (0.1 / 1000.0) /* pixels per us */ | |||
43 | #define SCALE_Y(20.0) (20.0) | |||
44 | ||||
45 | #define compare(a, b)(((a) > (b))? 1 : (((b) > (a))? -1 : 0)) (((a) > (b))? 1 : (((b) > (a))? -1 : 0)) | |||
46 | ||||
47 | #define svg(...)printf(...) printf(__VA_ARGS__) | |||
48 | ||||
49 | #define svg_bar(class, x1, x2, y)printf(" <rect class=\"%s\" x=\"%.03f\" y=\"%.03f\" width=\"%.03f\" height=\"%.03f\" />\n" , (class), (0.1 / 1000.0) * (x1), (20.0) * (y), (0.1 / 1000.0 ) * ((x2) - (x1)), (20.0) - 1.0) \ | |||
50 | svg(" <rect class=\"%s\" x=\"%.03f\" y=\"%.03f\" width=\"%.03f\" height=\"%.03f\" />\n", \printf(" <rect class=\"%s\" x=\"%.03f\" y=\"%.03f\" width=\"%.03f\" height=\"%.03f\" />\n" , (class), (0.1 / 1000.0) * (x1), (20.0) * (y), (0.1 / 1000.0 ) * ((x2) - (x1)), (20.0) - 1.0) | |||
51 | (class), \printf(" <rect class=\"%s\" x=\"%.03f\" y=\"%.03f\" width=\"%.03f\" height=\"%.03f\" />\n" , (class), (0.1 / 1000.0) * (x1), (20.0) * (y), (0.1 / 1000.0 ) * ((x2) - (x1)), (20.0) - 1.0) | |||
52 | SCALE_X * (x1), SCALE_Y * (y), \printf(" <rect class=\"%s\" x=\"%.03f\" y=\"%.03f\" width=\"%.03f\" height=\"%.03f\" />\n" , (class), (0.1 / 1000.0) * (x1), (20.0) * (y), (0.1 / 1000.0 ) * ((x2) - (x1)), (20.0) - 1.0) | |||
53 | SCALE_X * ((x2) - (x1)), SCALE_Y - 1.0)printf(" <rect class=\"%s\" x=\"%.03f\" y=\"%.03f\" width=\"%.03f\" height=\"%.03f\" />\n" , (class), (0.1 / 1000.0) * (x1), (20.0) * (y), (0.1 / 1000.0 ) * ((x2) - (x1)), (20.0) - 1.0) | |||
54 | ||||
55 | #define svg_text(b, x, y, format, ...)do { printf(" <text class=\"%s\" x=\"%.03f\" y=\"%.03f\">" , (b) ? "left" : "right", (0.1 / 1000.0) * (x) + (b ? 5.0 : - 5.0), (20.0) * (y) + 14.0); printf(format, ...); printf("</text>\n" ); } while (0) \ | |||
56 | do { \ | |||
57 | svg(" <text class=\"%s\" x=\"%.03f\" y=\"%.03f\">", (b) ? "left" : "right", SCALE_X * (x) + (b ? 5.0 : -5.0), SCALE_Y * (y) + 14.0)printf(" <text class=\"%s\" x=\"%.03f\" y=\"%.03f\">", (b) ? "left" : "right", (0.1 / 1000.0) * (x) + (b ? 5.0 : -5.0 ), (20.0) * (y) + 14.0); \ | |||
58 | svg(format, ## __VA_ARGS__)printf(format, ## __VA_ARGS__); \ | |||
59 | svg("</text>\n")printf("</text>\n"); \ | |||
60 | } while (false0) | |||
61 | ||||
62 | static enum dot { | |||
63 | DEP_ALL, | |||
64 | DEP_ORDER, | |||
65 | DEP_REQUIRE | |||
66 | } arg_dot = DEP_ALL; | |||
67 | static char** arg_dot_from_patterns = NULL((void*)0); | |||
68 | static char** arg_dot_to_patterns = NULL((void*)0); | |||
69 | static usec_t arg_fuzz = 0; | |||
70 | static bool_Bool arg_no_pager = false0; | |||
71 | static BusTransport arg_transport = BUS_TRANSPORT_LOCAL; | |||
72 | static const char *arg_host = NULL((void*)0); | |||
73 | static UnitFileScope arg_scope = UNIT_FILE_SYSTEM; | |||
74 | static bool_Bool arg_man = true1; | |||
75 | static bool_Bool arg_generators = false0; | |||
76 | static const char *arg_root = NULL((void*)0); | |||
77 | ||||
78 | struct boot_times { | |||
79 | usec_t firmware_time; | |||
80 | usec_t loader_time; | |||
81 | usec_t kernel_time; | |||
82 | usec_t kernel_done_time; | |||
83 | usec_t initrd_time; | |||
84 | usec_t userspace_time; | |||
85 | usec_t finish_time; | |||
86 | usec_t security_start_time; | |||
87 | usec_t security_finish_time; | |||
88 | usec_t generators_start_time; | |||
89 | usec_t generators_finish_time; | |||
90 | usec_t unitsload_start_time; | |||
91 | usec_t unitsload_finish_time; | |||
92 | ||||
93 | /* | |||
94 | * If we're analyzing the user instance, all timestamps will be offset | |||
95 | * by its own start-up timestamp, which may be arbitrarily big. | |||
96 | * With "plot", this causes arbitrarily wide output SVG files which almost | |||
97 | * completely consist of empty space. Thus we cancel out this offset. | |||
98 | * | |||
99 | * This offset is subtracted from times above by acquire_boot_times(), | |||
100 | * but it still needs to be subtracted from unit-specific timestamps | |||
101 | * (so it is stored here for reference). | |||
102 | */ | |||
103 | usec_t reverse_offset; | |||
104 | }; | |||
105 | ||||
106 | struct unit_times { | |||
107 | bool_Bool has_data; | |||
108 | char *name; | |||
109 | usec_t activating; | |||
110 | usec_t activated; | |||
111 | usec_t deactivated; | |||
112 | usec_t deactivating; | |||
113 | usec_t time; | |||
114 | }; | |||
115 | ||||
116 | struct host_info { | |||
117 | char *hostname; | |||
118 | char *kernel_name; | |||
119 | char *kernel_release; | |||
120 | char *kernel_version; | |||
121 | char *os_pretty_name; | |||
122 | char *virtualization; | |||
123 | char *architecture; | |||
124 | }; | |||
125 | ||||
126 | static int acquire_bus(sd_bus **bus, bool_Bool *use_full_bus) { | |||
127 | bool_Bool user = arg_scope != UNIT_FILE_SYSTEM; | |||
128 | int r; | |||
129 | ||||
130 | if (use_full_bus && *use_full_bus) { | |||
131 | r = bus_connect_transport(arg_transport, arg_host, user, bus); | |||
132 | if (IN_SET(r, 0, -EHOSTDOWN)({ _Bool _found = 0; static __attribute__ ((unused)) char _static_assert__macros_need_to_be_extended [20 - sizeof((int[]){0, -112})/sizeof(int)]; switch(r) { case 0: case -112: _found = 1; break; default: break; } _found; } )) | |||
133 | return r; | |||
134 | ||||
135 | *use_full_bus = false0; | |||
136 | } | |||
137 | ||||
138 | return bus_connect_transport_systemd(arg_transport, arg_host, user, bus); | |||
139 | } | |||
140 | ||||
141 | static int bus_get_uint64_property(sd_bus *bus, const char *path, const char *interface, const char *property, uint64_t *val) { | |||
142 | _cleanup_(sd_bus_error_free)__attribute__((cleanup(sd_bus_error_free))) sd_bus_error error = SD_BUS_ERROR_NULL((const sd_bus_error) {(((void*)0)), (((void*)0)), 0}); | |||
143 | int r; | |||
144 | ||||
145 | assert(bus)do { if ((__builtin_expect(!!(!(bus)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("bus"), "../src/analyze/analyze.c", 145, __PRETTY_FUNCTION__); } while (0); | |||
146 | assert(path)do { if ((__builtin_expect(!!(!(path)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("path"), "../src/analyze/analyze.c", 146 , __PRETTY_FUNCTION__); } while (0); | |||
147 | assert(interface)do { if ((__builtin_expect(!!(!(interface)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("interface"), "../src/analyze/analyze.c" , 147, __PRETTY_FUNCTION__); } while (0); | |||
148 | assert(property)do { if ((__builtin_expect(!!(!(property)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("property"), "../src/analyze/analyze.c", 148, __PRETTY_FUNCTION__); } while (0); | |||
149 | assert(val)do { if ((__builtin_expect(!!(!(val)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("val"), "../src/analyze/analyze.c", 149, __PRETTY_FUNCTION__); } while (0); | |||
150 | ||||
151 | r = sd_bus_get_property_trivial( | |||
152 | bus, | |||
153 | "org.freedesktop.systemd1", | |||
154 | path, | |||
155 | interface, | |||
156 | property, | |||
157 | &error, | |||
158 | 't', val); | |||
159 | ||||
160 | if (r < 0) | |||
161 | return log_error_errno(r, "Failed to parse reply: %s", bus_error_message(&error, -r))({ int _level = ((3)), _e = ((r)), _realm = (LOG_REALM_SYSTEMD ); (log_get_max_level_realm(_realm) >= ((_level) & 0x07 )) ? log_internal_realm(((_realm) << 10 | (_level)), _e , "../src/analyze/analyze.c", 161, __func__, "Failed to parse reply: %s" , bus_error_message(&error, -r)) : -abs(_e); }); | |||
162 | ||||
163 | return 0; | |||
164 | } | |||
165 | ||||
166 | static int bus_get_unit_property_strv(sd_bus *bus, const char *path, const char *property, char ***strv) { | |||
167 | _cleanup_(sd_bus_error_free)__attribute__((cleanup(sd_bus_error_free))) sd_bus_error error = SD_BUS_ERROR_NULL((const sd_bus_error) {(((void*)0)), (((void*)0)), 0}); | |||
168 | int r; | |||
169 | ||||
170 | assert(bus)do { if ((__builtin_expect(!!(!(bus)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("bus"), "../src/analyze/analyze.c", 170, __PRETTY_FUNCTION__); } while (0); | |||
171 | assert(path)do { if ((__builtin_expect(!!(!(path)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("path"), "../src/analyze/analyze.c", 171 , __PRETTY_FUNCTION__); } while (0); | |||
172 | assert(property)do { if ((__builtin_expect(!!(!(property)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("property"), "../src/analyze/analyze.c", 172, __PRETTY_FUNCTION__); } while (0); | |||
173 | assert(strv)do { if ((__builtin_expect(!!(!(strv)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("strv"), "../src/analyze/analyze.c", 173 , __PRETTY_FUNCTION__); } while (0); | |||
174 | ||||
175 | r = sd_bus_get_property_strv( | |||
176 | bus, | |||
177 | "org.freedesktop.systemd1", | |||
178 | path, | |||
179 | "org.freedesktop.systemd1.Unit", | |||
180 | property, | |||
181 | &error, | |||
182 | strv); | |||
183 | if (r < 0) | |||
184 | return log_error_errno(r, "Failed to get unit property %s: %s", property, bus_error_message(&error, -r))({ int _level = ((3)), _e = ((r)), _realm = (LOG_REALM_SYSTEMD ); (log_get_max_level_realm(_realm) >= ((_level) & 0x07 )) ? log_internal_realm(((_realm) << 10 | (_level)), _e , "../src/analyze/analyze.c", 184, __func__, "Failed to get unit property %s: %s" , property, bus_error_message(&error, -r)) : -abs(_e); }); | |||
185 | ||||
186 | return 0; | |||
187 | } | |||
188 | ||||
189 | static int compare_unit_time(const void *a, const void *b) { | |||
190 | return compare(((struct unit_times *)b)->time,(((((struct unit_times *)b)->time) > (((struct unit_times *)a)->time))? 1 : (((((struct unit_times *)a)->time) > (((struct unit_times *)b)->time))? -1 : 0)) | |||
191 | ((struct unit_times *)a)->time)(((((struct unit_times *)b)->time) > (((struct unit_times *)a)->time))? 1 : (((((struct unit_times *)a)->time) > (((struct unit_times *)b)->time))? -1 : 0)); | |||
192 | } | |||
193 | ||||
194 | static int compare_unit_start(const void *a, const void *b) { | |||
195 | return compare(((struct unit_times *)a)->activating,(((((struct unit_times *)a)->activating) > (((struct unit_times *)b)->activating))? 1 : (((((struct unit_times *)b)->activating ) > (((struct unit_times *)a)->activating))? -1 : 0)) | |||
196 | ((struct unit_times *)b)->activating)(((((struct unit_times *)a)->activating) > (((struct unit_times *)b)->activating))? 1 : (((((struct unit_times *)b)->activating ) > (((struct unit_times *)a)->activating))? -1 : 0)); | |||
197 | } | |||
198 | ||||
199 | static void unit_times_free(struct unit_times *t) { | |||
200 | struct unit_times *p; | |||
201 | ||||
202 | for (p = t; p->has_data; p++) | |||
203 | free(p->name); | |||
204 | free(t); | |||
205 | } | |||
206 | ||||
207 | DEFINE_TRIVIAL_CLEANUP_FUNC(struct unit_times *, unit_times_free)static inline void unit_times_freep(struct unit_times * *p) { if (*p) unit_times_free(*p); }; | |||
208 | ||||
209 | static void subtract_timestamp(usec_t *a, usec_t b) { | |||
210 | assert(a)do { if ((__builtin_expect(!!(!(a)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("a"), "../src/analyze/analyze.c", 210, __PRETTY_FUNCTION__ ); } while (0); | |||
211 | ||||
212 | if (*a > 0) { | |||
213 | assert(*a >= b)do { if ((__builtin_expect(!!(!(*a >= b)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("*a >= b"), "../src/analyze/analyze.c" , 213, __PRETTY_FUNCTION__); } while (0); | |||
214 | *a -= b; | |||
215 | } | |||
216 | } | |||
217 | ||||
218 | static int acquire_boot_times(sd_bus *bus, struct boot_times **bt) { | |||
219 | static struct boot_times times; | |||
220 | static bool_Bool cached = false0; | |||
221 | ||||
222 | if (cached) | |||
223 | goto finish; | |||
224 | ||||
225 | assert_cc(sizeof(usec_t) == sizeof(uint64_t))GCC diagnostic push
; GCC diagnostic ignored "-Wdeclaration-after-statement" ; struct _assert_struct_33 { char x[(sizeof(usec_t) == sizeof (uint64_t)) ? 0 : -1]; }; GCC diagnostic pop ; | |||
226 | ||||
227 | if (bus_get_uint64_property(bus, | |||
228 | "/org/freedesktop/systemd1", | |||
229 | "org.freedesktop.systemd1.Manager", | |||
230 | "FirmwareTimestampMonotonic", | |||
231 | ×.firmware_time) < 0 || | |||
232 | bus_get_uint64_property(bus, | |||
233 | "/org/freedesktop/systemd1", | |||
234 | "org.freedesktop.systemd1.Manager", | |||
235 | "LoaderTimestampMonotonic", | |||
236 | ×.loader_time) < 0 || | |||
237 | bus_get_uint64_property(bus, | |||
238 | "/org/freedesktop/systemd1", | |||
239 | "org.freedesktop.systemd1.Manager", | |||
240 | "KernelTimestamp", | |||
241 | ×.kernel_time) < 0 || | |||
242 | bus_get_uint64_property(bus, | |||
243 | "/org/freedesktop/systemd1", | |||
244 | "org.freedesktop.systemd1.Manager", | |||
245 | "InitRDTimestampMonotonic", | |||
246 | ×.initrd_time) < 0 || | |||
247 | bus_get_uint64_property(bus, | |||
248 | "/org/freedesktop/systemd1", | |||
249 | "org.freedesktop.systemd1.Manager", | |||
250 | "UserspaceTimestampMonotonic", | |||
251 | ×.userspace_time) < 0 || | |||
252 | bus_get_uint64_property(bus, | |||
253 | "/org/freedesktop/systemd1", | |||
254 | "org.freedesktop.systemd1.Manager", | |||
255 | "FinishTimestampMonotonic", | |||
256 | ×.finish_time) < 0 || | |||
257 | bus_get_uint64_property(bus, | |||
258 | "/org/freedesktop/systemd1", | |||
259 | "org.freedesktop.systemd1.Manager", | |||
260 | "SecurityStartTimestampMonotonic", | |||
261 | ×.security_start_time) < 0 || | |||
262 | bus_get_uint64_property(bus, | |||
263 | "/org/freedesktop/systemd1", | |||
264 | "org.freedesktop.systemd1.Manager", | |||
265 | "SecurityFinishTimestampMonotonic", | |||
266 | ×.security_finish_time) < 0 || | |||
267 | bus_get_uint64_property(bus, | |||
268 | "/org/freedesktop/systemd1", | |||
269 | "org.freedesktop.systemd1.Manager", | |||
270 | "GeneratorsStartTimestampMonotonic", | |||
271 | ×.generators_start_time) < 0 || | |||
272 | bus_get_uint64_property(bus, | |||
273 | "/org/freedesktop/systemd1", | |||
274 | "org.freedesktop.systemd1.Manager", | |||
275 | "GeneratorsFinishTimestampMonotonic", | |||
276 | ×.generators_finish_time) < 0 || | |||
277 | bus_get_uint64_property(bus, | |||
278 | "/org/freedesktop/systemd1", | |||
279 | "org.freedesktop.systemd1.Manager", | |||
280 | "UnitsLoadStartTimestampMonotonic", | |||
281 | ×.unitsload_start_time) < 0 || | |||
282 | bus_get_uint64_property(bus, | |||
283 | "/org/freedesktop/systemd1", | |||
284 | "org.freedesktop.systemd1.Manager", | |||
285 | "UnitsLoadFinishTimestampMonotonic", | |||
286 | ×.unitsload_finish_time) < 0) | |||
287 | return -EIO5; | |||
288 | ||||
289 | if (times.finish_time <= 0) { | |||
290 | log_error("Bootup is not yet finished (org.freedesktop.systemd1.Manager.FinishTimestampMonotonic=%"PRIu64").\n"({ int _level = (((3))), _e = ((0)), _realm = (LOG_REALM_SYSTEMD ); (log_get_max_level_realm(_realm) >= ((_level) & 0x07 )) ? log_internal_realm(((_realm) << 10 | (_level)), _e , "../src/analyze/analyze.c", 294, __func__, "Bootup is not yet finished (org.freedesktop.systemd1.Manager.FinishTimestampMonotonic=%" "l" "u"").\n" "Please try again later.\n" "Hint: Use 'systemctl%s list-jobs' to see active jobs" , times.finish_time, arg_scope == UNIT_FILE_SYSTEM ? "" : " --user" ) : -abs(_e); }) | |||
291 | "Please try again later.\n"({ int _level = (((3))), _e = ((0)), _realm = (LOG_REALM_SYSTEMD ); (log_get_max_level_realm(_realm) >= ((_level) & 0x07 )) ? log_internal_realm(((_realm) << 10 | (_level)), _e , "../src/analyze/analyze.c", 294, __func__, "Bootup is not yet finished (org.freedesktop.systemd1.Manager.FinishTimestampMonotonic=%" "l" "u"").\n" "Please try again later.\n" "Hint: Use 'systemctl%s list-jobs' to see active jobs" , times.finish_time, arg_scope == UNIT_FILE_SYSTEM ? "" : " --user" ) : -abs(_e); }) | |||
292 | "Hint: Use 'systemctl%s list-jobs' to see active jobs",({ int _level = (((3))), _e = ((0)), _realm = (LOG_REALM_SYSTEMD ); (log_get_max_level_realm(_realm) >= ((_level) & 0x07 )) ? log_internal_realm(((_realm) << 10 | (_level)), _e , "../src/analyze/analyze.c", 294, __func__, "Bootup is not yet finished (org.freedesktop.systemd1.Manager.FinishTimestampMonotonic=%" "l" "u"").\n" "Please try again later.\n" "Hint: Use 'systemctl%s list-jobs' to see active jobs" , times.finish_time, arg_scope == UNIT_FILE_SYSTEM ? "" : " --user" ) : -abs(_e); }) | |||
293 | times.finish_time,({ int _level = (((3))), _e = ((0)), _realm = (LOG_REALM_SYSTEMD ); (log_get_max_level_realm(_realm) >= ((_level) & 0x07 )) ? log_internal_realm(((_realm) << 10 | (_level)), _e , "../src/analyze/analyze.c", 294, __func__, "Bootup is not yet finished (org.freedesktop.systemd1.Manager.FinishTimestampMonotonic=%" "l" "u"").\n" "Please try again later.\n" "Hint: Use 'systemctl%s list-jobs' to see active jobs" , times.finish_time, arg_scope == UNIT_FILE_SYSTEM ? "" : " --user" ) : -abs(_e); }) | |||
294 | arg_scope == UNIT_FILE_SYSTEM ? "" : " --user")({ int _level = (((3))), _e = ((0)), _realm = (LOG_REALM_SYSTEMD ); (log_get_max_level_realm(_realm) >= ((_level) & 0x07 )) ? log_internal_realm(((_realm) << 10 | (_level)), _e , "../src/analyze/analyze.c", 294, __func__, "Bootup is not yet finished (org.freedesktop.systemd1.Manager.FinishTimestampMonotonic=%" "l" "u"").\n" "Please try again later.\n" "Hint: Use 'systemctl%s list-jobs' to see active jobs" , times.finish_time, arg_scope == UNIT_FILE_SYSTEM ? "" : " --user" ) : -abs(_e); }); | |||
295 | return -EINPROGRESS115; | |||
296 | } | |||
297 | ||||
298 | if (arg_scope == UNIT_FILE_SYSTEM) { | |||
299 | if (times.initrd_time > 0) | |||
300 | times.kernel_done_time = times.initrd_time; | |||
301 | else | |||
302 | times.kernel_done_time = times.userspace_time; | |||
303 | } else { | |||
304 | /* | |||
305 | * User-instance-specific timestamps processing | |||
306 | * (see comment to reverse_offset in struct boot_times). | |||
307 | */ | |||
308 | times.reverse_offset = times.userspace_time; | |||
309 | ||||
310 | times.firmware_time = times.loader_time = times.kernel_time = times.initrd_time = times.userspace_time = 0; | |||
311 | subtract_timestamp(×.finish_time, times.reverse_offset); | |||
312 | ||||
313 | subtract_timestamp(×.security_start_time, times.reverse_offset); | |||
314 | subtract_timestamp(×.security_finish_time, times.reverse_offset); | |||
315 | ||||
316 | subtract_timestamp(×.generators_start_time, times.reverse_offset); | |||
317 | subtract_timestamp(×.generators_finish_time, times.reverse_offset); | |||
318 | ||||
319 | subtract_timestamp(×.unitsload_start_time, times.reverse_offset); | |||
320 | subtract_timestamp(×.unitsload_finish_time, times.reverse_offset); | |||
321 | } | |||
322 | ||||
323 | cached = true1; | |||
324 | ||||
325 | finish: | |||
326 | *bt = × | |||
327 | return 0; | |||
328 | } | |||
329 | ||||
330 | static void free_host_info(struct host_info *hi) { | |||
331 | ||||
332 | if (!hi) | |||
333 | return; | |||
334 | ||||
335 | free(hi->hostname); | |||
336 | free(hi->kernel_name); | |||
337 | free(hi->kernel_release); | |||
338 | free(hi->kernel_version); | |||
339 | free(hi->os_pretty_name); | |||
340 | free(hi->virtualization); | |||
341 | free(hi->architecture); | |||
342 | free(hi); | |||
343 | } | |||
344 | ||||
345 | DEFINE_TRIVIAL_CLEANUP_FUNC(struct host_info*, free_host_info)static inline void free_host_infop(struct host_info* *p) { if (*p) free_host_info(*p); }; | |||
346 | ||||
347 | static int acquire_time_data(sd_bus *bus, struct unit_times **out) { | |||
348 | _cleanup_(sd_bus_message_unrefp)__attribute__((cleanup(sd_bus_message_unrefp))) sd_bus_message *reply = NULL((void*)0); | |||
349 | _cleanup_(sd_bus_error_free)__attribute__((cleanup(sd_bus_error_free))) sd_bus_error error = SD_BUS_ERROR_NULL((const sd_bus_error) {(((void*)0)), (((void*)0)), 0}); | |||
350 | int r, c = 0; | |||
351 | struct boot_times *boot_times = NULL((void*)0); | |||
352 | _cleanup_(unit_times_freep)__attribute__((cleanup(unit_times_freep))) struct unit_times *unit_times = NULL((void*)0); | |||
353 | size_t size = 0; | |||
354 | UnitInfo u; | |||
355 | ||||
356 | r = acquire_boot_times(bus, &boot_times); | |||
357 | if (r
| |||
358 | return r; | |||
359 | ||||
360 | r = sd_bus_call_method( | |||
361 | bus, | |||
362 | "org.freedesktop.systemd1", | |||
363 | "/org/freedesktop/systemd1", | |||
364 | "org.freedesktop.systemd1.Manager", | |||
365 | "ListUnits", | |||
366 | &error, &reply, | |||
367 | NULL((void*)0)); | |||
368 | if (r < 0) | |||
369 | return log_error_errno(r, "Failed to list units: %s", bus_error_message(&error, -r))({ int _level = ((3)), _e = ((r)), _realm = (LOG_REALM_SYSTEMD ); (log_get_max_level_realm(_realm) >= ((_level) & 0x07 )) ? log_internal_realm(((_realm) << 10 | (_level)), _e , "../src/analyze/analyze.c", 369, __func__, "Failed to list units: %s" , bus_error_message(&error, -r)) : -abs(_e); }); | |||
370 | ||||
371 | r = sd_bus_message_enter_container(reply, SD_BUS_TYPE_ARRAY, "(ssssssouso)"); | |||
372 | if (r < 0) | |||
373 | return bus_log_parse_error(r); | |||
374 | ||||
375 | while ((r = bus_parse_unit_info(reply, &u)) > 0) { | |||
376 | struct unit_times *t; | |||
377 | ||||
378 | if (!GREEDY_REALLOC(unit_times, size, c+2)greedy_realloc((void**) &(unit_times), &(size), (c+2) , sizeof((unit_times)[0]))) | |||
379 | return log_oom()log_oom_internal(LOG_REALM_SYSTEMD, "../src/analyze/analyze.c" , 379, __func__); | |||
380 | ||||
381 | unit_times[c+1].has_data = false0; | |||
382 | t = &unit_times[c]; | |||
383 | t->name = NULL((void*)0); | |||
384 | ||||
385 | assert_cc(sizeof(usec_t) == sizeof(uint64_t))GCC diagnostic push
; GCC diagnostic ignored "-Wdeclaration-after-statement" ; struct _assert_struct_34 { char x[(sizeof(usec_t) == sizeof (uint64_t)) ? 0 : -1]; }; GCC diagnostic pop ; | |||
386 | ||||
387 | if (bus_get_uint64_property(bus, u.unit_path, | |||
388 | "org.freedesktop.systemd1.Unit", | |||
389 | "InactiveExitTimestampMonotonic", | |||
390 | &t->activating) < 0 || | |||
391 | bus_get_uint64_property(bus, u.unit_path, | |||
392 | "org.freedesktop.systemd1.Unit", | |||
393 | "ActiveEnterTimestampMonotonic", | |||
394 | &t->activated) < 0 || | |||
395 | bus_get_uint64_property(bus, u.unit_path, | |||
396 | "org.freedesktop.systemd1.Unit", | |||
397 | "ActiveExitTimestampMonotonic", | |||
398 | &t->deactivating) < 0 || | |||
399 | bus_get_uint64_property(bus, u.unit_path, | |||
400 | "org.freedesktop.systemd1.Unit", | |||
401 | "InactiveEnterTimestampMonotonic", | |||
402 | &t->deactivated) < 0) | |||
403 | return -EIO5; | |||
404 | ||||
405 | subtract_timestamp(&t->activating, boot_times->reverse_offset); | |||
406 | subtract_timestamp(&t->activated, boot_times->reverse_offset); | |||
407 | subtract_timestamp(&t->deactivating, boot_times->reverse_offset); | |||
408 | subtract_timestamp(&t->deactivated, boot_times->reverse_offset); | |||
409 | ||||
410 | if (t->activated >= t->activating) | |||
411 | t->time = t->activated - t->activating; | |||
412 | else if (t->deactivated >= t->activating) | |||
413 | t->time = t->deactivated - t->activating; | |||
414 | else | |||
415 | t->time = 0; | |||
416 | ||||
417 | if (t->activating == 0) | |||
418 | continue; | |||
419 | ||||
420 | t->name = strdup(u.id); | |||
421 | if (!t->name) | |||
422 | return log_oom()log_oom_internal(LOG_REALM_SYSTEMD, "../src/analyze/analyze.c" , 422, __func__); | |||
423 | ||||
424 | t->has_data = true1; | |||
425 | c++; | |||
426 | } | |||
427 | if (r < 0) | |||
428 | return bus_log_parse_error(r); | |||
429 | ||||
430 | *out = TAKE_PTR(unit_times)({ typeof(unit_times) _ptr_ = (unit_times); (unit_times) = (( void*)0); _ptr_; }); | |||
431 | return c; | |||
432 | } | |||
433 | ||||
434 | static int acquire_host_info(sd_bus *bus, struct host_info **hi) { | |||
435 | static const struct bus_properties_map hostname_map[] = { | |||
436 | { "Hostname", "s", NULL((void*)0), offsetof(struct host_info, hostname)__builtin_offsetof(struct host_info, hostname) }, | |||
437 | { "KernelName", "s", NULL((void*)0), offsetof(struct host_info, kernel_name)__builtin_offsetof(struct host_info, kernel_name) }, | |||
438 | { "KernelRelease", "s", NULL((void*)0), offsetof(struct host_info, kernel_release)__builtin_offsetof(struct host_info, kernel_release) }, | |||
439 | { "KernelVersion", "s", NULL((void*)0), offsetof(struct host_info, kernel_version)__builtin_offsetof(struct host_info, kernel_version) }, | |||
440 | { "OperatingSystemPrettyName", "s", NULL((void*)0), offsetof(struct host_info, os_pretty_name)__builtin_offsetof(struct host_info, os_pretty_name) }, | |||
441 | {} | |||
442 | }; | |||
443 | ||||
444 | static const struct bus_properties_map manager_map[] = { | |||
445 | { "Virtualization", "s", NULL((void*)0), offsetof(struct host_info, virtualization)__builtin_offsetof(struct host_info, virtualization) }, | |||
446 | { "Architecture", "s", NULL((void*)0), offsetof(struct host_info, architecture)__builtin_offsetof(struct host_info, architecture) }, | |||
447 | {} | |||
448 | }; | |||
449 | ||||
450 | _cleanup_(sd_bus_error_free)__attribute__((cleanup(sd_bus_error_free))) sd_bus_error error = SD_BUS_ERROR_NULL((const sd_bus_error) {(((void*)0)), (((void*)0)), 0}); | |||
451 | _cleanup_(free_host_infop)__attribute__((cleanup(free_host_infop))) struct host_info *host; | |||
452 | int r; | |||
453 | ||||
454 | host = new0(struct host_info, 1)((struct host_info*) calloc((1), sizeof(struct host_info))); | |||
455 | if (!host) | |||
456 | return log_oom()log_oom_internal(LOG_REALM_SYSTEMD, "../src/analyze/analyze.c" , 456, __func__); | |||
457 | ||||
458 | r = bus_map_all_properties(bus, | |||
459 | "org.freedesktop.hostname1", | |||
460 | "/org/freedesktop/hostname1", | |||
461 | hostname_map, | |||
462 | BUS_MAP_STRDUP, | |||
463 | &error, | |||
464 | NULL((void*)0), | |||
465 | host); | |||
466 | if (r < 0) | |||
467 | log_debug_errno(r, "Failed to get host information from systemd-hostnamed: %s", bus_error_message(&error, r))({ int _level = ((7)), _e = ((r)), _realm = (LOG_REALM_SYSTEMD ); (log_get_max_level_realm(_realm) >= ((_level) & 0x07 )) ? log_internal_realm(((_realm) << 10 | (_level)), _e , "../src/analyze/analyze.c", 467, __func__, "Failed to get host information from systemd-hostnamed: %s" , bus_error_message(&error, r)) : -abs(_e); }); | |||
468 | ||||
469 | r = bus_map_all_properties(bus, | |||
470 | "org.freedesktop.systemd1", | |||
471 | "/org/freedesktop/systemd1", | |||
472 | manager_map, | |||
473 | BUS_MAP_STRDUP, | |||
474 | &error, | |||
475 | NULL((void*)0), | |||
476 | host); | |||
477 | if (r < 0) | |||
478 | return log_error_errno(r, "Failed to get host information from systemd: %s", bus_error_message(&error, r))({ int _level = ((3)), _e = ((r)), _realm = (LOG_REALM_SYSTEMD ); (log_get_max_level_realm(_realm) >= ((_level) & 0x07 )) ? log_internal_realm(((_realm) << 10 | (_level)), _e , "../src/analyze/analyze.c", 478, __func__, "Failed to get host information from systemd: %s" , bus_error_message(&error, r)) : -abs(_e); }); | |||
479 | ||||
480 | *hi = TAKE_PTR(host)({ typeof(host) _ptr_ = (host); (host) = ((void*)0); _ptr_; } ); | |||
481 | ||||
482 | return 0; | |||
483 | } | |||
484 | ||||
485 | static int pretty_boot_time(sd_bus *bus, char **_buf) { | |||
486 | char ts[FORMAT_TIMESPAN_MAX64]; | |||
487 | struct boot_times *t; | |||
488 | static char buf[4096]; | |||
489 | size_t size; | |||
490 | char *ptr; | |||
491 | int r; | |||
492 | usec_t activated_time = USEC_INFINITY((usec_t) -1); | |||
493 | _cleanup_free___attribute__((cleanup(freep))) char* path = NULL((void*)0), *unit_id = NULL((void*)0); | |||
494 | _cleanup_(sd_bus_error_free)__attribute__((cleanup(sd_bus_error_free))) sd_bus_error error = SD_BUS_ERROR_NULL((const sd_bus_error) {(((void*)0)), (((void*)0)), 0}); | |||
495 | ||||
496 | r = acquire_boot_times(bus, &t); | |||
497 | if (r < 0) | |||
498 | return r; | |||
499 | ||||
500 | path = unit_dbus_path_from_name(SPECIAL_DEFAULT_TARGET"default.target"); | |||
501 | if (!path) | |||
502 | return log_oom()log_oom_internal(LOG_REALM_SYSTEMD, "../src/analyze/analyze.c" , 502, __func__); | |||
503 | ||||
504 | r = sd_bus_get_property_string( | |||
505 | bus, | |||
506 | "org.freedesktop.systemd1", | |||
507 | path, | |||
508 | "org.freedesktop.systemd1.Unit", | |||
509 | "Id", | |||
510 | &error, | |||
511 | &unit_id); | |||
512 | if (r < 0) { | |||
513 | log_error_errno(r, "default.target doesn't seem to exist: %s", bus_error_message(&error, r))({ int _level = ((3)), _e = ((r)), _realm = (LOG_REALM_SYSTEMD ); (log_get_max_level_realm(_realm) >= ((_level) & 0x07 )) ? log_internal_realm(((_realm) << 10 | (_level)), _e , "../src/analyze/analyze.c", 513, __func__, "default.target doesn't seem to exist: %s" , bus_error_message(&error, r)) : -abs(_e); }); | |||
514 | unit_id = NULL((void*)0); | |||
515 | } | |||
516 | ||||
517 | r = bus_get_uint64_property(bus, path, | |||
518 | "org.freedesktop.systemd1.Unit", | |||
519 | "ActiveEnterTimestampMonotonic", | |||
520 | &activated_time); | |||
521 | if (r < 0) { | |||
522 | log_info_errno(r, "Could not get time to reach default.target. Continuing...")({ int _level = ((6)), _e = ((r)), _realm = (LOG_REALM_SYSTEMD ); (log_get_max_level_realm(_realm) >= ((_level) & 0x07 )) ? log_internal_realm(((_realm) << 10 | (_level)), _e , "../src/analyze/analyze.c", 522, __func__, "Could not get time to reach default.target. Continuing..." ) : -abs(_e); }); | |||
523 | activated_time = USEC_INFINITY((usec_t) -1); | |||
524 | } | |||
525 | ||||
526 | ptr = buf; | |||
527 | size = sizeof(buf); | |||
528 | ||||
529 | size = strpcpyf(&ptr, size, "Startup finished in "); | |||
530 | if (t->firmware_time > 0) | |||
531 | size = strpcpyf(&ptr, size, "%s (firmware) + ", format_timespan(ts, sizeof(ts), t->firmware_time - t->loader_time, USEC_PER_MSEC((usec_t) 1000ULL))); | |||
532 | if (t->loader_time > 0) | |||
533 | size = strpcpyf(&ptr, size, "%s (loader) + ", format_timespan(ts, sizeof(ts), t->loader_time, USEC_PER_MSEC((usec_t) 1000ULL))); | |||
534 | if (t->kernel_time > 0) | |||
535 | size = strpcpyf(&ptr, size, "%s (kernel) + ", format_timespan(ts, sizeof(ts), t->kernel_done_time, USEC_PER_MSEC((usec_t) 1000ULL))); | |||
536 | if (t->initrd_time > 0) | |||
537 | size = strpcpyf(&ptr, size, "%s (initrd) + ", format_timespan(ts, sizeof(ts), t->userspace_time - t->initrd_time, USEC_PER_MSEC((usec_t) 1000ULL))); | |||
538 | ||||
539 | size = strpcpyf(&ptr, size, "%s (userspace) ", format_timespan(ts, sizeof(ts), t->finish_time - t->userspace_time, USEC_PER_MSEC((usec_t) 1000ULL))); | |||
540 | if (t->kernel_time > 0) | |||
541 | strpcpyf(&ptr, size, "= %s", format_timespan(ts, sizeof(ts), t->firmware_time + t->finish_time, USEC_PER_MSEC((usec_t) 1000ULL))); | |||
542 | ||||
543 | if (unit_id && activated_time > 0 && activated_time != USEC_INFINITY((usec_t) -1)) | |||
544 | size = strpcpyf(&ptr, size, "\n%s reached after %s in userspace", unit_id, format_timespan(ts, sizeof(ts), activated_time - t->userspace_time, USEC_PER_MSEC((usec_t) 1000ULL))); | |||
545 | else if (unit_id && activated_time == 0) | |||
546 | size = strpcpyf(&ptr, size, "\n%s was never reached", unit_id); | |||
547 | else if (unit_id && activated_time == USEC_INFINITY((usec_t) -1)) | |||
548 | size = strpcpyf(&ptr, size, "\nCould not get time to reach %s.",unit_id); | |||
549 | else if (!unit_id) | |||
550 | size = strpcpyf(&ptr, size, "\ncould not find default.target"); | |||
551 | ||||
552 | ptr = strdup(buf); | |||
553 | if (!ptr) | |||
554 | return log_oom()log_oom_internal(LOG_REALM_SYSTEMD, "../src/analyze/analyze.c" , 554, __func__); | |||
555 | ||||
556 | *_buf = ptr; | |||
557 | return 0; | |||
558 | } | |||
559 | ||||
560 | static void svg_graph_box(double height, double begin, double end) { | |||
561 | long long i; | |||
562 | ||||
563 | /* outside box, fill */ | |||
564 | svg("<rect class=\"box\" x=\"0\" y=\"0\" width=\"%.03f\" height=\"%.03f\" />\n",printf("<rect class=\"box\" x=\"0\" y=\"0\" width=\"%.03f\" height=\"%.03f\" />\n" , (0.1 / 1000.0) * (end - begin), (20.0) * height) | |||
565 | SCALE_X * (end - begin), SCALE_Y * height)printf("<rect class=\"box\" x=\"0\" y=\"0\" width=\"%.03f\" height=\"%.03f\" />\n" , (0.1 / 1000.0) * (end - begin), (20.0) * height); | |||
566 | ||||
567 | for (i = ((long long) (begin / 100000)) * 100000; i <= end; i+=100000) { | |||
568 | /* lines for each second */ | |||
569 | if (i % 5000000 == 0) | |||
570 | svg(" <line class=\"sec5\" x1=\"%.03f\" y1=\"0\" x2=\"%.03f\" y2=\"%.03f\" />\n"printf(" <line class=\"sec5\" x1=\"%.03f\" y1=\"0\" x2=\"%.03f\" y2=\"%.03f\" />\n" " <text class=\"sec\" x=\"%.03f\" y=\"%.03f\" >%.01fs</text>\n" , (0.1 / 1000.0) * i, (0.1 / 1000.0) * i, (20.0) * height, (0.1 / 1000.0) * i, -5.0, 0.000001 * i) | |||
571 | " <text class=\"sec\" x=\"%.03f\" y=\"%.03f\" >%.01fs</text>\n",printf(" <line class=\"sec5\" x1=\"%.03f\" y1=\"0\" x2=\"%.03f\" y2=\"%.03f\" />\n" " <text class=\"sec\" x=\"%.03f\" y=\"%.03f\" >%.01fs</text>\n" , (0.1 / 1000.0) * i, (0.1 / 1000.0) * i, (20.0) * height, (0.1 / 1000.0) * i, -5.0, 0.000001 * i) | |||
572 | SCALE_X * i, SCALE_X * i, SCALE_Y * height, SCALE_X * i, -5.0, 0.000001 * i)printf(" <line class=\"sec5\" x1=\"%.03f\" y1=\"0\" x2=\"%.03f\" y2=\"%.03f\" />\n" " <text class=\"sec\" x=\"%.03f\" y=\"%.03f\" >%.01fs</text>\n" , (0.1 / 1000.0) * i, (0.1 / 1000.0) * i, (20.0) * height, (0.1 / 1000.0) * i, -5.0, 0.000001 * i); | |||
573 | else if (i % 1000000 == 0) | |||
574 | svg(" <line class=\"sec1\" x1=\"%.03f\" y1=\"0\" x2=\"%.03f\" y2=\"%.03f\" />\n"printf(" <line class=\"sec1\" x1=\"%.03f\" y1=\"0\" x2=\"%.03f\" y2=\"%.03f\" />\n" " <text class=\"sec\" x=\"%.03f\" y=\"%.03f\" >%.01fs</text>\n" , (0.1 / 1000.0) * i, (0.1 / 1000.0) * i, (20.0) * height, (0.1 / 1000.0) * i, -5.0, 0.000001 * i) | |||
575 | " <text class=\"sec\" x=\"%.03f\" y=\"%.03f\" >%.01fs</text>\n",printf(" <line class=\"sec1\" x1=\"%.03f\" y1=\"0\" x2=\"%.03f\" y2=\"%.03f\" />\n" " <text class=\"sec\" x=\"%.03f\" y=\"%.03f\" >%.01fs</text>\n" , (0.1 / 1000.0) * i, (0.1 / 1000.0) * i, (20.0) * height, (0.1 / 1000.0) * i, -5.0, 0.000001 * i) | |||
576 | SCALE_X * i, SCALE_X * i, SCALE_Y * height, SCALE_X * i, -5.0, 0.000001 * i)printf(" <line class=\"sec1\" x1=\"%.03f\" y1=\"0\" x2=\"%.03f\" y2=\"%.03f\" />\n" " <text class=\"sec\" x=\"%.03f\" y=\"%.03f\" >%.01fs</text>\n" , (0.1 / 1000.0) * i, (0.1 / 1000.0) * i, (20.0) * height, (0.1 / 1000.0) * i, -5.0, 0.000001 * i); | |||
577 | else | |||
578 | svg(" <line class=\"sec01\" x1=\"%.03f\" y1=\"0\" x2=\"%.03f\" y2=\"%.03f\" />\n",printf(" <line class=\"sec01\" x1=\"%.03f\" y1=\"0\" x2=\"%.03f\" y2=\"%.03f\" />\n" , (0.1 / 1000.0) * i, (0.1 / 1000.0) * i, (20.0) * height) | |||
579 | SCALE_X * i, SCALE_X * i, SCALE_Y * height)printf(" <line class=\"sec01\" x1=\"%.03f\" y1=\"0\" x2=\"%.03f\" y2=\"%.03f\" />\n" , (0.1 / 1000.0) * i, (0.1 / 1000.0) * i, (20.0) * height); | |||
580 | } | |||
581 | } | |||
582 | ||||
583 | static int analyze_plot(int argc, char *argv[], void *userdata) { | |||
584 | _cleanup_(free_host_infop)__attribute__((cleanup(free_host_infop))) struct host_info *host = NULL((void*)0); | |||
585 | _cleanup_(sd_bus_flush_close_unrefp)__attribute__((cleanup(sd_bus_flush_close_unrefp))) sd_bus *bus = NULL((void*)0); | |||
586 | _cleanup_(unit_times_freep)__attribute__((cleanup(unit_times_freep))) struct unit_times *times = NULL((void*)0); | |||
587 | struct boot_times *boot; | |||
588 | int n, m = 1, y = 0, r; | |||
589 | bool_Bool use_full_bus = true1; | |||
590 | double width; | |||
591 | _cleanup_free___attribute__((cleanup(freep))) char *pretty_times = NULL((void*)0); | |||
592 | struct unit_times *u; | |||
593 | ||||
594 | r = acquire_bus(&bus, &use_full_bus); | |||
595 | if (r < 0) | |||
596 | return log_error_errno(r, "Failed to create bus connection: %m")({ int _level = ((3)), _e = ((r)), _realm = (LOG_REALM_SYSTEMD ); (log_get_max_level_realm(_realm) >= ((_level) & 0x07 )) ? log_internal_realm(((_realm) << 10 | (_level)), _e , "../src/analyze/analyze.c", 596, __func__, "Failed to create bus connection: %m" ) : -abs(_e); }); | |||
597 | ||||
598 | n = acquire_boot_times(bus, &boot); | |||
599 | if (n < 0) | |||
600 | return n; | |||
601 | ||||
602 | n = pretty_boot_time(bus, &pretty_times); | |||
603 | if (n < 0) | |||
604 | return n; | |||
605 | ||||
606 | if (use_full_bus) { | |||
607 | n = acquire_host_info(bus, &host); | |||
608 | if (n < 0) | |||
609 | return n; | |||
610 | } | |||
611 | ||||
612 | n = acquire_time_data(bus, ×); | |||
613 | if (n <= 0) | |||
614 | return n; | |||
615 | ||||
616 | qsort(times, n, sizeof(struct unit_times), compare_unit_start); | |||
617 | ||||
618 | width = SCALE_X(0.1 / 1000.0) * (boot->firmware_time + boot->finish_time); | |||
619 | if (width < 800.0) | |||
620 | width = 800.0; | |||
621 | ||||
622 | if (boot->firmware_time > boot->loader_time) | |||
623 | m++; | |||
624 | if (boot->loader_time > 0) { | |||
625 | m++; | |||
626 | if (width < 1000.0) | |||
627 | width = 1000.0; | |||
628 | } | |||
629 | if (boot->initrd_time > 0) | |||
630 | m++; | |||
631 | if (boot->kernel_time > 0) | |||
632 | m++; | |||
633 | ||||
634 | for (u = times; u->has_data; u++) { | |||
635 | double text_start, text_width; | |||
636 | ||||
637 | if (u->activating < boot->userspace_time || | |||
638 | u->activating > boot->finish_time) { | |||
639 | u->name = mfree(u->name); | |||
640 | continue; | |||
641 | } | |||
642 | ||||
643 | /* If the text cannot fit on the left side then | |||
644 | * increase the svg width so it fits on the right. | |||
645 | * TODO: calculate the text width more accurately */ | |||
646 | text_width = 8.0 * strlen(u->name); | |||
647 | text_start = (boot->firmware_time + u->activating) * SCALE_X(0.1 / 1000.0); | |||
648 | if (text_width > text_start && text_width + text_start > width) | |||
649 | width = text_width + text_start; | |||
650 | ||||
651 | if (u->deactivated > u->activating && u->deactivated <= boot->finish_time | |||
652 | && u->activated == 0 && u->deactivating == 0) | |||
653 | u->activated = u->deactivating = u->deactivated; | |||
654 | if (u->activated < u->activating || u->activated > boot->finish_time) | |||
655 | u->activated = boot->finish_time; | |||
656 | if (u->deactivating < u->activated || u->activated > boot->finish_time) | |||
657 | u->deactivating = boot->finish_time; | |||
658 | if (u->deactivated < u->deactivating || u->deactivated > boot->finish_time) | |||
659 | u->deactivated = boot->finish_time; | |||
660 | m++; | |||
661 | } | |||
662 | ||||
663 | svg("<?xml version=\"1.0\" standalone=\"no\"?>\n"printf("<?xml version=\"1.0\" standalone=\"no\"?>\n" "<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\" " "\"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">\n" ) | |||
664 | "<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\" "printf("<?xml version=\"1.0\" standalone=\"no\"?>\n" "<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\" " "\"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">\n" ) | |||
665 | "\"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">\n")printf("<?xml version=\"1.0\" standalone=\"no\"?>\n" "<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\" " "\"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">\n" ); | |||
666 | ||||
667 | svg("<svg width=\"%.0fpx\" height=\"%.0fpx\" version=\"1.1\" "printf("<svg width=\"%.0fpx\" height=\"%.0fpx\" version=\"1.1\" " "xmlns=\"http://www.w3.org/2000/svg\">\n\n", 80.0 + width , 150.0 + (m * (20.0)) + 5 * (20.0)) | |||
668 | "xmlns=\"http://www.w3.org/2000/svg\">\n\n",printf("<svg width=\"%.0fpx\" height=\"%.0fpx\" version=\"1.1\" " "xmlns=\"http://www.w3.org/2000/svg\">\n\n", 80.0 + width , 150.0 + (m * (20.0)) + 5 * (20.0)) | |||
669 | 80.0 + width, 150.0 + (m * SCALE_Y) +printf("<svg width=\"%.0fpx\" height=\"%.0fpx\" version=\"1.1\" " "xmlns=\"http://www.w3.org/2000/svg\">\n\n", 80.0 + width , 150.0 + (m * (20.0)) + 5 * (20.0)) | |||
670 | 5 * SCALE_Y /* legend */)printf("<svg width=\"%.0fpx\" height=\"%.0fpx\" version=\"1.1\" " "xmlns=\"http://www.w3.org/2000/svg\">\n\n", 80.0 + width , 150.0 + (m * (20.0)) + 5 * (20.0)); | |||
671 | ||||
672 | /* write some basic info as a comment, including some help */ | |||
673 | svg("<!-- This file is a systemd-analyze SVG file. It is best rendered in a -->\n"printf("<!-- This file is a systemd-analyze SVG file. It is best rendered in a -->\n" "<!-- browser such as Chrome, Chromium or Firefox. Other applications -->\n" "<!-- that render these files properly but much slower are ImageMagick, -->\n" "<!-- gimp, inkscape, etc. To display the files on your system, just -->\n" "<!-- point your browser to this file. -->\n\n" "<!-- This plot was generated by systemd-analyze version %-16.16s -->\n\n" , "239") | |||
674 | "<!-- browser such as Chrome, Chromium or Firefox. Other applications -->\n"printf("<!-- This file is a systemd-analyze SVG file. It is best rendered in a -->\n" "<!-- browser such as Chrome, Chromium or Firefox. Other applications -->\n" "<!-- that render these files properly but much slower are ImageMagick, -->\n" "<!-- gimp, inkscape, etc. To display the files on your system, just -->\n" "<!-- point your browser to this file. -->\n\n" "<!-- This plot was generated by systemd-analyze version %-16.16s -->\n\n" , "239") | |||
675 | "<!-- that render these files properly but much slower are ImageMagick, -->\n"printf("<!-- This file is a systemd-analyze SVG file. It is best rendered in a -->\n" "<!-- browser such as Chrome, Chromium or Firefox. Other applications -->\n" "<!-- that render these files properly but much slower are ImageMagick, -->\n" "<!-- gimp, inkscape, etc. To display the files on your system, just -->\n" "<!-- point your browser to this file. -->\n\n" "<!-- This plot was generated by systemd-analyze version %-16.16s -->\n\n" , "239") | |||
676 | "<!-- gimp, inkscape, etc. To display the files on your system, just -->\n"printf("<!-- This file is a systemd-analyze SVG file. It is best rendered in a -->\n" "<!-- browser such as Chrome, Chromium or Firefox. Other applications -->\n" "<!-- that render these files properly but much slower are ImageMagick, -->\n" "<!-- gimp, inkscape, etc. To display the files on your system, just -->\n" "<!-- point your browser to this file. -->\n\n" "<!-- This plot was generated by systemd-analyze version %-16.16s -->\n\n" , "239") | |||
677 | "<!-- point your browser to this file. -->\n\n"printf("<!-- This file is a systemd-analyze SVG file. It is best rendered in a -->\n" "<!-- browser such as Chrome, Chromium or Firefox. Other applications -->\n" "<!-- that render these files properly but much slower are ImageMagick, -->\n" "<!-- gimp, inkscape, etc. To display the files on your system, just -->\n" "<!-- point your browser to this file. -->\n\n" "<!-- This plot was generated by systemd-analyze version %-16.16s -->\n\n" , "239") | |||
678 | "<!-- This plot was generated by systemd-analyze version %-16.16s -->\n\n", PACKAGE_VERSION)printf("<!-- This file is a systemd-analyze SVG file. It is best rendered in a -->\n" "<!-- browser such as Chrome, Chromium or Firefox. Other applications -->\n" "<!-- that render these files properly but much slower are ImageMagick, -->\n" "<!-- gimp, inkscape, etc. To display the files on your system, just -->\n" "<!-- point your browser to this file. -->\n\n" "<!-- This plot was generated by systemd-analyze version %-16.16s -->\n\n" , "239"); | |||
679 | ||||
680 | /* style sheet */ | |||
681 | svg("<defs>\n <style type=\"text/css\">\n <![CDATA[\n"printf("<defs>\n <style type=\"text/css\">\n <![CDATA[\n" " rect { stroke-width: 1; stroke-opacity: 0; }\n" " rect.background { fill: rgb(255,255,255); }\n" " rect.activating { fill: rgb(255,0,0); fill-opacity: 0.7; }\n" " rect.active { fill: rgb(200,150,150); fill-opacity: 0.7; }\n" " rect.deactivating { fill: rgb(150,100,100); fill-opacity: 0.7; }\n" " rect.kernel { fill: rgb(150,150,150); fill-opacity: 0.7; }\n" " rect.initrd { fill: rgb(150,150,150); fill-opacity: 0.7; }\n" " rect.firmware { fill: rgb(150,150,150); fill-opacity: 0.7; }\n" " rect.loader { fill: rgb(150,150,150); fill-opacity: 0.7; }\n" " rect.userspace { fill: rgb(150,150,150); fill-opacity: 0.7; }\n" " rect.security { fill: rgb(144,238,144); fill-opacity: 0.7; }\n" " rect.generators { fill: rgb(102,204,255); fill-opacity: 0.7; }\n" " rect.unitsload { fill: rgb( 82,184,255); fill-opacity: 0.7; }\n" " rect.box { fill: rgb(240,240,240); stroke: rgb(192,192,192); }\n" " line { stroke: rgb(64,64,64); stroke-width: 1; }\n" "// line.sec1 { }\n" " line.sec5 { stroke-width: 2; }\n" " line.sec01 { stroke: rgb(224,224,224); stroke-width: 1; }\n" " text { font-family: Verdana, Helvetica; font-size: 14px; }\n" " text.left { font-family: Verdana, Helvetica; font-size: 14px; text-anchor: start; }\n" " text.right { font-family: Verdana, Helvetica; font-size: 14px; text-anchor: end; }\n" " text.sec { font-size: 10px; }\n" " ]]>\n </style>\n</defs>\n\n" ) | |||
682 | " rect { stroke-width: 1; stroke-opacity: 0; }\n"printf("<defs>\n <style type=\"text/css\">\n <![CDATA[\n" " rect { stroke-width: 1; stroke-opacity: 0; }\n" " rect.background { fill: rgb(255,255,255); }\n" " rect.activating { fill: rgb(255,0,0); fill-opacity: 0.7; }\n" " rect.active { fill: rgb(200,150,150); fill-opacity: 0.7; }\n" " rect.deactivating { fill: rgb(150,100,100); fill-opacity: 0.7; }\n" " rect.kernel { fill: rgb(150,150,150); fill-opacity: 0.7; }\n" " rect.initrd { fill: rgb(150,150,150); fill-opacity: 0.7; }\n" " rect.firmware { fill: rgb(150,150,150); fill-opacity: 0.7; }\n" " rect.loader { fill: rgb(150,150,150); fill-opacity: 0.7; }\n" " rect.userspace { fill: rgb(150,150,150); fill-opacity: 0.7; }\n" " rect.security { fill: rgb(144,238,144); fill-opacity: 0.7; }\n" " rect.generators { fill: rgb(102,204,255); fill-opacity: 0.7; }\n" " rect.unitsload { fill: rgb( 82,184,255); fill-opacity: 0.7; }\n" " rect.box { fill: rgb(240,240,240); stroke: rgb(192,192,192); }\n" " line { stroke: rgb(64,64,64); stroke-width: 1; }\n" "// line.sec1 { }\n" " line.sec5 { stroke-width: 2; }\n" " line.sec01 { stroke: rgb(224,224,224); stroke-width: 1; }\n" " text { font-family: Verdana, Helvetica; font-size: 14px; }\n" " text.left { font-family: Verdana, Helvetica; font-size: 14px; text-anchor: start; }\n" " text.right { font-family: Verdana, Helvetica; font-size: 14px; text-anchor: end; }\n" " text.sec { font-size: 10px; }\n" " ]]>\n </style>\n</defs>\n\n" ) | |||
683 | " rect.background { fill: rgb(255,255,255); }\n"printf("<defs>\n <style type=\"text/css\">\n <![CDATA[\n" " rect { stroke-width: 1; stroke-opacity: 0; }\n" " rect.background { fill: rgb(255,255,255); }\n" " rect.activating { fill: rgb(255,0,0); fill-opacity: 0.7; }\n" " rect.active { fill: rgb(200,150,150); fill-opacity: 0.7; }\n" " rect.deactivating { fill: rgb(150,100,100); fill-opacity: 0.7; }\n" " rect.kernel { fill: rgb(150,150,150); fill-opacity: 0.7; }\n" " rect.initrd { fill: rgb(150,150,150); fill-opacity: 0.7; }\n" " rect.firmware { fill: rgb(150,150,150); fill-opacity: 0.7; }\n" " rect.loader { fill: rgb(150,150,150); fill-opacity: 0.7; }\n" " rect.userspace { fill: rgb(150,150,150); fill-opacity: 0.7; }\n" " rect.security { fill: rgb(144,238,144); fill-opacity: 0.7; }\n" " rect.generators { fill: rgb(102,204,255); fill-opacity: 0.7; }\n" " rect.unitsload { fill: rgb( 82,184,255); fill-opacity: 0.7; }\n" " rect.box { fill: rgb(240,240,240); stroke: rgb(192,192,192); }\n" " line { stroke: rgb(64,64,64); stroke-width: 1; }\n" "// line.sec1 { }\n" " line.sec5 { stroke-width: 2; }\n" " line.sec01 { stroke: rgb(224,224,224); stroke-width: 1; }\n" " text { font-family: Verdana, Helvetica; font-size: 14px; }\n" " text.left { font-family: Verdana, Helvetica; font-size: 14px; text-anchor: start; }\n" " text.right { font-family: Verdana, Helvetica; font-size: 14px; text-anchor: end; }\n" " text.sec { font-size: 10px; }\n" " ]]>\n </style>\n</defs>\n\n" ) | |||
684 | " rect.activating { fill: rgb(255,0,0); fill-opacity: 0.7; }\n"printf("<defs>\n <style type=\"text/css\">\n <![CDATA[\n" " rect { stroke-width: 1; stroke-opacity: 0; }\n" " rect.background { fill: rgb(255,255,255); }\n" " rect.activating { fill: rgb(255,0,0); fill-opacity: 0.7; }\n" " rect.active { fill: rgb(200,150,150); fill-opacity: 0.7; }\n" " rect.deactivating { fill: rgb(150,100,100); fill-opacity: 0.7; }\n" " rect.kernel { fill: rgb(150,150,150); fill-opacity: 0.7; }\n" " rect.initrd { fill: rgb(150,150,150); fill-opacity: 0.7; }\n" " rect.firmware { fill: rgb(150,150,150); fill-opacity: 0.7; }\n" " rect.loader { fill: rgb(150,150,150); fill-opacity: 0.7; }\n" " rect.userspace { fill: rgb(150,150,150); fill-opacity: 0.7; }\n" " rect.security { fill: rgb(144,238,144); fill-opacity: 0.7; }\n" " rect.generators { fill: rgb(102,204,255); fill-opacity: 0.7; }\n" " rect.unitsload { fill: rgb( 82,184,255); fill-opacity: 0.7; }\n" " rect.box { fill: rgb(240,240,240); stroke: rgb(192,192,192); }\n" " line { stroke: rgb(64,64,64); stroke-width: 1; }\n" "// line.sec1 { }\n" " line.sec5 { stroke-width: 2; }\n" " line.sec01 { stroke: rgb(224,224,224); stroke-width: 1; }\n" " text { font-family: Verdana, Helvetica; font-size: 14px; }\n" " text.left { font-family: Verdana, Helvetica; font-size: 14px; text-anchor: start; }\n" " text.right { font-family: Verdana, Helvetica; font-size: 14px; text-anchor: end; }\n" " text.sec { font-size: 10px; }\n" " ]]>\n </style>\n</defs>\n\n" ) | |||
685 | " rect.active { fill: rgb(200,150,150); fill-opacity: 0.7; }\n"printf("<defs>\n <style type=\"text/css\">\n <![CDATA[\n" " rect { stroke-width: 1; stroke-opacity: 0; }\n" " rect.background { fill: rgb(255,255,255); }\n" " rect.activating { fill: rgb(255,0,0); fill-opacity: 0.7; }\n" " rect.active { fill: rgb(200,150,150); fill-opacity: 0.7; }\n" " rect.deactivating { fill: rgb(150,100,100); fill-opacity: 0.7; }\n" " rect.kernel { fill: rgb(150,150,150); fill-opacity: 0.7; }\n" " rect.initrd { fill: rgb(150,150,150); fill-opacity: 0.7; }\n" " rect.firmware { fill: rgb(150,150,150); fill-opacity: 0.7; }\n" " rect.loader { fill: rgb(150,150,150); fill-opacity: 0.7; }\n" " rect.userspace { fill: rgb(150,150,150); fill-opacity: 0.7; }\n" " rect.security { fill: rgb(144,238,144); fill-opacity: 0.7; }\n" " rect.generators { fill: rgb(102,204,255); fill-opacity: 0.7; }\n" " rect.unitsload { fill: rgb( 82,184,255); fill-opacity: 0.7; }\n" " rect.box { fill: rgb(240,240,240); stroke: rgb(192,192,192); }\n" " line { stroke: rgb(64,64,64); stroke-width: 1; }\n" "// line.sec1 { }\n" " line.sec5 { stroke-width: 2; }\n" " line.sec01 { stroke: rgb(224,224,224); stroke-width: 1; }\n" " text { font-family: Verdana, Helvetica; font-size: 14px; }\n" " text.left { font-family: Verdana, Helvetica; font-size: 14px; text-anchor: start; }\n" " text.right { font-family: Verdana, Helvetica; font-size: 14px; text-anchor: end; }\n" " text.sec { font-size: 10px; }\n" " ]]>\n </style>\n</defs>\n\n" ) | |||
686 | " rect.deactivating { fill: rgb(150,100,100); fill-opacity: 0.7; }\n"printf("<defs>\n <style type=\"text/css\">\n <![CDATA[\n" " rect { stroke-width: 1; stroke-opacity: 0; }\n" " rect.background { fill: rgb(255,255,255); }\n" " rect.activating { fill: rgb(255,0,0); fill-opacity: 0.7; }\n" " rect.active { fill: rgb(200,150,150); fill-opacity: 0.7; }\n" " rect.deactivating { fill: rgb(150,100,100); fill-opacity: 0.7; }\n" " rect.kernel { fill: rgb(150,150,150); fill-opacity: 0.7; }\n" " rect.initrd { fill: rgb(150,150,150); fill-opacity: 0.7; }\n" " rect.firmware { fill: rgb(150,150,150); fill-opacity: 0.7; }\n" " rect.loader { fill: rgb(150,150,150); fill-opacity: 0.7; }\n" " rect.userspace { fill: rgb(150,150,150); fill-opacity: 0.7; }\n" " rect.security { fill: rgb(144,238,144); fill-opacity: 0.7; }\n" " rect.generators { fill: rgb(102,204,255); fill-opacity: 0.7; }\n" " rect.unitsload { fill: rgb( 82,184,255); fill-opacity: 0.7; }\n" " rect.box { fill: rgb(240,240,240); stroke: rgb(192,192,192); }\n" " line { stroke: rgb(64,64,64); stroke-width: 1; }\n" "// line.sec1 { }\n" " line.sec5 { stroke-width: 2; }\n" " line.sec01 { stroke: rgb(224,224,224); stroke-width: 1; }\n" " text { font-family: Verdana, Helvetica; font-size: 14px; }\n" " text.left { font-family: Verdana, Helvetica; font-size: 14px; text-anchor: start; }\n" " text.right { font-family: Verdana, Helvetica; font-size: 14px; text-anchor: end; }\n" " text.sec { font-size: 10px; }\n" " ]]>\n </style>\n</defs>\n\n" ) | |||
687 | " rect.kernel { fill: rgb(150,150,150); fill-opacity: 0.7; }\n"printf("<defs>\n <style type=\"text/css\">\n <![CDATA[\n" " rect { stroke-width: 1; stroke-opacity: 0; }\n" " rect.background { fill: rgb(255,255,255); }\n" " rect.activating { fill: rgb(255,0,0); fill-opacity: 0.7; }\n" " rect.active { fill: rgb(200,150,150); fill-opacity: 0.7; }\n" " rect.deactivating { fill: rgb(150,100,100); fill-opacity: 0.7; }\n" " rect.kernel { fill: rgb(150,150,150); fill-opacity: 0.7; }\n" " rect.initrd { fill: rgb(150,150,150); fill-opacity: 0.7; }\n" " rect.firmware { fill: rgb(150,150,150); fill-opacity: 0.7; }\n" " rect.loader { fill: rgb(150,150,150); fill-opacity: 0.7; }\n" " rect.userspace { fill: rgb(150,150,150); fill-opacity: 0.7; }\n" " rect.security { fill: rgb(144,238,144); fill-opacity: 0.7; }\n" " rect.generators { fill: rgb(102,204,255); fill-opacity: 0.7; }\n" " rect.unitsload { fill: rgb( 82,184,255); fill-opacity: 0.7; }\n" " rect.box { fill: rgb(240,240,240); stroke: rgb(192,192,192); }\n" " line { stroke: rgb(64,64,64); stroke-width: 1; }\n" "// line.sec1 { }\n" " line.sec5 { stroke-width: 2; }\n" " line.sec01 { stroke: rgb(224,224,224); stroke-width: 1; }\n" " text { font-family: Verdana, Helvetica; font-size: 14px; }\n" " text.left { font-family: Verdana, Helvetica; font-size: 14px; text-anchor: start; }\n" " text.right { font-family: Verdana, Helvetica; font-size: 14px; text-anchor: end; }\n" " text.sec { font-size: 10px; }\n" " ]]>\n </style>\n</defs>\n\n" ) | |||
688 | " rect.initrd { fill: rgb(150,150,150); fill-opacity: 0.7; }\n"printf("<defs>\n <style type=\"text/css\">\n <![CDATA[\n" " rect { stroke-width: 1; stroke-opacity: 0; }\n" " rect.background { fill: rgb(255,255,255); }\n" " rect.activating { fill: rgb(255,0,0); fill-opacity: 0.7; }\n" " rect.active { fill: rgb(200,150,150); fill-opacity: 0.7; }\n" " rect.deactivating { fill: rgb(150,100,100); fill-opacity: 0.7; }\n" " rect.kernel { fill: rgb(150,150,150); fill-opacity: 0.7; }\n" " rect.initrd { fill: rgb(150,150,150); fill-opacity: 0.7; }\n" " rect.firmware { fill: rgb(150,150,150); fill-opacity: 0.7; }\n" " rect.loader { fill: rgb(150,150,150); fill-opacity: 0.7; }\n" " rect.userspace { fill: rgb(150,150,150); fill-opacity: 0.7; }\n" " rect.security { fill: rgb(144,238,144); fill-opacity: 0.7; }\n" " rect.generators { fill: rgb(102,204,255); fill-opacity: 0.7; }\n" " rect.unitsload { fill: rgb( 82,184,255); fill-opacity: 0.7; }\n" " rect.box { fill: rgb(240,240,240); stroke: rgb(192,192,192); }\n" " line { stroke: rgb(64,64,64); stroke-width: 1; }\n" "// line.sec1 { }\n" " line.sec5 { stroke-width: 2; }\n" " line.sec01 { stroke: rgb(224,224,224); stroke-width: 1; }\n" " text { font-family: Verdana, Helvetica; font-size: 14px; }\n" " text.left { font-family: Verdana, Helvetica; font-size: 14px; text-anchor: start; }\n" " text.right { font-family: Verdana, Helvetica; font-size: 14px; text-anchor: end; }\n" " text.sec { font-size: 10px; }\n" " ]]>\n </style>\n</defs>\n\n" ) | |||
689 | " rect.firmware { fill: rgb(150,150,150); fill-opacity: 0.7; }\n"printf("<defs>\n <style type=\"text/css\">\n <![CDATA[\n" " rect { stroke-width: 1; stroke-opacity: 0; }\n" " rect.background { fill: rgb(255,255,255); }\n" " rect.activating { fill: rgb(255,0,0); fill-opacity: 0.7; }\n" " rect.active { fill: rgb(200,150,150); fill-opacity: 0.7; }\n" " rect.deactivating { fill: rgb(150,100,100); fill-opacity: 0.7; }\n" " rect.kernel { fill: rgb(150,150,150); fill-opacity: 0.7; }\n" " rect.initrd { fill: rgb(150,150,150); fill-opacity: 0.7; }\n" " rect.firmware { fill: rgb(150,150,150); fill-opacity: 0.7; }\n" " rect.loader { fill: rgb(150,150,150); fill-opacity: 0.7; }\n" " rect.userspace { fill: rgb(150,150,150); fill-opacity: 0.7; }\n" " rect.security { fill: rgb(144,238,144); fill-opacity: 0.7; }\n" " rect.generators { fill: rgb(102,204,255); fill-opacity: 0.7; }\n" " rect.unitsload { fill: rgb( 82,184,255); fill-opacity: 0.7; }\n" " rect.box { fill: rgb(240,240,240); stroke: rgb(192,192,192); }\n" " line { stroke: rgb(64,64,64); stroke-width: 1; }\n" "// line.sec1 { }\n" " line.sec5 { stroke-width: 2; }\n" " line.sec01 { stroke: rgb(224,224,224); stroke-width: 1; }\n" " text { font-family: Verdana, Helvetica; font-size: 14px; }\n" " text.left { font-family: Verdana, Helvetica; font-size: 14px; text-anchor: start; }\n" " text.right { font-family: Verdana, Helvetica; font-size: 14px; text-anchor: end; }\n" " text.sec { font-size: 10px; }\n" " ]]>\n </style>\n</defs>\n\n" ) | |||
690 | " rect.loader { fill: rgb(150,150,150); fill-opacity: 0.7; }\n"printf("<defs>\n <style type=\"text/css\">\n <![CDATA[\n" " rect { stroke-width: 1; stroke-opacity: 0; }\n" " rect.background { fill: rgb(255,255,255); }\n" " rect.activating { fill: rgb(255,0,0); fill-opacity: 0.7; }\n" " rect.active { fill: rgb(200,150,150); fill-opacity: 0.7; }\n" " rect.deactivating { fill: rgb(150,100,100); fill-opacity: 0.7; }\n" " rect.kernel { fill: rgb(150,150,150); fill-opacity: 0.7; }\n" " rect.initrd { fill: rgb(150,150,150); fill-opacity: 0.7; }\n" " rect.firmware { fill: rgb(150,150,150); fill-opacity: 0.7; }\n" " rect.loader { fill: rgb(150,150,150); fill-opacity: 0.7; }\n" " rect.userspace { fill: rgb(150,150,150); fill-opacity: 0.7; }\n" " rect.security { fill: rgb(144,238,144); fill-opacity: 0.7; }\n" " rect.generators { fill: rgb(102,204,255); fill-opacity: 0.7; }\n" " rect.unitsload { fill: rgb( 82,184,255); fill-opacity: 0.7; }\n" " rect.box { fill: rgb(240,240,240); stroke: rgb(192,192,192); }\n" " line { stroke: rgb(64,64,64); stroke-width: 1; }\n" "// line.sec1 { }\n" " line.sec5 { stroke-width: 2; }\n" " line.sec01 { stroke: rgb(224,224,224); stroke-width: 1; }\n" " text { font-family: Verdana, Helvetica; font-size: 14px; }\n" " text.left { font-family: Verdana, Helvetica; font-size: 14px; text-anchor: start; }\n" " text.right { font-family: Verdana, Helvetica; font-size: 14px; text-anchor: end; }\n" " text.sec { font-size: 10px; }\n" " ]]>\n </style>\n</defs>\n\n" ) | |||
691 | " rect.userspace { fill: rgb(150,150,150); fill-opacity: 0.7; }\n"printf("<defs>\n <style type=\"text/css\">\n <![CDATA[\n" " rect { stroke-width: 1; stroke-opacity: 0; }\n" " rect.background { fill: rgb(255,255,255); }\n" " rect.activating { fill: rgb(255,0,0); fill-opacity: 0.7; }\n" " rect.active { fill: rgb(200,150,150); fill-opacity: 0.7; }\n" " rect.deactivating { fill: rgb(150,100,100); fill-opacity: 0.7; }\n" " rect.kernel { fill: rgb(150,150,150); fill-opacity: 0.7; }\n" " rect.initrd { fill: rgb(150,150,150); fill-opacity: 0.7; }\n" " rect.firmware { fill: rgb(150,150,150); fill-opacity: 0.7; }\n" " rect.loader { fill: rgb(150,150,150); fill-opacity: 0.7; }\n" " rect.userspace { fill: rgb(150,150,150); fill-opacity: 0.7; }\n" " rect.security { fill: rgb(144,238,144); fill-opacity: 0.7; }\n" " rect.generators { fill: rgb(102,204,255); fill-opacity: 0.7; }\n" " rect.unitsload { fill: rgb( 82,184,255); fill-opacity: 0.7; }\n" " rect.box { fill: rgb(240,240,240); stroke: rgb(192,192,192); }\n" " line { stroke: rgb(64,64,64); stroke-width: 1; }\n" "// line.sec1 { }\n" " line.sec5 { stroke-width: 2; }\n" " line.sec01 { stroke: rgb(224,224,224); stroke-width: 1; }\n" " text { font-family: Verdana, Helvetica; font-size: 14px; }\n" " text.left { font-family: Verdana, Helvetica; font-size: 14px; text-anchor: start; }\n" " text.right { font-family: Verdana, Helvetica; font-size: 14px; text-anchor: end; }\n" " text.sec { font-size: 10px; }\n" " ]]>\n </style>\n</defs>\n\n" ) | |||
692 | " rect.security { fill: rgb(144,238,144); fill-opacity: 0.7; }\n"printf("<defs>\n <style type=\"text/css\">\n <![CDATA[\n" " rect { stroke-width: 1; stroke-opacity: 0; }\n" " rect.background { fill: rgb(255,255,255); }\n" " rect.activating { fill: rgb(255,0,0); fill-opacity: 0.7; }\n" " rect.active { fill: rgb(200,150,150); fill-opacity: 0.7; }\n" " rect.deactivating { fill: rgb(150,100,100); fill-opacity: 0.7; }\n" " rect.kernel { fill: rgb(150,150,150); fill-opacity: 0.7; }\n" " rect.initrd { fill: rgb(150,150,150); fill-opacity: 0.7; }\n" " rect.firmware { fill: rgb(150,150,150); fill-opacity: 0.7; }\n" " rect.loader { fill: rgb(150,150,150); fill-opacity: 0.7; }\n" " rect.userspace { fill: rgb(150,150,150); fill-opacity: 0.7; }\n" " rect.security { fill: rgb(144,238,144); fill-opacity: 0.7; }\n" " rect.generators { fill: rgb(102,204,255); fill-opacity: 0.7; }\n" " rect.unitsload { fill: rgb( 82,184,255); fill-opacity: 0.7; }\n" " rect.box { fill: rgb(240,240,240); stroke: rgb(192,192,192); }\n" " line { stroke: rgb(64,64,64); stroke-width: 1; }\n" "// line.sec1 { }\n" " line.sec5 { stroke-width: 2; }\n" " line.sec01 { stroke: rgb(224,224,224); stroke-width: 1; }\n" " text { font-family: Verdana, Helvetica; font-size: 14px; }\n" " text.left { font-family: Verdana, Helvetica; font-size: 14px; text-anchor: start; }\n" " text.right { font-family: Verdana, Helvetica; font-size: 14px; text-anchor: end; }\n" " text.sec { font-size: 10px; }\n" " ]]>\n </style>\n</defs>\n\n" ) | |||
693 | " rect.generators { fill: rgb(102,204,255); fill-opacity: 0.7; }\n"printf("<defs>\n <style type=\"text/css\">\n <![CDATA[\n" " rect { stroke-width: 1; stroke-opacity: 0; }\n" " rect.background { fill: rgb(255,255,255); }\n" " rect.activating { fill: rgb(255,0,0); fill-opacity: 0.7; }\n" " rect.active { fill: rgb(200,150,150); fill-opacity: 0.7; }\n" " rect.deactivating { fill: rgb(150,100,100); fill-opacity: 0.7; }\n" " rect.kernel { fill: rgb(150,150,150); fill-opacity: 0.7; }\n" " rect.initrd { fill: rgb(150,150,150); fill-opacity: 0.7; }\n" " rect.firmware { fill: rgb(150,150,150); fill-opacity: 0.7; }\n" " rect.loader { fill: rgb(150,150,150); fill-opacity: 0.7; }\n" " rect.userspace { fill: rgb(150,150,150); fill-opacity: 0.7; }\n" " rect.security { fill: rgb(144,238,144); fill-opacity: 0.7; }\n" " rect.generators { fill: rgb(102,204,255); fill-opacity: 0.7; }\n" " rect.unitsload { fill: rgb( 82,184,255); fill-opacity: 0.7; }\n" " rect.box { fill: rgb(240,240,240); stroke: rgb(192,192,192); }\n" " line { stroke: rgb(64,64,64); stroke-width: 1; }\n" "// line.sec1 { }\n" " line.sec5 { stroke-width: 2; }\n" " line.sec01 { stroke: rgb(224,224,224); stroke-width: 1; }\n" " text { font-family: Verdana, Helvetica; font-size: 14px; }\n" " text.left { font-family: Verdana, Helvetica; font-size: 14px; text-anchor: start; }\n" " text.right { font-family: Verdana, Helvetica; font-size: 14px; text-anchor: end; }\n" " text.sec { font-size: 10px; }\n" " ]]>\n </style>\n</defs>\n\n" ) | |||
694 | " rect.unitsload { fill: rgb( 82,184,255); fill-opacity: 0.7; }\n"printf("<defs>\n <style type=\"text/css\">\n <![CDATA[\n" " rect { stroke-width: 1; stroke-opacity: 0; }\n" " rect.background { fill: rgb(255,255,255); }\n" " rect.activating { fill: rgb(255,0,0); fill-opacity: 0.7; }\n" " rect.active { fill: rgb(200,150,150); fill-opacity: 0.7; }\n" " rect.deactivating { fill: rgb(150,100,100); fill-opacity: 0.7; }\n" " rect.kernel { fill: rgb(150,150,150); fill-opacity: 0.7; }\n" " rect.initrd { fill: rgb(150,150,150); fill-opacity: 0.7; }\n" " rect.firmware { fill: rgb(150,150,150); fill-opacity: 0.7; }\n" " rect.loader { fill: rgb(150,150,150); fill-opacity: 0.7; }\n" " rect.userspace { fill: rgb(150,150,150); fill-opacity: 0.7; }\n" " rect.security { fill: rgb(144,238,144); fill-opacity: 0.7; }\n" " rect.generators { fill: rgb(102,204,255); fill-opacity: 0.7; }\n" " rect.unitsload { fill: rgb( 82,184,255); fill-opacity: 0.7; }\n" " rect.box { fill: rgb(240,240,240); stroke: rgb(192,192,192); }\n" " line { stroke: rgb(64,64,64); stroke-width: 1; }\n" "// line.sec1 { }\n" " line.sec5 { stroke-width: 2; }\n" " line.sec01 { stroke: rgb(224,224,224); stroke-width: 1; }\n" " text { font-family: Verdana, Helvetica; font-size: 14px; }\n" " text.left { font-family: Verdana, Helvetica; font-size: 14px; text-anchor: start; }\n" " text.right { font-family: Verdana, Helvetica; font-size: 14px; text-anchor: end; }\n" " text.sec { font-size: 10px; }\n" " ]]>\n </style>\n</defs>\n\n" ) | |||
695 | " rect.box { fill: rgb(240,240,240); stroke: rgb(192,192,192); }\n"printf("<defs>\n <style type=\"text/css\">\n <![CDATA[\n" " rect { stroke-width: 1; stroke-opacity: 0; }\n" " rect.background { fill: rgb(255,255,255); }\n" " rect.activating { fill: rgb(255,0,0); fill-opacity: 0.7; }\n" " rect.active { fill: rgb(200,150,150); fill-opacity: 0.7; }\n" " rect.deactivating { fill: rgb(150,100,100); fill-opacity: 0.7; }\n" " rect.kernel { fill: rgb(150,150,150); fill-opacity: 0.7; }\n" " rect.initrd { fill: rgb(150,150,150); fill-opacity: 0.7; }\n" " rect.firmware { fill: rgb(150,150,150); fill-opacity: 0.7; }\n" " rect.loader { fill: rgb(150,150,150); fill-opacity: 0.7; }\n" " rect.userspace { fill: rgb(150,150,150); fill-opacity: 0.7; }\n" " rect.security { fill: rgb(144,238,144); fill-opacity: 0.7; }\n" " rect.generators { fill: rgb(102,204,255); fill-opacity: 0.7; }\n" " rect.unitsload { fill: rgb( 82,184,255); fill-opacity: 0.7; }\n" " rect.box { fill: rgb(240,240,240); stroke: rgb(192,192,192); }\n" " line { stroke: rgb(64,64,64); stroke-width: 1; }\n" "// line.sec1 { }\n" " line.sec5 { stroke-width: 2; }\n" " line.sec01 { stroke: rgb(224,224,224); stroke-width: 1; }\n" " text { font-family: Verdana, Helvetica; font-size: 14px; }\n" " text.left { font-family: Verdana, Helvetica; font-size: 14px; text-anchor: start; }\n" " text.right { font-family: Verdana, Helvetica; font-size: 14px; text-anchor: end; }\n" " text.sec { font-size: 10px; }\n" " ]]>\n </style>\n</defs>\n\n" ) | |||
696 | " line { stroke: rgb(64,64,64); stroke-width: 1; }\n"printf("<defs>\n <style type=\"text/css\">\n <![CDATA[\n" " rect { stroke-width: 1; stroke-opacity: 0; }\n" " rect.background { fill: rgb(255,255,255); }\n" " rect.activating { fill: rgb(255,0,0); fill-opacity: 0.7; }\n" " rect.active { fill: rgb(200,150,150); fill-opacity: 0.7; }\n" " rect.deactivating { fill: rgb(150,100,100); fill-opacity: 0.7; }\n" " rect.kernel { fill: rgb(150,150,150); fill-opacity: 0.7; }\n" " rect.initrd { fill: rgb(150,150,150); fill-opacity: 0.7; }\n" " rect.firmware { fill: rgb(150,150,150); fill-opacity: 0.7; }\n" " rect.loader { fill: rgb(150,150,150); fill-opacity: 0.7; }\n" " rect.userspace { fill: rgb(150,150,150); fill-opacity: 0.7; }\n" " rect.security { fill: rgb(144,238,144); fill-opacity: 0.7; }\n" " rect.generators { fill: rgb(102,204,255); fill-opacity: 0.7; }\n" " rect.unitsload { fill: rgb( 82,184,255); fill-opacity: 0.7; }\n" " rect.box { fill: rgb(240,240,240); stroke: rgb(192,192,192); }\n" " line { stroke: rgb(64,64,64); stroke-width: 1; }\n" "// line.sec1 { }\n" " line.sec5 { stroke-width: 2; }\n" " line.sec01 { stroke: rgb(224,224,224); stroke-width: 1; }\n" " text { font-family: Verdana, Helvetica; font-size: 14px; }\n" " text.left { font-family: Verdana, Helvetica; font-size: 14px; text-anchor: start; }\n" " text.right { font-family: Verdana, Helvetica; font-size: 14px; text-anchor: end; }\n" " text.sec { font-size: 10px; }\n" " ]]>\n </style>\n</defs>\n\n" ) | |||
697 | "// line.sec1 { }\n"printf("<defs>\n <style type=\"text/css\">\n <![CDATA[\n" " rect { stroke-width: 1; stroke-opacity: 0; }\n" " rect.background { fill: rgb(255,255,255); }\n" " rect.activating { fill: rgb(255,0,0); fill-opacity: 0.7; }\n" " rect.active { fill: rgb(200,150,150); fill-opacity: 0.7; }\n" " rect.deactivating { fill: rgb(150,100,100); fill-opacity: 0.7; }\n" " rect.kernel { fill: rgb(150,150,150); fill-opacity: 0.7; }\n" " rect.initrd { fill: rgb(150,150,150); fill-opacity: 0.7; }\n" " rect.firmware { fill: rgb(150,150,150); fill-opacity: 0.7; }\n" " rect.loader { fill: rgb(150,150,150); fill-opacity: 0.7; }\n" " rect.userspace { fill: rgb(150,150,150); fill-opacity: 0.7; }\n" " rect.security { fill: rgb(144,238,144); fill-opacity: 0.7; }\n" " rect.generators { fill: rgb(102,204,255); fill-opacity: 0.7; }\n" " rect.unitsload { fill: rgb( 82,184,255); fill-opacity: 0.7; }\n" " rect.box { fill: rgb(240,240,240); stroke: rgb(192,192,192); }\n" " line { stroke: rgb(64,64,64); stroke-width: 1; }\n" "// line.sec1 { }\n" " line.sec5 { stroke-width: 2; }\n" " line.sec01 { stroke: rgb(224,224,224); stroke-width: 1; }\n" " text { font-family: Verdana, Helvetica; font-size: 14px; }\n" " text.left { font-family: Verdana, Helvetica; font-size: 14px; text-anchor: start; }\n" " text.right { font-family: Verdana, Helvetica; font-size: 14px; text-anchor: end; }\n" " text.sec { font-size: 10px; }\n" " ]]>\n </style>\n</defs>\n\n" ) | |||
698 | " line.sec5 { stroke-width: 2; }\n"printf("<defs>\n <style type=\"text/css\">\n <![CDATA[\n" " rect { stroke-width: 1; stroke-opacity: 0; }\n" " rect.background { fill: rgb(255,255,255); }\n" " rect.activating { fill: rgb(255,0,0); fill-opacity: 0.7; }\n" " rect.active { fill: rgb(200,150,150); fill-opacity: 0.7; }\n" " rect.deactivating { fill: rgb(150,100,100); fill-opacity: 0.7; }\n" " rect.kernel { fill: rgb(150,150,150); fill-opacity: 0.7; }\n" " rect.initrd { fill: rgb(150,150,150); fill-opacity: 0.7; }\n" " rect.firmware { fill: rgb(150,150,150); fill-opacity: 0.7; }\n" " rect.loader { fill: rgb(150,150,150); fill-opacity: 0.7; }\n" " rect.userspace { fill: rgb(150,150,150); fill-opacity: 0.7; }\n" " rect.security { fill: rgb(144,238,144); fill-opacity: 0.7; }\n" " rect.generators { fill: rgb(102,204,255); fill-opacity: 0.7; }\n" " rect.unitsload { fill: rgb( 82,184,255); fill-opacity: 0.7; }\n" " rect.box { fill: rgb(240,240,240); stroke: rgb(192,192,192); }\n" " line { stroke: rgb(64,64,64); stroke-width: 1; }\n" "// line.sec1 { }\n" " line.sec5 { stroke-width: 2; }\n" " line.sec01 { stroke: rgb(224,224,224); stroke-width: 1; }\n" " text { font-family: Verdana, Helvetica; font-size: 14px; }\n" " text.left { font-family: Verdana, Helvetica; font-size: 14px; text-anchor: start; }\n" " text.right { font-family: Verdana, Helvetica; font-size: 14px; text-anchor: end; }\n" " text.sec { font-size: 10px; }\n" " ]]>\n </style>\n</defs>\n\n" ) | |||
699 | " line.sec01 { stroke: rgb(224,224,224); stroke-width: 1; }\n"printf("<defs>\n <style type=\"text/css\">\n <![CDATA[\n" " rect { stroke-width: 1; stroke-opacity: 0; }\n" " rect.background { fill: rgb(255,255,255); }\n" " rect.activating { fill: rgb(255,0,0); fill-opacity: 0.7; }\n" " rect.active { fill: rgb(200,150,150); fill-opacity: 0.7; }\n" " rect.deactivating { fill: rgb(150,100,100); fill-opacity: 0.7; }\n" " rect.kernel { fill: rgb(150,150,150); fill-opacity: 0.7; }\n" " rect.initrd { fill: rgb(150,150,150); fill-opacity: 0.7; }\n" " rect.firmware { fill: rgb(150,150,150); fill-opacity: 0.7; }\n" " rect.loader { fill: rgb(150,150,150); fill-opacity: 0.7; }\n" " rect.userspace { fill: rgb(150,150,150); fill-opacity: 0.7; }\n" " rect.security { fill: rgb(144,238,144); fill-opacity: 0.7; }\n" " rect.generators { fill: rgb(102,204,255); fill-opacity: 0.7; }\n" " rect.unitsload { fill: rgb( 82,184,255); fill-opacity: 0.7; }\n" " rect.box { fill: rgb(240,240,240); stroke: rgb(192,192,192); }\n" " line { stroke: rgb(64,64,64); stroke-width: 1; }\n" "// line.sec1 { }\n" " line.sec5 { stroke-width: 2; }\n" " line.sec01 { stroke: rgb(224,224,224); stroke-width: 1; }\n" " text { font-family: Verdana, Helvetica; font-size: 14px; }\n" " text.left { font-family: Verdana, Helvetica; font-size: 14px; text-anchor: start; }\n" " text.right { font-family: Verdana, Helvetica; font-size: 14px; text-anchor: end; }\n" " text.sec { font-size: 10px; }\n" " ]]>\n </style>\n</defs>\n\n" ) | |||
700 | " text { font-family: Verdana, Helvetica; font-size: 14px; }\n"printf("<defs>\n <style type=\"text/css\">\n <![CDATA[\n" " rect { stroke-width: 1; stroke-opacity: 0; }\n" " rect.background { fill: rgb(255,255,255); }\n" " rect.activating { fill: rgb(255,0,0); fill-opacity: 0.7; }\n" " rect.active { fill: rgb(200,150,150); fill-opacity: 0.7; }\n" " rect.deactivating { fill: rgb(150,100,100); fill-opacity: 0.7; }\n" " rect.kernel { fill: rgb(150,150,150); fill-opacity: 0.7; }\n" " rect.initrd { fill: rgb(150,150,150); fill-opacity: 0.7; }\n" " rect.firmware { fill: rgb(150,150,150); fill-opacity: 0.7; }\n" " rect.loader { fill: rgb(150,150,150); fill-opacity: 0.7; }\n" " rect.userspace { fill: rgb(150,150,150); fill-opacity: 0.7; }\n" " rect.security { fill: rgb(144,238,144); fill-opacity: 0.7; }\n" " rect.generators { fill: rgb(102,204,255); fill-opacity: 0.7; }\n" " rect.unitsload { fill: rgb( 82,184,255); fill-opacity: 0.7; }\n" " rect.box { fill: rgb(240,240,240); stroke: rgb(192,192,192); }\n" " line { stroke: rgb(64,64,64); stroke-width: 1; }\n" "// line.sec1 { }\n" " line.sec5 { stroke-width: 2; }\n" " line.sec01 { stroke: rgb(224,224,224); stroke-width: 1; }\n" " text { font-family: Verdana, Helvetica; font-size: 14px; }\n" " text.left { font-family: Verdana, Helvetica; font-size: 14px; text-anchor: start; }\n" " text.right { font-family: Verdana, Helvetica; font-size: 14px; text-anchor: end; }\n" " text.sec { font-size: 10px; }\n" " ]]>\n </style>\n</defs>\n\n" ) | |||
701 | " text.left { font-family: Verdana, Helvetica; font-size: 14px; text-anchor: start; }\n"printf("<defs>\n <style type=\"text/css\">\n <![CDATA[\n" " rect { stroke-width: 1; stroke-opacity: 0; }\n" " rect.background { fill: rgb(255,255,255); }\n" " rect.activating { fill: rgb(255,0,0); fill-opacity: 0.7; }\n" " rect.active { fill: rgb(200,150,150); fill-opacity: 0.7; }\n" " rect.deactivating { fill: rgb(150,100,100); fill-opacity: 0.7; }\n" " rect.kernel { fill: rgb(150,150,150); fill-opacity: 0.7; }\n" " rect.initrd { fill: rgb(150,150,150); fill-opacity: 0.7; }\n" " rect.firmware { fill: rgb(150,150,150); fill-opacity: 0.7; }\n" " rect.loader { fill: rgb(150,150,150); fill-opacity: 0.7; }\n" " rect.userspace { fill: rgb(150,150,150); fill-opacity: 0.7; }\n" " rect.security { fill: rgb(144,238,144); fill-opacity: 0.7; }\n" " rect.generators { fill: rgb(102,204,255); fill-opacity: 0.7; }\n" " rect.unitsload { fill: rgb( 82,184,255); fill-opacity: 0.7; }\n" " rect.box { fill: rgb(240,240,240); stroke: rgb(192,192,192); }\n" " line { stroke: rgb(64,64,64); stroke-width: 1; }\n" "// line.sec1 { }\n" " line.sec5 { stroke-width: 2; }\n" " line.sec01 { stroke: rgb(224,224,224); stroke-width: 1; }\n" " text { font-family: Verdana, Helvetica; font-size: 14px; }\n" " text.left { font-family: Verdana, Helvetica; font-size: 14px; text-anchor: start; }\n" " text.right { font-family: Verdana, Helvetica; font-size: 14px; text-anchor: end; }\n" " text.sec { font-size: 10px; }\n" " ]]>\n </style>\n</defs>\n\n" ) | |||
702 | " text.right { font-family: Verdana, Helvetica; font-size: 14px; text-anchor: end; }\n"printf("<defs>\n <style type=\"text/css\">\n <![CDATA[\n" " rect { stroke-width: 1; stroke-opacity: 0; }\n" " rect.background { fill: rgb(255,255,255); }\n" " rect.activating { fill: rgb(255,0,0); fill-opacity: 0.7; }\n" " rect.active { fill: rgb(200,150,150); fill-opacity: 0.7; }\n" " rect.deactivating { fill: rgb(150,100,100); fill-opacity: 0.7; }\n" " rect.kernel { fill: rgb(150,150,150); fill-opacity: 0.7; }\n" " rect.initrd { fill: rgb(150,150,150); fill-opacity: 0.7; }\n" " rect.firmware { fill: rgb(150,150,150); fill-opacity: 0.7; }\n" " rect.loader { fill: rgb(150,150,150); fill-opacity: 0.7; }\n" " rect.userspace { fill: rgb(150,150,150); fill-opacity: 0.7; }\n" " rect.security { fill: rgb(144,238,144); fill-opacity: 0.7; }\n" " rect.generators { fill: rgb(102,204,255); fill-opacity: 0.7; }\n" " rect.unitsload { fill: rgb( 82,184,255); fill-opacity: 0.7; }\n" " rect.box { fill: rgb(240,240,240); stroke: rgb(192,192,192); }\n" " line { stroke: rgb(64,64,64); stroke-width: 1; }\n" "// line.sec1 { }\n" " line.sec5 { stroke-width: 2; }\n" " line.sec01 { stroke: rgb(224,224,224); stroke-width: 1; }\n" " text { font-family: Verdana, Helvetica; font-size: 14px; }\n" " text.left { font-family: Verdana, Helvetica; font-size: 14px; text-anchor: start; }\n" " text.right { font-family: Verdana, Helvetica; font-size: 14px; text-anchor: end; }\n" " text.sec { font-size: 10px; }\n" " ]]>\n </style>\n</defs>\n\n" ) | |||
703 | " text.sec { font-size: 10px; }\n"printf("<defs>\n <style type=\"text/css\">\n <![CDATA[\n" " rect { stroke-width: 1; stroke-opacity: 0; }\n" " rect.background { fill: rgb(255,255,255); }\n" " rect.activating { fill: rgb(255,0,0); fill-opacity: 0.7; }\n" " rect.active { fill: rgb(200,150,150); fill-opacity: 0.7; }\n" " rect.deactivating { fill: rgb(150,100,100); fill-opacity: 0.7; }\n" " rect.kernel { fill: rgb(150,150,150); fill-opacity: 0.7; }\n" " rect.initrd { fill: rgb(150,150,150); fill-opacity: 0.7; }\n" " rect.firmware { fill: rgb(150,150,150); fill-opacity: 0.7; }\n" " rect.loader { fill: rgb(150,150,150); fill-opacity: 0.7; }\n" " rect.userspace { fill: rgb(150,150,150); fill-opacity: 0.7; }\n" " rect.security { fill: rgb(144,238,144); fill-opacity: 0.7; }\n" " rect.generators { fill: rgb(102,204,255); fill-opacity: 0.7; }\n" " rect.unitsload { fill: rgb( 82,184,255); fill-opacity: 0.7; }\n" " rect.box { fill: rgb(240,240,240); stroke: rgb(192,192,192); }\n" " line { stroke: rgb(64,64,64); stroke-width: 1; }\n" "// line.sec1 { }\n" " line.sec5 { stroke-width: 2; }\n" " line.sec01 { stroke: rgb(224,224,224); stroke-width: 1; }\n" " text { font-family: Verdana, Helvetica; font-size: 14px; }\n" " text.left { font-family: Verdana, Helvetica; font-size: 14px; text-anchor: start; }\n" " text.right { font-family: Verdana, Helvetica; font-size: 14px; text-anchor: end; }\n" " text.sec { font-size: 10px; }\n" " ]]>\n </style>\n</defs>\n\n" ) | |||
704 | " ]]>\n </style>\n</defs>\n\n")printf("<defs>\n <style type=\"text/css\">\n <![CDATA[\n" " rect { stroke-width: 1; stroke-opacity: 0; }\n" " rect.background { fill: rgb(255,255,255); }\n" " rect.activating { fill: rgb(255,0,0); fill-opacity: 0.7; }\n" " rect.active { fill: rgb(200,150,150); fill-opacity: 0.7; }\n" " rect.deactivating { fill: rgb(150,100,100); fill-opacity: 0.7; }\n" " rect.kernel { fill: rgb(150,150,150); fill-opacity: 0.7; }\n" " rect.initrd { fill: rgb(150,150,150); fill-opacity: 0.7; }\n" " rect.firmware { fill: rgb(150,150,150); fill-opacity: 0.7; }\n" " rect.loader { fill: rgb(150,150,150); fill-opacity: 0.7; }\n" " rect.userspace { fill: rgb(150,150,150); fill-opacity: 0.7; }\n" " rect.security { fill: rgb(144,238,144); fill-opacity: 0.7; }\n" " rect.generators { fill: rgb(102,204,255); fill-opacity: 0.7; }\n" " rect.unitsload { fill: rgb( 82,184,255); fill-opacity: 0.7; }\n" " rect.box { fill: rgb(240,240,240); stroke: rgb(192,192,192); }\n" " line { stroke: rgb(64,64,64); stroke-width: 1; }\n" "// line.sec1 { }\n" " line.sec5 { stroke-width: 2; }\n" " line.sec01 { stroke: rgb(224,224,224); stroke-width: 1; }\n" " text { font-family: Verdana, Helvetica; font-size: 14px; }\n" " text.left { font-family: Verdana, Helvetica; font-size: 14px; text-anchor: start; }\n" " text.right { font-family: Verdana, Helvetica; font-size: 14px; text-anchor: end; }\n" " text.sec { font-size: 10px; }\n" " ]]>\n </style>\n</defs>\n\n" ); | |||
705 | ||||
706 | svg("<rect class=\"background\" width=\"100%%\" height=\"100%%\" />\n")printf("<rect class=\"background\" width=\"100%%\" height=\"100%%\" />\n" ); | |||
707 | svg("<text x=\"20\" y=\"50\">%s</text>", pretty_times)printf("<text x=\"20\" y=\"50\">%s</text>", pretty_times ); | |||
708 | if (use_full_bus) | |||
709 | svg("<text x=\"20\" y=\"30\">%s %s (%s %s %s) %s %s</text>",printf("<text x=\"20\" y=\"30\">%s %s (%s %s %s) %s %s</text>" , isempty(host->os_pretty_name) ? "Linux" : host->os_pretty_name , strempty(host->hostname), strempty(host->kernel_name) , strempty(host->kernel_release), strempty(host->kernel_version ), strempty(host->architecture), strempty(host->virtualization )) | |||
710 | isempty(host->os_pretty_name) ? "Linux" : host->os_pretty_name,printf("<text x=\"20\" y=\"30\">%s %s (%s %s %s) %s %s</text>" , isempty(host->os_pretty_name) ? "Linux" : host->os_pretty_name , strempty(host->hostname), strempty(host->kernel_name) , strempty(host->kernel_release), strempty(host->kernel_version ), strempty(host->architecture), strempty(host->virtualization )) | |||
711 | strempty(host->hostname),printf("<text x=\"20\" y=\"30\">%s %s (%s %s %s) %s %s</text>" , isempty(host->os_pretty_name) ? "Linux" : host->os_pretty_name , strempty(host->hostname), strempty(host->kernel_name) , strempty(host->kernel_release), strempty(host->kernel_version ), strempty(host->architecture), strempty(host->virtualization )) | |||
712 | strempty(host->kernel_name),printf("<text x=\"20\" y=\"30\">%s %s (%s %s %s) %s %s</text>" , isempty(host->os_pretty_name) ? "Linux" : host->os_pretty_name , strempty(host->hostname), strempty(host->kernel_name) , strempty(host->kernel_release), strempty(host->kernel_version ), strempty(host->architecture), strempty(host->virtualization )) | |||
713 | strempty(host->kernel_release),printf("<text x=\"20\" y=\"30\">%s %s (%s %s %s) %s %s</text>" , isempty(host->os_pretty_name) ? "Linux" : host->os_pretty_name , strempty(host->hostname), strempty(host->kernel_name) , strempty(host->kernel_release), strempty(host->kernel_version ), strempty(host->architecture), strempty(host->virtualization )) | |||
714 | strempty(host->kernel_version),printf("<text x=\"20\" y=\"30\">%s %s (%s %s %s) %s %s</text>" , isempty(host->os_pretty_name) ? "Linux" : host->os_pretty_name , strempty(host->hostname), strempty(host->kernel_name) , strempty(host->kernel_release), strempty(host->kernel_version ), strempty(host->architecture), strempty(host->virtualization )) | |||
715 | strempty(host->architecture),printf("<text x=\"20\" y=\"30\">%s %s (%s %s %s) %s %s</text>" , isempty(host->os_pretty_name) ? "Linux" : host->os_pretty_name , strempty(host->hostname), strempty(host->kernel_name) , strempty(host->kernel_release), strempty(host->kernel_version ), strempty(host->architecture), strempty(host->virtualization )) | |||
716 | strempty(host->virtualization))printf("<text x=\"20\" y=\"30\">%s %s (%s %s %s) %s %s</text>" , isempty(host->os_pretty_name) ? "Linux" : host->os_pretty_name , strempty(host->hostname), strempty(host->kernel_name) , strempty(host->kernel_release), strempty(host->kernel_version ), strempty(host->architecture), strempty(host->virtualization )); | |||
717 | ||||
718 | svg("<g transform=\"translate(%.3f,100)\">\n", 20.0 + (SCALE_X * boot->firmware_time))printf("<g transform=\"translate(%.3f,100)\">\n", 20.0 + ((0.1 / 1000.0) * boot->firmware_time)); | |||
719 | svg_graph_box(m, -(double) boot->firmware_time, boot->finish_time); | |||
720 | ||||
721 | if (boot->firmware_time > 0) { | |||
722 | svg_bar("firmware", -(double) boot->firmware_time, -(double) boot->loader_time, y)printf(" <rect class=\"%s\" x=\"%.03f\" y=\"%.03f\" width=\"%.03f\" height=\"%.03f\" />\n" , ("firmware"), (0.1 / 1000.0) * (-(double) boot->firmware_time ), (20.0) * (y), (0.1 / 1000.0) * ((-(double) boot->loader_time ) - (-(double) boot->firmware_time)), (20.0) - 1.0); | |||
723 | svg_text(true, -(double) boot->firmware_time, y, "firmware")do { printf(" <text class=\"%s\" x=\"%.03f\" y=\"%.03f\">" , (1) ? "left" : "right", (0.1 / 1000.0) * (-(double) boot-> firmware_time) + (1 ? 5.0 : -5.0), (20.0) * (y) + 14.0); printf ("firmware"); printf("</text>\n"); } while (0); | |||
724 | y++; | |||
725 | } | |||
726 | if (boot->loader_time > 0) { | |||
727 | svg_bar("loader", -(double) boot->loader_time, 0, y)printf(" <rect class=\"%s\" x=\"%.03f\" y=\"%.03f\" width=\"%.03f\" height=\"%.03f\" />\n" , ("loader"), (0.1 / 1000.0) * (-(double) boot->loader_time ), (20.0) * (y), (0.1 / 1000.0) * ((0) - (-(double) boot-> loader_time)), (20.0) - 1.0); | |||
728 | svg_text(true, -(double) boot->loader_time, y, "loader")do { printf(" <text class=\"%s\" x=\"%.03f\" y=\"%.03f\">" , (1) ? "left" : "right", (0.1 / 1000.0) * (-(double) boot-> loader_time) + (1 ? 5.0 : -5.0), (20.0) * (y) + 14.0); printf ("loader"); printf("</text>\n"); } while (0); | |||
729 | y++; | |||
730 | } | |||
731 | if (boot->kernel_time > 0) { | |||
732 | svg_bar("kernel", 0, boot->kernel_done_time, y)printf(" <rect class=\"%s\" x=\"%.03f\" y=\"%.03f\" width=\"%.03f\" height=\"%.03f\" />\n" , ("kernel"), (0.1 / 1000.0) * (0), (20.0) * (y), (0.1 / 1000.0 ) * ((boot->kernel_done_time) - (0)), (20.0) - 1.0); | |||
733 | svg_text(true, 0, y, "kernel")do { printf(" <text class=\"%s\" x=\"%.03f\" y=\"%.03f\">" , (1) ? "left" : "right", (0.1 / 1000.0) * (0) + (1 ? 5.0 : - 5.0), (20.0) * (y) + 14.0); printf("kernel"); printf("</text>\n" ); } while (0); | |||
734 | y++; | |||
735 | } | |||
736 | if (boot->initrd_time > 0) { | |||
737 | svg_bar("initrd", boot->initrd_time, boot->userspace_time, y)printf(" <rect class=\"%s\" x=\"%.03f\" y=\"%.03f\" width=\"%.03f\" height=\"%.03f\" />\n" , ("initrd"), (0.1 / 1000.0) * (boot->initrd_time), (20.0) * (y), (0.1 / 1000.0) * ((boot->userspace_time) - (boot-> initrd_time)), (20.0) - 1.0); | |||
738 | svg_text(true, boot->initrd_time, y, "initrd")do { printf(" <text class=\"%s\" x=\"%.03f\" y=\"%.03f\">" , (1) ? "left" : "right", (0.1 / 1000.0) * (boot->initrd_time ) + (1 ? 5.0 : -5.0), (20.0) * (y) + 14.0); printf("initrd"); printf("</text>\n"); } while (0); | |||
739 | y++; | |||
740 | } | |||
741 | svg_bar("active", boot->userspace_time, boot->finish_time, y)printf(" <rect class=\"%s\" x=\"%.03f\" y=\"%.03f\" width=\"%.03f\" height=\"%.03f\" />\n" , ("active"), (0.1 / 1000.0) * (boot->userspace_time), (20.0 ) * (y), (0.1 / 1000.0) * ((boot->finish_time) - (boot-> userspace_time)), (20.0) - 1.0); | |||
742 | svg_bar("security", boot->security_start_time, boot->security_finish_time, y)printf(" <rect class=\"%s\" x=\"%.03f\" y=\"%.03f\" width=\"%.03f\" height=\"%.03f\" />\n" , ("security"), (0.1 / 1000.0) * (boot->security_start_time ), (20.0) * (y), (0.1 / 1000.0) * ((boot->security_finish_time ) - (boot->security_start_time)), (20.0) - 1.0); | |||
743 | svg_bar("generators", boot->generators_start_time, boot->generators_finish_time, y)printf(" <rect class=\"%s\" x=\"%.03f\" y=\"%.03f\" width=\"%.03f\" height=\"%.03f\" />\n" , ("generators"), (0.1 / 1000.0) * (boot->generators_start_time ), (20.0) * (y), (0.1 / 1000.0) * ((boot->generators_finish_time ) - (boot->generators_start_time)), (20.0) - 1.0); | |||
744 | svg_bar("unitsload", boot->unitsload_start_time, boot->unitsload_finish_time, y)printf(" <rect class=\"%s\" x=\"%.03f\" y=\"%.03f\" width=\"%.03f\" height=\"%.03f\" />\n" , ("unitsload"), (0.1 / 1000.0) * (boot->unitsload_start_time ), (20.0) * (y), (0.1 / 1000.0) * ((boot->unitsload_finish_time ) - (boot->unitsload_start_time)), (20.0) - 1.0); | |||
745 | svg_text(true, boot->userspace_time, y, "systemd")do { printf(" <text class=\"%s\" x=\"%.03f\" y=\"%.03f\">" , (1) ? "left" : "right", (0.1 / 1000.0) * (boot->userspace_time ) + (1 ? 5.0 : -5.0), (20.0) * (y) + 14.0); printf("systemd") ; printf("</text>\n"); } while (0); | |||
746 | y++; | |||
747 | ||||
748 | for (u = times; u->has_data; u++) { | |||
749 | char ts[FORMAT_TIMESPAN_MAX64]; | |||
750 | bool_Bool b; | |||
751 | ||||
752 | if (!u->name) | |||
753 | continue; | |||
754 | ||||
755 | svg_bar("activating", u->activating, u->activated, y)printf(" <rect class=\"%s\" x=\"%.03f\" y=\"%.03f\" width=\"%.03f\" height=\"%.03f\" />\n" , ("activating"), (0.1 / 1000.0) * (u->activating), (20.0) * (y), (0.1 / 1000.0) * ((u->activated) - (u->activating )), (20.0) - 1.0); | |||
756 | svg_bar("active", u->activated, u->deactivating, y)printf(" <rect class=\"%s\" x=\"%.03f\" y=\"%.03f\" width=\"%.03f\" height=\"%.03f\" />\n" , ("active"), (0.1 / 1000.0) * (u->activated), (20.0) * (y ), (0.1 / 1000.0) * ((u->deactivating) - (u->activated) ), (20.0) - 1.0); | |||
757 | svg_bar("deactivating", u->deactivating, u->deactivated, y)printf(" <rect class=\"%s\" x=\"%.03f\" y=\"%.03f\" width=\"%.03f\" height=\"%.03f\" />\n" , ("deactivating"), (0.1 / 1000.0) * (u->deactivating), (20.0 ) * (y), (0.1 / 1000.0) * ((u->deactivated) - (u->deactivating )), (20.0) - 1.0); | |||
758 | ||||
759 | /* place the text on the left if we have passed the half of the svg width */ | |||
760 | b = u->activating * SCALE_X(0.1 / 1000.0) < width / 2; | |||
761 | if (u->time) | |||
762 | svg_text(b, u->activating, y, "%s (%s)",do { printf(" <text class=\"%s\" x=\"%.03f\" y=\"%.03f\">" , (b) ? "left" : "right", (0.1 / 1000.0) * (u->activating) + (b ? 5.0 : -5.0), (20.0) * (y) + 14.0); printf("%s (%s)", u ->name, format_timespan(ts, sizeof(ts), u->time, ((usec_t ) 1000ULL))); printf("</text>\n"); } while (0) | |||
763 | u->name, format_timespan(ts, sizeof(ts), u->time, USEC_PER_MSEC))do { printf(" <text class=\"%s\" x=\"%.03f\" y=\"%.03f\">" , (b) ? "left" : "right", (0.1 / 1000.0) * (u->activating) + (b ? 5.0 : -5.0), (20.0) * (y) + 14.0); printf("%s (%s)", u ->name, format_timespan(ts, sizeof(ts), u->time, ((usec_t ) 1000ULL))); printf("</text>\n"); } while (0); | |||
764 | else | |||
765 | svg_text(b, u->activating, y, "%s", u->name)do { printf(" <text class=\"%s\" x=\"%.03f\" y=\"%.03f\">" , (b) ? "left" : "right", (0.1 / 1000.0) * (u->activating) + (b ? 5.0 : -5.0), (20.0) * (y) + 14.0); printf("%s", u-> name); printf("</text>\n"); } while (0); | |||
766 | y++; | |||
767 | } | |||
768 | ||||
769 | svg("</g>\n")printf("</g>\n"); | |||
770 | ||||
771 | /* Legend */ | |||
772 | svg("<g transform=\"translate(20,100)\">\n")printf("<g transform=\"translate(20,100)\">\n"); | |||
773 | y++; | |||
774 | svg_bar("activating", 0, 300000, y)printf(" <rect class=\"%s\" x=\"%.03f\" y=\"%.03f\" width=\"%.03f\" height=\"%.03f\" />\n" , ("activating"), (0.1 / 1000.0) * (0), (20.0) * (y), (0.1 / 1000.0 ) * ((300000) - (0)), (20.0) - 1.0); | |||
775 | svg_text(true, 400000, y, "Activating")do { printf(" <text class=\"%s\" x=\"%.03f\" y=\"%.03f\">" , (1) ? "left" : "right", (0.1 / 1000.0) * (400000) + (1 ? 5.0 : -5.0), (20.0) * (y) + 14.0); printf("Activating"); printf( "</text>\n"); } while (0); | |||
776 | y++; | |||
777 | svg_bar("active", 0, 300000, y)printf(" <rect class=\"%s\" x=\"%.03f\" y=\"%.03f\" width=\"%.03f\" height=\"%.03f\" />\n" , ("active"), (0.1 / 1000.0) * (0), (20.0) * (y), (0.1 / 1000.0 ) * ((300000) - (0)), (20.0) - 1.0); | |||
778 | svg_text(true, 400000, y, "Active")do { printf(" <text class=\"%s\" x=\"%.03f\" y=\"%.03f\">" , (1) ? "left" : "right", (0.1 / 1000.0) * (400000) + (1 ? 5.0 : -5.0), (20.0) * (y) + 14.0); printf("Active"); printf("</text>\n" ); } while (0); | |||
779 | y++; | |||
780 | svg_bar("deactivating", 0, 300000, y)printf(" <rect class=\"%s\" x=\"%.03f\" y=\"%.03f\" width=\"%.03f\" height=\"%.03f\" />\n" , ("deactivating"), (0.1 / 1000.0) * (0), (20.0) * (y), (0.1 / 1000.0) * ((300000) - (0)), (20.0) - 1.0); | |||
781 | svg_text(true, 400000, y, "Deactivating")do { printf(" <text class=\"%s\" x=\"%.03f\" y=\"%.03f\">" , (1) ? "left" : "right", (0.1 / 1000.0) * (400000) + (1 ? 5.0 : -5.0), (20.0) * (y) + 14.0); printf("Deactivating"); printf ("</text>\n"); } while (0); | |||
782 | y++; | |||
783 | svg_bar("security", 0, 300000, y)printf(" <rect class=\"%s\" x=\"%.03f\" y=\"%.03f\" width=\"%.03f\" height=\"%.03f\" />\n" , ("security"), (0.1 / 1000.0) * (0), (20.0) * (y), (0.1 / 1000.0 ) * ((300000) - (0)), (20.0) - 1.0); | |||
784 | svg_text(true, 400000, y, "Setting up security module")do { printf(" <text class=\"%s\" x=\"%.03f\" y=\"%.03f\">" , (1) ? "left" : "right", (0.1 / 1000.0) * (400000) + (1 ? 5.0 : -5.0), (20.0) * (y) + 14.0); printf("Setting up security module" ); printf("</text>\n"); } while (0); | |||
785 | y++; | |||
786 | svg_bar("generators", 0, 300000, y)printf(" <rect class=\"%s\" x=\"%.03f\" y=\"%.03f\" width=\"%.03f\" height=\"%.03f\" />\n" , ("generators"), (0.1 / 1000.0) * (0), (20.0) * (y), (0.1 / 1000.0 ) * ((300000) - (0)), (20.0) - 1.0); | |||
787 | svg_text(true, 400000, y, "Generators")do { printf(" <text class=\"%s\" x=\"%.03f\" y=\"%.03f\">" , (1) ? "left" : "right", (0.1 / 1000.0) * (400000) + (1 ? 5.0 : -5.0), (20.0) * (y) + 14.0); printf("Generators"); printf( "</text>\n"); } while (0); | |||
788 | y++; | |||
789 | svg_bar("unitsload", 0, 300000, y)printf(" <rect class=\"%s\" x=\"%.03f\" y=\"%.03f\" width=\"%.03f\" height=\"%.03f\" />\n" , ("unitsload"), (0.1 / 1000.0) * (0), (20.0) * (y), (0.1 / 1000.0 ) * ((300000) - (0)), (20.0) - 1.0); | |||
790 | svg_text(true, 400000, y, "Loading unit files")do { printf(" <text class=\"%s\" x=\"%.03f\" y=\"%.03f\">" , (1) ? "left" : "right", (0.1 / 1000.0) * (400000) + (1 ? 5.0 : -5.0), (20.0) * (y) + 14.0); printf("Loading unit files"); printf("</text>\n"); } while (0); | |||
791 | y++; | |||
792 | ||||
793 | svg("</g>\n\n")printf("</g>\n\n"); | |||
794 | ||||
795 | svg("</svg>\n")printf("</svg>\n"); | |||
796 | ||||
797 | return 0; | |||
798 | } | |||
799 | ||||
800 | static int list_dependencies_print(const char *name, unsigned int level, unsigned int branches, | |||
801 | bool_Bool last, struct unit_times *times, struct boot_times *boot) { | |||
802 | unsigned int i; | |||
803 | char ts[FORMAT_TIMESPAN_MAX64], ts2[FORMAT_TIMESPAN_MAX64]; | |||
804 | ||||
805 | for (i = level; i != 0; i--) | |||
806 | printf("%s", special_glyph(branches & (1 << (i-1)) ? TREE_VERTICAL : TREE_SPACE)); | |||
807 | ||||
808 | printf("%s", special_glyph(last ? TREE_RIGHT : TREE_BRANCH)); | |||
809 | ||||
810 | if (times) { | |||
811 | if (times->time > 0) | |||
812 | printf("%s%s @%s +%s%s", ansi_highlight_red(), name, | |||
813 | format_timespan(ts, sizeof(ts), times->activating - boot->userspace_time, USEC_PER_MSEC((usec_t) 1000ULL)), | |||
814 | format_timespan(ts2, sizeof(ts2), times->time, USEC_PER_MSEC((usec_t) 1000ULL)), ansi_normal()); | |||
815 | else if (times->activated > boot->userspace_time) | |||
816 | printf("%s @%s", name, format_timespan(ts, sizeof(ts), times->activated - boot->userspace_time, USEC_PER_MSEC((usec_t) 1000ULL))); | |||
817 | else | |||
818 | printf("%s", name); | |||
819 | } else | |||
820 | printf("%s", name); | |||
821 | printf("\n"); | |||
822 | ||||
823 | return 0; | |||
824 | } | |||
825 | ||||
826 | static int list_dependencies_get_dependencies(sd_bus *bus, const char *name, char ***deps) { | |||
827 | _cleanup_free___attribute__((cleanup(freep))) char *path = NULL((void*)0); | |||
828 | ||||
829 | assert(bus)do { if ((__builtin_expect(!!(!(bus)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("bus"), "../src/analyze/analyze.c", 829, __PRETTY_FUNCTION__); } while (0); | |||
830 | assert(name)do { if ((__builtin_expect(!!(!(name)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("name"), "../src/analyze/analyze.c", 830 , __PRETTY_FUNCTION__); } while (0); | |||
831 | assert(deps)do { if ((__builtin_expect(!!(!(deps)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("deps"), "../src/analyze/analyze.c", 831 , __PRETTY_FUNCTION__); } while (0); | |||
832 | ||||
833 | path = unit_dbus_path_from_name(name); | |||
834 | if (!path) | |||
835 | return -ENOMEM12; | |||
836 | ||||
837 | return bus_get_unit_property_strv(bus, path, "After", deps); | |||
838 | } | |||
839 | ||||
840 | static Hashmap *unit_times_hashmap; | |||
841 | ||||
842 | static int list_dependencies_compare(const void *_a, const void *_b) { | |||
843 | const char **a = (const char**) _a, **b = (const char**) _b; | |||
844 | usec_t usa = 0, usb = 0; | |||
845 | struct unit_times *times; | |||
846 | ||||
847 | times = hashmap_get(unit_times_hashmap, *a); | |||
848 | if (times) | |||
849 | usa = times->activated; | |||
850 | times = hashmap_get(unit_times_hashmap, *b); | |||
851 | if (times) | |||
852 | usb = times->activated; | |||
853 | ||||
854 | return usb - usa; | |||
855 | } | |||
856 | ||||
857 | static bool_Bool times_in_range(const struct unit_times *times, const struct boot_times *boot) { | |||
858 | return times && | |||
859 | times->activated > 0 && times->activated <= boot->finish_time; | |||
860 | } | |||
861 | ||||
862 | static int list_dependencies_one(sd_bus *bus, const char *name, unsigned int level, char ***units, | |||
863 | unsigned int branches) { | |||
864 | _cleanup_strv_free___attribute__((cleanup(strv_freep))) char **deps = NULL((void*)0); | |||
865 | char **c; | |||
866 | int r = 0; | |||
867 | usec_t service_longest = 0; | |||
868 | int to_print = 0; | |||
869 | struct unit_times *times; | |||
870 | struct boot_times *boot; | |||
871 | ||||
872 | if (strv_extend(units, name)) | |||
873 | return log_oom()log_oom_internal(LOG_REALM_SYSTEMD, "../src/analyze/analyze.c" , 873, __func__); | |||
874 | ||||
875 | r = list_dependencies_get_dependencies(bus, name, &deps); | |||
876 | if (r < 0) | |||
877 | return r; | |||
878 | ||||
879 | qsort_safe(deps, strv_length(deps), sizeof (char*), list_dependencies_compare); | |||
880 | ||||
881 | r = acquire_boot_times(bus, &boot); | |||
882 | if (r < 0) | |||
883 | return r; | |||
884 | ||||
885 | STRV_FOREACH(c, deps)for ((c) = (deps); (c) && *(c); (c)++) { | |||
886 | times = hashmap_get(unit_times_hashmap, *c); | |||
887 | if (times_in_range(times, boot) && | |||
888 | (times->activated >= service_longest | |||
889 | || service_longest == 0)) { | |||
890 | service_longest = times->activated; | |||
891 | break; | |||
892 | } | |||
893 | } | |||
894 | ||||
895 | if (service_longest == 0) | |||
896 | return r; | |||
897 | ||||
898 | STRV_FOREACH(c, deps)for ((c) = (deps); (c) && *(c); (c)++) { | |||
899 | times = hashmap_get(unit_times_hashmap, *c); | |||
900 | if (times_in_range(times, boot) && | |||
901 | service_longest - times->activated <= arg_fuzz) | |||
902 | to_print++; | |||
903 | } | |||
904 | ||||
905 | if (!to_print) | |||
906 | return r; | |||
907 | ||||
908 | STRV_FOREACH(c, deps)for ((c) = (deps); (c) && *(c); (c)++) { | |||
909 | times = hashmap_get(unit_times_hashmap, *c); | |||
910 | if (!times_in_range(times, boot) || | |||
911 | service_longest - times->activated > arg_fuzz) | |||
912 | continue; | |||
913 | ||||
914 | to_print--; | |||
915 | ||||
916 | r = list_dependencies_print(*c, level, branches, to_print == 0, times, boot); | |||
917 | if (r < 0) | |||
918 | return r; | |||
919 | ||||
920 | if (strv_contains(*units, *c)(!!strv_find((*units), (*c)))) { | |||
921 | r = list_dependencies_print("...", level + 1, (branches << 1) | (to_print ? 1 : 0), | |||
922 | true1, NULL((void*)0), boot); | |||
923 | if (r < 0) | |||
924 | return r; | |||
925 | continue; | |||
926 | } | |||
927 | ||||
928 | r = list_dependencies_one(bus, *c, level + 1, units, | |||
929 | (branches << 1) | (to_print ? 1 : 0)); | |||
930 | if (r < 0) | |||
931 | return r; | |||
932 | ||||
933 | if (to_print == 0) | |||
934 | break; | |||
935 | } | |||
936 | return 0; | |||
937 | } | |||
938 | ||||
939 | static int list_dependencies(sd_bus *bus, const char *name) { | |||
940 | _cleanup_strv_free___attribute__((cleanup(strv_freep))) char **units = NULL((void*)0); | |||
941 | char ts[FORMAT_TIMESPAN_MAX64]; | |||
942 | struct unit_times *times; | |||
943 | int r; | |||
944 | const char *id; | |||
945 | _cleanup_free___attribute__((cleanup(freep))) char *path = NULL((void*)0); | |||
946 | _cleanup_(sd_bus_message_unrefp)__attribute__((cleanup(sd_bus_message_unrefp))) sd_bus_message *reply = NULL((void*)0); | |||
947 | _cleanup_(sd_bus_error_free)__attribute__((cleanup(sd_bus_error_free))) sd_bus_error error = SD_BUS_ERROR_NULL((const sd_bus_error) {(((void*)0)), (((void*)0)), 0}); | |||
948 | struct boot_times *boot; | |||
949 | ||||
950 | assert(bus)do { if ((__builtin_expect(!!(!(bus)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("bus"), "../src/analyze/analyze.c", 950, __PRETTY_FUNCTION__); } while (0); | |||
951 | ||||
952 | path = unit_dbus_path_from_name(name); | |||
953 | if (!path) | |||
954 | return -ENOMEM12; | |||
955 | ||||
956 | r = sd_bus_get_property( | |||
957 | bus, | |||
958 | "org.freedesktop.systemd1", | |||
959 | path, | |||
960 | "org.freedesktop.systemd1.Unit", | |||
961 | "Id", | |||
962 | &error, | |||
963 | &reply, | |||
964 | "s"); | |||
965 | if (r < 0) | |||
966 | return log_error_errno(r, "Failed to get ID: %s", bus_error_message(&error, -r))({ int _level = ((3)), _e = ((r)), _realm = (LOG_REALM_SYSTEMD ); (log_get_max_level_realm(_realm) >= ((_level) & 0x07 )) ? log_internal_realm(((_realm) << 10 | (_level)), _e , "../src/analyze/analyze.c", 966, __func__, "Failed to get ID: %s" , bus_error_message(&error, -r)) : -abs(_e); }); | |||
967 | ||||
968 | r = sd_bus_message_read(reply, "s", &id); | |||
969 | if (r < 0) | |||
970 | return bus_log_parse_error(r); | |||
971 | ||||
972 | times = hashmap_get(unit_times_hashmap, id); | |||
973 | ||||
974 | r = acquire_boot_times(bus, &boot); | |||
975 | if (r < 0) | |||
976 | return r; | |||
977 | ||||
978 | if (times) { | |||
979 | if (times->time) | |||
980 | printf("%s%s +%s%s\n", ansi_highlight_red(), id, | |||
981 | format_timespan(ts, sizeof(ts), times->time, USEC_PER_MSEC((usec_t) 1000ULL)), ansi_normal()); | |||
982 | else if (times->activated > boot->userspace_time) | |||
983 | printf("%s @%s\n", id, format_timespan(ts, sizeof(ts), times->activated - boot->userspace_time, USEC_PER_MSEC((usec_t) 1000ULL))); | |||
984 | else | |||
985 | printf("%s\n", id); | |||
986 | } | |||
987 | ||||
988 | return list_dependencies_one(bus, name, 0, &units, 0); | |||
989 | } | |||
990 | ||||
991 | static int analyze_critical_chain(int argc, char *argv[], void *userdata) { | |||
992 | _cleanup_(sd_bus_flush_close_unrefp)__attribute__((cleanup(sd_bus_flush_close_unrefp))) sd_bus *bus = NULL((void*)0); | |||
993 | _cleanup_(unit_times_freep)__attribute__((cleanup(unit_times_freep))) struct unit_times *times = NULL((void*)0); | |||
994 | struct unit_times *u; | |||
995 | Hashmap *h; | |||
996 | int n, r; | |||
997 | ||||
998 | r = acquire_bus(&bus, NULL((void*)0)); | |||
999 | if (r < 0) | |||
1000 | return log_error_errno(r, "Failed to create bus connection: %m")({ int _level = ((3)), _e = ((r)), _realm = (LOG_REALM_SYSTEMD ); (log_get_max_level_realm(_realm) >= ((_level) & 0x07 )) ? log_internal_realm(((_realm) << 10 | (_level)), _e , "../src/analyze/analyze.c", 1000, __func__, "Failed to create bus connection: %m" ) : -abs(_e); }); | |||
1001 | ||||
1002 | n = acquire_time_data(bus, ×); | |||
1003 | if (n <= 0) | |||
1004 | return n; | |||
1005 | ||||
1006 | h = hashmap_new(&string_hash_ops)internal_hashmap_new(&string_hash_ops ); | |||
1007 | if (!h) | |||
1008 | return log_oom()log_oom_internal(LOG_REALM_SYSTEMD, "../src/analyze/analyze.c" , 1008, __func__); | |||
1009 | ||||
1010 | for (u = times; u->has_data; u++) { | |||
1011 | r = hashmap_put(h, u->name, u); | |||
1012 | if (r < 0) | |||
1013 | return log_error_errno(r, "Failed to add entry to hashmap: %m")({ int _level = ((3)), _e = ((r)), _realm = (LOG_REALM_SYSTEMD ); (log_get_max_level_realm(_realm) >= ((_level) & 0x07 )) ? log_internal_realm(((_realm) << 10 | (_level)), _e , "../src/analyze/analyze.c", 1013, __func__, "Failed to add entry to hashmap: %m" ) : -abs(_e); }); | |||
1014 | } | |||
1015 | unit_times_hashmap = h; | |||
1016 | ||||
1017 | (void) pager_open(arg_no_pager, false0); | |||
1018 | ||||
1019 | puts("The time after the unit is active or started is printed after the \"@\" character.\n" | |||
1020 | "The time the unit takes to start is printed after the \"+\" character.\n"); | |||
1021 | ||||
1022 | if (argc > 1) { | |||
1023 | char **name; | |||
1024 | STRV_FOREACH(name, strv_skip(argv, 1))for ((name) = (strv_skip(argv, 1)); (name) && *(name) ; (name)++) | |||
1025 | list_dependencies(bus, *name); | |||
1026 | } else | |||
1027 | list_dependencies(bus, SPECIAL_DEFAULT_TARGET"default.target"); | |||
1028 | ||||
1029 | h = hashmap_free(h); | |||
1030 | return 0; | |||
1031 | } | |||
1032 | ||||
1033 | static int analyze_blame(int argc, char *argv[], void *userdata) { | |||
1034 | _cleanup_(sd_bus_flush_close_unrefp)__attribute__((cleanup(sd_bus_flush_close_unrefp))) sd_bus *bus = NULL((void*)0); | |||
1035 | _cleanup_(unit_times_freep)__attribute__((cleanup(unit_times_freep))) struct unit_times *times = NULL((void*)0); | |||
| ||||
1036 | struct unit_times *u; | |||
1037 | int n, r; | |||
1038 | ||||
1039 | r = acquire_bus(&bus, NULL((void*)0)); | |||
1040 | if (r < 0) | |||
1041 | return log_error_errno(r, "Failed to create bus connection: %m")({ int _level = ((3)), _e = ((r)), _realm = (LOG_REALM_SYSTEMD ); (log_get_max_level_realm(_realm) >= ((_level) & 0x07 )) ? log_internal_realm(((_realm) << 10 | (_level)), _e , "../src/analyze/analyze.c", 1041, __func__, "Failed to create bus connection: %m" ) : -abs(_e); }); | |||
1042 | ||||
1043 | n = acquire_time_data(bus, ×); | |||
1044 | if (n <= 0) | |||
1045 | return n; | |||
1046 | ||||
1047 | qsort(times, n, sizeof(struct unit_times), compare_unit_time); | |||
| ||||
1048 | ||||
1049 | (void) pager_open(arg_no_pager, false0); | |||
1050 | ||||
1051 | for (u = times; u->has_data; u++) { | |||
1052 | char ts[FORMAT_TIMESPAN_MAX64]; | |||
1053 | ||||
1054 | if (u->time > 0) | |||
1055 | printf("%16s %s\n", format_timespan(ts, sizeof(ts), u->time, USEC_PER_MSEC((usec_t) 1000ULL)), u->name); | |||
1056 | } | |||
1057 | ||||
1058 | return 0; | |||
1059 | } | |||
1060 | ||||
1061 | static int analyze_time(int argc, char *argv[], void *userdata) { | |||
1062 | _cleanup_(sd_bus_flush_close_unrefp)__attribute__((cleanup(sd_bus_flush_close_unrefp))) sd_bus *bus = NULL((void*)0); | |||
1063 | _cleanup_free___attribute__((cleanup(freep))) char *buf = NULL((void*)0); | |||
1064 | int r; | |||
1065 | ||||
1066 | r = acquire_bus(&bus, NULL((void*)0)); | |||
1067 | if (r < 0) | |||
1068 | return log_error_errno(r, "Failed to create bus connection: %m")({ int _level = ((3)), _e = ((r)), _realm = (LOG_REALM_SYSTEMD ); (log_get_max_level_realm(_realm) >= ((_level) & 0x07 )) ? log_internal_realm(((_realm) << 10 | (_level)), _e , "../src/analyze/analyze.c", 1068, __func__, "Failed to create bus connection: %m" ) : -abs(_e); }); | |||
1069 | ||||
1070 | r = pretty_boot_time(bus, &buf); | |||
1071 | if (r < 0) | |||
1072 | return r; | |||
1073 | ||||
1074 | puts(buf); | |||
1075 | return 0; | |||
1076 | } | |||
1077 | ||||
1078 | static int graph_one_property(sd_bus *bus, const UnitInfo *u, const char* prop, const char *color, char* patterns[], char* from_patterns[], char* to_patterns[]) { | |||
1079 | _cleanup_strv_free___attribute__((cleanup(strv_freep))) char **units = NULL((void*)0); | |||
1080 | char **unit; | |||
1081 | int r; | |||
1082 | bool_Bool match_patterns; | |||
1083 | ||||
1084 | assert(u)do { if ((__builtin_expect(!!(!(u)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("u"), "../src/analyze/analyze.c", 1084, __PRETTY_FUNCTION__ ); } while (0); | |||
1085 | assert(prop)do { if ((__builtin_expect(!!(!(prop)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("prop"), "../src/analyze/analyze.c", 1085 , __PRETTY_FUNCTION__); } while (0); | |||
1086 | assert(color)do { if ((__builtin_expect(!!(!(color)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("color"), "../src/analyze/analyze.c", 1086 , __PRETTY_FUNCTION__); } while (0); | |||
1087 | ||||
1088 | match_patterns = strv_fnmatch(patterns, u->id, 0); | |||
1089 | ||||
1090 | if (!strv_isempty(from_patterns) && | |||
1091 | !match_patterns && | |||
1092 | !strv_fnmatch(from_patterns, u->id, 0)) | |||
1093 | return 0; | |||
1094 | ||||
1095 | r = bus_get_unit_property_strv(bus, u->unit_path, prop, &units); | |||
1096 | if (r < 0) | |||
1097 | return r; | |||
1098 | ||||
1099 | STRV_FOREACH(unit, units)for ((unit) = (units); (unit) && *(unit); (unit)++) { | |||
1100 | bool_Bool match_patterns2; | |||
1101 | ||||
1102 | match_patterns2 = strv_fnmatch(patterns, *unit, 0); | |||
1103 | ||||
1104 | if (!strv_isempty(to_patterns) && | |||
1105 | !match_patterns2 && | |||
1106 | !strv_fnmatch(to_patterns, *unit, 0)) | |||
1107 | continue; | |||
1108 | ||||
1109 | if (!strv_isempty(patterns) && !match_patterns && !match_patterns2) | |||
1110 | continue; | |||
1111 | ||||
1112 | printf("\t\"%s\"->\"%s\" [color=\"%s\"];\n", u->id, *unit, color); | |||
1113 | } | |||
1114 | ||||
1115 | return 0; | |||
1116 | } | |||
1117 | ||||
1118 | static int graph_one(sd_bus *bus, const UnitInfo *u, char *patterns[], char *from_patterns[], char *to_patterns[]) { | |||
1119 | int r; | |||
1120 | ||||
1121 | assert(bus)do { if ((__builtin_expect(!!(!(bus)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("bus"), "../src/analyze/analyze.c", 1121 , __PRETTY_FUNCTION__); } while (0); | |||
1122 | assert(u)do { if ((__builtin_expect(!!(!(u)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("u"), "../src/analyze/analyze.c", 1122, __PRETTY_FUNCTION__ ); } while (0); | |||
1123 | ||||
1124 | if (IN_SET(arg_dot, DEP_ORDER, DEP_ALL)({ _Bool _found = 0; static __attribute__ ((unused)) char _static_assert__macros_need_to_be_extended [20 - sizeof((int[]){DEP_ORDER, DEP_ALL})/sizeof(int)]; switch (arg_dot) { case DEP_ORDER: case DEP_ALL: _found = 1; break; default : break; } _found; })) { | |||
1125 | r = graph_one_property(bus, u, "After", "green", patterns, from_patterns, to_patterns); | |||
1126 | if (r < 0) | |||
1127 | return r; | |||
1128 | } | |||
1129 | ||||
1130 | if (IN_SET(arg_dot, DEP_REQUIRE, DEP_ALL)({ _Bool _found = 0; static __attribute__ ((unused)) char _static_assert__macros_need_to_be_extended [20 - sizeof((int[]){DEP_REQUIRE, DEP_ALL})/sizeof(int)]; switch (arg_dot) { case DEP_REQUIRE: case DEP_ALL: _found = 1; break ; default: break; } _found; })) { | |||
1131 | r = graph_one_property(bus, u, "Requires", "black", patterns, from_patterns, to_patterns); | |||
1132 | if (r < 0) | |||
1133 | return r; | |||
1134 | r = graph_one_property(bus, u, "Requisite", "darkblue", patterns, from_patterns, to_patterns); | |||
1135 | if (r < 0) | |||
1136 | return r; | |||
1137 | r = graph_one_property(bus, u, "Wants", "grey66", patterns, from_patterns, to_patterns); | |||
1138 | if (r < 0) | |||
1139 | return r; | |||
1140 | r = graph_one_property(bus, u, "Conflicts", "red", patterns, from_patterns, to_patterns); | |||
1141 | if (r < 0) | |||
1142 | return r; | |||
1143 | } | |||
1144 | ||||
1145 | return 0; | |||
1146 | } | |||
1147 | ||||
1148 | static int expand_patterns(sd_bus *bus, char **patterns, char ***ret) { | |||
1149 | _cleanup_strv_free___attribute__((cleanup(strv_freep))) char **expanded_patterns = NULL((void*)0); | |||
1150 | char **pattern; | |||
1151 | int r; | |||
1152 | ||||
1153 | STRV_FOREACH(pattern, patterns)for ((pattern) = (patterns); (pattern) && *(pattern); (pattern)++) { | |||
1154 | _cleanup_(sd_bus_error_free)__attribute__((cleanup(sd_bus_error_free))) sd_bus_error error = SD_BUS_ERROR_NULL((const sd_bus_error) {(((void*)0)), (((void*)0)), 0}); | |||
1155 | _cleanup_free___attribute__((cleanup(freep))) char *unit = NULL((void*)0), *unit_id = NULL((void*)0); | |||
1156 | ||||
1157 | if (strv_extend(&expanded_patterns, *pattern) < 0) | |||
1158 | return log_oom()log_oom_internal(LOG_REALM_SYSTEMD, "../src/analyze/analyze.c" , 1158, __func__); | |||
1159 | ||||
1160 | if (string_is_glob(*pattern)) | |||
1161 | continue; | |||
1162 | ||||
1163 | unit = unit_dbus_path_from_name(*pattern); | |||
1164 | if (!unit) | |||
1165 | return log_oom()log_oom_internal(LOG_REALM_SYSTEMD, "../src/analyze/analyze.c" , 1165, __func__); | |||
1166 | ||||
1167 | r = sd_bus_get_property_string( | |||
1168 | bus, | |||
1169 | "org.freedesktop.systemd1", | |||
1170 | unit, | |||
1171 | "org.freedesktop.systemd1.Unit", | |||
1172 | "Id", | |||
1173 | &error, | |||
1174 | &unit_id); | |||
1175 | if (r < 0) | |||
1176 | return log_error_errno(r, "Failed to get ID: %s", bus_error_message(&error, r))({ int _level = ((3)), _e = ((r)), _realm = (LOG_REALM_SYSTEMD ); (log_get_max_level_realm(_realm) >= ((_level) & 0x07 )) ? log_internal_realm(((_realm) << 10 | (_level)), _e , "../src/analyze/analyze.c", 1176, __func__, "Failed to get ID: %s" , bus_error_message(&error, r)) : -abs(_e); }); | |||
1177 | ||||
1178 | if (!streq(*pattern, unit_id)(strcmp((*pattern),(unit_id)) == 0)) { | |||
1179 | if (strv_extend(&expanded_patterns, unit_id) < 0) | |||
1180 | return log_oom()log_oom_internal(LOG_REALM_SYSTEMD, "../src/analyze/analyze.c" , 1180, __func__); | |||
1181 | } | |||
1182 | } | |||
1183 | ||||
1184 | *ret = expanded_patterns; | |||
1185 | expanded_patterns = NULL((void*)0); /* do not free */ | |||
1186 | ||||
1187 | return 0; | |||
1188 | } | |||
1189 | ||||
1190 | static int dot(int argc, char *argv[], void *userdata) { | |||
1191 | _cleanup_(sd_bus_message_unrefp)__attribute__((cleanup(sd_bus_message_unrefp))) sd_bus_message *reply = NULL((void*)0); | |||
1192 | _cleanup_(sd_bus_error_free)__attribute__((cleanup(sd_bus_error_free))) sd_bus_error error = SD_BUS_ERROR_NULL((const sd_bus_error) {(((void*)0)), (((void*)0)), 0}); | |||
1193 | _cleanup_(sd_bus_flush_close_unrefp)__attribute__((cleanup(sd_bus_flush_close_unrefp))) sd_bus *bus = NULL((void*)0); | |||
1194 | _cleanup_strv_free___attribute__((cleanup(strv_freep))) char **expanded_patterns = NULL((void*)0); | |||
1195 | _cleanup_strv_free___attribute__((cleanup(strv_freep))) char **expanded_from_patterns = NULL((void*)0); | |||
1196 | _cleanup_strv_free___attribute__((cleanup(strv_freep))) char **expanded_to_patterns = NULL((void*)0); | |||
1197 | int r; | |||
1198 | UnitInfo u; | |||
1199 | ||||
1200 | r = acquire_bus(&bus, NULL((void*)0)); | |||
1201 | if (r < 0) | |||
1202 | return log_error_errno(r, "Failed to create bus connection: %m")({ int _level = ((3)), _e = ((r)), _realm = (LOG_REALM_SYSTEMD ); (log_get_max_level_realm(_realm) >= ((_level) & 0x07 )) ? log_internal_realm(((_realm) << 10 | (_level)), _e , "../src/analyze/analyze.c", 1202, __func__, "Failed to create bus connection: %m" ) : -abs(_e); }); | |||
1203 | ||||
1204 | r = expand_patterns(bus, strv_skip(argv, 1), &expanded_patterns); | |||
1205 | if (r < 0) | |||
1206 | return r; | |||
1207 | ||||
1208 | r = expand_patterns(bus, arg_dot_from_patterns, &expanded_from_patterns); | |||
1209 | if (r < 0) | |||
1210 | return r; | |||
1211 | ||||
1212 | r = expand_patterns(bus, arg_dot_to_patterns, &expanded_to_patterns); | |||
1213 | if (r < 0) | |||
1214 | return r; | |||
1215 | ||||
1216 | r = sd_bus_call_method( | |||
1217 | bus, | |||
1218 | "org.freedesktop.systemd1", | |||
1219 | "/org/freedesktop/systemd1", | |||
1220 | "org.freedesktop.systemd1.Manager", | |||
1221 | "ListUnits", | |||
1222 | &error, | |||
1223 | &reply, | |||
1224 | ""); | |||
1225 | if (r < 0) | |||
1226 | log_error_errno(r, "Failed to list units: %s", bus_error_message(&error, -r))({ int _level = ((3)), _e = ((r)), _realm = (LOG_REALM_SYSTEMD ); (log_get_max_level_realm(_realm) >= ((_level) & 0x07 )) ? log_internal_realm(((_realm) << 10 | (_level)), _e , "../src/analyze/analyze.c", 1226, __func__, "Failed to list units: %s" , bus_error_message(&error, -r)) : -abs(_e); }); | |||
1227 | ||||
1228 | r = sd_bus_message_enter_container(reply, SD_BUS_TYPE_ARRAY, "(ssssssouso)"); | |||
1229 | if (r < 0) | |||
1230 | return bus_log_parse_error(r); | |||
1231 | ||||
1232 | printf("digraph systemd {\n"); | |||
1233 | ||||
1234 | while ((r = bus_parse_unit_info(reply, &u)) > 0) { | |||
1235 | ||||
1236 | r = graph_one(bus, &u, expanded_patterns, expanded_from_patterns, expanded_to_patterns); | |||
1237 | if (r < 0) | |||
1238 | return r; | |||
1239 | } | |||
1240 | if (r < 0) | |||
1241 | return bus_log_parse_error(r); | |||
1242 | ||||
1243 | printf("}\n"); | |||
1244 | ||||
1245 | log_info(" Color legend: black = Requires\n"({ int _level = (((6))), _e = ((0)), _realm = (LOG_REALM_SYSTEMD ); (log_get_max_level_realm(_realm) >= ((_level) & 0x07 )) ? log_internal_realm(((_realm) << 10 | (_level)), _e , "../src/analyze/analyze.c", 1249, __func__, " Color legend: black = Requires\n" " dark blue = Requisite\n" " dark grey = Wants\n" " red = Conflicts\n" " green = After\n" ) : -abs(_e); }) | |||
1246 | " dark blue = Requisite\n"({ int _level = (((6))), _e = ((0)), _realm = (LOG_REALM_SYSTEMD ); (log_get_max_level_realm(_realm) >= ((_level) & 0x07 )) ? log_internal_realm(((_realm) << 10 | (_level)), _e , "../src/analyze/analyze.c", 1249, __func__, " Color legend: black = Requires\n" " dark blue = Requisite\n" " dark grey = Wants\n" " red = Conflicts\n" " green = After\n" ) : -abs(_e); }) | |||
1247 | " dark grey = Wants\n"({ int _level = (((6))), _e = ((0)), _realm = (LOG_REALM_SYSTEMD ); (log_get_max_level_realm(_realm) >= ((_level) & 0x07 )) ? log_internal_realm(((_realm) << 10 | (_level)), _e , "../src/analyze/analyze.c", 1249, __func__, " Color legend: black = Requires\n" " dark blue = Requisite\n" " dark grey = Wants\n" " red = Conflicts\n" " green = After\n" ) : -abs(_e); }) | |||
1248 | " red = Conflicts\n"({ int _level = (((6))), _e = ((0)), _realm = (LOG_REALM_SYSTEMD ); (log_get_max_level_realm(_realm) >= ((_level) & 0x07 )) ? log_internal_realm(((_realm) << 10 | (_level)), _e , "../src/analyze/analyze.c", 1249, __func__, " Color legend: black = Requires\n" " dark blue = Requisite\n" " dark grey = Wants\n" " red = Conflicts\n" " green = After\n" ) : -abs(_e); }) | |||
1249 | " green = After\n")({ int _level = (((6))), _e = ((0)), _realm = (LOG_REALM_SYSTEMD ); (log_get_max_level_realm(_realm) >= ((_level) & 0x07 )) ? log_internal_realm(((_realm) << 10 | (_level)), _e , "../src/analyze/analyze.c", 1249, __func__, " Color legend: black = Requires\n" " dark blue = Requisite\n" " dark grey = Wants\n" " red = Conflicts\n" " green = After\n" ) : -abs(_e); }); | |||
1250 | ||||
1251 | if (on_tty()) | |||
1252 | log_notice("-- You probably want to process this output with graphviz' dot tool.\n"({ int _level = (((5))), _e = ((0)), _realm = (LOG_REALM_SYSTEMD ); (log_get_max_level_realm(_realm) >= ((_level) & 0x07 )) ? log_internal_realm(((_realm) << 10 | (_level)), _e , "../src/analyze/analyze.c", 1253, __func__, "-- You probably want to process this output with graphviz' dot tool.\n" "-- Try a shell pipeline like 'systemd-analyze dot | dot -Tsvg > systemd.svg'!\n" ) : -abs(_e); }) | |||
1253 | "-- Try a shell pipeline like 'systemd-analyze dot | dot -Tsvg > systemd.svg'!\n")({ int _level = (((5))), _e = ((0)), _realm = (LOG_REALM_SYSTEMD ); (log_get_max_level_realm(_realm) >= ((_level) & 0x07 )) ? log_internal_realm(((_realm) << 10 | (_level)), _e , "../src/analyze/analyze.c", 1253, __func__, "-- You probably want to process this output with graphviz' dot tool.\n" "-- Try a shell pipeline like 'systemd-analyze dot | dot -Tsvg > systemd.svg'!\n" ) : -abs(_e); }); | |||
1254 | ||||
1255 | return 0; | |||
1256 | } | |||
1257 | ||||
1258 | static int dump_fallback(sd_bus *bus) { | |||
1259 | _cleanup_(sd_bus_error_free)__attribute__((cleanup(sd_bus_error_free))) sd_bus_error error = SD_BUS_ERROR_NULL((const sd_bus_error) {(((void*)0)), (((void*)0)), 0}); | |||
1260 | _cleanup_(sd_bus_message_unrefp)__attribute__((cleanup(sd_bus_message_unrefp))) sd_bus_message *reply = NULL((void*)0); | |||
1261 | const char *text = NULL((void*)0); | |||
1262 | int r; | |||
1263 | ||||
1264 | assert(bus)do { if ((__builtin_expect(!!(!(bus)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("bus"), "../src/analyze/analyze.c", 1264 , __PRETTY_FUNCTION__); } while (0); | |||
1265 | ||||
1266 | r = sd_bus_call_method( | |||
1267 | bus, | |||
1268 | "org.freedesktop.systemd1", | |||
1269 | "/org/freedesktop/systemd1", | |||
1270 | "org.freedesktop.systemd1.Manager", | |||
1271 | "Dump", | |||
1272 | &error, | |||
1273 | &reply, | |||
1274 | NULL((void*)0)); | |||
1275 | if (r < 0) | |||
1276 | return log_error_errno(r, "Failed to issue method call Dump: %s", bus_error_message(&error, r))({ int _level = ((3)), _e = ((r)), _realm = (LOG_REALM_SYSTEMD ); (log_get_max_level_realm(_realm) >= ((_level) & 0x07 )) ? log_internal_realm(((_realm) << 10 | (_level)), _e , "../src/analyze/analyze.c", 1276, __func__, "Failed to issue method call Dump: %s" , bus_error_message(&error, r)) : -abs(_e); }); | |||
1277 | ||||
1278 | r = sd_bus_message_read(reply, "s", &text); | |||
1279 | if (r < 0) | |||
1280 | return bus_log_parse_error(r); | |||
1281 | ||||
1282 | fputs(text, stdoutstdout); | |||
1283 | return 0; | |||
1284 | } | |||
1285 | ||||
1286 | static int dump(int argc, char *argv[], void *userdata) { | |||
1287 | _cleanup_(sd_bus_error_free)__attribute__((cleanup(sd_bus_error_free))) sd_bus_error error = SD_BUS_ERROR_NULL((const sd_bus_error) {(((void*)0)), (((void*)0)), 0}); | |||
1288 | _cleanup_(sd_bus_message_unrefp)__attribute__((cleanup(sd_bus_message_unrefp))) sd_bus_message *reply = NULL((void*)0); | |||
1289 | _cleanup_(sd_bus_flush_close_unrefp)__attribute__((cleanup(sd_bus_flush_close_unrefp))) sd_bus *bus = NULL((void*)0); | |||
1290 | int fd = -1; | |||
1291 | int r; | |||
1292 | ||||
1293 | r = acquire_bus(&bus, NULL((void*)0)); | |||
1294 | if (r < 0) | |||
1295 | return log_error_errno(r, "Failed to create bus connection: %m")({ int _level = ((3)), _e = ((r)), _realm = (LOG_REALM_SYSTEMD ); (log_get_max_level_realm(_realm) >= ((_level) & 0x07 )) ? log_internal_realm(((_realm) << 10 | (_level)), _e , "../src/analyze/analyze.c", 1295, __func__, "Failed to create bus connection: %m" ) : -abs(_e); }); | |||
1296 | ||||
1297 | (void) pager_open(arg_no_pager, false0); | |||
1298 | ||||
1299 | if (!sd_bus_can_send(bus, SD_BUS_TYPE_UNIX_FD)) | |||
1300 | return dump_fallback(bus); | |||
1301 | ||||
1302 | r = sd_bus_call_method( | |||
1303 | bus, | |||
1304 | "org.freedesktop.systemd1", | |||
1305 | "/org/freedesktop/systemd1", | |||
1306 | "org.freedesktop.systemd1.Manager", | |||
1307 | "DumpByFileDescriptor", | |||
1308 | &error, | |||
1309 | &reply, | |||
1310 | NULL((void*)0)); | |||
1311 | if (r < 0) { | |||
1312 | /* fall back to Dump if DumpByFileDescriptor is not supported */ | |||
1313 | if (!IN_SET(r, -EACCES, -EBADR)({ _Bool _found = 0; static __attribute__ ((unused)) char _static_assert__macros_need_to_be_extended [20 - sizeof((int[]){-13, -53})/sizeof(int)]; switch(r) { case -13: case -53: _found = 1; break; default: break; } _found; } )) | |||
1314 | return log_error_errno(r, "Failed to issue method call DumpByFileDescriptor: %s", bus_error_message(&error, r))({ int _level = ((3)), _e = ((r)), _realm = (LOG_REALM_SYSTEMD ); (log_get_max_level_realm(_realm) >= ((_level) & 0x07 )) ? log_internal_realm(((_realm) << 10 | (_level)), _e , "../src/analyze/analyze.c", 1314, __func__, "Failed to issue method call DumpByFileDescriptor: %s" , bus_error_message(&error, r)) : -abs(_e); }); | |||
1315 | ||||
1316 | return dump_fallback(bus); | |||
1317 | } | |||
1318 | ||||
1319 | r = sd_bus_message_read(reply, "h", &fd); | |||
1320 | if (r < 0) | |||
1321 | return bus_log_parse_error(r); | |||
1322 | ||||
1323 | fflush(stdoutstdout); | |||
1324 | return copy_bytes(fd, STDOUT_FILENO1, (uint64_t) -1, 0); | |||
1325 | } | |||
1326 | ||||
1327 | static int cat_config(int argc, char *argv[], void *userdata) { | |||
1328 | char **arg; | |||
1329 | int r; | |||
1330 | ||||
1331 | (void) pager_open(arg_no_pager, false0); | |||
1332 | ||||
1333 | STRV_FOREACH(arg, argv + 1)for ((arg) = (argv + 1); (arg) && *(arg); (arg)++) { | |||
1334 | const char *t = NULL((void*)0); | |||
1335 | ||||
1336 | if (arg != argv + 1) | |||
1337 | print_separator(); | |||
1338 | ||||
1339 | if (path_is_absolute(*arg)) { | |||
1340 | const char *dir; | |||
1341 | ||||
1342 | NULSTR_FOREACH(dir, CONF_PATHS_NULSTR(""))for ((dir) = ("/etc/" "" "\0" "/run/" "" "\0" "/usr/local/lib/" "" "\0" "/usr/lib/" "" "\0"); (dir) && *(dir); (dir) = strchr((dir), 0)+1) { | |||
1343 | t = path_startswith(*arg, dir); | |||
1344 | if (t) | |||
1345 | break; | |||
1346 | } | |||
1347 | ||||
1348 | if (!t) { | |||
1349 | log_error("Path %s does not start with any known prefix.", *arg)({ int _level = (((3))), _e = ((0)), _realm = (LOG_REALM_SYSTEMD ); (log_get_max_level_realm(_realm) >= ((_level) & 0x07 )) ? log_internal_realm(((_realm) << 10 | (_level)), _e , "../src/analyze/analyze.c", 1349, __func__, "Path %s does not start with any known prefix." , *arg) : -abs(_e); }); | |||
1350 | return -EINVAL22; | |||
1351 | } | |||
1352 | } else | |||
1353 | t = *arg; | |||
1354 | ||||
1355 | r = conf_files_cat(arg_root, t); | |||
1356 | if (r < 0) | |||
1357 | return r; | |||
1358 | } | |||
1359 | ||||
1360 | return 0; | |||
1361 | } | |||
1362 | ||||
1363 | static int set_log_level(int argc, char *argv[], void *userdata) { | |||
1364 | _cleanup_(sd_bus_error_free)__attribute__((cleanup(sd_bus_error_free))) sd_bus_error error = SD_BUS_ERROR_NULL((const sd_bus_error) {(((void*)0)), (((void*)0)), 0}); | |||
1365 | _cleanup_(sd_bus_flush_close_unrefp)__attribute__((cleanup(sd_bus_flush_close_unrefp))) sd_bus *bus = NULL((void*)0); | |||
1366 | int r; | |||
1367 | ||||
1368 | assert(argc == 2)do { if ((__builtin_expect(!!(!(argc == 2)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("argc == 2"), "../src/analyze/analyze.c" , 1368, __PRETTY_FUNCTION__); } while (0); | |||
1369 | assert(argv)do { if ((__builtin_expect(!!(!(argv)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("argv"), "../src/analyze/analyze.c", 1369 , __PRETTY_FUNCTION__); } while (0); | |||
1370 | ||||
1371 | r = acquire_bus(&bus, NULL((void*)0)); | |||
1372 | if (r < 0) | |||
1373 | return log_error_errno(r, "Failed to create bus connection: %m")({ int _level = ((3)), _e = ((r)), _realm = (LOG_REALM_SYSTEMD ); (log_get_max_level_realm(_realm) >= ((_level) & 0x07 )) ? log_internal_realm(((_realm) << 10 | (_level)), _e , "../src/analyze/analyze.c", 1373, __func__, "Failed to create bus connection: %m" ) : -abs(_e); }); | |||
1374 | ||||
1375 | r = sd_bus_set_property( | |||
1376 | bus, | |||
1377 | "org.freedesktop.systemd1", | |||
1378 | "/org/freedesktop/systemd1", | |||
1379 | "org.freedesktop.systemd1.Manager", | |||
1380 | "LogLevel", | |||
1381 | &error, | |||
1382 | "s", | |||
1383 | argv[1]); | |||
1384 | if (r < 0) | |||
1385 | return log_error_errno(r, "Failed to issue method call: %s", bus_error_message(&error, r))({ int _level = ((3)), _e = ((r)), _realm = (LOG_REALM_SYSTEMD ); (log_get_max_level_realm(_realm) >= ((_level) & 0x07 )) ? log_internal_realm(((_realm) << 10 | (_level)), _e , "../src/analyze/analyze.c", 1385, __func__, "Failed to issue method call: %s" , bus_error_message(&error, r)) : -abs(_e); }); | |||
1386 | ||||
1387 | return 0; | |||
1388 | } | |||
1389 | ||||
1390 | static int get_log_level(int argc, char *argv[], void *userdata) { | |||
1391 | _cleanup_(sd_bus_error_free)__attribute__((cleanup(sd_bus_error_free))) sd_bus_error error = SD_BUS_ERROR_NULL((const sd_bus_error) {(((void*)0)), (((void*)0)), 0}); | |||
1392 | _cleanup_(sd_bus_flush_close_unrefp)__attribute__((cleanup(sd_bus_flush_close_unrefp))) sd_bus *bus = NULL((void*)0); | |||
1393 | _cleanup_free___attribute__((cleanup(freep))) char *level = NULL((void*)0); | |||
1394 | int r; | |||
1395 | ||||
1396 | r = acquire_bus(&bus, NULL((void*)0)); | |||
1397 | if (r < 0) | |||
1398 | return log_error_errno(r, "Failed to create bus connection: %m")({ int _level = ((3)), _e = ((r)), _realm = (LOG_REALM_SYSTEMD ); (log_get_max_level_realm(_realm) >= ((_level) & 0x07 )) ? log_internal_realm(((_realm) << 10 | (_level)), _e , "../src/analyze/analyze.c", 1398, __func__, "Failed to create bus connection: %m" ) : -abs(_e); }); | |||
1399 | ||||
1400 | r = sd_bus_get_property_string( | |||
1401 | bus, | |||
1402 | "org.freedesktop.systemd1", | |||
1403 | "/org/freedesktop/systemd1", | |||
1404 | "org.freedesktop.systemd1.Manager", | |||
1405 | "LogLevel", | |||
1406 | &error, | |||
1407 | &level); | |||
1408 | if (r < 0) | |||
1409 | return log_error_errno(r, "Failed to get log level: %s", bus_error_message(&error, r))({ int _level = ((3)), _e = ((r)), _realm = (LOG_REALM_SYSTEMD ); (log_get_max_level_realm(_realm) >= ((_level) & 0x07 )) ? log_internal_realm(((_realm) << 10 | (_level)), _e , "../src/analyze/analyze.c", 1409, __func__, "Failed to get log level: %s" , bus_error_message(&error, r)) : -abs(_e); }); | |||
1410 | ||||
1411 | puts(level); | |||
1412 | return 0; | |||
1413 | } | |||
1414 | ||||
1415 | static int get_or_set_log_level(int argc, char *argv[], void *userdata) { | |||
1416 | return (argc == 1) ? get_log_level(argc, argv, userdata) : set_log_level(argc, argv, userdata); | |||
1417 | } | |||
1418 | ||||
1419 | static int set_log_target(int argc, char *argv[], void *userdata) { | |||
1420 | _cleanup_(sd_bus_error_free)__attribute__((cleanup(sd_bus_error_free))) sd_bus_error error = SD_BUS_ERROR_NULL((const sd_bus_error) {(((void*)0)), (((void*)0)), 0}); | |||
1421 | _cleanup_(sd_bus_flush_close_unrefp)__attribute__((cleanup(sd_bus_flush_close_unrefp))) sd_bus *bus = NULL((void*)0); | |||
1422 | int r; | |||
1423 | ||||
1424 | assert(argc == 2)do { if ((__builtin_expect(!!(!(argc == 2)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("argc == 2"), "../src/analyze/analyze.c" , 1424, __PRETTY_FUNCTION__); } while (0); | |||
1425 | assert(argv)do { if ((__builtin_expect(!!(!(argv)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("argv"), "../src/analyze/analyze.c", 1425 , __PRETTY_FUNCTION__); } while (0); | |||
1426 | ||||
1427 | r = acquire_bus(&bus, NULL((void*)0)); | |||
1428 | if (r < 0) | |||
1429 | return log_error_errno(r, "Failed to create bus connection: %m")({ int _level = ((3)), _e = ((r)), _realm = (LOG_REALM_SYSTEMD ); (log_get_max_level_realm(_realm) >= ((_level) & 0x07 )) ? log_internal_realm(((_realm) << 10 | (_level)), _e , "../src/analyze/analyze.c", 1429, __func__, "Failed to create bus connection: %m" ) : -abs(_e); }); | |||
1430 | ||||
1431 | r = sd_bus_set_property( | |||
1432 | bus, | |||
1433 | "org.freedesktop.systemd1", | |||
1434 | "/org/freedesktop/systemd1", | |||
1435 | "org.freedesktop.systemd1.Manager", | |||
1436 | "LogTarget", | |||
1437 | &error, | |||
1438 | "s", | |||
1439 | argv[1]); | |||
1440 | if (r < 0) | |||
1441 | return log_error_errno(r, "Failed to issue method call: %s", bus_error_message(&error, r))({ int _level = ((3)), _e = ((r)), _realm = (LOG_REALM_SYSTEMD ); (log_get_max_level_realm(_realm) >= ((_level) & 0x07 )) ? log_internal_realm(((_realm) << 10 | (_level)), _e , "../src/analyze/analyze.c", 1441, __func__, "Failed to issue method call: %s" , bus_error_message(&error, r)) : -abs(_e); }); | |||
1442 | ||||
1443 | return 0; | |||
1444 | } | |||
1445 | ||||
1446 | static int get_log_target(int argc, char *argv[], void *userdata) { | |||
1447 | _cleanup_(sd_bus_error_free)__attribute__((cleanup(sd_bus_error_free))) sd_bus_error error = SD_BUS_ERROR_NULL((const sd_bus_error) {(((void*)0)), (((void*)0)), 0}); | |||
1448 | _cleanup_(sd_bus_flush_close_unrefp)__attribute__((cleanup(sd_bus_flush_close_unrefp))) sd_bus *bus = NULL((void*)0); | |||
1449 | _cleanup_free___attribute__((cleanup(freep))) char *target = NULL((void*)0); | |||
1450 | int r; | |||
1451 | ||||
1452 | r = acquire_bus(&bus, NULL((void*)0)); | |||
1453 | if (r < 0) | |||
1454 | return log_error_errno(r, "Failed to create bus connection: %m")({ int _level = ((3)), _e = ((r)), _realm = (LOG_REALM_SYSTEMD ); (log_get_max_level_realm(_realm) >= ((_level) & 0x07 )) ? log_internal_realm(((_realm) << 10 | (_level)), _e , "../src/analyze/analyze.c", 1454, __func__, "Failed to create bus connection: %m" ) : -abs(_e); }); | |||
1455 | ||||
1456 | r = sd_bus_get_property_string( | |||
1457 | bus, | |||
1458 | "org.freedesktop.systemd1", | |||
1459 | "/org/freedesktop/systemd1", | |||
1460 | "org.freedesktop.systemd1.Manager", | |||
1461 | "LogTarget", | |||
1462 | &error, | |||
1463 | &target); | |||
1464 | if (r < 0) | |||
1465 | return log_error_errno(r, "Failed to get log target: %s", bus_error_message(&error, r))({ int _level = ((3)), _e = ((r)), _realm = (LOG_REALM_SYSTEMD ); (log_get_max_level_realm(_realm) >= ((_level) & 0x07 )) ? log_internal_realm(((_realm) << 10 | (_level)), _e , "../src/analyze/analyze.c", 1465, __func__, "Failed to get log target: %s" , bus_error_message(&error, r)) : -abs(_e); }); | |||
1466 | ||||
1467 | puts(target); | |||
1468 | return 0; | |||
1469 | } | |||
1470 | ||||
1471 | static int get_or_set_log_target(int argc, char *argv[], void *userdata) { | |||
1472 | return (argc == 1) ? get_log_target(argc, argv, userdata) : set_log_target(argc, argv, userdata); | |||
1473 | } | |||
1474 | ||||
1475 | static int dump_unit_paths(int argc, char *argv[], void *userdata) { | |||
1476 | _cleanup_(lookup_paths_free)__attribute__((cleanup(lookup_paths_free))) LookupPaths paths = {}; | |||
1477 | int r; | |||
1478 | char **p; | |||
1479 | ||||
1480 | r = lookup_paths_init(&paths, arg_scope, 0, NULL((void*)0)); | |||
1481 | if (r < 0) | |||
1482 | return log_error_errno(r, "lookup_paths_init() failed: %m")({ int _level = ((3)), _e = ((r)), _realm = (LOG_REALM_SYSTEMD ); (log_get_max_level_realm(_realm) >= ((_level) & 0x07 )) ? log_internal_realm(((_realm) << 10 | (_level)), _e , "../src/analyze/analyze.c", 1482, __func__, "lookup_paths_init() failed: %m" ) : -abs(_e); }); | |||
1483 | ||||
1484 | STRV_FOREACH(p, paths.search_path)for ((p) = (paths.search_path); (p) && *(p); (p)++) | |||
1485 | puts(*p); | |||
1486 | ||||
1487 | return 0; | |||
1488 | } | |||
1489 | ||||
1490 | #if HAVE_SECCOMP1 | |||
1491 | static void dump_syscall_filter(const SyscallFilterSet *set) { | |||
1492 | const char *syscall; | |||
1493 | ||||
1494 | printf("%s\n", set->name); | |||
1495 | printf(" # %s\n", set->help); | |||
1496 | NULSTR_FOREACH(syscall, set->value)for ((syscall) = (set->value); (syscall) && *(syscall ); (syscall) = strchr((syscall), 0)+1) | |||
1497 | printf(" %s\n", syscall); | |||
1498 | } | |||
1499 | ||||
1500 | static int dump_syscall_filters(int argc, char *argv[], void *userdata) { | |||
1501 | bool_Bool first = true1; | |||
1502 | ||||
1503 | (void) pager_open(arg_no_pager, false0); | |||
1504 | ||||
1505 | if (strv_isempty(strv_skip(argv, 1))) { | |||
1506 | int i; | |||
1507 | ||||
1508 | for (i = 0; i < _SYSCALL_FILTER_SET_MAX; i++) { | |||
1509 | if (!first) | |||
1510 | puts(""); | |||
1511 | dump_syscall_filter(syscall_filter_sets + i); | |||
1512 | first = false0; | |||
1513 | } | |||
1514 | } else { | |||
1515 | char **name; | |||
1516 | ||||
1517 | STRV_FOREACH(name, strv_skip(argv, 1))for ((name) = (strv_skip(argv, 1)); (name) && *(name) ; (name)++) { | |||
1518 | const SyscallFilterSet *set; | |||
1519 | ||||
1520 | if (!first) | |||
1521 | puts(""); | |||
1522 | ||||
1523 | set = syscall_filter_set_find(*name); | |||
1524 | if (!set) { | |||
1525 | /* make sure the error appears below normal output */ | |||
1526 | fflush(stdoutstdout); | |||
1527 | ||||
1528 | log_error("Filter set \"%s\" not found.", *name)({ int _level = (((3))), _e = ((0)), _realm = (LOG_REALM_SYSTEMD ); (log_get_max_level_realm(_realm) >= ((_level) & 0x07 )) ? log_internal_realm(((_realm) << 10 | (_level)), _e , "../src/analyze/analyze.c", 1528, __func__, "Filter set \"%s\" not found." , *name) : -abs(_e); }); | |||
1529 | return -ENOENT2; | |||
1530 | } | |||
1531 | ||||
1532 | dump_syscall_filter(set); | |||
1533 | first = false0; | |||
1534 | } | |||
1535 | } | |||
1536 | ||||
1537 | return 0; | |||
1538 | } | |||
1539 | ||||
1540 | #else | |||
1541 | static int dump_syscall_filters(int argc, char *argv[], void *userdata) { | |||
1542 | log_error("Not compiled with syscall filters, sorry.")({ int _level = (((3))), _e = ((0)), _realm = (LOG_REALM_SYSTEMD ); (log_get_max_level_realm(_realm) >= ((_level) & 0x07 )) ? log_internal_realm(((_realm) << 10 | (_level)), _e , "../src/analyze/analyze.c", 1542, __func__, "Not compiled with syscall filters, sorry." ) : -abs(_e); }); | |||
1543 | return -EOPNOTSUPP95; | |||
1544 | } | |||
1545 | #endif | |||
1546 | ||||
1547 | static int test_calendar(int argc, char *argv[], void *userdata) { | |||
1548 | int ret = 0, r; | |||
1549 | char **p; | |||
1550 | usec_t n; | |||
1551 | ||||
1552 | n = now(CLOCK_REALTIME0); | |||
1553 | ||||
1554 | STRV_FOREACH(p, strv_skip(argv, 1))for ((p) = (strv_skip(argv, 1)); (p) && *(p); (p)++) { | |||
1555 | _cleanup_(calendar_spec_freep)__attribute__((cleanup(calendar_spec_freep))) CalendarSpec *spec = NULL((void*)0); | |||
1556 | _cleanup_free___attribute__((cleanup(freep))) char *t = NULL((void*)0); | |||
1557 | usec_t next; | |||
1558 | ||||
1559 | r = calendar_spec_from_string(*p, &spec); | |||
1560 | if (r < 0) { | |||
1561 | ret = log_error_errno(r, "Failed to parse calendar specification '%s': %m", *p)({ int _level = ((3)), _e = ((r)), _realm = (LOG_REALM_SYSTEMD ); (log_get_max_level_realm(_realm) >= ((_level) & 0x07 )) ? log_internal_realm(((_realm) << 10 | (_level)), _e , "../src/analyze/analyze.c", 1561, __func__, "Failed to parse calendar specification '%s': %m" , *p) : -abs(_e); }); | |||
1562 | continue; | |||
1563 | } | |||
1564 | ||||
1565 | r = calendar_spec_normalize(spec); | |||
1566 | if (r < 0) { | |||
1567 | ret = log_error_errno(r, "Failed to normalize calendar specification '%s': %m", *p)({ int _level = ((3)), _e = ((r)), _realm = (LOG_REALM_SYSTEMD ); (log_get_max_level_realm(_realm) >= ((_level) & 0x07 )) ? log_internal_realm(((_realm) << 10 | (_level)), _e , "../src/analyze/analyze.c", 1567, __func__, "Failed to normalize calendar specification '%s': %m" , *p) : -abs(_e); }); | |||
1568 | continue; | |||
1569 | } | |||
1570 | ||||
1571 | r = calendar_spec_to_string(spec, &t); | |||
1572 | if (r < 0) { | |||
1573 | ret = log_error_errno(r, "Failed to format calendar specification '%s': %m", *p)({ int _level = ((3)), _e = ((r)), _realm = (LOG_REALM_SYSTEMD ); (log_get_max_level_realm(_realm) >= ((_level) & 0x07 )) ? log_internal_realm(((_realm) << 10 | (_level)), _e , "../src/analyze/analyze.c", 1573, __func__, "Failed to format calendar specification '%s': %m" , *p) : -abs(_e); }); | |||
1574 | continue; | |||
1575 | } | |||
1576 | ||||
1577 | if (!streq(t, *p)(strcmp((t),(*p)) == 0)) | |||
1578 | printf(" Original form: %s\n", *p); | |||
1579 | ||||
1580 | printf("Normalized form: %s\n", t); | |||
1581 | ||||
1582 | r = calendar_spec_next_usec(spec, n, &next); | |||
1583 | if (r == -ENOENT2) | |||
1584 | printf(" Next elapse: never\n"); | |||
1585 | else if (r < 0) { | |||
1586 | ret = log_error_errno(r, "Failed to determine next elapse for '%s': %m", *p)({ int _level = ((3)), _e = ((r)), _realm = (LOG_REALM_SYSTEMD ); (log_get_max_level_realm(_realm) >= ((_level) & 0x07 )) ? log_internal_realm(((_realm) << 10 | (_level)), _e , "../src/analyze/analyze.c", 1586, __func__, "Failed to determine next elapse for '%s': %m" , *p) : -abs(_e); }); | |||
1587 | continue; | |||
1588 | } else { | |||
1589 | char buffer[CONST_MAX(FORMAT_TIMESTAMP_MAX, FORMAT_TIMESTAMP_RELATIVE_MAX)__extension__ (__builtin_choose_expr( __builtin_constant_p((3 +1+10+1+8+1+6+1+6+1)) && __builtin_constant_p(256) && __builtin_types_compatible_p(typeof((3+1+10+1+8+1+6+1+6+1)), typeof(256)), (((3+1+10+1+8+1+6+1+6+1)) > (256)) ? ((3+1+ 10+1+8+1+6+1+6+1)) : (256), ((void)0)))]; | |||
1590 | ||||
1591 | printf(" Next elapse: %s\n", format_timestamp(buffer, sizeof(buffer), next)); | |||
1592 | ||||
1593 | if (!in_utc_timezone()) | |||
1594 | printf(" (in UTC): %s\n", format_timestamp_utc(buffer, sizeof(buffer), next)); | |||
1595 | ||||
1596 | printf(" From now: %s\n", format_timestamp_relative(buffer, sizeof(buffer), next)); | |||
1597 | } | |||
1598 | ||||
1599 | if (*(p+1)) | |||
1600 | putchar('\n'); | |||
1601 | } | |||
1602 | ||||
1603 | return ret; | |||
1604 | } | |||
1605 | ||||
1606 | static int service_watchdogs(int argc, char *argv[], void *userdata) { | |||
1607 | _cleanup_(sd_bus_error_free)__attribute__((cleanup(sd_bus_error_free))) sd_bus_error error = SD_BUS_ERROR_NULL((const sd_bus_error) {(((void*)0)), (((void*)0)), 0}); | |||
1608 | _cleanup_(sd_bus_flush_close_unrefp)__attribute__((cleanup(sd_bus_flush_close_unrefp))) sd_bus *bus = NULL((void*)0); | |||
1609 | int b, r; | |||
1610 | ||||
1611 | assert(IN_SET(argc, 1, 2))do { if ((__builtin_expect(!!(!(({ _Bool _found = 0; static __attribute__ ((unused)) char _static_assert__macros_need_to_be_extended[20 - sizeof((int[]){1, 2})/sizeof(int)]; switch(argc) { case 1: case 2: _found = 1; break; default: break; } _found; }))),0) )) log_assert_failed_realm(LOG_REALM_SYSTEMD, ("IN_SET(argc, 1, 2)" ), "../src/analyze/analyze.c", 1611, __PRETTY_FUNCTION__); } while (0); | |||
1612 | assert(argv)do { if ((__builtin_expect(!!(!(argv)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("argv"), "../src/analyze/analyze.c", 1612 , __PRETTY_FUNCTION__); } while (0); | |||
1613 | ||||
1614 | r = acquire_bus(&bus, NULL((void*)0)); | |||
1615 | if (r < 0) | |||
1616 | return log_error_errno(r, "Failed to create bus connection: %m")({ int _level = ((3)), _e = ((r)), _realm = (LOG_REALM_SYSTEMD ); (log_get_max_level_realm(_realm) >= ((_level) & 0x07 )) ? log_internal_realm(((_realm) << 10 | (_level)), _e , "../src/analyze/analyze.c", 1616, __func__, "Failed to create bus connection: %m" ) : -abs(_e); }); | |||
1617 | ||||
1618 | /* get ServiceWatchdogs */ | |||
1619 | if (argc == 1) { | |||
1620 | r = sd_bus_get_property_trivial( | |||
1621 | bus, | |||
1622 | "org.freedesktop.systemd1", | |||
1623 | "/org/freedesktop/systemd1", | |||
1624 | "org.freedesktop.systemd1.Manager", | |||
1625 | "ServiceWatchdogs", | |||
1626 | &error, | |||
1627 | 'b', | |||
1628 | &b); | |||
1629 | if (r < 0) | |||
1630 | return log_error_errno(r, "Failed to get service-watchdog state: %s", bus_error_message(&error, r))({ int _level = ((3)), _e = ((r)), _realm = (LOG_REALM_SYSTEMD ); (log_get_max_level_realm(_realm) >= ((_level) & 0x07 )) ? log_internal_realm(((_realm) << 10 | (_level)), _e , "../src/analyze/analyze.c", 1630, __func__, "Failed to get service-watchdog state: %s" , bus_error_message(&error, r)) : -abs(_e); }); | |||
1631 | ||||
1632 | printf("%s\n", yes_no(!!b)); | |||
1633 | ||||
1634 | return 0; | |||
1635 | } | |||
1636 | ||||
1637 | /* set ServiceWatchdogs */ | |||
1638 | b = parse_boolean(argv[1]); | |||
1639 | if (b < 0) { | |||
1640 | log_error("Failed to parse service-watchdogs argument.")({ int _level = (((3))), _e = ((0)), _realm = (LOG_REALM_SYSTEMD ); (log_get_max_level_realm(_realm) >= ((_level) & 0x07 )) ? log_internal_realm(((_realm) << 10 | (_level)), _e , "../src/analyze/analyze.c", 1640, __func__, "Failed to parse service-watchdogs argument." ) : -abs(_e); }); | |||
1641 | return -EINVAL22; | |||
1642 | } | |||
1643 | ||||
1644 | r = sd_bus_set_property( | |||
1645 | bus, | |||
1646 | "org.freedesktop.systemd1", | |||
1647 | "/org/freedesktop/systemd1", | |||
1648 | "org.freedesktop.systemd1.Manager", | |||
1649 | "ServiceWatchdogs", | |||
1650 | &error, | |||
1651 | "b", | |||
1652 | b); | |||
1653 | if (r < 0) | |||
1654 | return log_error_errno(r, "Failed to set service-watchdog state: %s", bus_error_message(&error, r))({ int _level = ((3)), _e = ((r)), _realm = (LOG_REALM_SYSTEMD ); (log_get_max_level_realm(_realm) >= ((_level) & 0x07 )) ? log_internal_realm(((_realm) << 10 | (_level)), _e , "../src/analyze/analyze.c", 1654, __func__, "Failed to set service-watchdog state: %s" , bus_error_message(&error, r)) : -abs(_e); }); | |||
1655 | ||||
1656 | return 0; | |||
1657 | } | |||
1658 | ||||
1659 | static int do_verify(int argc, char *argv[], void *userdata) { | |||
1660 | return verify_units(strv_skip(argv, 1), arg_scope, arg_man, arg_generators); | |||
1661 | } | |||
1662 | ||||
1663 | static int do_security(int argc, char *argv[], void *userdata) { | |||
1664 | _cleanup_(sd_bus_flush_close_unrefp)__attribute__((cleanup(sd_bus_flush_close_unrefp))) sd_bus *bus = NULL((void*)0); | |||
1665 | int r; | |||
1666 | ||||
1667 | r = acquire_bus(&bus, NULL((void*)0)); | |||
1668 | if (r < 0) | |||
1669 | return log_error_errno(r, "Failed to create bus connection: %m")({ int _level = ((3)), _e = ((r)), _realm = (LOG_REALM_SYSTEMD ); (log_get_max_level_realm(_realm) >= ((_level) & 0x07 )) ? log_internal_realm(((_realm) << 10 | (_level)), _e , "../src/analyze/analyze.c", 1669, __func__, "Failed to create bus connection: %m" ) : -abs(_e); }); | |||
1670 | ||||
1671 | (void) pager_open(arg_no_pager, false0); | |||
1672 | ||||
1673 | return analyze_security(bus, strv_skip(argv, 1), 0); | |||
1674 | } | |||
1675 | ||||
1676 | static int help(int argc, char *argv[], void *userdata) { | |||
1677 | ||||
1678 | (void) pager_open(arg_no_pager, false0); | |||
1679 | ||||
1680 | printf("%s [OPTIONS...] {COMMAND} ...\n\n" | |||
1681 | "Profile systemd, show unit dependencies, check unit files.\n\n" | |||
1682 | " -h --help Show this help\n" | |||
1683 | " --version Show package version\n" | |||
1684 | " --no-pager Do not pipe output into a pager\n" | |||
1685 | " --system Operate on system systemd instance\n" | |||
1686 | " --user Operate on user systemd instance\n" | |||
1687 | " --global Operate on global user configuration\n" | |||
1688 | " -H --host=[USER@]HOST Operate on remote host\n" | |||
1689 | " -M --machine=CONTAINER Operate on local container\n" | |||
1690 | " --order Show only order in the graph\n" | |||
1691 | " --require Show only requirement in the graph\n" | |||
1692 | " --from-pattern=GLOB Show only origins in the graph\n" | |||
1693 | " --to-pattern=GLOB Show only destinations in the graph\n" | |||
1694 | " --fuzz=SECONDS Also print also services which finished SECONDS\n" | |||
1695 | " earlier than the latest in the branch\n" | |||
1696 | " --man[=BOOL] Do [not] check for existence of man pages\n\n" | |||
1697 | " --generators[=BOOL] Do [not] run unit generators (requires privileges)\n\n" | |||
1698 | "Commands:\n" | |||
1699 | " time Print time spent in the kernel\n" | |||
1700 | " blame Print list of running units ordered by time to init\n" | |||
1701 | " critical-chain [UNIT...] Print a tree of the time critical chain of units\n" | |||
1702 | " plot Output SVG graphic showing service initialization\n" | |||
1703 | " dot [UNIT...] Output dependency graph in man:dot(1) format\n" | |||
1704 | " log-level [LEVEL] Get/set logging threshold for manager\n" | |||
1705 | " log-target [TARGET] Get/set logging target for manager\n" | |||
1706 | " dump Output state serialization of service manager\n" | |||
1707 | " cat-config Show configuration file and drop-ins\n" | |||
1708 | " unit-paths List load directories for units\n" | |||
1709 | " syscall-filter [NAME...] Print list of syscalls in seccomp filter\n" | |||
1710 | " verify FILE... Check unit files for correctness\n" | |||
1711 | " calendar SPEC... Validate repetitive calendar time events\n" | |||
1712 | " service-watchdogs [BOOL] Get/set service watchdog state\n" | |||
1713 | " security [UNIT...] Analyze security of unit\n" | |||
1714 | , program_invocation_short_name); | |||
1715 | ||||
1716 | /* When updating this list, including descriptions, apply | |||
1717 | * changes to shell-completion/bash/systemd-analyze and | |||
1718 | * shell-completion/zsh/_systemd-analyze too. */ | |||
1719 | ||||
1720 | return 0; | |||
1721 | } | |||
1722 | ||||
1723 | static int parse_argv(int argc, char *argv[]) { | |||
1724 | enum { | |||
1725 | ARG_VERSION = 0x100, | |||
1726 | ARG_ORDER, | |||
1727 | ARG_REQUIRE, | |||
1728 | ARG_ROOT, | |||
1729 | ARG_SYSTEM, | |||
1730 | ARG_USER, | |||
1731 | ARG_GLOBAL, | |||
1732 | ARG_DOT_FROM_PATTERN, | |||
1733 | ARG_DOT_TO_PATTERN, | |||
1734 | ARG_FUZZ, | |||
1735 | ARG_NO_PAGER, | |||
1736 | ARG_MAN, | |||
1737 | ARG_GENERATORS, | |||
1738 | }; | |||
1739 | ||||
1740 | static const struct option options[] = { | |||
1741 | { "help", no_argument0, NULL((void*)0), 'h' }, | |||
1742 | { "version", no_argument0, NULL((void*)0), ARG_VERSION }, | |||
1743 | { "order", no_argument0, NULL((void*)0), ARG_ORDER }, | |||
1744 | { "require", no_argument0, NULL((void*)0), ARG_REQUIRE }, | |||
1745 | { "root", required_argument1, NULL((void*)0), ARG_ROOT }, | |||
1746 | { "system", no_argument0, NULL((void*)0), ARG_SYSTEM }, | |||
1747 | { "user", no_argument0, NULL((void*)0), ARG_USER }, | |||
1748 | { "global", no_argument0, NULL((void*)0), ARG_GLOBAL }, | |||
1749 | { "from-pattern", required_argument1, NULL((void*)0), ARG_DOT_FROM_PATTERN }, | |||
1750 | { "to-pattern", required_argument1, NULL((void*)0), ARG_DOT_TO_PATTERN }, | |||
1751 | { "fuzz", required_argument1, NULL((void*)0), ARG_FUZZ }, | |||
1752 | { "no-pager", no_argument0, NULL((void*)0), ARG_NO_PAGER }, | |||
1753 | { "man", optional_argument2, NULL((void*)0), ARG_MAN }, | |||
1754 | { "generators", optional_argument2, NULL((void*)0), ARG_GENERATORS }, | |||
1755 | { "host", required_argument1, NULL((void*)0), 'H' }, | |||
1756 | { "machine", required_argument1, NULL((void*)0), 'M' }, | |||
1757 | {} | |||
1758 | }; | |||
1759 | ||||
1760 | int r, c; | |||
1761 | ||||
1762 | assert(argc >= 0)do { if ((__builtin_expect(!!(!(argc >= 0)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("argc >= 0"), "../src/analyze/analyze.c" , 1762, __PRETTY_FUNCTION__); } while (0); | |||
1763 | assert(argv)do { if ((__builtin_expect(!!(!(argv)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("argv"), "../src/analyze/analyze.c", 1763 , __PRETTY_FUNCTION__); } while (0); | |||
1764 | ||||
1765 | while ((c = getopt_long(argc, argv, "hH:M:", options, NULL((void*)0))) >= 0) | |||
1766 | switch (c) { | |||
1767 | ||||
1768 | case 'h': | |||
1769 | return help(0, NULL((void*)0), NULL((void*)0)); | |||
1770 | ||||
1771 | case ARG_VERSION: | |||
1772 | return version(); | |||
1773 | ||||
1774 | case ARG_ROOT: | |||
1775 | arg_root = optarg; | |||
1776 | break; | |||
1777 | ||||
1778 | case ARG_SYSTEM: | |||
1779 | arg_scope = UNIT_FILE_SYSTEM; | |||
1780 | break; | |||
1781 | ||||
1782 | case ARG_USER: | |||
1783 | arg_scope = UNIT_FILE_USER; | |||
1784 | break; | |||
1785 | ||||
1786 | case ARG_GLOBAL: | |||
1787 | arg_scope = UNIT_FILE_GLOBAL; | |||
1788 | break; | |||
1789 | ||||
1790 | case ARG_ORDER: | |||
1791 | arg_dot = DEP_ORDER; | |||
1792 | break; | |||
1793 | ||||
1794 | case ARG_REQUIRE: | |||
1795 | arg_dot = DEP_REQUIRE; | |||
1796 | break; | |||
1797 | ||||
1798 | case ARG_DOT_FROM_PATTERN: | |||
1799 | if (strv_extend(&arg_dot_from_patterns, optarg) < 0) | |||
1800 | return log_oom()log_oom_internal(LOG_REALM_SYSTEMD, "../src/analyze/analyze.c" , 1800, __func__); | |||
1801 | ||||
1802 | break; | |||
1803 | ||||
1804 | case ARG_DOT_TO_PATTERN: | |||
1805 | if (strv_extend(&arg_dot_to_patterns, optarg) < 0) | |||
1806 | return log_oom()log_oom_internal(LOG_REALM_SYSTEMD, "../src/analyze/analyze.c" , 1806, __func__); | |||
1807 | ||||
1808 | break; | |||
1809 | ||||
1810 | case ARG_FUZZ: | |||
1811 | r = parse_sec(optarg, &arg_fuzz); | |||
1812 | if (r < 0) | |||
1813 | return r; | |||
1814 | break; | |||
1815 | ||||
1816 | case ARG_NO_PAGER: | |||
1817 | arg_no_pager = true1; | |||
1818 | break; | |||
1819 | ||||
1820 | case 'H': | |||
1821 | arg_transport = BUS_TRANSPORT_REMOTE; | |||
1822 | arg_host = optarg; | |||
1823 | break; | |||
1824 | ||||
1825 | case 'M': | |||
1826 | arg_transport = BUS_TRANSPORT_MACHINE; | |||
1827 | arg_host = optarg; | |||
1828 | break; | |||
1829 | ||||
1830 | case ARG_MAN: | |||
1831 | if (optarg) { | |||
1832 | r = parse_boolean(optarg); | |||
1833 | if (r < 0) { | |||
1834 | log_error("Failed to parse --man= argument.")({ int _level = (((3))), _e = ((0)), _realm = (LOG_REALM_SYSTEMD ); (log_get_max_level_realm(_realm) >= ((_level) & 0x07 )) ? log_internal_realm(((_realm) << 10 | (_level)), _e , "../src/analyze/analyze.c", 1834, __func__, "Failed to parse --man= argument." ) : -abs(_e); }); | |||
1835 | return -EINVAL22; | |||
1836 | } | |||
1837 | ||||
1838 | arg_man = r; | |||
1839 | } else | |||
1840 | arg_man = true1; | |||
1841 | ||||
1842 | break; | |||
1843 | ||||
1844 | case ARG_GENERATORS: | |||
1845 | if (optarg) { | |||
1846 | r = parse_boolean(optarg); | |||
1847 | if (r < 0) { | |||
1848 | log_error("Failed to parse --generators= argument.")({ int _level = (((3))), _e = ((0)), _realm = (LOG_REALM_SYSTEMD ); (log_get_max_level_realm(_realm) >= ((_level) & 0x07 )) ? log_internal_realm(((_realm) << 10 | (_level)), _e , "../src/analyze/analyze.c", 1848, __func__, "Failed to parse --generators= argument." ) : -abs(_e); }); | |||
1849 | return -EINVAL22; | |||
1850 | } | |||
1851 | ||||
1852 | arg_generators = r; | |||
1853 | } else | |||
1854 | arg_generators = true1; | |||
1855 | ||||
1856 | break; | |||
1857 | ||||
1858 | case '?': | |||
1859 | return -EINVAL22; | |||
1860 | ||||
1861 | default: | |||
1862 | assert_not_reached("Unhandled option code.")do { log_assert_failed_unreachable_realm(LOG_REALM_SYSTEMD, ( "Unhandled option code."), "../src/analyze/analyze.c", 1862, __PRETTY_FUNCTION__ ); } while (0); | |||
1863 | } | |||
1864 | ||||
1865 | if (arg_scope == UNIT_FILE_GLOBAL && | |||
1866 | !STR_IN_SET(argv[optind] ?: "time", "dot", "unit-paths", "verify")(!!strv_find((((char**) ((const char*[]) { "dot", "unit-paths" , "verify", ((void*)0) }))), (argv[optind] ?: "time")))) { | |||
1867 | log_error("Option --global only makes sense with verbs dot, unit-paths, verify.")({ int _level = (((3))), _e = ((0)), _realm = (LOG_REALM_SYSTEMD ); (log_get_max_level_realm(_realm) >= ((_level) & 0x07 )) ? log_internal_realm(((_realm) << 10 | (_level)), _e , "../src/analyze/analyze.c", 1867, __func__, "Option --global only makes sense with verbs dot, unit-paths, verify." ) : -abs(_e); }); | |||
1868 | return -EINVAL22; | |||
1869 | } | |||
1870 | ||||
1871 | if (arg_root && !streq_ptr(argv[optind], "cat-config")) { | |||
1872 | log_error("Option --root is only supported for cat-config right now.")({ int _level = (((3))), _e = ((0)), _realm = (LOG_REALM_SYSTEMD ); (log_get_max_level_realm(_realm) >= ((_level) & 0x07 )) ? log_internal_realm(((_realm) << 10 | (_level)), _e , "../src/analyze/analyze.c", 1872, __func__, "Option --root is only supported for cat-config right now." ) : -abs(_e); }); | |||
1873 | return -EINVAL22; | |||
1874 | } | |||
1875 | ||||
1876 | return 1; /* work to do */ | |||
1877 | } | |||
1878 | ||||
1879 | int main(int argc, char *argv[]) { | |||
1880 | ||||
1881 | static const Verb verbs[] = { | |||
1882 | { "help", VERB_ANY((unsigned) -1), VERB_ANY((unsigned) -1), 0, help }, | |||
1883 | { "time", VERB_ANY((unsigned) -1), 1, VERB_DEFAULT, analyze_time }, | |||
1884 | { "blame", VERB_ANY((unsigned) -1), 1, 0, analyze_blame }, | |||
1885 | { "critical-chain", VERB_ANY((unsigned) -1), VERB_ANY((unsigned) -1), 0, analyze_critical_chain }, | |||
1886 | { "plot", VERB_ANY((unsigned) -1), 1, 0, analyze_plot }, | |||
1887 | { "dot", VERB_ANY((unsigned) -1), VERB_ANY((unsigned) -1), 0, dot }, | |||
1888 | { "log-level", VERB_ANY((unsigned) -1), 2, 0, get_or_set_log_level }, | |||
1889 | { "log-target", VERB_ANY((unsigned) -1), 2, 0, get_or_set_log_target }, | |||
1890 | /* The following four verbs are deprecated aliases */ | |||
1891 | { "set-log-level", 2, 2, 0, set_log_level }, | |||
1892 | { "get-log-level", VERB_ANY((unsigned) -1), 1, 0, get_log_level }, | |||
1893 | { "set-log-target", 2, 2, 0, set_log_target }, | |||
1894 | { "get-log-target", VERB_ANY((unsigned) -1), 1, 0, get_log_target }, | |||
1895 | { "dump", VERB_ANY((unsigned) -1), 1, 0, dump }, | |||
1896 | { "cat-config", 2, VERB_ANY((unsigned) -1), 0, cat_config }, | |||
1897 | { "unit-paths", 1, 1, 0, dump_unit_paths }, | |||
1898 | { "syscall-filter", VERB_ANY((unsigned) -1), VERB_ANY((unsigned) -1), 0, dump_syscall_filters }, | |||
1899 | { "verify", 2, VERB_ANY((unsigned) -1), 0, do_verify }, | |||
1900 | { "calendar", 2, VERB_ANY((unsigned) -1), 0, test_calendar }, | |||
1901 | { "service-watchdogs", VERB_ANY((unsigned) -1), 2, 0, service_watchdogs }, | |||
1902 | { "security", VERB_ANY((unsigned) -1), VERB_ANY((unsigned) -1), 0, do_security }, | |||
1903 | {} | |||
1904 | }; | |||
1905 | ||||
1906 | int r; | |||
1907 | ||||
1908 | setlocale(LC_ALL6, ""); | |||
1909 | setlocale(LC_NUMERIC1, "C"); /* we want to format/parse floats in C style */ | |||
1910 | ||||
1911 | log_parse_environment()log_parse_environment_realm(LOG_REALM_SYSTEMD); | |||
1912 | log_open(); | |||
1913 | ||||
1914 | r = parse_argv(argc, argv); | |||
1915 | if (r <= 0) | |||
1916 | goto finish; | |||
1917 | ||||
1918 | r = dispatch_verb(argc, argv, verbs, NULL((void*)0)); | |||
1919 | ||||
1920 | finish: | |||
1921 | pager_close(); | |||
1922 | ||||
1923 | strv_free(arg_dot_from_patterns); | |||
1924 | strv_free(arg_dot_to_patterns); | |||
1925 | ||||
1926 | return r < 0 ? EXIT_FAILURE1 : EXIT_SUCCESS0; | |||
1927 | } |