]> git.ipfire.org Git - thirdparty/systemd.git/blame - src/path.h
path: convert failure field to enum
[thirdparty/systemd.git] / src / path.h
CommitLineData
03467c88 1/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
01f78473
LP
2
3#ifndef foopathhfoo
4#define foopathhfoo
5
6/***
7 This file is part of systemd.
8
9 Copyright 2010 Lennart Poettering
10
11 systemd is free software; you can redistribute it and/or modify it
12 under the terms of the GNU General Public License as published by
13 the Free Software Foundation; either version 2 of the License, or
14 (at your option) any later version.
15
16 systemd is distributed in the hope that it will be useful, but
17 WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 General Public License for more details.
20
21 You should have received a copy of the GNU General Public License
22 along with systemd; If not, see <http://www.gnu.org/licenses/>.
23***/
24
25typedef struct Path Path;
26
27#include "unit.h"
28#include "mount.h"
29
30typedef enum PathState {
31 PATH_DEAD,
32 PATH_WAITING,
33 PATH_RUNNING,
fdf20a31 34 PATH_FAILED,
01f78473
LP
35 _PATH_STATE_MAX,
36 _PATH_STATE_INVALID = -1
37} PathState;
38
39typedef enum PathType {
40 PATH_EXISTS,
8092a428 41 PATH_EXISTS_GLOB,
01f78473
LP
42 PATH_DIRECTORY_NOT_EMPTY,
43 PATH_CHANGED,
e9223856 44 PATH_MODIFIED,
01f78473
LP
45 _PATH_TYPE_MAX,
46 _PATH_TYPE_INVALID = -1
47} PathType;
48
49typedef struct PathSpec {
01f78473
LP
50 char *path;
51
8fe914ec
LP
52 Watch watch;
53
54 LIST_FIELDS(struct PathSpec, spec);
55
56 PathType type;
01f78473
LP
57 int inotify_fd;
58 int primary_wd;
01f78473 59
8fe914ec 60 bool previous_exists;
01f78473
LP
61} PathSpec;
62
57020a3a
LP
63int path_spec_watch(PathSpec *s, Unit *u);
64void path_spec_unwatch(PathSpec *s, Unit *u);
65int path_spec_fd_event(PathSpec *s, uint32_t events);
66void path_spec_done(PathSpec *s);
67
68static inline bool path_spec_owns_inotify_fd(PathSpec *s, int fd) {
4b562198
MS
69 return s->inotify_fd == fd;
70}
71
cd43ca73
LP
72typedef enum PathResult {
73 PATH_SUCCESS,
74 PATH_FAILURE_RESOURCES,
75 _PATH_RESULT_MAX,
76 _PATH_RESULT_INVALID = -1
77} PathResult;
78
01f78473 79struct Path {
ac155bb8 80 Unit meta;
01f78473
LP
81
82 LIST_HEAD(PathSpec, specs);
83
57020a3a 84 UnitRef unit;
01f78473 85
8fe914ec
LP
86 PathState state, deserialized_state;
87
672028dc 88 bool inotify_triggered;
0e456f97
LP
89
90 bool make_directory;
91 mode_t directory_mode;
cd43ca73
LP
92
93 PathResult result;
01f78473
LP
94};
95
96void path_unit_notify(Unit *u, UnitActiveState new_state);
97
98/* Called from the mount code figure out if a mount is a dependency of
99 * any of the paths of this path object */
100int path_add_one_mount_link(Path *p, Mount *m);
101
102extern const UnitVTable path_vtable;
103
104const char* path_state_to_string(PathState i);
105PathState path_state_from_string(const char *s);
106
107const char* path_type_to_string(PathType i);
108PathType path_type_from_string(const char *s);
109
cd43ca73
LP
110const char* path_result_to_string(PathResult i);
111PathResult path_result_from_string(const char *s);
112
01f78473 113#endif