]> git.ipfire.org Git - thirdparty/systemd.git/blame - src/core/path.h
core: propagate unit start limit hit state to triggering path unit
[thirdparty/systemd.git] / src / core / path.h
CommitLineData
53e1b683 1/* SPDX-License-Identifier: LGPL-2.1+ */
c2f1db8f 2#pragma once
01f78473 3
01f78473 4typedef struct Path Path;
c1ff5570 5typedef struct PathSpec PathSpec;
01f78473
LP
6
7#include "unit.h"
01f78473 8
01f78473
LP
9typedef enum PathType {
10 PATH_EXISTS,
8092a428 11 PATH_EXISTS_GLOB,
01f78473
LP
12 PATH_DIRECTORY_NOT_EMPTY,
13 PATH_CHANGED,
e9223856 14 PATH_MODIFIED,
01f78473
LP
15 _PATH_TYPE_MAX,
16 _PATH_TYPE_INVALID = -1
17} PathType;
18
19typedef struct PathSpec {
718db961
LP
20 Unit *unit;
21
01f78473
LP
22 char *path;
23
718db961 24 sd_event_source *event_source;
8fe914ec
LP
25
26 LIST_FIELDS(struct PathSpec, spec);
27
28 PathType type;
01f78473
LP
29 int inotify_fd;
30 int primary_wd;
01f78473 31
8fe914ec 32 bool previous_exists;
01f78473
LP
33} PathSpec;
34
718db961
LP
35int path_spec_watch(PathSpec *s, sd_event_io_handler_t handler);
36void path_spec_unwatch(PathSpec *s);
57020a3a
LP
37int path_spec_fd_event(PathSpec *s, uint32_t events);
38void path_spec_done(PathSpec *s);
39
40static inline bool path_spec_owns_inotify_fd(PathSpec *s, int fd) {
4b562198
MS
41 return s->inotify_fd == fd;
42}
43
cd43ca73
LP
44typedef enum PathResult {
45 PATH_SUCCESS,
46 PATH_FAILURE_RESOURCES,
07299350 47 PATH_FAILURE_START_LIMIT_HIT,
47ab8f73 48 PATH_FAILURE_UNIT_START_LIMIT_HIT,
cd43ca73
LP
49 _PATH_RESULT_MAX,
50 _PATH_RESULT_INVALID = -1
51} PathResult;
52
01f78473 53struct Path {
ac155bb8 54 Unit meta;
01f78473
LP
55
56 LIST_HEAD(PathSpec, specs);
57
8fe914ec
LP
58 PathState state, deserialized_state;
59
0e456f97
LP
60 bool make_directory;
61 mode_t directory_mode;
cd43ca73
LP
62
63 PathResult result;
01f78473
LP
64};
65
74051b9b
LP
66void path_free_specs(Path *p);
67
01f78473
LP
68extern const UnitVTable path_vtable;
69
44a6b1b6
ZJS
70const char* path_type_to_string(PathType i) _const_;
71PathType path_type_from_string(const char *s) _pure_;
01f78473 72
44a6b1b6
ZJS
73const char* path_result_to_string(PathResult i) _const_;
74PathResult path_result_from_string(const char *s) _pure_;
57b7a260
FS
75
76DEFINE_CAST(PATH, Path);