]> git.ipfire.org Git - thirdparty/systemd.git/blob - src/basic/unit-file.h
tree-wide: use -EINVAL for enum invalid values
[thirdparty/systemd.git] / src / basic / unit-file.h
1 /* SPDX-License-Identifier: LGPL-2.1-or-later */
2 #pragma once
3
4 #include <stdbool.h>
5
6 #include "hashmap.h"
7 #include "time-util.h"
8 #include "unit-name.h"
9
10 typedef enum UnitFileState UnitFileState;
11 typedef enum UnitFileScope UnitFileScope;
12 typedef struct LookupPaths LookupPaths;
13
14 enum UnitFileState {
15 UNIT_FILE_ENABLED,
16 UNIT_FILE_ENABLED_RUNTIME,
17 UNIT_FILE_LINKED,
18 UNIT_FILE_LINKED_RUNTIME,
19 UNIT_FILE_ALIAS,
20 UNIT_FILE_MASKED,
21 UNIT_FILE_MASKED_RUNTIME,
22 UNIT_FILE_STATIC,
23 UNIT_FILE_DISABLED,
24 UNIT_FILE_INDIRECT,
25 UNIT_FILE_GENERATED,
26 UNIT_FILE_TRANSIENT,
27 UNIT_FILE_BAD,
28 _UNIT_FILE_STATE_MAX,
29 _UNIT_FILE_STATE_INVALID = -EINVAL,
30 };
31
32 enum UnitFileScope {
33 UNIT_FILE_SYSTEM,
34 UNIT_FILE_GLOBAL,
35 UNIT_FILE_USER,
36 _UNIT_FILE_SCOPE_MAX,
37 _UNIT_FILE_SCOPE_INVALID = -EINVAL,
38 };
39
40 bool unit_type_may_alias(UnitType type) _const_;
41 bool unit_type_may_template(UnitType type) _const_;
42
43 int unit_symlink_name_compatible(const char *symlink, const char *target, bool instance_propagation);
44 int unit_validate_alias_symlink_and_warn(const char *filename, const char *target);
45
46 bool lookup_paths_timestamp_hash_same(const LookupPaths *lp, uint64_t timestamp_hash, uint64_t *ret_new);
47 int unit_file_build_name_map(
48 const LookupPaths *lp,
49 uint64_t *cache_timestamp_hash,
50 Hashmap **unit_ids_map,
51 Hashmap **unit_names_map,
52 Set **path_cache);
53
54 int unit_file_find_fragment(
55 Hashmap *unit_ids_map,
56 Hashmap *unit_name_map,
57 const char *unit_name,
58 const char **ret_fragment_path,
59 Set **ret_names);
60
61 const char* runlevel_to_target(const char *rl);