chiark / gitweb /
main: fix help regarding --unit/systemd.unit=
[elogind.git] / src / path.h
1 /*-*- Mode: C; c-basic-offset: 8 -*-*/
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
25 typedef struct Path Path;
26
27 #include "unit.h"
28 #include "mount.h"
29
30 typedef enum PathState {
31         PATH_DEAD,
32         PATH_WAITING,
33         PATH_RUNNING,
34         PATH_MAINTAINANCE,
35         _PATH_STATE_MAX,
36         _PATH_STATE_INVALID = -1
37 } PathState;
38
39 typedef enum PathType {
40         PATH_EXISTS,
41         PATH_DIRECTORY_NOT_EMPTY,
42         PATH_CHANGED,
43         _PATH_TYPE_MAX,
44         _PATH_TYPE_INVALID = -1
45 } PathType;
46
47 typedef struct PathSpec {
48         PathType type;
49         char *path;
50
51         int inotify_fd;
52         int primary_wd;
53         bool previous_exists;
54
55         Watch watch;
56
57         LIST_FIELDS(struct PathSpec, spec);
58 } PathSpec;
59
60 struct Path {
61         Meta meta;
62
63         LIST_HEAD(PathSpec, specs);
64
65         PathState state, deserialized_state;
66         Unit *unit;
67
68         bool failure;
69 };
70
71 void path_unit_notify(Unit *u, UnitActiveState new_state);
72
73 /* Called from the mount code figure out if a mount is a dependency of
74  * any of the paths of this path object */
75 int path_add_one_mount_link(Path *p, Mount *m);
76
77 extern const UnitVTable path_vtable;
78
79 const char* path_state_to_string(PathState i);
80 PathState path_state_from_string(const char *s);
81
82 const char* path_type_to_string(PathType i);
83 PathType path_type_from_string(const char *s);
84
85 #endif