]> git.ipfire.org Git - thirdparty/systemd.git/blob - src/shared/path-lookup.h
tree-wide: remove Lennart's copyright lines
[thirdparty/systemd.git] / src / shared / path-lookup.h
1 /* SPDX-License-Identifier: LGPL-2.1+ */
2 #pragma once
3
4 #include <stdbool.h>
5
6 typedef struct LookupPaths LookupPaths;
7
8 #include "install.h"
9 #include "macro.h"
10
11 typedef enum LookupPathsFlags {
12 LOOKUP_PATHS_EXCLUDE_GENERATED = 1 << 0,
13 LOOKUP_PATHS_TEMPORARY_GENERATED = 1 << 1,
14 LOOKUP_PATHS_SPLIT_USR = 1 << 2,
15 } LookupPathsFlags;
16
17 struct LookupPaths {
18 /* Where we look for unit files. This includes the individual special paths below, but also any vendor
19 * supplied, static unit file paths. */
20 char **search_path;
21
22 /* Where we shall create or remove our installation symlinks, aka "configuration", and where the user/admin
23 * shall place his own unit files. */
24 char *persistent_config;
25 char *runtime_config;
26
27 /* Where to place generated unit files (i.e. those a "generator" tool generated). Note the special semantics of
28 * this directory: the generators are flushed each time a "systemctl daemon-reload" is issued. The user should
29 * not alter these directories directly. */
30 char *generator;
31 char *generator_early;
32 char *generator_late;
33
34 /* Where to place transient unit files (i.e. those created dynamically via the bus API). Note the special
35 * semantics of this directory: all units created transiently have their unit files removed as the transient
36 * unit is unloaded. The user should not alter this directory directly. */
37 char *transient;
38
39 /* Where the snippets created by "systemctl set-property" are placed. Note that for transient units, the
40 * snippets are placed in the transient directory though (see above). The user should not alter this directory
41 * directly. */
42 char *persistent_control;
43 char *runtime_control;
44
45 /* The root directory prepended to all items above, or NULL */
46 char *root_dir;
47
48 /* A temporary directory when running in test mode, to be nuked */
49 char *temporary_dir;
50 };
51
52 int lookup_paths_init(LookupPaths *p, UnitFileScope scope, LookupPathsFlags flags, const char *root_dir);
53 int xdg_user_dirs(char ***ret_config_dirs, char ***ret_data_dirs);
54 int xdg_user_runtime_dir(char **ret, const char *suffix);
55 int xdg_user_config_dir(char **ret, const char *suffix);
56 int xdg_user_data_dir(char **ret, const char *suffix);
57 bool path_is_user_data_dir(const char *path);
58 bool path_is_user_config_dir(const char *path);
59
60 int lookup_paths_reduce(LookupPaths *p);
61
62 int lookup_paths_mkdir_generator(LookupPaths *p);
63 void lookup_paths_trim_generator(LookupPaths *p);
64 void lookup_paths_flush_generator(LookupPaths *p);
65
66 void lookup_paths_free(LookupPaths *p);
67
68 char **generator_binary_paths(UnitFileScope scope);