]> git.ipfire.org Git - thirdparty/systemd.git/blame - src/core/path.h
tree-wide: drop license boilerplate
[thirdparty/systemd.git] / src / core / path.h
CommitLineData
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
01f78473
LP
8***/
9
10typedef struct Path Path;
c1ff5570 11typedef struct PathSpec PathSpec;
01f78473
LP
12
13#include "unit.h"
01f78473 14
01f78473
LP
15typedef enum PathType {
16 PATH_EXISTS,
8092a428 17 PATH_EXISTS_GLOB,
01f78473
LP
18 PATH_DIRECTORY_NOT_EMPTY,
19 PATH_CHANGED,
e9223856 20 PATH_MODIFIED,
01f78473
LP
21 _PATH_TYPE_MAX,
22 _PATH_TYPE_INVALID = -1
23} PathType;
24
25typedef struct PathSpec {
718db961
LP
26 Unit *unit;
27
01f78473
LP
28 char *path;
29
718db961 30 sd_event_source *event_source;
8fe914ec
LP
31
32 LIST_FIELDS(struct PathSpec, spec);
33
34 PathType type;
01f78473
LP
35 int inotify_fd;
36 int primary_wd;
01f78473 37
8fe914ec 38 bool previous_exists;
01f78473
LP
39} PathSpec;
40
718db961
LP
41int path_spec_watch(PathSpec *s, sd_event_io_handler_t handler);
42void path_spec_unwatch(PathSpec *s);
57020a3a
LP
43int path_spec_fd_event(PathSpec *s, uint32_t events);
44void path_spec_done(PathSpec *s);
45
46static inline bool path_spec_owns_inotify_fd(PathSpec *s, int fd) {
4b562198
MS
47 return s->inotify_fd == fd;
48}
49
cd43ca73
LP
50typedef enum PathResult {
51 PATH_SUCCESS,
52 PATH_FAILURE_RESOURCES,
07299350 53 PATH_FAILURE_START_LIMIT_HIT,
cd43ca73
LP
54 _PATH_RESULT_MAX,
55 _PATH_RESULT_INVALID = -1
56} PathResult;
57
01f78473 58struct Path {
ac155bb8 59 Unit meta;
01f78473
LP
60
61 LIST_HEAD(PathSpec, specs);
62
8fe914ec
LP
63 PathState state, deserialized_state;
64
672028dc 65 bool inotify_triggered;
0e456f97
LP
66
67 bool make_directory;
68 mode_t directory_mode;
cd43ca73
LP
69
70 PathResult result;
01f78473
LP
71};
72
74051b9b
LP
73void path_free_specs(Path *p);
74
01f78473
LP
75extern const UnitVTable path_vtable;
76
44a6b1b6
ZJS
77const char* path_type_to_string(PathType i) _const_;
78PathType path_type_from_string(const char *s) _pure_;
01f78473 79
44a6b1b6
ZJS
80const char* path_result_to_string(PathResult i) _const_;
81PathResult path_result_from_string(const char *s) _pure_;