]> git.ipfire.org Git - thirdparty/systemd.git/blob - src/core/path.c
core: use SYNTHETIC_ERRNO() macro
[thirdparty/systemd.git] / src / core / path.c
1 /* SPDX-License-Identifier: LGPL-2.1-or-later */
2
3 #include <errno.h>
4 #include <sys/epoll.h>
5 #include <sys/inotify.h>
6 #include <unistd.h>
7
8 #include "bus-error.h"
9 #include "bus-util.h"
10 #include "dbus-path.h"
11 #include "dbus-unit.h"
12 #include "escape.h"
13 #include "fd-util.h"
14 #include "fs-util.h"
15 #include "glob-util.h"
16 #include "macro.h"
17 #include "mkdir.h"
18 #include "path.h"
19 #include "path-util.h"
20 #include "serialize.h"
21 #include "special.h"
22 #include "stat-util.h"
23 #include "string-table.h"
24 #include "string-util.h"
25 #include "unit-name.h"
26 #include "unit.h"
27
28 static const UnitActiveState state_translation_table[_PATH_STATE_MAX] = {
29 [PATH_DEAD] = UNIT_INACTIVE,
30 [PATH_WAITING] = UNIT_ACTIVE,
31 [PATH_RUNNING] = UNIT_ACTIVE,
32 [PATH_FAILED] = UNIT_FAILED,
33 };
34
35 static int path_dispatch_io(sd_event_source *source, int fd, uint32_t revents, void *userdata);
36
37 int path_spec_watch(PathSpec *s, sd_event_io_handler_t handler) {
38 static const int flags_table[_PATH_TYPE_MAX] = {
39 [PATH_EXISTS] = IN_DELETE_SELF|IN_MOVE_SELF|IN_ATTRIB,
40 [PATH_EXISTS_GLOB] = IN_DELETE_SELF|IN_MOVE_SELF|IN_ATTRIB,
41 [PATH_CHANGED] = IN_DELETE_SELF|IN_MOVE_SELF|IN_ATTRIB|IN_CLOSE_WRITE|IN_CREATE|IN_DELETE|IN_MOVED_FROM|IN_MOVED_TO,
42 [PATH_MODIFIED] = IN_DELETE_SELF|IN_MOVE_SELF|IN_ATTRIB|IN_CLOSE_WRITE|IN_CREATE|IN_DELETE|IN_MOVED_FROM|IN_MOVED_TO|IN_MODIFY,
43 [PATH_DIRECTORY_NOT_EMPTY] = IN_DELETE_SELF|IN_MOVE_SELF|IN_ATTRIB|IN_CREATE|IN_MOVED_TO,
44 };
45
46 bool exists = false;
47 char *slash, *oldslash = NULL;
48 int r;
49
50 assert(s);
51 assert(s->unit);
52 assert(handler);
53
54 path_spec_unwatch(s);
55
56 s->inotify_fd = inotify_init1(IN_NONBLOCK|IN_CLOEXEC);
57 if (s->inotify_fd < 0) {
58 r = -errno;
59 goto fail;
60 }
61
62 r = sd_event_add_io(s->unit->manager->event, &s->event_source, s->inotify_fd, EPOLLIN, handler, s);
63 if (r < 0)
64 goto fail;
65
66 (void) sd_event_source_set_description(s->event_source, "path");
67
68 /* This function assumes the path was passed through path_simplify()! */
69 assert(!strstr(s->path, "//"));
70
71 for (slash = strchr(s->path, '/'); ; slash = strchr(slash+1, '/')) {
72 char *cut = NULL;
73 int flags;
74 char tmp;
75
76 if (slash) {
77 cut = slash + (slash == s->path);
78 tmp = *cut;
79 *cut = '\0';
80
81 flags = IN_MOVE_SELF | IN_DELETE_SELF | IN_ATTRIB | IN_CREATE | IN_MOVED_TO;
82 } else
83 flags = flags_table[s->type];
84
85 r = inotify_add_watch(s->inotify_fd, s->path, flags);
86 if (r < 0) {
87 if (IN_SET(errno, EACCES, ENOENT)) {
88 if (cut)
89 *cut = tmp;
90 break;
91 }
92
93 /* This second call to inotify_add_watch() should fail like the previous
94 * one and is done for logging the error in a comprehensive way. */
95 r = inotify_add_watch_and_warn(s->inotify_fd, s->path, flags);
96 if (r < 0) {
97 if (cut)
98 *cut = tmp;
99 goto fail;
100 }
101
102 /* Hmm, we succeeded in adding the watch this time... let's continue. */
103 }
104 exists = true;
105
106 /* Path exists, we don't need to watch parent too closely. */
107 if (oldslash) {
108 char *cut2 = oldslash + (oldslash == s->path);
109 char tmp2 = *cut2;
110 *cut2 = '\0';
111
112 (void) inotify_add_watch(s->inotify_fd, s->path, IN_MOVE_SELF);
113 /* Error is ignored, the worst can happen is we get spurious events. */
114
115 *cut2 = tmp2;
116 }
117
118 if (cut)
119 *cut = tmp;
120
121 if (slash)
122 oldslash = slash;
123 else {
124 /* whole path has been iterated over */
125 s->primary_wd = r;
126 break;
127 }
128 }
129
130 if (!exists) {
131 r = log_error_errno(errno, "Failed to add watch on any of the components of %s: %m", s->path);
132 /* either EACCESS or ENOENT */
133 goto fail;
134 }
135
136 return 0;
137
138 fail:
139 path_spec_unwatch(s);
140 return r;
141 }
142
143 void path_spec_unwatch(PathSpec *s) {
144 assert(s);
145
146 s->event_source = sd_event_source_unref(s->event_source);
147 s->inotify_fd = safe_close(s->inotify_fd);
148 }
149
150 int path_spec_fd_event(PathSpec *s, uint32_t revents) {
151 union inotify_event_buffer buffer;
152 struct inotify_event *e;
153 ssize_t l;
154 int r = 0;
155
156 if (revents != EPOLLIN)
157 return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
158 "Got invalid poll event on inotify.");
159
160 l = read(s->inotify_fd, &buffer, sizeof(buffer));
161 if (l < 0) {
162 if (IN_SET(errno, EAGAIN, EINTR))
163 return 0;
164
165 return log_error_errno(errno, "Failed to read inotify event: %m");
166 }
167
168 FOREACH_INOTIFY_EVENT(e, buffer, l) {
169 if (IN_SET(s->type, PATH_CHANGED, PATH_MODIFIED) &&
170 s->primary_wd == e->wd)
171 r = 1;
172 }
173
174 return r;
175 }
176
177 static bool path_spec_check_good(PathSpec *s, bool initial, bool from_trigger_notify) {
178 bool b, good = false;
179
180 switch (s->type) {
181
182 case PATH_EXISTS:
183 good = access(s->path, F_OK) >= 0;
184 break;
185
186 case PATH_EXISTS_GLOB:
187 good = glob_exists(s->path) > 0;
188 break;
189
190 case PATH_DIRECTORY_NOT_EMPTY: {
191 int k;
192
193 k = dir_is_empty(s->path);
194 good = !(k == -ENOENT || k > 0);
195 break;
196 }
197
198 case PATH_CHANGED:
199 case PATH_MODIFIED:
200 b = access(s->path, F_OK) >= 0;
201 good = !initial && !from_trigger_notify && b != s->previous_exists;
202 s->previous_exists = b;
203 break;
204
205 default:
206 ;
207 }
208
209 return good;
210 }
211
212 static void path_spec_mkdir(PathSpec *s, mode_t mode) {
213 int r;
214
215 if (IN_SET(s->type, PATH_EXISTS, PATH_EXISTS_GLOB))
216 return;
217
218 r = mkdir_p_label(s->path, mode);
219 if (r < 0)
220 log_warning_errno(r, "mkdir(%s) failed: %m", s->path);
221 }
222
223 static void path_spec_dump(PathSpec *s, FILE *f, const char *prefix) {
224 const char *type;
225
226 assert_se(type = path_type_to_string(s->type));
227 fprintf(f, "%s%s: %s\n", prefix, type, s->path);
228 }
229
230 void path_spec_done(PathSpec *s) {
231 assert(s);
232 assert(s->inotify_fd == -1);
233
234 free(s->path);
235 }
236
237 static void path_init(Unit *u) {
238 Path *p = PATH(u);
239
240 assert(u);
241 assert(u->load_state == UNIT_STUB);
242
243 p->directory_mode = 0755;
244 }
245
246 void path_free_specs(Path *p) {
247 PathSpec *s;
248
249 assert(p);
250
251 while ((s = p->specs)) {
252 path_spec_unwatch(s);
253 LIST_REMOVE(spec, p->specs, s);
254 path_spec_done(s);
255 free(s);
256 }
257 }
258
259 static void path_done(Unit *u) {
260 Path *p = PATH(u);
261
262 assert(p);
263
264 path_free_specs(p);
265 }
266
267 static int path_add_mount_dependencies(Path *p) {
268 PathSpec *s;
269 int r;
270
271 assert(p);
272
273 LIST_FOREACH(spec, s, p->specs) {
274 r = unit_require_mounts_for(UNIT(p), s->path, UNIT_DEPENDENCY_FILE);
275 if (r < 0)
276 return r;
277 }
278
279 return 0;
280 }
281
282 static int path_verify(Path *p) {
283 assert(p);
284 assert(UNIT(p)->load_state == UNIT_LOADED);
285
286 if (!p->specs)
287 return log_unit_error_errno(UNIT(p), SYNTHETIC_ERRNO(ENOEXEC), "Path unit lacks path setting. Refusing.");
288
289 return 0;
290 }
291
292 static int path_add_default_dependencies(Path *p) {
293 int r;
294
295 assert(p);
296
297 if (!UNIT(p)->default_dependencies)
298 return 0;
299
300 r = unit_add_dependency_by_name(UNIT(p), UNIT_BEFORE, SPECIAL_PATHS_TARGET, true, UNIT_DEPENDENCY_DEFAULT);
301 if (r < 0)
302 return r;
303
304 if (MANAGER_IS_SYSTEM(UNIT(p)->manager)) {
305 r = unit_add_two_dependencies_by_name(UNIT(p), UNIT_AFTER, UNIT_REQUIRES, SPECIAL_SYSINIT_TARGET, true, UNIT_DEPENDENCY_DEFAULT);
306 if (r < 0)
307 return r;
308 }
309
310 return unit_add_two_dependencies_by_name(UNIT(p), UNIT_BEFORE, UNIT_CONFLICTS, SPECIAL_SHUTDOWN_TARGET, true, UNIT_DEPENDENCY_DEFAULT);
311 }
312
313 static int path_add_trigger_dependencies(Path *p) {
314 Unit *x;
315 int r;
316
317 assert(p);
318
319 if (!hashmap_isempty(UNIT(p)->dependencies[UNIT_TRIGGERS]))
320 return 0;
321
322 r = unit_load_related_unit(UNIT(p), ".service", &x);
323 if (r < 0)
324 return r;
325
326 return unit_add_two_dependencies(UNIT(p), UNIT_BEFORE, UNIT_TRIGGERS, x, true, UNIT_DEPENDENCY_IMPLICIT);
327 }
328
329 static int path_add_extras(Path *p) {
330 int r;
331
332 r = path_add_trigger_dependencies(p);
333 if (r < 0)
334 return r;
335
336 r = path_add_mount_dependencies(p);
337 if (r < 0)
338 return r;
339
340 return path_add_default_dependencies(p);
341 }
342
343 static int path_load(Unit *u) {
344 Path *p = PATH(u);
345 int r;
346
347 assert(u);
348 assert(u->load_state == UNIT_STUB);
349
350 r = unit_load_fragment_and_dropin(u, true);
351 if (r < 0)
352 return r;
353
354 if (u->load_state != UNIT_LOADED)
355 return 0;
356
357 r = path_add_extras(p);
358 if (r < 0)
359 return r;
360
361 return path_verify(p);
362 }
363
364 static void path_dump(Unit *u, FILE *f, const char *prefix) {
365 Path *p = PATH(u);
366 Unit *trigger;
367 PathSpec *s;
368
369 assert(p);
370 assert(f);
371
372 trigger = UNIT_TRIGGER(u);
373
374 fprintf(f,
375 "%sPath State: %s\n"
376 "%sResult: %s\n"
377 "%sUnit: %s\n"
378 "%sMakeDirectory: %s\n"
379 "%sDirectoryMode: %04o\n",
380 prefix, path_state_to_string(p->state),
381 prefix, path_result_to_string(p->result),
382 prefix, trigger ? trigger->id : "n/a",
383 prefix, yes_no(p->make_directory),
384 prefix, p->directory_mode);
385
386 LIST_FOREACH(spec, s, p->specs)
387 path_spec_dump(s, f, prefix);
388 }
389
390 static void path_unwatch(Path *p) {
391 PathSpec *s;
392
393 assert(p);
394
395 LIST_FOREACH(spec, s, p->specs)
396 path_spec_unwatch(s);
397 }
398
399 static int path_watch(Path *p) {
400 int r;
401 PathSpec *s;
402
403 assert(p);
404
405 LIST_FOREACH(spec, s, p->specs) {
406 r = path_spec_watch(s, path_dispatch_io);
407 if (r < 0)
408 return r;
409 }
410
411 return 0;
412 }
413
414 static void path_set_state(Path *p, PathState state) {
415 PathState old_state;
416 assert(p);
417
418 if (p->state != state)
419 bus_unit_send_pending_change_signal(UNIT(p), false);
420
421 old_state = p->state;
422 p->state = state;
423
424 if (!IN_SET(state, PATH_WAITING, PATH_RUNNING))
425 path_unwatch(p);
426
427 if (state != old_state)
428 log_unit_debug(UNIT(p), "Changed %s -> %s", path_state_to_string(old_state), path_state_to_string(state));
429
430 unit_notify(UNIT(p), state_translation_table[old_state], state_translation_table[state], 0);
431 }
432
433 static void path_enter_waiting(Path *p, bool initial, bool from_trigger_notify);
434
435 static int path_coldplug(Unit *u) {
436 Path *p = PATH(u);
437
438 assert(p);
439 assert(p->state == PATH_DEAD);
440
441 if (p->deserialized_state != p->state) {
442
443 if (IN_SET(p->deserialized_state, PATH_WAITING, PATH_RUNNING))
444 path_enter_waiting(p, true, false);
445 else
446 path_set_state(p, p->deserialized_state);
447 }
448
449 return 0;
450 }
451
452 static void path_enter_dead(Path *p, PathResult f) {
453 assert(p);
454
455 if (p->result == PATH_SUCCESS)
456 p->result = f;
457
458 unit_log_result(UNIT(p), p->result == PATH_SUCCESS, path_result_to_string(p->result));
459 path_set_state(p, p->result != PATH_SUCCESS ? PATH_FAILED : PATH_DEAD);
460 }
461
462 static void path_enter_running(Path *p) {
463 _cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
464 Unit *trigger;
465 int r;
466
467 assert(p);
468
469 /* Don't start job if we are supposed to go down */
470 if (unit_stop_pending(UNIT(p)))
471 return;
472
473 trigger = UNIT_TRIGGER(UNIT(p));
474 if (!trigger) {
475 log_unit_error(UNIT(p), "Unit to trigger vanished.");
476 path_enter_dead(p, PATH_FAILURE_RESOURCES);
477 return;
478 }
479
480 r = manager_add_job(UNIT(p)->manager, JOB_START, trigger, JOB_REPLACE, NULL, &error, NULL);
481 if (r < 0)
482 goto fail;
483
484 path_set_state(p, PATH_RUNNING);
485 path_unwatch(p);
486
487 return;
488
489 fail:
490 log_unit_warning(UNIT(p), "Failed to queue unit startup job: %s", bus_error_message(&error, r));
491 path_enter_dead(p, PATH_FAILURE_RESOURCES);
492 }
493
494 static bool path_check_good(Path *p, bool initial, bool from_trigger_notify) {
495 PathSpec *s;
496
497 assert(p);
498
499 LIST_FOREACH(spec, s, p->specs)
500 if (path_spec_check_good(s, initial, from_trigger_notify))
501 return true;
502
503 return false;
504 }
505
506 static void path_enter_waiting(Path *p, bool initial, bool from_trigger_notify) {
507 Unit *trigger;
508 int r;
509
510 /* If the triggered unit is already running, so are we */
511 trigger = UNIT_TRIGGER(UNIT(p));
512 if (trigger && !UNIT_IS_INACTIVE_OR_FAILED(unit_active_state(trigger))) {
513 path_set_state(p, PATH_RUNNING);
514 path_unwatch(p);
515 return;
516 }
517
518 if (path_check_good(p, initial, from_trigger_notify)) {
519 log_unit_debug(UNIT(p), "Got triggered.");
520 path_enter_running(p);
521 return;
522 }
523
524 r = path_watch(p);
525 if (r < 0)
526 goto fail;
527
528 /* Hmm, so now we have created inotify watches, but the file
529 * might have appeared/been removed by now, so we must
530 * recheck */
531
532 if (path_check_good(p, false, from_trigger_notify)) {
533 log_unit_debug(UNIT(p), "Got triggered.");
534 path_enter_running(p);
535 return;
536 }
537
538 path_set_state(p, PATH_WAITING);
539 return;
540
541 fail:
542 log_unit_warning_errno(UNIT(p), r, "Failed to enter waiting state: %m");
543 path_enter_dead(p, PATH_FAILURE_RESOURCES);
544 }
545
546 static void path_mkdir(Path *p) {
547 PathSpec *s;
548
549 assert(p);
550
551 if (!p->make_directory)
552 return;
553
554 LIST_FOREACH(spec, s, p->specs)
555 path_spec_mkdir(s, p->directory_mode);
556 }
557
558 static int path_start(Unit *u) {
559 Path *p = PATH(u);
560 int r;
561
562 assert(p);
563 assert(IN_SET(p->state, PATH_DEAD, PATH_FAILED));
564
565 r = unit_test_trigger_loaded(u);
566 if (r < 0)
567 return r;
568
569 r = unit_test_start_limit(u);
570 if (r < 0) {
571 path_enter_dead(p, PATH_FAILURE_START_LIMIT_HIT);
572 return r;
573 }
574
575 r = unit_acquire_invocation_id(u);
576 if (r < 0)
577 return r;
578
579 path_mkdir(p);
580
581 p->result = PATH_SUCCESS;
582 path_enter_waiting(p, true, false);
583
584 return 1;
585 }
586
587 static int path_stop(Unit *u) {
588 Path *p = PATH(u);
589
590 assert(p);
591 assert(IN_SET(p->state, PATH_WAITING, PATH_RUNNING));
592
593 path_enter_dead(p, PATH_SUCCESS);
594 return 1;
595 }
596
597 static int path_serialize(Unit *u, FILE *f, FDSet *fds) {
598 Path *p = PATH(u);
599 PathSpec *s;
600
601 assert(u);
602 assert(f);
603 assert(fds);
604
605 (void) serialize_item(f, "state", path_state_to_string(p->state));
606 (void) serialize_item(f, "result", path_result_to_string(p->result));
607
608 LIST_FOREACH(spec, s, p->specs) {
609 const char *type;
610 _cleanup_free_ char *escaped = NULL;
611
612 escaped = cescape(s->path);
613 if (!escaped)
614 return log_oom();
615
616 assert_se(type = path_type_to_string(s->type));
617 (void) serialize_item_format(f, "path-spec", "%s %i %s",
618 type,
619 s->previous_exists,
620 escaped);
621 }
622
623 return 0;
624 }
625
626 static int path_deserialize_item(Unit *u, const char *key, const char *value, FDSet *fds) {
627 Path *p = PATH(u);
628
629 assert(u);
630 assert(key);
631 assert(value);
632 assert(fds);
633
634 if (streq(key, "state")) {
635 PathState state;
636
637 state = path_state_from_string(value);
638 if (state < 0)
639 log_unit_debug(u, "Failed to parse state value: %s", value);
640 else
641 p->deserialized_state = state;
642
643 } else if (streq(key, "result")) {
644 PathResult f;
645
646 f = path_result_from_string(value);
647 if (f < 0)
648 log_unit_debug(u, "Failed to parse result value: %s", value);
649 else if (f != PATH_SUCCESS)
650 p->result = f;
651
652 } else if (streq(key, "path-spec")) {
653 int previous_exists, skip = 0, r;
654 _cleanup_free_ char *type_str = NULL;
655
656 if (sscanf(value, "%ms %i %n", &type_str, &previous_exists, &skip) < 2)
657 log_unit_debug(u, "Failed to parse path-spec value: %s", value);
658 else {
659 _cleanup_free_ char *unescaped = NULL;
660 PathType type;
661 PathSpec *s;
662
663 type = path_type_from_string(type_str);
664 if (type < 0) {
665 log_unit_warning(u, "Unknown path type \"%s\", ignoring.", type_str);
666 return 0;
667 }
668
669 r = cunescape(value+skip, 0, &unescaped);
670 if (r < 0) {
671 log_unit_warning_errno(u, r, "Failed to unescape serialize path: %m");
672 return 0;
673 }
674
675 LIST_FOREACH(spec, s, p->specs)
676 if (s->type == type &&
677 path_equal(s->path, unescaped)) {
678
679 s->previous_exists = previous_exists;
680 break;
681 }
682 }
683
684 } else
685 log_unit_debug(u, "Unknown serialization key: %s", key);
686
687 return 0;
688 }
689
690 _pure_ static UnitActiveState path_active_state(Unit *u) {
691 assert(u);
692
693 return state_translation_table[PATH(u)->state];
694 }
695
696 _pure_ static const char *path_sub_state_to_string(Unit *u) {
697 assert(u);
698
699 return path_state_to_string(PATH(u)->state);
700 }
701
702 static int path_dispatch_io(sd_event_source *source, int fd, uint32_t revents, void *userdata) {
703 PathSpec *s = userdata;
704 Path *p;
705 int changed;
706
707 assert(s);
708 assert(s->unit);
709 assert(fd >= 0);
710
711 p = PATH(s->unit);
712
713 if (!IN_SET(p->state, PATH_WAITING, PATH_RUNNING))
714 return 0;
715
716 /* log_debug("inotify wakeup on %s.", UNIT(p)->id); */
717
718 LIST_FOREACH(spec, s, p->specs)
719 if (path_spec_owns_inotify_fd(s, fd))
720 break;
721
722 if (!s) {
723 log_error("Got event on unknown fd.");
724 goto fail;
725 }
726
727 changed = path_spec_fd_event(s, revents);
728 if (changed < 0)
729 goto fail;
730
731 if (changed)
732 path_enter_running(p);
733 else
734 path_enter_waiting(p, false, false);
735
736 return 0;
737
738 fail:
739 path_enter_dead(p, PATH_FAILURE_RESOURCES);
740 return 0;
741 }
742
743 static void path_trigger_notify(Unit *u, Unit *other) {
744 Path *p = PATH(u);
745
746 assert(u);
747 assert(other);
748
749 /* Invoked whenever the unit we trigger changes state or gains or loses a job */
750
751 /* Filter out invocations with bogus state */
752 assert(UNIT_IS_LOAD_COMPLETE(other->load_state));
753
754 /* Don't propagate state changes from the triggered unit if we are already down */
755 if (!IN_SET(p->state, PATH_WAITING, PATH_RUNNING))
756 return;
757
758 /* Propagate start limit hit state */
759 if (other->start_limit_hit) {
760 path_enter_dead(p, PATH_FAILURE_UNIT_START_LIMIT_HIT);
761 return;
762 }
763
764 /* Don't propagate anything if there's still a job queued */
765 if (other->job)
766 return;
767
768 if (p->state == PATH_RUNNING &&
769 UNIT_IS_INACTIVE_OR_FAILED(unit_active_state(other))) {
770 log_unit_debug(UNIT(p), "Got notified about unit deactivation.");
771 path_enter_waiting(p, false, true);
772 } else if (p->state == PATH_WAITING &&
773 !UNIT_IS_INACTIVE_OR_FAILED(unit_active_state(other))) {
774 log_unit_debug(UNIT(p), "Got notified about unit activation.");
775 path_enter_waiting(p, false, true);
776 }
777 }
778
779 static void path_reset_failed(Unit *u) {
780 Path *p = PATH(u);
781
782 assert(p);
783
784 if (p->state == PATH_FAILED)
785 path_set_state(p, PATH_DEAD);
786
787 p->result = PATH_SUCCESS;
788 }
789
790 static const char* const path_type_table[_PATH_TYPE_MAX] = {
791 [PATH_EXISTS] = "PathExists",
792 [PATH_EXISTS_GLOB] = "PathExistsGlob",
793 [PATH_DIRECTORY_NOT_EMPTY] = "DirectoryNotEmpty",
794 [PATH_CHANGED] = "PathChanged",
795 [PATH_MODIFIED] = "PathModified",
796 };
797
798 DEFINE_STRING_TABLE_LOOKUP(path_type, PathType);
799
800 static const char* const path_result_table[_PATH_RESULT_MAX] = {
801 [PATH_SUCCESS] = "success",
802 [PATH_FAILURE_RESOURCES] = "resources",
803 [PATH_FAILURE_START_LIMIT_HIT] = "start-limit-hit",
804 [PATH_FAILURE_UNIT_START_LIMIT_HIT] = "unit-start-limit-hit",
805 };
806
807 DEFINE_STRING_TABLE_LOOKUP(path_result, PathResult);
808
809 const UnitVTable path_vtable = {
810 .object_size = sizeof(Path),
811
812 .sections =
813 "Unit\0"
814 "Path\0"
815 "Install\0",
816 .private_section = "Path",
817
818 .can_transient = true,
819 .can_fail = true,
820 .can_trigger = true,
821
822 .init = path_init,
823 .done = path_done,
824 .load = path_load,
825
826 .coldplug = path_coldplug,
827
828 .dump = path_dump,
829
830 .start = path_start,
831 .stop = path_stop,
832
833 .serialize = path_serialize,
834 .deserialize_item = path_deserialize_item,
835
836 .active_state = path_active_state,
837 .sub_state_to_string = path_sub_state_to_string,
838
839 .trigger_notify = path_trigger_notify,
840
841 .reset_failed = path_reset_failed,
842
843 .bus_set_property = bus_path_set_property,
844 };