1 /* SPDX-License-Identifier: LGPL-2.1-or-later */
4 #include "core-forward.h"
7 typedef enum PathType
{
10 PATH_DIRECTORY_NOT_EMPTY
,
14 _PATH_TYPE_INVALID
= -EINVAL
,
17 typedef struct PathSpec
{
22 sd_event_source
*event_source
;
24 LIST_FIELDS(struct PathSpec
, spec
);
33 int path_spec_watch(PathSpec
*s
, sd_event_io_handler_t handler
);
34 void path_spec_unwatch(PathSpec
*s
);
35 int path_spec_fd_event(PathSpec
*s
, uint32_t events
);
36 void path_spec_done(PathSpec
*s
);
38 static inline bool path_spec_owns_inotify_fd(PathSpec
*s
, int fd
) {
39 return s
->inotify_fd
== fd
;
42 typedef enum PathResult
{
44 PATH_FAILURE_RESOURCES
,
45 PATH_FAILURE_START_LIMIT_HIT
,
46 PATH_FAILURE_UNIT_START_LIMIT_HIT
,
47 PATH_FAILURE_TRIGGER_LIMIT_HIT
,
49 _PATH_RESULT_INVALID
= -EINVAL
,
55 LIST_HEAD(PathSpec
, specs
);
57 PathState state
, deserialized_state
;
60 mode_t directory_mode
;
64 RateLimit trigger_limit
;
66 sd_event_source
*trigger_notify_event_source
;
69 typedef struct ActivationDetailsPath
{
70 ActivationDetails meta
;
71 char *trigger_path_filename
;
72 } ActivationDetailsPath
;
74 void path_free_specs(Path
*p
);
76 extern const UnitVTable path_vtable
;
77 extern const ActivationDetailsVTable activation_details_path_vtable
;
79 const char* path_type_to_string(PathType i
) _const_
;
80 PathType
path_type_from_string(const char *s
) _pure_
;
82 const char* path_result_to_string(PathResult i
) _const_
;
83 PathResult
path_result_from_string(const char *s
) _pure_
;
85 DEFINE_CAST(PATH
, Path
);
86 DEFINE_ACTIVATION_DETAILS_CAST(ACTIVATION_DETAILS_PATH
, ActivationDetailsPath
, PATH
);