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