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