]>
Commit | Line | Data |
---|---|---|
53e1b683 | 1 | /* SPDX-License-Identifier: LGPL-2.1+ */ |
c2f1db8f | 2 | #pragma once |
01f78473 LP |
3 | |
4 | /*** | |
5 | This file is part of systemd. | |
6 | ||
7 | Copyright 2010 Lennart Poettering | |
8 | ||
9 | systemd is free software; you can redistribute it and/or modify it | |
5430f7f2 LP |
10 | under the terms of the GNU Lesser General Public License as published by |
11 | the Free Software Foundation; either version 2.1 of the License, or | |
01f78473 LP |
12 | (at your option) any later version. |
13 | ||
14 | systemd is distributed in the hope that it will be useful, but | |
15 | WITHOUT ANY WARRANTY; without even the implied warranty of | |
16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
5430f7f2 | 17 | Lesser General Public License for more details. |
01f78473 | 18 | |
5430f7f2 | 19 | You should have received a copy of the GNU Lesser General Public License |
01f78473 LP |
20 | along with systemd; If not, see <http://www.gnu.org/licenses/>. |
21 | ***/ | |
22 | ||
23 | typedef struct Path Path; | |
c1ff5570 | 24 | typedef struct PathSpec PathSpec; |
01f78473 LP |
25 | |
26 | #include "unit.h" | |
01f78473 | 27 | |
01f78473 LP |
28 | typedef enum PathType { |
29 | PATH_EXISTS, | |
8092a428 | 30 | PATH_EXISTS_GLOB, |
01f78473 LP |
31 | PATH_DIRECTORY_NOT_EMPTY, |
32 | PATH_CHANGED, | |
e9223856 | 33 | PATH_MODIFIED, |
01f78473 LP |
34 | _PATH_TYPE_MAX, |
35 | _PATH_TYPE_INVALID = -1 | |
36 | } PathType; | |
37 | ||
38 | typedef struct PathSpec { | |
718db961 LP |
39 | Unit *unit; |
40 | ||
01f78473 LP |
41 | char *path; |
42 | ||
718db961 | 43 | sd_event_source *event_source; |
8fe914ec LP |
44 | |
45 | LIST_FIELDS(struct PathSpec, spec); | |
46 | ||
47 | PathType type; | |
01f78473 LP |
48 | int inotify_fd; |
49 | int primary_wd; | |
01f78473 | 50 | |
8fe914ec | 51 | bool previous_exists; |
01f78473 LP |
52 | } PathSpec; |
53 | ||
718db961 LP |
54 | int path_spec_watch(PathSpec *s, sd_event_io_handler_t handler); |
55 | void path_spec_unwatch(PathSpec *s); | |
57020a3a LP |
56 | int path_spec_fd_event(PathSpec *s, uint32_t events); |
57 | void path_spec_done(PathSpec *s); | |
58 | ||
59 | static inline bool path_spec_owns_inotify_fd(PathSpec *s, int fd) { | |
4b562198 MS |
60 | return s->inotify_fd == fd; |
61 | } | |
62 | ||
cd43ca73 LP |
63 | typedef enum PathResult { |
64 | PATH_SUCCESS, | |
65 | PATH_FAILURE_RESOURCES, | |
07299350 | 66 | PATH_FAILURE_START_LIMIT_HIT, |
cd43ca73 LP |
67 | _PATH_RESULT_MAX, |
68 | _PATH_RESULT_INVALID = -1 | |
69 | } PathResult; | |
70 | ||
01f78473 | 71 | struct Path { |
ac155bb8 | 72 | Unit meta; |
01f78473 LP |
73 | |
74 | LIST_HEAD(PathSpec, specs); | |
75 | ||
8fe914ec LP |
76 | PathState state, deserialized_state; |
77 | ||
672028dc | 78 | bool inotify_triggered; |
0e456f97 LP |
79 | |
80 | bool make_directory; | |
81 | mode_t directory_mode; | |
cd43ca73 LP |
82 | |
83 | PathResult result; | |
01f78473 LP |
84 | }; |
85 | ||
74051b9b LP |
86 | void path_free_specs(Path *p); |
87 | ||
01f78473 LP |
88 | extern const UnitVTable path_vtable; |
89 | ||
44a6b1b6 ZJS |
90 | const char* path_type_to_string(PathType i) _const_; |
91 | PathType path_type_from_string(const char *s) _pure_; | |
01f78473 | 92 | |
44a6b1b6 ZJS |
93 | const char* path_result_to_string(PathResult i) _const_; |
94 | PathResult path_result_from_string(const char *s) _pure_; |