]>
Commit | Line | Data |
---|---|---|
53e1b683 | 1 | /* SPDX-License-Identifier: LGPL-2.1+ */ |
c2f1db8f | 2 | #pragma once |
01f78473 | 3 | |
01f78473 | 4 | typedef struct Path Path; |
c1ff5570 | 5 | typedef struct PathSpec PathSpec; |
01f78473 LP |
6 | |
7 | #include "unit.h" | |
01f78473 | 8 | |
01f78473 LP |
9 | typedef 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 | ||
19 | typedef 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 |
35 | int path_spec_watch(PathSpec *s, sd_event_io_handler_t handler); |
36 | void path_spec_unwatch(PathSpec *s); | |
57020a3a LP |
37 | int path_spec_fd_event(PathSpec *s, uint32_t events); |
38 | void path_spec_done(PathSpec *s); | |
39 | ||
40 | static inline bool path_spec_owns_inotify_fd(PathSpec *s, int fd) { | |
4b562198 MS |
41 | return s->inotify_fd == fd; |
42 | } | |
43 | ||
cd43ca73 LP |
44 | typedef enum PathResult { |
45 | PATH_SUCCESS, | |
46 | PATH_FAILURE_RESOURCES, | |
07299350 | 47 | PATH_FAILURE_START_LIMIT_HIT, |
cd43ca73 LP |
48 | _PATH_RESULT_MAX, |
49 | _PATH_RESULT_INVALID = -1 | |
50 | } PathResult; | |
51 | ||
01f78473 | 52 | struct Path { |
ac155bb8 | 53 | Unit meta; |
01f78473 LP |
54 | |
55 | LIST_HEAD(PathSpec, specs); | |
56 | ||
8fe914ec LP |
57 | PathState state, deserialized_state; |
58 | ||
672028dc | 59 | bool inotify_triggered; |
0e456f97 LP |
60 | |
61 | bool make_directory; | |
62 | mode_t directory_mode; | |
cd43ca73 LP |
63 | |
64 | PathResult result; | |
01f78473 LP |
65 | }; |
66 | ||
74051b9b LP |
67 | void path_free_specs(Path *p); |
68 | ||
01f78473 LP |
69 | extern const UnitVTable path_vtable; |
70 | ||
44a6b1b6 ZJS |
71 | const char* path_type_to_string(PathType i) _const_; |
72 | PathType path_type_from_string(const char *s) _pure_; | |
01f78473 | 73 | |
44a6b1b6 ZJS |
74 | const char* path_result_to_string(PathResult i) _const_; |
75 | PathResult path_result_from_string(const char *s) _pure_; | |
57b7a260 FS |
76 | |
77 | DEFINE_CAST(PATH, Path); |